Merge lp:telepathy-ofono/staging into lp:telepathy-ofono

Proposed by Gustavo Pichorim Boiko
Status: Approved
Approved by: Gustavo Pichorim Boiko
Approved revision: 184
Proposed branch: lp:telepathy-ofono/staging
Merge into: lp:telepathy-ofono
Diff against target: 2221 lines (+3/-1798)
20 files modified
CMakeLists.txt (+2/-16)
audiooutputsiface.cpp (+0/-167)
audiooutputsiface.h (+0/-148)
connection.cpp (+0/-180)
connection.h (+0/-24)
dbustypes.h (+0/-11)
debian/control (+0/-2)
ofonocallchannel.cpp (+0/-47)
ofonocallchannel.h (+0/-6)
ofonoconferencecallchannel.cpp (+0/-32)
ofonoconferencecallchannel.h (+0/-3)
powerd.h (+0/-34)
powerdaudiomodemediator.cpp (+0/-63)
powerdaudiomodemediator.h (+0/-46)
powerddbus.cpp (+0/-43)
powerddbus.h (+0/-38)
protocol.cpp (+1/-9)
protocol.h (+0/-5)
qpulseaudioengine.cpp (+0/-800)
qpulseaudioengine.h (+0/-124)
To merge this branch: bzr merge lp:telepathy-ofono/staging
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
system-apps-ci-bot continuous-integration Approve
Review via email: mp+320729@code.launchpad.net

Commit message

Remove audio routing/proximity sensor management from telepathy-ofono.

Description of the change

Remove audio routing/proximity sensor management from telepathy-ofono.

To post a comment you must log in.
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

PASSED: Continuous integration, rev:184
https://jenkins.canonical.com/system-apps/job/lp-telepathy-ofono-ci/1/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/2345
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2345
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2163
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2163/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2163
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/2163/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2163
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2163/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2163
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/2163/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2163
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/2163/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2163
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/2163/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Works as expected!

review: Approve

Unmerged revisions

184. By Gustavo Pichorim Boiko

Remove audio routing/proximity sensor management from telepathy-ofono.

183. By Gustavo Pichorim Boiko

Merge trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-10-11 01:59:06 +0000
3+++ CMakeLists.txt 2017-03-22 21:10:43 +0000
4@@ -41,13 +41,6 @@
5 pkg_check_modules(SQLITE3 REQUIRED sqlite3)
6 pkg_check_modules(MC_PLUGINS REQUIRED mission-control-plugins)
7
8-pkg_check_modules(PULSEAUDIO libpulse)
9-if (PULSEAUDIO_FOUND)
10- add_definitions(-DUSE_PULSEAUDIO)
11- set(USE_PULSEAUDIO ON)
12- include_directories(${PULSEAUDIO_INCLUDE_DIRS})
13-endif (PULSEAUDIO_FOUND)
14-
15 find_program(DBUS_RUNNER dbus-test-runner)
16
17 if(NOT DAEMON_DIR)
18@@ -90,30 +83,23 @@
19 ofonoconferencecallchannel.cpp
20 emergencymodeiface.cpp
21 voicemailiface.cpp
22- audiooutputsiface.cpp
23 mmsdmanager.cpp
24 mmsdservice.cpp
25 mmsdmessage.cpp
26 mmsgroupcache.cpp
27 pendingmessagesmanager.cpp
28 phoneutils.cpp
29- powerdaudiomodemediator.cpp
30- powerddbus.cpp
31 sqlitedatabase.cpp
32 ussdiface.cpp
33 ${telepathyfono_RES})
34
35-if(USE_PULSEAUDIO)
36- add_executable(${TELEPATHY_OFONO} qpulseaudioengine.cpp ${TELEPATHY_OFONO_SRC})
37-else(USE_PULSEAUDIO)
38- add_executable(${TELEPATHY_OFONO} ${TELEPATHY_OFONO_SRC})
39-endif(USE_PULSEAUDIO)
40+add_executable(${TELEPATHY_OFONO} ${TELEPATHY_OFONO_SRC})
41 qt5_use_modules(${TELEPATHY_OFONO} Core DBus Sql)
42 add_dependencies(${TELEPATHY_OFONO} schema_update qrc_update)
43
44 enable_testing()
45
46-target_link_libraries(${TELEPATHY_OFONO} ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${WAUDIO_LIBRARIES} -ltelepathy-qt5 ${TELEPATHY_QT5_SERVICE_LIBRARIES} ${Qt5Network_LIBRARIES} ${OFONO_QT_LIBRARIES} ${PULSEAUDIO_LIBRARIES} ${SQLITE3_LIBRARIES} ${LibPhoneNumber_LIBRARIES})
47+target_link_libraries(${TELEPATHY_OFONO} ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} -ltelepathy-qt5 ${TELEPATHY_QT5_SERVICE_LIBRARIES} ${Qt5Network_LIBRARIES} ${OFONO_QT_LIBRARIES} ${SQLITE3_LIBRARIES} ${LibPhoneNumber_LIBRARIES})
48 install(TARGETS ${TELEPATHY_OFONO} DESTINATION ${DAEMON_DIR})
49
50 configure_file(ofono.service.in org.freedesktop.Telepathy.ConnectionManager.ofono.service)
51
52=== removed file 'audiooutputsiface.cpp'
53--- audiooutputsiface.cpp 2014-08-05 02:01:51 +0000
54+++ audiooutputsiface.cpp 1970-01-01 00:00:00 +0000
55@@ -1,167 +0,0 @@
56-/**
57- * Copyright (C) 2013 Canonical, Ltd.
58- *
59- * This program is free software: you can redistribute it and/or modify it under
60- * the terms of the GNU Lesser General Public License version 3, as published by
61- * the Free Software Foundation.
62- *
63- * This program is distributed in the hope that it will be useful, but WITHOUT
64- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
65- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
66- * Lesser General Public License for more details.
67- *
68- * You should have received a copy of the GNU Lesser General Public License
69- * along with this program. If not, see <http://www.gnu.org/licenses/>.
70- *
71- * Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
72- */
73-
74-#include <QDebug>
75-
76-#include <TelepathyQt/Constants>
77-#include <TelepathyQt/DBusObject>
78-
79-#include "audiooutputsiface.h"
80-
81-
82-QDBusArgument &operator<<(QDBusArgument &argument, const AudioOutput &output)
83-{
84- argument.beginStructure();
85- argument << output.id << output.type << output.name;
86- argument.endStructure();
87- return argument;
88-}
89-
90-const QDBusArgument &operator>>(const QDBusArgument &argument, AudioOutput &output)
91-{
92- argument.beginStructure();
93- argument >> output.id >> output.type >> output.name;
94- argument.endStructure();
95- return argument;
96-}
97-
98-// Chan.I.AudioOutputs
99-BaseChannelAudioOutputsInterface::Adaptee::Adaptee(BaseChannelAudioOutputsInterface *interface)
100- : QObject(interface),
101- mInterface(interface)
102-{
103- qDBusRegisterMetaType<AudioOutput>();
104- qDBusRegisterMetaType<AudioOutputList>();
105-}
106-
107-struct TP_QT_NO_EXPORT BaseChannelAudioOutputsInterface::Private {
108- Private(BaseChannelAudioOutputsInterface *parent)
109- : adaptee(new BaseChannelAudioOutputsInterface::Adaptee(parent)) {
110- }
111- AudioOutputList audioOutputs;
112- QString activeAudioOutput;
113- SetActiveAudioOutputCallback setActiveAudioOutputCB;
114- BaseChannelAudioOutputsInterface::Adaptee *adaptee;
115-};
116-
117-BaseChannelAudioOutputsInterface::Adaptee::~Adaptee()
118-{
119-}
120-
121-void BaseChannelAudioOutputsInterface::Adaptee::setActiveAudioOutput(const QString &id, const ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr &context)
122-{
123- if (!mInterface->mPriv->setActiveAudioOutputCB.isValid()) {
124- context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
125- return;
126- }
127- Tp::DBusError error;
128- mInterface->mPriv->setActiveAudioOutputCB(id, &error);
129- if (error.isValid()) {
130- context->setFinishedWithError(error.name(), error.message());
131- return;
132- }
133- context->setFinished();
134-}
135-
136-BaseChannelAudioOutputsInterface::BaseChannelAudioOutputsInterface()
137- : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_AUDIOOUTPUTS),
138- mPriv(new Private(this))
139-{
140-}
141-
142-BaseChannelAudioOutputsInterface::~BaseChannelAudioOutputsInterface()
143-{
144- delete mPriv;
145-}
146-
147-QString BaseChannelAudioOutputsInterface::activeAudioOutput() const
148-{
149- return mPriv->activeAudioOutput;
150-}
151-
152-AudioOutputList BaseChannelAudioOutputsInterface::audioOutputs() const
153-{
154- return mPriv->audioOutputs;
155-}
156-
157-void BaseChannelAudioOutputsInterface::setSetActiveAudioOutputCallback(const SetActiveAudioOutputCallback &cb)
158-{
159- mPriv->setActiveAudioOutputCB = cb;
160-}
161-
162-void BaseChannelAudioOutputsInterface::setActiveAudioOutput(const QString &id)
163-{
164- mPriv->activeAudioOutput = id;
165- Q_EMIT mPriv->adaptee->activeAudioOutputChanged(id);
166-}
167-
168-void BaseChannelAudioOutputsInterface::setAudioOutputs(const AudioOutputList &outputs)
169-{
170- mPriv->audioOutputs = outputs;
171- Q_EMIT mPriv->adaptee->audioOutputsChanged(outputs);
172-}
173-
174-QVariantMap BaseChannelAudioOutputsInterface::immutableProperties() const
175-{
176- QVariantMap map;
177- return map;
178-}
179-
180-void BaseChannelAudioOutputsInterface::createAdaptor()
181-{
182- (void) new ChannelInterfaceAudioOutputsAdaptor(dbusObject()->dbusConnection(),
183- mPriv->adaptee, dbusObject());
184-}
185-
186-
187-ChannelInterfaceAudioOutputsAdaptor::ChannelInterfaceAudioOutputsAdaptor(const QDBusConnection& bus, QObject* adaptee, QObject* parent)
188- : Tp::AbstractAdaptor(bus, adaptee, parent)
189-{
190- connect(adaptee, SIGNAL(audioOutputsChanged(AudioOutputList)), SIGNAL(AudioOutputsChanged(AudioOutputList)));
191- connect(adaptee, SIGNAL(activeAudioOutputChanged(QString)), SIGNAL(ActiveAudioOutputChanged(QString)));
192-}
193-
194-ChannelInterfaceAudioOutputsAdaptor::~ChannelInterfaceAudioOutputsAdaptor()
195-{
196-}
197-
198-void ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutput(const QString &id, const QDBusMessage& dbusMessage)
199-{
200- if (!adaptee()->metaObject()->indexOfMethod("setActiveAudioOutput(QString,ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr)") == -1) {
201- dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
202- return;
203- }
204-
205- SetActiveAudioOutputContextPtr ctx = SetActiveAudioOutputContextPtr(
206- new Tp::MethodInvocationContext< >(dbusConnection(), dbusMessage));
207- QMetaObject::invokeMethod(adaptee(), "setActiveAudioOutput",
208- Q_ARG(QString, id),
209- Q_ARG(ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr, ctx));
210- return;
211-}
212-
213-QString ChannelInterfaceAudioOutputsAdaptor::ActiveAudioOutput() const
214-{
215- return qvariant_cast< QString >(adaptee()->property("activeAudioOutput"));
216-}
217-
218-AudioOutputList ChannelInterfaceAudioOutputsAdaptor::AudioOutputs() const
219-{
220- return qvariant_cast< AudioOutputList >(adaptee()->property("audioOutputs"));
221-}
222-
223
224=== removed file 'audiooutputsiface.h'
225--- audiooutputsiface.h 2014-08-05 02:01:51 +0000
226+++ audiooutputsiface.h 1970-01-01 00:00:00 +0000
227@@ -1,148 +0,0 @@
228-/**
229- * Copyright (C) 2013 Canonical, Ltd.
230- *
231- * This program is free software: you can redistribute it and/or modify it under
232- * the terms of the GNU Lesser General Public License version 3, as published by
233- * the Free Software Foundation.
234- *
235- * This program is distributed in the hope that it will be useful, but WITHOUT
236- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
237- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
238- * Lesser General Public License for more details.
239- *
240- * You should have received a copy of the GNU Lesser General Public License
241- * along with this program. If not, see <http://www.gnu.org/licenses/>.
242- *
243- * Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
244- */
245-
246-#ifndef OFONOAUDIOOUTPUTSIFACE_H
247-#define OFONOAUDIOOUTPUTSIFACE_H
248-
249-// telepathy-qt
250-#include <TelepathyQt/Constants>
251-#include <TelepathyQt/BaseChannel>
252-#include <TelepathyQt/AbstractAdaptor>
253-#include <TelepathyQt/DBusError>
254-#include <TelepathyQt/Callbacks>
255-
256-#include "dbustypes.h"
257-
258-#define TP_QT_IFACE_CHANNEL_AUDIOOUTPUTS "com.canonical.Telephony.AudioOutputs"
259-
260-class BaseChannelAudioOutputsInterface;
261-
262-typedef Tp::SharedPtr<BaseChannelAudioOutputsInterface> BaseChannelAudioOutputsInterfacePtr;
263-
264-class TP_QT_EXPORT BaseChannelAudioOutputsInterface : public Tp::AbstractChannelInterface
265-{
266- Q_OBJECT
267- Q_DISABLE_COPY(BaseChannelAudioOutputsInterface)
268-
269-public:
270- static BaseChannelAudioOutputsInterfacePtr create() {
271- return BaseChannelAudioOutputsInterfacePtr(new BaseChannelAudioOutputsInterface());
272- }
273- template<typename BaseChannelAudioOutputsInterfaceSubclass>
274- static Tp::SharedPtr<BaseChannelAudioOutputsInterfaceSubclass> create() {
275- return Tp::SharedPtr<BaseChannelAudioOutputsInterfaceSubclass>(
276- new BaseChannelAudioOutputsInterfaceSubclass());
277- }
278- QVariantMap immutableProperties() const;
279- virtual ~BaseChannelAudioOutputsInterface();
280- AudioOutputList audioOutputs() const;
281- QString activeAudioOutput() const;
282-
283- typedef Tp::Callback2<void, QString, Tp::DBusError*> SetActiveAudioOutputCallback;
284- void setSetActiveAudioOutputCallback(const SetActiveAudioOutputCallback &cb);
285-
286-public Q_SLOTS:
287- void setActiveAudioOutput(const QString &id);
288- void setAudioOutputs(const AudioOutputList &outputs);
289-
290-protected:
291- BaseChannelAudioOutputsInterface();
292-
293-private:
294- void createAdaptor();
295-
296- class Adaptee;
297- friend class Adaptee;
298- struct Private;
299- friend struct Private;
300- Private *mPriv;
301-};
302-
303-
304-class TP_QT_EXPORT ChannelInterfaceAudioOutputsAdaptor : public Tp::AbstractAdaptor
305-{
306- Q_OBJECT
307- Q_CLASSINFO("D-Bus Interface", TP_QT_IFACE_CHANNEL_AUDIOOUTPUTS)
308- Q_CLASSINFO("D-Bus Introspection", ""
309-" <interface name=\"com.canonical.Telephony.AudioOutputs\">\n"
310-" <property access=\"read\" type=\"s\" name=\"ActiveAudioOutput\"/>\n"
311-" <property access=\"read\" type=\"a(sss)\" name=\"AudioOutputs\"/>\n"
312-" <method name=\"SetActiveAudioOutput\">\n"
313-" <arg direction=\"in\" type=\"s\" name=\"id\"/>\n"
314-" </method>\n"
315-" <signal name=\"AudioOutputsChanged\">\n"
316-" <arg type=\"a(sss)\" name=\"outputs\"/>\n"
317-" </signal>\n"
318-" <signal name=\"ActiveAudioOutputChanged\">\n"
319-" <arg type=\"s\" name=\"id\"/>\n"
320-" </signal>\n"
321-" </interface>\n"
322-"")
323- Q_PROPERTY(AudioOutputList AudioOutputs READ AudioOutputs)
324- Q_PROPERTY(QString ActiveAudioOutput READ ActiveAudioOutput)
325-public:
326- ChannelInterfaceAudioOutputsAdaptor(const QDBusConnection& dbusConnection, QObject* adaptee, QObject* parent);
327- virtual ~ChannelInterfaceAudioOutputsAdaptor();
328-
329- typedef Tp::MethodInvocationContextPtr< > SetActiveAudioOutputContextPtr;
330-
331-public: // PROPERTIES
332- QString ActiveAudioOutput() const;
333- AudioOutputList AudioOutputs() const;
334-
335-public Q_SLOTS: // METHODS
336- void SetActiveAudioOutput(const QString &id, const QDBusMessage& dbusMessage);
337-
338-Q_SIGNALS: // SIGNALS
339- void AudioOutputsChanged(const AudioOutputList &outputs);
340- void ActiveAudioOutputChanged(const QString &id);
341-};
342-
343-
344-class TP_QT_NO_EXPORT BaseChannelAudioOutputsInterface::Adaptee : public QObject
345-{
346- Q_OBJECT
347- Q_PROPERTY(AudioOutputList audioOutputs READ audioOutputs)
348- Q_PROPERTY(QString activeAudioOutput READ activeAudioOutput)
349-
350-public:
351- Adaptee(BaseChannelAudioOutputsInterface *interface);
352- ~Adaptee();
353- AudioOutputList audioOutputs() const
354- {
355- return mInterface->audioOutputs();
356- }
357-
358- QString activeAudioOutput() const
359- {
360- return mInterface->activeAudioOutput();
361- }
362-
363-
364-private Q_SLOTS:
365- void setActiveAudioOutput(const QString &id, const ChannelInterfaceAudioOutputsAdaptor::SetActiveAudioOutputContextPtr &context);
366-
367-Q_SIGNALS:
368- void activeAudioOutputChanged(const QString &id);
369- void audioOutputsChanged(const AudioOutputList &outputs);
370-
371-public:
372- BaseChannelAudioOutputsInterface *mInterface;
373-};
374-
375-#endif
376
377=== modified file 'connection.cpp'
378--- connection.cpp 2016-11-09 19:39:48 +0000
379+++ connection.cpp 2017-03-22 21:10:43 +0000
380@@ -34,49 +34,10 @@
381 #include "mmsdservice.h"
382 #include "mmsgroupcache.h"
383
384-#ifdef USE_PULSEAUDIO
385-#include "qpulseaudioengine.h"
386-#endif
387-
388 #include "sqlitedatabase.h"
389 #include "pendingmessagesmanager.h"
390 #include "dbustypes.h"
391
392-static void enable_earpiece()
393-{
394-#ifdef USE_PULSEAUDIO
395- QPulseAudioEngine::instance()->setCallMode(CallActive, AudioModeBtOrWiredOrEarpiece);
396-#endif
397-}
398-
399-static void enable_normal()
400-{
401-#ifdef USE_PULSEAUDIO
402- QTimer* timer = new QTimer();
403- timer->setSingleShot(true);
404- QObject::connect(timer, &QTimer::timeout, [=](){
405- QPulseAudioEngine::instance()->setMicMute(false);
406- QPulseAudioEngine::instance()->setCallMode(CallEnded, AudioModeWiredOrSpeaker);
407- timer->deleteLater();
408- });
409- timer->start(2000);
410-#endif
411-}
412-
413-static void enable_speaker()
414-{
415-#ifdef USE_PULSEAUDIO
416- QPulseAudioEngine::instance()->setCallMode(CallActive, AudioModeSpeaker);
417-#endif
418-}
419-
420-static void enable_ringtone()
421-{
422-#ifdef USE_PULSEAUDIO
423- QPulseAudioEngine::instance()->setCallMode(CallRinging, AudioModeWiredOrSpeaker);
424-#endif
425-}
426-
427 oFonoConnection::oFonoConnection(const QDBusConnection &dbusConnection,
428 const QString &cmName,
429 const QString &protocolName,
430@@ -88,8 +49,6 @@
431 mMmsdManager(new MMSDManager(this)),
432 mConferenceCall(NULL)
433 {
434- qRegisterMetaType<AudioOutputList>();
435- qRegisterMetaType<AudioOutput>();
436 OfonoModem::SelectionSetting setting = OfonoModem::AutomaticSelect;
437 mModemPath = parameters["modem-objpath"].toString();
438 if (!mModemPath.isEmpty()) {
439@@ -254,22 +213,6 @@
440 QObject::connect(mMmsdManager, SIGNAL(serviceAdded(const QString&)), SLOT(onMMSDServiceAdded(const QString&)));
441 QObject::connect(mMmsdManager, SIGNAL(serviceRemoved(const QString&)), SLOT(onMMSDServiceRemoved(const QString&)));
442
443- // update audio route
444- QObject::connect(mOfonoVoiceCallManager, SIGNAL(callAdded(QString,QVariantMap)), SLOT(updateAudioRoute()));
445- QObject::connect(mOfonoVoiceCallManager, SIGNAL(callRemoved(QString)), SLOT(updateAudioRoute()));
446-
447-#ifdef USE_PULSEAUDIO
448- // update audio modes
449- QObject::connect(QPulseAudioEngine::instance(), SIGNAL(audioModeChanged(AudioMode)), SLOT(onAudioModeChanged(AudioMode)));
450- QObject::connect(QPulseAudioEngine::instance(), SIGNAL(availableAudioModesChanged(AudioModes)), SLOT(onAvailableAudioModesChanged(AudioModes)));
451-
452- // check if we should indeed use pulseaudio
453- QByteArray pulseAudioDisabled = qgetenv("PA_DISABLED");
454- mHasPulseAudio = true;
455- if (!pulseAudioDisabled.isEmpty())
456- mHasPulseAudio = false;
457-#endif
458-
459 QObject::connect(mOfonoSupplementaryServices, SIGNAL(notificationReceived(const QString &)), supplementaryServicesIface.data(), SLOT(NotificationReceived(const QString &)));
460 QObject::connect(mOfonoSupplementaryServices, SIGNAL(requestReceived(const QString &)), supplementaryServicesIface.data(), SLOT(RequestReceived(const QString &)));
461
462@@ -1232,27 +1175,11 @@
463 return mOfonoMessageWaiting->voicemailWaiting();
464 }
465
466-QString oFonoConnection::activeAudioOutput()
467-{
468- return mActiveAudioOutput;
469-}
470-
471-AudioOutputList oFonoConnection::audioOutputs()
472-{
473- return mAudioOutputs;
474-}
475-
476 QStringList oFonoConnection::emergencyNumbers(Tp::DBusError *error)
477 {
478 return mOfonoVoiceCallManager->emergencyNumbers();
479 }
480
481-void oFonoConnection::setActiveAudioOutput(const QString &id)
482-{
483- mActiveAudioOutput = id;
484- Q_EMIT activeAudioOutputChanged(id);
485-}
486-
487 void oFonoConnection::USSDInitiate(const QString &command, Tp::DBusError *error)
488 {
489 mOfonoSupplementaryServices->initiate(command);
490@@ -1268,113 +1195,6 @@
491 mOfonoSupplementaryServices->cancel();
492 }
493
494-#ifdef USE_PULSEAUDIO
495-void oFonoConnection::onAudioModeChanged(AudioMode mode)
496-{
497- qDebug("PulseAudio audio mode changed: 0x%x", mode);
498-
499- if (mode == AudioModeEarpiece && mActiveAudioOutput != "earpiece") {
500- setActiveAudioOutput("earpiece");
501- } else if (mode == AudioModeWiredHeadset && mActiveAudioOutput != "wired_headset") {
502- setActiveAudioOutput("wired_headset");
503- } else if (mode == AudioModeSpeaker && mActiveAudioOutput != "speaker") {
504- setActiveAudioOutput("speaker");
505- } else if (mode == AudioModeBluetooth && mActiveAudioOutput != "bluetooth") {
506- setActiveAudioOutput("bluetooth");
507- }
508-}
509-
510-void oFonoConnection::onAvailableAudioModesChanged(AudioModes modes)
511-{
512- qDebug("PulseAudio available audio modes changed");
513- bool defaultFound = false;
514- mAudioOutputs.clear();
515- Q_FOREACH(const AudioMode &mode, modes) {
516- AudioOutput output;
517- if (mode == AudioModeBluetooth) {
518- // there can be only one bluetooth
519- output.id = "bluetooth";
520- output.type = "bluetooth";
521- // we dont support names for now, so we set a default value
522- output.name = "bluetooth";
523- } else if (mode == AudioModeEarpiece || mode == AudioModeWiredHeadset) {
524- if (!defaultFound) {
525- defaultFound = true;
526- output.id = "default";
527- output.type = "default";
528- output.name = "default";
529- } else {
530- continue;
531- }
532- } else if (mode == AudioModeSpeaker) {
533- output.id = "speaker";
534- output.type = "speaker";
535- output.name = "speaker";
536- }
537- mAudioOutputs << output;
538- }
539- Q_EMIT audioOutputsChanged(mAudioOutputs);
540-}
541-#endif
542-
543-void oFonoConnection::updateAudioRoute()
544-{
545-#ifdef USE_PULSEAUDIO
546- if (!mHasPulseAudio)
547- return;
548-#endif
549-
550- int currentCalls = mOfonoVoiceCallManager->getCalls().size();
551- if (currentCalls != 0) {
552- if (currentCalls == 1) {
553- // if we have only one call, check if it's incoming and
554- // enable speaker mode so the ringtone is audible
555- OfonoVoiceCall *call = new OfonoVoiceCall(mOfonoVoiceCallManager->getCalls().first());
556- if (call) {
557- if (call->state() == "incoming") {
558- enable_ringtone();
559- call->deleteLater();
560- return;
561- }
562- if (call->state() == "disconnected") {
563- enable_normal();
564- call->deleteLater();
565- return;
566- }
567- // if only one call and dialing, default to earpiece
568- if (call->state() == "dialing") {
569- enable_earpiece();
570- call->deleteLater();
571- return;
572- }
573- if (call->state().isEmpty()) {
574- call->deleteLater();
575- return;
576- }
577- call->deleteLater();
578- }
579- }
580- } else {
581- enable_normal();
582- Q_EMIT lastChannelClosed();
583- }
584-
585-}
586-
587-// this method is only called when call channels go from incoming to active.
588-// please call this method only from oFonoCallChannel instances
589-void oFonoConnection::updateAudioRouteToEarpiece()
590-{
591-#ifdef USE_PULSEAUDIO
592- if (!mHasPulseAudio)
593- return;
594-#endif
595-
596- if (mOfonoVoiceCallManager->getCalls().size() == 1) {
597- enable_earpiece();
598- }
599-}
600-
601 QString oFonoConnection::uniqueName() const
602 {
603 QString timestamp(QString::number(QDateTime::currentMSecsSinceEpoch()));
604
605=== modified file 'connection.h'
606--- connection.h 2016-10-11 01:59:06 +0000
607+++ connection.h 2017-03-22 21:10:43 +0000
608@@ -47,12 +47,8 @@
609 #include "mmsdmanager.h"
610 #include "mmsdmessage.h"
611 #include "dbustypes.h"
612-#include "audiooutputsiface.h"
613 #include "ussdiface.h"
614
615-#ifdef USE_PULSEAUDIO
616-#include "qpulseaudioengine.h"
617-#endif
618
619 class oFonoConnection;
620 class oFonoTextChannel;
621@@ -77,9 +73,6 @@
622 uint setPresence(const QString& status, const QString& statusMessage, Tp::DBusError *error);
623 void connect(Tp::DBusError *error);
624 void setSpeakerMode(bool active);
625- void setActiveAudioOutput(const QString &id);
626- AudioOutputList audioOutputs();
627- QString activeAudioOutput();
628 QStringList emergencyNumbers(Tp::DBusError *error);
629 bool voicemailIndicator(Tp::DBusError *error);
630 QString voicemailNumber(Tp::DBusError *error);
631@@ -118,17 +111,11 @@
632 ~oFonoConnection();
633
634 Q_SIGNALS:
635- void activeAudioOutputChanged(const QString &id);
636- void audioOutputsChanged(const AudioOutputList &outputs);
637 void channelMerged(const QDBusObjectPath &objPath);
638 void channelSplitted(const QDBusObjectPath &objPath);
639 void channelHangup(const QDBusObjectPath &objPath);
640 void lastChannelClosed();
641
642-public Q_SLOTS:
643- void updateAudioRoute();
644- void updateAudioRouteToEarpiece();
645-
646 private Q_SLOTS:
647 void onOfonoIncomingMessage(const QString &message, const QVariantMap &info);
648 void onOfonoImmediateMessage(const QString &message, const QVariantMap &info);
649@@ -152,11 +139,6 @@
650 void updateOnlineStatus();
651 void onDisconnected();
652
653-#ifdef USE_PULSEAUDIO
654- void onAudioModeChanged(AudioMode mode);
655- void onAvailableAudioModesChanged(AudioModes modes);
656-#endif
657-
658 private:
659 void updateMcc();
660 bool isNetworkRegistered();
661@@ -167,10 +149,6 @@
662 QMap<uint, QString> mGroupHandles;
663 uint mGroupHandleCount;
664
665-#ifdef USE_PULSEAUDIO
666- bool mHasPulseAudio;
667-#endif
668-
669 QList<oFonoTextChannel*> mTextChannels;
670 QMap<QString, oFonoCallChannel*> mCallChannels;
671
672@@ -190,8 +168,6 @@
673 QMap<QString, QList<MMSDMessage*> > mServiceMMSList;
674 oFonoConferenceCallChannel *mConferenceCall;
675 QString mModemPath;
676- QString mActiveAudioOutput;
677- AudioOutputList mAudioOutputs;
678 };
679
680 #endif
681
682=== modified file 'dbustypes.h'
683--- dbustypes.h 2014-08-25 15:40:47 +0000
684+++ dbustypes.h 2017-03-22 21:10:43 +0000
685@@ -20,12 +20,6 @@
686 #define DBUSTYPES
687 #include <QDBusObjectPath>
688
689-struct AudioOutput {
690- QString id;
691- QString type;
692- QString name;
693-};
694-
695 struct MessageStruct {
696 QDBusObjectPath path;
697 QVariantMap properties;
698@@ -45,11 +39,6 @@
699 QString filePath;
700 };
701
702-Q_DECLARE_METATYPE(AudioOutput)
703-
704-typedef QList<AudioOutput> AudioOutputList;
705-Q_DECLARE_METATYPE(AudioOutputList)
706-
707 typedef QList<IncomingAttachmentStruct> IncomingAttachmentList;
708 typedef QList<OutgoingAttachmentStruct> OutgoingAttachmentList;
709 Q_DECLARE_METATYPE(IncomingAttachmentStruct)
710
711=== modified file 'debian/control'
712--- debian/control 2016-07-19 11:20:42 +0000
713+++ debian/control 2017-03-22 21:10:43 +0000
714@@ -12,9 +12,7 @@
715 libphonenumber-dev,
716 libqt5sql5-sqlite,
717 libtelepathy-qt5-dev (>= 0.9.3),
718- libpulse-dev [armhf arm64],
719 libsqlite3-dev,
720- pulseaudio,
721 qt5-default (>= 5.0),
722 qtbase5-dev (>= 5.0),
723 sqlite3,
724
725=== modified file 'ofonocallchannel.cpp'
726--- ofonocallchannel.cpp 2016-10-26 20:42:04 +0000
727+++ ofonocallchannel.cpp 2017-03-22 21:10:43 +0000
728@@ -17,9 +17,6 @@
729 */
730
731 #include "ofonocallchannel.h"
732-#ifdef USE_PULSEAUDIO
733-#include "qpulseaudioengine.h"
734-#endif
735
736
737 oFonoCallChannel::oFonoCallChannel(oFonoConnection *conn, QString phoneNumber, uint targetHandle, QString voiceObj, QObject *parent):
738@@ -47,15 +44,11 @@
739 mMuteIface = Tp::BaseCallMuteInterface::create();
740 mMuteIface->setSetMuteStateCallback(Tp::memFun(this,&oFonoCallChannel::onMuteStateChanged));
741
742- mAudioOutputsIface = BaseChannelAudioOutputsInterface::create();
743- mAudioOutputsIface->setSetActiveAudioOutputCallback(Tp::memFun(this,&oFonoCallChannel::onSetActiveAudioOutput));
744-
745 mSplittableIface = Tp::BaseChannelSplittableInterface::create();
746 mSplittableIface->setSplitCallback(Tp::memFun(this,&oFonoCallChannel::onSplit));
747
748 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mHoldIface));
749 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mMuteIface));
750- baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mAudioOutputsIface));
751 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mSplittableIface));
752
753 mBaseChannel = baseChannel;
754@@ -68,13 +61,6 @@
755 QObject::connect(this, SIGNAL(answerComplete(bool)), this, SLOT(onAnswerComplete(bool)));
756 // init must be called after initialization, otherwise we will have no object path registered.
757 QTimer::singleShot(0, this, SLOT(init()));
758-
759-#ifdef USE_PULSEAUDIO
760- QByteArray pulseAudioDisabled = qgetenv("PA_DISABLED");
761- mHasPulseAudio = true;
762- if (!pulseAudioDisabled.isEmpty())
763- mHasPulseAudio = false;
764-#endif
765 }
766
767 Tp::CallState oFonoCallChannel::callState()
768@@ -87,21 +73,6 @@
769 mConnection->voiceCallManager()->privateChat(path());
770 }
771
772-void oFonoCallChannel::onSetActiveAudioOutput(const QString &id, Tp::DBusError *error)
773-{
774-#ifdef USE_PULSEAUDIO
775- // fallback to earpiece/headset
776- AudioMode mode = AudioModeWiredOrEarpiece;
777- if (id == "bluetooth") {
778- mode = AudioModeBluetooth;
779- } else if (id == "speaker") {
780- mode = AudioModeSpeaker;
781- }
782- if (mHasPulseAudio)
783- QPulseAudioEngine::instance()->setCallMode(CallActive, mode);
784-#endif
785-}
786-
787 void oFonoCallChannel::onHangupComplete(bool status)
788 {
789 if (!status) {
790@@ -180,15 +151,10 @@
791 QObject::connect(mBaseChannel.data(), SIGNAL(closed()), this, SLOT(deleteLater()));
792 QObject::connect(mConnection->callVolume(), SIGNAL(mutedChanged(bool)), SLOT(onOfonoMuteChanged(bool)));
793 QObject::connect(this, SIGNAL(stateChanged(QString)), SLOT(onOfonoCallStateChanged(QString)));
794- QObject::connect(mConnection, SIGNAL(activeAudioOutputChanged(QString)), mAudioOutputsIface.data(), SLOT(setActiveAudioOutput(QString)));
795- QObject::connect(mConnection, SIGNAL(audioOutputsChanged(AudioOutputList)), mAudioOutputsIface.data(), SLOT(setAudioOutputs(AudioOutputList)));
796 QObject::connect(mConnection->voiceCallManager(), SIGNAL(sendTonesComplete(bool)), SLOT(onDtmfComplete(bool)));
797 QObject::connect(this, SIGNAL(multipartyChanged(bool)), this, SLOT(onMultipartyChanged(bool)));
798
799 QObject::connect(this, SIGNAL(disconnectReason(const QString &)), this, SLOT(onDisconnectReason(const QString &)));
800-
801- mAudioOutputsIface->setAudioOutputs(mConnection->audioOutputs());
802- mAudioOutputsIface->setActiveAudioOutput(mConnection->activeAudioOutput());
803 }
804
805 void oFonoCallChannel::onDisconnectReason(const QString &reason) {
806@@ -241,16 +207,8 @@
807 {
808 if (state == Tp::LocalMuteStateMuted) {
809 mConnection->callVolume()->setMuted(true);
810-#ifdef USE_PULSEAUDIO
811- if (mHasPulseAudio)
812- QPulseAudioEngine::instance()->setMicMute(true);
813-#endif
814 } else if (state == Tp::LocalMuteStateUnmuted) {
815 mConnection->callVolume()->setMuted(false);
816-#ifdef USE_PULSEAUDIO
817- if (mHasPulseAudio)
818- QPulseAudioEngine::instance()->setMicMute(false);
819-#endif
820 }
821 }
822
823@@ -351,9 +309,6 @@
824 if (mMultiparty) {
825 Q_EMIT multipartyCallActive();
826 }
827- if (mPreviousState == "incoming") {
828- mConnection->updateAudioRouteToEarpiece();
829- }
830 if (mPreviousState == "dialing" || mPreviousState == "alerting" ||
831 mPreviousState == "incoming") {
832 mConnection->callVolume()->setMuted(false);
833@@ -375,7 +330,5 @@
834 } else if (state == "waiting") {
835 qDebug() << "waiting";
836 }
837- // always update the audio route when call state changes
838- mConnection->updateAudioRoute();
839 mPreviousState = state;
840 }
841
842=== modified file 'ofonocallchannel.h'
843--- ofonocallchannel.h 2015-02-17 17:03:42 +0000
844+++ ofonocallchannel.h 2017-03-22 21:10:43 +0000
845@@ -29,7 +29,6 @@
846 #include <ofono-qt/ofonovoicecall.h>
847
848 #include "connection.h"
849-#include "audiooutputsiface.h"
850
851 class oFonoConnection;
852
853@@ -47,7 +46,6 @@
854 void onHoldStateChanged(const Tp::LocalHoldState &state, const Tp::LocalHoldStateReason &reason, Tp::DBusError *error);
855 void onDTMFStartTone(uchar event, Tp::DBusError *error);
856 void onDTMFStopTone(Tp::DBusError *error);
857- void onSetActiveAudioOutput(const QString &id, Tp::DBusError *error);
858 void onSplit(Tp::DBusError *error);
859 Tp::CallState callState();
860
861@@ -74,9 +72,6 @@
862 private:
863 QString mObjPath;
864 QString mPreviousState;
865-#ifdef USE_PULSEAUDIO
866- bool mHasPulseAudio;
867-#endif
868 bool mIncoming;
869 bool mRequestedHangup;
870 Tp::BaseChannelPtr mBaseChannel;
871@@ -86,7 +81,6 @@
872 Tp::BaseChannelHoldInterfacePtr mHoldIface;
873 Tp::BaseChannelSplittableInterfacePtr mSplittableIface;
874 Tp::BaseCallMuteInterfacePtr mMuteIface;
875- BaseChannelAudioOutputsInterfacePtr mAudioOutputsIface;
876 Tp::BaseChannelCallTypePtr mCallChannel;
877 Tp::BaseCallContentDTMFInterfacePtr mDTMFIface;
878 Tp::BaseCallContentPtr mCallContent;
879
880=== modified file 'ofonoconferencecallchannel.cpp'
881--- ofonoconferencecallchannel.cpp 2016-10-26 20:42:04 +0000
882+++ ofonoconferencecallchannel.cpp 2017-03-22 21:10:43 +0000
883@@ -17,9 +17,6 @@
884 */
885
886 #include "ofonoconferencecallchannel.h"
887-#ifdef USE_PULSEAUDIO
888-#include "qpulseaudioengine.h"
889-#endif
890 #include "ofonocallchannel.h"
891
892
893@@ -50,9 +47,6 @@
894 mMuteIface = Tp::BaseCallMuteInterface::create();
895 mMuteIface->setSetMuteStateCallback(Tp::memFun(this,&oFonoConferenceCallChannel::onMuteStateChanged));
896
897- mAudioOutputsIface = BaseChannelAudioOutputsInterface::create();
898- mAudioOutputsIface->setSetActiveAudioOutputCallback(Tp::memFun(this,&oFonoConferenceCallChannel::onSetActiveAudioOutput));
899-
900 mConferenceIface = Tp::BaseChannelConferenceInterface::create(mCallChannels);
901
902 mMergeableIface = Tp::BaseChannelMergeableConferenceInterface::create();
903@@ -60,7 +54,6 @@
904
905 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mHoldIface));
906 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mMuteIface));
907- baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mAudioOutputsIface));
908 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mConferenceIface));
909 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mMergeableIface));
910
911@@ -126,20 +119,6 @@
912 }
913 }
914
915-void oFonoConferenceCallChannel::onSetActiveAudioOutput(const QString &id, Tp::DBusError *error)
916-{
917-#ifdef USE_PULSEAUDIO
918- // fallback to earpiece/headset
919- AudioMode mode = AudioModeWiredOrEarpiece;
920- if (id == "bluetooth") {
921- mode = AudioModeBluetooth;
922- } else if (id == "speaker") {
923- mode = AudioModeSpeaker;
924- }
925- QPulseAudioEngine::instance()->setCallMode(CallActive, mode);
926-#endif
927-}
928-
929 void oFonoConferenceCallChannel::onHangup(uint reason, const QString &detailedReason, const QString &message, Tp::DBusError *error)
930 {
931 // TODO: use the parameters sent by telepathy
932@@ -174,13 +153,8 @@
933
934 QObject::connect(mBaseChannel.data(), SIGNAL(closed()), this, SLOT(deleteLater()));
935 QObject::connect(mConnection->callVolume(), SIGNAL(mutedChanged(bool)), SLOT(onOfonoMuteChanged(bool)));
936- QObject::connect(mConnection, SIGNAL(activeAudioOutputChanged(QString)), mAudioOutputsIface.data(), SLOT(setActiveAudioOutput(QString)));
937- QObject::connect(mConnection, SIGNAL(audioOutputsChanged(AudioOutputList)), mAudioOutputsIface.data(), SLOT(setAudioOutputs(AudioOutputList)));
938 QObject::connect(mConnection->voiceCallManager(), SIGNAL(sendTonesComplete(bool)), SLOT(onDtmfComplete(bool)));
939
940- mAudioOutputsIface->setAudioOutputs(mConnection->audioOutputs());
941- mAudioOutputsIface->setActiveAudioOutput(mConnection->activeAudioOutput());
942-
943 QObject::connect(mConnection, SIGNAL(channelMerged(const QDBusObjectPath&)), this, SLOT(onChannelMerged(const QDBusObjectPath&)));
944 QObject::connect(mConnection, SIGNAL(channelSplitted(const QDBusObjectPath&)), this, SLOT(onChannelSplitted(const QDBusObjectPath&)));
945 QObject::connect(mConnection, SIGNAL(channelHangup(const QDBusObjectPath&)), this, SLOT(onChannelSplitted(const QDBusObjectPath&)));
946@@ -228,14 +202,8 @@
947 {
948 if (state == Tp::LocalMuteStateMuted) {
949 mConnection->callVolume()->setMuted(true);
950-#ifdef USE_PULSEAUDIO
951- QPulseAudioEngine::instance()->setMicMute(true);
952-#endif
953 } else if (state == Tp::LocalMuteStateUnmuted) {
954 mConnection->callVolume()->setMuted(false);
955-#ifdef USE_PULSEAUDIO
956- QPulseAudioEngine::instance()->setMicMute(false);
957-#endif
958 }
959 }
960
961
962=== modified file 'ofonoconferencecallchannel.h'
963--- ofonoconferencecallchannel.h 2015-01-26 18:52:02 +0000
964+++ ofonoconferencecallchannel.h 2017-03-22 21:10:43 +0000
965@@ -29,7 +29,6 @@
966 #include <ofono-qt/ofonovoicecall.h>
967
968 #include "connection.h"
969-#include "audiooutputsiface.h"
970
971 class oFonoConnection;
972
973@@ -45,7 +44,6 @@
974 void onHoldStateChanged(const Tp::LocalHoldState &state, const Tp::LocalHoldStateReason &reason, Tp::DBusError *error);
975 void onDTMFStartTone(uchar event, Tp::DBusError *error);
976 void onDTMFStopTone(Tp::DBusError *error);
977- void onSetActiveAudioOutput(const QString &id, Tp::DBusError *error);
978 void onMerge(const QDBusObjectPath &channel, Tp::DBusError *error);
979 Tp::BaseChannelPtr baseChannel();
980 void setConferenceActive(bool active);
981@@ -72,7 +70,6 @@
982 Tp::BaseChannelConferenceInterfacePtr mConferenceIface;
983 Tp::BaseChannelMergeableConferenceInterfacePtr mMergeableIface;
984 Tp::BaseCallMuteInterfacePtr mMuteIface;
985- BaseChannelAudioOutputsInterfacePtr mAudioOutputsIface;
986 Tp::BaseChannelCallTypePtr mCallChannel;
987 Tp::BaseCallContentDTMFInterfacePtr mDTMFIface;
988 Tp::BaseCallContentPtr mCallContent;
989
990=== removed file 'powerd.h'
991--- powerd.h 2014-09-30 17:25:02 +0000
992+++ powerd.h 1970-01-01 00:00:00 +0000
993@@ -1,34 +0,0 @@
994-/**
995- * Copyright (C) 2014 Canonical, Ltd.
996- *
997- * This program is free software: you can redistribute it and/or modify it under
998- * the terms of the GNU Lesser General Public License version 3, as published by
999- * the Free Software Foundation.
1000- *
1001- * This program is distributed in the hope that it will be useful, but WITHOUT
1002- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1003- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1004- * Lesser General Public License for more details.
1005- *
1006- * You should have received a copy of the GNU Lesser General Public License
1007- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1008- *
1009- * Authors: Andreas Pokorny <andreas.pokorny@canonical.com>
1010- */
1011-
1012-#ifndef POWERD_H
1013-#define POWERD_H
1014-
1015-class PowerD
1016-{
1017-public:
1018- PowerD() = default;
1019- virtual ~PowerD() = default;
1020- PowerD(PowerD const&) = delete;
1021- PowerD& operator=(PowerD const&) = delete;
1022-
1023- virtual void enableProximityHandling() = 0;
1024- virtual void disableProximityHandling() = 0;
1025-};
1026-
1027-#endif // POWERD_H
1028
1029=== removed file 'powerdaudiomodemediator.cpp'
1030--- powerdaudiomodemediator.cpp 2014-12-15 19:45:19 +0000
1031+++ powerdaudiomodemediator.cpp 1970-01-01 00:00:00 +0000
1032@@ -1,63 +0,0 @@
1033-/**
1034- * Copyright (C) 2014 Canonical, Ltd.
1035- *
1036- * This program is free software: you can redistribute it and/or modify it under
1037- * the terms of the GNU Lesser General Public License version 3, as published by
1038- * the Free Software Foundation.
1039- *
1040- * This program is distributed in the hope that it will be useful, but WITHOUT
1041- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1042- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1043- * Lesser General Public License for more details.
1044- *
1045- * You should have received a copy of the GNU Lesser General Public License
1046- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1047- *
1048- * Authors: Andreas Pokorny <andreas.pokorny@canonical.com>
1049- */
1050-
1051-#include <QDBusInterface>
1052-#include "powerdaudiomodemediator.h"
1053-
1054-PowerDAudioModeMediator::PowerDAudioModeMediator(PowerD &powerd)
1055- : powerd(powerd)
1056-{
1057-}
1058-
1059-void PowerDAudioModeMediator::audioModeChanged(const QString &mode)
1060-{
1061- bool enableProximity = !(mode == "speaker" || mode == "bluetooth" || mode == "wired_headset");
1062-
1063- if (mProximityEnabled != enableProximity)
1064- {
1065- mProximityEnabled = enableProximity;
1066- apply();
1067- }
1068-}
1069-
1070-void PowerDAudioModeMediator::apply() const
1071-{
1072- if (mProximityEnabled) {
1073- powerd.enableProximityHandling();
1074- } else {
1075- // we need to power the screen on before disabling the proximity handling
1076- QDBusInterface unityIface("com.canonical.Unity.Screen",
1077- "/com/canonical/Unity/Screen",
1078- "com.canonical.Unity.Screen",
1079- QDBusConnection::systemBus());
1080- QList<QVariant> args;
1081- args.append("on");
1082- args.append(3);
1083- unityIface.callWithArgumentList(QDBus::NoBlock, "setScreenPowerMode", args);
1084- powerd.disableProximityHandling();
1085- }
1086-}
1087-
1088-void PowerDAudioModeMediator::audioOutputClosed()
1089-{
1090- if (mProximityEnabled)
1091- {
1092- mProximityEnabled = false;
1093- apply();
1094- }
1095-}
1096
1097=== removed file 'powerdaudiomodemediator.h'
1098--- powerdaudiomodemediator.h 2014-09-30 17:25:02 +0000
1099+++ powerdaudiomodemediator.h 1970-01-01 00:00:00 +0000
1100@@ -1,46 +0,0 @@
1101-/****************************************************************************
1102-**
1103-** Copyright (C) 2014 Canonical, Ltd.
1104-**
1105-** Authors:
1106-** Andreas Pokorny <andreas.pokorny@canonical.com>
1107-**
1108-** GNU Lesser General Public License Usage
1109-** Alternatively, this file may be used under the terms of the GNU Lesser
1110-** General Public License version 2.1 as published by the Free Software
1111-** Foundation and appearing in the file LICENSE.LGPL included in the
1112-** packaging of this file. Please review the following information to
1113-** ensure the GNU Lesser General Public License version 2.1 requirements
1114-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
1115-**
1116-****************************************************************************/
1117-
1118-#ifndef POWERDAUDIOMODEMEDIATOR_H
1119-#define POWERDAUDIOMODEMEDIATOR_H
1120-
1121-#include "powerd.h"
1122-
1123-#include <QString>
1124-#include <fstream>
1125-#include <memory>
1126-
1127-class PowerD;
1128-/*!
1129- * \brief PowerDAudioModeMediator is responsible for configuring proximity
1130- * handling of powerd during different call states and used audio outputs.
1131- * In General that mean enabling sreen blanking on proximity events, when
1132- * a call is active and neither a bluetooth headset nor the speakers are used.
1133- */
1134-class PowerDAudioModeMediator
1135-{
1136-public:
1137- PowerDAudioModeMediator(PowerD &powerd);
1138- void audioModeChanged(const QString &mode);
1139- void audioOutputClosed();
1140-private:
1141- void apply() const;
1142- PowerD &powerd;
1143- bool mProximityEnabled{false};
1144-};
1145-
1146-#endif
1147
1148=== removed file 'powerddbus.cpp'
1149--- powerddbus.cpp 2014-09-30 17:25:02 +0000
1150+++ powerddbus.cpp 1970-01-01 00:00:00 +0000
1151@@ -1,43 +0,0 @@
1152-/**
1153- * Copyright (C) 2014 Canonical, Ltd.
1154- *
1155- * This program is free software: you can redistribute it and/or modify it under
1156- * the terms of the GNU Lesser General Public License version 3, as published by
1157- * the Free Software Foundation.
1158- *
1159- * This program is distributed in the hope that it will be useful, but WITHOUT
1160- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1161- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1162- * Lesser General Public License for more details.
1163- *
1164- * You should have received a copy of the GNU Lesser General Public License
1165- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1166- *
1167- * Authors: Andreas Pokorny <andreas.pokorny@canonical.com>
1168- */
1169-
1170-#include "powerddbus.h"
1171-
1172-#include <QDBusConnection>
1173-#include <QDBusInterface>
1174-#include <QDBusReply>
1175-
1176-PowerDDBus::PowerDDBus()
1177- : mPowerDIface{
1178- new QDBusInterface(
1179- "com.canonical.powerd",
1180- "/com/canonical/powerd",
1181- "com.canonical.powerd",
1182- QDBusConnection::systemBus())}
1183-{
1184-}
1185-
1186-void PowerDDBus::enableProximityHandling()
1187-{
1188- mPowerDIface->call("enableProximityHandling", "telepathy-ofono");
1189-}
1190-
1191-void PowerDDBus::disableProximityHandling()
1192-{
1193- mPowerDIface->call("disableProximityHandling", "telepathy-ofono");
1194-}
1195
1196=== removed file 'powerddbus.h'
1197--- powerddbus.h 2014-09-30 17:25:02 +0000
1198+++ powerddbus.h 1970-01-01 00:00:00 +0000
1199@@ -1,38 +0,0 @@
1200-/**
1201- * Copyright (C) 2014 Canonical, Ltd.
1202- *
1203- * This program is free software: you can redistribute it and/or modify it under
1204- * the terms of the GNU Lesser General Public License version 3, as published by
1205- * the Free Software Foundation.
1206- *
1207- * This program is distributed in the hope that it will be useful, but WITHOUT
1208- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1209- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1210- * Lesser General Public License for more details.
1211- *
1212- * You should have received a copy of the GNU Lesser General Public License
1213- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1214- *
1215- * Authors: Andreas Pokorny <andreas.pokorny@canonical.com>
1216- */
1217-
1218-#ifndef POWERD_DUBS_H
1219-#define POWERD_DBUS_H
1220-
1221-#include "powerd.h"
1222-
1223-#include <memory>
1224-
1225-class QDBusInterface;
1226-
1227-class PowerDDBus : public PowerD
1228-{
1229-public:
1230- PowerDDBus();
1231- void enableProximityHandling() override;
1232- void disableProximityHandling() override;
1233-private:
1234- std::unique_ptr<QDBusInterface> mPowerDIface;
1235-};
1236-
1237-#endif
1238
1239=== modified file 'protocol.cpp'
1240--- protocol.cpp 2015-08-18 21:36:52 +0000
1241+++ protocol.cpp 2017-03-22 21:10:43 +0000
1242@@ -24,7 +24,7 @@
1243 #include <TelepathyQt/ProtocolParameterList>
1244
1245 Protocol::Protocol(const QDBusConnection &dbusConnection, const QString &name)
1246- : Tp::BaseProtocol(dbusConnection, name), mAudioModeMediator(mPowerDDBus)
1247+ : Tp::BaseProtocol(dbusConnection, name)
1248 {
1249
1250 addressingIface = Tp::BaseProtocolAddressingInterface::create();
1251@@ -48,13 +48,5 @@
1252 Tp::BaseConnectionPtr Protocol::createConnection(const QVariantMap &parameters, Tp::DBusError *error) {
1253 Q_UNUSED(error);
1254 Tp::BaseConnectionPtr connection_ptr = Tp::BaseConnection::create<oFonoConnection>("ofono", name().toLatin1(), parameters);
1255- connect(
1256- static_cast<oFonoConnection*>(connection_ptr.data()), &oFonoConnection::activeAudioOutputChanged,
1257- Tp::memFun(&mAudioModeMediator, &PowerDAudioModeMediator::audioModeChanged)
1258- );
1259- connect(
1260- static_cast<oFonoConnection*>(connection_ptr.data()), &oFonoConnection::lastChannelClosed,
1261- Tp::memFun(&mAudioModeMediator, &PowerDAudioModeMediator::audioOutputClosed)
1262- );
1263 return connection_ptr;
1264 }
1265
1266=== modified file 'protocol.h'
1267--- protocol.h 2015-08-18 21:36:52 +0000
1268+++ protocol.h 2017-03-22 21:10:43 +0000
1269@@ -24,9 +24,6 @@
1270
1271 #include <TelepathyQt/BaseProtocol>
1272
1273-#include "powerdaudiomodemediator.h"
1274-#include "powerddbus.h"
1275-
1276 class Protocol : public Tp::BaseProtocol
1277 {
1278 Q_OBJECT
1279@@ -38,8 +35,6 @@
1280 private:
1281 Tp::BaseConnectionPtr createConnection(const QVariantMap &parameters, Tp::DBusError *error);
1282 Tp::BaseProtocolAddressingInterfacePtr addressingIface;
1283- PowerDDBus mPowerDDBus;
1284- PowerDAudioModeMediator mAudioModeMediator;
1285 };
1286
1287 #endif
1288
1289=== removed file 'qpulseaudioengine.cpp'
1290--- qpulseaudioengine.cpp 2015-11-10 07:49:07 +0000
1291+++ qpulseaudioengine.cpp 1970-01-01 00:00:00 +0000
1292@@ -1,800 +0,0 @@
1293-/****************************************************************************
1294-**
1295-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
1296-** Contact: http://www.qt-project.org/legal
1297-**
1298-** This file was taken from qt5 and modified by
1299-** David Henningsson <david.henningsson@canonical.com> for usage in
1300-** telepathy-ofono.
1301-**
1302-** GNU Lesser General Public License Usage
1303-** Alternatively, this file may be used under the terms of the GNU Lesser
1304-** General Public License version 2.1 as published by the Free Software
1305-** Foundation and appearing in the file LICENSE.LGPL included in the
1306-** packaging of this file. Please review the following information to
1307-** ensure the GNU Lesser General Public License version 2.1 requirements
1308-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
1309-**
1310-****************************************************************************/
1311-
1312-#include <QtCore/qdebug.h>
1313-
1314-#include "qpulseaudioengine.h"
1315-#include <sys/types.h>
1316-#include <unistd.h>
1317-
1318-#define PULSEAUDIO_PROFILE_HSP "headset_head_unit"
1319-#define PULSEAUDIO_PROFILE_A2DP "a2dp_sink"
1320-
1321-QT_BEGIN_NAMESPACE
1322-
1323-static void contextStateCallbackInit(pa_context *context, void *userdata)
1324-{
1325- Q_UNUSED(context);
1326- QPulseAudioEngineWorker *pulseEngine = reinterpret_cast<QPulseAudioEngineWorker*>(userdata);
1327- pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
1328-}
1329-
1330-static void contextStateCallback(pa_context *context, void *userdata)
1331-{
1332- Q_UNUSED(userdata);
1333- Q_UNUSED(context);
1334-}
1335-
1336-static void success_cb(pa_context *context, int success, void *userdata)
1337-{
1338- QPulseAudioEngineWorker *pulseEngine = reinterpret_cast<QPulseAudioEngineWorker*>(userdata);
1339- pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
1340-}
1341-
1342-/* Callbacks used when handling events from PulseAudio */
1343-static void plug_card_cb(pa_context *c, const pa_card_info *info, int isLast, void *userdata)
1344-{
1345- QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata);
1346- if (isLast != 0 || !pulseEngine || !info) {
1347- pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
1348- return;
1349- }
1350- pulseEngine->plugCardCallback(info);
1351-}
1352-
1353-static void update_card_cb(pa_context *c, const pa_card_info *info, int isLast, void *userdata)
1354-{
1355- QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata);
1356- if (isLast != 0 || !pulseEngine || !info) {
1357- pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
1358- return;
1359- }
1360- pulseEngine->updateCardCallback(info);
1361-}
1362-
1363-static void unplug_card_cb(pa_context *c, const pa_card_info *info, int isLast, void *userdata)
1364-{
1365- QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata);
1366- if (!pulseEngine) {
1367- pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
1368- return;
1369- }
1370-
1371- if (info == NULL) {
1372- /* That means that the card used to query card_info was removed */
1373- pulseEngine->unplugCardCallback();
1374- }
1375-}
1376-
1377-static void subscribeCallback(pa_context *context, pa_subscription_event_type_t t, uint32_t idx, void *userdata)
1378-{
1379- /* For card change events (slot plug/unplug and add/remove card) */
1380- if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_CARD) {
1381- if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE) {
1382- QMetaObject::invokeMethod((QPulseAudioEngineWorker *) userdata, "handleCardEvent",
1383- Qt::QueuedConnection, Q_ARG(int, PA_SUBSCRIPTION_EVENT_CHANGE), Q_ARG(unsigned int, idx));
1384- } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
1385- QMetaObject::invokeMethod((QPulseAudioEngineWorker *) userdata, "handleCardEvent",
1386- Qt::QueuedConnection, Q_ARG(int, PA_SUBSCRIPTION_EVENT_NEW), Q_ARG(unsigned int, idx));
1387- } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
1388- QMetaObject::invokeMethod((QPulseAudioEngineWorker *) userdata, "handleCardEvent",
1389- Qt::QueuedConnection, Q_ARG(int, PA_SUBSCRIPTION_EVENT_REMOVE), Q_ARG(unsigned int, idx));
1390- }
1391- }
1392-}
1393-
1394-QPulseAudioEngineWorker::QPulseAudioEngineWorker(QObject *parent)
1395- : QObject(parent)
1396- , m_mainLoopApi(0)
1397- , m_context(0)
1398- , m_callstatus(CallEnded)
1399- , m_audiomode(AudioModeSpeaker)
1400- , m_micmute(false)
1401- , m_defaultsink("sink.primary")
1402- , m_defaultsource("source.primary")
1403- , m_voicecallcard("")
1404- , m_voicecallhighest("")
1405- , m_voicecallprofile("")
1406- , m_bt_hsp("")
1407- , m_bt_hsp_a2dp("")
1408-
1409-{
1410- m_mainLoop = pa_threaded_mainloop_new();
1411- if (m_mainLoop == 0) {
1412- qWarning("Unable to create pulseaudio mainloop");
1413- return;
1414- }
1415-
1416- if (pa_threaded_mainloop_start(m_mainLoop) != 0) {
1417- qWarning("Unable to start pulseaudio mainloop");
1418- pa_threaded_mainloop_free(m_mainLoop);
1419- m_mainLoop = 0;
1420- return;
1421- }
1422-
1423- createPulseContext();
1424-}
1425-
1426-bool QPulseAudioEngineWorker::createPulseContext()
1427-{
1428- bool keepGoing = true;
1429- bool ok = true;
1430-
1431- if (m_context)
1432- return true;
1433-
1434- m_mainLoopApi = pa_threaded_mainloop_get_api(m_mainLoop);
1435-
1436- pa_threaded_mainloop_lock(m_mainLoop);
1437-
1438- m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtmPulseContext:%1")).arg(::getpid()).toLatin1().constData());
1439- pa_context_set_state_callback(m_context, contextStateCallbackInit, this);
1440-
1441- if (!m_context) {
1442- qWarning("Unable to create new pulseaudio context");
1443- pa_threaded_mainloop_unlock(m_mainLoop);
1444- return false;
1445- }
1446-
1447- if (pa_context_connect(m_context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) < 0) {
1448- qWarning("Unable to create a connection to the pulseaudio context");
1449- pa_threaded_mainloop_unlock(m_mainLoop);
1450- releasePulseContext();
1451- return false;
1452- }
1453-
1454- pa_threaded_mainloop_wait(m_mainLoop);
1455-
1456- while (keepGoing) {
1457- switch (pa_context_get_state(m_context)) {
1458- case PA_CONTEXT_CONNECTING:
1459- case PA_CONTEXT_AUTHORIZING:
1460- case PA_CONTEXT_SETTING_NAME:
1461- break;
1462-
1463- case PA_CONTEXT_READY:
1464- qDebug("Pulseaudio connection established.");
1465- keepGoing = false;
1466- break;
1467-
1468- case PA_CONTEXT_TERMINATED:
1469- qCritical("Pulseaudio context terminated.");
1470- keepGoing = false;
1471- ok = false;
1472- break;
1473-
1474- case PA_CONTEXT_FAILED:
1475- default:
1476- qCritical() << QString("Pulseaudio connection failure: %1").arg(pa_strerror(pa_context_errno(m_context)));
1477- keepGoing = false;
1478- ok = false;
1479- }
1480-
1481- if (keepGoing) {
1482- pa_threaded_mainloop_wait(m_mainLoop);
1483- }
1484- }
1485-
1486- if (ok) {
1487- pa_context_set_state_callback(m_context, contextStateCallback, this);
1488- pa_context_set_subscribe_callback(m_context, subscribeCallback, this);
1489- pa_context_subscribe(m_context, PA_SUBSCRIPTION_MASK_CARD, NULL, this);
1490- } else {
1491- if (m_context) {
1492- pa_context_unref(m_context);
1493- m_context = 0;
1494- }
1495- }
1496-
1497- pa_threaded_mainloop_unlock(m_mainLoop);
1498- return true;
1499-}
1500-
1501-
1502-void QPulseAudioEngineWorker::releasePulseContext()
1503-{
1504- if (m_context) {
1505- pa_threaded_mainloop_lock(m_mainLoop);
1506- pa_context_disconnect(m_context);
1507- pa_context_unref(m_context);
1508- pa_threaded_mainloop_unlock(m_mainLoop);
1509- m_context = 0;
1510- }
1511-
1512-}
1513-
1514-QPulseAudioEngineWorker::~QPulseAudioEngineWorker()
1515-{
1516- releasePulseContext();
1517-
1518- if (m_mainLoop) {
1519- pa_threaded_mainloop_stop(m_mainLoop);
1520- pa_threaded_mainloop_free(m_mainLoop);
1521- m_mainLoop = 0;
1522- }
1523-}
1524-
1525-void QPulseAudioEngineWorker::cardInfoCallback(const pa_card_info *info)
1526-{
1527- pa_card_profile_info2 *voice_call = NULL, *highest = NULL;
1528- pa_card_profile_info2 *hsp = NULL, *a2dp = NULL;
1529-
1530- /* For now we only support one card with the voicecall feature */
1531- for (int i = 0; i < info->n_profiles; i++) {
1532- if (!highest || info->profiles2[i]->priority > highest->priority)
1533- highest = info->profiles2[i];
1534- if (!strcmp(info->profiles2[i]->name, "voicecall"))
1535- voice_call = info->profiles2[i];
1536- else if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_HSP) &&
1537- info->profiles2[i]->available != 0)
1538- hsp = info->profiles2[i];
1539- else if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_A2DP) &&
1540- info->profiles2[i]->available != 0)
1541- a2dp = info->profiles2[i];
1542- }
1543-
1544- /* Record the card that supports voicecall (default one to be used) */
1545- if (voice_call) {
1546- qDebug("Found card that supports voicecall: '%s'", info->name);
1547- m_voicecallcard = info->name;
1548- m_voicecallhighest = highest->name;
1549- m_voicecallprofile = voice_call->name;
1550- }
1551-
1552- /* Handle the use cases needed for bluetooth */
1553- if (hsp && a2dp) {
1554- qDebug("Found card that supports hsp and a2dp: '%s'", info->name);
1555- m_bt_hsp_a2dp = info->name;
1556- } else if (hsp && (a2dp == NULL)) {
1557- /* This card only provides the hsp profile */
1558- qDebug("Found card that supports only hsp: '%s'", info->name);
1559- m_bt_hsp = info->name;
1560- }
1561-}
1562-
1563-void QPulseAudioEngineWorker::sinkInfoCallback(const pa_sink_info *info)
1564-{
1565- pa_sink_port_info *earpiece = NULL, *speaker = NULL;
1566- pa_sink_port_info *wired_headset = NULL, *wired_headphone = NULL;
1567- pa_sink_port_info *preferred = NULL;
1568- pa_sink_port_info *bluetooth_sco = NULL;
1569- pa_sink_port_info *speaker_and_wired_headphone = NULL;
1570- AudioMode audiomodetoset;
1571- AudioModes modes;
1572-
1573- for (int i = 0; i < info->n_ports; i++) {
1574- if (!strcmp(info->ports[i]->name, "output-earpiece"))
1575- earpiece = info->ports[i];
1576- else if (!strcmp(info->ports[i]->name, "output-wired_headset") &&
1577- (info->ports[i]->available != PA_PORT_AVAILABLE_NO))
1578- wired_headset = info->ports[i];
1579- else if (!strcmp(info->ports[i]->name, "output-wired_headphone") &&
1580- (info->ports[i]->available != PA_PORT_AVAILABLE_NO))
1581- wired_headphone = info->ports[i];
1582- else if (!strcmp(info->ports[i]->name, "output-speaker"))
1583- speaker = info->ports[i];
1584- else if (!strcmp(info->ports[i]->name, "output-bluetooth_sco"))
1585- bluetooth_sco = info->ports[i];
1586- else if (!strcmp(info->ports[i]->name, "output-speaker+wired_headphone"))
1587- speaker_and_wired_headphone = info->ports[i];
1588- }
1589-
1590- if (!earpiece || !speaker)
1591- return; /* Not the right sink */
1592-
1593- /* Refresh list of available audio modes */
1594- modes.append(AudioModeEarpiece);
1595- modes.append(AudioModeSpeaker);
1596- if (wired_headset || wired_headphone)
1597- modes.append(AudioModeWiredHeadset);
1598- if (bluetooth_sco && ((m_bt_hsp != "") || (m_bt_hsp_a2dp != "")))
1599- modes.append(AudioModeBluetooth);
1600-
1601- /* Check if the requested mode is available (earpiece*/
1602- if (((m_audiomode == AudioModeWiredHeadset) && !modes.contains(AudioModeWiredHeadset)) ||
1603- ((m_audiomode == AudioModeBluetooth) && !modes.contains(AudioModeBluetooth)))
1604- return;
1605-
1606- /* Now to decide which output to be used, depending on the active mode */
1607- if (m_audiomode & AudioModeEarpiece) {
1608- preferred = earpiece;
1609- audiomodetoset = AudioModeEarpiece;
1610- }
1611- if (m_audiomode & AudioModeSpeaker) {
1612- preferred = speaker;
1613- audiomodetoset = AudioModeSpeaker;
1614- }
1615- if ((m_audiomode & AudioModeWiredHeadset) && (modes.contains(AudioModeWiredHeadset))) {
1616- preferred = wired_headset ? wired_headset : wired_headphone;
1617- audiomodetoset = AudioModeWiredHeadset;
1618- }
1619- if (m_callstatus == CallRinging && speaker_and_wired_headphone) {
1620- preferred = speaker_and_wired_headphone;
1621- }
1622- if ((m_audiomode & AudioModeBluetooth) && (modes.contains(AudioModeBluetooth))) {
1623- preferred = bluetooth_sco;
1624- audiomodetoset = AudioModeBluetooth;
1625- }
1626-
1627- m_audiomode = audiomodetoset;
1628-
1629- m_nametoset = info->name;
1630- if (info->active_port != preferred)
1631- m_valuetoset = preferred->name;
1632-
1633- if (modes != m_availableAudioModes)
1634- m_availableAudioModes = modes;
1635-}
1636-
1637-void QPulseAudioEngineWorker::sourceInfoCallback(const pa_source_info *info)
1638-{
1639- pa_source_port_info *builtin_mic = NULL, *preferred = NULL;
1640- pa_source_port_info *wired_headset = NULL, *bluetooth_sco = NULL;
1641-
1642- if (info->monitor_of_sink != PA_INVALID_INDEX)
1643- return; /* Not the right source */
1644-
1645- for (int i = 0; i < info->n_ports; i++) {
1646- if (!strcmp(info->ports[i]->name, "input-builtin_mic"))
1647- builtin_mic = info->ports[i];
1648- else if (!strcmp(info->ports[i]->name, "input-wired_headset") &&
1649- (info->ports[i]->available != PA_PORT_AVAILABLE_NO))
1650- wired_headset = info->ports[i];
1651- else if (!strcmp(info->ports[i]->name, "input-bluetooth_sco_headset"))
1652- bluetooth_sco = info->ports[i];
1653- }
1654-
1655- if (!builtin_mic)
1656- return; /* Not the right source */
1657-
1658- /* Now to decide which output to be used, depending on the active mode */
1659- if ((m_audiomode & AudioModeEarpiece) || (m_audiomode & AudioModeSpeaker))
1660- preferred = builtin_mic;
1661- if ((m_audiomode & AudioModeWiredHeadset) && (m_availableAudioModes.contains(AudioModeWiredHeadset)))
1662- preferred = wired_headset ? wired_headset : builtin_mic;
1663- if ((m_audiomode & AudioModeBluetooth) && (m_availableAudioModes.contains(AudioModeBluetooth)))
1664- preferred = bluetooth_sco;
1665-
1666- m_nametoset = info->name;
1667- if (info->active_port != preferred)
1668- m_valuetoset = preferred->name;
1669-}
1670-
1671-void QPulseAudioEngineWorker::serverInfoCallback(const pa_server_info *info)
1672-{
1673- /* Saving default sink/source to restore after call hangup */
1674- m_defaultsink = info->default_sink_name;
1675- m_defaultsource = info->default_source_name;
1676-
1677- /* In the case of a server callback we need to signal the mainloop */
1678- pa_threaded_mainloop_signal(mainloop(), 0);
1679-}
1680-
1681-static void cardinfo_cb(pa_context *context, const pa_card_info *info, int isLast, void *userdata)
1682-{
1683- QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata);
1684- if (isLast != 0 || !pulseEngine || !info) {
1685- pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
1686- return;
1687- }
1688- pulseEngine->cardInfoCallback(info);
1689-}
1690-
1691-static void sinkinfo_cb(pa_context *context, const pa_sink_info *info, int isLast, void *userdata)
1692-{
1693- QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata);
1694- if (isLast != 0 || !pulseEngine || !info) {
1695- pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
1696- return;
1697- }
1698- pulseEngine->sinkInfoCallback(info);
1699-}
1700-
1701-static void sourceinfo_cb(pa_context *context, const pa_source_info *info, int isLast, void *userdata)
1702-{
1703- QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata);
1704- if (isLast != 0 || !pulseEngine || !info) {
1705- pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
1706- return;
1707- }
1708- pulseEngine->sourceInfoCallback(info);
1709-}
1710-
1711-static void serverinfo_cb(pa_context *context, const pa_server_info *info, void *userdata)
1712-{
1713- QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata);
1714- if (!pulseEngine || !info) {
1715- pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
1716- return;
1717- }
1718- pulseEngine->serverInfoCallback(info);
1719-}
1720-
1721-bool QPulseAudioEngineWorker::handleOperation(pa_operation *operation, const char *func_name)
1722-{
1723- if (!operation) {
1724- qCritical("'%s' failed (lost PulseAudio connection?)", func_name);
1725- /* Free resources so it can retry a new connection during next operation */
1726- pa_threaded_mainloop_unlock(m_mainLoop);
1727- releasePulseContext();
1728- return false;
1729- }
1730-
1731- while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING)
1732- pa_threaded_mainloop_wait(m_mainLoop);
1733- pa_operation_unref(operation);
1734- return true;
1735-}
1736-
1737-int QPulseAudioEngineWorker::setupVoiceCall()
1738-{
1739- pa_operation *o;
1740-
1741- qDebug("Setting up pulseaudio for voice call");
1742-
1743- pa_threaded_mainloop_lock(m_mainLoop);
1744-
1745- /* Get and set the default sink/source to be restored later */
1746- o = pa_context_get_server_info(m_context, serverinfo_cb, this);
1747- if (!handleOperation(o, "pa_context_get_server_info"))
1748- return -1;
1749-
1750- qDebug("Recorded default sink: %s default source: %s",
1751- m_defaultsink.c_str(), m_defaultsource.c_str());
1752-
1753- /* Walk through the list of devices, find the voice call capable card and
1754- * identify if we have bluetooth capable devices (hsp and a2dp) */
1755- m_voicecallcard = m_voicecallhighest = m_voicecallprofile = "";
1756- m_bt_hsp = m_bt_hsp_a2dp = "";
1757- o = pa_context_get_card_info_list(m_context, cardinfo_cb, this);
1758- if (!handleOperation(o, "pa_context_get_card_info_list"))
1759- return -1;
1760- /* In case we have only one bt device that provides hsp and a2dp, we need
1761- * to make sure we switch the default profile for that card (to hsp) */
1762- if ((m_bt_hsp_a2dp != "") && (m_bt_hsp == "")) {
1763- qDebug("Setting PulseAudio card '%s' profile '%s'",
1764- m_bt_hsp_a2dp.c_str(), PULSEAUDIO_PROFILE_HSP);
1765- o = pa_context_set_card_profile_by_name(m_context,
1766- m_bt_hsp_a2dp.c_str(), PULSEAUDIO_PROFILE_HSP, success_cb, this);
1767- if (!handleOperation(o, "pa_context_set_card_profile_by_name"))
1768- return -1;
1769- }
1770-
1771- pa_threaded_mainloop_unlock(m_mainLoop);
1772-
1773- return 0;
1774-}
1775-
1776-void QPulseAudioEngineWorker::restoreVoiceCall()
1777-{
1778- pa_operation *o;
1779-
1780- qDebug("Restoring pulseaudio previous state");
1781-
1782- /* Then restore previous settings */
1783- pa_threaded_mainloop_lock(m_mainLoop);
1784-
1785- /* See if we need to restore any HSP+AD2P device state */
1786- if ((m_bt_hsp_a2dp != "") && (m_bt_hsp == "")) {
1787- qDebug("Restoring PulseAudio card '%s' to profile '%s'",
1788- m_bt_hsp_a2dp.c_str(), PULSEAUDIO_PROFILE_A2DP);
1789- o = pa_context_set_card_profile_by_name(m_context,
1790- m_bt_hsp_a2dp.c_str(), PULSEAUDIO_PROFILE_A2DP, success_cb, this);
1791- if (!handleOperation(o, "pa_context_set_card_profile_by_name"))
1792- return;
1793- }
1794-
1795- /* Restore default sink/source */
1796- if (m_defaultsink != "") {
1797- qDebug("Restoring PulseAudio default sink to '%s'", m_defaultsink.c_str());
1798- o = pa_context_set_default_sink(m_context, m_defaultsink.c_str(), success_cb, this);
1799- if (!handleOperation(o, "pa_context_set_default_sink"))
1800- return;
1801- }
1802- if (m_defaultsource != "") {
1803- qDebug("Restoring PulseAudio default source to '%s'", m_defaultsource.c_str());
1804- o = pa_context_set_default_source(m_context, m_defaultsource.c_str(), success_cb, this);
1805- if (!handleOperation(o, "pa_context_set_default_source"))
1806- return;
1807- }
1808-
1809- pa_threaded_mainloop_unlock(m_mainLoop);
1810-}
1811-
1812-void QPulseAudioEngineWorker::setCallMode(CallStatus callstatus, AudioMode audiomode)
1813-{
1814- if (!createPulseContext()) {
1815- return;
1816- }
1817- CallStatus p_callstatus = m_callstatus;
1818- AudioMode p_audiomode = m_audiomode;
1819- AudioModes p_availableAudioModes = m_availableAudioModes;
1820- pa_operation *o;
1821-
1822- /* Check if we need to save the current pulseaudio state (e.g. when starting a call) */
1823- if ((callstatus != CallEnded) && (p_callstatus == CallEnded)) {
1824- if (setupVoiceCall() < 0) {
1825- qCritical("Failed to setup PulseAudio for Voice Call");
1826- return;
1827- }
1828- }
1829-
1830- /* If we have an active call, update internal state (used later when updating sink/source ports) */
1831- m_callstatus = callstatus;
1832- m_audiomode = audiomode;
1833-
1834- pa_threaded_mainloop_lock(m_mainLoop);
1835-
1836- /* Switch the virtual card mode when call is active and not active
1837- * This needs to be done before sink/source gets updated, because after changing mode
1838- * it will automatically move to input/output-parking */
1839- if ((m_callstatus == CallActive) && (p_callstatus != CallActive) &&
1840- (m_voicecallcard != "") && (m_voicecallprofile != "")) {
1841- qDebug("Setting PulseAudio card '%s' profile '%s'",
1842- m_voicecallcard.c_str(), m_voicecallprofile.c_str());
1843- o = pa_context_set_card_profile_by_name(m_context,
1844- m_voicecallcard.c_str(), m_voicecallprofile.c_str(), success_cb, this);
1845- if (!handleOperation(o, "pa_context_set_card_profile_by_name"))
1846- return;
1847- } else if ((m_callstatus == CallEnded) && (m_voicecallcard != "") && (m_voicecallhighest != "")) {
1848- /* If using droid, make sure to restore to the profile that has the highest score */
1849- qDebug("Restoring PulseAudio card '%s' to profile '%s'",
1850- m_voicecallcard.c_str(), m_voicecallhighest.c_str());
1851- o = pa_context_set_card_profile_by_name(m_context,
1852- m_voicecallcard.c_str(), m_voicecallhighest.c_str(), success_cb, this);
1853- if (!handleOperation(o, "pa_context_set_card_profile_by_name"))
1854- return;
1855- }
1856-
1857- /* Find highest compatible sink/source elements from the voicecall
1858- compatible card (on touch this means the pulse droid element) */
1859- m_nametoset = m_valuetoset = "";
1860- o = pa_context_get_sink_info_list(m_context, sinkinfo_cb, this);
1861- if (!handleOperation(o, "pa_context_get_sink_info_list"))
1862- return;
1863- if ((m_nametoset != "") && (m_nametoset != m_defaultsink)) {
1864- qDebug("Setting PulseAudio default sink to '%s'", m_nametoset.c_str());
1865- o = pa_context_set_default_sink(m_context, m_nametoset.c_str(), success_cb, this);
1866- if (!handleOperation(o, "pa_context_set_default_sink"))
1867- return;
1868- }
1869- if (m_valuetoset != "") {
1870- qDebug("Setting PulseAudio sink '%s' port '%s'",
1871- m_nametoset.c_str(), m_valuetoset.c_str());
1872- o = pa_context_set_sink_port_by_name(m_context, m_nametoset.c_str(),
1873- m_valuetoset.c_str(), success_cb, this);
1874- if (!handleOperation(o, "pa_context_set_sink_port_by_name"))
1875- return;
1876- }
1877-
1878- /* Same for source */
1879- m_nametoset = m_valuetoset = "";
1880- o = pa_context_get_source_info_list(m_context, sourceinfo_cb, this);
1881- if (!handleOperation(o, "pa_context_get_source_info_list"))
1882- return;
1883- if ((m_nametoset != "") && (m_nametoset != m_defaultsource)) {
1884- qDebug("Setting PulseAudio default source to '%s'", m_nametoset.c_str());
1885- o = pa_context_set_default_source(m_context, m_nametoset.c_str(), success_cb, this);
1886- if (!handleOperation(o, "pa_context_set_default_source"))
1887- return;
1888- }
1889- if (m_valuetoset != "") {
1890- qDebug("Setting PulseAudio source '%s' port '%s'",
1891- m_nametoset.c_str(), m_valuetoset.c_str());
1892- o = pa_context_set_source_port_by_name(m_context, m_nametoset.c_str(),
1893- m_valuetoset.c_str(), success_cb, this);
1894- if (!handleOperation(o, "pa_context_set_source_port_by_name"))
1895- return;
1896- }
1897-
1898- pa_threaded_mainloop_unlock(m_mainLoop);
1899-
1900- /* Notify if the list of audio modes changed */
1901- if (p_availableAudioModes != m_availableAudioModes)
1902- Q_EMIT availableAudioModesChanged(m_availableAudioModes);
1903-
1904- /* Notify if call mode changed */
1905- if (p_audiomode != m_audiomode) {
1906- Q_EMIT audioModeChanged(m_audiomode);
1907- }
1908-
1909- /* If no more active voicecall, restore previous saved pulseaudio state */
1910- if (callstatus == CallEnded) {
1911- restoreVoiceCall();
1912- }
1913-
1914- /* In case the app had set mute when the call wasn't active, make sure we reflect it here */
1915- if (m_callstatus != CallEnded)
1916- setMicMute(m_micmute);
1917-}
1918-
1919-void QPulseAudioEngineWorker::setMicMute(bool muted)
1920-{
1921- if (!createPulseContext()) {
1922- return;
1923- }
1924-
1925- m_micmute = muted;
1926-
1927- if (m_callstatus == CallEnded)
1928- return;
1929-
1930- pa_threaded_mainloop_lock(m_mainLoop);
1931-
1932- m_nametoset = "";
1933- pa_operation *o = pa_context_get_source_info_list(m_context, sourceinfo_cb, this);
1934- if (!handleOperation(o, "pa_context_get_source_info_list"))
1935- return;
1936-
1937- if (m_nametoset != "") {
1938- int m = m_micmute ? 1 : 0;
1939- qDebug("Setting PulseAudio source '%s' muted '%d'", m_nametoset.c_str(), m);
1940- o = pa_context_set_source_mute_by_name(m_context,
1941- m_nametoset.c_str(), m, success_cb, this);
1942- if (!handleOperation(o, "pa_context_set_source_mute_by_name"))
1943- return;
1944- }
1945-
1946- pa_threaded_mainloop_unlock(m_mainLoop);
1947-}
1948-
1949-void QPulseAudioEngineWorker::plugCardCallback(const pa_card_info *info)
1950-{
1951- qDebug("Notified about card (%s) add event from PulseAudio", info->name);
1952-
1953- /* We only care about BT (HSP) devices, and if one is not already available */
1954- if ((m_callstatus != CallEnded) && ((m_bt_hsp == "") || (m_bt_hsp_a2dp == ""))) {
1955- /* Check if it's indeed a BT device (with at least one hsp profile) */
1956- pa_card_profile_info *hsp = NULL;
1957- for (int i = 0; i < info->n_profiles; i++) {
1958- if (!strcmp(info->profiles[i].name, PULSEAUDIO_PROFILE_HSP))
1959- hsp = &info->profiles[i];
1960- }
1961- if (hsp)
1962- m_handleevent = true;
1963- }
1964-}
1965-
1966-void QPulseAudioEngineWorker::updateCardCallback(const pa_card_info *info)
1967-{
1968- qDebug("Notified about card (%s) changes event from PulseAudio", info->name);
1969-
1970- /* We only care if the card event for the voicecall capable card */
1971- if ((m_callstatus == CallActive) && (!strcmp(info->name, m_voicecallcard.c_str()))) {
1972- if (m_audiomode == AudioModeWiredHeadset) {
1973- /* If previous mode is wired, it means it got unplugged */
1974- m_handleevent = true;
1975- m_audiomodetoset = AudioModeBtOrWiredOrEarpiece;
1976- } else if ((m_audiomode == AudioModeEarpiece) || ((m_audiomode == AudioModeSpeaker))) {
1977- /* Now only trigger the event in case wired headset/headphone is now available */
1978- pa_card_port_info *port_info = NULL;
1979- for (int i = 0; i < info->n_ports; i++) {
1980- if (info->ports[i] && (info->ports[i]->available == PA_PORT_AVAILABLE_YES) && (
1981- !strcmp(info->ports[i]->name, "output-wired_headset") ||
1982- !strcmp(info->ports[i]->name, "output-wired_headphone"))) {
1983- m_handleevent = true;
1984- m_audiomodetoset = AudioModeWiredOrEarpiece;
1985- }
1986- }
1987- } else if (m_audiomode == AudioModeBluetooth) {
1988- /* Handle the event so we can update the audiomodes */
1989- m_handleevent = true;
1990- m_audiomodetoset = AudioModeBluetooth;
1991- }
1992- }
1993-}
1994-
1995-void QPulseAudioEngineWorker::unplugCardCallback()
1996-{
1997- if (m_callstatus != CallEnded) {
1998- m_handleevent = true;
1999- }
2000-}
2001-
2002-void QPulseAudioEngineWorker::handleCardEvent(const int evt, const unsigned int idx)
2003-{
2004- pa_operation *o = NULL;
2005-
2006- /* Internal state var used to know if we need to update our internal state */
2007- m_handleevent = false;
2008-
2009- if (evt == PA_SUBSCRIPTION_EVENT_NEW) {
2010- o = pa_context_get_card_info_by_index(m_context, idx, plug_card_cb, this);
2011- if (!handleOperation(o, "pa_context_get_card_info_by_index"))
2012- return;
2013- if (m_handleevent) {
2014- qDebug("Adding new BT-HSP capable device");
2015- /* In case A2DP is available, switch to HSP */
2016- if (setupVoiceCall() < 0)
2017- return;
2018- /* Enable the HSP output port */
2019- setCallMode(m_callstatus, AudioModeBluetooth);
2020- }
2021- } else if (evt == PA_SUBSCRIPTION_EVENT_CHANGE) {
2022- o = pa_context_get_card_info_by_index(m_context, idx, update_card_cb, this);
2023- if (!handleOperation(o, "pa_context_get_card_info_by_index"))
2024- return;
2025- if (m_handleevent) {
2026- /* In this case it means the handset state changed */
2027- qDebug("Notifying card changes for the voicecall capable card");
2028- setCallMode(m_callstatus, m_audiomodetoset);
2029- }
2030- } else if (evt == PA_SUBSCRIPTION_EVENT_REMOVE) {
2031- /* Check if the main HSP card was removed */
2032- if (m_bt_hsp != "") {
2033- o = pa_context_get_card_info_by_name(m_context, m_bt_hsp.c_str(), unplug_card_cb, this);
2034- if (!handleOperation(o, "pa_context_get_sink_info_by_name"))
2035- return;
2036- }
2037- if (m_bt_hsp_a2dp != "") {
2038- o = pa_context_get_card_info_by_name(m_context, m_bt_hsp_a2dp.c_str(), unplug_card_cb, this);
2039- if (!handleOperation(o, "pa_context_get_sink_info_by_name"))
2040- return;
2041- }
2042- if (m_handleevent) {
2043- qDebug("Notifying about BT-HSP card removal");
2044- /* Needed in order to save the default sink/source */
2045- if (setupVoiceCall() < 0)
2046- return;
2047- /* Enable the default handset output port */
2048- setCallMode(m_callstatus, AudioModeWiredOrEarpiece);
2049- }
2050- }
2051-}
2052-
2053-Q_GLOBAL_STATIC(QPulseAudioEngine, pulseEngine);
2054-
2055-QPulseAudioEngine::QPulseAudioEngine(QObject *parent) :
2056- QObject(parent)
2057-{
2058- qRegisterMetaType<CallStatus>();
2059- qRegisterMetaType<AudioMode>();
2060- qRegisterMetaType<AudioModes>();
2061- mWorker = new QPulseAudioEngineWorker();
2062- QObject::connect(mWorker, SIGNAL(audioModeChanged(const AudioMode)), this, SIGNAL(audioModeChanged(const AudioMode)), Qt::QueuedConnection);
2063- QObject::connect(mWorker, SIGNAL(availableAudioModesChanged(const AudioModes)), this, SIGNAL(availableAudioModesChanged(const AudioModes)), Qt::QueuedConnection);
2064- mWorker->createPulseContext();
2065- mWorker->moveToThread(&mThread);
2066- mThread.start();
2067-}
2068-
2069-QPulseAudioEngine::~QPulseAudioEngine()
2070-{
2071- mThread.quit();
2072- mThread.wait();
2073-}
2074-
2075-QPulseAudioEngine *QPulseAudioEngine::instance()
2076-{
2077- QPulseAudioEngine *engine = pulseEngine();
2078- return engine;
2079-}
2080-
2081-void QPulseAudioEngine::setCallMode(CallStatus callstatus, AudioMode audiomode)
2082-{
2083- QMetaObject::invokeMethod(mWorker, "setCallMode", Qt::QueuedConnection, Q_ARG(CallStatus, callstatus), Q_ARG(AudioMode, audiomode));
2084-}
2085-
2086-void QPulseAudioEngine::setMicMute(bool muted)
2087-{
2088- QMetaObject::invokeMethod(mWorker, "setMicMute", Qt::QueuedConnection, Q_ARG(bool, muted));
2089-}
2090-
2091-QT_END_NAMESPACE
2092-
2093
2094=== removed file 'qpulseaudioengine.h'
2095--- qpulseaudioengine.h 2015-07-28 18:10:10 +0000
2096+++ qpulseaudioengine.h 1970-01-01 00:00:00 +0000
2097@@ -1,124 +0,0 @@
2098-/****************************************************************************
2099-**
2100-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
2101-** Contact: http://www.qt-project.org/legal
2102-**
2103-** This file was taken from qt5 and modified by
2104-** David Henningsson <david.henningsson@canonical.com> for usage in
2105-** telepathy-ofono.
2106-**
2107-** GNU Lesser General Public License Usage
2108-** Alternatively, this file may be used under the terms of the GNU Lesser
2109-** General Public License version 2.1 as published by the Free Software
2110-** Foundation and appearing in the file LICENSE.LGPL included in the
2111-** packaging of this file. Please review the following information to
2112-** ensure the GNU Lesser General Public License version 2.1 requirements
2113-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
2114-**
2115-****************************************************************************/
2116-
2117-#ifndef QPULSEAUDIOENGINE_H
2118-#define QPULSEAUDIOENGINE_H
2119-
2120-#include <QtCore/qmap.h>
2121-#include <QtCore/qbytearray.h>
2122-#include <QThread>
2123-#include <pulse/pulseaudio.h>
2124-
2125-enum AudioMode {
2126- AudioModeEarpiece = 0x0001,
2127- AudioModeWiredHeadset = 0x0002,
2128- AudioModeSpeaker = 0x0004,
2129- AudioModeBluetooth = 0x0008,
2130- AudioModeBtOrWiredOrEarpiece = AudioModeBluetooth | AudioModeWiredHeadset | AudioModeEarpiece,
2131- AudioModeWiredOrEarpiece = AudioModeWiredHeadset | AudioModeEarpiece,
2132- AudioModeWiredOrSpeaker = AudioModeWiredHeadset | AudioModeSpeaker
2133-};
2134-
2135-Q_DECLARE_METATYPE(AudioMode)
2136-
2137-typedef QList<AudioMode> AudioModes;
2138-Q_DECLARE_METATYPE(AudioModes)
2139-
2140-enum CallStatus {
2141- CallRinging,
2142- CallActive,
2143- CallEnded
2144-};
2145-
2146-Q_DECLARE_METATYPE(CallStatus)
2147-
2148-QT_BEGIN_NAMESPACE
2149-
2150-class QPulseAudioEngineWorker : public QObject
2151-{
2152- Q_OBJECT
2153-
2154-public:
2155- QPulseAudioEngineWorker(QObject *parent = 0);
2156- ~QPulseAudioEngineWorker();
2157-
2158- pa_threaded_mainloop *mainloop() { return m_mainLoop; }
2159- pa_context *context() { return m_context; }
2160- bool createPulseContext(void);
2161- int setupVoiceCall(void);
2162- void restoreVoiceCall(void);
2163- /* Callbacks to be used internally */
2164- void cardInfoCallback(const pa_card_info *card);
2165- void sinkInfoCallback(const pa_sink_info *sink);
2166- void sourceInfoCallback(const pa_source_info *source);
2167- void serverInfoCallback(const pa_server_info *server);
2168- void plugCardCallback(const pa_card_info *card);
2169- void updateCardCallback(const pa_card_info *card);
2170- void unplugCardCallback();
2171-
2172-Q_SIGNALS:
2173- void audioModeChanged(const AudioMode mode);
2174- void availableAudioModesChanged(const AudioModes modes);
2175-
2176-public Q_SLOTS:
2177- void handleCardEvent(const int evt, const unsigned int idx);
2178- void setCallMode(CallStatus callstatus, AudioMode audiomode);
2179- void setMicMute(bool muted); /* True if muted, false if unmuted */
2180-
2181-private:
2182- pa_mainloop_api *m_mainLoopApi;
2183- pa_threaded_mainloop *m_mainLoop;
2184- pa_context *m_context;
2185-
2186- AudioModes m_availableAudioModes;
2187- CallStatus m_callstatus;
2188- AudioMode m_audiomode;
2189- AudioMode m_audiomodetoset;
2190- bool m_micmute, m_handleevent;
2191- std::string m_nametoset, m_valuetoset;
2192- std::string m_defaultsink, m_defaultsource;
2193- std::string m_bt_hsp, m_bt_hsp_a2dp;
2194- std::string m_voicecallcard, m_voicecallhighest, m_voicecallprofile;
2195-
2196- bool handleOperation(pa_operation *operation, const char *func_name);
2197- void releasePulseContext(void);
2198-};
2199-
2200-class QPulseAudioEngine : public QObject
2201-{
2202- Q_OBJECT
2203-public:
2204- explicit QPulseAudioEngine(QObject *parent = 0);
2205- ~QPulseAudioEngine();
2206- static QPulseAudioEngine *instance();
2207-
2208- void setCallMode(CallStatus callstatus, AudioMode audiomode);
2209- void setMicMute(bool muted); /* True if muted, false if unmuted */
2210-
2211-Q_SIGNALS:
2212- void audioModeChanged(const AudioMode mode);
2213- void availableAudioModesChanged(const AudioModes modes);
2214-private:
2215- QPulseAudioEngineWorker *mWorker;
2216- QThread mThread;
2217-};
2218-
2219-QT_END_NAMESPACE
2220-
2221-#endif

Subscribers

People subscribed via source and target branches

to all changes: