mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-17 17:05:50 +00:00
Fix memory leak when switching between immediate and queued audio packets
This commit is contained in:
parent
4aa82b0a9f
commit
3dff15b8c4
@ -288,24 +288,25 @@ static void ReceiveThreadProc(void* context) {
|
|||||||
if (RTPQ_PACKET_READY(queueStatus)) {
|
if (RTPQ_PACKET_READY(queueStatus)) {
|
||||||
// If packets are ready, pull them and send them to the decoder
|
// If packets are ready, pull them and send them to the decoder
|
||||||
uint16_t length;
|
uint16_t length;
|
||||||
while ((packet = (PQUEUED_AUDIO_PACKET)RtpaGetQueuedPacket(&rtpAudioQueue, sizeof(QUEUED_AUDIO_PACKET_HEADER), &length)) != NULL) {
|
PQUEUED_AUDIO_PACKET queuedPacket;
|
||||||
|
while ((queuedPacket = (PQUEUED_AUDIO_PACKET)RtpaGetQueuedPacket(&rtpAudioQueue, sizeof(QUEUED_AUDIO_PACKET_HEADER), &length)) != NULL) {
|
||||||
// Populate header data (not preserved in queued packets)
|
// Populate header data (not preserved in queued packets)
|
||||||
packet->header.size = length;
|
queuedPacket->header.size = length;
|
||||||
|
|
||||||
if ((AudioCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
if ((AudioCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
||||||
if (!queuePacketToLbq(&packet)) {
|
if (!queuePacketToLbq(&queuedPacket)) {
|
||||||
// An exit signal was received
|
// An exit signal was received
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
decodeInputData(packet);
|
decodeInputData(queuedPacket);
|
||||||
free(packet);
|
free(queuedPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Break on exit
|
// Break on exit
|
||||||
if (packet != NULL) {
|
if (queuedPacket != NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user