mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-11-29 01:04:41 +00:00
Redesign the RTP stats APIs to be race-free
We now accumulate the stats internally via atomic operations and copy them into the caller's buffer when requested. While we could expose the atomic fields in the public ABI, we want to avoid this due to MSVC's C11 atomic implementation having no ABI guarantees with the /experimental flag.
This commit is contained in:
1 parent
08ebedb8aa
commit
541e396833
7 files changed
+76
-24
No files matched your search
+14
-1
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "Video.h"
|
||||
|
||||
#include <stdatomic.h>
|
||||
|
||||
typedef struct _RTPV_QUEUE_ENTRY {
|
||||
struct _RTPV_QUEUE_ENTRY* next;
|
||||
struct _RTPV_QUEUE_ENTRY* prev;
|
||||
@@ -19,6 +21,16 @@ typedef struct _RTPV_QUEUE_LIST {
|
||||
uint32_t count;
|
||||
} RTPV_QUEUE_LIST, *PRTPV_QUEUE_LIST;
|
||||
|
||||
typedef struct _RTP_VIDEO_QUEUE_STATS {
|
||||
atomic_uint packetCountVideo;
|
||||
atomic_uint packetCountFec;
|
||||
atomic_uint packetCountFecRecovered;
|
||||
atomic_uint packetCountFecFailed;
|
||||
atomic_uint packetCountOOS;
|
||||
atomic_uint packetCountInvalid;
|
||||
atomic_uint packetCountFecInvalid;
|
||||
} RTP_VIDEO_QUEUE_STATS, *PRTP_VIDEO_QUEUE_STATS;
|
||||
|
||||
typedef struct _RTP_VIDEO_QUEUE {
|
||||
RTPV_QUEUE_LIST pendingFecBlockList;
|
||||
RTPV_QUEUE_LIST completedFecBlockList;
|
||||
@@ -47,7 +59,7 @@ typedef struct _RTP_VIDEO_QUEUE {
|
||||
uint64_t lastOosFramePresentationTimestamp;
|
||||
bool receivedOosData;
|
||||
|
||||
RTP_VIDEO_STATS stats; // the above values are short-lived, this tracks stats for the life of the queue
|
||||
RTP_VIDEO_QUEUE_STATS stats; // the above values are short-lived, this tracks stats for the life of the queue
|
||||
} RTP_VIDEO_QUEUE, *PRTP_VIDEO_QUEUE;
|
||||
|
||||
#define RTPF_RET_QUEUED 0
|
||||
@@ -58,3 +70,4 @@ void RtpvCleanupQueue(PRTP_VIDEO_QUEUE queue);
|
||||
int RtpvAddPacket(PRTP_VIDEO_QUEUE queue, PRTP_PACKET packet, int length, PRTPV_QUEUE_ENTRY packetEntry);
|
||||
uint32_t RtpvGetCurrentFrameNumber(PRTP_VIDEO_QUEUE queue);
|
||||
void RtpvSubmitQueuedPackets(PRTP_VIDEO_QUEUE queue);
|
||||
void RtpvGetStats(PRTP_VIDEO_QUEUE queue, PRTP_VIDEO_STATS stats);
|
||||
Reference in new issue
Block a user