Commit f0d32e94 authored by Igor Kovalenko's avatar Igor Kovalenko Committed by PulseAudio Marge Bot
Browse files

bluetooth: add mSBC to backend-ofono

Part-of: <!507>
parent 030dc8b9
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment