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