Changeset View
Changeset View
Standalone View
Standalone View
src/context.cpp
Show First 20 Lines • Show All 227 Lines • ▼ Show 20 Line(s) | 225 | Context::Context(QObject *parent) | |||
---|---|---|---|---|---|
228 | , m_context(nullptr) | 228 | , m_context(nullptr) | ||
229 | , m_mainloop(nullptr) | 229 | , m_mainloop(nullptr) | ||
230 | , m_references(0) | 230 | , m_references(0) | ||
231 | { | 231 | { | ||
232 | QDBusServiceWatcher *watcher = new QDBusServiceWatcher(QStringLiteral("org.pulseaudio.Server"), | 232 | QDBusServiceWatcher *watcher = new QDBusServiceWatcher(QStringLiteral("org.pulseaudio.Server"), | ||
233 | QDBusConnection::sessionBus(), | 233 | QDBusConnection::sessionBus(), | ||
234 | QDBusServiceWatcher::WatchForRegistration, | 234 | QDBusServiceWatcher::WatchForRegistration, | ||
235 | this); | 235 | this); | ||
236 | connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, [this]() { | 236 | connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, &Context::connectToDaemon); | ||
237 | if (!m_context) { | | |||
238 | connectToDaemon(); | | |||
239 | } | | |||
240 | }); | | |||
241 | | ||||
242 | connectToDaemon(); | 237 | connectToDaemon(); | ||
243 | } | 238 | } | ||
244 | 239 | | |||
245 | Context::~Context() | 240 | Context::~Context() | ||
246 | { | 241 | { | ||
247 | if (m_context) { | 242 | if (m_context) { | ||
248 | pa_context_unref(m_context); | 243 | pa_context_unref(m_context); | ||
249 | m_context = nullptr; | 244 | m_context = nullptr; | ||
▲ Show 20 Lines • Show All 336 Lines • ▼ Show 20 Line(s) | 576 | if (!PAOperation(pa_ext_stream_restore_write(m_context, | |||
586 | nullptr, | 581 | nullptr, | ||
587 | nullptr))) { | 582 | nullptr))) { | ||
588 | qCWarning(PLASMAPA) << "pa_ext_stream_restore_write failed"; | 583 | qCWarning(PLASMAPA) << "pa_ext_stream_restore_write failed"; | ||
589 | } | 584 | } | ||
590 | } | 585 | } | ||
591 | 586 | | |||
592 | void Context::connectToDaemon() | 587 | void Context::connectToDaemon() | ||
593 | { | 588 | { | ||
594 | Q_ASSERT(m_context == nullptr); | 589 | if (m_context) { | ||
590 | return; | ||||
591 | } | ||||
595 | 592 | | |||
596 | // We require a glib event loop | 593 | // We require a glib event loop | ||
597 | if (!QByteArray(QAbstractEventDispatcher::instance()->metaObject()->className()).contains("EventDispatcherGlib")) { | 594 | if (!QByteArray(QAbstractEventDispatcher::instance()->metaObject()->className()).contains("EventDispatcherGlib")) { | ||
598 | qCWarning(PLASMAPA) << "Disabling PulseAudio integration for lack of GLib event loop"; | 595 | qCWarning(PLASMAPA) << "Disabling PulseAudio integration for lack of GLib event loop"; | ||
599 | return; | 596 | return; | ||
600 | } | 597 | } | ||
601 | 598 | | |||
602 | qCDebug(PLASMAPA) << "Attempting connection to PulseAudio sound daemon"; | 599 | qCDebug(PLASMAPA) << "Attempting connection to PulseAudio sound daemon"; | ||
Show All 34 Lines |