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