[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid.spec
^
|
|
|
Changed |
_service
^
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/README
^
|
@@ -15,7 +15,6 @@
* 6.0.x
* 7.x
* 8.x
- * 9.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).
@@ -81,12 +80,10 @@
By default files are tried in following order,
- /odm/etc/audio_policy_configuration.xml (new xml format)
- /vendor/etc/audio/audio_policy_configuration.xml (new xml format)
- /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)
+ /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
-----------------
@@ -101,7 +98,8 @@
When module-droid-card is loaded with default arguments, droid-card will try
to create a default profile (called surprisingly "default"). The default
profile will try to merge useful output and input streams to one profile,
-to allow use of possible low latency or deep buffer outputs.
+to allow use of possible low latency outputs or multiple inputs if the
+input streams are split to multiple devices.
For example configuration with
@@ -112,8 +110,8 @@
deep_buffer {}
}
inputs {
- primary {}
- voice_rx {}
+ builtin {}
+ external {}
}
}
other {
@@ -122,11 +120,39 @@
}
The default profile would contain two sinks, sink.primary and sink.deep_buffer
-and one source, source.droid.
+and one source, source.builtin_external. Then this combined source would use
+either "builtin" or "external" input stream, depending on which one has the
+input route currently in use (for example, input-wired_headset from "external"
+and input-back_mic from "builtin" input stream).
Usually this default profile is everything that is needed in normal use, and
additional profiles created should be needed only for testing things out etc.
+additional profiles
+-------------------
+
+In addition to the default profile all input and output definitions are
+translated to PulseAudio card profiles. For example configuration with
+
+ audio_hw_modules {
+ primary {
+ outputs {
+ primary {}
+ lpa {}
+ }
+ inputs {
+ primary {}
+ }
+ }
+ other {
+ ...
+ }
+ }
+
+Would map to card profiles (input-output) primary-primary and lpa-primary.
+When module-droid-card is run without module_id argument, as default "primary"
+is used.
+
virtual profiles
----------------
@@ -176,33 +202,6 @@
related optimizations etc. Voicecall-record profile can be enabled when
voicecall profile is active.
-debugging profiles
-------------------
-
-If needed in favour of default profile one can opt to creating combinations
-of all output and input definitions in a module definition. This can be
-done by passing "default=false" to module-droid-card. Module argument
-module_id will then defines which module to load (by default "primary").
-Without default profile all input and output definitions are translated
-to PulseAudio card profiles. For example configuration with
-
- audio_hw_modules {
- primary {
- outputs {
- primary {}
- lpa {}
- }
- inputs {
- primary {}
- }
- }
- other {
- ...
- }
- }
-
-Would map to card profiles (<output>-<input>) primary-primary and lpa-primary.
-
module-droid-sink and module-droid-source
-----------------------------------------
@@ -253,41 +252,6 @@
accessory-plugin and pulseaudio-policy-enforcement module for actually making
the port switching)
-Droid source automatic reconfiguration
---------------------------------------
-
-As droid HAL makes assumptions on (input) routing based on what the parameters
-for the stream are (device, sample rate, channels, format, etc.) normal
-PulseAudio sources are a bit inflexible as only sample rate can change after
-source creation and even then there are restrictions based on alternative
-sample rate value.
-
-To overcome this and to allow some more variables affecting the stream being
-passed to the input stream droid source is modified to reconfigure itself
-with the source-output that connects to it. This means, that just looking at
-inactive source from "pactl list" listing doesn't tell the whole story.
-
-Droid source is always reconfigured with the *last* source-output that
-connects to it, possibly already connected source-outputs will continue
-to read from the source but through resampler.
-
-For example,
-
- 1) source-output 44100Hz, stereo connects (so1)
- a) source is configured with 44100Hz, stereo
- b) so1 connects to the source without resampler
- 2) source-output 16000Hz, mono connects (so2)
- a) so1 is detached from the source
- b) source is configured with 16000Hz, mono
- c) so2 connects to the source without resampler
- d) resampler is created for so1, 16000Hz, mono -> 44100Hz stereo
- f) so1 is re-attached to the source through resampler
- 3) source-output 16000Hz, mono connects (so3)
- a) so1 and so2 are detached from the source
- b) so3 connects to the source without resampler
- c) so1 is re-attached to the source through resampler
- d) so2 is attached to the source
-
Classifying sinks and sources
-----------------------------
@@ -321,8 +285,9 @@
There also may be just one sink, with all the properties defined as "true"
and so on.
-Right now there exists only one source (input device) which will always have
-both properties as true.
+Similarly if there is only one input device the sole source would have both
+input type properties set as "true", but it also might be that the different
+input type properties are split to two different sources.
Quirks
------
@@ -372,14 +337,6 @@
* 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.
- * output_fast
- * Enabled by default.
- * Create separate sink if AUDIO_OUTPUT_FLAG_FAST is found. If this sink
- is misbehaving try disabling this quirk.
- * output_deep_buffer
- * Enabled by default.
- * Create separate sink if AUDIO_OUTPUT_FLAG_DEEP_BUFFER is found. If
- this sink is misbehaving try disabling this quirk.
For example, to disable input_atoi and enable close_input quirks, use module
argument
@@ -417,4 +374,6 @@
module-droid-keepalive
----------------------
-Module relocated to its own package pulseaudio-module-keepalive.
+Keepalive module is MCE (https://github.com/nemomobile/mce) specific module
+tracking sink/source activity and keeping a WAKELOCK when there are active
+streams.
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/configure.ac
^
|
@@ -183,6 +183,10 @@
AC_SUBST(HYBRIS_CFLAGS)
AC_SUBST(HYBRIS_LIBS)
+PKG_CHECK_MODULES([DBUS], [dbus-1 >= 1.2])
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
+
#### expat (for xml config format parsing) (optional) ####
AC_ARG_ENABLE([xml],
@@ -256,10 +260,9 @@
CC_CHECK_DROID_ENUM([${DROIDHEADERS_CFLAGS}], [AUDIO_INPUT_FLAG_NONE])
CC_CHECK_DROID_ENUM([${DROIDHEADERS_CFLAGS}], [AUDIO_INPUT_FLAG_FAST])
CC_CHECK_DROID_ENUM([${DROIDHEADERS_CFLAGS}], [AUDIO_INPUT_FLAG_HW_HOTWORD])
+# Added in 6.0
CC_CHECK_DROID_ENUM([${DROIDHEADERS_CFLAGS}], [AUDIO_INPUT_FLAG_RAW])
CC_CHECK_DROID_ENUM([${DROIDHEADERS_CFLAGS}], [AUDIO_INPUT_FLAG_SYNC])
-CC_CHECK_DROID_ENUM([${DROIDHEADERS_CFLAGS}], [AUDIO_INPUT_FLAG_MMAP_NOIRQ])
-CC_CHECK_DROID_ENUM([${DROIDHEADERS_CFLAGS}], [AUDIO_INPUT_FLAG_VOIP_TX])
# Channels
CC_CHECK_DROID_ENUM([${DROIDHEADERS_CFLAGS}], [AUDIO_CHANNEL_OUT_SURROUND])
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/common/config-parser-xml.c
^
|
@@ -343,70 +343,86 @@
return str;
}
-static void device_list_free(struct device *list) {
- struct device *d;
+static void device_free(struct device *d) {
+ pa_assert(d);
+ pa_xfree(d->name);
+ pa_xfree(d);
+}
- while (list) {
- SLLIST_STEAL_FIRST(d, list);
- pa_xfree(d->name);
- pa_xfree(d);
- }
+static void profile_free(struct profile *p) {
+ pa_assert(p);
+ pa_xfree(p->name);
+ pa_xfree(p);
}
-static void profile_list_free(struct profile *list) {
- struct profile *p;
+static void mix_port_free(struct mix_port *p) {
+ struct profile *profile;
- while (list) {
- SLLIST_STEAL_FIRST(p, list);
- pa_xfree(p->name);
- pa_xfree(p);
- };
-}
+ pa_assert(p);
-static void mix_port_list_free(struct mix_port *list) {
- struct mix_port *p;
+ while (p->profiles) {
+ SLLIST_STEAL_FIRST(profile, p->profiles);
+ profile_free(profile);
+ };
- while (list) {
- SLLIST_STEAL_FIRST(p, list);
- profile_list_free(p->profiles);
- pa_xfree(p->name);
- pa_xfree(p->role);
- pa_xfree(p);
- }
+ pa_xfree(p->name);
+ pa_xfree(p->role);
+ pa_xfree(p);
}
-static void device_port_list_free(struct device_port *list) {
- struct device_port *p;
-
- while (list) {
- SLLIST_STEAL_FIRST(p, list);
- profile_list_free(p->profiles);
- pa_xfree(p->tag_name);
- pa_xfree(p->role);
- pa_xfree(p);
- }
+static void device_port_free(struct device_port *p) {
+ pa_assert(p);
+ pa_xfree(p->tag_name);
+ pa_xfree(p->role);
+ pa_xfree(p);
}
-static void route_list_free(struct route *list) {
- struct route *r;
+static void route_free(struct route *r) {
+ struct device *d;
- while (list) {
- SLLIST_STEAL_FIRST(r, list);
- device_list_free(r->sources);
- pa_xfree(r->type);
- pa_xfree(r->sink);
- pa_xfree(r);
- }
+ pa_assert(r);
+
+ while (r->sources) {
+ SLLIST_STEAL_FIRST(d, r->sources);
+ device_free(d);
+ }
+ pa_xfree(r->type);
+ pa_xfree(r->sink);
+ pa_xfree(r);
}
static void module_free(struct module *m) {
+ struct device *dev;
+ struct mix_port *mix_port;
+ struct device_port *device_port;
+ struct route *route;
+
pa_assert(m);
- device_list_free(m->attached_devices);
- device_list_free(m->default_output);
- mix_port_list_free(m->mix_ports);
- device_port_list_free(m->device_ports);
- route_list_free(m->routes);
+ while (m->attached_devices) {
+ SLLIST_STEAL_FIRST(dev, m->attached_devices);
+ device_free(dev);
+ };
+
+ while (m->default_output) {
+ SLLIST_STEAL_FIRST(dev, m->default_output);
+ device_free(dev);
+ };
+
+ while (m->mix_ports) {
+ SLLIST_STEAL_FIRST(mix_port, m->mix_ports);
+ mix_port_free(mix_port);
+ };
+
+ while (m->device_ports) {
+ SLLIST_STEAL_FIRST(device_port, m->device_ports);
+ device_port_free(device_port);
+ };
+
+ while (m->routes) {
+ SLLIST_STEAL_FIRST(route, m->routes);
+ route_free(route);
+ };
pa_xfree(m->name);
pa_xfree(m);
@@ -663,7 +679,7 @@
data->current_mix_port = p;
} else {
pa_log("[%s:%u] Failed to parse element <" ELEMENT_mixPort ">", data->fn, data->lineno);
- mix_port_list_free(p);
+ mix_port_free(p);
}
return parsed;
@@ -743,15 +759,15 @@
if (!parsed) {
pa_log_error("[%s:%u] Failed to parse element <" ELEMENT_profile ">", data->fn, data->lineno);
- profile_list_free(p);
+ profile_free(p);
} else if (unknown_format) {
pa_log_info("[%s:%u] Ignore profile with unknown format.", data->fn, data->lineno);
- profile_list_free(p);
+ profile_free(p);
} else {
if (data->current_mix_port)
- SLLIST_APPEND(struct profile, data->current_mix_port->profiles, p);
+ SLLIST_APPEND(struct profile, data->current_module->mix_ports->profiles, p);
else if (data->current_device_port)
- SLLIST_APPEND(struct profile, data->current_device_port->profiles, p);
+ SLLIST_APPEND(struct profile, data->current_module->device_ports->profiles, p);
else
pa_assert_not_reached();
}
@@ -786,10 +802,10 @@
if (!parsed) {
pa_log("[%s:%u] Failed to parse element <" ELEMENT_devicePort ">", data->fn, data->lineno);
- device_port_list_free(d);
+ device_port_free(d);
} else if (unknown_device) {
pa_log_info("[%s:%u] Ignore <" ELEMENT_devicePort "> with unknown device.", data->fn, data->lineno);
- device_port_list_free(d);
+ device_port_free(d);
} else {
SLLIST_APPEND(struct device_port, data->current_module->device_ports, d);
data->current_device_port = d;
@@ -828,7 +844,7 @@
SLLIST_APPEND(struct route, data->current_module->routes, r);
} else {
pa_log("[%s:%u] Failed to parse element <" ELEMENT_route ">", data->fn, data->lineno);
- route_list_free(r);
+ route_free(r);
}
return parsed;
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/common/conversion.c
^
|
@@ -117,34 +117,6 @@
return str;
}
-/* Generic conversion */
-bool pa_string_convert_num_to_str(pa_conversion_string_t type, uint32_t value, const char **to_str) {
- switch (type) {
- case CONV_STRING_FORMAT:
- return string_convert_num_to_str(string_conversion_table_format, value, to_str);
-
- case CONV_STRING_OUTPUT_CHANNELS:
- return string_convert_num_to_str(string_conversion_table_output_channels, value, to_str);
-
- case CONV_STRING_INPUT_CHANNELS:
- return string_convert_num_to_str(string_conversion_table_input_channels, value, to_str);
-
- case CONV_STRING_OUTPUT_DEVICE:
- return string_convert_num_to_str(string_conversion_table_output_device, value, to_str);
-
- case CONV_STRING_INPUT_DEVICE:
- return string_convert_num_to_str(string_conversion_table_input_device, value, to_str);
-
- case CONV_STRING_OUTPUT_FLAG:
- return string_convert_num_to_str(string_conversion_table_output_flag, value, to_str);
-
- case CONV_STRING_INPUT_FLAG:
- return string_convert_num_to_str(string_conversion_table_input_flag, value, to_str);
- }
-
- pa_assert_not_reached();
- return false;
-}
/* Output device */
bool pa_string_convert_output_device_num_to_str(audio_devices_t value, const char **to_str) {
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/common/droid-config.c
^
|
@@ -66,8 +66,6 @@
#include <hardware/audio.h>
#include <hardware_legacy/audio_policy_conf.h>
-#define ODM_AUDIO_POLICY_CONFIG_XML_FILE "/odm/etc/audio_policy_configuration.xml"
-#define VENDOR_AUDIO_AUDIO_POLICY_CONFIG_XML_FILE "/vendor/etc/audio/audio_policy_configuration.xml"
#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"
@@ -76,8 +74,6 @@
pa_droid_config_audio *config = NULL;
const char *manual_config;
const char *config_location[] = {
- ODM_AUDIO_POLICY_CONFIG_XML_FILE,
- VENDOR_AUDIO_AUDIO_POLICY_CONFIG_XML_FILE,
VENDOR_AUDIO_POLICY_CONFIG_XML_FILE,
AUDIO_POLICY_VENDOR_CONFIG_FILE,
SYSTEM_AUDIO_POLICY_CONFIG_XML_FILE,
@@ -199,28 +195,6 @@
return NULL;
}
-static const pa_droid_config_device *find_device(const pa_droid_config_hw_module *module, bool output, const char* device_name) {
- pa_droid_config_device *device;
-
- pa_assert(module);
- pa_assert(device_name);
-
- SLLIST_FOREACH(device, output ? module->outputs : module->inputs) {
- if (pa_streq(device_name, device->name))
- return device;
- }
-
- return NULL;
-}
-
-const pa_droid_config_device *pa_droid_config_find_output(const pa_droid_config_hw_module *module, const char* output_name) {
- return find_device(module, true, output_name);
-}
-
-const pa_droid_config_device *pa_droid_config_find_input(const pa_droid_config_hw_module *module, const char* input_name) {
- return find_device(module, false, input_name);
-}
-
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-12.2.79.tar.bz2/src/common/droid-util-audio.h
^
|
@@ -339,8 +339,6 @@
STRING_ENTRY_IF_AUDIO_INPUT_FLAG_HW_HOTWORD
STRING_ENTRY_IF_AUDIO_INPUT_FLAG_RAW
STRING_ENTRY_IF_AUDIO_INPUT_FLAG_SYNC
- STRING_ENTRY_IF_AUDIO_INPUT_FLAG_MMAP_NOIRQ
- STRING_ENTRY_IF_AUDIO_INPUT_FLAG_VOIP_TX
{ 0, NULL }
};
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/common/droid-util.c
^
|
@@ -80,13 +80,10 @@
{ "output_make_writable", QUIRK_OUTPUT_MAKE_WRITABLE },
{ "realcall", QUIRK_REALCALL },
{ "unload_call_exit", QUIRK_UNLOAD_CALL_EXIT },
- { "output_fast", QUIRK_OUTPUT_FAST },
- { "output_deep_buffer", QUIRK_OUTPUT_DEEP_BUFFER },
};
-#define DEFAULT_PRIORITY (100)
-#define DEFAULT_AUDIO_FORMAT (AUDIO_FORMAT_PCM_16_BIT)
+#define DEFAULT_PRIORITY (100)
static const char * const droid_combined_auto_outputs[3] = { "primary", "low_latency", NULL };
@@ -94,7 +91,8 @@
static void droid_port_free(pa_droid_port *p);
-static int input_stream_set_route(pa_droid_hw_module *hw_module, pa_droid_stream *s);
+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 pa_droid_profile *profile_new(pa_droid_profile_set *ps,
const pa_droid_config_hw_module *module,
@@ -115,6 +113,7 @@
p->priority = DEFAULT_PRIORITY;
p->output_mappings = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
+ p->input_mappings = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
pa_hashmap_put(ps->profiles, p->name, p);
@@ -124,7 +123,7 @@
static pa_droid_profile *droid_profile_new(pa_droid_profile_set *ps,
const pa_droid_config_device *primary_output,
const pa_droid_config_device *output,
- const pa_droid_config_device *inputs) {
+ const pa_droid_config_device *input) {
pa_droid_profile *p;
char *name;
char *description;
@@ -132,13 +131,13 @@
pa_assert(ps);
pa_assert(output);
pa_assert(!primary_output || primary_output->direction == PA_DIRECTION_OUTPUT);
- pa_assert(!inputs || inputs->direction == PA_DIRECTION_INPUT);
+ pa_assert(!input || input->direction == PA_DIRECTION_INPUT);
- name = pa_sprintf_malloc("%s%s%s", output->name, inputs ? "-" : "", inputs ? inputs->name : "");
+ name = pa_sprintf_malloc("%s%s%s", output->name, input ? "-" : "", input ? input->name : "");
description = pa_sprintf_malloc("%s output%s%s%s", output->name,
- inputs ? " and " : "",
- inputs ? inputs->name : "",
- inputs ? " inputs." : "");
+ input ? " and " : "",
+ input ? input->name : "",
+ input ? " input." : "");
p = profile_new(ps, output->module, name, description);
pa_xfree(name);
@@ -147,7 +146,7 @@
if (pa_streq(output->name, "primary")) {
p->priority += DEFAULT_PRIORITY;
- if (inputs && pa_streq(inputs->name, "primary"))
+ if (input && pa_streq(input->name, "primary"))
p->priority += DEFAULT_PRIORITY;
}
@@ -155,8 +154,8 @@
pa_idxset_put(p->output_mappings, pa_droid_mapping_get(ps, primary_output), NULL);
if (output)
pa_idxset_put(p->output_mappings, pa_droid_mapping_get(ps, output), NULL);
- if (inputs)
- p->input_mapping = pa_droid_mapping_get(ps, inputs);
+ if (input)
+ pa_idxset_put(p->input_mappings, pa_droid_mapping_get(ps, input), NULL);
return p;
}
@@ -168,7 +167,7 @@
if (am->direction == PA_DIRECTION_OUTPUT)
pa_idxset_put(p->output_mappings, am, NULL);
else
- p->input_mapping = am;
+ pa_idxset_put(p->input_mappings, am, NULL);
}
static pa_droid_profile *add_profile(pa_droid_profile_set *ps,
@@ -177,7 +176,7 @@
const pa_droid_config_device *input) {
pa_droid_profile *ap;
- pa_assert(!primary_output || primary_output->direction == PA_DIRECTION_OUTPUT);
+ pa_assert(primary_output && primary_output->direction == PA_DIRECTION_OUTPUT);
pa_assert(output && output->direction == PA_DIRECTION_OUTPUT);
pa_assert(!input || input->direction == PA_DIRECTION_INPUT);
@@ -210,20 +209,14 @@
}
static void add_all_profiles(pa_droid_profile_set *ps,
- const pa_droid_config_hw_module *module) {
- const pa_droid_config_device *primary_output = NULL;
- const pa_droid_config_device *output;
- const pa_droid_config_device *input;
+ const pa_droid_config_hw_module *module,
+ const pa_droid_config_device *primary_output) {
+ pa_droid_config_device *output;
+ pa_droid_config_device *input;
pa_assert(ps);
pa_assert(module);
-
- SLLIST_FOREACH(output, module->outputs) {
- if (output->flags & AUDIO_OUTPUT_FLAG_PRIMARY) {
- primary_output = output;
- break;
- }
- }
+ pa_assert(primary_output && primary_output->direction == PA_DIRECTION_OUTPUT);
/* Each distinct hw module output matches one profile. If there are multiple inputs
* combinations are made so that all possible outputs and inputs can be selected.
@@ -244,7 +237,7 @@
pa_droid_profile_set *ps;
ps = profile_set_new(module);
- add_all_profiles(ps, module);
+ add_all_profiles(ps, module, NULL);
return ps;
}
@@ -254,15 +247,19 @@
const pa_droid_config_device *primary_output,
const pa_droid_config_device *low_latency_output,
const pa_droid_config_device *media_latency_output,
- const pa_droid_config_device *inputs) {
+ const pa_droid_config_device *builtin_input,
+ const pa_droid_config_device *external_input,
+ bool merge_inputs) {
pa_droid_profile *p;
pa_assert(ps);
pa_assert(module);
pa_assert(!primary_output || primary_output->direction == PA_DIRECTION_OUTPUT);
- pa_assert(!low_latency_output || low_latency_output->direction == PA_DIRECTION_OUTPUT);
- pa_assert(!media_latency_output || media_latency_output->direction == PA_DIRECTION_OUTPUT);
+ pa_assert(!low_latency_output || primary_output->direction == PA_DIRECTION_OUTPUT);
+ pa_assert(!media_latency_output || primary_output->direction == PA_DIRECTION_OUTPUT);
+ pa_assert(!builtin_input || builtin_input->direction == PA_DIRECTION_INPUT);
+ pa_assert(!external_input || external_input->direction == PA_DIRECTION_INPUT);
pa_log_debug("New default profile");
@@ -275,21 +272,35 @@
if (media_latency_output && primary_output != media_latency_output && low_latency_output != media_latency_output)
pa_idxset_put(p->output_mappings, pa_droid_mapping_get(ps, media_latency_output), NULL);
- if (inputs)
- p->input_mapping = pa_droid_mapping_get(ps, inputs);
+ if (builtin_input && external_input && builtin_input != external_input && merge_inputs) {
+ pa_idxset_put(p->input_mappings, pa_droid_mapping_merged_get(ps, builtin_input, external_input), NULL);
+ } else {
+ if (builtin_input)
+ pa_idxset_put(p->input_mappings, pa_droid_mapping_get(ps, builtin_input), NULL);
+ if (external_input && builtin_input != external_input)
+ pa_idxset_put(p->input_mappings, pa_droid_mapping_get(ps, external_input), NULL);
+ }
- p->priority += DEFAULT_PRIORITY * (pa_idxset_size(p->output_mappings) + p->input_mapping ? 1 : 0);
+ p->priority += DEFAULT_PRIORITY * (pa_idxset_size(p->output_mappings) + pa_idxset_size(p->input_mappings));
p->priority += primary_output ? DEFAULT_PRIORITY : 0;
pa_hashmap_put(ps->profiles, p->name, p);
}
static void auto_add_profiles(pa_droid_profile_set *ps,
- const pa_droid_config_hw_module *module) {
+ const pa_droid_config_hw_module *module,
+ bool merge_inputs) {
const pa_droid_config_device *output;
+ const pa_droid_config_device *input;
+
const pa_droid_config_device *primary_output = NULL;
const pa_droid_config_device *low_latency_output = NULL;
const pa_droid_config_device *media_latency_output = NULL;
+ const pa_droid_config_device *builtin_input = NULL;
+ const pa_droid_config_device *external_input = NULL;
+
+ uint32_t input_devices;
+
pa_assert(ps);
pa_assert(module);
@@ -303,11 +314,6 @@
pa_log_debug("Ignore output %s with flag AUDIO_OUTPUT_FLAG_RAW", output->name);
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/common/include/droid/conversion.h
^
|
@@ -55,8 +55,6 @@
CONV_STRING_INPUT_FLAG
} pa_conversion_string_t;
-bool pa_string_convert_num_to_str(pa_conversion_string_t type, uint32_t value, const char **to_str);
-
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);
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/common/include/droid/droid-config.h
^
|
@@ -91,8 +91,6 @@
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);
-const pa_droid_config_device *pa_droid_config_find_output(const pa_droid_config_hw_module *module, const char* output_name);
-const pa_droid_config_device *pa_droid_config_find_input(const pa_droid_config_hw_module *module, const char* input_name);
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);
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/common/include/droid/droid-util.h
^
|
@@ -92,18 +92,13 @@
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;
-
- /* Mode and input control */
- struct _state {
- audio_mode_t mode;
- audio_devices_t input_device;
- audio_source_t audio_source;
- pa_droid_stream *active_input;
- } state;
+ pa_hook hooks[PA_DROID_HOOK_MAX];
};
struct pa_droid_output_stream {
@@ -116,22 +111,20 @@
struct pa_droid_input_stream {
struct audio_stream_in *stream;
- pa_sample_spec default_sample_spec;
- pa_channel_map default_channel_map;
pa_sample_spec sample_spec;
pa_channel_map channel_map;
- pa_sample_spec req_sample_spec;
- pa_channel_map req_channel_map;
+ pa_sample_spec input_sample_spec;
+ pa_channel_map input_channel_map;
uint32_t flags;
uint32_t device;
- bool first;
+ audio_devices_t all_devices;
+ bool merged;
};
struct pa_droid_stream {
PA_REFCNT_DECLARE;
pa_droid_hw_module *module;
- const pa_droid_config_device *device_def;
size_t buffer_size;
void *data;
@@ -169,8 +162,8 @@
pa_droid_profile_set *profile_set;
const pa_droid_config_device *output;
- /* Use all devices in one input */
- const pa_droid_config_device *inputs;
+ const pa_droid_config_device *input;
+ const pa_droid_config_device *input2;
char *name;
char *description;
@@ -196,12 +189,9 @@
unsigned priority;
/* Idxsets contain pa_droid_mapping objects.
- * Profile doesn't own the mappings, these
- * are references to structs in profile set
- * hashmaps. */
+ * Profile doesn't own the mappings. */
pa_idxset *output_mappings;
- /* Only one input */
- pa_droid_mapping *input_mapping;
+ pa_idxset *input_mappings;
} pa_droid_profile;
@@ -226,8 +216,6 @@
QUIRK_OUTPUT_MAKE_WRITABLE,
QUIRK_REALCALL,
QUIRK_UNLOAD_CALL_EXIT,
- QUIRK_OUTPUT_FAST,
- QUIRK_OUTPUT_DEEP_BUFFER,
QUIRK_COUNT
};
@@ -252,24 +240,24 @@
return hw->quirks && hw->quirks->enabled[quirk];
}
-bool pa_droid_hw_set_mode(pa_droid_hw_module *hw_module, audio_mode_t mode);
-bool pa_droid_hw_has_mic_control(pa_droid_hw_module *hw);
-int pa_droid_hw_mic_get_mute(pa_droid_hw_module *hw_module, bool *muted);
-void pa_droid_hw_mic_set_mute(pa_droid_hw_module *hw_module, bool muted);
-
/* Profiles */
pa_droid_profile_set *pa_droid_profile_set_new(const pa_droid_config_hw_module *module);
-pa_droid_profile_set *pa_droid_profile_set_default_new(const pa_droid_config_hw_module *module);
+pa_droid_profile_set *pa_droid_profile_set_default_new(const pa_droid_config_hw_module *module,
+ bool merge_inputs);
void pa_droid_profile_set_free(pa_droid_profile_set *ps);
void pa_droid_profile_add_mapping(pa_droid_profile *p, pa_droid_mapping *am);
void pa_droid_profile_free(pa_droid_profile *p);
pa_droid_mapping *pa_droid_mapping_get(pa_droid_profile_set *ps, const pa_droid_config_device *device);
+pa_droid_mapping *pa_droid_mapping_merged_get(pa_droid_profile_set *ps,
+ const pa_droid_config_device *input1,
+ const pa_droid_config_device *input2);
bool pa_droid_mapping_is_primary(pa_droid_mapping *am);
/* Go through idxset containing pa_droid_mapping objects and if primary output or input
* mapping is found, return pointer to that mapping. */
pa_droid_mapping *pa_droid_idxset_get_primary(pa_idxset *i);
+pa_droid_mapping *pa_droid_idxset_mapping_with_device(pa_idxset *i, uint32_t flag);
void pa_droid_mapping_free(pa_droid_mapping *am);
/* Add ports from sinks/sources.
@@ -279,9 +267,10 @@
* May be called multiple times for one card profile. */
void pa_droid_add_card_ports(pa_card_profile *cp, pa_hashmap *ports, pa_droid_mapping *am, pa_core *core);
+pa_hook *pa_droid_hooks(pa_droid_hw_module *hw);
+
/* Module operations */
int pa_droid_set_parameters(pa_droid_hw_module *hw, const char *parameters);
-pa_droid_stream *pa_droid_hw_primary_output_stream(pa_droid_hw_module *hw);
/* Stream operations */
pa_droid_stream *pa_droid_stream_ref(pa_droid_stream *s);
@@ -293,7 +282,7 @@
pa_droid_stream *pa_droid_open_output_stream(pa_droid_hw_module *module,
const pa_sample_spec *spec,
const pa_channel_map *map,
- const char *module_output_name,
+ audio_output_flags_t flags,
audio_devices_t devices);
/* Set routing to the input or output stream, with following side-effects:
@@ -307,19 +296,12 @@
*/
int pa_droid_stream_set_route(pa_droid_stream *s, audio_devices_t device);
-/* Open input stream with currently active routing, sample_spec and channel_map
- * are requests and may change when opening the stream. */
-pa_droid_stream *pa_droid_open_input_stream(pa_droid_hw_module *hw_module,
- const pa_sample_spec *default_sample_spec,
- const pa_channel_map *default_channel_map);
-bool pa_droid_stream_reconfigure_input(pa_droid_stream *s,
- const pa_sample_spec *requested_sample_spec,
- const pa_channel_map *requested_channel_map);
-bool pa_droid_hw_set_input_device(pa_droid_hw_module *hw_module,
- audio_devices_t device);
-
-const pa_sample_spec *pa_droid_stream_sample_spec(pa_droid_stream *stream);
-const pa_channel_map *pa_droid_stream_channel_map(pa_droid_stream *stream);
+/* Input stream operations */
+pa_droid_stream *pa_droid_open_input_stream(pa_droid_hw_module *module,
+ const pa_sample_spec *spec,
+ const pa_channel_map *map,
+ audio_devices_t devices,
+ pa_droid_mapping *am);
bool pa_droid_stream_is_primary(pa_droid_stream *s);
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/droid/Makefile.am
^
|
@@ -15,11 +15,17 @@
modlibexec_LTLIBRARIES = \
libdroid-sink.la \
libdroid-source.la \
+ module-droid-keepalive.la \
module-droid-sink.la \
module-droid-source.la \
module-droid-card.la
-noinst_HEADERS = module-droid-sink-symdef.h module-droid-source-symdef.h module-droid-card-symdef.h
+noinst_HEADERS = module-droid-sink-symdef.h module-droid-source-symdef.h module-droid-card-symdef.h module-droid-keepalive-symdef.h
+
+module_droid_keepalive_la_SOURCES = keepalive.c keepalive.h module-droid-keepalive.c
+module_droid_keepalive_la_LDFLAGS = -module -avoid-version -Wl,-z,noexecstack
+module_droid_keepalive_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS)
+module_droid_keepalive_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
libdroid_sink_la_SOURCES = droid-sink.c droid-sink.h
libdroid_sink_la_LDFLAGS = -avoid-version -Wl,-z,noexecstack -lhybris-common
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/droid/droid-sink.c
^
|
@@ -54,7 +54,6 @@
#include <pulsecore/time-smoother.h>
#include <pulsecore/hashmap.h>
#include <pulsecore/core-subscribe.h>
-#include <pulse/version.h>
#include "droid-sink.h"
#include <droid/droid-util.h>
@@ -372,11 +371,7 @@
pa_log_debug("Thread starting up.");
if (u->core->realtime_scheduling)
-#if PA_CHECK_VERSION(13,0,0)
- pa_thread_make_realtime(u->core->realtime_priority);
-#else
pa_make_realtime(u->core->realtime_priority);
-#endif
pa_thread_mq_install(&u->thread_mq);
@@ -403,7 +398,11 @@
pa_rtpoll_set_timer_disabled(u->rtpoll);
/* Sleep */
+#if (PULSEAUDIO_VERSION == 5)
+ if ((ret = pa_rtpoll_run(u->rtpoll, true)) < 0)
+#elif (PULSEAUDIO_VERSION >= 6)
if ((ret = pa_rtpoll_run(u->rtpoll)) < 0)
+#endif
goto fail;
if (ret == 0)
@@ -1046,7 +1045,6 @@
pa_card *card) {
struct userdata *u = NULL;
- const pa_droid_config_device *output = NULL;
bool deferred_volume = false;
char *thread_name = NULL;
pa_sink_new_data data;
@@ -1069,18 +1067,15 @@
pa_assert(ma);
pa_assert(driver);
- pa_log_info("Create new droid-sink");
-
deferred_volume = m->core->deferred_volume;
if (pa_modargs_get_value_boolean(ma, "deferred_volume", &deferred_volume) < 0) {
pa_log("Failed to parse deferred_volume argument.");
goto fail;
}
- if (card && am) {
- output = am->output;
- module_id = output->module->name;
- } else
+ if (card && am)
+ module_id = am->output->module->name;
+ else
module_id = pa_modargs_get_value(ma, "module_id", DEFAULT_MODULE_ID);
sample_spec = m->core->default_sample_spec;
@@ -1154,18 +1149,6 @@
pa_assert(card);
pa_assert_se((u->hw_module = pa_droid_hw_module_get(u->core, NULL, card_data->module_id)));
} else {
- const char *output_name;
-
- if (!(output_name = pa_modargs_get_value(ma, "output", NULL))) {
- pa_log("No output name defined.");
- goto fail;
- }
-
- if (!(output = pa_droid_config_find_output(u->hw_module->enabled_module, output_name))) {
- pa_log("Could not find output %s from module %s.", output_name, u->hw_module->enabled_module->name);
- goto fail;
- }
-
/* Sink wasn't created from inside card module, so we'll need to open
* hw module ourself.
*
@@ -1185,8 +1168,8 @@
}
/* Default routing */
- dev_out = output->module->global_config ? output->module->global_config->default_output_device
- : u->hw_module->config->global_config->default_output_device;
+ dev_out = (am && am->output->module->global_config) ? am->output->module->global_config->default_output_device
+ : u->hw_module->config->global_config->default_output_device;
if ((tmp = pa_modargs_get_value(ma, "output_devices", NULL))) {
audio_devices_t tmp_dev;
@@ -1197,9 +1180,10 @@
pa_log_debug("Set initial devices %s", tmp);
}
- flags = output->flags;
+ if (am)
+ flags = am->output->flags;
- u->stream = pa_droid_open_output_stream(u->hw_module, &sample_spec, &channel_map, output->name, dev_out);
+ u->stream = pa_droid_open_output_stream(u->hw_module, &sample_spec, &channel_map, flags, dev_out);
if (!u->stream) {
pa_log("Failed to open output stream.");
@@ -1214,7 +1198,7 @@
pa_log_info("Using buffer size %u.", u->buffer_size);
if ((prewrite_resume = pa_modargs_get_value(ma, "prewrite_on_resume", NULL))) {
- if (!parse_prewrite_on_resume(u, prewrite_resume, output->name)) {
+ if (!parse_prewrite_on_resume(u, prewrite_resume, am ? am->output->name : module_id)) {
pa_log("Failed to parse prewrite_on_resume (%s)", prewrite_resume);
goto fail;
}
@@ -1231,7 +1215,10 @@
data.module = m;
data.card = card;
- set_sink_name(ma, &data, output->name);
+ if (am)
+ set_sink_name(ma, &data, am->output->name);
+ else
+ set_sink_name(ma, &data, module_id);
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_CLASS, "sound");
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_API, PROP_DROID_API_STRING);
@@ -1297,7 +1284,10 @@
/* Rewind internal memblockq */
pa_sink_set_max_rewind(u->sink, 0);
- thread_name = pa_sprintf_malloc("droid-sink-%s", output->name);
+ if (am)
+ thread_name = pa_sprintf_malloc("droid-sink-%s", am->output->name);
+ else
+ thread_name = pa_sprintf_malloc("droid-sink-%s", module_id);
if (!(u->thread = pa_thread_new(thread_name, thread_func, u))) {
pa_log("Failed to create thread.");
goto fail;
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/droid/droid-source.c
^
|
@@ -51,7 +51,6 @@
#include <pulsecore/rtpoll.h>
#include <pulsecore/time-smoother.h>
#include <pulsecore/resampler.h>
-#include <pulse/version.h>
#include "droid-source.h"
#include <droid/droid-util.h>
@@ -74,6 +73,8 @@
size_t buffer_size;
pa_usec_t timestamp;
+ pa_hook_slot *input_buffer_size_changed_slot;
+ pa_hook_slot *input_channel_map_changed_slot;
pa_resampler *resampler;
pa_droid_card_data *card_data;
@@ -82,6 +83,10 @@
bool stream_valid;
};
+enum {
+ SOURCE_MESSAGE_DO_ROUTING = PA_SOURCE_MESSAGE_MAX
+};
+
#define DEFAULT_MODULE_ID "primary"
#define DROID_AUDIO_SOURCE "droid.audio_source"
@@ -90,22 +95,13 @@
static void userdata_free(struct userdata *u);
static int suspend(struct userdata *u);
static void unsuspend(struct userdata *u);
-static void source_reconfigure(struct userdata *u,
- const pa_sample_spec *reconfigure_sample_spec,
- const pa_channel_map *reconfigure_channel_map,
- audio_devices_t update_device);
-
-/* Our droid source may be left in a state of not having an input stream
- * if reconfiguration fails and fallback to previously active values fails
- * as well. In this case just avoid using the stream but don't die. */
-#define assert_stream(x, action) if (!x) do { pa_log_warn("Assert " #x " failed."); action; } while(0)
static int do_routing(struct userdata *u, audio_devices_t devices) {
int ret;
audio_devices_t old_device;
pa_assert(u);
- assert_stream(u->stream, return 0);
+ pa_assert(u->stream);
if (u->primary_devices == devices)
pa_log_debug("Refresh active device routing.");
@@ -212,11 +208,7 @@
pa_log_debug("Thread starting up.");
if (u->core->realtime_scheduling)
-#if PA_CHECK_VERSION(13,0,0)
- pa_thread_make_realtime(u->core->realtime_priority);
-#else
pa_make_realtime(u->core->realtime_priority);
-#endif
pa_thread_mq_install(&u->thread_mq);
@@ -233,7 +225,11 @@
pa_rtpoll_set_timer_disabled(u->rtpoll);
/* Sleep */
+#if (PULSEAUDIO_VERSION == 5)
+ if ((ret = pa_rtpoll_run(u->rtpoll, true)) < 0)
+#elif (PULSEAUDIO_VERSION >= 6)
if ((ret = pa_rtpoll_run(u->rtpoll)) < 0)
+#endif
goto fail;
if (ret == 0)
@@ -256,7 +252,7 @@
int ret;
pa_assert(u);
- assert_stream(u->stream, return 0);
+ pa_assert(u->stream);
ret = pa_droid_stream_suspend(u->stream, true);
@@ -269,10 +265,9 @@
/* Called from IO context */
static void unsuspend(struct userdata *u) {
pa_assert(u);
+ pa_assert(u->stream);
- if (!u->stream) {
- assert_stream(u->stream, u->stream_valid = false);
- } else if (pa_droid_stream_suspend(u->stream, false) >= 0) {
+ if (pa_droid_stream_suspend(u->stream, false) >= 0) {
u->stream_valid = true;
pa_log_info("Resuming...");
} else
@@ -326,17 +321,28 @@
/* Called from IO context */
static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
-#if PULSEAUDIO_VERSION < 12
struct userdata *u = PA_SOURCE(o)->userdata;
switch (code) {
+ case SOURCE_MESSAGE_DO_ROUTING: {
+ audio_devices_t device = PA_PTR_TO_UINT(data);
+
+ pa_assert(PA_SOURCE_IS_OPENED(u->source->thread_info.state));
+
+ suspend(u);
+ do_routing(u, device);
+ unsuspend(u);
+ break;
+ }
+
+#if PULSEAUDIO_VERSION < 12
case PA_SOURCE_MESSAGE_SET_STATE: {
int r;
if ((r = source_set_state_in_io_thread_cb(u->source, PA_PTR_TO_UINT(data), 0)) < 0)
return r;
}
- }
#endif
+ }
return pa_source_process_msg(o, code, data, offset, chunk);
}
@@ -358,12 +364,13 @@
return 0;
}
- pa_log_debug("Source set port %#010x", data->device);
+ pa_log_debug("Source set port %u", data->device);
- if (!PA_SOURCE_IS_OPENED(u->source->state))
+ if (!PA_SOURCE_IS_OPENED(pa_source_get_state(u->source)))
do_routing(u, data->device);
- else
- source_reconfigure(u, NULL, NULL, data->device);
+ else {
+ pa_asyncmsgq_post(u->source->asyncmsgq, PA_MSGOBJECT(u->source), SOURCE_MESSAGE_DO_ROUTING, PA_UINT_TO_PTR(data->device), 0, NULL, NULL);
+ }
return 0;
}
@@ -389,30 +396,60 @@
}
}
+#if (PULSEAUDIO_VERSION == 5)
+static void source_get_mute_cb(pa_source *s) {
+#elif (PULSEAUDIO_VERSION >= 6)
static int source_get_mute_cb(pa_source *s, bool *muted) {
+#endif
struct userdata *u = s->userdata;
+ int ret = 0;
+ bool b;
pa_assert(u);
- pa_assert(u->hw_module);
+ pa_assert(u->hw_module && u->hw_module->device);
+
+ pa_droid_hw_module_lock(u->hw_module);
+ if (u->hw_module->device->get_mic_mute(u->hw_module->device, &b) < 0) {
+ pa_log("Failed to get mute state.");
+ ret = -1;
+ }
+ pa_droid_hw_module_unlock(u->hw_module);
- return pa_droid_hw_mic_get_mute(u->hw_module, muted);
+#if (PULSEAUDIO_VERSION == 5)
+ if (ret == 0)
+ s->muted = b;
+#elif (PULSEAUDIO_VERSION >= 6)
+ if (ret == 0)
+ *muted = b;
+
+ return ret;
+#endif
}
static void source_set_mute_cb(pa_source *s) {
struct userdata *u = s->userdata;
pa_assert(u);
+ pa_assert(u->hw_module && u->hw_module->device);
- pa_droid_hw_mic_set_mute(u->hw_module, s->muted);
+ pa_droid_hw_module_lock(u->hw_module);
+ if (u->hw_module->device->set_mic_mute(u->hw_module->device, s->muted) < 0)
+ pa_log("Failed to set mute state to %smuted.", s->muted ? "" : "un");
+ pa_droid_hw_module_unlock(u->hw_module);
}
static void source_set_mute_control(struct userdata *u) {
pa_assert(u);
pa_assert(u->hw_module && u->hw_module->device);
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/droid/keepalive.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 <signal.h>
+#include <stdio.h>
+
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
+
+#include <pulse/rtclock.h>
+#include <pulse/timeval.h>
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/core.h>
+#include <pulsecore/core-error.h>
+#include <pulsecore/dbus-shared.h>
+#include <pulsecore/dbus-util.h>
+#include <pulsecore/atomic.h>
+
+#include "keepalive.h"
+
+#define MCE_BUS (DBUS_BUS_SYSTEM)
+#define MCE_DBUS_NAME "com.nokia.mce"
+#define MCE_DBUS_PATH "/com/nokia/mce/request"
+#define MCE_DBUS_IFACE "com.nokia.mce.request"
+#define MCE_DBUS_KEEPALIVE_PERIOD_REQ "req_cpu_keepalive_period"
+#define MCE_DBUS_KEEPALIVE_START_REQ "req_cpu_keepalive_start"
+#define MCE_DBUS_KEEPALIVE_STOP_REQ "req_cpu_keepalive_stop"
+
+struct pa_droid_keepalive {
+ pa_core *core;
+ pa_dbus_connection *dbus_connection;
+ DBusPendingCall *pending;
+
+ pa_atomic_t started;
+ pa_usec_t timeout;
+ pa_time_event *timer_event;
+
+};
+
+pa_droid_keepalive* pa_droid_keepalive_new(pa_core *c) {
+ pa_droid_keepalive *k;
+ pa_dbus_connection *dbus;
+ DBusError error;
+
+ pa_assert(c);
+
+ dbus_error_init(&error);
+
+ dbus = pa_dbus_bus_get(c, MCE_BUS, &error);
+ if (dbus_error_is_set(&error)) {
+ pa_log("Failed to get %s bus: %s", MCE_BUS == DBUS_BUS_SESSION ? "session" : "system", error.message);
+ dbus_error_free(&error);
+ return NULL;
+ }
+
+ k = pa_xnew0(pa_droid_keepalive, 1);
+ k->core = c;
+ k->dbus_connection = dbus;
+ k->timeout = 0;
+ pa_atomic_store(&k->started, 0);
+
+ return k;
+}
+
+static void send_dbus_signal(pa_dbus_connection *dbus) {
+ DBusMessage *msg;
+
+ pa_assert(dbus);
+
+ /* pa_log_debug("Send keepalive heartbeat."); */
+
+ pa_assert_se((msg = dbus_message_new_method_call(MCE_DBUS_NAME,
+ MCE_DBUS_PATH,
+ MCE_DBUS_IFACE,
+ MCE_DBUS_KEEPALIVE_START_REQ)));
+
+ dbus_connection_send(pa_dbus_connection_get(dbus), msg, NULL);
+ dbus_message_unref(msg);
+}
+
+static void keepalive_cb(pa_mainloop_api *m, pa_time_event *e, const struct timeval *t, void *userdata) {
+ pa_droid_keepalive *k = userdata;
+
+ pa_assert(k);
+ pa_assert(k->timer_event == e);
+
+ send_dbus_signal(k->dbus_connection);
+ pa_core_rttime_restart(k->core, k->timer_event, pa_rtclock_now() + k->timeout);
+}
+
+static void keepalive_start(pa_droid_keepalive *k) {
+ pa_assert(k);
+ pa_assert(k->timeout);
+ pa_assert(!k->timer_event);
+
+ pa_log_info("Start keepalive heartbeat with interval %lu seconds.", (unsigned long) (k->timeout / PA_USEC_PER_SEC));
+
+ /* Send first keepalive heartbeat immediately. */
+ send_dbus_signal(k->dbus_connection);
+
+ k->timer_event = pa_core_rttime_new(k->core, pa_rtclock_now() + k->timeout, keepalive_cb, k);
+}
+
+static void pending_req_reply_cb(DBusPendingCall *pending, void *userdata) {
+ pa_droid_keepalive *k = userdata;
+ DBusMessage *msg;
+ uint32_t period;
+
+ pa_assert(pending);
+ pa_assert(k);
+ pa_assert(pending == k->pending);
+
+ k->pending = NULL;
+ pa_assert_se(msg = dbus_pending_call_steal_reply(pending));
+
+ if (dbus_message_get_type(msg) == DBUS_MESSAGE_TYPE_ERROR) {
+ pa_log("Failed to get %s", MCE_DBUS_KEEPALIVE_PERIOD_REQ);
+ goto finish;
+ }
+
+ pa_assert_se(dbus_message_get_args(msg, NULL,
+ DBUS_TYPE_INT32, &period,
+ DBUS_TYPE_INVALID));
+
+ k->timeout = PA_USEC_PER_SEC * period;
+
+ keepalive_start(k);
+
+finish:
+ dbus_message_unref(msg);
+ dbus_pending_call_unref(pending);
+}
+
+void pa_droid_keepalive_start(pa_droid_keepalive *k) {
+ DBusMessage *msg = NULL;
+
+ pa_assert(k);
+
+ /* Only allow first call go through. pa_atomic_inc() returns previous value before incrementing. */
+ if (pa_atomic_inc(&k->started) > 0)
+ return;
+
+ pa_assert(!k->timer_event);
+ pa_assert(!k->pending);
+
+ /* Period time already requested, just start hearbeat. */
+ if (k->timeout > 0) {
+ keepalive_start(k);
+ return;
+ }
+
+ pa_log_debug("Starting keepalive - Request keepalive period.");
+ /* Send first keepalive heartbeat immediately. */
+ send_dbus_signal(k->dbus_connection);
+
+ pa_assert_se((msg = dbus_message_new_method_call(MCE_DBUS_NAME,
+ MCE_DBUS_PATH,
+ MCE_DBUS_IFACE,
+ MCE_DBUS_KEEPALIVE_PERIOD_REQ)));
+
+ dbus_connection_send_with_reply(pa_dbus_connection_get(k->dbus_connection), msg, &k->pending, -1);
+ dbus_message_unref(msg);
+
+ if (k->pending)
+ dbus_pending_call_set_notify(k->pending, pending_req_reply_cb, k, NULL);
+ else
+ pa_log("D-Bus method call failed.");
+}
+
+void pa_droid_keepalive_stop(pa_droid_keepalive *k) {
+ DBusMessage *msg;
+
+ pa_assert(k);
+
+ /* Only allow last call go through. pa_atomic_dec() returns previous value before decrementing. */
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/droid/keepalive.h
^
|
@@ -0,0 +1,44 @@
+#ifndef foodroidkeepalivefoo
+#define foodroidkeepalivefoo
+
+/*
+ * 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.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/dbus-shared.h>
+#include <pulsecore/atomic.h>
+
+typedef struct pa_droid_keepalive pa_droid_keepalive;
+
+pa_droid_keepalive* pa_droid_keepalive_new(pa_core *c);
+void pa_droid_keepalive_free(pa_droid_keepalive *k);
+
+void pa_droid_keepalive_start(pa_droid_keepalive *k);
+void pa_droid_keepalive_stop(pa_droid_keepalive *k);
+
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/droid/module-droid-card.c
^
|
@@ -60,7 +60,6 @@
//#include <droid/system/audio_policy.h>
#include <droid/droid-util.h>
-#include <droid/sllist.h>
#include "droid-sink.h"
#include "droid-source.h"
@@ -83,7 +82,7 @@
"voice_property_key=<proplist key searched for sink-input that should control voice call volume> "
"voice_property_value=<proplist value for the key for voice control sink-input> "
"default_profile=<boolean. create default profile for primary module or not. defaults to true> "
- "merge_inputs=<unused, always true> "
+ "merge_inputs=<boolean. merge input streams to single source with default profile. defaults to true> "
"quirks=<comma separated list of quirks to enable/disable>"
);
@@ -117,7 +116,6 @@
"voice_property_value",
"default_profile",
"combine",
- "merge_inputs",
"quirks",
NULL,
};
@@ -240,7 +238,7 @@
pa_hashmap *profiles) {
pa_droid_profile *ap;
pa_card_profile *cp;
- struct profile_data *d;
+ struct profile_data *d, *ext;
pa_assert(u);
pa_assert(u->profile_set);
@@ -300,19 +298,6 @@
data->namereg_fail = false;
}
-static bool output_enabled(struct userdata *u, pa_droid_mapping *am) {
- pa_assert(u);
- pa_assert(am);
-
- if (!pa_droid_quirk(u->hw_module, QUIRK_OUTPUT_FAST) && am->output->flags & AUDIO_OUTPUT_FLAG_FAST)
- return false;
-
- if (!pa_droid_quirk(u->hw_module, QUIRK_OUTPUT_DEEP_BUFFER) && am->output->flags & AUDIO_OUTPUT_FLAG_DEEP_BUFFER)
- return false;
-
- return true;
-}
-
static void add_profile(struct userdata *u, pa_hashmap *h, pa_hashmap *ports, pa_droid_profile *ap) {
pa_card_profile *cp;
struct profile_data *d;
@@ -333,9 +318,6 @@
max_channels = 0;
PA_IDXSET_FOREACH(am, ap->output_mappings, idx) {
- if (!output_enabled(u, am))
- continue;
-
cp->n_sinks++;
pa_droid_add_card_ports(cp, ports, am, u->core);
max_channels = popcount(am->output->channel_masks) > max_channels
@@ -344,13 +326,11 @@
cp->max_sink_channels = max_channels;
max_channels = 0;
- if ((am = ap->input_mapping)) {
- const pa_droid_config_device *input;
+ PA_IDXSET_FOREACH(am, ap->input_mappings, idx) {
cp->n_sources++;
pa_droid_add_card_ports(cp, ports, am, u->core);
- SLLIST_FOREACH(input, am->inputs)
- max_channels = popcount(input->channel_masks) > max_channels
- ? popcount(input->channel_masks) : max_channels;
+ max_channels = popcount(am->input->channel_masks) > max_channels
+ ? popcount(am->input->channel_masks) : max_channels;
}
cp->max_source_channels = max_channels;
@@ -389,18 +369,50 @@
if (d->droid_profile && pa_idxset_size(d->droid_profile->output_mappings) > 0) {
PA_IDXSET_FOREACH(am, d->droid_profile->output_mappings, idx) {
- if (!output_enabled(u, am))
- continue;
-
am->sink = pa_droid_sink_new(u->module, u->modargs, __FILE__, &u->card_data, 0, am, u->card);
}
}
- if (d->droid_profile && (am = d->droid_profile->input_mapping)) {
- am->source = pa_droid_source_new(u->module, u->modargs, __FILE__, (audio_devices_t) 0, &u->card_data, am, u->card);
+ if (d->droid_profile && pa_idxset_size(d->droid_profile->input_mappings) > 0) {
+ PA_IDXSET_FOREACH(am, d->droid_profile->input_mappings, idx) {
+ am->source = pa_droid_source_new(u->module, u->modargs, __FILE__, (audio_devices_t) 0, &u->card_data, am, u->card);
+ }
}
}
+static int set_mode(struct userdata *u, audio_mode_t mode) {
+ int ret;
+ const char *mode_str;
+
+ pa_assert(u);
+ pa_assert(u->hw_module);
+ pa_assert(u->hw_module->device);
+
+ switch (mode) {
+ case AUDIO_MODE_RINGTONE:
+ mode_str = "AUDIO_MODE_RINGTONE";
+ break;
+ case AUDIO_MODE_IN_CALL:
+ mode_str = "AUDIO_MODE_IN_CALL";
+ break;
+ case AUDIO_MODE_IN_COMMUNICATION:
+ mode_str = "AUDIO_MODE_IN_COMMUNICATION";
+ break;
+ default:
+ mode_str = "AUDIO_MODE_NORMAL";
+ break;
+ }
+
+ pa_log_debug("Set mode to %s.", mode_str);
+
+ pa_droid_hw_module_lock(u->hw_module);
+ if ((ret = u->hw_module->device->set_mode(u->hw_module->device, mode)) < 0)
+ pa_log("Failed to set mode.");
+ pa_droid_hw_module_unlock(u->hw_module);
+
+ return ret;
+}
+
static void park_profile(pa_droid_profile *dp) {
pa_droid_mapping *am;
uint32_t idx;
@@ -416,9 +428,11 @@
};
/* Virtual profiles don't have input mappings. */
- if ((am = dp->input_mapping)) {
- if (pa_droid_mapping_is_primary(am))
- pa_source_set_port(am->source, PA_DROID_INPUT_PARKING, false);
+ if (dp->input_mappings) {
+ PA_IDXSET_FOREACH(am, dp->input_mappings, idx) {
+ if (pa_droid_mapping_is_primary(am))
+ pa_source_set_port(am->source, PA_DROID_INPUT_PARKING, false);
+ }
};
}
@@ -433,6 +447,7 @@
static bool voicecall_profile_event_cb(struct userdata *u, pa_droid_profile *p, bool enabling) {
pa_droid_profile *dp = NULL;
+ pa_card_profile *cp = NULL;
pa_droid_mapping *am_output;
pa_assert(u);
@@ -544,7 +559,7 @@
if (next->mode != current->mode) {
park_profile(current->droid_profile);
- pa_droid_hw_set_mode(u->hw_module, next->mode);
+ set_mode(u, next->mode);
}
virtual_event(u, current, false);
@@ -597,7 +612,7 @@
if (next->mode != current->mode) {
park_profile(current->droid_profile);
- pa_droid_hw_set_mode(u->hw_module, next->mode);
+ set_mode(u, next->mode);
}
if (next->virtual.parent) {
@@ -670,8 +685,15 @@
}
}
- if (curr->droid_profile && (am = curr->droid_profile->input_mapping)) {
- if (am->source && next->droid_profile && next->droid_profile->input_mapping) {
+ if (curr->droid_profile && pa_idxset_size(curr->droid_profile->input_mappings) > 0) {
+ PA_IDXSET_FOREACH(am, curr->droid_profile->input_mappings, idx) {
+ if (!am->source)
+ continue;
+
+ if (next->droid_profile &&
+ pa_idxset_get_by_data(next->droid_profile->input_mappings, am, NULL))
+ continue;
+
source_outputs = pa_source_move_all_start(am->source, source_outputs);
pa_droid_source_free(am->source);
am->source = NULL;
@@ -680,9 +702,6 @@
if (next->droid_profile && pa_idxset_size(next->droid_profile->output_mappings) > 0) {
PA_IDXSET_FOREACH(am, next->droid_profile->output_mappings, idx) {
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/droid/module-droid-keepalive-symdef.h
^
|
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+#ifndef foomoduledroidkeepalivesymdeffoo
+#define foomoduledroidkeepalivesymdeffoo
+
+#include <pulsecore/core.h>
+#include <pulsecore/module.h>
+
+#define pa__init module_droid_keepalive_LTX_pa__init
+#define pa__done module_droid_keepalive_LTX_pa__done
+#define pa__get_author module_droid_keepalive_LTX_pa__get_author
+#define pa__get_description module_droid_keepalive_LTX_pa__get_description
+#define pa__get_usage module_droid_keepalive_LTX_pa__get_usage
+#define pa__get_version module_droid_keepalive_LTX_pa__get_version
+
+int pa__init(struct pa_module*m);
+void pa__done(struct pa_module*m);
+
+const char* pa__get_author(void);
+const char* pa__get_description(void);
+const char* pa__get_usage(void);
+const char* pa__get_version(void);
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/droid/module-droid-keepalive.c
^
|
@@ -0,0 +1,198 @@
+/*
+ * 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 <signal.h>
+#include <stdio.h>
+
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
+
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/core.h>
+#include <pulsecore/i18n.h>
+#include <pulsecore/module.h>
+#include <pulsecore/sink.h>
+#include <pulsecore/source.h>
+#include <pulsecore/modargs.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/idxset.h>
+
+#include "keepalive.h"
+
+#include "module-droid-keepalive-symdef.h"
+
+PA_MODULE_AUTHOR("Juho Hämäläinen");
+PA_MODULE_DESCRIPTION("Droid keepalive. Send cpu wakeup heartbeat while streams are active.");
+PA_MODULE_VERSION(PACKAGE_VERSION);
+PA_MODULE_USAGE(
+ "-"
+);
+
+static const char* const valid_modargs[] = {
+ NULL,
+};
+
+struct userdata {
+ pa_core *core;
+ pa_module *module;
+
+ pa_droid_keepalive *keepalive;
+ bool active;
+ pa_hook_slot *sink_state_changed_slot;
+ pa_hook_slot *source_state_changed_slot;
+};
+
+static void start(struct userdata *u) {
+ if (u->active)
+ return;
+
+ u->active = true;
+
+ pa_droid_keepalive_start(u->keepalive);
+}
+
+static void stop(struct userdata *u) {
+ void *state = NULL;
+ pa_sink *sink;
+ pa_source *source;
+
+ if (!u->active)
+ return;
+
+ while ((sink = pa_idxset_iterate(u->core->sinks, &state, NULL))) {
+ if (pa_sink_get_state(sink) != PA_SINK_SUSPENDED)
+ return;
+ }
+
+ state = NULL;
+ while ((source = pa_idxset_iterate(u->core->sources, &state, NULL))) {
+ if (source->monitor_of)
+ continue;
+ if (pa_source_get_state(source) != PA_SOURCE_SUSPENDED)
+ return;
+ }
+
+ /* We get here if all sinks and sources are in suspended state. */
+ pa_droid_keepalive_stop(u->keepalive);
+ u->active = false;
+}
+
+static void update_sink(pa_sink *sink, struct userdata *u) {
+ pa_assert(sink);
+ pa_assert(u);
+
+ if (pa_sink_get_state(sink) != PA_SINK_SUSPENDED)
+ start(u);
+ else
+ stop(u);
+}
+
+static void update_source(pa_source *source, struct userdata *u) {
+ pa_assert(source);
+ pa_assert(u);
+
+ /* 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);
+
+ u = pa_xnew0(struct userdata, 1);
+ u->core = m->core;
+ u->active = false;
+ u->module = m;
+ m->userdata = u;
+
+ if (!(u->keepalive = pa_droid_keepalive_new(u->core))) {
+ pa_log("Failed to create keepalive handler.");
+ goto fail;
+ }
+
+ 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:
+ pa__done(m);
+
+ return -1;
+}
+
+void pa__done(pa_module *m) {
+ struct userdata *u;
+
+ pa_assert(m);
+
+ if ((u = m->userdata)) {
+
+ if (u->sink_state_changed_slot)
+ pa_hook_slot_free(u->sink_state_changed_slot);
+ if (u->source_state_changed_slot)
+ pa_hook_slot_free(u->source_state_changed_slot);
+
+ if (u->keepalive) {
+ pa_droid_keepalive_stop(u->keepalive);
+ pa_droid_keepalive_free(u->keepalive);
+ }
+
+ pa_xfree(u);
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:pulseaudio-modules-droid-12.2.79.tar.bz2/src/droid/module-droid-sink.c
^
|
@@ -60,7 +60,6 @@
"sink_channel_map",
"sink_mix_route",
"flags",
- "output",
"output_devices",
"sink_name",
"module_id",
|