aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/network/AirPlayServer.cpp15
-rw-r--r--xbmc/network/AirPlayServer.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/xbmc/network/AirPlayServer.cpp b/xbmc/network/AirPlayServer.cpp
index 127a765985..8040d9b0d1 100644
--- a/xbmc/network/AirPlayServer.cpp
+++ b/xbmc/network/AirPlayServer.cpp
@@ -63,6 +63,7 @@ using namespace ANNOUNCEMENT;
#define AIRPLAY_STATUS_NOT_IMPLEMENTED 501
#define AIRPLAY_STATUS_NO_RESPONSE_NEEDED 1000
+CCriticalSection CAirPlayServer::ServerInstanceLock;
CAirPlayServer *CAirPlayServer::ServerInstance = NULL;
int CAirPlayServer::m_isPlaying = 0;
@@ -156,6 +157,8 @@ const char *eventStrings[] = {"playing", "paused", "loading", "stopped"};
void CAirPlayServer::Announce(AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data)
{
+ CSingleLock lock(ServerInstanceLock);
+
if ( (flag & Player) && strcmp(sender, "xbmc") == 0 && ServerInstance)
{
if (strcmp(message, "OnStop") == 0)
@@ -184,6 +187,8 @@ bool CAirPlayServer::StartServer(int port, bool nonlocal)
{
StopServer(true);
+ CSingleLock lock(ServerInstanceLock);
+
ServerInstance = new CAirPlayServer(port, nonlocal);
if (ServerInstance->Initialize())
{
@@ -196,6 +201,7 @@ bool CAirPlayServer::StartServer(int port, bool nonlocal)
bool CAirPlayServer::SetCredentials(bool usePassword, const CStdString& password)
{
+ CSingleLock lock(ServerInstanceLock);
bool ret = false;
if (ServerInstance)
@@ -214,6 +220,7 @@ bool CAirPlayServer::SetInternalCredentials(bool usePassword, const CStdString&
void CAirPlayServer::StopServer(bool bWait)
{
+ CSingleLock lock(ServerInstanceLock);
if (ServerInstance)
{
ServerInstance->StopThread(bWait);
@@ -694,13 +701,17 @@ bool CAirPlayServer::CTCPClient::checkAuthorization(const CStdString& authStr,
void CAirPlayServer::backupVolume()
{
- if (ServerInstance->m_origVolume == -1)
+ CSingleLock lock(ServerInstanceLock);
+
+ if (ServerInstance && ServerInstance->m_origVolume == -1)
ServerInstance->m_origVolume = (int)g_application.GetVolume();
}
void CAirPlayServer::restoreVolume()
{
- if (ServerInstance->m_origVolume != -1 && CSettings::Get().GetBool("services.airplayvolumecontrol"))
+ CSingleLock lock(ServerInstanceLock);
+
+ if (ServerInstance && ServerInstance->m_origVolume != -1 && CSettings::Get().GetBool("services.airplayvolumecontrol"))
{
g_application.SetVolume((float)ServerInstance->m_origVolume);
ServerInstance->m_origVolume = -1;
diff --git a/xbmc/network/AirPlayServer.h b/xbmc/network/AirPlayServer.h
index 4c486fbff8..27c7f40b2d 100644
--- a/xbmc/network/AirPlayServer.h
+++ b/xbmc/network/AirPlayServer.h
@@ -112,6 +112,7 @@ private:
CStdString m_password;
int m_origVolume;
+ static CCriticalSection ServerInstanceLock;
static CAirPlayServer *ServerInstance;
};