Merge lp:~phablet-team/telepathy-ofono/remove_audio_routing into lp:telepathy-ofono/staging
- remove_audio_routing
- Merge into staging
Proposed by
Gustavo Pichorim Boiko
Status: | Merged |
---|---|
Approved by: | Renato Araujo Oliveira Filho |
Approved revision: | 179 |
Merged at revision: | 184 |
Proposed branch: | lp:~phablet-team/telepathy-ofono/remove_audio_routing |
Merge into: | lp:telepathy-ofono/staging |
Diff against target: |
2235 lines (+9/-1798) 21 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/changelog (+6/-0) 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:~phablet-team/telepathy-ofono/remove_audio_routing |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Renato Araujo Oliveira Filho (community) | Approve | ||
Review via email: mp+316371@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
Renato Araujo Oliveira Filho (renatofilho) wrote : | # |
review:
Approve
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-02-03 19:47:54 +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-02-03 19:47:54 +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-02-03 19:47:54 +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-02-03 19:47:54 +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/changelog' |
712 | --- debian/changelog 2016-09-09 14:10:28 +0000 |
713 | +++ debian/changelog 2017-02-03 19:47:54 +0000 |
714 | @@ -1,3 +1,9 @@ |
715 | +telepathy-ofono (0.2+17.04.20161109-0ubuntu1) zesty; urgency=medium |
716 | + |
717 | + * Group chat fixes. |
718 | + |
719 | + -- Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> Wed, 09 Nov 2016 19:54:03 +0000 |
720 | + |
721 | telepathy-ofono (0.2+16.10.20160909-0ubuntu1) yakkety; urgency=medium |
722 | |
723 | * No change rebuild for libphonenumber7 |
724 | |
725 | === modified file 'debian/control' |
726 | --- debian/control 2016-07-19 11:20:42 +0000 |
727 | +++ debian/control 2017-02-03 19:47:54 +0000 |
728 | @@ -12,9 +12,7 @@ |
729 | libphonenumber-dev, |
730 | libqt5sql5-sqlite, |
731 | libtelepathy-qt5-dev (>= 0.9.3), |
732 | - libpulse-dev [armhf arm64], |
733 | libsqlite3-dev, |
734 | - pulseaudio, |
735 | qt5-default (>= 5.0), |
736 | qtbase5-dev (>= 5.0), |
737 | sqlite3, |
738 | |
739 | === modified file 'ofonocallchannel.cpp' |
740 | --- ofonocallchannel.cpp 2016-10-26 20:42:04 +0000 |
741 | +++ ofonocallchannel.cpp 2017-02-03 19:47:54 +0000 |
742 | @@ -17,9 +17,6 @@ |
743 | */ |
744 | |
745 | #include "ofonocallchannel.h" |
746 | -#ifdef USE_PULSEAUDIO |
747 | -#include "qpulseaudioengine.h" |
748 | -#endif |
749 | |
750 | |
751 | oFonoCallChannel::oFonoCallChannel(oFonoConnection *conn, QString phoneNumber, uint targetHandle, QString voiceObj, QObject *parent): |
752 | @@ -47,15 +44,11 @@ |
753 | mMuteIface = Tp::BaseCallMuteInterface::create(); |
754 | mMuteIface->setSetMuteStateCallback(Tp::memFun(this,&oFonoCallChannel::onMuteStateChanged)); |
755 | |
756 | - mAudioOutputsIface = BaseChannelAudioOutputsInterface::create(); |
757 | - mAudioOutputsIface->setSetActiveAudioOutputCallback(Tp::memFun(this,&oFonoCallChannel::onSetActiveAudioOutput)); |
758 | - |
759 | mSplittableIface = Tp::BaseChannelSplittableInterface::create(); |
760 | mSplittableIface->setSplitCallback(Tp::memFun(this,&oFonoCallChannel::onSplit)); |
761 | |
762 | baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mHoldIface)); |
763 | baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mMuteIface)); |
764 | - baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mAudioOutputsIface)); |
765 | baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mSplittableIface)); |
766 | |
767 | mBaseChannel = baseChannel; |
768 | @@ -68,13 +61,6 @@ |
769 | QObject::connect(this, SIGNAL(answerComplete(bool)), this, SLOT(onAnswerComplete(bool))); |
770 | // init must be called after initialization, otherwise we will have no object path registered. |
771 | QTimer::singleShot(0, this, SLOT(init())); |
772 | - |
773 | -#ifdef USE_PULSEAUDIO |
774 | - QByteArray pulseAudioDisabled = qgetenv("PA_DISABLED"); |
775 | - mHasPulseAudio = true; |
776 | - if (!pulseAudioDisabled.isEmpty()) |
777 | - mHasPulseAudio = false; |
778 | -#endif |
779 | } |
780 | |
781 | Tp::CallState oFonoCallChannel::callState() |
782 | @@ -87,21 +73,6 @@ |
783 | mConnection->voiceCallManager()->privateChat(path()); |
784 | } |
785 | |
786 | -void oFonoCallChannel::onSetActiveAudioOutput(const QString &id, Tp::DBusError *error) |
787 | -{ |
788 | -#ifdef USE_PULSEAUDIO |
789 | - // fallback to earpiece/headset |
790 | - AudioMode mode = AudioModeWiredOrEarpiece; |
791 | - if (id == "bluetooth") { |
792 | - mode = AudioModeBluetooth; |
793 | - } else if (id == "speaker") { |
794 | - mode = AudioModeSpeaker; |
795 | - } |
796 | - if (mHasPulseAudio) |
797 | - QPulseAudioEngine::instance()->setCallMode(CallActive, mode); |
798 | -#endif |
799 | -} |
800 | - |
801 | void oFonoCallChannel::onHangupComplete(bool status) |
802 | { |
803 | if (!status) { |
804 | @@ -180,15 +151,10 @@ |
805 | QObject::connect(mBaseChannel.data(), SIGNAL(closed()), this, SLOT(deleteLater())); |
806 | QObject::connect(mConnection->callVolume(), SIGNAL(mutedChanged(bool)), SLOT(onOfonoMuteChanged(bool))); |
807 | QObject::connect(this, SIGNAL(stateChanged(QString)), SLOT(onOfonoCallStateChanged(QString))); |
808 | - QObject::connect(mConnection, SIGNAL(activeAudioOutputChanged(QString)), mAudioOutputsIface.data(), SLOT(setActiveAudioOutput(QString))); |
809 | - QObject::connect(mConnection, SIGNAL(audioOutputsChanged(AudioOutputList)), mAudioOutputsIface.data(), SLOT(setAudioOutputs(AudioOutputList))); |
810 | QObject::connect(mConnection->voiceCallManager(), SIGNAL(sendTonesComplete(bool)), SLOT(onDtmfComplete(bool))); |
811 | QObject::connect(this, SIGNAL(multipartyChanged(bool)), this, SLOT(onMultipartyChanged(bool))); |
812 | |
813 | QObject::connect(this, SIGNAL(disconnectReason(const QString &)), this, SLOT(onDisconnectReason(const QString &))); |
814 | - |
815 | - mAudioOutputsIface->setAudioOutputs(mConnection->audioOutputs()); |
816 | - mAudioOutputsIface->setActiveAudioOutput(mConnection->activeAudioOutput()); |
817 | } |
818 | |
819 | void oFonoCallChannel::onDisconnectReason(const QString &reason) { |
820 | @@ -241,16 +207,8 @@ |
821 | { |
822 | if (state == Tp::LocalMuteStateMuted) { |
823 | mConnection->callVolume()->setMuted(true); |
824 | -#ifdef USE_PULSEAUDIO |
825 | - if (mHasPulseAudio) |
826 | - QPulseAudioEngine::instance()->setMicMute(true); |
827 | -#endif |
828 | } else if (state == Tp::LocalMuteStateUnmuted) { |
829 | mConnection->callVolume()->setMuted(false); |
830 | -#ifdef USE_PULSEAUDIO |
831 | - if (mHasPulseAudio) |
832 | - QPulseAudioEngine::instance()->setMicMute(false); |
833 | -#endif |
834 | } |
835 | } |
836 | |
837 | @@ -351,9 +309,6 @@ |
838 | if (mMultiparty) { |
839 | Q_EMIT multipartyCallActive(); |
840 | } |
841 | - if (mPreviousState == "incoming") { |
842 | - mConnection->updateAudioRouteToEarpiece(); |
843 | - } |
844 | if (mPreviousState == "dialing" || mPreviousState == "alerting" || |
845 | mPreviousState == "incoming") { |
846 | mConnection->callVolume()->setMuted(false); |
847 | @@ -375,7 +330,5 @@ |
848 | } else if (state == "waiting") { |
849 | qDebug() << "waiting"; |
850 | } |
851 | - // always update the audio route when call state changes |
852 | - mConnection->updateAudioRoute(); |
853 | mPreviousState = state; |
854 | } |
855 | |
856 | === modified file 'ofonocallchannel.h' |
857 | --- ofonocallchannel.h 2015-02-17 17:03:42 +0000 |
858 | +++ ofonocallchannel.h 2017-02-03 19:47:54 +0000 |
859 | @@ -29,7 +29,6 @@ |
860 | #include <ofono-qt/ofonovoicecall.h> |
861 | |
862 | #include "connection.h" |
863 | -#include "audiooutputsiface.h" |
864 | |
865 | class oFonoConnection; |
866 | |
867 | @@ -47,7 +46,6 @@ |
868 | void onHoldStateChanged(const Tp::LocalHoldState &state, const Tp::LocalHoldStateReason &reason, Tp::DBusError *error); |
869 | void onDTMFStartTone(uchar event, Tp::DBusError *error); |
870 | void onDTMFStopTone(Tp::DBusError *error); |
871 | - void onSetActiveAudioOutput(const QString &id, Tp::DBusError *error); |
872 | void onSplit(Tp::DBusError *error); |
873 | Tp::CallState callState(); |
874 | |
875 | @@ -74,9 +72,6 @@ |
876 | private: |
877 | QString mObjPath; |
878 | QString mPreviousState; |
879 | -#ifdef USE_PULSEAUDIO |
880 | - bool mHasPulseAudio; |
881 | -#endif |
882 | bool mIncoming; |
883 | bool mRequestedHangup; |
884 | Tp::BaseChannelPtr mBaseChannel; |
885 | @@ -86,7 +81,6 @@ |
886 | Tp::BaseChannelHoldInterfacePtr mHoldIface; |
887 | Tp::BaseChannelSplittableInterfacePtr mSplittableIface; |
888 | Tp::BaseCallMuteInterfacePtr mMuteIface; |
889 | - BaseChannelAudioOutputsInterfacePtr mAudioOutputsIface; |
890 | Tp::BaseChannelCallTypePtr mCallChannel; |
891 | Tp::BaseCallContentDTMFInterfacePtr mDTMFIface; |
892 | Tp::BaseCallContentPtr mCallContent; |
893 | |
894 | === modified file 'ofonoconferencecallchannel.cpp' |
895 | --- ofonoconferencecallchannel.cpp 2016-10-26 20:42:04 +0000 |
896 | +++ ofonoconferencecallchannel.cpp 2017-02-03 19:47:54 +0000 |
897 | @@ -17,9 +17,6 @@ |
898 | */ |
899 | |
900 | #include "ofonoconferencecallchannel.h" |
901 | -#ifdef USE_PULSEAUDIO |
902 | -#include "qpulseaudioengine.h" |
903 | -#endif |
904 | #include "ofonocallchannel.h" |
905 | |
906 | |
907 | @@ -50,9 +47,6 @@ |
908 | mMuteIface = Tp::BaseCallMuteInterface::create(); |
909 | mMuteIface->setSetMuteStateCallback(Tp::memFun(this,&oFonoConferenceCallChannel::onMuteStateChanged)); |
910 | |
911 | - mAudioOutputsIface = BaseChannelAudioOutputsInterface::create(); |
912 | - mAudioOutputsIface->setSetActiveAudioOutputCallback(Tp::memFun(this,&oFonoConferenceCallChannel::onSetActiveAudioOutput)); |
913 | - |
914 | mConferenceIface = Tp::BaseChannelConferenceInterface::create(mCallChannels); |
915 | |
916 | mMergeableIface = Tp::BaseChannelMergeableConferenceInterface::create(); |
917 | @@ -60,7 +54,6 @@ |
918 | |
919 | baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mHoldIface)); |
920 | baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mMuteIface)); |
921 | - baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mAudioOutputsIface)); |
922 | baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mConferenceIface)); |
923 | baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mMergeableIface)); |
924 | |
925 | @@ -126,20 +119,6 @@ |
926 | } |
927 | } |
928 | |
929 | -void oFonoConferenceCallChannel::onSetActiveAudioOutput(const QString &id, Tp::DBusError *error) |
930 | -{ |
931 | -#ifdef USE_PULSEAUDIO |
932 | - // fallback to earpiece/headset |
933 | - AudioMode mode = AudioModeWiredOrEarpiece; |
934 | - if (id == "bluetooth") { |
935 | - mode = AudioModeBluetooth; |
936 | - } else if (id == "speaker") { |
937 | - mode = AudioModeSpeaker; |
938 | - } |
939 | - QPulseAudioEngine::instance()->setCallMode(CallActive, mode); |
940 | -#endif |
941 | -} |
942 | - |
943 | void oFonoConferenceCallChannel::onHangup(uint reason, const QString &detailedReason, const QString &message, Tp::DBusError *error) |
944 | { |
945 | // TODO: use the parameters sent by telepathy |
946 | @@ -174,13 +153,8 @@ |
947 | |
948 | QObject::connect(mBaseChannel.data(), SIGNAL(closed()), this, SLOT(deleteLater())); |
949 | QObject::connect(mConnection->callVolume(), SIGNAL(mutedChanged(bool)), SLOT(onOfonoMuteChanged(bool))); |
950 | - QObject::connect(mConnection, SIGNAL(activeAudioOutputChanged(QString)), mAudioOutputsIface.data(), SLOT(setActiveAudioOutput(QString))); |
951 | - QObject::connect(mConnection, SIGNAL(audioOutputsChanged(AudioOutputList)), mAudioOutputsIface.data(), SLOT(setAudioOutputs(AudioOutputList))); |
952 | QObject::connect(mConnection->voiceCallManager(), SIGNAL(sendTonesComplete(bool)), SLOT(onDtmfComplete(bool))); |
953 | |
954 | - mAudioOutputsIface->setAudioOutputs(mConnection->audioOutputs()); |
955 | - mAudioOutputsIface->setActiveAudioOutput(mConnection->activeAudioOutput()); |
956 | - |
957 | QObject::connect(mConnection, SIGNAL(channelMerged(const QDBusObjectPath&)), this, SLOT(onChannelMerged(const QDBusObjectPath&))); |
958 | QObject::connect(mConnection, SIGNAL(channelSplitted(const QDBusObjectPath&)), this, SLOT(onChannelSplitted(const QDBusObjectPath&))); |
959 | QObject::connect(mConnection, SIGNAL(channelHangup(const QDBusObjectPath&)), this, SLOT(onChannelSplitted(const QDBusObjectPath&))); |
960 | @@ -228,14 +202,8 @@ |
961 | { |
962 | if (state == Tp::LocalMuteStateMuted) { |
963 | mConnection->callVolume()->setMuted(true); |
964 | -#ifdef USE_PULSEAUDIO |
965 | - QPulseAudioEngine::instance()->setMicMute(true); |
966 | -#endif |
967 | } else if (state == Tp::LocalMuteStateUnmuted) { |
968 | mConnection->callVolume()->setMuted(false); |
969 | -#ifdef USE_PULSEAUDIO |
970 | - QPulseAudioEngine::instance()->setMicMute(false); |
971 | -#endif |
972 | } |
973 | } |
974 | |
975 | |
976 | === modified file 'ofonoconferencecallchannel.h' |
977 | --- ofonoconferencecallchannel.h 2015-01-26 18:52:02 +0000 |
978 | +++ ofonoconferencecallchannel.h 2017-02-03 19:47:54 +0000 |
979 | @@ -29,7 +29,6 @@ |
980 | #include <ofono-qt/ofonovoicecall.h> |
981 | |
982 | #include "connection.h" |
983 | -#include "audiooutputsiface.h" |
984 | |
985 | class oFonoConnection; |
986 | |
987 | @@ -45,7 +44,6 @@ |
988 | void onHoldStateChanged(const Tp::LocalHoldState &state, const Tp::LocalHoldStateReason &reason, Tp::DBusError *error); |
989 | void onDTMFStartTone(uchar event, Tp::DBusError *error); |
990 | void onDTMFStopTone(Tp::DBusError *error); |
991 | - void onSetActiveAudioOutput(const QString &id, Tp::DBusError *error); |
992 | void onMerge(const QDBusObjectPath &channel, Tp::DBusError *error); |
993 | Tp::BaseChannelPtr baseChannel(); |
994 | void setConferenceActive(bool active); |
995 | @@ -72,7 +70,6 @@ |
996 | Tp::BaseChannelConferenceInterfacePtr mConferenceIface; |
997 | Tp::BaseChannelMergeableConferenceInterfacePtr mMergeableIface; |
998 | Tp::BaseCallMuteInterfacePtr mMuteIface; |
999 | - BaseChannelAudioOutputsInterfacePtr mAudioOutputsIface; |
1000 | Tp::BaseChannelCallTypePtr mCallChannel; |
1001 | Tp::BaseCallContentDTMFInterfacePtr mDTMFIface; |
1002 | Tp::BaseCallContentPtr mCallContent; |
1003 | |
1004 | === removed file 'powerd.h' |
1005 | --- powerd.h 2014-09-30 17:25:02 +0000 |
1006 | +++ powerd.h 1970-01-01 00:00:00 +0000 |
1007 | @@ -1,34 +0,0 @@ |
1008 | -/** |
1009 | - * Copyright (C) 2014 Canonical, Ltd. |
1010 | - * |
1011 | - * This program is free software: you can redistribute it and/or modify it under |
1012 | - * the terms of the GNU Lesser General Public License version 3, as published by |
1013 | - * the Free Software Foundation. |
1014 | - * |
1015 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
1016 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1017 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1018 | - * Lesser General Public License for more details. |
1019 | - * |
1020 | - * You should have received a copy of the GNU Lesser General Public License |
1021 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1022 | - * |
1023 | - * Authors: Andreas Pokorny <andreas.pokorny@canonical.com> |
1024 | - */ |
1025 | - |
1026 | -#ifndef POWERD_H |
1027 | -#define POWERD_H |
1028 | - |
1029 | -class PowerD |
1030 | -{ |
1031 | -public: |
1032 | - PowerD() = default; |
1033 | - virtual ~PowerD() = default; |
1034 | - PowerD(PowerD const&) = delete; |
1035 | - PowerD& operator=(PowerD const&) = delete; |
1036 | - |
1037 | - virtual void enableProximityHandling() = 0; |
1038 | - virtual void disableProximityHandling() = 0; |
1039 | -}; |
1040 | - |
1041 | -#endif // POWERD_H |
1042 | |
1043 | === removed file 'powerdaudiomodemediator.cpp' |
1044 | --- powerdaudiomodemediator.cpp 2014-12-15 19:45:19 +0000 |
1045 | +++ powerdaudiomodemediator.cpp 1970-01-01 00:00:00 +0000 |
1046 | @@ -1,63 +0,0 @@ |
1047 | -/** |
1048 | - * Copyright (C) 2014 Canonical, Ltd. |
1049 | - * |
1050 | - * This program is free software: you can redistribute it and/or modify it under |
1051 | - * the terms of the GNU Lesser General Public License version 3, as published by |
1052 | - * the Free Software Foundation. |
1053 | - * |
1054 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
1055 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1056 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1057 | - * Lesser General Public License for more details. |
1058 | - * |
1059 | - * You should have received a copy of the GNU Lesser General Public License |
1060 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1061 | - * |
1062 | - * Authors: Andreas Pokorny <andreas.pokorny@canonical.com> |
1063 | - */ |
1064 | - |
1065 | -#include <QDBusInterface> |
1066 | -#include "powerdaudiomodemediator.h" |
1067 | - |
1068 | -PowerDAudioModeMediator::PowerDAudioModeMediator(PowerD &powerd) |
1069 | - : powerd(powerd) |
1070 | -{ |
1071 | -} |
1072 | - |
1073 | -void PowerDAudioModeMediator::audioModeChanged(const QString &mode) |
1074 | -{ |
1075 | - bool enableProximity = !(mode == "speaker" || mode == "bluetooth" || mode == "wired_headset"); |
1076 | - |
1077 | - if (mProximityEnabled != enableProximity) |
1078 | - { |
1079 | - mProximityEnabled = enableProximity; |
1080 | - apply(); |
1081 | - } |
1082 | -} |
1083 | - |
1084 | -void PowerDAudioModeMediator::apply() const |
1085 | -{ |
1086 | - if (mProximityEnabled) { |
1087 | - powerd.enableProximityHandling(); |
1088 | - } else { |
1089 | - // we need to power the screen on before disabling the proximity handling |
1090 | - QDBusInterface unityIface("com.canonical.Unity.Screen", |
1091 | - "/com/canonical/Unity/Screen", |
1092 | - "com.canonical.Unity.Screen", |
1093 | - QDBusConnection::systemBus()); |
1094 | - QList<QVariant> args; |
1095 | - args.append("on"); |
1096 | - args.append(3); |
1097 | - unityIface.callWithArgumentList(QDBus::NoBlock, "setScreenPowerMode", args); |
1098 | - powerd.disableProximityHandling(); |
1099 | - } |
1100 | -} |
1101 | - |
1102 | -void PowerDAudioModeMediator::audioOutputClosed() |
1103 | -{ |
1104 | - if (mProximityEnabled) |
1105 | - { |
1106 | - mProximityEnabled = false; |
1107 | - apply(); |
1108 | - } |
1109 | -} |
1110 | |
1111 | === removed file 'powerdaudiomodemediator.h' |
1112 | --- powerdaudiomodemediator.h 2014-09-30 17:25:02 +0000 |
1113 | +++ powerdaudiomodemediator.h 1970-01-01 00:00:00 +0000 |
1114 | @@ -1,46 +0,0 @@ |
1115 | -/**************************************************************************** |
1116 | -** |
1117 | -** Copyright (C) 2014 Canonical, Ltd. |
1118 | -** |
1119 | -** Authors: |
1120 | -** Andreas Pokorny <andreas.pokorny@canonical.com> |
1121 | -** |
1122 | -** GNU Lesser General Public License Usage |
1123 | -** Alternatively, this file may be used under the terms of the GNU Lesser |
1124 | -** General Public License version 2.1 as published by the Free Software |
1125 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
1126 | -** packaging of this file. Please review the following information to |
1127 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
1128 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
1129 | -** |
1130 | -****************************************************************************/ |
1131 | - |
1132 | -#ifndef POWERDAUDIOMODEMEDIATOR_H |
1133 | -#define POWERDAUDIOMODEMEDIATOR_H |
1134 | - |
1135 | -#include "powerd.h" |
1136 | - |
1137 | -#include <QString> |
1138 | -#include <fstream> |
1139 | -#include <memory> |
1140 | - |
1141 | -class PowerD; |
1142 | -/*! |
1143 | - * \brief PowerDAudioModeMediator is responsible for configuring proximity |
1144 | - * handling of powerd during different call states and used audio outputs. |
1145 | - * In General that mean enabling sreen blanking on proximity events, when |
1146 | - * a call is active and neither a bluetooth headset nor the speakers are used. |
1147 | - */ |
1148 | -class PowerDAudioModeMediator |
1149 | -{ |
1150 | -public: |
1151 | - PowerDAudioModeMediator(PowerD &powerd); |
1152 | - void audioModeChanged(const QString &mode); |
1153 | - void audioOutputClosed(); |
1154 | -private: |
1155 | - void apply() const; |
1156 | - PowerD &powerd; |
1157 | - bool mProximityEnabled{false}; |
1158 | -}; |
1159 | - |
1160 | -#endif |
1161 | |
1162 | === removed file 'powerddbus.cpp' |
1163 | --- powerddbus.cpp 2014-09-30 17:25:02 +0000 |
1164 | +++ powerddbus.cpp 1970-01-01 00:00:00 +0000 |
1165 | @@ -1,43 +0,0 @@ |
1166 | -/** |
1167 | - * Copyright (C) 2014 Canonical, Ltd. |
1168 | - * |
1169 | - * This program is free software: you can redistribute it and/or modify it under |
1170 | - * the terms of the GNU Lesser General Public License version 3, as published by |
1171 | - * the Free Software Foundation. |
1172 | - * |
1173 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
1174 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1175 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1176 | - * Lesser General Public License for more details. |
1177 | - * |
1178 | - * You should have received a copy of the GNU Lesser General Public License |
1179 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1180 | - * |
1181 | - * Authors: Andreas Pokorny <andreas.pokorny@canonical.com> |
1182 | - */ |
1183 | - |
1184 | -#include "powerddbus.h" |
1185 | - |
1186 | -#include <QDBusConnection> |
1187 | -#include <QDBusInterface> |
1188 | -#include <QDBusReply> |
1189 | - |
1190 | -PowerDDBus::PowerDDBus() |
1191 | - : mPowerDIface{ |
1192 | - new QDBusInterface( |
1193 | - "com.canonical.powerd", |
1194 | - "/com/canonical/powerd", |
1195 | - "com.canonical.powerd", |
1196 | - QDBusConnection::systemBus())} |
1197 | -{ |
1198 | -} |
1199 | - |
1200 | -void PowerDDBus::enableProximityHandling() |
1201 | -{ |
1202 | - mPowerDIface->call("enableProximityHandling", "telepathy-ofono"); |
1203 | -} |
1204 | - |
1205 | -void PowerDDBus::disableProximityHandling() |
1206 | -{ |
1207 | - mPowerDIface->call("disableProximityHandling", "telepathy-ofono"); |
1208 | -} |
1209 | |
1210 | === removed file 'powerddbus.h' |
1211 | --- powerddbus.h 2014-09-30 17:25:02 +0000 |
1212 | +++ powerddbus.h 1970-01-01 00:00:00 +0000 |
1213 | @@ -1,38 +0,0 @@ |
1214 | -/** |
1215 | - * Copyright (C) 2014 Canonical, Ltd. |
1216 | - * |
1217 | - * This program is free software: you can redistribute it and/or modify it under |
1218 | - * the terms of the GNU Lesser General Public License version 3, as published by |
1219 | - * the Free Software Foundation. |
1220 | - * |
1221 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
1222 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1223 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1224 | - * Lesser General Public License for more details. |
1225 | - * |
1226 | - * You should have received a copy of the GNU Lesser General Public License |
1227 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1228 | - * |
1229 | - * Authors: Andreas Pokorny <andreas.pokorny@canonical.com> |
1230 | - */ |
1231 | - |
1232 | -#ifndef POWERD_DUBS_H |
1233 | -#define POWERD_DBUS_H |
1234 | - |
1235 | -#include "powerd.h" |
1236 | - |
1237 | -#include <memory> |
1238 | - |
1239 | -class QDBusInterface; |
1240 | - |
1241 | -class PowerDDBus : public PowerD |
1242 | -{ |
1243 | -public: |
1244 | - PowerDDBus(); |
1245 | - void enableProximityHandling() override; |
1246 | - void disableProximityHandling() override; |
1247 | -private: |
1248 | - std::unique_ptr<QDBusInterface> mPowerDIface; |
1249 | -}; |
1250 | - |
1251 | -#endif |
1252 | |
1253 | === modified file 'protocol.cpp' |
1254 | --- protocol.cpp 2015-08-18 21:36:52 +0000 |
1255 | +++ protocol.cpp 2017-02-03 19:47:54 +0000 |
1256 | @@ -24,7 +24,7 @@ |
1257 | #include <TelepathyQt/ProtocolParameterList> |
1258 | |
1259 | Protocol::Protocol(const QDBusConnection &dbusConnection, const QString &name) |
1260 | - : Tp::BaseProtocol(dbusConnection, name), mAudioModeMediator(mPowerDDBus) |
1261 | + : Tp::BaseProtocol(dbusConnection, name) |
1262 | { |
1263 | |
1264 | addressingIface = Tp::BaseProtocolAddressingInterface::create(); |
1265 | @@ -48,13 +48,5 @@ |
1266 | Tp::BaseConnectionPtr Protocol::createConnection(const QVariantMap ¶meters, Tp::DBusError *error) { |
1267 | Q_UNUSED(error); |
1268 | Tp::BaseConnectionPtr connection_ptr = Tp::BaseConnection::create<oFonoConnection>("ofono", name().toLatin1(), parameters); |
1269 | - connect( |
1270 | - static_cast<oFonoConnection*>(connection_ptr.data()), &oFonoConnection::activeAudioOutputChanged, |
1271 | - Tp::memFun(&mAudioModeMediator, &PowerDAudioModeMediator::audioModeChanged) |
1272 | - ); |
1273 | - connect( |
1274 | - static_cast<oFonoConnection*>(connection_ptr.data()), &oFonoConnection::lastChannelClosed, |
1275 | - Tp::memFun(&mAudioModeMediator, &PowerDAudioModeMediator::audioOutputClosed) |
1276 | - ); |
1277 | return connection_ptr; |
1278 | } |
1279 | |
1280 | === modified file 'protocol.h' |
1281 | --- protocol.h 2015-08-18 21:36:52 +0000 |
1282 | +++ protocol.h 2017-02-03 19:47:54 +0000 |
1283 | @@ -24,9 +24,6 @@ |
1284 | |
1285 | #include <TelepathyQt/BaseProtocol> |
1286 | |
1287 | -#include "powerdaudiomodemediator.h" |
1288 | -#include "powerddbus.h" |
1289 | - |
1290 | class Protocol : public Tp::BaseProtocol |
1291 | { |
1292 | Q_OBJECT |
1293 | @@ -38,8 +35,6 @@ |
1294 | private: |
1295 | Tp::BaseConnectionPtr createConnection(const QVariantMap ¶meters, Tp::DBusError *error); |
1296 | Tp::BaseProtocolAddressingInterfacePtr addressingIface; |
1297 | - PowerDDBus mPowerDDBus; |
1298 | - PowerDAudioModeMediator mAudioModeMediator; |
1299 | }; |
1300 | |
1301 | #endif |
1302 | |
1303 | === removed file 'qpulseaudioengine.cpp' |
1304 | --- qpulseaudioengine.cpp 2015-11-10 07:49:07 +0000 |
1305 | +++ qpulseaudioengine.cpp 1970-01-01 00:00:00 +0000 |
1306 | @@ -1,800 +0,0 @@ |
1307 | -/**************************************************************************** |
1308 | -** |
1309 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
1310 | -** Contact: http://www.qt-project.org/legal |
1311 | -** |
1312 | -** This file was taken from qt5 and modified by |
1313 | -** David Henningsson <david.henningsson@canonical.com> for usage in |
1314 | -** telepathy-ofono. |
1315 | -** |
1316 | -** GNU Lesser General Public License Usage |
1317 | -** Alternatively, this file may be used under the terms of the GNU Lesser |
1318 | -** General Public License version 2.1 as published by the Free Software |
1319 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
1320 | -** packaging of this file. Please review the following information to |
1321 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
1322 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
1323 | -** |
1324 | -****************************************************************************/ |
1325 | - |
1326 | -#include <QtCore/qdebug.h> |
1327 | - |
1328 | -#include "qpulseaudioengine.h" |
1329 | -#include <sys/types.h> |
1330 | -#include <unistd.h> |
1331 | - |
1332 | -#define PULSEAUDIO_PROFILE_HSP "headset_head_unit" |
1333 | -#define PULSEAUDIO_PROFILE_A2DP "a2dp_sink" |
1334 | - |
1335 | -QT_BEGIN_NAMESPACE |
1336 | - |
1337 | -static void contextStateCallbackInit(pa_context *context, void *userdata) |
1338 | -{ |
1339 | - Q_UNUSED(context); |
1340 | - QPulseAudioEngineWorker *pulseEngine = reinterpret_cast<QPulseAudioEngineWorker*>(userdata); |
1341 | - pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0); |
1342 | -} |
1343 | - |
1344 | -static void contextStateCallback(pa_context *context, void *userdata) |
1345 | -{ |
1346 | - Q_UNUSED(userdata); |
1347 | - Q_UNUSED(context); |
1348 | -} |
1349 | - |
1350 | -static void success_cb(pa_context *context, int success, void *userdata) |
1351 | -{ |
1352 | - QPulseAudioEngineWorker *pulseEngine = reinterpret_cast<QPulseAudioEngineWorker*>(userdata); |
1353 | - pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0); |
1354 | -} |
1355 | - |
1356 | -/* Callbacks used when handling events from PulseAudio */ |
1357 | -static void plug_card_cb(pa_context *c, const pa_card_info *info, int isLast, void *userdata) |
1358 | -{ |
1359 | - QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata); |
1360 | - if (isLast != 0 || !pulseEngine || !info) { |
1361 | - pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0); |
1362 | - return; |
1363 | - } |
1364 | - pulseEngine->plugCardCallback(info); |
1365 | -} |
1366 | - |
1367 | -static void update_card_cb(pa_context *c, const pa_card_info *info, int isLast, void *userdata) |
1368 | -{ |
1369 | - QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata); |
1370 | - if (isLast != 0 || !pulseEngine || !info) { |
1371 | - pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0); |
1372 | - return; |
1373 | - } |
1374 | - pulseEngine->updateCardCallback(info); |
1375 | -} |
1376 | - |
1377 | -static void unplug_card_cb(pa_context *c, const pa_card_info *info, int isLast, void *userdata) |
1378 | -{ |
1379 | - QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata); |
1380 | - if (!pulseEngine) { |
1381 | - pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0); |
1382 | - return; |
1383 | - } |
1384 | - |
1385 | - if (info == NULL) { |
1386 | - /* That means that the card used to query card_info was removed */ |
1387 | - pulseEngine->unplugCardCallback(); |
1388 | - } |
1389 | -} |
1390 | - |
1391 | -static void subscribeCallback(pa_context *context, pa_subscription_event_type_t t, uint32_t idx, void *userdata) |
1392 | -{ |
1393 | - /* For card change events (slot plug/unplug and add/remove card) */ |
1394 | - if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_CARD) { |
1395 | - if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_CHANGE) { |
1396 | - QMetaObject::invokeMethod((QPulseAudioEngineWorker *) userdata, "handleCardEvent", |
1397 | - Qt::QueuedConnection, Q_ARG(int, PA_SUBSCRIPTION_EVENT_CHANGE), Q_ARG(unsigned int, idx)); |
1398 | - } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) { |
1399 | - QMetaObject::invokeMethod((QPulseAudioEngineWorker *) userdata, "handleCardEvent", |
1400 | - Qt::QueuedConnection, Q_ARG(int, PA_SUBSCRIPTION_EVENT_NEW), Q_ARG(unsigned int, idx)); |
1401 | - } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) { |
1402 | - QMetaObject::invokeMethod((QPulseAudioEngineWorker *) userdata, "handleCardEvent", |
1403 | - Qt::QueuedConnection, Q_ARG(int, PA_SUBSCRIPTION_EVENT_REMOVE), Q_ARG(unsigned int, idx)); |
1404 | - } |
1405 | - } |
1406 | -} |
1407 | - |
1408 | -QPulseAudioEngineWorker::QPulseAudioEngineWorker(QObject *parent) |
1409 | - : QObject(parent) |
1410 | - , m_mainLoopApi(0) |
1411 | - , m_context(0) |
1412 | - , m_callstatus(CallEnded) |
1413 | - , m_audiomode(AudioModeSpeaker) |
1414 | - , m_micmute(false) |
1415 | - , m_defaultsink("sink.primary") |
1416 | - , m_defaultsource("source.primary") |
1417 | - , m_voicecallcard("") |
1418 | - , m_voicecallhighest("") |
1419 | - , m_voicecallprofile("") |
1420 | - , m_bt_hsp("") |
1421 | - , m_bt_hsp_a2dp("") |
1422 | - |
1423 | -{ |
1424 | - m_mainLoop = pa_threaded_mainloop_new(); |
1425 | - if (m_mainLoop == 0) { |
1426 | - qWarning("Unable to create pulseaudio mainloop"); |
1427 | - return; |
1428 | - } |
1429 | - |
1430 | - if (pa_threaded_mainloop_start(m_mainLoop) != 0) { |
1431 | - qWarning("Unable to start pulseaudio mainloop"); |
1432 | - pa_threaded_mainloop_free(m_mainLoop); |
1433 | - m_mainLoop = 0; |
1434 | - return; |
1435 | - } |
1436 | - |
1437 | - createPulseContext(); |
1438 | -} |
1439 | - |
1440 | -bool QPulseAudioEngineWorker::createPulseContext() |
1441 | -{ |
1442 | - bool keepGoing = true; |
1443 | - bool ok = true; |
1444 | - |
1445 | - if (m_context) |
1446 | - return true; |
1447 | - |
1448 | - m_mainLoopApi = pa_threaded_mainloop_get_api(m_mainLoop); |
1449 | - |
1450 | - pa_threaded_mainloop_lock(m_mainLoop); |
1451 | - |
1452 | - m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtmPulseContext:%1")).arg(::getpid()).toLatin1().constData()); |
1453 | - pa_context_set_state_callback(m_context, contextStateCallbackInit, this); |
1454 | - |
1455 | - if (!m_context) { |
1456 | - qWarning("Unable to create new pulseaudio context"); |
1457 | - pa_threaded_mainloop_unlock(m_mainLoop); |
1458 | - return false; |
1459 | - } |
1460 | - |
1461 | - if (pa_context_connect(m_context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) < 0) { |
1462 | - qWarning("Unable to create a connection to the pulseaudio context"); |
1463 | - pa_threaded_mainloop_unlock(m_mainLoop); |
1464 | - releasePulseContext(); |
1465 | - return false; |
1466 | - } |
1467 | - |
1468 | - pa_threaded_mainloop_wait(m_mainLoop); |
1469 | - |
1470 | - while (keepGoing) { |
1471 | - switch (pa_context_get_state(m_context)) { |
1472 | - case PA_CONTEXT_CONNECTING: |
1473 | - case PA_CONTEXT_AUTHORIZING: |
1474 | - case PA_CONTEXT_SETTING_NAME: |
1475 | - break; |
1476 | - |
1477 | - case PA_CONTEXT_READY: |
1478 | - qDebug("Pulseaudio connection established."); |
1479 | - keepGoing = false; |
1480 | - break; |
1481 | - |
1482 | - case PA_CONTEXT_TERMINATED: |
1483 | - qCritical("Pulseaudio context terminated."); |
1484 | - keepGoing = false; |
1485 | - ok = false; |
1486 | - break; |
1487 | - |
1488 | - case PA_CONTEXT_FAILED: |
1489 | - default: |
1490 | - qCritical() << QString("Pulseaudio connection failure: %1").arg(pa_strerror(pa_context_errno(m_context))); |
1491 | - keepGoing = false; |
1492 | - ok = false; |
1493 | - } |
1494 | - |
1495 | - if (keepGoing) { |
1496 | - pa_threaded_mainloop_wait(m_mainLoop); |
1497 | - } |
1498 | - } |
1499 | - |
1500 | - if (ok) { |
1501 | - pa_context_set_state_callback(m_context, contextStateCallback, this); |
1502 | - pa_context_set_subscribe_callback(m_context, subscribeCallback, this); |
1503 | - pa_context_subscribe(m_context, PA_SUBSCRIPTION_MASK_CARD, NULL, this); |
1504 | - } else { |
1505 | - if (m_context) { |
1506 | - pa_context_unref(m_context); |
1507 | - m_context = 0; |
1508 | - } |
1509 | - } |
1510 | - |
1511 | - pa_threaded_mainloop_unlock(m_mainLoop); |
1512 | - return true; |
1513 | -} |
1514 | - |
1515 | - |
1516 | -void QPulseAudioEngineWorker::releasePulseContext() |
1517 | -{ |
1518 | - if (m_context) { |
1519 | - pa_threaded_mainloop_lock(m_mainLoop); |
1520 | - pa_context_disconnect(m_context); |
1521 | - pa_context_unref(m_context); |
1522 | - pa_threaded_mainloop_unlock(m_mainLoop); |
1523 | - m_context = 0; |
1524 | - } |
1525 | - |
1526 | -} |
1527 | - |
1528 | -QPulseAudioEngineWorker::~QPulseAudioEngineWorker() |
1529 | -{ |
1530 | - releasePulseContext(); |
1531 | - |
1532 | - if (m_mainLoop) { |
1533 | - pa_threaded_mainloop_stop(m_mainLoop); |
1534 | - pa_threaded_mainloop_free(m_mainLoop); |
1535 | - m_mainLoop = 0; |
1536 | - } |
1537 | -} |
1538 | - |
1539 | -void QPulseAudioEngineWorker::cardInfoCallback(const pa_card_info *info) |
1540 | -{ |
1541 | - pa_card_profile_info2 *voice_call = NULL, *highest = NULL; |
1542 | - pa_card_profile_info2 *hsp = NULL, *a2dp = NULL; |
1543 | - |
1544 | - /* For now we only support one card with the voicecall feature */ |
1545 | - for (int i = 0; i < info->n_profiles; i++) { |
1546 | - if (!highest || info->profiles2[i]->priority > highest->priority) |
1547 | - highest = info->profiles2[i]; |
1548 | - if (!strcmp(info->profiles2[i]->name, "voicecall")) |
1549 | - voice_call = info->profiles2[i]; |
1550 | - else if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_HSP) && |
1551 | - info->profiles2[i]->available != 0) |
1552 | - hsp = info->profiles2[i]; |
1553 | - else if (!strcmp(info->profiles2[i]->name, PULSEAUDIO_PROFILE_A2DP) && |
1554 | - info->profiles2[i]->available != 0) |
1555 | - a2dp = info->profiles2[i]; |
1556 | - } |
1557 | - |
1558 | - /* Record the card that supports voicecall (default one to be used) */ |
1559 | - if (voice_call) { |
1560 | - qDebug("Found card that supports voicecall: '%s'", info->name); |
1561 | - m_voicecallcard = info->name; |
1562 | - m_voicecallhighest = highest->name; |
1563 | - m_voicecallprofile = voice_call->name; |
1564 | - } |
1565 | - |
1566 | - /* Handle the use cases needed for bluetooth */ |
1567 | - if (hsp && a2dp) { |
1568 | - qDebug("Found card that supports hsp and a2dp: '%s'", info->name); |
1569 | - m_bt_hsp_a2dp = info->name; |
1570 | - } else if (hsp && (a2dp == NULL)) { |
1571 | - /* This card only provides the hsp profile */ |
1572 | - qDebug("Found card that supports only hsp: '%s'", info->name); |
1573 | - m_bt_hsp = info->name; |
1574 | - } |
1575 | -} |
1576 | - |
1577 | -void QPulseAudioEngineWorker::sinkInfoCallback(const pa_sink_info *info) |
1578 | -{ |
1579 | - pa_sink_port_info *earpiece = NULL, *speaker = NULL; |
1580 | - pa_sink_port_info *wired_headset = NULL, *wired_headphone = NULL; |
1581 | - pa_sink_port_info *preferred = NULL; |
1582 | - pa_sink_port_info *bluetooth_sco = NULL; |
1583 | - pa_sink_port_info *speaker_and_wired_headphone = NULL; |
1584 | - AudioMode audiomodetoset; |
1585 | - AudioModes modes; |
1586 | - |
1587 | - for (int i = 0; i < info->n_ports; i++) { |
1588 | - if (!strcmp(info->ports[i]->name, "output-earpiece")) |
1589 | - earpiece = info->ports[i]; |
1590 | - else if (!strcmp(info->ports[i]->name, "output-wired_headset") && |
1591 | - (info->ports[i]->available != PA_PORT_AVAILABLE_NO)) |
1592 | - wired_headset = info->ports[i]; |
1593 | - else if (!strcmp(info->ports[i]->name, "output-wired_headphone") && |
1594 | - (info->ports[i]->available != PA_PORT_AVAILABLE_NO)) |
1595 | - wired_headphone = info->ports[i]; |
1596 | - else if (!strcmp(info->ports[i]->name, "output-speaker")) |
1597 | - speaker = info->ports[i]; |
1598 | - else if (!strcmp(info->ports[i]->name, "output-bluetooth_sco")) |
1599 | - bluetooth_sco = info->ports[i]; |
1600 | - else if (!strcmp(info->ports[i]->name, "output-speaker+wired_headphone")) |
1601 | - speaker_and_wired_headphone = info->ports[i]; |
1602 | - } |
1603 | - |
1604 | - if (!earpiece || !speaker) |
1605 | - return; /* Not the right sink */ |
1606 | - |
1607 | - /* Refresh list of available audio modes */ |
1608 | - modes.append(AudioModeEarpiece); |
1609 | - modes.append(AudioModeSpeaker); |
1610 | - if (wired_headset || wired_headphone) |
1611 | - modes.append(AudioModeWiredHeadset); |
1612 | - if (bluetooth_sco && ((m_bt_hsp != "") || (m_bt_hsp_a2dp != ""))) |
1613 | - modes.append(AudioModeBluetooth); |
1614 | - |
1615 | - /* Check if the requested mode is available (earpiece*/ |
1616 | - if (((m_audiomode == AudioModeWiredHeadset) && !modes.contains(AudioModeWiredHeadset)) || |
1617 | - ((m_audiomode == AudioModeBluetooth) && !modes.contains(AudioModeBluetooth))) |
1618 | - return; |
1619 | - |
1620 | - /* Now to decide which output to be used, depending on the active mode */ |
1621 | - if (m_audiomode & AudioModeEarpiece) { |
1622 | - preferred = earpiece; |
1623 | - audiomodetoset = AudioModeEarpiece; |
1624 | - } |
1625 | - if (m_audiomode & AudioModeSpeaker) { |
1626 | - preferred = speaker; |
1627 | - audiomodetoset = AudioModeSpeaker; |
1628 | - } |
1629 | - if ((m_audiomode & AudioModeWiredHeadset) && (modes.contains(AudioModeWiredHeadset))) { |
1630 | - preferred = wired_headset ? wired_headset : wired_headphone; |
1631 | - audiomodetoset = AudioModeWiredHeadset; |
1632 | - } |
1633 | - if (m_callstatus == CallRinging && speaker_and_wired_headphone) { |
1634 | - preferred = speaker_and_wired_headphone; |
1635 | - } |
1636 | - if ((m_audiomode & AudioModeBluetooth) && (modes.contains(AudioModeBluetooth))) { |
1637 | - preferred = bluetooth_sco; |
1638 | - audiomodetoset = AudioModeBluetooth; |
1639 | - } |
1640 | - |
1641 | - m_audiomode = audiomodetoset; |
1642 | - |
1643 | - m_nametoset = info->name; |
1644 | - if (info->active_port != preferred) |
1645 | - m_valuetoset = preferred->name; |
1646 | - |
1647 | - if (modes != m_availableAudioModes) |
1648 | - m_availableAudioModes = modes; |
1649 | -} |
1650 | - |
1651 | -void QPulseAudioEngineWorker::sourceInfoCallback(const pa_source_info *info) |
1652 | -{ |
1653 | - pa_source_port_info *builtin_mic = NULL, *preferred = NULL; |
1654 | - pa_source_port_info *wired_headset = NULL, *bluetooth_sco = NULL; |
1655 | - |
1656 | - if (info->monitor_of_sink != PA_INVALID_INDEX) |
1657 | - return; /* Not the right source */ |
1658 | - |
1659 | - for (int i = 0; i < info->n_ports; i++) { |
1660 | - if (!strcmp(info->ports[i]->name, "input-builtin_mic")) |
1661 | - builtin_mic = info->ports[i]; |
1662 | - else if (!strcmp(info->ports[i]->name, "input-wired_headset") && |
1663 | - (info->ports[i]->available != PA_PORT_AVAILABLE_NO)) |
1664 | - wired_headset = info->ports[i]; |
1665 | - else if (!strcmp(info->ports[i]->name, "input-bluetooth_sco_headset")) |
1666 | - bluetooth_sco = info->ports[i]; |
1667 | - } |
1668 | - |
1669 | - if (!builtin_mic) |
1670 | - return; /* Not the right source */ |
1671 | - |
1672 | - /* Now to decide which output to be used, depending on the active mode */ |
1673 | - if ((m_audiomode & AudioModeEarpiece) || (m_audiomode & AudioModeSpeaker)) |
1674 | - preferred = builtin_mic; |
1675 | - if ((m_audiomode & AudioModeWiredHeadset) && (m_availableAudioModes.contains(AudioModeWiredHeadset))) |
1676 | - preferred = wired_headset ? wired_headset : builtin_mic; |
1677 | - if ((m_audiomode & AudioModeBluetooth) && (m_availableAudioModes.contains(AudioModeBluetooth))) |
1678 | - preferred = bluetooth_sco; |
1679 | - |
1680 | - m_nametoset = info->name; |
1681 | - if (info->active_port != preferred) |
1682 | - m_valuetoset = preferred->name; |
1683 | -} |
1684 | - |
1685 | -void QPulseAudioEngineWorker::serverInfoCallback(const pa_server_info *info) |
1686 | -{ |
1687 | - /* Saving default sink/source to restore after call hangup */ |
1688 | - m_defaultsink = info->default_sink_name; |
1689 | - m_defaultsource = info->default_source_name; |
1690 | - |
1691 | - /* In the case of a server callback we need to signal the mainloop */ |
1692 | - pa_threaded_mainloop_signal(mainloop(), 0); |
1693 | -} |
1694 | - |
1695 | -static void cardinfo_cb(pa_context *context, const pa_card_info *info, int isLast, void *userdata) |
1696 | -{ |
1697 | - QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata); |
1698 | - if (isLast != 0 || !pulseEngine || !info) { |
1699 | - pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0); |
1700 | - return; |
1701 | - } |
1702 | - pulseEngine->cardInfoCallback(info); |
1703 | -} |
1704 | - |
1705 | -static void sinkinfo_cb(pa_context *context, const pa_sink_info *info, int isLast, void *userdata) |
1706 | -{ |
1707 | - QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata); |
1708 | - if (isLast != 0 || !pulseEngine || !info) { |
1709 | - pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0); |
1710 | - return; |
1711 | - } |
1712 | - pulseEngine->sinkInfoCallback(info); |
1713 | -} |
1714 | - |
1715 | -static void sourceinfo_cb(pa_context *context, const pa_source_info *info, int isLast, void *userdata) |
1716 | -{ |
1717 | - QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata); |
1718 | - if (isLast != 0 || !pulseEngine || !info) { |
1719 | - pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0); |
1720 | - return; |
1721 | - } |
1722 | - pulseEngine->sourceInfoCallback(info); |
1723 | -} |
1724 | - |
1725 | -static void serverinfo_cb(pa_context *context, const pa_server_info *info, void *userdata) |
1726 | -{ |
1727 | - QPulseAudioEngineWorker *pulseEngine = static_cast<QPulseAudioEngineWorker*>(userdata); |
1728 | - if (!pulseEngine || !info) { |
1729 | - pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0); |
1730 | - return; |
1731 | - } |
1732 | - pulseEngine->serverInfoCallback(info); |
1733 | -} |
1734 | - |
1735 | -bool QPulseAudioEngineWorker::handleOperation(pa_operation *operation, const char *func_name) |
1736 | -{ |
1737 | - if (!operation) { |
1738 | - qCritical("'%s' failed (lost PulseAudio connection?)", func_name); |
1739 | - /* Free resources so it can retry a new connection during next operation */ |
1740 | - pa_threaded_mainloop_unlock(m_mainLoop); |
1741 | - releasePulseContext(); |
1742 | - return false; |
1743 | - } |
1744 | - |
1745 | - while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING) |
1746 | - pa_threaded_mainloop_wait(m_mainLoop); |
1747 | - pa_operation_unref(operation); |
1748 | - return true; |
1749 | -} |
1750 | - |
1751 | -int QPulseAudioEngineWorker::setupVoiceCall() |
1752 | -{ |
1753 | - pa_operation *o; |
1754 | - |
1755 | - qDebug("Setting up pulseaudio for voice call"); |
1756 | - |
1757 | - pa_threaded_mainloop_lock(m_mainLoop); |
1758 | - |
1759 | - /* Get and set the default sink/source to be restored later */ |
1760 | - o = pa_context_get_server_info(m_context, serverinfo_cb, this); |
1761 | - if (!handleOperation(o, "pa_context_get_server_info")) |
1762 | - return -1; |
1763 | - |
1764 | - qDebug("Recorded default sink: %s default source: %s", |
1765 | - m_defaultsink.c_str(), m_defaultsource.c_str()); |
1766 | - |
1767 | - /* Walk through the list of devices, find the voice call capable card and |
1768 | - * identify if we have bluetooth capable devices (hsp and a2dp) */ |
1769 | - m_voicecallcard = m_voicecallhighest = m_voicecallprofile = ""; |
1770 | - m_bt_hsp = m_bt_hsp_a2dp = ""; |
1771 | - o = pa_context_get_card_info_list(m_context, cardinfo_cb, this); |
1772 | - if (!handleOperation(o, "pa_context_get_card_info_list")) |
1773 | - return -1; |
1774 | - /* In case we have only one bt device that provides hsp and a2dp, we need |
1775 | - * to make sure we switch the default profile for that card (to hsp) */ |
1776 | - if ((m_bt_hsp_a2dp != "") && (m_bt_hsp == "")) { |
1777 | - qDebug("Setting PulseAudio card '%s' profile '%s'", |
1778 | - m_bt_hsp_a2dp.c_str(), PULSEAUDIO_PROFILE_HSP); |
1779 | - o = pa_context_set_card_profile_by_name(m_context, |
1780 | - m_bt_hsp_a2dp.c_str(), PULSEAUDIO_PROFILE_HSP, success_cb, this); |
1781 | - if (!handleOperation(o, "pa_context_set_card_profile_by_name")) |
1782 | - return -1; |
1783 | - } |
1784 | - |
1785 | - pa_threaded_mainloop_unlock(m_mainLoop); |
1786 | - |
1787 | - return 0; |
1788 | -} |
1789 | - |
1790 | -void QPulseAudioEngineWorker::restoreVoiceCall() |
1791 | -{ |
1792 | - pa_operation *o; |
1793 | - |
1794 | - qDebug("Restoring pulseaudio previous state"); |
1795 | - |
1796 | - /* Then restore previous settings */ |
1797 | - pa_threaded_mainloop_lock(m_mainLoop); |
1798 | - |
1799 | - /* See if we need to restore any HSP+AD2P device state */ |
1800 | - if ((m_bt_hsp_a2dp != "") && (m_bt_hsp == "")) { |
1801 | - qDebug("Restoring PulseAudio card '%s' to profile '%s'", |
1802 | - m_bt_hsp_a2dp.c_str(), PULSEAUDIO_PROFILE_A2DP); |
1803 | - o = pa_context_set_card_profile_by_name(m_context, |
1804 | - m_bt_hsp_a2dp.c_str(), PULSEAUDIO_PROFILE_A2DP, success_cb, this); |
1805 | - if (!handleOperation(o, "pa_context_set_card_profile_by_name")) |
1806 | - return; |
1807 | - } |
1808 | - |
1809 | - /* Restore default sink/source */ |
1810 | - if (m_defaultsink != "") { |
1811 | - qDebug("Restoring PulseAudio default sink to '%s'", m_defaultsink.c_str()); |
1812 | - o = pa_context_set_default_sink(m_context, m_defaultsink.c_str(), success_cb, this); |
1813 | - if (!handleOperation(o, "pa_context_set_default_sink")) |
1814 | - return; |
1815 | - } |
1816 | - if (m_defaultsource != "") { |
1817 | - qDebug("Restoring PulseAudio default source to '%s'", m_defaultsource.c_str()); |
1818 | - o = pa_context_set_default_source(m_context, m_defaultsource.c_str(), success_cb, this); |
1819 | - if (!handleOperation(o, "pa_context_set_default_source")) |
1820 | - return; |
1821 | - } |
1822 | - |
1823 | - pa_threaded_mainloop_unlock(m_mainLoop); |
1824 | -} |
1825 | - |
1826 | -void QPulseAudioEngineWorker::setCallMode(CallStatus callstatus, AudioMode audiomode) |
1827 | -{ |
1828 | - if (!createPulseContext()) { |
1829 | - return; |
1830 | - } |
1831 | - CallStatus p_callstatus = m_callstatus; |
1832 | - AudioMode p_audiomode = m_audiomode; |
1833 | - AudioModes p_availableAudioModes = m_availableAudioModes; |
1834 | - pa_operation *o; |
1835 | - |
1836 | - /* Check if we need to save the current pulseaudio state (e.g. when starting a call) */ |
1837 | - if ((callstatus != CallEnded) && (p_callstatus == CallEnded)) { |
1838 | - if (setupVoiceCall() < 0) { |
1839 | - qCritical("Failed to setup PulseAudio for Voice Call"); |
1840 | - return; |
1841 | - } |
1842 | - } |
1843 | - |
1844 | - /* If we have an active call, update internal state (used later when updating sink/source ports) */ |
1845 | - m_callstatus = callstatus; |
1846 | - m_audiomode = audiomode; |
1847 | - |
1848 | - pa_threaded_mainloop_lock(m_mainLoop); |
1849 | - |
1850 | - /* Switch the virtual card mode when call is active and not active |
1851 | - * This needs to be done before sink/source gets updated, because after changing mode |
1852 | - * it will automatically move to input/output-parking */ |
1853 | - if ((m_callstatus == CallActive) && (p_callstatus != CallActive) && |
1854 | - (m_voicecallcard != "") && (m_voicecallprofile != "")) { |
1855 | - qDebug("Setting PulseAudio card '%s' profile '%s'", |
1856 | - m_voicecallcard.c_str(), m_voicecallprofile.c_str()); |
1857 | - o = pa_context_set_card_profile_by_name(m_context, |
1858 | - m_voicecallcard.c_str(), m_voicecallprofile.c_str(), success_cb, this); |
1859 | - if (!handleOperation(o, "pa_context_set_card_profile_by_name")) |
1860 | - return; |
1861 | - } else if ((m_callstatus == CallEnded) && (m_voicecallcard != "") && (m_voicecallhighest != "")) { |
1862 | - /* If using droid, make sure to restore to the profile that has the highest score */ |
1863 | - qDebug("Restoring PulseAudio card '%s' to profile '%s'", |
1864 | - m_voicecallcard.c_str(), m_voicecallhighest.c_str()); |
1865 | - o = pa_context_set_card_profile_by_name(m_context, |
1866 | - m_voicecallcard.c_str(), m_voicecallhighest.c_str(), success_cb, this); |
1867 | - if (!handleOperation(o, "pa_context_set_card_profile_by_name")) |
1868 | - return; |
1869 | - } |
1870 | - |
1871 | - /* Find highest compatible sink/source elements from the voicecall |
1872 | - compatible card (on touch this means the pulse droid element) */ |
1873 | - m_nametoset = m_valuetoset = ""; |
1874 | - o = pa_context_get_sink_info_list(m_context, sinkinfo_cb, this); |
1875 | - if (!handleOperation(o, "pa_context_get_sink_info_list")) |
1876 | - return; |
1877 | - if ((m_nametoset != "") && (m_nametoset != m_defaultsink)) { |
1878 | - qDebug("Setting PulseAudio default sink to '%s'", m_nametoset.c_str()); |
1879 | - o = pa_context_set_default_sink(m_context, m_nametoset.c_str(), success_cb, this); |
1880 | - if (!handleOperation(o, "pa_context_set_default_sink")) |
1881 | - return; |
1882 | - } |
1883 | - if (m_valuetoset != "") { |
1884 | - qDebug("Setting PulseAudio sink '%s' port '%s'", |
1885 | - m_nametoset.c_str(), m_valuetoset.c_str()); |
1886 | - o = pa_context_set_sink_port_by_name(m_context, m_nametoset.c_str(), |
1887 | - m_valuetoset.c_str(), success_cb, this); |
1888 | - if (!handleOperation(o, "pa_context_set_sink_port_by_name")) |
1889 | - return; |
1890 | - } |
1891 | - |
1892 | - /* Same for source */ |
1893 | - m_nametoset = m_valuetoset = ""; |
1894 | - o = pa_context_get_source_info_list(m_context, sourceinfo_cb, this); |
1895 | - if (!handleOperation(o, "pa_context_get_source_info_list")) |
1896 | - return; |
1897 | - if ((m_nametoset != "") && (m_nametoset != m_defaultsource)) { |
1898 | - qDebug("Setting PulseAudio default source to '%s'", m_nametoset.c_str()); |
1899 | - o = pa_context_set_default_source(m_context, m_nametoset.c_str(), success_cb, this); |
1900 | - if (!handleOperation(o, "pa_context_set_default_source")) |
1901 | - return; |
1902 | - } |
1903 | - if (m_valuetoset != "") { |
1904 | - qDebug("Setting PulseAudio source '%s' port '%s'", |
1905 | - m_nametoset.c_str(), m_valuetoset.c_str()); |
1906 | - o = pa_context_set_source_port_by_name(m_context, m_nametoset.c_str(), |
1907 | - m_valuetoset.c_str(), success_cb, this); |
1908 | - if (!handleOperation(o, "pa_context_set_source_port_by_name")) |
1909 | - return; |
1910 | - } |
1911 | - |
1912 | - pa_threaded_mainloop_unlock(m_mainLoop); |
1913 | - |
1914 | - /* Notify if the list of audio modes changed */ |
1915 | - if (p_availableAudioModes != m_availableAudioModes) |
1916 | - Q_EMIT availableAudioModesChanged(m_availableAudioModes); |
1917 | - |
1918 | - /* Notify if call mode changed */ |
1919 | - if (p_audiomode != m_audiomode) { |
1920 | - Q_EMIT audioModeChanged(m_audiomode); |
1921 | - } |
1922 | - |
1923 | - /* If no more active voicecall, restore previous saved pulseaudio state */ |
1924 | - if (callstatus == CallEnded) { |
1925 | - restoreVoiceCall(); |
1926 | - } |
1927 | - |
1928 | - /* In case the app had set mute when the call wasn't active, make sure we reflect it here */ |
1929 | - if (m_callstatus != CallEnded) |
1930 | - setMicMute(m_micmute); |
1931 | -} |
1932 | - |
1933 | -void QPulseAudioEngineWorker::setMicMute(bool muted) |
1934 | -{ |
1935 | - if (!createPulseContext()) { |
1936 | - return; |
1937 | - } |
1938 | - |
1939 | - m_micmute = muted; |
1940 | - |
1941 | - if (m_callstatus == CallEnded) |
1942 | - return; |
1943 | - |
1944 | - pa_threaded_mainloop_lock(m_mainLoop); |
1945 | - |
1946 | - m_nametoset = ""; |
1947 | - pa_operation *o = pa_context_get_source_info_list(m_context, sourceinfo_cb, this); |
1948 | - if (!handleOperation(o, "pa_context_get_source_info_list")) |
1949 | - return; |
1950 | - |
1951 | - if (m_nametoset != "") { |
1952 | - int m = m_micmute ? 1 : 0; |
1953 | - qDebug("Setting PulseAudio source '%s' muted '%d'", m_nametoset.c_str(), m); |
1954 | - o = pa_context_set_source_mute_by_name(m_context, |
1955 | - m_nametoset.c_str(), m, success_cb, this); |
1956 | - if (!handleOperation(o, "pa_context_set_source_mute_by_name")) |
1957 | - return; |
1958 | - } |
1959 | - |
1960 | - pa_threaded_mainloop_unlock(m_mainLoop); |
1961 | -} |
1962 | - |
1963 | -void QPulseAudioEngineWorker::plugCardCallback(const pa_card_info *info) |
1964 | -{ |
1965 | - qDebug("Notified about card (%s) add event from PulseAudio", info->name); |
1966 | - |
1967 | - /* We only care about BT (HSP) devices, and if one is not already available */ |
1968 | - if ((m_callstatus != CallEnded) && ((m_bt_hsp == "") || (m_bt_hsp_a2dp == ""))) { |
1969 | - /* Check if it's indeed a BT device (with at least one hsp profile) */ |
1970 | - pa_card_profile_info *hsp = NULL; |
1971 | - for (int i = 0; i < info->n_profiles; i++) { |
1972 | - if (!strcmp(info->profiles[i].name, PULSEAUDIO_PROFILE_HSP)) |
1973 | - hsp = &info->profiles[i]; |
1974 | - } |
1975 | - if (hsp) |
1976 | - m_handleevent = true; |
1977 | - } |
1978 | -} |
1979 | - |
1980 | -void QPulseAudioEngineWorker::updateCardCallback(const pa_card_info *info) |
1981 | -{ |
1982 | - qDebug("Notified about card (%s) changes event from PulseAudio", info->name); |
1983 | - |
1984 | - /* We only care if the card event for the voicecall capable card */ |
1985 | - if ((m_callstatus == CallActive) && (!strcmp(info->name, m_voicecallcard.c_str()))) { |
1986 | - if (m_audiomode == AudioModeWiredHeadset) { |
1987 | - /* If previous mode is wired, it means it got unplugged */ |
1988 | - m_handleevent = true; |
1989 | - m_audiomodetoset = AudioModeBtOrWiredOrEarpiece; |
1990 | - } else if ((m_audiomode == AudioModeEarpiece) || ((m_audiomode == AudioModeSpeaker))) { |
1991 | - /* Now only trigger the event in case wired headset/headphone is now available */ |
1992 | - pa_card_port_info *port_info = NULL; |
1993 | - for (int i = 0; i < info->n_ports; i++) { |
1994 | - if (info->ports[i] && (info->ports[i]->available == PA_PORT_AVAILABLE_YES) && ( |
1995 | - !strcmp(info->ports[i]->name, "output-wired_headset") || |
1996 | - !strcmp(info->ports[i]->name, "output-wired_headphone"))) { |
1997 | - m_handleevent = true; |
1998 | - m_audiomodetoset = AudioModeWiredOrEarpiece; |
1999 | - } |
2000 | - } |
2001 | - } else if (m_audiomode == AudioModeBluetooth) { |
2002 | - /* Handle the event so we can update the audiomodes */ |
2003 | - m_handleevent = true; |
2004 | - m_audiomodetoset = AudioModeBluetooth; |
2005 | - } |
2006 | - } |
2007 | -} |
2008 | - |
2009 | -void QPulseAudioEngineWorker::unplugCardCallback() |
2010 | -{ |
2011 | - if (m_callstatus != CallEnded) { |
2012 | - m_handleevent = true; |
2013 | - } |
2014 | -} |
2015 | - |
2016 | -void QPulseAudioEngineWorker::handleCardEvent(const int evt, const unsigned int idx) |
2017 | -{ |
2018 | - pa_operation *o = NULL; |
2019 | - |
2020 | - /* Internal state var used to know if we need to update our internal state */ |
2021 | - m_handleevent = false; |
2022 | - |
2023 | - if (evt == PA_SUBSCRIPTION_EVENT_NEW) { |
2024 | - o = pa_context_get_card_info_by_index(m_context, idx, plug_card_cb, this); |
2025 | - if (!handleOperation(o, "pa_context_get_card_info_by_index")) |
2026 | - return; |
2027 | - if (m_handleevent) { |
2028 | - qDebug("Adding new BT-HSP capable device"); |
2029 | - /* In case A2DP is available, switch to HSP */ |
2030 | - if (setupVoiceCall() < 0) |
2031 | - return; |
2032 | - /* Enable the HSP output port */ |
2033 | - setCallMode(m_callstatus, AudioModeBluetooth); |
2034 | - } |
2035 | - } else if (evt == PA_SUBSCRIPTION_EVENT_CHANGE) { |
2036 | - o = pa_context_get_card_info_by_index(m_context, idx, update_card_cb, this); |
2037 | - if (!handleOperation(o, "pa_context_get_card_info_by_index")) |
2038 | - return; |
2039 | - if (m_handleevent) { |
2040 | - /* In this case it means the handset state changed */ |
2041 | - qDebug("Notifying card changes for the voicecall capable card"); |
2042 | - setCallMode(m_callstatus, m_audiomodetoset); |
2043 | - } |
2044 | - } else if (evt == PA_SUBSCRIPTION_EVENT_REMOVE) { |
2045 | - /* Check if the main HSP card was removed */ |
2046 | - if (m_bt_hsp != "") { |
2047 | - o = pa_context_get_card_info_by_name(m_context, m_bt_hsp.c_str(), unplug_card_cb, this); |
2048 | - if (!handleOperation(o, "pa_context_get_sink_info_by_name")) |
2049 | - return; |
2050 | - } |
2051 | - if (m_bt_hsp_a2dp != "") { |
2052 | - o = pa_context_get_card_info_by_name(m_context, m_bt_hsp_a2dp.c_str(), unplug_card_cb, this); |
2053 | - if (!handleOperation(o, "pa_context_get_sink_info_by_name")) |
2054 | - return; |
2055 | - } |
2056 | - if (m_handleevent) { |
2057 | - qDebug("Notifying about BT-HSP card removal"); |
2058 | - /* Needed in order to save the default sink/source */ |
2059 | - if (setupVoiceCall() < 0) |
2060 | - return; |
2061 | - /* Enable the default handset output port */ |
2062 | - setCallMode(m_callstatus, AudioModeWiredOrEarpiece); |
2063 | - } |
2064 | - } |
2065 | -} |
2066 | - |
2067 | -Q_GLOBAL_STATIC(QPulseAudioEngine, pulseEngine); |
2068 | - |
2069 | -QPulseAudioEngine::QPulseAudioEngine(QObject *parent) : |
2070 | - QObject(parent) |
2071 | -{ |
2072 | - qRegisterMetaType<CallStatus>(); |
2073 | - qRegisterMetaType<AudioMode>(); |
2074 | - qRegisterMetaType<AudioModes>(); |
2075 | - mWorker = new QPulseAudioEngineWorker(); |
2076 | - QObject::connect(mWorker, SIGNAL(audioModeChanged(const AudioMode)), this, SIGNAL(audioModeChanged(const AudioMode)), Qt::QueuedConnection); |
2077 | - QObject::connect(mWorker, SIGNAL(availableAudioModesChanged(const AudioModes)), this, SIGNAL(availableAudioModesChanged(const AudioModes)), Qt::QueuedConnection); |
2078 | - mWorker->createPulseContext(); |
2079 | - mWorker->moveToThread(&mThread); |
2080 | - mThread.start(); |
2081 | -} |
2082 | - |
2083 | -QPulseAudioEngine::~QPulseAudioEngine() |
2084 | -{ |
2085 | - mThread.quit(); |
2086 | - mThread.wait(); |
2087 | -} |
2088 | - |
2089 | -QPulseAudioEngine *QPulseAudioEngine::instance() |
2090 | -{ |
2091 | - QPulseAudioEngine *engine = pulseEngine(); |
2092 | - return engine; |
2093 | -} |
2094 | - |
2095 | -void QPulseAudioEngine::setCallMode(CallStatus callstatus, AudioMode audiomode) |
2096 | -{ |
2097 | - QMetaObject::invokeMethod(mWorker, "setCallMode", Qt::QueuedConnection, Q_ARG(CallStatus, callstatus), Q_ARG(AudioMode, audiomode)); |
2098 | -} |
2099 | - |
2100 | -void QPulseAudioEngine::setMicMute(bool muted) |
2101 | -{ |
2102 | - QMetaObject::invokeMethod(mWorker, "setMicMute", Qt::QueuedConnection, Q_ARG(bool, muted)); |
2103 | -} |
2104 | - |
2105 | -QT_END_NAMESPACE |
2106 | - |
2107 | |
2108 | === removed file 'qpulseaudioengine.h' |
2109 | --- qpulseaudioengine.h 2015-07-28 18:10:10 +0000 |
2110 | +++ qpulseaudioengine.h 1970-01-01 00:00:00 +0000 |
2111 | @@ -1,124 +0,0 @@ |
2112 | -/**************************************************************************** |
2113 | -** |
2114 | -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). |
2115 | -** Contact: http://www.qt-project.org/legal |
2116 | -** |
2117 | -** This file was taken from qt5 and modified by |
2118 | -** David Henningsson <david.henningsson@canonical.com> for usage in |
2119 | -** telepathy-ofono. |
2120 | -** |
2121 | -** GNU Lesser General Public License Usage |
2122 | -** Alternatively, this file may be used under the terms of the GNU Lesser |
2123 | -** General Public License version 2.1 as published by the Free Software |
2124 | -** Foundation and appearing in the file LICENSE.LGPL included in the |
2125 | -** packaging of this file. Please review the following information to |
2126 | -** ensure the GNU Lesser General Public License version 2.1 requirements |
2127 | -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
2128 | -** |
2129 | -****************************************************************************/ |
2130 | - |
2131 | -#ifndef QPULSEAUDIOENGINE_H |
2132 | -#define QPULSEAUDIOENGINE_H |
2133 | - |
2134 | -#include <QtCore/qmap.h> |
2135 | -#include <QtCore/qbytearray.h> |
2136 | -#include <QThread> |
2137 | -#include <pulse/pulseaudio.h> |
2138 | - |
2139 | -enum AudioMode { |
2140 | - AudioModeEarpiece = 0x0001, |
2141 | - AudioModeWiredHeadset = 0x0002, |
2142 | - AudioModeSpeaker = 0x0004, |
2143 | - AudioModeBluetooth = 0x0008, |
2144 | - AudioModeBtOrWiredOrEarpiece = AudioModeBluetooth | AudioModeWiredHeadset | AudioModeEarpiece, |
2145 | - AudioModeWiredOrEarpiece = AudioModeWiredHeadset | AudioModeEarpiece, |
2146 | - AudioModeWiredOrSpeaker = AudioModeWiredHeadset | AudioModeSpeaker |
2147 | -}; |
2148 | - |
2149 | -Q_DECLARE_METATYPE(AudioMode) |
2150 | - |
2151 | -typedef QList<AudioMode> AudioModes; |
2152 | -Q_DECLARE_METATYPE(AudioModes) |
2153 | - |
2154 | -enum CallStatus { |
2155 | - CallRinging, |
2156 | - CallActive, |
2157 | - CallEnded |
2158 | -}; |
2159 | - |
2160 | -Q_DECLARE_METATYPE(CallStatus) |
2161 | - |
2162 | -QT_BEGIN_NAMESPACE |
2163 | - |
2164 | -class QPulseAudioEngineWorker : public QObject |
2165 | -{ |
2166 | - Q_OBJECT |
2167 | - |
2168 | -public: |
2169 | - QPulseAudioEngineWorker(QObject *parent = 0); |
2170 | - ~QPulseAudioEngineWorker(); |
2171 | - |
2172 | - pa_threaded_mainloop *mainloop() { return m_mainLoop; } |
2173 | - pa_context *context() { return m_context; } |
2174 | - bool createPulseContext(void); |
2175 | - int setupVoiceCall(void); |
2176 | - void restoreVoiceCall(void); |
2177 | - /* Callbacks to be used internally */ |
2178 | - void cardInfoCallback(const pa_card_info *card); |
2179 | - void sinkInfoCallback(const pa_sink_info *sink); |
2180 | - void sourceInfoCallback(const pa_source_info *source); |
2181 | - void serverInfoCallback(const pa_server_info *server); |
2182 | - void plugCardCallback(const pa_card_info *card); |
2183 | - void updateCardCallback(const pa_card_info *card); |
2184 | - void unplugCardCallback(); |
2185 | - |
2186 | -Q_SIGNALS: |
2187 | - void audioModeChanged(const AudioMode mode); |
2188 | - void availableAudioModesChanged(const AudioModes modes); |
2189 | - |
2190 | -public Q_SLOTS: |
2191 | - void handleCardEvent(const int evt, const unsigned int idx); |
2192 | - void setCallMode(CallStatus callstatus, AudioMode audiomode); |
2193 | - void setMicMute(bool muted); /* True if muted, false if unmuted */ |
2194 | - |
2195 | -private: |
2196 | - pa_mainloop_api *m_mainLoopApi; |
2197 | - pa_threaded_mainloop *m_mainLoop; |
2198 | - pa_context *m_context; |
2199 | - |
2200 | - AudioModes m_availableAudioModes; |
2201 | - CallStatus m_callstatus; |
2202 | - AudioMode m_audiomode; |
2203 | - AudioMode m_audiomodetoset; |
2204 | - bool m_micmute, m_handleevent; |
2205 | - std::string m_nametoset, m_valuetoset; |
2206 | - std::string m_defaultsink, m_defaultsource; |
2207 | - std::string m_bt_hsp, m_bt_hsp_a2dp; |
2208 | - std::string m_voicecallcard, m_voicecallhighest, m_voicecallprofile; |
2209 | - |
2210 | - bool handleOperation(pa_operation *operation, const char *func_name); |
2211 | - void releasePulseContext(void); |
2212 | -}; |
2213 | - |
2214 | -class QPulseAudioEngine : public QObject |
2215 | -{ |
2216 | - Q_OBJECT |
2217 | -public: |
2218 | - explicit QPulseAudioEngine(QObject *parent = 0); |
2219 | - ~QPulseAudioEngine(); |
2220 | - static QPulseAudioEngine *instance(); |
2221 | - |
2222 | - void setCallMode(CallStatus callstatus, AudioMode audiomode); |
2223 | - void setMicMute(bool muted); /* True if muted, false if unmuted */ |
2224 | - |
2225 | -Q_SIGNALS: |
2226 | - void audioModeChanged(const AudioMode mode); |
2227 | - void availableAudioModesChanged(const AudioModes modes); |
2228 | -private: |
2229 | - QPulseAudioEngineWorker *mWorker; |
2230 | - QThread mThread; |
2231 | -}; |
2232 | - |
2233 | -QT_END_NAMESPACE |
2234 | - |
2235 | -#endif |
looks good.