mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-07-01 07:15:39 +00:00
Fix thread sanitizer warnings with C11 atomics
This commit is contained in:
parent
ce546b12b0
commit
5cbd555b14
@ -3,7 +3,7 @@
|
||||
|
||||
static int stage = STAGE_NONE;
|
||||
static ConnListenerConnectionTerminated originalTerminationCallback;
|
||||
static bool alreadyTerminated;
|
||||
static atomic_bool alreadyTerminated;
|
||||
static PLT_THREAD terminationCallbackThread;
|
||||
static int terminationCallbackErrorCode;
|
||||
|
||||
@ -17,7 +17,7 @@ CONNECTION_LISTENER_CALLBACKS ListenerCallbacks;
|
||||
DECODER_RENDERER_CALLBACKS VideoCallbacks;
|
||||
AUDIO_RENDERER_CALLBACKS AudioCallbacks;
|
||||
int NegotiatedVideoFormat;
|
||||
volatile bool ConnectionInterrupted;
|
||||
atomic_bool ConnectionInterrupted;
|
||||
bool HighQualitySurroundSupported;
|
||||
bool HighQualitySurroundEnabled;
|
||||
OPUS_MULTISTREAM_CONFIGURATION NormalQualityOpusConfig;
|
||||
|
@ -33,9 +33,9 @@ static PLT_THREAD invalidateRefFramesThread;
|
||||
static PLT_THREAD controlReceiveThread;
|
||||
static PLT_EVENT invalidateRefFramesEvent;
|
||||
static int lossCountSinceLastReport;
|
||||
static int lastGoodFrame;
|
||||
static int lastSeenFrame;
|
||||
static bool stopping;
|
||||
static atomic_int lastGoodFrame;
|
||||
static atomic_int lastSeenFrame;
|
||||
static atomic_bool stopping;
|
||||
static bool disconnectPending;
|
||||
|
||||
static int intervalGoodFrameCount;
|
||||
@ -44,7 +44,7 @@ static uint64_t intervalStartTimeMs;
|
||||
static int lastIntervalLossPercentage;
|
||||
static int lastConnectionStatusUpdate;
|
||||
|
||||
static bool idrFrameRequired;
|
||||
static atomic_bool idrFrameRequired;
|
||||
static LINKED_BLOCKING_QUEUE invalidReferenceFrameTuples;
|
||||
|
||||
#define CONN_IMMEDIATE_POOR_LOSS_RATE 30
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
static SOCKET inputSock = INVALID_SOCKET;
|
||||
static unsigned char currentAesIv[16];
|
||||
static bool initialized;
|
||||
static atomic_bool initialized;
|
||||
static EVP_CIPHER_CTX* cipherContext;
|
||||
static bool cipherInitialized;
|
||||
|
||||
|
@ -19,7 +19,7 @@ extern CONNECTION_LISTENER_CALLBACKS ListenerCallbacks;
|
||||
extern DECODER_RENDERER_CALLBACKS VideoCallbacks;
|
||||
extern AUDIO_RENDERER_CALLBACKS AudioCallbacks;
|
||||
extern int NegotiatedVideoFormat;
|
||||
extern volatile bool ConnectionInterrupted;
|
||||
extern atomic_bool ConnectionInterrupted;
|
||||
extern bool HighQualitySurroundSupported;
|
||||
extern bool HighQualitySurroundEnabled;
|
||||
extern OPUS_MULTISTREAM_CONFIGURATION NormalQualityOpusConfig;
|
||||
|
@ -106,7 +106,7 @@ int LbqPeekQueueElement(PLINKED_BLOCKING_QUEUE queueHead, void** data) {
|
||||
return LBQ_INTERRUPTED;
|
||||
}
|
||||
|
||||
if (queueHead->head == NULL) {
|
||||
if (queueHead->currentSize == 0) {
|
||||
return LBQ_NO_ELEMENT;
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ int LbqPollQueueElement(PLINKED_BLOCKING_QUEUE queueHead, void** data) {
|
||||
return LBQ_INTERRUPTED;
|
||||
}
|
||||
|
||||
if (queueHead->head == NULL) {
|
||||
if (queueHead->currentSize == 0) {
|
||||
return LBQ_NO_ELEMENT;
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,8 @@ typedef struct _LINKED_BLOCKING_QUEUE {
|
||||
PLT_MUTEX mutex;
|
||||
PLT_EVENT containsDataEvent;
|
||||
int sizeBound;
|
||||
int currentSize;
|
||||
bool shutdown;
|
||||
atomic_int currentSize;
|
||||
atomic_bool shutdown;
|
||||
int lifetimeSize;
|
||||
PLINKED_BLOCKING_QUEUE_ENTRY head;
|
||||
PLINKED_BLOCKING_QUEUE_ENTRY tail;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdatomic.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
@ -10,18 +10,18 @@ typedef HANDLE PLT_MUTEX;
|
||||
typedef HANDLE PLT_EVENT;
|
||||
typedef struct _PLT_THREAD {
|
||||
HANDLE handle;
|
||||
bool cancelled;
|
||||
atomic_bool cancelled;
|
||||
} PLT_THREAD;
|
||||
#elif defined(__vita__)
|
||||
typedef int PLT_MUTEX;
|
||||
typedef struct _PLT_EVENT {
|
||||
int mutex;
|
||||
int cond;
|
||||
bool signalled;
|
||||
atomic_bool signalled;
|
||||
} PLT_EVENT;
|
||||
typedef struct _PLT_THREAD {
|
||||
int handle;
|
||||
int cancelled;
|
||||
atomic_bool cancelled;
|
||||
void *context;
|
||||
bool alive;
|
||||
} PLT_THREAD;
|
||||
@ -30,11 +30,11 @@ typedef pthread_mutex_t PLT_MUTEX;
|
||||
typedef struct _PLT_EVENT {
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
bool signalled;
|
||||
atomic_bool signalled;
|
||||
} PLT_EVENT;
|
||||
typedef struct _PLT_THREAD {
|
||||
pthread_t thread;
|
||||
bool cancelled;
|
||||
atomic_bool cancelled;
|
||||
} PLT_THREAD;
|
||||
#else
|
||||
#error Unsupported platform
|
||||
|
@ -22,7 +22,7 @@ static PLT_THREAD decoderThread;
|
||||
|
||||
static bool receivedDataFromPeer;
|
||||
static uint64_t firstDataTimeMs;
|
||||
static bool receivedFullFrame;
|
||||
static atomic_bool receivedFullFrame;
|
||||
|
||||
// We can't request an IDR frame until the depacketizer knows
|
||||
// that a packet was lost. This timeout bounds the time that
|
||||
|
Loading…
x
Reference in New Issue
Block a user