From f8df5030e19c778cfb310ac3d34e82395f72f7e9 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 28 May 2015 06:23:19 -0500 Subject: [PATCH] Platform code cleanup --- limelight-common/Connection.c | 11 ++--------- .../{PlatformThreads.c => Platform.c} | 16 ++++++++++++++-- limelight-common/Platform.h | 5 ++++- limelight-common/PlatformSockets.h | 4 +--- limelight-common/PlatformThreads.h | 3 --- limelight-common/limelight-common.vcxproj | 2 +- .../limelight-common.vcxproj.filters | 6 +++--- 7 files changed, 25 insertions(+), 22 deletions(-) rename limelight-common/{PlatformThreads.c => Platform.c} (96%) diff --git a/limelight-common/Connection.c b/limelight-common/Connection.c index 75d5e3d..1b3aaf5 100644 --- a/limelight-common/Connection.c +++ b/limelight-common/Connection.c @@ -93,8 +93,7 @@ void LiStopConnection(void) { } if (stage == STAGE_PLATFORM_INIT) { Limelog("Cleaning up platform..."); - cleanupPlatformSockets(); - cleanupPlatformThreads(); + cleanupPlatform(); stage--; Limelog("done\n"); } @@ -139,13 +138,7 @@ int LiStartConnection(IP_ADDRESS host, PSTREAM_CONFIGURATION streamConfig, PCONN Limelog("Initializing platform..."); listenerCallbacks.stageStarting(STAGE_PLATFORM_INIT); - err = initializePlatformSockets(); - if (err != 0) { - Limelog("failed: %d\n", err); - listenerCallbacks.stageFailed(STAGE_PLATFORM_INIT, err); - goto Cleanup; - } - err = initializePlatformThreads(); + err = initializePlatform(); if (err != 0) { Limelog("failed: %d\n", err); listenerCallbacks.stageFailed(STAGE_PLATFORM_INIT, err); diff --git a/limelight-common/PlatformThreads.c b/limelight-common/Platform.c similarity index 96% rename from limelight-common/PlatformThreads.c rename to limelight-common/Platform.c index 78404b9..5873527 100644 --- a/limelight-common/PlatformThreads.c +++ b/limelight-common/Platform.c @@ -1,6 +1,9 @@ #include "PlatformThreads.h" #include "Platform.h" +int initializePlatformSockets(void); +void cleanupPlatformSockets(void); + #if defined(LC_WINDOWS_PHONE) || defined(LC_WINDOWS) CHAR DbgBuf[512]; #endif @@ -307,7 +310,14 @@ int PltWaitForEvent(PLT_EVENT *event) { #endif } -int initializePlatformThreads(void) { +int initializePlatform(void) { + int err; + + err = initializePlatformSockets(); + if (err != 0) { + return err; + } + #if defined(LC_WINDOWS) || defined(LC_WINDOWS_PHONE) return PltCreateMutex(&thread_list_lock); #else @@ -315,7 +325,9 @@ int initializePlatformThreads(void) { #endif } -void cleanupPlatformThreads(void) { +void cleanupPlatform(void) { + cleanupPlatformSockets(); + #if defined(LC_WINDOWS) || defined(LC_WINDOWS_PHONE) LC_ASSERT(pending_thread_head == NULL); LC_ASSERT(thread_head == NULL); diff --git a/limelight-common/Platform.h b/limelight-common/Platform.h index be1b5d4..ebf8d7b 100644 --- a/limelight-common/Platform.h +++ b/limelight-common/Platform.h @@ -45,4 +45,7 @@ extern PLATFORM_CALLBACKS platformCallbacks; _ASSERTE(x) #else #define LC_ASSERT(x) -#endif \ No newline at end of file +#endif + +int initializePlatform(void); +void cleanupPlatform(void); \ No newline at end of file diff --git a/limelight-common/PlatformSockets.h b/limelight-common/PlatformSockets.h index f101872..2d03a1b 100644 --- a/limelight-common/PlatformSockets.h +++ b/limelight-common/PlatformSockets.h @@ -32,6 +32,4 @@ typedef ssize_t SOCK_RET; SOCKET connectTcpSocket(IP_ADDRESS dstaddr, unsigned short port); SOCKET bindUdpSocket(void); -int enableNoDelay(SOCKET s); -int initializePlatformSockets(void); -void cleanupPlatformSockets(void); \ No newline at end of file +int enableNoDelay(SOCKET s); \ No newline at end of file diff --git a/limelight-common/PlatformThreads.h b/limelight-common/PlatformThreads.h index d12daac..4c29246 100644 --- a/limelight-common/PlatformThreads.h +++ b/limelight-common/PlatformThreads.h @@ -35,9 +35,6 @@ typedef struct _PLT_EVENT { #error Unsupported platform #endif -int initializePlatformThreads(void); -void cleanupPlatformThreads(void); - int PltCreateMutex(PLT_MUTEX *mutex); void PltDeleteMutex(PLT_MUTEX *mutex); void PltLockMutex(PLT_MUTEX *mutex); diff --git a/limelight-common/limelight-common.vcxproj b/limelight-common/limelight-common.vcxproj index 85c6aa3..c276297 100644 --- a/limelight-common/limelight-common.vcxproj +++ b/limelight-common/limelight-common.vcxproj @@ -141,7 +141,7 @@ - + diff --git a/limelight-common/limelight-common.vcxproj.filters b/limelight-common/limelight-common.vcxproj.filters index 672f0bc..adf2cec 100644 --- a/limelight-common/limelight-common.vcxproj.filters +++ b/limelight-common/limelight-common.vcxproj.filters @@ -33,9 +33,6 @@ Source Files - - Source Files - Source Files @@ -66,6 +63,9 @@ Source Files + + Source Files +