mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-11-27 16:24:02 +00:00
Fix potential leaks on queue shutdown
This commit is contained in:
1 parent
bf71226754
commit
348d5d1e32
2 files changed
+26
-10
No files matched your search
+13
-6
@@ -405,14 +405,17 @@ static void queueFrameInvalidationTuple(uint32_t startFrame, uint32_t endFrame)
|
||||
PQUEUED_REFERENCE_FRAME_CONTROL qfit;
|
||||
qfit = malloc(sizeof(*qfit));
|
||||
if (qfit != NULL) {
|
||||
int err;
|
||||
|
||||
*qfit = (QUEUED_REFERENCE_FRAME_CONTROL){
|
||||
.startFrame = startFrame,
|
||||
.endFrame = endFrame,
|
||||
.invalidate = true,
|
||||
};
|
||||
if (LbqOfferQueueItem(&referenceFrameControlQueue, qfit, &qfit->entry) == LBQ_BOUND_EXCEEDED) {
|
||||
// Too many invalidation tuples, so we need an IDR frame now
|
||||
Limelog("RFI range list reached maximum size limit\n");
|
||||
|
||||
err = LbqOfferQueueItem(&referenceFrameControlQueue, qfit, &qfit->entry);
|
||||
if (err != LBQ_SUCCESS) {
|
||||
Limelog("Failed to queue RFI range: %d\n", err);
|
||||
free(qfit);
|
||||
LiRequestIdrFrame();
|
||||
}
|
||||
@@ -452,14 +455,18 @@ void connectionReceivedCompleteFrame(uint32_t frameIndex, bool frameIsLTR) {
|
||||
PQUEUED_REFERENCE_FRAME_CONTROL qfit;
|
||||
qfit = malloc(sizeof(*qfit));
|
||||
if (qfit != NULL) {
|
||||
int err;
|
||||
|
||||
*qfit = (QUEUED_REFERENCE_FRAME_CONTROL){
|
||||
.startFrame = frameIndex,
|
||||
.invalidate = false,
|
||||
};
|
||||
if (LbqOfferQueueItem(&referenceFrameControlQueue, qfit, &qfit->entry) == LBQ_BOUND_EXCEEDED) {
|
||||
|
||||
err = LbqOfferQueueItem(&referenceFrameControlQueue, qfit, &qfit->entry);
|
||||
if (err != LBQ_SUCCESS) {
|
||||
// This shouldn't happen and indicates that something has gone wrong with the queue
|
||||
LC_ASSERT(false);
|
||||
Limelog("Couldn't queue LTR ACK because the list has reached maximum size limit\n");
|
||||
Limelog("Couldn't queue LTR ACK: %d\n", err);
|
||||
free(qfit);
|
||||
LiRequestIdrFrame();
|
||||
}
|
||||
@@ -477,7 +484,7 @@ void connectionSendFrameFecStatus(PSS_FRAME_FEC_STATUS fecStatus) {
|
||||
PQUEUED_FRAME_FEC_STATUS queuedFecStatus = malloc(sizeof(*queuedFecStatus));
|
||||
if (queuedFecStatus != NULL) {
|
||||
queuedFecStatus->fecStatus = *fecStatus;
|
||||
if (LbqOfferQueueItem(&frameFecStatusQueue, queuedFecStatus, &queuedFecStatus->entry) == LBQ_BOUND_EXCEEDED) {
|
||||
if (LbqOfferQueueItem(&frameFecStatusQueue, queuedFecStatus, &queuedFecStatus->entry) != LBQ_SUCCESS) {
|
||||
free(queuedFecStatus);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-4
@@ -538,8 +538,14 @@ static void reassembleFrame(int frameNumber, bool frameIsLTR) {
|
||||
nalChainFragmentCount = 0;
|
||||
|
||||
if ((VideoCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
||||
if (LbqOfferQueueItem(&decodeUnitQueue, qdu, &qdu->entry) == LBQ_BOUND_EXCEEDED) {
|
||||
Limelog("Video decode unit queue overflow\n");
|
||||
int err = LbqOfferQueueItem(&decodeUnitQueue, qdu, &qdu->entry);
|
||||
if (err != LBQ_SUCCESS) {
|
||||
if (err == LBQ_BOUND_EXCEEDED) {
|
||||
Limelog("Video decode unit queue overflow\n");
|
||||
}
|
||||
else {
|
||||
Limelog("Failed to queue video decode unit: %d\n", err);
|
||||
}
|
||||
|
||||
// RFI recovery is not supported here
|
||||
waitingForIdrFrame = true;
|
||||
@@ -555,8 +561,11 @@ static void reassembleFrame(int frameNumber, bool frameIsLTR) {
|
||||
// Free all frames in the decode unit queue
|
||||
freeDecodeUnitList(LbqFlushQueueItems(&decodeUnitQueue));
|
||||
|
||||
// Request an IDR frame to recover
|
||||
LiRequestIdrFrame();
|
||||
// Request an IDR frame to recover if we're not shutting down
|
||||
if (err != LBQ_INTERRUPTED) {
|
||||
LiRequestIdrFrame();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user