diff --git a/VoidLink/ViewControllers/MainFrameViewController.m b/VoidLink/ViewControllers/MainFrameViewController.m index b7fbc4dc..dd70e1ec 100644 --- a/VoidLink/ViewControllers/MainFrameViewController.m +++ b/VoidLink/ViewControllers/MainFrameViewController.m @@ -74,6 +74,8 @@ SettingsViewController* settingsViewController; StreamFrameViewController* streamFrameViewController; id navBarAppearanceStandard; + + NSTimer *_foregroundHostUpdateTimer; #if TARGET_OS_TV UITapGestureRecognizer* _menuRecognizer; @@ -1639,7 +1641,12 @@ static NSMutableSet* hostList; { if (!_background) { // This will kick off box art caching - [self updateHosts]; + + + _foregroundHostUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:10 repeats:YES block:^(NSTimer *timer) { + [self updateHosts]; + }]; + // Reset state first so we can rediscover hosts that were deleted before [_discMan resetDiscoveryState]; @@ -1744,7 +1751,12 @@ static NSMutableSet* hostList; } - +- (void)viewWillDisappear:(BOOL)animated{ + NSLog(@"willDisappear"); + [super viewWillDisappear:animated]; + [_foregroundHostUpdateTimer invalidate]; + _foregroundHostUpdateTimer = nil; +} - (void)viewWillAppear:(BOOL)animated { @@ -1863,13 +1875,12 @@ static NSMutableSet* hostList; } - (void)updateHosts { - Log(LOG_I, @"Updating hosts..."); + Log(LOG_I, @"Updating hosts %f", CACurrentMediaTime()); @synchronized (hostList) { // Sort the host list in alphabetical order NSArray* sortedHostList = [[hostList allObjects] sortedArrayUsingSelector:@selector(compareName:)]; for (TemporaryHost* comp in sortedHostList) { - if(comp.state == StateOnline || comp.pairState == PairStatePaired) [self.hostCollectionVC addHost:comp]; - + if(comp.state == StateOnline || comp.pairState == PairStatePaired || comp.pairState == PairStateUnknown) [self.hostCollectionVC addHost:comp]; // new host card test // if([comp.name isEqualToString: @"ASRockPC"]) { diff --git a/VoidLink/ViewControllers/StreamFrameViewController.m b/VoidLink/ViewControllers/StreamFrameViewController.m index 85188a3c..4a0f8f62 100644 --- a/VoidLink/ViewControllers/StreamFrameViewController.m +++ b/VoidLink/ViewControllers/StreamFrameViewController.m @@ -746,7 +746,7 @@ #if !TARGET_OS_TV // Terminate the stream if the app is inactive for 60 seconds Log(LOG_I, @"Starting inactivity termination timer"); - _inactivityTimer = [NSTimer scheduledTimerWithTimeInterval:1800 + _inactivityTimer = [NSTimer scheduledTimerWithTimeInterval:18000 target:self selector:@selector(inactiveTimerExpired:) userInfo:nil @@ -773,14 +773,14 @@ // This fires when the home button is pressed - (void)applicationDidEnterBackground:(UIApplication *)application { - + /* Log(LOG_I, @"Terminating stream immediately for backgrounding"); if (_inactivityTimer != nil) { [_inactivityTimer invalidate]; _inactivityTimer = nil; } - + */ // [self returnToMainFrame]; }