Merge lp:~tiagosh/telepathy-ofono/remove-audio-routing into lp:telepathy-ofono

Proposed by Tiago Salem Herrmann on 2016-01-15
Status: Needs review
Proposed branch: lp:~tiagosh/telepathy-ofono/remove-audio-routing
Merge into: lp:telepathy-ofono
Diff against target: 2220 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:~tiagosh/telepathy-ofono/remove-audio-routing
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Approve on 2016-06-14
PS Jenkins bot continuous-integration Approve on 2016-01-15
Ubuntu Phablet Team 2016-01-15 Pending
Review via email: mp+282794@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.

PASSED: Continuous integration, rev:171
https://jenkins.canonical.com/system-apps/job/lp-telepathy-ofono-ci/2/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/573
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/66
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/573
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/556
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial/556
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/550
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/550/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial/550
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial/550/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/550
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/550/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial/550
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial/550/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/550
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/550/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial/550
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial/550/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)

Unmerged revisions

171. By Tiago Salem Herrmann on 2016-01-15

Remove audio routing/proximity sensor management from telepathy-ofono

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

Subscribers

People subscribed via source and target branches