From b101af4569f9e7fee2143c0b80fcbf6641055853 Mon Sep 17 00:00:00 2001 From: casey langen Date: Wed, 15 Feb 2017 17:48:11 -0800 Subject: [PATCH] Hopefully fixes thread local issues in older versions of macOS. --- src/contrib/websocket_remote/main.cpp | 30 +++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/contrib/websocket_remote/main.cpp b/src/contrib/websocket_remote/main.cpp index fb2252519..e8d8ee749 100644 --- a/src/contrib/websocket_remote/main.cpp +++ b/src/contrib/websocket_remote/main.cpp @@ -1,16 +1,9 @@ #include -#ifdef WIN32 - #include - #include - #include - #include -#else - #include - #include - #include - #include -#endif +#include +#include +#include +#include #include #include @@ -28,9 +21,9 @@ #include #ifdef WIN32 - #define DLL_EXPORT __declspec(dllexport) +#define DLL_EXPORT __declspec(dllexport) #else - #define DLL_EXPORT +#define DLL_EXPORT #endif #define DEFAULT_PORT 9002 @@ -57,6 +50,12 @@ static IPreferences* preferences = nullptr; static ISimpleDataProvider* dataProvider = nullptr; static int nextId = 0; +#ifdef __APPLE__ +__thread char threadLocalBuffer[4096]; +#else +thread_local char threadLocalBuffer[4096]; +#endif + namespace prefs { static const std::string port = "port"; } @@ -790,9 +789,8 @@ class PlaybackRemote : public IPlaybackRemote { template std::string GetMetadataString(MetadataT* metadata, const std::string& key) { - thread_local char buffer[4096]; - metadata->GetValue(key.c_str(), buffer, sizeof(buffer)); - return std::string(buffer); + metadata->GetValue(key.c_str(), threadLocalBuffer, sizeof(threadLocalBuffer)); + return std::string(threadLocalBuffer); } template