[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid.spec
^
|
|
[-]
[+]
|
Deleted |
_service:tar_git:pulseaudio-modules-droid-11.1.68.tar.bz2/src/common/droid-util.h
^
|
@@ -1,456 +0,0 @@
-#ifndef foodroidutilfoo
-#define foodroidutilfoo
-
-/*
- * Copyright (C) 2013 Jolla Ltd.
- *
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <pulsecore/core-util.h>
-#include <pulsecore/macro.h>
-#include <pulsecore/mutex.h>
-#include <pulsecore/strlist.h>
-#include <pulsecore/atomic.h>
-
-#include <android-config.h>
-
-#if !defined(ANDROID_VERSION_MAJOR) || !defined(ANDROID_VERSION_MINOR) || !defined(ANDROID_VERSION_PATCH)
-#error "ANDROID_VERSION_* not defined. Did you get your headers via extract-headers.sh?"
-#endif
-
-#if ANDROID_VERSION_MAJOR == 4 && ANDROID_VERSION_MINOR == 1
-#include "droid-util-41qc.h"
-#else
-#include "droid-util-audio.h"
-#endif
-
-/* We currently support API version up-to 3.0 */
-#define DROID_API_VERSION_SUPPORT HARDWARE_DEVICE_API_VERSION(3, 0)
-
-#if AUDIO_DEVICE_API_VERSION_CURRENT > DROID_API_VERSION_SUPPORT
-#warning Compiling against higher audio device API version than currently supported!
-#warning Compile likely fails or module may malfunction.
-#endif
-
-#define AUDIO_API_VERSION_MAJ ((AUDIO_DEVICE_API_VERSION_CURRENT >> 8) & 0xff)
-#define AUDIO_API_VERSION_MIN (AUDIO_DEVICE_API_VERSION_CURRENT & 0xff)
-
-#define AUDIO_API_VERSION_GET_MAJ(x) ((x >> 8) & 0xff)
-#define AUDIO_API_VERSION_GET_MIN(x) (x & 0xff)
-
-#if defined(QCOM_BSP) && (AUDIO_API_VERSION_MAJ >= 3)
-#define DROID_AUDIO_HAL_USE_VSID
-#endif
-
-#define PROP_DROID_DEVICES "droid.devices"
-#define PROP_DROID_FLAGS "droid.flags"
-#define PROP_DROID_HW_MODULE "droid.hw_module"
-#define PROP_DROID_API_STRING "droid-hal"
-
-#define PROP_DROID_OUTPUT_PRIMARY "droid.output.primary"
-#define PROP_DROID_OUTPUT_LOW_LATENCY "droid.output.low_latency"
-#define PROP_DROID_OUTPUT_MEDIA_LATENCY "droid.output.media_latency"
-#define PROP_DROID_OUTPUT_OFFLOAD "droid.output.offload"
-#define PROP_DROID_INPUT_BUILTIN "droid.input.builtin"
-#define PROP_DROID_INPUT_EXTERNAL "droid.input.external"
-
-#define PA_DROID_PRIMARY_DEVICE "primary"
-
-typedef struct pa_droid_hw_module pa_droid_hw_module;
-typedef struct pa_droid_stream pa_droid_stream;
-typedef struct pa_droid_output_stream pa_droid_output_stream;
-typedef struct pa_droid_input_stream pa_droid_input_stream;
-typedef struct pa_droid_card_data pa_droid_card_data;
-typedef int (*common_set_parameters_cb_t)(pa_droid_card_data *card_data, const char *str);
-
-typedef struct pa_droid_config_audio pa_droid_config_audio;
-typedef struct pa_droid_config_hw_module pa_droid_config_hw_module;
-
-typedef struct pa_droid_quirks pa_droid_quirks;
-
-typedef enum pa_droid_hook {
- PA_DROID_HOOK_INPUT_CHANNEL_MAP_CHANGED, /* Call data: pa_droid_stream */
- PA_DROID_HOOK_INPUT_BUFFER_SIZE_CHANGED, /* Call data: pa_droid_stream */
- PA_DROID_HOOK_MAX
-} pa_droid_hook_t;
-
-
-struct pa_droid_hw_module {
- PA_REFCNT_DECLARE;
-
- pa_core *core;
- char *shared_name;
-
- pa_droid_config_audio *config;
- const pa_droid_config_hw_module *enabled_module;
- pa_mutex *hw_mutex;
- pa_mutex *output_mutex;
- pa_mutex *input_mutex;
-
- struct hw_module_t *hwmod;
- audio_hw_device_t *device;
-
- const char *module_id;
-
- uint32_t stream_out_id;
- uint32_t stream_in_id;
-
- pa_idxset *outputs;
- pa_idxset *inputs;
- pa_hook_slot *sink_put_hook_slot;
- pa_hook_slot *sink_unlink_hook_slot;
- pa_hook_slot *source_put_hook_slot;
- pa_hook_slot *source_unlink_hook_slot;
-
- pa_atomic_t active_outputs;
-
- pa_droid_quirks *quirks;
- pa_hook hooks[PA_DROID_HOOK_MAX];
-};
-
-struct pa_droid_output_stream {
- struct audio_stream_out *stream;
- pa_sample_spec sample_spec;
- pa_channel_map channel_map;
- uint32_t flags;
- uint32_t device;
-};
-
-struct pa_droid_input_stream {
- struct audio_stream_in *stream;
- pa_sample_spec sample_spec;
- pa_channel_map channel_map;
- pa_sample_spec input_sample_spec;
- pa_channel_map input_channel_map;
- uint32_t flags;
- uint32_t device;
- audio_devices_t all_devices;
- bool merged;
-};
-
-struct pa_droid_stream {
- PA_REFCNT_DECLARE;
-
- pa_droid_hw_module *module;
- size_t buffer_size;
- void *data;
-
- pa_droid_output_stream *output;
- pa_droid_input_stream *input;
-};
-
-struct pa_droid_card_data {
- void *userdata;
- /* General functions */
- char *module_id;
- common_set_parameters_cb_t set_parameters;
-};
-
-#define AUDIO_MAX_SAMPLING_RATES (32)
-
-typedef struct pa_droid_config_global {
- uint32_t audio_hal_version;
- audio_devices_t attached_output_devices;
- audio_devices_t default_output_device;
- audio_devices_t attached_input_devices;
-} pa_droid_config_global;
-
-typedef struct pa_droid_config_output {
- const pa_droid_config_hw_module *module;
-
- char *name;
- uint32_t sampling_rates[AUDIO_MAX_SAMPLING_RATES]; /* (uint32_t) -1 -> dynamic */
- audio_channel_mask_t channel_masks; /* 0 -> dynamic */
- audio_format_t formats; /* 0 -> dynamic */
- audio_devices_t devices;
- audio_output_flags_t flags;
-
- struct pa_droid_config_output *next;
-} pa_droid_config_output;
-
-typedef struct pa_droid_config_input {
- const pa_droid_config_hw_module *module;
-
- char *name;
- uint32_t sampling_rates[AUDIO_MAX_SAMPLING_RATES]; /* (uint32_t) -1 -> dynamic */
- audio_channel_mask_t channel_masks; /* 0 -> dynamic */
- audio_format_t formats; /* 0 -> dynamic */
- audio_devices_t devices;
-#if AUDIO_API_VERSION_MAJ >= 3
- audio_input_flags_t flags;
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/README
^
|
@@ -14,6 +14,7 @@
* 5.x
* 6.0.x
* 7.x
+ * 8.x
Headers for defining devices and strings for different droid versions are in
src/common/droid-util-audio.h (legacy headers for Jolla 1 in droid-util-41qc.h).
@@ -49,6 +50,35 @@
Components
==========
+common
+------
+
+The common part of PulseAudio Droid modules contains library for handling
+most operations towards audio HAL.
+
+### Audio policy configuration parsing
+
+To populate our configuration structs there exists two parsers, legacy parser
+for old .conf format present in Android versions 7.0 and older and new xml
+format present from version 7.0 upwards. The legacy format is obsoleted in
+version 7.0 but by default still in use and most 7.0 adaptations probably
+contain the legacy format. But 8.0 adaptations and up start to include only
+the new style xml format configuration files.
+
+### Configuration files
+
+By default new style xml format is tried first and if it is not found old
+config is read next. If the configuration is in non-default location for
+some reason "config" module argument (available for all modules, card, sink,
+and source) can be used to point to the configuration file location.
+
+By default files are tried in following order,
+
+ /vendor/etc/audio_policy_configuration.xml (new xml format)
+ /vendor/etc/audio_policy.conf (legacy format)
+ /system/etc/audio_policy_configuration.xml (new xml format)
+ /system/etc/audio_policy.conf (legacy format)
+
module-droid-card
-----------------
@@ -56,11 +86,6 @@
configuration, creates profiles and loads sinks and sources based on the
selected profile.
-Droid-card reads configuration from /vendor/etc/audio_policy.conf or
-/system/etc/audio_policy.conf, depending on which is found first. If vendor
-config is found, configuration is read from there, otherwise from system
-configuration.
-
default profile
---------------
@@ -301,6 +326,11 @@
doing voicecall routing. If there is no voicecall audio you can
try enabling this quirk so that the realcall parameter is applied
when switching to voicecall profile.
+ * unload_call_exit
+ * Disabled by default.
+ * Some HAL module implementations get stuck in mutex or segfault when
+ trying to unload the module. To avoid confusing segfaults call
+ exit(0) instead of calling unload for the module.
For example, to disable input_atoi and enable close_input quirks, use module
argument
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/configure.ac
^
|
@@ -187,6 +187,25 @@
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)
+#### expat (for xml config format parsing) (optional) ####
+
+AC_ARG_ENABLE([xml],
+ AS_HELP_STRING([--disable-xml],[Disable optional xml config support]))
+
+AS_IF([test "x$enable_xml" != "xno"],
+ [PKG_CHECK_MODULES(EXPAT, [ expat >= 2.1 ], HAVE_EXPAT=1, HAVE_EXPAT=0)],
+ HAVE_EXPAT=0)
+
+AS_IF([test "x$enable_xml" = "xyes" && test "x$HAVE_EXPAT" = "x0"],
+ [AC_MSG_ERROR([*** expat not found])])
+
+AC_SUBST(HAVE_EXPAT)
+AC_SUBST(EXPAT_CFLAGS)
+AC_SUBST(EXPAT_LIBS)
+AM_CONDITIONAL([HAVE_EXPAT], [test "x$HAVE_EXPAT" = x1])
+AS_IF([test "x$HAVE_EXPAT" = "x1"], AC_DEFINE([HAVE_EXPAT], 1, [Have expat?]))
+AS_IF([test "x$HAVE_EXPAT" = "x1"], ENABLE_XML="yes (expat)", ENABLE_XML=no)
+
# Output devices
CC_CHECK_DROID_ENUM([${DROIDHEADERS_CFLAGS}], [AUDIO_DEVICE_OUT_HDMI])
CC_CHECK_DROID_ENUM([${DROIDHEADERS_CFLAGS}], [AUDIO_DEVICE_OUT_HDMI_ARC])
@@ -277,6 +296,12 @@
AC_SUBST([DROID_DEVICE_CFLAGS])
fi
+# Workaround for SBJ HAL headers
+if test "x$droiddevice" = xsbj ; then
+ SBJ_DEVICE_LDFLAGS="-Wl,--allow-multiple-definition"
+ AC_SUBST([SBJ_DEVICE_LDFLAGS])
+fi
+
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]) ;;
@@ -309,5 +334,6 @@
prefix: ${prefix}
modules directory: ${modlibexecdir}
- Droid device ${droiddevice}
+ Droid device: ${droiddevice}
+ XML config support: ${ENABLE_XML}
"
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/Makefile.am
^
|
@@ -1,18 +1,35 @@
AM_LIBADD = \
$(PULSEAUDIO_LIBS) \
- $(HYBRIS_LIBS)
+ $(HYBRIS_LIBS) \
+ $(EXPAT_LIBS)
AM_CFLAGS = \
$(DROID_DEVICE_CFLAGS) \
$(PULSEAUDIO_CFLAGS) \
$(DROIDHEADERS_CFLAGS) \
$(HYBRIS_CFLAGS) \
+ $(EXPAT_CFLAGS) \
-DPULSEAUDIO_VERSION=@PA_MAJOR@ \
- -I$(top_srcdir)/src/common
+ -I$(top_srcdir)/src/common \
+ -I$(top_srcdir)/src/common/include
modlibexec_LTLIBRARIES = libdroid-util.la
+includedir = @includedir@/pulsecore/modules/droid
+include_HEADERS = include/droid/version.h \
+ include/droid/conversion.h \
+ include/droid/droid-config.h \
+ include/droid/droid-util.h
-libdroid_util_la_SOURCES = droid-util.c droid-util.h
-libdroid_util_la_LDFLAGS = -avoid-version -Wl,-z,noexecstack -lhybris-common
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libdroid-util.pc
+
+libdroid_util_la_SOURCES = droid-util.c \
+ droid-config.c \
+ conversion.c \
+ config-parser-legacy.c \
+ config-parser-xml.c \
+ droid-util-audio.h \
+ droid-util-41qc.h
+libdroid_util_la_LDFLAGS = -avoid-version -Wl,-z,noexecstack -lhybris-common $(SBJ_DEVICE_LDFLAGS)
libdroid_util_la_LIBADD = $(AM_LIBADD)
libdroid_util_la_CFLAGS = $(AM_CFLAGS)
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/config-parser-legacy.c
^
|
@@ -0,0 +1,436 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdbool.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/core-error.h>
+#include <pulsecore/log.h>
+#include <pulse/xmalloc.h>
+
+#include <hardware_legacy/audio_policy_conf.h>
+
+#include "droid/version.h"
+#include "droid/droid-config.h"
+#include "droid/conversion.h"
+#include "droid/sllist.h"
+
+/* Section defining custom global configuration variables. */
+#define GLOBAL_CONFIG_EXT_TAG "custom_properties"
+
+#define GAIN_TAG_PREFIX "gain_"
+
+#define MAX_LINE_LENGTH (1024)
+#define WHITESPACE "\n\r \t"
+
+static void log_parse_error(const char *fn, const unsigned ln, const char *section, const char *v) {
+ pa_log("[%s:%u] failed to parse line in section %s: unknown section (%s)", fn, ln, section, v);
+}
+
+pa_droid_config_audio *pa_parse_droid_audio_config_legacy(const char *filename) {
+ pa_droid_config_audio *config = NULL;
+ FILE *f;
+ unsigned n = 0;
+ bool ret = true;
+ char *full_line = NULL;
+ uint32_t hw_module_count = 0;
+
+ enum config_loc {
+ IN_ROOT = 0,
+ IN_GLOBAL = 1,
+ IN_GLOBAL_EXT = 2,
+ IN_HW_MODULES = 3,
+ IN_MODULE = 4,
+ IN_OUTPUT_INPUT = 5,
+ IN_CONFIG = 6,
+ IN_MODULE_GLOBAL = 10,
+ IN_DEVICES = 20,
+ IN_DEVICES_DEVICE = 21,
+ IN_GAINS = 22,
+ IN_GAIN_N = 23
+ } loc = IN_ROOT;
+
+ bool in_output = true;
+
+ pa_droid_config_hw_module *module = NULL;
+ pa_droid_config_device *output = NULL;
+ pa_droid_config_device *input = NULL;
+
+ pa_assert(filename);
+
+ f = fopen(filename, "r");
+
+ if (!f) {
+ pa_log_info("Failed to open config file (%s): %s", filename, pa_cstrerror(errno));
+ ret = false;
+ goto finish;
+ }
+
+ config = pa_xnew0(pa_droid_config_audio, 1);
+ config->global_config = pa_xnew0(pa_droid_config_global, 1);
+
+ pa_lock_fd(fileno(f), 1);
+
+ full_line = pa_xmalloc0(sizeof(char) * MAX_LINE_LENGTH);
+
+ while (!feof(f)) {
+ char *ln, *d, *v, *value;
+
+ if (!fgets(full_line, MAX_LINE_LENGTH, f))
+ break;
+
+ n++;
+
+ pa_strip_nl(full_line);
+
+ if (!*full_line)
+ continue;
+
+ ln = full_line + strspn(full_line, WHITESPACE);
+
+ if (ln[0] == '#')
+ continue;
+
+ v = ln;
+ d = v + strcspn(v, WHITESPACE);
+
+ value = d + strspn(d, WHITESPACE);
+ d[0] = '\0';
+ d = value + strcspn(value, WHITESPACE);
+ d[0] = '\0';
+
+ /* Enter section */
+ if (pa_streq(value, "{")) {
+
+ if (!*v) {
+ pa_log("[%s:%u] failed to parse line - too few words", filename, n);
+ goto finish;
+ }
+
+ switch (loc) {
+ case IN_ROOT:
+ if (pa_streq(v, GLOBAL_CONFIG_TAG)) {
+ loc = IN_GLOBAL;
+ }
+ else if (pa_streq(v, AUDIO_HW_MODULE_TAG))
+ loc = IN_HW_MODULES;
+ else {
+ log_parse_error(filename, n, "<root>", v);
+ ret = false;
+ goto finish;
+ }
+ break;
+
+ case IN_GLOBAL:
+ if (pa_streq(v, GLOBAL_CONFIG_EXT_TAG))
+ loc = IN_GLOBAL_EXT;
+ else {
+ log_parse_error(filename, n, GLOBAL_CONFIG_TAG, v);
+ ret = false;
+ goto finish;
+ }
+ break;
+
+ case IN_HW_MODULES:
+ pa_assert(!module);
+
+ module = pa_droid_config_hw_module_new(config, v);
+ SLLIST_APPEND(pa_droid_config_hw_module, config->hw_modules, module);
+ hw_module_count++;
+ loc = IN_MODULE;
+ pa_log_debug("config: New module: %s", module->name);
+ break;
+
+ case IN_MODULE:
+ pa_assert(module);
+
+ if (pa_streq(v, OUTPUTS_TAG)) {
+ loc = IN_OUTPUT_INPUT;
+ in_output = true;
+ } else if (pa_streq(v, INPUTS_TAG)) {
+ loc = IN_OUTPUT_INPUT;
+ in_output = false;
+ } else if (pa_streq(v, GLOBAL_CONFIG_TAG)) {
+ loc = IN_MODULE_GLOBAL;
+ } else if (pa_streq(v, DEVICES_TAG)) {
+ loc = IN_DEVICES;
+ } else {
+ log_parse_error(filename, n, module->name, v);
+ ret = false;
+ goto finish;
+ }
+ break;
+
+ case IN_OUTPUT_INPUT:
+ pa_assert(module);
+
+ if (in_output) {
+ output = pa_droid_config_device_new(module, PA_DIRECTION_OUTPUT, v);
+ SLLIST_APPEND(pa_droid_config_device, module->outputs, output);
+ loc = IN_CONFIG;
+ pa_log_debug("config: %s: New output: %s", module->name, output->name);
+ } else {
+ input = pa_droid_config_device_new(module, PA_DIRECTION_INPUT, v);
+ SLLIST_APPEND(pa_droid_config_device, module->inputs, input);
+ loc = IN_CONFIG;
+ pa_log_debug("config: %s: New input: %s", module->name, input->name);
+ }
+ break;
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/config-parser-xml.c
^
|
@@ -0,0 +1,1064 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <pulsecore/log.h>
+
+#include "droid/droid-config.h"
+
+#ifndef HAVE_EXPAT
+#include <unistd.h>
+pa_droid_config_audio *pa_parse_droid_audio_config_xml(const char *filename) {
+ if (access(filename, F_OK) == 0)
+ pa_log_warn("Could not parse %s, xml configuration parsing support not compiled in", filename);
+ return NULL;
+}
+#else
+
+#include <stdarg.h>
+#include <string.h>
+#include <expat.h>
+
+#include <pulse/xmalloc.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/core-error.h>
+
+#include "droid/conversion.h"
+#include "droid/sllist.h"
+
+#ifdef XML_UNICODE_WCHAR_T
+# include <wchar.h>
+# define XML_FMT_STR "ls"
+#else
+# define XML_FMT_STR "s"
+#endif
+
+#define POLICY_SUPPORTED_VERSION "1.0"
+
+#define ELEMENT_audioPolicyConfiguration "audioPolicyConfiguration"
+#define ELEMENT_globalConfiguration "globalConfiguration"
+#define ELEMENT_modules "modules"
+#define ELEMENT_module "module"
+#define ELEMENT_attachedDevices "attachedDevices"
+#define ELEMENT_item "item"
+#define ELEMENT_defaultOutputDevice "defaultOutputDevice"
+#define ELEMENT_mixPorts "mixPorts"
+#define ELEMENT_mixPort "mixPort"
+#define ELEMENT_profile "profile"
+#define ELEMENT_devicePorts "devicePorts"
+#define ELEMENT_devicePort "devicePort"
+/* ELEMENT_profile */
+#define ELEMENT_routes "routes"
+#define ELEMENT_route "route"
+
+#define ATTRIBUTE_version "version"
+#define ATTRIBUTE_name "name"
+#define ATTRIBUTE_halVersion "halVersion"
+#define ATTRIBUTE_format "format"
+#define ATTRIBUTE_samplingRates "samplingRates"
+#define ATTRIBUTE_channelMasks "channelMasks"
+#define ATTRIBUTE_tagName "tagName"
+#define ATTRIBUTE_role "role"
+#define ATTRIBUTE_flags "flags"
+#define ATTRIBUTE_sink "sink"
+#define ATTRIBUTE_sources "sources"
+#define ATTRIBUTE_type "type"
+
+#define PORT_TYPE_sink "sink"
+#define PORT_TYPE_source "source"
+
+
+struct parser_data;
+
+struct element_parser {
+ const char *name;
+ bool (*attributes)(struct parser_data *data, const char *element_name, const XML_Char **attributes);
+ void (*char_data)(struct parser_data *data, const char *str);
+ const struct element_parser *next;
+ const struct element_parser *child;
+};
+
+struct element_parser_stack {
+ const struct element_parser *data;
+ struct element_parser_stack *next;
+};
+
+#define ELEMENT_STACK_PUSH(_stack, _item) \
+ do { \
+ struct element_parser_stack *_i; \
+ _i = pa_xmalloc0(sizeof(*_i)); \
+ _i->data = _item; \
+ _i->next = _stack; \
+ _stack = _i; \
+ } while(0)
+
+#define ELEMENT_STACK_POP(_stack, _item) \
+ do { \
+ if (_stack) { \
+ struct element_parser_stack *_t; \
+ _t = _stack; \
+ _item = _stack->data; \
+ _stack = _stack->next; \
+ pa_xfree(_t); \
+ } else \
+ _item = NULL; \
+ } while(0)
+
+static bool parse_audio_policy_configuration(struct parser_data *data, const char *element_name, const XML_Char **attributes);
+static bool parse_route(struct parser_data *data, const char *element_name, const XML_Char **attributes);
+static bool parse_profile(struct parser_data *data, const char *element_name, const XML_Char **attributes);
+static bool parse_device_port(struct parser_data *data, const char *element_name, const XML_Char **attributes);
+static bool parse_mix_port(struct parser_data *data, const char *element_name, const XML_Char **attributes);
+static void parse_default_output_device(struct parser_data *data, const char *str);
+static void parse_item(struct parser_data *data, const char *str);
+static bool parse_module(struct parser_data *data, const char *element_name, const XML_Char **attributes);
+static bool parse_global_configuration(struct parser_data *data, const char *element_name, const XML_Char **attributes);
+
+static const struct element_parser element_parse_route = {
+ ELEMENT_route,
+ parse_route,
+ NULL,
+ NULL,
+ NULL
+};
+
+static const struct element_parser element_parse_routes = {
+ ELEMENT_routes,
+ NULL,
+ NULL,
+ NULL,
+ &element_parse_route
+};
+
+static const struct element_parser element_parse_profile = {
+ ELEMENT_profile,
+ parse_profile,
+ NULL,
+ NULL,
+ NULL
+};
+
+static const struct element_parser element_parse_device_port = {
+ ELEMENT_devicePort,
+ parse_device_port,
+ NULL,
+ NULL,
+ &element_parse_profile
+};
+
+static const struct element_parser element_parse_device_ports = {
+ ELEMENT_devicePorts,
+ NULL,
+ NULL,
+ &element_parse_routes,
+ &element_parse_device_port
+};
+
+static const struct element_parser element_parse_mix_port = {
+ ELEMENT_mixPort,
+ parse_mix_port,
+ NULL,
+ NULL,
+ &element_parse_profile
+};
+
+static const struct element_parser element_parse_mix_ports = {
+ ELEMENT_mixPorts,
+ NULL,
+ NULL,
+ &element_parse_device_ports,
+ &element_parse_mix_port
+};
+
+static const struct element_parser element_parse_default_output_device = {
+ ELEMENT_defaultOutputDevice,
+ NULL,
+ parse_default_output_device,
+ &element_parse_mix_ports,
+ NULL
+};
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/conversion.c
^
|
@@ -0,0 +1,475 @@
+/*
+ * Copyright (C) 2013-2018 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "droid/version.h"
+#if ANDROID_VERSION_MAJOR == 4 && ANDROID_VERSION_MINOR == 1
+#include "droid-util-41qc.h"
+#else
+#include "droid-util-audio.h"
+#endif
+
+#include <pulsecore/core-util.h>
+
+#include <hardware/audio.h>
+
+#include "droid/conversion.h"
+#include "droid/droid-config.h"
+
+#define CONVERT_FUNC(TABL) \
+bool pa_convert_ ## TABL (uint32_t value, pa_conversion_field_t field, uint32_t *to_value) { \
+ for (unsigned int i = 0; i < sizeof( conversion_table_ ## TABL )/(sizeof(uint32_t)*2); i++) { \
+ if ( conversion_table_ ## TABL [i][field] == value) { \
+ *to_value = conversion_table_ ## TABL [i][!field]; \
+ return true; \
+ } \
+ } \
+ return false; \
+} struct __funny_extra_to_allow_semicolon
+
+/* Creates convert_format convert_channel etc.
+ * bool pa_convert_func(uint32_t value, pa_conversion_field_t field, uint32_t *to_value);
+ * return true if conversion succesful */
+CONVERT_FUNC(format);
+CONVERT_FUNC(output_channel);
+CONVERT_FUNC(input_channel);
+
+#define value_separator(legacy) (legacy ? "|" : ",")
+
+static bool string_convert_num_to_str(const struct string_conversion *list, const uint32_t value, const char **to_str) {
+ pa_assert(list);
+ pa_assert(to_str);
+
+ for (unsigned int i = 0; list[i].str; i++) {
+ if (list[i].value == value) {
+ *to_str = list[i].str;
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool string_convert_str_to_num(const struct string_conversion *list, const char *str, uint32_t *to_value) {
+ pa_assert(list);
+ pa_assert(str);
+ pa_assert(to_value);
+
+ for (unsigned int i = 0; list[i].str; i++) {
+ if (pa_streq(list[i].str, str)) {
+ *to_value = list[i].value;
+ return true;
+ }
+ }
+ return false;
+}
+
+static char *list_string(struct string_conversion *list, uint32_t flags) {
+ char *str = NULL;
+ char *tmp;
+
+#if AUDIO_API_VERSION_MAJ >= 2
+ if (flags & AUDIO_DEVICE_BIT_IN)
+ flags &= ~AUDIO_DEVICE_BIT_IN;
+#endif
+
+ for (unsigned int i = 0; list[i].str; i++) {
+#if AUDIO_API_VERSION_MAJ >= 2
+ if (list[i].value & AUDIO_DEVICE_BIT_IN) {
+ if (popcount(list[i].value & ~AUDIO_DEVICE_BIT_IN) != 1)
+ continue;
+ } else
+#endif
+ if (popcount(list[i].value) != 1)
+ continue;
+
+ if (flags & list[i].value) {
+ if (str) {
+ tmp = pa_sprintf_malloc("%s|%s", str, list[i].str);
+ pa_xfree(str);
+ str = tmp;
+ } else {
+ str = pa_sprintf_malloc("%s", list[i].str);
+ }
+ }
+ }
+
+ return str;
+}
+
+
+/* Output device */
+bool pa_string_convert_output_device_num_to_str(audio_devices_t value, const char **to_str) {
+ return string_convert_num_to_str(string_conversion_table_output_device, (uint32_t) value, to_str);
+}
+
+bool pa_string_convert_output_device_str_to_num(const char *str, audio_devices_t *to_value) {
+ return string_convert_str_to_num(string_conversion_table_output_device, str, (uint32_t*) to_value);
+}
+
+char *pa_list_string_output_device(audio_devices_t devices) {
+ return list_string(string_conversion_table_output_device, devices);
+}
+
+/* Input device */
+bool pa_string_convert_input_device_num_to_str(audio_devices_t value, const char **to_str) {
+ return string_convert_num_to_str(string_conversion_table_input_device, (uint32_t) value, to_str);
+}
+
+bool pa_string_convert_input_device_str_to_num(const char *str, audio_devices_t *to_value) {
+ return string_convert_str_to_num(string_conversion_table_input_device, str, (uint32_t*) to_value);
+}
+
+char *pa_list_string_input_device(audio_devices_t devices) {
+ return list_string(string_conversion_table_input_device, devices);
+}
+
+/* Flags */
+bool pa_string_convert_flag_num_to_str(audio_output_flags_t value, const char **to_str) {
+ return string_convert_num_to_str(string_conversion_table_output_flag, (uint32_t) value, to_str);
+}
+
+bool pa_string_convert_flag_str_to_num(const char *str, audio_output_flags_t *to_value) {
+ return string_convert_str_to_num(string_conversion_table_output_flag, str, (uint32_t*) to_value);
+}
+
+char *pa_list_string_flags(audio_output_flags_t flags) {
+ return list_string(string_conversion_table_output_flag, flags);
+}
+
+bool pa_input_device_default_audio_source(audio_devices_t input_device, audio_source_t *default_source)
+{
+#if AUDIO_API_VERSION_MAJ >= 2
+ input_device &= ~AUDIO_DEVICE_BIT_IN;
+#endif
+
+ /* Note converting HAL values to different HAL values! */
+ for (unsigned int i = 0; i < sizeof(conversion_table_default_audio_source) / (sizeof(uint32_t) * 2); i++) {
+ if (conversion_table_default_audio_source[i][0] & input_device) {
+ *default_source = conversion_table_default_audio_source[i][1];
+ return true;
+ }
+ }
+ return false;
+}
+
+
+bool pa_droid_output_port_name(audio_devices_t value, const char **to_str) {
+ return string_convert_num_to_str(string_conversion_table_output_device_fancy, (uint32_t) value, to_str);
+}
+
+bool pa_droid_input_port_name(audio_devices_t value, const char **to_str) {
+ return string_convert_num_to_str(string_conversion_table_input_device_fancy, (uint32_t) value, to_str);
+}
+
+bool pa_droid_audio_source_name(audio_source_t value, const char **to_str) {
+ return string_convert_num_to_str(string_conversion_table_audio_source_fancy, (uint32_t) value, to_str);
+}
+
+static int parse_list(const struct string_conversion *table,
+ const char *separator,
+ const char *str,
+ uint32_t *dst,
+ char **unknown_entries) {
+ int count = 0;
+ char *entry;
+ char *unknown = NULL;
+ const char *state = NULL;
+
+ pa_assert(table);
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/droid-config.c
^
|
@@ -0,0 +1,243 @@
+/*
+ * Copyright (C) 2013-2018 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "droid/version.h"
+#include "droid/droid-config.h"
+#include "droid/sllist.h"
+
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
+
+#include <pulse/rtclock.h>
+#include <pulse/timeval.h>
+#include <pulse/volume.h>
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/core.h>
+#include <pulsecore/core-error.h>
+#include <pulsecore/i18n.h>
+#include <pulsecore/module.h>
+#include <pulsecore/memchunk.h>
+#include <pulsecore/sink.h>
+#include <pulsecore/modargs.h>
+#include <pulsecore/core-rtclock.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/sample-util.h>
+#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/thread.h>
+#include <pulsecore/thread-mq.h>
+#include <pulsecore/rtpoll.h>
+#include <pulsecore/time-smoother.h>
+#include <pulsecore/refcnt.h>
+#include <pulsecore/shared.h>
+#include <pulsecore/mutex.h>
+#include <pulsecore/strlist.h>
+#include <pulsecore/atomic.h>
+
+#include <hardware/audio.h>
+#include <hardware_legacy/audio_policy_conf.h>
+
+#define VENDOR_AUDIO_POLICY_CONFIG_XML_FILE "/vendor/etc/audio_policy_configuration.xml"
+#define SYSTEM_AUDIO_POLICY_CONFIG_XML_FILE "/system/etc/audio_policy_configuration.xml"
+
+
+pa_droid_config_audio *pa_droid_config_load(pa_modargs *ma) {
+ pa_droid_config_audio *config = NULL;
+ const char *manual_config;
+ const char *config_location[] = {
+ VENDOR_AUDIO_POLICY_CONFIG_XML_FILE,
+ AUDIO_POLICY_VENDOR_CONFIG_FILE,
+ SYSTEM_AUDIO_POLICY_CONFIG_XML_FILE,
+ AUDIO_POLICY_CONFIG_FILE,
+ NULL};
+
+ pa_assert(ma);
+
+ if ((manual_config = pa_modargs_get_value(ma, "config", NULL))) {
+ if (!(config = pa_parse_droid_audio_config(manual_config)))
+ pa_log("Failed to parse configuration from %s", manual_config);
+ } else {
+ int i;
+ for (i = 0; config_location[i]; i++) {
+ if ((config = pa_parse_droid_audio_config(config_location[i])))
+ break;
+ else
+ pa_log_debug("Failed to parse configuration from %s", config_location[i]);
+ }
+
+ }
+
+ if (!config)
+ pa_log("Failed to parse any configuration.");
+
+ return config;
+}
+
+pa_droid_config_audio *pa_droid_config_dup(const pa_droid_config_audio *config) {
+ pa_droid_config_audio *config_copy;
+ pa_droid_config_hw_module *module, *module_copy;
+ pa_droid_config_device *device, *device_copy;
+
+ pa_assert(config);
+
+ config_copy = pa_xnew0(pa_droid_config_audio, 1);
+
+ if (config->global_config)
+ config_copy->global_config = pa_xmemdup(config->global_config, sizeof(*config->global_config));
+
+ SLLIST_FOREACH(module, config->hw_modules) {
+ module_copy = pa_droid_config_hw_module_new(config_copy, module->name);
+ if (module->global_config)
+ module_copy->global_config = pa_xmemdup(module->global_config, sizeof(*module->global_config));
+
+ SLLIST_FOREACH(device, module->outputs) {
+ device_copy = pa_xmemdup(device, sizeof(*device));
+ device_copy->module = module_copy;
+ device_copy->name = pa_xstrdup(device->name);
+ SLLIST_APPEND(pa_droid_config_device, module_copy->outputs, device_copy);
+ }
+
+ SLLIST_FOREACH(device, module->inputs) {
+ device_copy = pa_xmemdup(device, sizeof(*device));
+ device_copy->module = module_copy;
+ device_copy->name = pa_xstrdup(device->name);
+ SLLIST_APPEND(pa_droid_config_device, module_copy->inputs, device_copy);
+ }
+
+ SLLIST_APPEND(pa_droid_config_hw_module, config_copy->hw_modules, module_copy);
+ }
+
+ return config_copy;
+}
+
+pa_droid_config_audio *pa_parse_droid_audio_config(const char *filename) {
+ const char *suffix;
+
+ pa_assert(filename);
+
+ if ((suffix = rindex(filename, '.'))) {
+ if (strlen(suffix) == 4 && pa_streq(suffix, ".xml"))
+ return pa_parse_droid_audio_config_xml(filename);
+ else if (strlen(suffix) == 5 && pa_streq(suffix, ".conf"))
+ return pa_parse_droid_audio_config_legacy(filename);
+ }
+
+ return NULL;
+}
+
+void pa_droid_config_free(pa_droid_config_audio *config) {
+ pa_droid_config_hw_module *module;
+ pa_droid_config_device *device;
+
+ if (!config)
+ return;
+
+ while (config->hw_modules) {
+ SLLIST_STEAL_FIRST(module, config->hw_modules);
+
+ while (module->outputs) {
+ SLLIST_STEAL_FIRST(device, module->outputs);
+ pa_droid_config_device_free(device);
+ }
+
+ while (module->inputs) {
+ SLLIST_STEAL_FIRST(device, module->inputs);
+ pa_droid_config_device_free(device);
+ }
+
+ pa_droid_config_hw_module_free(module);
+ }
+
+ pa_xfree(config->global_config);
+ pa_xfree(config);
+}
+
+const pa_droid_config_hw_module *pa_droid_config_find_module(const pa_droid_config_audio *config, const char* module_id) {
+ pa_droid_config_hw_module *module;
+
+ pa_assert(config);
+ pa_assert(module_id);
+
+ SLLIST_FOREACH(module, config->hw_modules) {
+ if (pa_streq(module_id, module->name))
+ return module;
+ }
+
+ return NULL;
+}
+
+pa_droid_config_hw_module *pa_droid_config_hw_module_new(const pa_droid_config_audio *config, const char *name) {
+ pa_droid_config_hw_module *hw_module;
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/droid-util-41qc.h
^
|
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2013 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
@@ -29,6 +29,8 @@
#include <hardware/audio.h>
#include <hardware_legacy/audio_policy_conf.h>
+#include <pulse/channelmap.h>
+
// PulseAudio value - Android value
uint32_t conversion_table_output_channel[][2] = {
@@ -214,6 +216,10 @@
{ 0, NULL }
};
+struct string_conversion string_conversion_table_input_flag[] = {
+ { 0, NULL }
+};
+
/* Channels */
struct string_conversion string_conversion_table_output_channels[] = {
STRING_ENTRY(AUDIO_CHANNEL_OUT_FRONT_LEFT),
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/droid-util-audio.h
^
|
@@ -22,6 +22,7 @@
#ifndef _DROID_UTIL_AUDIO_H_
#define _DROID_UTIL_AUDIO_H_
+#include <android-config.h>
#ifdef QCOM_BSP
#define QCOM_HARDWARE
#endif
@@ -29,9 +30,7 @@
#include <hardware/audio.h>
#include <hardware_legacy/audio_policy_conf.h>
-#ifdef SPEAKER_DRC_ENABLED_TAG
-#define DROID_HAVE_DRC
-#endif
+#include <pulse/channelmap.h>
#ifdef STRING_ENTRY
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/droid-util.c
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
@@ -23,6 +23,7 @@
#include <config.h>
#endif
+#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
@@ -35,6 +36,7 @@
#include <pulse/timeval.h>
#include <pulse/volume.h>
#include <pulse/xmalloc.h>
+#include <pulse/direction.h>
#include <pulsecore/core.h>
#include <pulsecore/core-error.h>
@@ -58,7 +60,11 @@
#include <pulsecore/strlist.h>
#include <pulsecore/atomic.h>
-#include "droid-util.h"
+#include "droid/version.h"
+#include "droid/droid-util.h"
+#include "droid/droid-config.h"
+#include "droid/conversion.h"
+#include "droid/sllist.h"
struct droid_quirk {
const char *name;
@@ -73,851 +79,21 @@
{ "no_hw_volume", QUIRK_NO_HW_VOLUME },
{ "output_make_writable", QUIRK_OUTPUT_MAKE_WRITABLE },
{ "realcall", QUIRK_REALCALL },
+ { "unload_call_exit", QUIRK_UNLOAD_CALL_EXIT },
};
-#define SLLIST_APPEND(t, head, item) \
- do { \
- item->next = NULL; \
- if (!head) { \
- head = item; \
- } else { \
- t *_list; \
- for (_list = head; _list->next; _list = _list->next); \
- _list->next = item; \
- } \
- } while (0)
-
-#define SLLIST_FOREACH(i, head) \
- for (i = (head); i; i = i->next)
-
-#define SLLIST_STEAL_FIRST(i, head) \
- do { \
- if (head) { \
- i = head; \
- head = head->next; \
- } else \
- i = NULL; \
- } while (0)
-
-
-#define CONVERT_FUNC(TABL) \
-bool pa_convert_ ## TABL (uint32_t value, pa_conversion_field_t field, uint32_t *to_value) { \
- for (unsigned int i = 0; i < sizeof( conversion_table_ ## TABL )/(sizeof(uint32_t)*2); i++) { \
- if ( conversion_table_ ## TABL [i][field] == value) { \
- *to_value = conversion_table_ ## TABL [i][!field]; \
- return true; \
- } \
- } \
- return false; \
-} struct __funny_extra_to_allow_semicolon
-
-/* Creates convert_format convert_channel etc.
- * bool pa_convert_func(uint32_t value, pa_conversion_field_t field, uint32_t *to_value);
- * return true if conversion succesful */
-CONVERT_FUNC(format);
-CONVERT_FUNC(output_channel);
-CONVERT_FUNC(input_channel);
#define DEFAULT_PRIORITY (100)
-/* Section defining custom global configuration variables. */
-#define GLOBAL_CONFIG_EXT_TAG "custom_properties"
-
-/* From recent audio_policy_conf.h */
-#ifndef AUDIO_HAL_VERSION_TAG
-#define AUDIO_HAL_VERSION_TAG "audio_hal_version"
-#endif
-#ifndef GAINS_TAG
-#define GAINS_TAG "gains"
-#endif
-
-#define GAIN_TAG_PREFIX "gain_"
-
static const char * const droid_combined_auto_outputs[3] = { "primary", "low_latency", NULL };
static const char * const droid_combined_auto_inputs[2] = { "primary", NULL };
-static void droid_config_free(pa_droid_config_audio *config);
static void droid_port_free(pa_droid_port *p);
static pa_droid_stream *get_primary_output(pa_droid_hw_module *hw);
static int input_stream_set_route(pa_droid_stream *s, audio_devices_t device);
-static bool string_convert_num_to_str(const struct string_conversion *list, const uint32_t value, const char **to_str) {
- pa_assert(list);
- pa_assert(to_str);
-
- for (unsigned int i = 0; list[i].str; i++) {
- if (list[i].value == value) {
- *to_str = list[i].str;
- return true;
- }
- }
- return false;
-}
-
-static bool string_convert_str_to_num(const struct string_conversion *list, const char *str, uint32_t *to_value) {
- pa_assert(list);
- pa_assert(str);
- pa_assert(to_value);
-
- for (unsigned int i = 0; list[i].str; i++) {
- if (pa_streq(list[i].str, str)) {
- *to_value = list[i].value;
- return true;
- }
- }
- return false;
-}
-
-static char *list_string(struct string_conversion *list, uint32_t flags) {
- char *str = NULL;
- char *tmp;
-
-#if AUDIO_API_VERSION_MAJ >= 2
- if (flags & AUDIO_DEVICE_BIT_IN)
- flags &= ~AUDIO_DEVICE_BIT_IN;
-#endif
-
- for (unsigned int i = 0; list[i].str; i++) {
-#if AUDIO_API_VERSION_MAJ >= 2
- if (list[i].value & AUDIO_DEVICE_BIT_IN) {
- if (popcount(list[i].value & ~AUDIO_DEVICE_BIT_IN) != 1)
- continue;
- } else
-#endif
- if (popcount(list[i].value) != 1)
- continue;
-
- if (flags & list[i].value) {
- if (str) {
- tmp = pa_sprintf_malloc("%s|%s", str, list[i].str);
- pa_xfree(str);
- str = tmp;
- } else {
- str = pa_sprintf_malloc("%s", list[i].str);
- }
- }
- }
-
- return str;
-}
-
-
-/* Output device */
-bool pa_string_convert_output_device_num_to_str(audio_devices_t value, const char **to_str) {
- return string_convert_num_to_str(string_conversion_table_output_device, (uint32_t) value, to_str);
-}
-
-bool pa_string_convert_output_device_str_to_num(const char *str, audio_devices_t *to_value) {
- return string_convert_str_to_num(string_conversion_table_output_device, str, (uint32_t*) to_value);
-}
-
-char *pa_list_string_output_device(audio_devices_t devices) {
- return list_string(string_conversion_table_output_device, devices);
-}
-
-/* Input device */
-bool pa_string_convert_input_device_num_to_str(audio_devices_t value, const char **to_str) {
- return string_convert_num_to_str(string_conversion_table_input_device, (uint32_t) value, to_str);
-}
-
-bool pa_string_convert_input_device_str_to_num(const char *str, audio_devices_t *to_value) {
- return string_convert_str_to_num(string_conversion_table_input_device, str, (uint32_t*) to_value);
-}
-
-char *pa_list_string_input_device(audio_devices_t devices) {
- return list_string(string_conversion_table_input_device, devices);
-}
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/include/droid/conversion.h
^
|
@@ -0,0 +1,112 @@
+#ifndef foodroidconversionfoo
+#define foodroidconversionfoo
+
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <pulsecore/modargs.h>
+
+#include <hardware/audio.h>
+
+/* From recent audio_policy_conf.h */
+#ifndef AUDIO_HAL_VERSION_TAG
+#define AUDIO_HAL_VERSION_TAG "audio_hal_version"
+#endif
+#ifndef GAINS_TAG
+#define GAINS_TAG "gains"
+#endif
+
+#include <droid/version.h>
+#include <droid/droid-config.h>
+
+typedef enum {
+ CONV_FROM_PA,
+ CONV_FROM_HAL
+} pa_conversion_field_t;
+
+typedef enum {
+ CONV_STRING_FORMAT,
+ CONV_STRING_OUTPUT_CHANNELS,
+ CONV_STRING_INPUT_CHANNELS,
+ CONV_STRING_OUTPUT_DEVICE,
+ CONV_STRING_INPUT_DEVICE,
+ CONV_STRING_OUTPUT_FLAG,
+ CONV_STRING_INPUT_FLAG
+} pa_conversion_string_t;
+
+bool pa_convert_output_channel(uint32_t value, pa_conversion_field_t from, uint32_t *to_value);
+bool pa_convert_input_channel(uint32_t value, pa_conversion_field_t from, uint32_t *to_value);
+bool pa_convert_format(uint32_t value, pa_conversion_field_t from, uint32_t *to_value);
+
+bool pa_string_convert_output_device_num_to_str(audio_devices_t value, const char **to_str);
+bool pa_string_convert_output_device_str_to_num(const char *str, audio_devices_t *to_value);
+bool pa_string_convert_input_device_num_to_str(audio_devices_t value, const char **to_str);
+bool pa_string_convert_input_device_str_to_num(const char *str, audio_devices_t *to_value);
+
+bool pa_string_convert_flag_num_to_str(audio_output_flags_t value, const char **to_str);
+bool pa_string_convert_flag_str_to_num(const char *str, audio_output_flags_t *to_value);
+
+char *pa_list_string_output_device(audio_devices_t devices);
+char *pa_list_string_input_device(audio_devices_t devices);
+char *pa_list_string_flags(audio_output_flags_t flags);
+
+/* Get default audio source associated with input device.
+ * Return true if default source was found. */
+bool pa_input_device_default_audio_source(audio_devices_t input_device, audio_source_t *default_source);
+
+/* Pretty port names */
+bool pa_droid_output_port_name(audio_devices_t value, const char **to_str);
+bool pa_droid_input_port_name(audio_devices_t value, const char **to_str);
+
+/* Pretty audio source names */
+bool pa_droid_audio_source_name(audio_source_t value, const char **to_str);
+
+int pa_conversion_parse_list(pa_conversion_string_t type, const char *separator,
+ const char *str, uint32_t *dst, char **unknown_entries);
+
+bool pa_conversion_parse_sampling_rates(const char *fn, const unsigned ln,
+ const char *str, bool legacy,
+ uint32_t sampling_rates[AUDIO_MAX_SAMPLING_RATES]);
+bool pa_conversion_parse_formats(const char *fn, const unsigned ln,
+ const char *str, bool legacy,
+ audio_format_t *formats);
+bool pa_conversion_parse_output_channels(const char *fn, const unsigned ln,
+ const char *str, bool legacy,
+ audio_channel_mask_t *channels);
+bool pa_conversion_parse_input_channels(const char *fn, const unsigned ln,
+ const char *str, bool legacy,
+ audio_channel_mask_t *channels);
+bool pa_conversion_parse_output_devices(const char *fn, const unsigned ln,
+ char *str, bool legacy, bool must_recognize_all,
+ audio_devices_t *devices);
+bool pa_conversion_parse_input_devices(const char *fn, const unsigned ln,
+ char *str, bool legacy, bool must_recognize_all,
+ audio_devices_t *devices);
+bool pa_conversion_parse_output_flags(const char *fn, const unsigned ln,
+ const char *str, audio_output_flags_t *flags);
+bool pa_conversion_parse_input_flags(const char *fn, const unsigned ln,
+ const char *str, uint32_t *flags);
+bool pa_conversion_parse_version(const char *fn, const unsigned ln, const char *str, uint32_t *version);
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/include/droid/droid-config.h
^
|
@@ -0,0 +1,102 @@
+#ifndef foodroidconfigfoo
+#define foodroidconfigfoo
+
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <pulsecore/modargs.h>
+
+#include <android-config.h>
+#include <hardware/audio.h>
+
+#include <droid/version.h>
+
+typedef struct pa_droid_config_audio pa_droid_config_audio;
+typedef struct pa_droid_config_hw_module pa_droid_config_hw_module;
+
+#define AUDIO_MAX_SAMPLING_RATES (32)
+
+typedef struct pa_droid_config_global {
+ uint32_t audio_hal_version;
+ audio_devices_t attached_output_devices;
+ audio_devices_t default_output_device;
+ audio_devices_t attached_input_devices;
+} pa_droid_config_global;
+
+typedef struct pa_droid_config_device {
+ const pa_droid_config_hw_module *module;
+
+ char *name;
+ uint32_t sampling_rates[AUDIO_MAX_SAMPLING_RATES]; /* (uint32_t) -1 -> dynamic */
+ audio_channel_mask_t channel_masks; /* 0 -> dynamic */
+ audio_format_t formats; /* 0 -> dynamic */
+ audio_devices_t devices;
+ /* Instead of using audio_output_flags_t and audio_input_flags_t
+ * unify the flags as uint32_t so that we can have single struct for both
+ * output and input configurations.
+ * audio_input_flags_t was introduced in APIs 2 & 3, depending on adaptation,
+ * so having input flags as uint32_t is simpler from input implementation
+ * point of view as well. */
+ uint32_t flags;
+ pa_direction_t direction;
+
+ struct pa_droid_config_device *next;
+} pa_droid_config_device;
+
+struct pa_droid_config_hw_module {
+ const pa_droid_config_audio *config;
+
+ char *name;
+ /* If global config is not defined for module, use root global config. */
+ pa_droid_config_global *global_config;
+ pa_droid_config_device *outputs;
+ pa_droid_config_device *inputs;
+
+ struct pa_droid_config_hw_module *next;
+};
+
+struct pa_droid_config_audio {
+ pa_droid_config_global *global_config;
+ pa_droid_config_hw_module *hw_modules;
+};
+
+/* Config parser */
+pa_droid_config_audio *pa_droid_config_load(pa_modargs *ma);
+pa_droid_config_audio *pa_droid_config_dup(const pa_droid_config_audio *config);
+void pa_droid_config_free(pa_droid_config_audio *config);
+pa_droid_config_audio *pa_parse_droid_audio_config_legacy(const char *filename);
+pa_droid_config_audio *pa_parse_droid_audio_config_xml(const char *filename);
+/* autodetect config type from filename and parse */
+pa_droid_config_audio *pa_parse_droid_audio_config(const char *filename);
+
+const pa_droid_config_hw_module *pa_droid_config_find_module(const pa_droid_config_audio *config, const char* module_id);
+
+pa_droid_config_hw_module *pa_droid_config_hw_module_new(const pa_droid_config_audio *config, const char *name);
+void pa_droid_config_hw_module_free(pa_droid_config_hw_module *hw_module);
+pa_droid_config_device *pa_droid_config_device_new(const pa_droid_config_hw_module *module,
+ pa_direction_t direction,
+ const char *name);
+void pa_droid_config_device_free(pa_droid_config_device *device);
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/include/droid/droid-util.h
^
|
@@ -0,0 +1,333 @@
+#ifndef foodroidutilfoo
+#define foodroidutilfoo
+
+/*
+ * Copyright (C) 2013-2018 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/mutex.h>
+#include <pulsecore/strlist.h>
+#include <pulsecore/atomic.h>
+
+#include <droid/version.h>
+#include <droid/droid-config.h>
+
+#if defined(QCOM_BSP) && (AUDIO_API_VERSION_MAJ >= 3)
+#define DROID_AUDIO_HAL_USE_VSID
+#endif
+
+#define PROP_DROID_DEVICES "droid.devices"
+#define PROP_DROID_FLAGS "droid.flags"
+#define PROP_DROID_HW_MODULE "droid.hw_module"
+#define PROP_DROID_API_STRING "droid-hal"
+
+#define PROP_DROID_OUTPUT_PRIMARY "droid.output.primary"
+#define PROP_DROID_OUTPUT_LOW_LATENCY "droid.output.low_latency"
+#define PROP_DROID_OUTPUT_MEDIA_LATENCY "droid.output.media_latency"
+#define PROP_DROID_OUTPUT_OFFLOAD "droid.output.offload"
+#define PROP_DROID_INPUT_BUILTIN "droid.input.builtin"
+#define PROP_DROID_INPUT_EXTERNAL "droid.input.external"
+
+#define PA_DROID_PRIMARY_DEVICE "primary"
+
+typedef struct pa_droid_hw_module pa_droid_hw_module;
+typedef struct pa_droid_stream pa_droid_stream;
+typedef struct pa_droid_output_stream pa_droid_output_stream;
+typedef struct pa_droid_input_stream pa_droid_input_stream;
+typedef struct pa_droid_card_data pa_droid_card_data;
+typedef int (*common_set_parameters_cb_t)(pa_droid_card_data *card_data, const char *str);
+
+typedef struct pa_droid_quirks pa_droid_quirks;
+
+typedef enum pa_droid_hook {
+ PA_DROID_HOOK_INPUT_CHANNEL_MAP_CHANGED, /* Call data: pa_droid_stream */
+ PA_DROID_HOOK_INPUT_BUFFER_SIZE_CHANGED, /* Call data: pa_droid_stream */
+ PA_DROID_HOOK_MAX
+} pa_droid_hook_t;
+
+
+struct pa_droid_hw_module {
+ PA_REFCNT_DECLARE;
+
+ pa_core *core;
+ char *shared_name;
+
+ pa_droid_config_audio *config;
+ const pa_droid_config_hw_module *enabled_module;
+ pa_mutex *hw_mutex;
+ pa_mutex *output_mutex;
+ pa_mutex *input_mutex;
+
+ struct hw_module_t *hwmod;
+ audio_hw_device_t *device;
+
+ const char *module_id;
+
+ uint32_t stream_out_id;
+ uint32_t stream_in_id;
+
+ pa_idxset *outputs;
+ pa_idxset *inputs;
+ pa_hook_slot *sink_put_hook_slot;
+ pa_hook_slot *sink_unlink_hook_slot;
+ pa_hook_slot *source_put_hook_slot;
+ pa_hook_slot *source_unlink_hook_slot;
+
+ pa_atomic_t active_outputs;
+
+ pa_droid_quirks *quirks;
+ pa_hook hooks[PA_DROID_HOOK_MAX];
+};
+
+struct pa_droid_output_stream {
+ struct audio_stream_out *stream;
+ pa_sample_spec sample_spec;
+ pa_channel_map channel_map;
+ uint32_t flags;
+ uint32_t device;
+};
+
+struct pa_droid_input_stream {
+ struct audio_stream_in *stream;
+ pa_sample_spec sample_spec;
+ pa_channel_map channel_map;
+ pa_sample_spec input_sample_spec;
+ pa_channel_map input_channel_map;
+ uint32_t flags;
+ uint32_t device;
+ audio_devices_t all_devices;
+ bool merged;
+};
+
+struct pa_droid_stream {
+ PA_REFCNT_DECLARE;
+
+ pa_droid_hw_module *module;
+ size_t buffer_size;
+ void *data;
+
+ pa_droid_output_stream *output;
+ pa_droid_input_stream *input;
+};
+
+struct pa_droid_card_data {
+ void *userdata;
+ /* General functions */
+ char *module_id;
+ common_set_parameters_cb_t set_parameters;
+};
+
+
+/* Profiles */
+
+typedef struct pa_droid_profile_set pa_droid_profile_set;
+typedef struct pa_droid_mapping pa_droid_mapping;
+
+typedef struct pa_droid_port_data {
+ audio_devices_t device;
+} pa_droid_port_data;
+
+typedef struct pa_droid_port {
+ pa_droid_mapping *mapping;
+
+ audio_devices_t device;
+ char *name;
+ char *description;
+ unsigned priority;
+} pa_droid_port;
+
+struct pa_droid_mapping {
+ pa_droid_profile_set *profile_set;
+
+ const pa_droid_config_device *output;
+ const pa_droid_config_device *input;
+ const pa_droid_config_device *input2;
+
+ char *name;
+ char *description;
+ unsigned priority;
+ pa_proplist *proplist;
+
+ /* Mapping doesn't own the ports */
+ pa_idxset *ports;
+
+ pa_direction_t direction;
+
+ pa_sink *sink;
+ pa_source *source;
+};
+
+typedef struct pa_droid_profile {
+ pa_droid_profile_set *profile_set;
+
+ const pa_droid_config_hw_module *module;
+
+ char *name;
+ char *description;
+ unsigned priority;
+
+ /* Idxsets contain pa_droid_mapping objects.
+ * Profile doesn't own the mappings. */
+ pa_idxset *output_mappings;
+ pa_idxset *input_mappings;
+
+} pa_droid_profile;
+
+struct pa_droid_profile_set {
+ const pa_droid_config_audio *config;
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/include/droid/sllist.h
^
|
@@ -0,0 +1,49 @@
+#ifndef foosllistfoo
+#define foosllistfoo
+
+/*
+ * Copyright (C) 2018 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.
+ */
+
+#define SLLIST_APPEND(t, head, item) \
+ do { \
+ item->next = NULL; \
+ if (!head) { \
+ head = item; \
+ } else { \
+ t *_list; \
+ for (_list = head; _list->next; _list = _list->next); \
+ _list->next = item; \
+ } \
+ } while (0)
+
+#define SLLIST_FOREACH(i, head) \
+ for (i = (head); i; i = i->next)
+
+#define SLLIST_STEAL_FIRST(i, head) \
+ do { \
+ if (head) { \
+ i = head; \
+ head = head->next; \
+ } else \
+ i = NULL; \
+ } while (0)
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/common/include/droid/version.h
^
|
@@ -0,0 +1,51 @@
+#ifndef foodroidversionfoo
+#define foodroidversionfoo
+
+/*
+ * Copyright (C) 2018 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.
+ */
+
+
+#include <android-config.h>
+#ifdef QCOM_BSP
+#define QCOM_HARDWARE
+#endif
+
+#include <hardware/audio.h>
+
+#if !defined(ANDROID_VERSION_MAJOR) || !defined(ANDROID_VERSION_MINOR) || !defined(ANDROID_VERSION_PATCH)
+#error "ANDROID_VERSION_* not defined. Did you get your headers via extract-headers.sh?"
+#endif
+
+/* We currently support API version up-to 3.0 */
+#define DROID_API_VERSION_SUPPORT HARDWARE_DEVICE_API_VERSION(3, 0)
+
+#if AUDIO_DEVICE_API_VERSION_CURRENT > DROID_API_VERSION_SUPPORT
+#warning Compiling against higher audio device API version than currently supported!
+#warning Compile likely fails or module may malfunction.
+#endif
+
+#define AUDIO_API_VERSION_MAJ ((AUDIO_DEVICE_API_VERSION_CURRENT >> 8) & 0xff)
+#define AUDIO_API_VERSION_MIN (AUDIO_DEVICE_API_VERSION_CURRENT & 0xff)
+
+#define AUDIO_API_VERSION_GET_MAJ(x) ((x >> 8) & 0xff)
+#define AUDIO_API_VERSION_GET_MIN(x) (x & 0xff)
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/Makefile.am
^
|
@@ -9,7 +9,7 @@
$(HYBRIS_CFLAGS) \
-DPULSEAUDIO_VERSION=@PA_MAJOR@ \
-I$(top_srcdir)/src/droid \
- -I$(top_srcdir)/src/common
+ -I$(top_srcdir)/src/common/include
modlibexec_LTLIBRARIES = \
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/droid-sink.c
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
@@ -56,7 +56,8 @@
#include <pulsecore/core-subscribe.h>
#include "droid-sink.h"
-#include "droid-util.h"
+#include <droid/droid-util.h>
+#include <droid/conversion.h>
struct userdata {
pa_core *core;
@@ -1138,18 +1139,17 @@
* hw module ourself.
*
* First let's find out if hw module has already been opened, or if we need to
- * do it ourself.
- */
+ * do it ourself. */
if (!(u->hw_module = pa_droid_hw_module_get(u->core, NULL, module_id))) {
-
/* No hw module object in shared object db, let's open the module now. */
-
if (!(config = pa_droid_config_load(ma)))
goto fail;
- /* Ownership of config transfers to hw_module if opening of hw module succeeds. */
if (!(u->hw_module = pa_droid_hw_module_get(u->core, config, module_id)))
goto fail;
+
+ pa_droid_config_free(config);
+ config = NULL;
}
}
@@ -1308,6 +1308,7 @@
return u->sink;
fail:
+ pa_droid_config_free(config);
pa_xfree(thread_name);
if (config)
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/droid-sink.h
^
|
@@ -2,9 +2,9 @@
#define foodroidsinkfoo
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
@@ -41,7 +41,7 @@
#include <pulsecore/macro.h>
#include <pulsecore/card.h>
-#include "droid-util.h"
+#include <droid/droid-util.h>
pa_sink *pa_droid_sink_new(pa_module *m,
pa_modargs *ma,
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/droid-source.c
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
@@ -53,7 +53,8 @@
#include <pulsecore/resampler.h>
#include "droid-source.h"
-#include "droid-util.h"
+#include <droid/droid-util.h>
+#include <droid/conversion.h>
struct userdata {
pa_core *core;
@@ -595,15 +596,20 @@
u->card_data = card_data;
pa_assert_se((u->hw_module = pa_droid_hw_module_get(u->core, NULL, card_data->module_id)));
} else {
- /* Stand-alone source */
-
+ /* Source wasn't created from inside card module, so we'll need to open
+ * hw module ourself.
+ *
+ * First let's find out if hw module has already been opened, or if we need to
+ * do it ourself. */
if (!(u->hw_module = pa_droid_hw_module_get(u->core, NULL, module_id))) {
if (!(config = pa_droid_config_load(ma)))
goto fail;
- /* Ownership of config transfers to hw_module if opening of hw module succeeds. */
if (!(u->hw_module = pa_droid_hw_module_get(u->core, config, module_id)))
goto fail;
+
+ pa_droid_config_free(config);
+ config = NULL;
}
}
@@ -719,11 +725,9 @@
return u->source;
fail:
+ pa_droid_config_free(config);
pa_xfree(thread_name);
- if (config)
- pa_xfree(config);
-
if (u)
userdata_free(u);
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/droid-source.h
^
|
@@ -2,9 +2,9 @@
#define foodroidsourcefoo
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
@@ -41,7 +41,7 @@
#include <pulsecore/macro.h>
#include <pulsecore/card.h>
-#include "droid-util.h"
+#include <droid/droid-util.h>
/* If device is non-zero, it will override whatever is set in modargs for input device. */
pa_source *pa_droid_source_new(pa_module *m,
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/keepalive.c
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/keepalive.h
^
|
@@ -2,9 +2,9 @@
#define foodroidkeepalivefoo
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/module-droid-card-symdef.h
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/module-droid-card.c
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
@@ -59,7 +59,7 @@
//#include <droid/hardware/audio_policy.h>
//#include <droid/system/audio_policy.h>
-#include "droid-util.h"
+#include <droid/droid-util.h>
#include "droid-sink.h"
#include "droid-source.h"
@@ -720,14 +720,21 @@
u->core = m->core;
m->userdata = u;
- if (!(config = pa_droid_config_load(ma)))
- goto fail;
-
module_id = pa_modargs_get_value(ma, "module_id", DEFAULT_MODULE_ID);
- /* Ownership of config transfers to hw_module if opening of hw module succeeds. */
- if (!(u->hw_module = pa_droid_hw_module_get(u->core, config, module_id)))
- goto fail;
+ /* First let's find out if hw module has already been opened, or if we need to
+ * do it ourself. */
+ if (!(u->hw_module = pa_droid_hw_module_get(u->core, NULL, module_id))) {
+ /* No hw module object in shared object db, let's open the module now. */
+ if (!(config = pa_droid_config_load(ma)))
+ goto fail;
+
+ if (!(u->hw_module = pa_droid_hw_module_get(u->core, config, module_id)))
+ goto fail;
+
+ pa_droid_config_free(config);
+ config = NULL;
+ }
if ((quirks = pa_modargs_get_value(ma, "quirks", NULL))) {
if (!pa_droid_quirk_parse(u->hw_module, quirks)) {
@@ -835,6 +842,8 @@
return 0;
fail:
+ pa_droid_config_free(config);
+
if (ma)
pa_modargs_free(ma);
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/module-droid-keepalive-symdef.h
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/module-droid-keepalive.c
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
@@ -103,42 +103,52 @@
u->active = false;
}
-static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_object *o, struct userdata *u) {
- pa_assert(c);
- pa_object_assert_ref(o);
+static void update_sink(pa_sink *sink, struct userdata *u) {
+ pa_assert(sink);
pa_assert(u);
- if (pa_source_isinstance(o)) {
- pa_source *s = PA_SOURCE(o);
+ if (pa_sink_get_state(sink) != PA_SINK_SUSPENDED)
+ start(u);
+ else
+ stop(u);
+}
- /* Don't react on monitor state changes. */
- if (!s->monitor_of) {
- pa_source_state_t state = pa_source_get_state(s);
-
- if (state != PA_SOURCE_SUSPENDED)
- start(u);
- else
- stop(u);
- }
- } else if (pa_sink_isinstance(o)) {
- pa_sink *s = PA_SINK(o);
- pa_sink_state_t state = pa_sink_get_state(s);
+static void update_source(pa_source *source, struct userdata *u) {
+ pa_assert(source);
+ pa_assert(u);
- if (state != PA_SINK_SUSPENDED)
+ /* Don't react on monitor state changes. */
+ if (!source->monitor_of) {
+ if (pa_source_get_state(source) != PA_SOURCE_SUSPENDED)
start(u);
else
stop(u);
}
+}
+
+static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_object *o, struct userdata *u) {
+ pa_assert(c);
+ pa_object_assert_ref(o);
+ pa_assert(u);
+
+ if (pa_source_isinstance(o))
+ update_source(PA_SOURCE(o), u);
+ else if (pa_sink_isinstance(o))
+ update_sink(PA_SINK(o), u);
return PA_HOOK_OK;
}
int pa__init(pa_module *m) {
+ uint32_t idx = 0;
+ pa_sink *sink;
+ pa_source *source;
+ struct userdata *u;
pa_assert(m);
- struct userdata *u = pa_xnew0(struct userdata, 1);
+ u = pa_xnew0(struct userdata, 1);
u->core = m->core;
u->active = false;
u->module = m;
@@ -152,6 +162,12 @@
u->sink_state_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_STATE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) device_state_changed_hook_cb, u);
u->source_state_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_STATE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) device_state_changed_hook_cb, u);
+ PA_IDXSET_FOREACH(source, u->core->sources, idx)
+ update_source(source, u);
+
+ PA_IDXSET_FOREACH(sink, u->core->sinks, idx)
+ update_sink(sink, u);
+
return 0;
fail:
@@ -173,7 +189,7 @@
pa_hook_slot_free(u->source_state_changed_slot);
if (u->keepalive) {
- stop(u);
+ pa_droid_keepalive_stop(u->keepalive);
pa_droid_keepalive_free(u->keepalive);
}
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/module-droid-sink-symdef.h
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/module-droid-sink.c
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
@@ -37,7 +37,8 @@
#include <pulsecore/log.h>
#include <pulsecore/macro.h>
-#include "droid-util.h"
+#include <droid/droid-util.h>
+#include <droid/conversion.h>
#include "droid-sink.h"
#include "module-droid-sink-symdef.h"
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/module-droid-source-symdef.h
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-11.1.75.tar.bz2/src/droid/module-droid-source.c
^
|
@@ -1,7 +1,7 @@
/*
- * Copyright (C) 2013 Jolla Ltd.
+ * Copyright (C) 2013-2018 Jolla Ltd.
*
- * Contact: Juho Hämäläinen <juho.hamalainen@tieto.com>
+ * 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
@@ -37,7 +37,7 @@
#include <pulsecore/log.h>
#include <pulsecore/macro.h>
-#include "droid-util.h"
+#include <droid/droid-util.h>
#include "droid-source.h"
#include "module-droid-source-symdef.h"
|