diff --git a/mythtv/libs/libmythtv/AirPlay/mythairplayserver.cpp b/mythtv/libs/libmythtv/AirPlay/mythairplayserver.cpp
index 367a2a9..56eab48 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 | | // create the server thread |
| 313 | | if (!gMythAirplayServerThread) |
| 314 | | gMythAirplayServerThread = new MThread("AirplayServer"); |
| 315 | | if (!gMythAirplayServerThread) |
| 316 | | { |
| 317 | | LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create airplay thread."); |
| 318 | | return false; |
| 319 | | } |
| | 312 | // server already exits |
| | 313 | if (s_airplayServerThread) |
| | 314 | return true; |
| 320 | 315 | |
| 321 | | // create the server object |
| 322 | | if (!gMythAirplayServer) |
| 323 | | gMythAirplayServer = new MythAirplayServer(); |
| 324 | | if (!gMythAirplayServer) |
| 325 | | { |
| 326 | | LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create airplay object."); |
| 327 | | return false; |
| 328 | | } |
| | 316 | // create the server thread & server object |
| | 317 | s_airplayServerThread = new MThread("AirplayServer"); |
| | 318 | s_airplayServer = new MythAirplayServer(); |
| 329 | 319 | |
| 330 | 320 | // start the thread |
| 331 | | if (!gMythAirplayServerThread->isRunning()) |
| 332 | | { |
| 333 | | gMythAirplayServer->moveToThread(gMythAirplayServerThread->qthread()); |
| 334 | | QObject::connect( |
| 335 | | gMythAirplayServerThread->qthread(), SIGNAL(started()), |
| 336 | | gMythAirplayServer, SLOT(Start())); |
| 337 | | gMythAirplayServerThread->start(QThread::LowestPriority); |
| 338 | | } |
| | 321 | s_airplayServer->moveToThread(s_airplayServerThread->qthread()); |
| | 322 | QObject::connect( |
| | 323 | s_airplayServerThread->qthread(), SIGNAL(started()), |
| | 324 | s_airplayServer, SLOT(Start())); |
| | 325 | s_airplayServerThread->start(QThread::LowestPriority); |
| 339 | 326 | |
| 340 | 327 | LOG(VB_GENERAL, LOG_INFO, LOC + "Created airplay objects."); |
| 341 | 328 | return true; |
| … |
… |
void MythAirplayServer::Cleanup(void)
|
| 345 | 332 | { |
| 346 | 333 | LOG(VB_GENERAL, LOG_INFO, LOC + "Cleaning up."); |
| 347 | 334 | |
| 348 | | if (gMythAirplayServer) |
| 349 | | gMythAirplayServer->Teardown(); |
| | 335 | QMutexLocker locker(&s_airplayServerMutex); |
| 350 | 336 | |
| 351 | | QMutexLocker locker(gMythAirplayServerMutex); |
| 352 | | if (gMythAirplayServerThread) |
| | 337 | if (s_airplayServer) |
| | 338 | s_airplayServer->Teardown(); |
| | 339 | |
| | 340 | if (s_airplayServerThread) |
| 353 | 341 | { |
| 354 | | gMythAirplayServerThread->exit(); |
| 355 | | gMythAirplayServerThread->wait(); |
| | 342 | s_airplayServerThread->exit(); |
| | 343 | s_airplayServerThread->wait(); |
| 356 | 344 | } |
| 357 | | delete gMythAirplayServerThread; |
| 358 | | gMythAirplayServerThread = NULL; |
| 359 | 345 | |
| 360 | | delete gMythAirplayServer; |
| 361 | | gMythAirplayServer = NULL; |
| | 346 | delete s_airplayServer; |
| | 347 | s_airplayServer = NULL; |
| | 348 | |
| | 349 | delete s_airplayServerThread; |
| | 350 | s_airplayServerThread = NULL; |
| 362 | 351 | } |
| 363 | 352 | |
| 364 | 353 | |
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; |