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

Proposed by Tiago Salem Herrmann
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
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team 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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

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

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
1=== modified file 'qpulseaudioengine.cpp'
2--- qpulseaudioengine.cpp 2015-11-10 07:49:07 +0000
3+++ qpulseaudioengine.cpp 2015-11-27 15:57:17 +0000
4@@ -113,6 +113,7 @@
5 , m_voicecallprofile("")
6 , m_bt_hsp("")
7 , m_bt_hsp_a2dp("")
8+ , m_default_bt_card_fallback("")
9
10 {
11 m_mainLoop = pa_threaded_mainloop_new();
12@@ -658,14 +659,26 @@
13 {
14 qDebug("Notified about card (%s) add event from PulseAudio", info->name);
15
16+ /* Check if it's indeed a BT device (with at least one hsp profile) */
17+ pa_card_profile_info2 *hsp = NULL, *a2dp = NULL;
18+ for (int i = 0; i < info->n_profiles; i++) {
19+ if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_HSP))
20+ hsp = info->profiles2[i];
21+ else if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_A2DP) &&
22+ info->profiles2[i]->available != 0) {
23+ qDebug("Found a2dp");
24+ a2dp = info->profiles2[i];
25+ }
26+ qDebug("%s", info->profiles2[i]->name);
27+ }
28+
29+ if ((!info->active_profile || !strcmp(info->active_profile->name, "off")) && a2dp) {
30+ qDebug("No profile set");
31+ m_default_bt_card_fallback = info->name;
32+ }
33+
34 /* We only care about BT (HSP) devices, and if one is not already available */
35 if ((m_callstatus != CallEnded) && ((m_bt_hsp == "") || (m_bt_hsp_a2dp == ""))) {
36- /* Check if it's indeed a BT device (with at least one hsp profile) */
37- pa_card_profile_info *hsp = NULL;
38- for (int i = 0; i < info->n_profiles; i++) {
39- if (!strcmp(info->profiles[i].name, PULSEAUDIO_PROFILE_HSP))
40- hsp = &info->profiles[i];
41- }
42 if (hsp)
43 m_handleevent = true;
44 }
45@@ -675,6 +688,25 @@
46 {
47 qDebug("Notified about card (%s) changes event from PulseAudio", info->name);
48
49+ /* Check if it's indeed a BT device (with at least one hsp profile) */
50+ pa_card_profile_info2 *hsp = NULL, *a2dp = NULL;
51+ for (int i = 0; i < info->n_profiles; i++) {
52+ if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_HSP))
53+ hsp = info->profiles2[i];
54+ else if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_A2DP) &&
55+ info->profiles2[i]->available != 0) {
56+ qDebug("Found a2dp");
57+ a2dp = info->profiles2[i];
58+ }
59+ qDebug("%s", info->profiles2[i]->name);
60+ }
61+
62+ if ((!info->active_profile || !strcmp(info->active_profile->name, "off")) && a2dp) {
63+ qDebug("No profile set");
64+ m_default_bt_card_fallback = info->name;
65+ }
66+
67+
68 /* We only care if the card event for the voicecall capable card */
69 if ((m_callstatus == CallActive) && (!strcmp(info->name, m_voicecallcard.c_str()))) {
70 if (m_audiomode == AudioModeWiredHeadset) {
71@@ -718,6 +750,15 @@
72 o = pa_context_get_card_info_by_index(m_context, idx, plug_card_cb, this);
73 if (!handleOperation(o, "pa_context_get_card_info_by_index"))
74 return;
75+
76+ if (m_default_bt_card_fallback != "") {
77+ o = pa_context_set_card_profile_by_name(m_context,
78+ m_default_bt_card_fallback.c_str(), PULSEAUDIO_PROFILE_A2DP, success_cb, this);
79+ if (!handleOperation(o, "pa_context_set_card_profile_by_name"))
80+ return;
81+ m_default_bt_card_fallback = "";
82+ }
83+
84 if (m_handleevent) {
85 qDebug("Adding new BT-HSP capable device");
86 /* In case A2DP is available, switch to HSP */
87@@ -730,6 +771,15 @@
88 o = pa_context_get_card_info_by_index(m_context, idx, update_card_cb, this);
89 if (!handleOperation(o, "pa_context_get_card_info_by_index"))
90 return;
91+
92+ if (m_default_bt_card_fallback != "") {
93+ o = pa_context_set_card_profile_by_name(m_context,
94+ m_default_bt_card_fallback.c_str(), PULSEAUDIO_PROFILE_A2DP, success_cb, this);
95+ if (!handleOperation(o, "pa_context_set_card_profile_by_name"))
96+ return;
97+ m_default_bt_card_fallback = "";
98+ }
99+
100 if (m_handleevent) {
101 /* In this case it means the handset state changed */
102 qDebug("Notifying card changes for the voicecall capable card");
103
104=== modified file 'qpulseaudioengine.h'
105--- qpulseaudioengine.h 2015-11-27 15:57:17 +0000
106+++ qpulseaudioengine.h 2015-11-27 15:57:17 +0000
107@@ -95,6 +95,7 @@
108 std::string m_nametoset, m_valuetoset;
109 std::string m_defaultsink, m_defaultsource;
110 std::string m_bt_hsp, m_bt_hsp_a2dp;
111+ std::string m_default_bt_card_fallback;
112 std::string m_voicecallcard, m_voicecallhighest, m_voicecallprofile;
113
114 bool handleOperation(pa_operation *operation, const char *func_name);

Subscribers

People subscribed via source and target branches