fix: metal renderer black screen
This commit is contained in:
1 parent
5bf218d930
commit
5bcc452c9f
1 file changed
+17
-15
@@ -824,31 +824,34 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
|||||||
frameNumber:(int)frameNumber
|
frameNumber:(int)frameNumber
|
||||||
frameType:(int)frameType
|
frameType:(int)frameType
|
||||||
decodeStartTime:(CFTimeInterval)decodeStartTime {
|
decodeStartTime:(CFTimeInterval)decodeStartTime {
|
||||||
@synchronized(self) {
|
VTDecompressionSessionRef sessionForDecode = NULL;
|
||||||
// If the decompression session is nil, we must decide what to do.
|
@synchronized(self) {
|
||||||
|
// If the session is nil, it can only be created by an IDR frame.
|
||||||
if (_decompressionSession == nil) {
|
if (_decompressionSession == nil) {
|
||||||
// We can only create a session with an IDR frame.
|
|
||||||
if (frameType == FRAME_TYPE_IDR) {
|
if (frameType == FRAME_TYPE_IDR) {
|
||||||
// This is the startup path. Create the session now.
|
|
||||||
[self setupDecompressionSession];
|
[self setupDecompressionSession];
|
||||||
|
|
||||||
// If session creation still fails, we cannot proceed.
|
|
||||||
if (_decompressionSession == nil) {
|
|
||||||
Log(LOG_E, @"Failed to create initial decompression session with IDR frame.");
|
|
||||||
return kVTInvalidSessionErr;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// This happens when resuming from background; we've reset the session
|
// Not an IDR, so we can't create a session. Drop the frame.
|
||||||
// and are waiting for a new IDR frame. Drop all other frames until it arrives.
|
|
||||||
return noErr;
|
return noErr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Also re-create the session if a new IDR frame arrives during an active stream,
|
// If an IDR arrives during a valid session, re-create the session
|
||||||
// as it may contain updated video parameters (e.g., HDR toggled).
|
// in case video parameters have changed.
|
||||||
else if (frameType == FRAME_TYPE_IDR) {
|
else if (frameType == FRAME_TYPE_IDR) {
|
||||||
[self setupDecompressionSession];
|
[self setupDecompressionSession];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If, after trying, the session is still nil, we cannot proceed.
|
||||||
|
if (_decompressionSession == nil) {
|
||||||
|
Log(LOG_E, @"Decompression session is nil after setup attempt. Dropping frame.");
|
||||||
|
return kVTInvalidSessionErr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Capture a strong reference to the session that we can use outside the lock.
|
||||||
|
// This prevents another thread from deallocating it while we're using it.
|
||||||
|
sessionForDecode = (VTDecompressionSessionRef)CFRetain(_decompressionSession);
|
||||||
|
}
|
||||||
|
|
||||||
if (frameType == FRAME_TYPE_IDR && !_hasSentVideoContentShown) {
|
if (frameType == FRAME_TYPE_IDR && !_hasSentVideoContentShown) {
|
||||||
// Tell our parent VC to hide the progress indicator and set up PiP
|
// Tell our parent VC to hide the progress indicator and set up PiP
|
||||||
[_callbacks videoContentShown];
|
[_callbacks videoContentShown];
|
||||||
@@ -1001,7 +1004,6 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
|||||||
});
|
});
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setHdrMode:(BOOL)enabled {
|
- (void)setHdrMode:(BOOL)enabled {
|
||||||
|
|||||||
Reference in new issue
Block a user