src/daemon/default.pa.in | 4 + src/modules/bluetooth/module-bluetooth-device.c | 72 +++++++++++++++++------- src/modules/bluetooth/module-bluetooth-policy.c | 4 + src/modules/module-virtual-surround-sink.c | 6 +- 4 files changed, 64 insertions(+), 22 deletions(-)
New commits: commit 6ef23eb4af309018b5e0e834d634e92deef79877 Author: Mikel Astiz <[email protected]> Date: Mon Nov 26 18:32:09 2012 +0100 conf: Load bluetooth-policy module by default Headset use-cases shouldn't get affected by this module and the support for A2DP source is interesting, therefore load the module by default. diff --git a/src/daemon/default.pa.in b/src/daemon/default.pa.in index e3f1f4f..13e548b 100755 --- a/src/daemon/default.pa.in +++ b/src/daemon/default.pa.in @@ -84,6 +84,10 @@ load-module module-jackdbus-detect ifelse(@HAVE_BLUEZ@, 1, [dnl ### Automatically load driver modules for Bluetooth hardware +.ifexists module-bluetooth-policy@PA_SOEXT@ +load-module module-bluetooth-policy +.endif + .ifexists module-bluetooth-discover@PA_SOEXT@ load-module module-bluetooth-discover .endif commit 71bd458bd1f9c92e2d929b8741346112109b17e0 Author: Mikel Astiz <[email protected]> Date: Mon Nov 26 18:32:08 2012 +0100 bluetooth: Disable profile auto-switch policy for headsets Given that headsets have just one single port exposing whether the audio is streaming (playing) or not, it's not possible that module-bluetooth-policy would distinguish A2DP/HSP cases, and thus the automatic selection of the card profile is not deterministic. For this reason, disable the policy entirely for headsets and focus only on HFGW and A2DP source profiles. diff --git a/src/modules/bluetooth/module-bluetooth-policy.c b/src/modules/bluetooth/module-bluetooth-policy.c index 87a5716..f0bffe9 100644 --- a/src/modules/bluetooth/module-bluetooth-policy.c +++ b/src/modules/bluetooth/module-bluetooth-policy.c @@ -187,6 +187,10 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port if (!s || !pa_streq(s, "bluetooth")) return PA_HOOK_OK; + /* Do not automatically switch profiles for headsets, just in case */ + if (pa_hashmap_get(port->profiles, "hsp") || pa_hashmap_get(port->profiles, "a2dp")) + return PA_HOOK_OK; + is_active_profile = card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name); if (is_active_profile && port->available == PA_PORT_AVAILABLE_YES) commit 40329acc1a28145643e49207e9d65cd05bbda2c8 Author: Mikel Astiz <[email protected]> Date: Mon Nov 26 18:32:07 2012 +0100 bluetooth: Merge headset ports into one Merge the former "hsp-output" and "a2dp-output" ports into one single port, in order to fix the regression of having several independent entries in the UI. diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index dd1bb86..506a479 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -1281,6 +1281,15 @@ static pa_port_available_t audio_state_to_availability(pa_bt_audio_state_t state return PA_PORT_AVAILABLE_UNKNOWN; } +static pa_port_available_t audio_state_to_availability_merged(pa_bt_audio_state_t state1, pa_bt_audio_state_t state2) { + if (state1 < PA_BT_AUDIO_STATE_CONNECTED && state2 < PA_BT_AUDIO_STATE_CONNECTED) + return PA_PORT_AVAILABLE_NO; + else if (state1 >= PA_BT_AUDIO_STATE_PLAYING || state2 >= PA_BT_AUDIO_STATE_PLAYING) + return PA_PORT_AVAILABLE_YES; + else + return PA_PORT_AVAILABLE_UNKNOWN; +} + /* Run from main thread */ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *userdata) { DBusError err; @@ -1356,9 +1365,14 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us if (state != PA_BT_AUDIO_STATE_INVALID && pa_hashmap_get(u->card->profiles, "hsp")) { pa_device_port *port; - pa_port_available_t available = audio_state_to_availability(state); + pa_port_available_t available; - pa_assert_se(port = pa_hashmap_get(u->card->ports, "hsp-output")); + if (pa_hashmap_get(u->card->profiles, "a2dp") == NULL) + available = audio_state_to_availability(state); + else + available = audio_state_to_availability_merged(state, u->device->audio_sink_state); + + pa_assert_se(port = pa_hashmap_get(u->card->ports, "bluetooth-output")); pa_device_port_set_available(port, available); pa_assert_se(port = pa_hashmap_get(u->card->ports, "hsp-input")); @@ -1385,9 +1399,14 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us if (state != PA_BT_AUDIO_STATE_INVALID && pa_hashmap_get(u->card->profiles, "a2dp")) { pa_device_port *port; - pa_port_available_t available = audio_state_to_availability(state); + pa_port_available_t available; + + if (pa_hashmap_get(u->card->profiles, "hsp") == NULL) + available = audio_state_to_availability(state); + else + available = audio_state_to_availability_merged(state, u->device->headset_state); - pa_assert_se(port = pa_hashmap_get(u->card->ports, "a2dp-output")); + pa_assert_se(port = pa_hashmap_get(u->card->ports, "bluetooth-output")); pa_device_port_set_available(port, available); acquire = (available == PA_PORT_AVAILABLE_YES && u->profile == PROFILE_A2DP); @@ -1614,7 +1633,7 @@ static void connect_ports(struct userdata *u, void *sink_or_source_new_data, pa_ switch (u->profile) { case PROFILE_A2DP: - pa_assert_se(port = pa_hashmap_get(u->card->ports, "a2dp-output")); + pa_assert_se(port = pa_hashmap_get(u->card->ports, "bluetooth-output")); pa_assert_se(pa_hashmap_put(data.sink_new_data->ports, port->name, port) >= 0); pa_device_port_ref(port); break; @@ -1627,7 +1646,7 @@ static void connect_ports(struct userdata *u, void *sink_or_source_new_data, pa_ case PROFILE_HSP: if (direction == PA_DIRECTION_OUTPUT) { - pa_assert_se(port = pa_hashmap_get(u->card->ports, "hsp-output")); + pa_assert_se(port = pa_hashmap_get(u->card->ports, "bluetooth-output")); pa_assert_se(pa_hashmap_put(data.sink_new_data->ports, port->name, port) >= 0); } else { pa_assert_se(port = pa_hashmap_get(u->card->ports, "hsp-input")); @@ -2247,13 +2266,20 @@ static void create_ports_for_profile(struct userdata *u, pa_hashmap *ports, pa_c switch (*d) { case PROFILE_A2DP: - pa_assert_se(port = pa_device_port_new(u->core, "a2dp-output", _("Bluetooth High Quality (A2DP)"), 0)); - pa_assert_se(pa_hashmap_put(ports, port->name, port) >= 0); - port->is_output = 1; - port->is_input = 0; - port->priority = profile->priority * 100; - port->available = audio_state_to_availability(device->audio_sink_state); - pa_hashmap_put(port->profiles, profile->name, profile); + if ((port = pa_hashmap_get(ports, "bluetooth-output")) != NULL) { + port->priority = PA_MAX(port->priority, profile->priority * 100); + port->available = audio_state_to_availability_merged(device->headset_state, device->audio_sink_state); + pa_hashmap_put(port->profiles, profile->name, profile); + } else { + pa_assert_se(port = pa_device_port_new(u->core, "bluetooth-output", _("Bluetooth Output"), 0)); + pa_assert_se(pa_hashmap_put(ports, port->name, port) >= 0); + port->is_output = 1; + port->is_input = 0; + port->priority = profile->priority * 100; + port->available = audio_state_to_availability(device->audio_sink_state); + pa_hashmap_put(port->profiles, profile->name, profile); + } + break; case PROFILE_A2DP_SOURCE: @@ -2267,13 +2293,19 @@ static void create_ports_for_profile(struct userdata *u, pa_hashmap *ports, pa_c break; case PROFILE_HSP: - pa_assert_se(port = pa_device_port_new(u->core, "hsp-output", _("Bluetooth Telephony (HSP/HFP)"), 0)); - pa_assert_se(pa_hashmap_put(ports, port->name, port) >= 0); - port->is_output = 1; - port->is_input = 0; - port->priority = profile->priority * 100; - port->available = audio_state_to_availability(device->headset_state); - pa_hashmap_put(port->profiles, profile->name, profile); + if ((port = pa_hashmap_get(ports, "bluetooth-output")) != NULL) { + port->priority = PA_MAX(port->priority, profile->priority * 100); + port->available = audio_state_to_availability_merged(device->headset_state, device->audio_sink_state); + pa_hashmap_put(port->profiles, profile->name, profile); + } else { + pa_assert_se(port = pa_device_port_new(u->core, "bluetooth-output", _("Bluetooth Output"), 0)); + pa_assert_se(pa_hashmap_put(ports, port->name, port) >= 0); + port->is_output = 1; + port->is_input = 0; + port->priority = profile->priority * 100; + port->available = audio_state_to_availability(device->headset_state); + pa_hashmap_put(port->profiles, profile->name, profile); + } pa_assert_se(port = pa_device_port_new(u->core, "hsp-input", _("Bluetooth Telephony (HSP/HFP)"), 0)); pa_assert_se(pa_hashmap_put(ports, port->name, port) >= 0); commit 523af5b30220df76515b8b9fa62d0f80bffc541f Author: Niels Ole Salscheider <[email protected]> Date: Sat Nov 24 12:32:51 2012 +0100 virtual-surround: check if resampled memblock is not equal to input Since commit e32a408b3cdd46857fdf12210c1bf5bdbf3a96f8, we silence the input memblock in order to give the resampler enough input samples, if necessary. But if there is no need to resample the hrir, the resampled memblock is actually the same as the input memblock. Thus, we have to make sure that we do not silence it in this case. diff --git a/src/modules/module-virtual-surround-sink.c b/src/modules/module-virtual-surround-sink.c index 4915278..adaa58f 100644 --- a/src/modules/module-virtual-surround-sink.c +++ b/src/modules/module-virtual-surround-sink.c @@ -738,8 +738,10 @@ int pa__init(pa_module*m) { /* add silence to the hrir until we get enough samples out of the resampler */ while (hrir_copied_length < hrir_total_length) { pa_resampler_run(resampler, &hrir_temp_chunk, &hrir_temp_chunk_resampled); - /* Silence input block */ - pa_silence_memblock(hrir_temp_chunk.memblock, &hrir_temp_ss); + if (hrir_temp_chunk.memblock != hrir_temp_chunk_resampled.memblock) { + /* Silence input block */ + pa_silence_memblock(hrir_temp_chunk.memblock, &hrir_temp_ss); + } if (hrir_temp_chunk_resampled.memblock) { /* Copy hrir data */ _______________________________________________ pulseaudio-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/pulseaudio-commits
