fix: metal renderer stuck when disconnect and resume stream
This commit is contained in:
@@ -125,6 +125,7 @@ extern int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
|
||||
|
||||
_parameterSetBuffers = [[NSMutableArray alloc] init];
|
||||
_frameQueue = [FrameQueue sharedInstance];
|
||||
[_frameQueue start];
|
||||
_maxRefreshRate = [[UIScreen mainScreen] maximumFramesPerSecond];
|
||||
|
||||
DataManager* dataMan = [[DataManager alloc] init];
|
||||
|
||||
@@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (int)currentSoftCap;
|
||||
- (void)waitForEnqueue;
|
||||
- (void)shutdown;
|
||||
- (void)start;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -287,10 +287,15 @@
|
||||
return [self count] == 0;
|
||||
}
|
||||
|
||||
- (void)clear {
|
||||
os_unfair_lock_lock(&_lock);
|
||||
- (void)_clear_unsafe {
|
||||
_head = _tail = _count = 0;
|
||||
_frameDropMetrics = [[FloatBuffer alloc] initWithCapacity:512];
|
||||
}
|
||||
|
||||
// The public clear method now safely calls the unsafe version.
|
||||
- (void)clear {
|
||||
os_unfair_lock_lock(&_lock);
|
||||
[self _clear_unsafe];
|
||||
os_unfair_lock_unlock(&_lock);
|
||||
}
|
||||
|
||||
@@ -331,6 +336,14 @@
|
||||
dispatch_semaphore_signal(_frameSemaphore);
|
||||
}
|
||||
|
||||
- (void)start {
|
||||
os_unfair_lock_lock(&_lock);
|
||||
[self _clear_unsafe]; // Use the version without the lock
|
||||
self.isStopping = NO;
|
||||
os_unfair_lock_unlock(&_lock);
|
||||
Log(LOG_I, @"FrameQueue (re)started");
|
||||
}
|
||||
|
||||
// For use with NSLog("%@", franeQueue);
|
||||
- (NSString *)description {
|
||||
__block NSMutableArray *parts = [NSMutableArray arrayWithCapacity:_count];
|
||||
|
||||
@@ -745,7 +745,9 @@
|
||||
_inactivityTimer = nil;
|
||||
}
|
||||
if (self.metalViewController) {
|
||||
[self.metalViewController shutdown];
|
||||
[self.metalViewController.view removeFromSuperview];
|
||||
[self.metalViewController removeFromParentViewController];
|
||||
self.metalViewController = nil;
|
||||
NSLog(@"Metal renderer stopped and cleaned up.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user