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

Proposed by Tiago Salem Herrmann on 2015-11-27
Status: Needs review
Proposed branch: lp:~tiagosh/telepathy-ofono/fallback_a2dp
Merge into: lp:telepathy-ofono
Prerequisite: lp:~tiagosh/telepathy-ofono/fix-1519007
Diff against target: 114 lines (+57/-6)
2 files modified
qpulseaudioengine.cpp (+56/-6)
qpulseaudioengine.h (+1/-0)
To merge this branch: bzr merge lp:~tiagosh/telepathy-ofono/fallback_a2dp
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing on 2016-06-14
PS Jenkins bot continuous-integration Approve on 2015-11-27
Ubuntu Phablet Team 2015-11-27 Pending
Review via email: mp+278840@code.launchpad.net

This proposal supersedes 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.

FAILED: Continuous integration, rev:172
https://jenkins.canonical.com/system-apps/job/lp-telepathy-ofono-ci/3/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/574/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/574
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/555
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial/555
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/549/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial/549/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/549
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/549/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial/549
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial/549/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/549/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial/549/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-telepathy-ofono-ci/3/rebuild

review: Needs Fixing (continuous-integration)

Unmerged revisions

172. By Tiago Salem Herrmann on 2015-11-27

Fallback to a2dp if no profile is set

171. By Tiago Salem Herrmann on 2015-11-24

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 'qpulseaudioengine.cpp'
--- qpulseaudioengine.cpp 2015-11-10 07:49:07 +0000
+++ qpulseaudioengine.cpp 2015-11-27 15:57:17 +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-11-27 15:57:17 +0000
+++ qpulseaudioengine.h 2015-11-27 15:57:17 +0000
@@ -95,6 +95,7 @@
95 std::string m_nametoset, m_valuetoset;95 std::string m_nametoset, m_valuetoset;
96 std::string m_defaultsink, m_defaultsource;96 std::string m_defaultsink, m_defaultsource;
97 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;
98 std::string m_voicecallcard, m_voicecallhighest, m_voicecallprofile;99 std::string m_voicecallcard, m_voicecallhighest, m_voicecallprofile;
99100
100 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