Changeset View
Changeset View
Standalone View
Standalone View
src/context.cpp
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #include "context.h" | 21 | #include "context.h" | ||
22 | #include "server.h" | 22 | #include "server.h" | ||
23 | 23 | | |||
24 | #include <QAbstractEventDispatcher> | 24 | #include <QAbstractEventDispatcher> | ||
25 | #include "debug.h" | 25 | #include "debug.h" | ||
26 | #include <QMutexLocker> | 26 | #include <QMutexLocker> | ||
27 | #include <QTimer> | 27 | #include <QTimer> | ||
28 | #include <QDBusServiceWatcher> | ||||
29 | #include <QDBusConnection> | ||||
28 | 30 | | |||
29 | #include "card.h" | 31 | #include "card.h" | ||
30 | #include "client.h" | 32 | #include "client.h" | ||
31 | #include "sink.h" | 33 | #include "sink.h" | ||
32 | #include "sinkinput.h" | 34 | #include "sinkinput.h" | ||
33 | #include "source.h" | 35 | #include "source.h" | ||
34 | #include "sourceoutput.h" | 36 | #include "sourceoutput.h" | ||
35 | #include "streamrestore.h" | 37 | #include "streamrestore.h" | ||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | |||||
172 | 174 | | |||
173 | Context::Context(QObject *parent) | 175 | Context::Context(QObject *parent) | ||
174 | : QObject(parent) | 176 | : QObject(parent) | ||
175 | , m_server(new Server(this)) | 177 | , m_server(new Server(this)) | ||
176 | , m_context(nullptr) | 178 | , m_context(nullptr) | ||
177 | , m_mainloop(nullptr) | 179 | , m_mainloop(nullptr) | ||
178 | , m_references(0) | 180 | , m_references(0) | ||
179 | { | 181 | { | ||
182 | QDBusServiceWatcher *watcher = new QDBusServiceWatcher(QStringLiteral("org.pulseaudio.Server"), | ||||
183 | QDBusConnection::sessionBus(), | ||||
184 | QDBusServiceWatcher::WatchForRegistration, | ||||
185 | this); | ||||
186 | connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, [this]() { | ||||
187 | if (!m_context) { | ||||
188 | connectToDaemon(); | ||||
189 | } | ||||
190 | }); | ||||
191 | | ||||
180 | connectToDaemon(); | 192 | connectToDaemon(); | ||
181 | } | 193 | } | ||
182 | 194 | | |||
183 | Context::~Context() | 195 | Context::~Context() | ||
184 | { | 196 | { | ||
185 | if (m_context) { | 197 | if (m_context) { | ||
186 | pa_context_unref(m_context); | 198 | pa_context_unref(m_context); | ||
187 | m_context = nullptr; | 199 | m_context = nullptr; | ||
▲ Show 20 Lines • Show All 345 Lines • Show Last 20 Lines |