mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-17 17:05:50 +00:00
Fix queued packet leak when audio packet queue overflows
This commit is contained in:
parent
e9fd544ff4
commit
ef33aaa3c8
@ -135,6 +135,7 @@ void destroyAudioStream(void) {
|
||||
static bool queuePacketToLbq(PQUEUED_AUDIO_PACKET* packet) {
|
||||
int err;
|
||||
|
||||
do {
|
||||
err = LbqOfferQueueItem(&packetQueue, *packet, &(*packet)->header.lentry);
|
||||
if (err == LBQ_SUCCESS) {
|
||||
// The LBQ owns the buffer now
|
||||
@ -142,13 +143,13 @@ static bool queuePacketToLbq(PQUEUED_AUDIO_PACKET* packet) {
|
||||
}
|
||||
else if (err == LBQ_BOUND_EXCEEDED) {
|
||||
Limelog("Audio packet queue overflow\n");
|
||||
|
||||
// The audio queue is full, so free all existing items and try again
|
||||
freePacketList(LbqFlushQueueItems(&packetQueue));
|
||||
}
|
||||
else if (err == LBQ_INTERRUPTED) {
|
||||
return false;
|
||||
}
|
||||
} while (err == LBQ_BOUND_EXCEEDED);
|
||||
|
||||
return true;
|
||||
return err == LBQ_SUCCESS;
|
||||
}
|
||||
|
||||
static void decodeInputData(PQUEUED_AUDIO_PACKET packet) {
|
||||
@ -309,6 +310,10 @@ static void ReceiveThreadProc(void* context) {
|
||||
// An exit signal was received
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// Ownership should have been taken by the LBQ
|
||||
LC_ASSERT(packet == NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
decodeInputData(packet);
|
||||
@ -331,8 +336,13 @@ static void ReceiveThreadProc(void* context) {
|
||||
if ((AudioCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
||||
if (!queuePacketToLbq(&queuedPacket)) {
|
||||
// An exit signal was received
|
||||
free(queuedPacket);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// Ownership should have been taken by the LBQ
|
||||
LC_ASSERT(queuedPacket == NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
decodeInputData(queuedPacket);
|
||||
|
Loading…
x
Reference in New Issue
Block a user