Merge lp:~tiagosh/telepathy-ofono/fallback_a2dp into lp:telepathy-ofono

Proposed by Tiago Salem Herrmann
Status: Superseded
Proposed branch: lp:~tiagosh/telepathy-ofono/fallback_a2dp
Merge into: lp:telepathy-ofono
Diff against target: 137 lines (+60/-8)
3 files modified
connection.cpp (+1/-1)
qpulseaudioengine.cpp (+56/-6)
qpulseaudioengine.h (+3/-1)
To merge this branch: bzr merge lp:~tiagosh/telepathy-ofono/fallback_a2dp
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+278838@code.launchpad.net

This proposal has been superseded by a proposal from 2015-11-27.

Commit message

Fallback to a2dp if no profile is set.

Description of the change

Fallback to a2dp if no profile is set.

To post a comment you must log in.

Unmerged revisions

172. By Tiago Salem Herrmann

Fallback to a2dp if no profile is set

171. By Tiago Salem Herrmann

Set bluetooth device when playing the ringtone

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'connection.cpp'
--- connection.cpp 2015-10-13 19:29:54 +0000
+++ connection.cpp 2015-11-27 15:56:01 +0000
@@ -72,7 +72,7 @@
72static void enable_ringtone()72static void enable_ringtone()
73{73{
74#ifdef USE_PULSEAUDIO74#ifdef USE_PULSEAUDIO
75 QPulseAudioEngine::instance()->setCallMode(CallRinging, AudioModeWiredOrSpeaker);75 QPulseAudioEngine::instance()->setCallMode(CallRinging, AudioModeBtOrWiredOrSpeaker);
76#endif76#endif
77}77}
7878
7979
=== modified file 'qpulseaudioengine.cpp'
--- qpulseaudioengine.cpp 2015-11-10 07:49:07 +0000
+++ qpulseaudioengine.cpp 2015-11-27 15:56:01 +0000
@@ -113,6 +113,7 @@
113 , m_voicecallprofile("")113 , m_voicecallprofile("")
114 , m_bt_hsp("")114 , m_bt_hsp("")
115 , m_bt_hsp_a2dp("")115 , m_bt_hsp_a2dp("")
116 , m_default_bt_card_fallback("")
116117
117{118{
118 m_mainLoop = pa_threaded_mainloop_new();119 m_mainLoop = pa_threaded_mainloop_new();
@@ -658,14 +659,26 @@
658{659{
659 qDebug("Notified about card (%s) add event from PulseAudio", info->name);660 qDebug("Notified about card (%s) add event from PulseAudio", info->name);
660661
662 /* Check if it's indeed a BT device (with at least one hsp profile) */
663 pa_card_profile_info2 *hsp = NULL, *a2dp = NULL;
664 for (int i = 0; i < info->n_profiles; i++) {
665 if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_HSP))
666 hsp = info->profiles2[i];
667 else if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_A2DP) &&
668 info->profiles2[i]->available != 0) {
669 qDebug("Found a2dp");
670 a2dp = info->profiles2[i];
671 }
672 qDebug("%s", info->profiles2[i]->name);
673 }
674
675 if ((!info->active_profile || !strcmp(info->active_profile->name, "off")) && a2dp) {
676 qDebug("No profile set");
677 m_default_bt_card_fallback = info->name;
678 }
679
661 /* We only care about BT (HSP) devices, and if one is not already available */680 /* We only care about BT (HSP) devices, and if one is not already available */
662 if ((m_callstatus != CallEnded) && ((m_bt_hsp == "") || (m_bt_hsp_a2dp == ""))) {681 if ((m_callstatus != CallEnded) && ((m_bt_hsp == "") || (m_bt_hsp_a2dp == ""))) {
663 /* Check if it's indeed a BT device (with at least one hsp profile) */
664 pa_card_profile_info *hsp = NULL;
665 for (int i = 0; i < info->n_profiles; i++) {
666 if (!strcmp(info->profiles[i].name, PULSEAUDIO_PROFILE_HSP))
667 hsp = &info->profiles[i];
668 }
669 if (hsp)682 if (hsp)
670 m_handleevent = true;683 m_handleevent = true;
671 }684 }
@@ -675,6 +688,25 @@
675{688{
676 qDebug("Notified about card (%s) changes event from PulseAudio", info->name);689 qDebug("Notified about card (%s) changes event from PulseAudio", info->name);
677690
691 /* Check if it's indeed a BT device (with at least one hsp profile) */
692 pa_card_profile_info2 *hsp = NULL, *a2dp = NULL;
693 for (int i = 0; i < info->n_profiles; i++) {
694 if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_HSP))
695 hsp = info->profiles2[i];
696 else if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_A2DP) &&
697 info->profiles2[i]->available != 0) {
698 qDebug("Found a2dp");
699 a2dp = info->profiles2[i];
700 }
701 qDebug("%s", info->profiles2[i]->name);
702 }
703
704 if ((!info->active_profile || !strcmp(info->active_profile->name, "off")) && a2dp) {
705 qDebug("No profile set");
706 m_default_bt_card_fallback = info->name;
707 }
708
709
678 /* We only care if the card event for the voicecall capable card */710 /* We only care if the card event for the voicecall capable card */
679 if ((m_callstatus == CallActive) && (!strcmp(info->name, m_voicecallcard.c_str()))) {711 if ((m_callstatus == CallActive) && (!strcmp(info->name, m_voicecallcard.c_str()))) {
680 if (m_audiomode == AudioModeWiredHeadset) {712 if (m_audiomode == AudioModeWiredHeadset) {
@@ -718,6 +750,15 @@
718 o = pa_context_get_card_info_by_index(m_context, idx, plug_card_cb, this);750 o = pa_context_get_card_info_by_index(m_context, idx, plug_card_cb, this);
719 if (!handleOperation(o, "pa_context_get_card_info_by_index"))751 if (!handleOperation(o, "pa_context_get_card_info_by_index"))
720 return;752 return;
753
754 if (m_default_bt_card_fallback != "") {
755 o = pa_context_set_card_profile_by_name(m_context,
756 m_default_bt_card_fallback.c_str(), PULSEAUDIO_PROFILE_A2DP, success_cb, this);
757 if (!handleOperation(o, "pa_context_set_card_profile_by_name"))
758 return;
759 m_default_bt_card_fallback = "";
760 }
761
721 if (m_handleevent) {762 if (m_handleevent) {
722 qDebug("Adding new BT-HSP capable device");763 qDebug("Adding new BT-HSP capable device");
723 /* In case A2DP is available, switch to HSP */764 /* In case A2DP is available, switch to HSP */
@@ -730,6 +771,15 @@
730 o = pa_context_get_card_info_by_index(m_context, idx, update_card_cb, this);771 o = pa_context_get_card_info_by_index(m_context, idx, update_card_cb, this);
731 if (!handleOperation(o, "pa_context_get_card_info_by_index"))772 if (!handleOperation(o, "pa_context_get_card_info_by_index"))
732 return;773 return;
774
775 if (m_default_bt_card_fallback != "") {
776 o = pa_context_set_card_profile_by_name(m_context,
777 m_default_bt_card_fallback.c_str(), PULSEAUDIO_PROFILE_A2DP, success_cb, this);
778 if (!handleOperation(o, "pa_context_set_card_profile_by_name"))
779 return;
780 m_default_bt_card_fallback = "";
781 }
782
733 if (m_handleevent) {783 if (m_handleevent) {
734 /* In this case it means the handset state changed */784 /* In this case it means the handset state changed */
735 qDebug("Notifying card changes for the voicecall capable card");785 qDebug("Notifying card changes for the voicecall capable card");
736786
=== modified file 'qpulseaudioengine.h'
--- qpulseaudioengine.h 2015-07-28 18:10:10 +0000
+++ qpulseaudioengine.h 2015-11-27 15:56:01 +0000
@@ -32,7 +32,8 @@
32 AudioModeBluetooth = 0x0008,32 AudioModeBluetooth = 0x0008,
33 AudioModeBtOrWiredOrEarpiece = AudioModeBluetooth | AudioModeWiredHeadset | AudioModeEarpiece,33 AudioModeBtOrWiredOrEarpiece = AudioModeBluetooth | AudioModeWiredHeadset | AudioModeEarpiece,
34 AudioModeWiredOrEarpiece = AudioModeWiredHeadset | AudioModeEarpiece,34 AudioModeWiredOrEarpiece = AudioModeWiredHeadset | AudioModeEarpiece,
35 AudioModeWiredOrSpeaker = AudioModeWiredHeadset | AudioModeSpeaker35 AudioModeWiredOrSpeaker = AudioModeWiredHeadset | AudioModeSpeaker,
36 AudioModeBtOrWiredOrSpeaker = AudioModeBluetooth | AudioModeWiredOrSpeaker
36};37};
3738
38Q_DECLARE_METATYPE(AudioMode)39Q_DECLARE_METATYPE(AudioMode)
@@ -94,6 +95,7 @@
94 std::string m_nametoset, m_valuetoset;95 std::string m_nametoset, m_valuetoset;
95 std::string m_defaultsink, m_defaultsource;96 std::string m_defaultsink, m_defaultsource;
96 std::string m_bt_hsp, m_bt_hsp_a2dp;97 std::string m_bt_hsp, m_bt_hsp_a2dp;
98 std::string m_default_bt_card_fallback;
97 std::string m_voicecallcard, m_voicecallhighest, m_voicecallprofile;99 std::string m_voicecallcard, m_voicecallhighest, m_voicecallprofile;
98100
99 bool handleOperation(pa_operation *operation, const char *func_name);101 bool handleOperation(pa_operation *operation, const char *func_name);

Subscribers

People subscribed via source and target branches