[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-hidl.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-hidl.spec
^
|
|
[-]
[+]
|
Deleted |
_service:tar_git:pulseaudio-modules-droid-hidl-1.2.0.tar.bz2/src/hidl/common.h
^
|
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- *
- * Contact: Juho Hämäläinen <juho.hamalainen@jolla.com>
- *
- * These PulseAudio Modules are free software; you can redistribute
- * it and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA.
- */
-
-#ifndef __HIDL_PASSTHROUGH_COMMON__
-#define __HIDL_PASSTHROUGH_COMMON__
-
-#include <stdlib.h>
-
-#define HELPER_NAME "hidl-helper"
-
-#define HIDL_PASSTHROUGH_PATH "/org/sailfishos/hidlpassthrough"
-#define HIDL_PASSTHROUGH_IFACE "org.SailfishOS.HIDLPassthrough"
-
-#define HIDL_PASSTHROUGH_METHOD_GET_PARAMETERS "get_parameters"
-#define HIDL_PASSTHROUGH_METHOD_SET_PARAMETERS "set_parameters"
-
-#define PULSE_ENV_LOG_LEVEL "PULSE_LOG"
-#define PULSE_LOG_LEVEL_DEBUG (4)
-
-static inline void log_init(unsigned int *level) {
- const char *e;
-
- if ((e = getenv(PULSE_ENV_LOG_LEVEL))) {
- *level = atoi(e);
-
- if (*level > PULSE_LOG_LEVEL_DEBUG)
- *level = PULSE_LOG_LEVEL_DEBUG;
- }
-}
-
-#endif
|
[-]
[+]
|
Deleted |
_service:tar_git:pulseaudio-modules-droid-hidl-1.2.0.tar.bz2/src/hidl/dbus-comms.c
^
|
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- *
- * Contact: Juho Hämäläinen <juho.hamalainen@jolla.com>
- *
- * This application is free software; you can redistribute
- * it and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation
- * version 2.1 of the License.
- *
- * This application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this application; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA.
- */
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include "common.h"
-#include "logging.h"
-#include "dbus-comms.h"
-
-#define CONNECT_RETRY_TIMEOUT_S (1)
-
-struct dbus_comms {
- gchar *address;
- guint connect_source;
- GDBusConnection *dbus;
- dbus_comms_connected_cb cb;
- void *userdata;
-};
-
-static gint
-dbus_call(
- DBusComms *c,
- const gchar *method,
- const gchar *args,
- gchar **reply_str)
-{
- gint ret = 1;
- GDBusMessage *msg = NULL;
- GDBusMessage *reply = NULL;
- GError *error = NULL;
-
- g_assert(c);
- g_assert(method);
- g_assert(args);
-
- if (reply_str)
- *reply_str = NULL;
-
- if (!c->dbus) {
- ERR("No connection (%s)", c->address);
- goto out;
- }
-
- msg = g_dbus_message_new_method_call(NULL,
- HIDL_PASSTHROUGH_PATH,
- HIDL_PASSTHROUGH_IFACE,
- method);
- g_dbus_message_set_body(msg, g_variant_new("(s)", args));
- reply = g_dbus_connection_send_message_with_reply_sync(c->dbus,
- msg,
- G_DBUS_SEND_MESSAGE_FLAGS_NONE,
- -1,
- NULL, /* out_serial */
- NULL, /* cancellable */
- &error);
- if (!reply) {
- ERR("Failed to call %s(): %s", method, error->message);
- goto out;
- }
-
- if (g_dbus_message_get_message_type(reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
- ERR("Failed to call %s()", method);
- goto out;
- }
-
- if (reply_str)
- *reply_str = g_strdup(g_dbus_message_get_arg0(reply));
- ret = 0;
-
-out:
- if (error)
- g_error_free(error);
- if (msg)
- g_object_unref(msg);
- if (reply)
- g_object_unref(reply);
-
- return ret;
-}
-
-gint
-dbus_comms_set_parameters(
- DBusComms *c,
- const gchar *key_value_pairs)
-{
- g_assert(c);
- g_assert(key_value_pairs);
-
- return dbus_call(c, HIDL_PASSTHROUGH_METHOD_SET_PARAMETERS, key_value_pairs, NULL);
-}
-
-gint
-dbus_comms_get_parameters(
- DBusComms *c,
- const gchar *keys,
- gchar **reply_values)
-{
- g_assert(c);
- g_assert(keys);
- g_assert(reply_values);
-
- return dbus_call(c, HIDL_PASSTHROUGH_METHOD_GET_PARAMETERS, keys, reply_values);
-}
-
-static gboolean
-dbus_init_cb(
- gpointer user_data)
-{
- DBusComms *c = user_data;
- GError *error = NULL;
-
- c->dbus = g_dbus_connection_new_for_address_sync(c->address,
- G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
- NULL, /* observer */
- NULL, /* cancellable */
- &error);
-
-
- if (!c->dbus) {
- DBG("Could not connect to %s, try again in %d seconds...", c->address, CONNECT_RETRY_TIMEOUT_S);
- return G_SOURCE_CONTINUE;
- }
-
- if (error) {
- DBG("Could not connect to %s: %s", c->address, error->message);
- g_error_free(error);
- return G_SOURCE_CONTINUE;
- }
-
- DBG("Connected to DBus socket %s", c->address);
- c->connect_source = 0;
- if (c->cb) {
- c->cb(c, TRUE, c->userdata);
- }
- return G_SOURCE_REMOVE;
-}
-
-static void
-dbus_deinit(
- DBusComms *c)
-{
- if (c->connect_source) {
- g_source_remove(c->connect_source);
- c->connect_source = 0;
- }
-
- if (c->dbus) {
- g_object_unref(c->dbus);
- c->dbus= NULL;
- }
-}
-
-void
-dbus_comms_init_delayed(
- DBusComms *c,
- dbus_comms_connected_cb cb,
- void *userdata)
-{
- dbus_deinit(c);
- DBG("Using address: %s", c->address);
- c->cb = cb;
- c->userdata = userdata;
- c->connect_source = g_timeout_add_seconds(1, dbus_init_cb, c);
-}
-
-DBusComms*
-dbus_comms_new(
- const gchar *address)
-{
- DBusComms *c;
-
- c = g_new0(DBusComms, 1);
- c->address = g_strdup(address);
-
- return c;
-}
-
-void
-dbus_comms_done(
- DBusComms *c)
|
[-]
[+]
|
Deleted |
_service:tar_git:pulseaudio-modules-droid-hidl-1.2.0.tar.bz2/src/hidl/dbus-comms.h
^
|
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- *
- * Contact: Juho Hämäläinen <juho.hamalainen@jolla.com>
- *
- * This application is free software; you can redistribute
- * it and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation
- * version 2.1 of the License.
- *
- * This application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this application; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA.
- */
-
-#ifndef _HIDL_HELPER_DBUS_COMMS_
-#define _HIDL_HELPER_DBUS_COMMS_
-
-typedef struct dbus_comms DBusComms;
-
-DBusComms*
-dbus_comms_new(
- const gchar *address);
-
-void
-dbus_comms_done(
- DBusComms *c);
-
-typedef void (*dbus_comms_connected_cb)(DBusComms *c, gboolean connected, void *userdata);
-
-void
-dbus_comms_init_delayed(
- DBusComms *c,
- dbus_comms_connected_cb cb,
- void *userdata);
-
-gint
-dbus_comms_get_parameters(
- DBusComms *c,
- const gchar *keys,
- gchar **reply_values);
-
-gint
-dbus_comms_set_parameters(
- DBusComms *c,
- const gchar *key_value_pairs);
-
-
-#endif
|
[-]
[+]
|
Deleted |
_service:tar_git:pulseaudio-modules-droid-hidl-1.2.0.tar.bz2/src/hidl/hidl-helper.c
^
|
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * 2019 Slava Monich <slava.monich@jolla.com>
- *
- * Contact: Juho Hämäläinen <juho.hamalainen@jolla.com>
- *
- * This application is free software; you can redistribute
- * it and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation
- * version 2.1 of the License.
- *
- * This application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this application; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA.
- */
-
-#include <gbinder.h>
-#include <glib-unix.h>
-#include <gutil_log.h>
-
-#include <android-config.h>
-#if !defined(ANDROID_VERSION_MAJOR)
-#error "ANDROID_VERSION_MAJOR not defined. Did you get your headers via extract-headers.sh?"
-#endif
-
-#if ANDROID_VERSION_MAJOR <= 7
-#define DEFAULT_TYPE_STR "af"
-#define DEFAULT_BIND_IDX (17)
-#elif ANDROID_VERSION_MAJOR <= 8
-#define DEFAULT_TYPE_STR "af"
-#define DEFAULT_BIND_IDX (18)
-#else
-#define DEFAULT_TYPE_STR "hidl"
-#define DEFAULT_BIND_IDX (18)
-#endif
-
-#include "common.h"
-#include "impl.h"
-#include "logging.h"
-gboolean _app_standalone = FALSE;
-
-#define RET_OK (0)
-#define RET_INVARG (2)
-
-static const char pname[] = HELPER_NAME;
-
-typedef struct app App;
-
-struct app {
- GMainLoop* loop;
- int ret;
- gint type;
- AppConfig config;
-};
-
-static AppImplementation app_implementations[APP_MAX] = {
- { "hidl", app_hidl_init, app_hidl_wait, app_hidl_done },
- { "af", app_af_init, app_af_wait, app_af_done },
-};
-
-
-static gboolean
-app_signal(
- gpointer user_data)
-{
- App* app = user_data;
-
- DBG("Caught signal, %s shutting down...", pname);
- g_main_loop_quit(app->loop);
- return G_SOURCE_CONTINUE;
-}
-
-static void
-app_run(
- App* app)
-{
- guint sigtrm = g_unix_signal_add(SIGTERM, app_signal, app);
- guint sigint = g_unix_signal_add(SIGINT, app_signal, app);
-
- g_main_loop_run(app->loop);
-
- g_source_remove(sigtrm);
- g_source_remove(sigint);
-}
-
-static gboolean
-parse_app_type(
- App *app,
- const gchar *type_str)
-{
- guint i;
-
- if (!type_str)
- type_str = DEFAULT_TYPE_STR;
-
- for (i = 0; i < sizeof(app_implementations) / sizeof(app_implementations[0]); i++) {
- if (!g_strcmp0(type_str, app_implementations[i].name)) {
- DBG("Using %s implementation", app_implementations[i].name);
- app->type = i;
- break;
- }
- }
-
- return app->type >= 0;
-}
-
-static gboolean
-app_init(
- App* app,
- int argc,
- char* argv[])
-{
- guint level = 0;
- gboolean ok = FALSE;
- GError* error = NULL;
- gchar *type_str = NULL;
- GOptionContext* options = NULL;
-
- GOptionEntry entries[] = {
- { "type", 't', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
- &type_str, "Passthrough type, af/hidl (default " DEFAULT_TYPE_STR ")", NULL },
- { "standalone", 's', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE,
- &_app_standalone, "Standalone execution.", NULL },
- { "verbose", 'v', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE,
- &app->config.verbose, "Enable verbose output", NULL },
- { NULL, 0, 0, 0, NULL, NULL, NULL }
- };
-
- options = g_option_context_new("<PulseAudio DBus address>");
-
- gutil_log_timestamp = FALSE;
- gutil_log_set_type(GLOG_TYPE_STDOUT, pname);
- gutil_log_default.level = GLOG_LEVEL_ERR;
- log_init(&level);
-
- g_option_context_add_main_entries(options, entries, NULL);
- if (!g_option_context_parse(options, &argc, &argv, &error))
- goto fail;
-
- if (app->config.verbose || level == PULSE_LOG_LEVEL_DEBUG)
- gutil_log_default.level = GLOG_LEVEL_VERBOSE;
-
- if (argc <= 1)
- goto fail;
-
- app->config.address = g_strdup(argv[1]);
- app->config.binder_index = DEFAULT_BIND_IDX;
-
- if (!parse_app_type(app, type_str)) {
- ERR("Unknown type '%s'", type_str ? type_str : DEFAULT_TYPE_STR);
- goto fail;
- }
- g_free(type_str);
-
- app->loop = g_main_loop_new(NULL, TRUE);
- if (!app_implementations[app->type].init(app->loop, &app->config))
- goto fail;
-
- ok = TRUE;
- app->ret = RET_OK;
- g_option_context_free(options);
-
- return ok;
-
-fail:
- g_free(type_str);
-
- if (options)
- g_option_context_free(options);
-
- if (error) {
- ERR("Options: %s", error->message);
- g_error_free(error);
- }
-
- if (!app->config.address)
- ERR("Address is not defined for %s", pname);
-
- return ok;
-}
-
-static void
-app_deinit(
- App *app)
-{
- if (app->type >= 0 && app->ret == RET_OK)
- app->ret = app_implementations[app->type].done();
- g_free(app->config.address);
-}
-
-int main(int argc, char* argv[])
-{
- App app;
|
[-]
[+]
|
Deleted |
_service:tar_git:pulseaudio-modules-droid-hidl-1.2.0.tar.bz2/src/hidl/impl-af.c
^
|
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- *
- * Contact: Juho Hämäläinen <juho.hamalainen@jolla.com>
- *
- * This application is free software; you can redistribute
- * it and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation
- * version 2.1 of the License.
- *
- * This application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this application; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA.
- */
-
-#include <gbinder.h>
-#include <glib-unix.h>
-
-#include "common.h"
-#include "impl.h"
-#include "logging.h"
-#include "dbus-comms.h"
-
-#define BINDER_DEVICE GBINDER_DEFAULT_BINDER
-#define SERVICE_NAME "media.audio_flinger"
-#define SERVICE_IFACE "android.media.IAudioFlinger"
-
-
-enum af_methods {
- AF_SET_PARAMETERS = GBINDER_FIRST_CALL_TRANSACTION, /* + starting index */
- AF_GET_PARAMETERS,
- AF_REGISTER_CLIENT,
-};
-
-typedef struct af_app AfApp;
-
-struct af_app {
- GMainLoop* loop;
- const AppConfig *config;
- gulong presence_id;
- GBinderServiceManager* sm;
- GBinderLocalObject *local;
- DBusComms *dbus;
-};
-
-static AfApp _app;
-
-static guint
-binder_idx(
- AfApp *app,
- guint idx)
-{
- return app->config->binder_index + idx;
-}
-
-static GBinderLocalReply*
-app_reply(
- GBinderLocalObject* obj,
- GBinderRemoteRequest* req,
- guint code,
- guint flags,
- int* status,
- void* user_data)
-{
- AfApp* app = user_data;
- const char* iface;
- GBinderLocalReply* reply = NULL;
-
- iface = gbinder_remote_request_interface(req);
- if (g_strcmp0(iface, SERVICE_IFACE)) {
- ERR("Unexpected interface \"%s\"", iface);
- *status = -1;
- return NULL;
- }
-
- if (code == binder_idx(app, AF_SET_PARAMETERS)) {
- GBinderReader reader;
- int token;
- int iohandle;
- const char *key_value_pairs;
-
- gbinder_remote_request_init_reader(req, &reader);
- gbinder_reader_read_int32(&reader, &token);
- gbinder_reader_read_int32(&reader, &iohandle);
- key_value_pairs = gbinder_reader_read_string8(&reader);
-
- DBG("(%d) setParameters(%d, \"%s\")", token, iohandle, key_value_pairs);
- dbus_comms_set_parameters(app->dbus, key_value_pairs);
-
- reply = gbinder_local_object_new_reply(obj);
- gbinder_local_reply_append_int32(reply, 0);
- *status = 0;
- } else if (code == binder_idx(app, AF_GET_PARAMETERS)) {
- GBinderReader reader;
- int token;
- int iohandle;
- const char *keys;
- char *key_value_pairs = NULL;
-
- gbinder_remote_request_init_reader(req, &reader);
- gbinder_reader_read_int32(&reader, &token);
- gbinder_reader_read_int32(&reader, &iohandle);
- keys = gbinder_reader_read_string8(&reader);
-
- dbus_comms_get_parameters(app->dbus, keys, &key_value_pairs);
- DBG("(%d) getParameters(%d, \"%s\"): \"%s\"", token, iohandle, keys, key_value_pairs);
-
- reply = gbinder_local_object_new_reply(obj);
- gbinder_local_reply_append_string8(reply, key_value_pairs ? key_value_pairs : "");
- g_free(key_value_pairs);
- *status = 0;
- } else if (code == binder_idx(app, AF_REGISTER_CLIENT)) {
- DBG("register client");
- *status = 0;
- } else {
- ERR("Unknown code (%u)", code);
- *status = 0;
- }
-
- return reply;
-}
-
-static void
-app_add_service_done(
- GBinderServiceManager* sm,
- int status,
- void *user_data)
-{
- AfApp *app = user_data;
-
- if (status == GBINDER_STATUS_OK) {
- DBG("Added " SERVICE_NAME);
- } else {
- ERR("Failed to add " SERVICE_NAME " (%d)", status);
- g_main_loop_quit(app->loop);
- }
-}
-
-static void
-sm_presence_handler(
- GBinderServiceManager* sm,
- void* user_data)
-{
- AfApp* app = user_data;
-
- if (gbinder_servicemanager_is_present(app->sm)) {
- DBG("Service manager has reappeared.");
- gbinder_servicemanager_add_service(app->sm, SERVICE_NAME, app->local,
- app_add_service_done, app);
- } else {
- DBG("Service manager has died.");
- }
-}
-
-static void
-dbus_connected_cb(
- DBusComms *c,
- gboolean connected,
- void *userdata)
-{
- AfApp *app = userdata;
-
- if (connected) {
- DBG("DBus up, connect service");
- gbinder_servicemanager_add_service(app->sm, SERVICE_NAME, app->local,
- app_add_service_done, app);
- }
-}
-
-gboolean
-app_af_init(
- GMainLoop *mainloop,
- const AppConfig *config)
-{
- memset(&_app, 0, sizeof(_app));
- _app.loop = mainloop;
- _app.config = config;
- _app.sm = gbinder_servicemanager_new(BINDER_DEVICE);
- _app.local = gbinder_servicemanager_new_local_object(_app.sm,
- SERVICE_IFACE,
- app_reply,
- &_app);
- _app.presence_id = gbinder_servicemanager_add_presence_handler(_app.sm,
- sm_presence_handler,
- &_app);
- _app.dbus = dbus_comms_new(_app.config->address);
- dbus_comms_init_delayed(_app.dbus, dbus_connected_cb, &_app);
-
- return TRUE;
-}
-
-gboolean
-app_af_wait(
|
[-]
[+]
|
Deleted |
_service:tar_git:pulseaudio-modules-droid-hidl-1.2.0.tar.bz2/src/hidl/impl-hidl.c
^
|
@@ -1,429 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- * 2019 Slava Monich <slava.monich@jolla.com>
- *
- * Contact: Juho Hämäläinen <juho.hamalainen@jolla.com>
- *
- * This application is free software; you can redistribute
- * it and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation
- * version 2.1 of the License.
- *
- * This application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this application; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA.
- */
-
-#include <gbinder.h>
-#include <glib-unix.h>
-
-#include "common.h"
-#include "impl.h"
-#include "logging.h"
-#include "dbus-comms.h"
-
-#define BINDER_DEVICE GBINDER_DEFAULT_HWBINDER
-#define QCRIL_IFACE_1_0(x) "vendor.qti.hardware.radio.am@1.0::" x
-#define QCRIL_AUDIO_1_0 QCRIL_IFACE_1_0("IQcRilAudio")
-#define QCRIL_AUDIO_CALLBACK_1_0 QCRIL_IFACE_1_0("IQcRilAudioCallback")
-
-#define OFONO_RIL_SUBSCRIPTION_CONF "/etc/ofono/ril_subscription.conf"
-#define OFONO_RIL_SUBSCRIPTION_D "/etc/ofono/ril_subscription.d"
-#define OFONO_RIL_SLOTS_MAX (4)
-
-
-enum qcril_audio_methods {
- QCRIL_AUDIO_SET_CALLBACK = GBINDER_FIRST_CALL_TRANSACTION,
- QCRIL_AUDIO_SET_ERROR
-};
-
-enum qcril_audio_callback_methods {
- QCRIL_AUDIO_CALLBACK_GET_PARAMETERS = GBINDER_FIRST_CALL_TRANSACTION,
- QCRIL_AUDIO_CALLBACK_SET_PARAMETERS
-};
-
-typedef struct hidl_app HidlApp;
-
-typedef struct am_client {
- HidlApp *app;
- char* fqname;
- gchar* slot;
- GBinderServiceManager* sm;
- GBinderLocalObject* local;
- GBinderRemoteObject* remote;
- GBinderClient* client;
- gulong wait_id;
- gulong death_id;
-} AmClient;
-
-struct hidl_app {
- GMainLoop* loop;
- const AppConfig *config;
- GBinderServiceManager* sm;
- GSList* clients;
- DBusComms *dbus;
-};
-
-static HidlApp _app;
-
-static void
-am_client_registration_handler(
- GBinderServiceManager* sm,
- const char* name,
- void* user_data);
-
-static void
-am_remote_died(
- GBinderRemoteObject* obj,
- void* user_data)
-{
- AmClient* am = user_data;
-
- DBG("%s has died", am->fqname);
- gbinder_remote_object_unref(am->remote);
- am->remote = NULL;
-
- /* Wait for it to re-appear */
- am->wait_id = gbinder_servicemanager_add_registration_handler(am->sm,
- am->fqname, am_client_registration_handler, am);
-}
-
-/* IQcRilAudioCallback::getParameters(string str) generates (string) */
-static gboolean
-am_client_callback_get_parameters(
- AmClient* am,
- const char* str,
- GBinderLocalReply* reply)
-{
- if (str) {
- gchar* result = NULL;
- dbus_comms_get_parameters(am->app->dbus, str, &result);
-
- if (result) {
- GBinderWriter writer;
- gbinder_local_reply_init_writer(reply, &writer);
- gbinder_writer_append_int32(&writer, 0 /* OK */);
- gbinder_writer_append_hidl_string(&writer, result);
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-/* IQcRilAudioCallback::setParameters(string str) generates (int32_t) */
-static gboolean
-am_client_callback_set_parameters(
- AmClient* am,
- const char* str,
- GBinderLocalReply* reply)
-{
- if (str) {
- GBinderWriter writer;
- guint32 result = 0;
-
- result = dbus_comms_set_parameters(am->app->dbus, str);
- gbinder_local_reply_init_writer(reply, &writer);
- gbinder_writer_append_int32(&writer, 0 /* OK */);
- gbinder_writer_append_int32(&writer, result);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-static GBinderLocalReply*
-am_client_callback(
- GBinderLocalObject* obj,
- GBinderRemoteRequest* req,
- guint code,
- guint flags,
- int* status,
- void* user_data)
-{
- AmClient* am = user_data;
- const char* iface = gbinder_remote_request_interface(req);
-
- if (!g_strcmp0(iface, QCRIL_AUDIO_CALLBACK_1_0)) {
- GBinderReader reader;
- GBinderLocalReply* reply = gbinder_local_object_new_reply(obj);
- const char* str;
-
- gbinder_remote_request_init_reader(req, &reader);
- str = gbinder_reader_read_hidl_string_c(&reader);
- switch (code) {
- case QCRIL_AUDIO_CALLBACK_GET_PARAMETERS:
- DBG("IQcRilAudioCallback::getParameters %s %s", am->slot, str);
- if (am_client_callback_get_parameters(am, str, reply)) {
- return reply;
- }
- break;
- case QCRIL_AUDIO_CALLBACK_SET_PARAMETERS:
- DBG("IQcRilAudioCallback::setParameters %s %s", am->slot, str);
- if (am_client_callback_set_parameters(am, str, reply)) {
- return reply;
- }
- break;
- }
- /* We haven't used the reply */
- gbinder_local_reply_unref(reply);
- }
- ERR("Unexpected callback %s %u", iface, code);
- *status = GBINDER_STATUS_FAILED;
- return NULL;
-}
-
-static gboolean
-am_client_connect(
- AmClient* am)
-{
- int status = 0;
- am->remote = gbinder_servicemanager_get_service_sync(am->sm,
- am->fqname, &status); /* auto-released reference */
-
- if (am->remote) {
- GBinderLocalRequest* req;
-
- DBG("Connected to %s", am->fqname);
- gbinder_remote_object_ref(am->remote);
- am->client = gbinder_client_new(am->remote, QCRIL_AUDIO_1_0);
- am->death_id = gbinder_remote_object_add_death_handler(am->remote,
- am_remote_died, am);
|
[-]
[+]
|
Deleted |
_service:tar_git:pulseaudio-modules-droid-hidl-1.2.0.tar.bz2/src/hidl/impl.h
^
|
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- *
- * Contact: Juho Hämäläinen <juho.hamalainen@jolla.com>
- *
- * This application is free software; you can redistribute
- * it and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation
- * version 2.1 of the License.
- *
- * This application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this application; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA.
- */
-
-#ifndef _HIDL_HELPER_IMPL_
-#define _HIDL_HELPER_IMPL_
-
-enum app_type {
- APP_HIDL,
- APP_AF,
- APP_MAX
-};
-
-typedef struct app_config {
- gchar *address;
- gboolean verbose;
- gint binder_index;
-} AppConfig;
-
-typedef gboolean (*app_init_cb)(GMainLoop *mainloop, const AppConfig *config);
-typedef gboolean (*app_wait_cb)(void);
-typedef gint (*app_done_cb)(void);
-
-typedef struct app_implementation {
- const char *name;
- app_init_cb init;
- app_wait_cb wait;
- app_done_cb done;
-} AppImplementation;
-
-gboolean
-app_af_init(
- GMainLoop *mainloop,
- const AppConfig *config);
-
-gboolean
-app_af_wait(
- void);
-
-gint
-app_af_done(
- void);
-
-
-gboolean
-app_hidl_init(
- GMainLoop *mainloop,
- const AppConfig *config);
-
-gboolean
-app_hidl_wait(
- void);
-
-gint
-app_hidl_done(
- void);
-
-#endif
|
[-]
[+]
|
Deleted |
_service:tar_git:pulseaudio-modules-droid-hidl-1.2.0.tar.bz2/src/hidl/logging.h
^
|
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2019 Jolla Ltd.
- *
- * Contact: Juho Hämäläinen <juho.hamalainen@jolla.com>
- *
- * This application is free software; you can redistribute
- * it and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation
- * version 2.1 of the License.
- *
- * This application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this application; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- * USA.
- */
-
-#ifndef _HIDL_HELPER_LOGGING_
-#define _HIDL_HELPER_LOGGING_
-
-#include <gutil_log.h>
-
-extern gboolean _app_standalone;
-
-#define DBGP(...) do { \
- printf(__VA_ARGS__); \
- printf("\n"); \
- fflush(stdout); \
- } while(0)
-
-#define DBG(...) do { \
- if (gutil_log_default.level == GLOG_LEVEL_VERBOSE) {\
- if (_app_standalone) \
- GDEBUG(__VA_ARGS__); \
- else \
- DBGP(__VA_ARGS__); \
- } \
- } while(0)
-
-#define ERR(...) do { \
- if (_app_standalone) \
- GERR(__VA_ARGS__); \
- else \
- DBGP(__VA_ARGS__); \
- } while(0)
-
-#endif
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-hidl-1.3.0.tar.bz2/README.md
^
|
@@ -11,6 +11,13 @@
that parses droid configuration and loads the hw module to
PulseAudio global object.
+Helper binary is separated to its own package, audiosystem-passthrough.
+When using the helper from PulseAudio if the defaults are not suitable
+add configuration to PulseAudio sysconfig file. Available options are
+
+ AUDIOSYSTEM_PASSTHROUGH_TYPE={qti,af}
+ AUDIOSYSTEM_PASSTHROUGH_IDX={17,18} # only applicable to af type
+
Normally just compiling the package against your adaptation should
provide working module, but for testing one can also run the helper
binary by hand.
@@ -19,6 +26,6 @@
load-module module-droid-hidl helper=false
-Run the helper in standalone mode (type can be either hidl or af),
+Run the helper in standalone mode (type can be either qti or af),
- /usr/libexec/pulse/hidl-helper unix:path=.../pulse/dbus-socket -s -v -t <type>
+ /usr/libexec/audiosystem-passthrough/audiosystem-passthrough -v -a unix:path=.../pulse/dbus-socket -t <type>
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-hidl-1.3.0.tar.bz2/configure.ac
^
|
@@ -177,17 +177,9 @@
AC_SUBST(DROIDUTIL_CFLAGS)
AC_SUBST(DROIDUTIL_LIBS)
-PKG_CHECK_MODULES([LIBGBINDER], [libgbinder] >= 1.0.32)
-AC_SUBST(LIBGBINDER_CFLAGS)
-AC_SUBST(LIBGBINDER_LIBS)
-
-PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.56])
-AC_SUBST(GLIB_CFLAGS)
-AC_SUBST(GLIB_LIBS)
-
-PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.56])
-AC_SUBST(GIO_CFLAGS)
-AC_SUBST(GIO_LIBS)
+PKG_CHECK_MODULES([PASSTHROUGH_COMMON], [audiosystem-passthrough >= 1.0.0])
+AC_SUBST(PASSTHROUGH_COMMON_CFLAGS)
+AC_SUBST(PASSTHROUGH_COMMON_LIBS)
AC_ARG_WITH(
[module-dir],
@@ -201,15 +193,6 @@
AC_SUBST(modlibexecdir)
-AC_ARG_WITH([helper-dir],
- AS_HELP_STRING([--with-helper-dir], [Directory where to install the helper binary (defaults to ${libexecdir}/pulse).]),
- [helperdir=$withval], [helperdir="${libexecdir}/pulse"]
-)
-AC_SUBST(helperdir)
-
-HELPER_LOCATION_CFLAGS="-DHIDL_HELPER_LOCATION=\"\\\"${helperdir}\\\"\""
-AC_SUBST([HELPER_LOCATION_CFLAGS])
-
AC_MSG_CHECKING([If we are using hardfp tool chain])
case `echo | gcc -v -xc -o - - 2>&1 | grep COLLECT_GCC_OPTIONS | tail -1` in
*float-abi=hard*) hardfp=yes; AC_MSG_RESULT([yes]) ;;
@@ -239,5 +222,4 @@
prefix: ${prefix}
modules directory: ${modlibexecdir}
- helper directory: ${helperdir}
"
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-hidl-1.3.0.tar.bz2/src/hidl/Makefile.am
^
|
@@ -3,7 +3,7 @@
$(DBUS_LIBS) \
$(DROIDUTIL_LIBS)
AM_CFLAGS = \
- $(HELPER_LOCATION_CFLAGS) \
+ $(PASSTHROUGH_COMMON_CFLAGS) \
$(PULSEAUDIO_CFLAGS) \
$(DBUS_CFLAGS) \
$(DROIDHEADERS_CFLAGS) \
@@ -20,11 +20,3 @@
module_droid_hidl_la_LDFLAGS = -module -avoid-version -Wl,-no-undefined -Wl,-z,noexecstack
module_droid_hidl_la_LIBADD = $(AM_LIBADD) -lm
module_droid_hidl_la_CFLAGS = $(AM_CFLAGS)
-
-pulselibexecdir=$(libexecdir)/pulse
-
-pulselibexec_PROGRAMS = hidl-helper
-
-hidl_helper_SOURCES = hidl-helper.c dbus-comms.c impl-af.c impl-hidl.c
-hidl_helper_LDADD = $(LIBGBINDER_LIBS) $(GLIB_LIBS) $(GIO_LIBS)
-hidl_helper_CFLAGS = $(DROIDHEADERS_CFLAGS) $(LIBGBINDER_CFLAGS) $(GLIB_CFLAGS) $(GIO_CFLAGS)
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-hidl-1.3.0.tar.bz2/src/hidl/module-droid-hidl.c
^
|
@@ -51,11 +51,11 @@
#include <droid/droid-util.h>
-#include "common.h"
+#include <audiosystem-passthrough/common.h>
#include "module-droid-hidl-symdef.h"
PA_MODULE_AUTHOR("Juho Hämäläinen");
-PA_MODULE_DESCRIPTION("Droid HIDL passthrough");
+PA_MODULE_DESCRIPTION("Droid AudioSystem passthrough");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_USAGE(
"module_id=<which droid hw module to load, default primary> "
@@ -70,9 +70,19 @@
#define DEFAULT_MODULE_ID "primary"
-#define HELPER_BINARY HIDL_HELPER_LOCATION "/" HELPER_NAME
+#define HELPER_BINARY PASSTHROUGH_HELPER_DIR "/" PASSTHROUGH_HELPER_EXE
#define BUFFER_MAX (512)
+#if ANDROID_VERSION_MAJOR <= 7
+#define DEFAULT_BINDER_IDX "17"
+#elif ANDROID_VERSION_MAJOR <= 8
+#define DEFAULT_BINDER_IDX "18"
+#else
+#define DEFAULT_BINDER_IDX "18"
+#endif
+
+#define QTI_INTERFACE_NAME "IQcRilAudio"
+
struct userdata {
pa_core *core;
pa_module *module;
@@ -94,13 +104,13 @@
return false;
}
-static void hidl_get_parameters(DBusConnection *conn, DBusMessage *msg, void *userdata);
-static void hidl_set_parameters(DBusConnection *conn, DBusMessage *msg, void *userdata);
+static void get_parameters(DBusConnection *conn, DBusMessage *msg, void *userdata);
+static void set_parameters(DBusConnection *conn, DBusMessage *msg, void *userdata);
-enum hidl_passthrough_methods {
- HIDL_PASSTHROUGH_GET_PARAMETERS,
- HIDL_PASSTHROUGH_SET_PARAMETERS,
- HIDL_PASSTHROUGH_METHOD_MAX
+enum audiosystem_passthrough_methods {
+ PASSTHROUGH_GET_PARAMETERS,
+ PASSTHROUGH_SET_PARAMETERS,
+ PASSTHROUGH_METHOD_MAX
};
static pa_dbus_arg_info get_parameters_args[] = {
@@ -111,25 +121,25 @@
{ "key_value_pairs", "s", "in" }
};
-static pa_dbus_method_handler hidl_passthrough_method_handlers[HIDL_PASSTHROUGH_METHOD_MAX] = {
- [HIDL_PASSTHROUGH_GET_PARAMETERS] = {
- .method_name = HIDL_PASSTHROUGH_METHOD_GET_PARAMETERS,
+static pa_dbus_method_handler passthrough_method_handlers[PASSTHROUGH_METHOD_MAX] = {
+ [PASSTHROUGH_GET_PARAMETERS] = {
+ .method_name = AUDIOSYSTEM_PASSTHROUGH_GET_PARAMETERS,
.arguments = get_parameters_args,
.n_arguments = sizeof(get_parameters_args) / sizeof(get_parameters_args[0]),
- .receive_cb = hidl_get_parameters
+ .receive_cb = get_parameters
},
- [HIDL_PASSTHROUGH_SET_PARAMETERS] = {
- .method_name = HIDL_PASSTHROUGH_METHOD_SET_PARAMETERS,
+ [PASSTHROUGH_SET_PARAMETERS] = {
+ .method_name = AUDIOSYSTEM_PASSTHROUGH_SET_PARAMETERS,
.arguments = set_parameters_args,
.n_arguments = sizeof(set_parameters_args) / sizeof(set_parameters_args[0]),
- .receive_cb = hidl_set_parameters
+ .receive_cb = set_parameters
},
};
-static pa_dbus_interface_info hidl_passthrough_info = {
- .name = HIDL_PASSTHROUGH_IFACE,
- .method_handlers = hidl_passthrough_method_handlers,
- .n_method_handlers = HIDL_PASSTHROUGH_METHOD_MAX,
+static pa_dbus_interface_info passthrough_info = {
+ .name = AUDIOSYSTEM_PASSTHROUGH_IFACE,
+ .method_handlers = passthrough_method_handlers,
+ .n_method_handlers = PASSTHROUGH_METHOD_MAX,
.property_handlers = NULL,
.n_property_handlers = 0,
.get_all_properties_cb = NULL,
@@ -143,20 +153,20 @@
u->dbus_protocol = pa_dbus_protocol_get(u->core);
- pa_dbus_protocol_add_interface(u->dbus_protocol, HIDL_PASSTHROUGH_PATH, &hidl_passthrough_info, u);
- pa_dbus_protocol_register_extension(u->dbus_protocol, HIDL_PASSTHROUGH_IFACE);
+ pa_dbus_protocol_add_interface(u->dbus_protocol, AUDIOSYSTEM_PASSTHROUGH_PATH, &passthrough_info, u);
+ pa_dbus_protocol_register_extension(u->dbus_protocol, AUDIOSYSTEM_PASSTHROUGH_IFACE);
}
static void dbus_done(struct userdata *u) {
pa_assert(u);
- pa_dbus_protocol_unregister_extension(u->dbus_protocol, HIDL_PASSTHROUGH_IFACE);
- pa_dbus_protocol_remove_interface(u->dbus_protocol, HIDL_PASSTHROUGH_PATH, hidl_passthrough_info.name);
+ pa_dbus_protocol_unregister_extension(u->dbus_protocol, AUDIOSYSTEM_PASSTHROUGH_IFACE);
+ pa_dbus_protocol_remove_interface(u->dbus_protocol, AUDIOSYSTEM_PASSTHROUGH_PATH, passthrough_info.name);
pa_dbus_protocol_unref(u->dbus_protocol);
u->dbus_protocol = NULL;
}
-static void hidl_get_parameters(DBusConnection *conn, DBusMessage *msg, void *userdata) {
+static void get_parameters(DBusConnection *conn, DBusMessage *msg, void *userdata) {
struct userdata *u;
DBusMessage *reply;
DBusError error;
@@ -193,7 +203,7 @@
dbus_error_free(&error);
}
-static void hidl_set_parameters(DBusConnection *conn, DBusMessage *msg, void *userdata) {
+static void set_parameters(DBusConnection *conn, DBusMessage *msg, void *userdata) {
struct userdata *u;
DBusError error;
char *key_value_pairs = NULL;
@@ -250,9 +260,9 @@
memset(buffer, 0, BUFFER_MAX);
if ((r = pa_read(u->fd, buffer, BUFFER_MAX, NULL)) > 0) {
if (log_level_debug())
- pa_log_debug("[" HELPER_NAME "] %s", buffer);
+ pa_log_debug("[" PASSTHROUGH_HELPER_EXE "] %s", buffer);
else
- pa_log("[" HELPER_NAME "] %s", buffer);
+ pa_log("[" PASSTHROUGH_HELPER_EXE "] %s", buffer);
} else if (r < 0) {
pa_log("failed read");
io_free(u);
@@ -266,11 +276,55 @@
}
}
+static bool file_exists(const char *path) {
+ return access(path, F_OK) == 0 ? true : false;
+}
+
+static bool string_in_file(const char *path, const char *string) {
+ char line[512];
+ FILE *f = NULL;
+ bool found = false;
+
+ pa_assert(path);
+
+ if (!file_exists(path))
+ goto done;
+
+ if (!(f = pa_fopen_cloexec(path, "r"))) {
+ pa_log_warn("open('%s') failed: %s", path, pa_cstrerror(errno));
+ goto done;
+ }
+
+ while (fgets(line, sizeof(line), f)) {
+ if (strstr(line, string)) {
+ found = true;
+ break;
+ }
+ }
+
+done:
+ if (f)
+ fclose(f);
+
+ return found;
+}
+
+static void helper_setenv(const char *dbus_address, const char *impl_type, const char *idx) {
+ setenv(ENV_AUDIOSYSTEM_PASSTHROUGH_ADDRESS, dbus_address, 1);
+ setenv(ENV_AUDIOSYSTEM_PASSTHROUGH_TYPE, impl_type, 0);
+ setenv(ENV_AUDIOSYSTEM_PASSTHROUGH_IDX, idx, 0);
+}
+
+static void helper_unsetenv(void) {
+ unsetenv(ENV_AUDIOSYSTEM_PASSTHROUGH_ADDRESS);
+ unsetenv(ENV_AUDIOSYSTEM_PASSTHROUGH_TYPE);
+ unsetenv(ENV_AUDIOSYSTEM_PASSTHROUGH_IDX);
+}
+
int pa__init(pa_module *m) {
pa_modargs *ma = NULL;
const char *module_id;
bool helper = true;
- char *dbus_address = NULL;
pa_assert(m);
@@ -301,15 +355,41 @@
dbus_init(u);
|