fix: occasional crashes when put in foreground
This commit is contained in:
1 parent
c8f61b0b87
commit
0582655954
2 files changed
+12
No files matched your search
@@ -43,4 +43,6 @@
|
||||
frameType:(int)frameType
|
||||
decodeStartTime:(CFTimeInterval)decodeStartTime;
|
||||
|
||||
- (void)invalidateDecompressionSession;
|
||||
|
||||
@end
|
||||
@@ -98,6 +98,7 @@ extern int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
|
||||
_formatDescImageBuffer = nil;
|
||||
}
|
||||
|
||||
@synchronized(self) {
|
||||
if (_decompressionSession != nil){
|
||||
VTDecompressionSessionWaitForAsynchronousFrames(_decompressionSession);
|
||||
|
||||
@@ -105,6 +106,7 @@ extern int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
|
||||
CFRelease(_decompressionSession);
|
||||
_decompressionSession = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithView:(UIView* )view callbacks:(id<ConnectionCallbacks>)callbacks streamAspectRatio:(float)aspectRatio
|
||||
@@ -174,6 +176,7 @@ extern int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
|
||||
|
||||
|
||||
- (void)setupDecompressionSessionWithAttributes:(NSDictionary *)destinationPixelBufferAttributes {
|
||||
// This method is called from within synchronized block, so no additional sync needed here
|
||||
if (_decompressionSession != NULL) {
|
||||
VTDecompressionSessionInvalidate(_decompressionSession);
|
||||
CFRelease(_decompressionSession);
|
||||
@@ -367,11 +370,13 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
||||
[_displayLink invalidate];
|
||||
}
|
||||
|
||||
@synchronized(self) {
|
||||
if (_decompressionSession != NULL) {
|
||||
VTDecompressionSessionInvalidate(_decompressionSession);
|
||||
CFRelease(_decompressionSession);
|
||||
_decompressionSession = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define NALU_START_PREFIX_SIZE 3
|
||||
@@ -845,6 +850,8 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
||||
frameNumber:(int)frameNumber
|
||||
frameType:(int)frameType
|
||||
decodeStartTime:(CFTimeInterval)decodeStartTime {
|
||||
// Synchronize access to decompression session to prevent race conditions during background/foreground transitions
|
||||
@synchronized(self) {
|
||||
// Check if we need to create/recreate the decompression session
|
||||
BOOL needsNewSession = (frameType == FRAME_TYPE_IDR || _decompressionSession == nil);
|
||||
|
||||
@@ -878,12 +885,14 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
||||
if (status == kVTInvalidSessionErr) {
|
||||
// The session was invalidated by the OS. Destroy our reference
|
||||
// so it gets recreated on the next IDR frame.
|
||||
@synchronized(self) {
|
||||
if (self->_decompressionSession) {
|
||||
VTDecompressionSessionInvalidate(self->_decompressionSession);
|
||||
CFRelease(self->_decompressionSession);
|
||||
self->_decompressionSession = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
LiRequestIdrFrame(); // Request an IDR to restart the stream
|
||||
return;
|
||||
}
|
||||
@@ -949,6 +958,7 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
||||
});
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setHdrMode:(BOOL)enabled {
|
||||
|
||||
Reference in new issue
Block a user