From cdf07e69056edb379ae54dc9082152fc2612b1ef Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 6 Apr 2014 20:33:48 -0400 Subject: [PATCH] Initialize the thread list mutex --- limelight-common/Connection.c | 7 +++++++ limelight-common/Limelight-internal.h | 1 + limelight-common/PlatformThreads.c | 15 +++++++++++++++ limelight-common/PlatformThreads.h | 3 +++ 4 files changed, 26 insertions(+) diff --git a/limelight-common/Connection.c b/limelight-common/Connection.c index 8eb3725..e7655e8 100644 --- a/limelight-common/Connection.c +++ b/limelight-common/Connection.c @@ -80,6 +80,7 @@ void LiStopConnection(void) { if (stage == STAGE_PLATFORM_INIT) { Limelog("Cleaning up platform..."); cleanupPlatformSockets(); + cleanupPlatformThreads(); stage--; Limelog("done\n"); } @@ -100,6 +101,12 @@ int LiStartConnection(IP_ADDRESS host, PSTREAM_CONFIGURATION streamConfig, PCONN ListenerCallbacks.stageFailed(STAGE_PLATFORM_INIT, err); goto Cleanup; } + err = initializePlatformThreads(); + if (err != 0) { + Limelog("failed: %d\n", err); + ListenerCallbacks.stageFailed(STAGE_PLATFORM_INIT, err); + goto Cleanup; + } stage++; LC_ASSERT(stage == STAGE_PLATFORM_INIT); ListenerCallbacks.stageComplete(STAGE_PLATFORM_INIT); diff --git a/limelight-common/Limelight-internal.h b/limelight-common/Limelight-internal.h index 706aa15..33a2150 100644 --- a/limelight-common/Limelight-internal.h +++ b/limelight-common/Limelight-internal.h @@ -3,6 +3,7 @@ #include "Limelight.h" #include "Platform.h" #include "PlatformSockets.h" +#include "PlatformThreads.h" #include "Video.h" char* allocateConfigDataForStreamConfig(PSTREAM_CONFIGURATION streamConfig); diff --git a/limelight-common/PlatformThreads.c b/limelight-common/PlatformThreads.c index 592aef1..8113912 100644 --- a/limelight-common/PlatformThreads.c +++ b/limelight-common/PlatformThreads.c @@ -268,3 +268,18 @@ int PltWaitForEvent(PLT_EVENT *event) { return PLT_WAIT_SUCCESS; #endif } + +int initializePlatformThreads(void) { +#if defined(LC_WINDOWS) || defined(LC_WINDOWS_PHONE) + return PltCreateMutex(&thread_list_lock); +#else + return 0; +#endif +} + +void cleanupPlatformThreads(void) { +#if defined(LC_WINDOWS) || defined(LC_WINDOWS_PHONE) + PltDeleteMutex(&thread_list_lock); +#else +#endif +} \ No newline at end of file diff --git a/limelight-common/PlatformThreads.h b/limelight-common/PlatformThreads.h index 1b25c3e..dec8841 100644 --- a/limelight-common/PlatformThreads.h +++ b/limelight-common/PlatformThreads.h @@ -42,6 +42,9 @@ CreateThread( ); #endif +int initializePlatformThreads(void); +void cleanupPlatformThreads(void); + int PltCreateMutex(PLT_MUTEX *mutex); void PltDeleteMutex(PLT_MUTEX *mutex); void PltLockMutex(PLT_MUTEX *mutex);