diff --git a/mythtv/libs/libmythtv/AirPlay/mythairplayserver.cpp b/mythtv/libs/libmythtv/AirPlay/mythairplayserver.cpp
index 367a2a9..a8f3c19 100644
a
|
b
|
|
22 | 22 | #include "bonjourregister.h" |
23 | 23 | #include "mythairplayserver.h" |
24 | 24 | |
25 | | MythAirplayServer* MythAirplayServer::gMythAirplayServer = NULL; |
26 | | MThread* MythAirplayServer::gMythAirplayServerThread = NULL; |
27 | | QMutex* MythAirplayServer::gMythAirplayServerMutex = new QMutex(QMutex::Recursive); |
| 25 | static MythAirplayServer* s_airplayServer = NULL; |
| 26 | static MThread* s_airplayServerThread = NULL; |
| 27 | static QMutex s_airplayServerMutex; |
28 | 28 | |
29 | 29 | #define LOC QString("AirPlay: ") |
30 | 30 | |
… |
… |
class APHTTPRequest |
307 | 307 | |
308 | 308 | bool MythAirplayServer::Create(void) |
309 | 309 | { |
310 | | QMutexLocker locker(gMythAirplayServerMutex); |
| 310 | QMutexLocker locker(&s_airplayServerMutex); |
311 | 311 | |
312 | 312 | // create the server thread |
313 | | if (!gMythAirplayServerThread) |
314 | | gMythAirplayServerThread = new MThread("AirplayServer"); |
315 | | if (!gMythAirplayServerThread) |
| 313 | if (!s_airplayServerThread) |
| 314 | s_airplayServerThread = new MThread("AirplayServer"); |
| 315 | if (!s_airplayServerThread) |
316 | 316 | { |
317 | 317 | LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create airplay thread."); |
318 | 318 | return false; |
319 | 319 | } |
320 | 320 | |
321 | 321 | // create the server object |
322 | | if (!gMythAirplayServer) |
323 | | gMythAirplayServer = new MythAirplayServer(); |
324 | | if (!gMythAirplayServer) |
| 322 | if (!s_airplayServer) |
| 323 | s_airplayServer = new MythAirplayServer(); |
| 324 | if (!s_airplayServer) |
325 | 325 | { |
326 | 326 | LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create airplay object."); |
| 327 | delete s_airplayServerThread; |
| 328 | s_airplayServerThread = NULL; |
327 | 329 | return false; |
328 | 330 | } |
329 | 331 | |
330 | 332 | // start the thread |
331 | | if (!gMythAirplayServerThread->isRunning()) |
| 333 | if (!s_airplayServerThread->isRunning()) |
332 | 334 | { |
333 | | gMythAirplayServer->moveToThread(gMythAirplayServerThread->qthread()); |
| 335 | s_airplayServer->moveToThread(s_airplayServerThread->qthread()); |
334 | 336 | QObject::connect( |
335 | | gMythAirplayServerThread->qthread(), SIGNAL(started()), |
336 | | gMythAirplayServer, SLOT(Start())); |
337 | | gMythAirplayServerThread->start(QThread::LowestPriority); |
| 337 | s_airplayServerThread->qthread(), SIGNAL(started()), |
| 338 | s_airplayServer, SLOT(Start())); |
| 339 | s_airplayServerThread->start(QThread::LowestPriority); |
338 | 340 | } |
339 | 341 | |
340 | 342 | LOG(VB_GENERAL, LOG_INFO, LOC + "Created airplay objects."); |
… |
… |
void MythAirplayServer::Cleanup(void) |
345 | 347 | { |
346 | 348 | LOG(VB_GENERAL, LOG_INFO, LOC + "Cleaning up."); |
347 | 349 | |
348 | | if (gMythAirplayServer) |
349 | | gMythAirplayServer->Teardown(); |
| 350 | QMutexLocker locker(&s_airplayServerMutex); |
350 | 351 | |
351 | | QMutexLocker locker(gMythAirplayServerMutex); |
352 | | if (gMythAirplayServerThread) |
| 352 | if (s_airplayServer) |
| 353 | s_airplayServer->Teardown(); |
| 354 | |
| 355 | if (s_airplayServerThread) |
353 | 356 | { |
354 | | gMythAirplayServerThread->exit(); |
355 | | gMythAirplayServerThread->wait(); |
| 357 | s_airplayServerThread->exit(); |
| 358 | s_airplayServerThread->wait(); |
356 | 359 | } |
357 | | delete gMythAirplayServerThread; |
358 | | gMythAirplayServerThread = NULL; |
359 | 360 | |
360 | | delete gMythAirplayServer; |
361 | | gMythAirplayServer = NULL; |
| 361 | delete s_airplayServer; |
| 362 | s_airplayServer = NULL; |
| 363 | |
| 364 | delete s_airplayServerThread; |
| 365 | s_airplayServerThread = NULL; |
362 | 366 | } |
363 | 367 | |
364 | 368 | |
diff --git a/mythtv/libs/libmythtv/AirPlay/mythairplayserver.h b/mythtv/libs/libmythtv/AirPlay/mythairplayserver.h
index 2005b09..24b9c76 100644
a
|
b
|
class MTV_PUBLIC MythAirplayServer : public ServerPool |
59 | 59 | public: |
60 | 60 | static bool Create(void); |
61 | 61 | static void Cleanup(void); |
62 | | static MythAirplayServer *AirplaySharedInstance(void) |
63 | | { return gMythAirplayServer; } |
64 | 62 | |
65 | 63 | MythAirplayServer(); |
66 | 64 | |
… |
… |
class MTV_PUBLIC MythAirplayServer : public ServerPool |
94 | 92 | void PausePlayback(void); |
95 | 93 | void UnpausePlayback(void); |
96 | 94 | |
97 | | // Globals |
98 | | static MythAirplayServer *gMythAirplayServer; |
99 | | static QMutex *gMythAirplayServerMutex; |
100 | | static MThread *gMythAirplayServerThread; |
101 | | |
102 | 95 | // Members |
103 | 96 | QString m_name; |
104 | 97 | BonjourRegister *m_bonjour; |