diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c index cbd151aa5..5f0b0210d 100644 --- a/src/modules/bluetooth/backend-ofono.c +++ b/src/modules/bluetooth/backend-ofono.c @@ -220,14 +220,21 @@ static int card_acquire(struct hf_audio_card *card) { DBUS_TYPE_BYTE, &codec, DBUS_TYPE_INVALID) == true)) { dbus_message_unref(r); - if (codec != HFP_AUDIO_CODEC_CVSD) { + + if (codec == HFP_AUDIO_CODEC_CVSD) { + pa_bluetooth_transport_reconfigure(card->transport, pa_bluetooth_get_hf_codec("CVSD"), sco_transport_write, NULL); + } else if (codec == HFP_AUDIO_CODEC_MSBC) { + /* oFono is expected to set up socket BT_VOICE_TRANSPARENT option */ + pa_bluetooth_transport_reconfigure(card->transport, pa_bluetooth_get_hf_codec("mSBC"), sco_transport_write, NULL); + } else { + pa_assert_fp(codec != HFP_AUDIO_CODEC_CVSD && codec != HFP_AUDIO_CODEC_MSBC); pa_log_error("Invalid codec: %u", codec); /* shutdown to make sure connection is dropped immediately */ shutdown(fd, SHUT_RDWR); close(fd); return -1; } - pa_bluetooth_transport_reconfigure(card->transport, pa_bluetooth_get_hf_codec("CVSD"), sco_transport_write, NULL); + card->fd = fd; return 0; } @@ -538,6 +545,7 @@ static void hf_audio_agent_register(pa_bluetooth_backend *hf) { pa_assert_se(m = dbus_message_new_method_call(OFONO_SERVICE, "/", HF_AUDIO_MANAGER_INTERFACE, "Register")); codecs[ncodecs++] = HFP_AUDIO_CODEC_CVSD; + codecs[ncodecs++] = HFP_AUDIO_CODEC_MSBC; pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &pcodecs, ncodecs, DBUS_TYPE_INVALID)); @@ -683,7 +691,7 @@ static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage card = pa_hashmap_get(backend->cards, path); - if (!card || codec != HFP_AUDIO_CODEC_CVSD || card->fd >= 0) { + if (!card || (codec != HFP_AUDIO_CODEC_CVSD && codec != HFP_AUDIO_CODEC_MSBC) || card->fd >= 0) { pa_log_warn("New audio connection invalid arguments (path=%s fd=%d, codec=%d)", path, fd, codec); pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Invalid arguments in method call")); shutdown(fd, SHUT_RDWR); @@ -695,7 +703,12 @@ static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage card->connecting = false; card->fd = fd; - pa_bluetooth_transport_reconfigure(card->transport, pa_bluetooth_get_hf_codec("CVSD"), sco_transport_write, NULL); + if (codec == HFP_AUDIO_CODEC_CVSD) { + pa_bluetooth_transport_reconfigure(card->transport, pa_bluetooth_get_hf_codec("CVSD"), sco_transport_write, NULL); + } else if (codec == HFP_AUDIO_CODEC_MSBC) { + /* oFono is expected to set up socket BT_VOICE_TRANSPARENT option */ + pa_bluetooth_transport_reconfigure(card->transport, pa_bluetooth_get_hf_codec("mSBC"), sco_transport_write, NULL); + } pa_bluetooth_transport_set_state(card->transport, PA_BLUETOOTH_TRANSPORT_STATE_PLAYING);