stop video render when app enters background without pip enabled for balanced mode
This commit is contained in:
1 parent
f5b56ca67f
commit
4a9e109de5
3 files changed
+14
-3
No files matched your search
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
@property (atomic, readonly) PlotMetrics decodeMetrics;
|
@property (atomic, readonly) PlotMetrics decodeMetrics;
|
||||||
@property (atomic, readonly) PlotMetrics frameQueueMetrics;
|
@property (atomic, readonly) PlotMetrics frameQueueMetrics;
|
||||||
|
@property (atomic, assign) bool appDidEnterBackgroundWithoutPiP;
|
||||||
|
|
||||||
@property (nonatomic, strong, readonly) AVSampleBufferDisplayLayer *displayLayer;
|
@property (nonatomic, strong, readonly) AVSampleBufferDisplayLayer *displayLayer;
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,9 @@ extern int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size,
|
|||||||
{
|
{
|
||||||
NSLog(@"initializing video decoder %f", CACurrentMediaTime());
|
NSLog(@"initializing video decoder %f", CACurrentMediaTime());
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
|
_appDidEnterBackgroundWithoutPiP = false;
|
||||||
|
|
||||||
_sq = dispatch_queue_create("com.moonlight.VideoDecoderRenderer",
|
_sq = dispatch_queue_create("com.moonlight.VideoDecoderRenderer",
|
||||||
dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INTERACTIVE, 0));
|
dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INTERACTIVE, 0));
|
||||||
|
|
||||||
@@ -263,6 +265,7 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
|||||||
// DisplayLink calls us every vsync we we try to present the most recent frame. We try to maintain a user-configurable buffer
|
// DisplayLink calls us every vsync we we try to present the most recent frame. We try to maintain a user-configurable buffer
|
||||||
// of 1-5 frames. If the buffer is full, every other frame is dropped which just appears to the user as a lower framerate stream.
|
// of 1-5 frames. If the buffer is full, every other frame is dropped which just appears to the user as a lower framerate stream.
|
||||||
- (void)renderModeAVSB:(CADisplayLink *)link {
|
- (void)renderModeAVSB:(CADisplayLink *)link {
|
||||||
|
|
||||||
CFTimeInterval start = link.timestamp;
|
CFTimeInterval start = link.timestamp;
|
||||||
CFTimeInterval deadline = link.targetTimestamp;
|
CFTimeInterval deadline = link.targetTimestamp;
|
||||||
static CFTimeInterval lastTargetLocal = 0.0f;
|
static CFTimeInterval lastTargetLocal = 0.0f;
|
||||||
@@ -326,6 +329,8 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
|||||||
// Legacy frame pacing callback - matches upstream/Integration behavior exactly
|
// Legacy frame pacing callback - matches upstream/Integration behavior exactly
|
||||||
- (void)displayLinkCallback:(CADisplayLink *)sender
|
- (void)displayLinkCallback:(CADisplayLink *)sender
|
||||||
{
|
{
|
||||||
|
if(_appDidEnterBackgroundWithoutPiP) return;
|
||||||
|
|
||||||
VIDEO_FRAME_HANDLE handle;
|
VIDEO_FRAME_HANDLE handle;
|
||||||
PDECODE_UNIT du;
|
PDECODE_UNIT du;
|
||||||
|
|
||||||
@@ -374,7 +379,7 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
|||||||
Log(LOG_I, @"Setting timebase for stream to %d / %d", pts.value, pts.timescale);
|
Log(LOG_I, @"Setting timebase for stream to %d / %d", pts.value, pts.timescale);
|
||||||
}
|
}
|
||||||
|
|
||||||
[self->_displayLayer enqueueSampleBuffer:frame.sampleBuffer];
|
if(!_appDidEnterBackgroundWithoutPiP) [self->_displayLayer enqueueSampleBuffer:frame.sampleBuffer];
|
||||||
|
|
||||||
#ifdef DISPLAYLINK_VERBOSE
|
#ifdef DISPLAYLINK_VERBOSE
|
||||||
// Some OS-level metrics I'm not sure what to do with
|
// Some OS-level metrics I'm not sure what to do with
|
||||||
|
|||||||
@@ -1031,6 +1031,8 @@
|
|||||||
- (void)applicationWillResignActive:(NSNotification *)notification {
|
- (void)applicationWillResignActive:(NSNotification *)notification {
|
||||||
//[self.pipController startPictureInPicture];
|
//[self.pipController startPictureInPicture];
|
||||||
//sleep(1);
|
//sleep(1);
|
||||||
|
_streamMan.videoRenderer.appDidEnterBackgroundWithoutPiP = true;
|
||||||
|
|
||||||
[_streamView saveRelocatedWidgetViews];
|
[_streamView saveRelocatedWidgetViews];
|
||||||
|
|
||||||
#if !TARGET_OS_TV
|
#if !TARGET_OS_TV
|
||||||
@@ -1046,6 +1048,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidBecomeActive:(NSNotification *)notification {
|
- (void)applicationDidBecomeActive:(NSNotification *)notification {
|
||||||
|
_streamMan.videoRenderer.appDidEnterBackgroundWithoutPiP = false;
|
||||||
// Stop the background timer, since we're foregrounded again
|
// Stop the background timer, since we're foregrounded again
|
||||||
if (_inactivityTimer != nil) {
|
if (_inactivityTimer != nil) {
|
||||||
Log(LOG_I, @"Stopping inactivity timer after becoming active again");
|
Log(LOG_I, @"Stopping inactivity timer after becoming active again");
|
||||||
@@ -1075,11 +1078,13 @@
|
|||||||
|
|
||||||
// This fires when the home button is pressed
|
// This fires when the home button is pressed
|
||||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||||
|
|
||||||
NSLog(@"did enter background, %d, %@, %d", _settings.enablePIP, self.pipController, self.pipController.isPictureInPictureActive);
|
NSLog(@"did enter background, %d, %@, %d", _settings.enablePIP, self.pipController, self.pipController.isPictureInPictureActive);
|
||||||
if (_settings.enablePIP && self.pipController && self.pipController.isPictureInPictureActive) {
|
if (_settings.enablePIP && self.pipController && self.pipController.isPictureInPictureActive) {
|
||||||
//Log(LOG_I, @"PIP is active, not terminating stream");
|
//Log(LOG_I, @"PIP is active, not terminating stream");
|
||||||
|
_streamMan.videoRenderer.appDidEnterBackgroundWithoutPiP = false;
|
||||||
} else {
|
} else {
|
||||||
|
_streamMan.videoRenderer.appDidEnterBackgroundWithoutPiP = true;
|
||||||
|
|
||||||
if ([_settings.renderingBackend intValue] == RENDER_METAL && self.metalViewController) {
|
if ([_settings.renderingBackend intValue] == RENDER_METAL && self.metalViewController) {
|
||||||
Log(LOG_I, @"Pausing Metal renderer on background");
|
Log(LOG_I, @"Pausing Metal renderer on background");
|
||||||
[self.metalViewController pauseRendering];
|
[self.metalViewController pauseRendering];
|
||||||
|
|||||||
Reference in new issue
Block a user