mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-07-01 23:35:47 +00:00
Fix handling of partial writes and EAGAIN in Amlogic decoder
Fixes spurious codec resets due to EAGAIN errors at 4K during complex scenes.
This commit is contained in:
parent
30b563a2fc
commit
a9302d02f5
@ -92,25 +92,35 @@ void aml_cleanup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int aml_submit_decode_unit(PDECODE_UNIT decodeUnit) {
|
int aml_submit_decode_unit(PDECODE_UNIT decodeUnit) {
|
||||||
int result = DR_OK;
|
|
||||||
PLENTRY entry = decodeUnit->bufferList;
|
PLENTRY entry = decodeUnit->bufferList;
|
||||||
while (entry != NULL) {
|
while (entry != NULL) {
|
||||||
int api = codec_write(&codecParam, entry->data, entry->length);
|
char* data = entry->data;
|
||||||
if (api != entry->length) {
|
int length = entry->length;
|
||||||
fprintf(stderr, "codec_write error: %x\n", api);
|
|
||||||
codec_reset(&codecParam);
|
while (length > 0) {
|
||||||
result = DR_NEED_IDR;
|
int written = codec_write(&codecParam, data, length);
|
||||||
break;
|
if (written > 0) {
|
||||||
|
data += written;
|
||||||
|
length -= written;
|
||||||
|
} else if (errno == EAGAIN) {
|
||||||
|
usleep(500);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "codec_write() failed: %d\n", errno);
|
||||||
|
codec_reset(&codecParam);
|
||||||
|
return DR_NEED_IDR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = entry->next;
|
entry = entry->next;
|
||||||
}
|
}
|
||||||
return result;
|
return DR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECODER_RENDERER_CALLBACKS decoder_callbacks_aml = {
|
DECODER_RENDERER_CALLBACKS decoder_callbacks_aml = {
|
||||||
.setup = aml_setup,
|
.setup = aml_setup,
|
||||||
.cleanup = aml_cleanup,
|
.cleanup = aml_cleanup,
|
||||||
.submitDecodeUnit = aml_submit_decode_unit,
|
.submitDecodeUnit = aml_submit_decode_unit,
|
||||||
.capabilities = CAPABILITY_DIRECT_SUBMIT | CAPABILITY_SLICES_PER_FRAME(8),
|
|
||||||
|
// We may delay in aml_submit_decode_unit() for a while, so we can't set CAPABILITY_DIRECT_SUBMIT
|
||||||
|
.capabilities = CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user