mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 06:01:13 +00:00
Only interact with the AVSampleBufferDisplayLayer on the main thread
This commit is contained in:
@@ -324,6 +324,7 @@ void ClLogMessage(const char* format, ...)
|
|||||||
LiInitializeVideoCallbacks(&_drCallbacks);
|
LiInitializeVideoCallbacks(&_drCallbacks);
|
||||||
_drCallbacks.setup = DrDecoderSetup;
|
_drCallbacks.setup = DrDecoderSetup;
|
||||||
_drCallbacks.submitDecodeUnit = DrSubmitDecodeUnit;
|
_drCallbacks.submitDecodeUnit = DrSubmitDecodeUnit;
|
||||||
|
_drCallbacks.capabilities = CAPABILITY_DIRECT_SUBMIT;
|
||||||
|
|
||||||
// RFI doesn't work properly with HEVC on iOS 11 with an iPhone SE (at least)
|
// RFI doesn't work properly with HEVC on iOS 11 with an iPhone SE (at least)
|
||||||
// It doesnt work on macOS either, tested with Network Link Conditioner.
|
// It doesnt work on macOS either, tested with Network Link Conditioner.
|
||||||
|
|||||||
@@ -269,8 +269,13 @@
|
|||||||
if (displayLayer.status == AVQueuedSampleBufferRenderingStatusFailed) {
|
if (displayLayer.status == AVQueuedSampleBufferRenderingStatusFailed) {
|
||||||
Log(LOG_E, @"Display layer rendering failed: %@", displayLayer.error);
|
Log(LOG_E, @"Display layer rendering failed: %@", displayLayer.error);
|
||||||
|
|
||||||
// Recreate the display layer
|
// Recreate the display layer on the main thread.
|
||||||
[self reinitializeDisplayLayer];
|
// We need to use dispatch_sync() or we may miss
|
||||||
|
// some parameter sets while the layer is being
|
||||||
|
// recreated.
|
||||||
|
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||||
|
[self reinitializeDisplayLayer];
|
||||||
|
});
|
||||||
|
|
||||||
// Request an IDR frame to initialize the new decoder
|
// Request an IDR frame to initialize the new decoder
|
||||||
free(data);
|
free(data);
|
||||||
@@ -338,13 +343,18 @@
|
|||||||
CFDictionarySetValue(dict, kCMSampleAttachmentKey_DependsOnOthers, kCFBooleanFalse);
|
CFDictionarySetValue(dict, kCMSampleAttachmentKey_DependsOnOthers, kCFBooleanFalse);
|
||||||
}
|
}
|
||||||
|
|
||||||
[displayLayer enqueueSampleBuffer:sampleBuffer];
|
|
||||||
#if !TARGET_OS_IPHONE
|
#if !TARGET_OS_IPHONE
|
||||||
_view.frameCount++;
|
_view.frameCount++;
|
||||||
#endif
|
#endif
|
||||||
// Dereference the buffers
|
|
||||||
CFRelease(blockBuffer);
|
// Enqueue video samples on the main thread
|
||||||
CFRelease(sampleBuffer);
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self->displayLayer enqueueSampleBuffer:sampleBuffer];
|
||||||
|
|
||||||
|
// Dereference the buffers
|
||||||
|
CFRelease(blockBuffer);
|
||||||
|
CFRelease(sampleBuffer);
|
||||||
|
});
|
||||||
|
|
||||||
return DR_OK;
|
return DR_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user