From d0ae6ca081ac5382fb541f4c426c588c37b53184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20H=C3=A4m=C3=A4l=C3=A4inen?= Date: Mon, 4 Sep 2017 10:46:10 +0300 Subject: [PATCH 1/3] [common] Have correct type for function. --- src/common/droid-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/droid-util.c b/src/common/droid-util.c index af371b6..4f228e5 100644 --- a/src/common/droid-util.c +++ b/src/common/droid-util.c @@ -393,8 +393,8 @@ static bool parse_formats(const char *fn, const unsigned ln, return check_and_log(fn, ln, "formats", count, str, unknown, false); } -static int parse_channels(const char *fn, const unsigned ln, - const char *str, bool in_output, audio_channel_mask_t *channels) { +static bool parse_channels(const char *fn, const unsigned ln, + const char *str, bool in_output, audio_channel_mask_t *channels) { int count; char *unknown = NULL; From f0e679dbc198a0af6508d103bc1d3c017b75b5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20H=C3=A4m=C3=A4l=C3=A4inen?= Date: Mon, 4 Sep 2017 10:47:11 +0300 Subject: [PATCH 2/3] [sink] Fix segfault when running standalone sink. We need to check droid mapping pointer as well. --- src/droid/droid-sink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/droid/droid-sink.c b/src/droid/droid-sink.c index 1db912d..c82ca30 100644 --- a/src/droid/droid-sink.c +++ b/src/droid/droid-sink.c @@ -1177,8 +1177,8 @@ pa_sink *pa_droid_sink_new(pa_module *m, } /* Default routing */ - dev_out = am->output->module->global_config ? am->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; From 887177a194432e4dcc93964b21a4b1be81ae3280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20H=C3=A4m=C3=A4l=C3=A4inen?= Date: Mon, 4 Sep 2017 12:38:21 +0300 Subject: [PATCH 3/3] [common] Fix output channel conversion. JB#39594 AUDIO_DEVICE_IN_ALL contains AUDIO_DEVICE_BIT_DEFAULT, like AUDIO_DEVICE_OUT_ALL, which meant that config was always filled with input channels, even when device was output device. Fix the logic so that correct channel mask is generated for output device as well. --- src/common/droid-util.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/common/droid-util.c b/src/common/droid-util.c index 4f228e5..280e218 100644 --- a/src/common/droid-util.c +++ b/src/common/droid-util.c @@ -1934,13 +1934,19 @@ static bool stream_config_fill(audio_devices_t devices, audio_format_t hal_audio_format = 0; audio_channel_mask_t hal_channel_mask = 0; bool voicecall_record = false; + bool output = true; pa_assert(sample_spec); pa_assert(channel_map); pa_assert(config); #if AUDIO_API_VERSION_MAJ >= 2 - devices &= ~AUDIO_DEVICE_BIT_IN; + if (devices & AUDIO_DEVICE_BIT_IN) { + output = false; + devices &= ~AUDIO_DEVICE_BIT_IN; + } +#else + output = !(devices & AUDIO_DEVICE_IN_ALL); #endif if (devices & AUDIO_DEVICE_IN_VOICE_CALL) @@ -1951,24 +1957,19 @@ static bool stream_config_fill(audio_devices_t devices, goto fail; } - if (devices & AUDIO_DEVICE_IN_ALL) { - for (int i = 0; i < channel_map->channels; i++) { - audio_channel_mask_t c; - if (!pa_convert_input_channel(channel_map->map[i], CONV_FROM_PA, &c)) { - pa_log("Failed to convert channel map."); - goto fail; - } - hal_channel_mask |= c; - } - } else { - for (int i = 0; i < channel_map->channels; i++) { - audio_channel_mask_t c; - if (!pa_convert_output_channel(channel_map->map[i], CONV_FROM_PA, &c)) { - pa_log("Failed to convert channel map."); - goto fail; - } - hal_channel_mask |= c; + for (int i = 0; i < channel_map->channels; i++) { + bool found; + audio_channel_mask_t c; + + found = output ? pa_convert_output_channel(channel_map->map[i], CONV_FROM_PA, &c) + : pa_convert_input_channel(channel_map->map[i], CONV_FROM_PA, &c); + + if (!found) { + pa_log("Failed to convert %s channel map.", output ? "output" : "input"); + goto fail; } + + hal_channel_mask |= c; } if (voicecall_record) {