Revert "fix: pip video freeze"

This reverts commit 0473233775.
This commit is contained in:
Acaki committed 2025-07-12 11:41:57 +08:00
1 parent a69d7eaede
commit 487f987c25
1 file changed
+12 -5
+12 -5
View File
@@ -39,11 +39,10 @@ extern int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
- (void)reinitializeDisplayLayer - (void)reinitializeDisplayLayer
{ {
if (_displayLayer == nil) { CALayer *oldLayer = _displayLayer;
_displayLayer = [[AVSampleBufferDisplayLayer alloc] init];
_displayLayer.backgroundColor = [UIColor blackColor].CGColor; _displayLayer = [[AVSampleBufferDisplayLayer alloc] init];
[_view.layer addSublayer:_displayLayer]; _displayLayer.backgroundColor = [UIColor blackColor].CGColor;
}
// Ensure the AVSampleBufferDisplayLayer is sized to preserve the aspect ratio // Ensure the AVSampleBufferDisplayLayer is sized to preserve the aspect ratio
// of the video stream. We used to use AVLayerVideoGravityResizeAspect, but that // of the video stream. We used to use AVLayerVideoGravityResizeAspect, but that
@@ -64,6 +63,14 @@ extern int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
// can see the loading progress label as the stream is starting. // can see the loading progress label as the stream is starting.
_displayLayer.hidden = YES; _displayLayer.hidden = YES;
if (oldLayer != nil) {
// Switch out the old display layer with the new one
[_view.layer replaceSublayer:oldLayer with:_displayLayer];
}
else {
[_view.layer addSublayer:_displayLayer];
}
if (formatDesc != nil) { if (formatDesc != nil) {
CFRelease(formatDesc); CFRelease(formatDesc);
formatDesc = nil; formatDesc = nil;