如何在后台管理 GPUImage movieFile 处理?
How to manage GPUImage movieFile Processing in background?
我已经实现了 GPUImage
库以在现有视频中应用过滤器,现在的问题是当我锁定设备时应用程序崩溃,我还设置了 BOOL
变量来获取应用程序当前状态,不幸的是,Bun 在应用程序崩溃后 resignActive 调用。崩溃发生在这行代码中。
[self.context presentRenderbuffer:GL_RENDERBUFFER];
你能否建议我最好的处理方法。
-(void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(EnterBackground:)
name:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(DidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
- (void)EnterBackground:(NSNotification*)notification{
NSLog(@"Enter in background");
[self.movieFile endProcessing];
[self.filter removeAllTargets];
[self.movieFile removeAllTargets];
}
- (void)DidBecomeActive:(NSNotification*)notification{
[_movieFile startProcessing];
}
不要忘记在 viewWillDisappear
中删除观察者
我已经实现了 GPUImage
库以在现有视频中应用过滤器,现在的问题是当我锁定设备时应用程序崩溃,我还设置了 BOOL
变量来获取应用程序当前状态,不幸的是,Bun 在应用程序崩溃后 resignActive 调用。崩溃发生在这行代码中。
[self.context presentRenderbuffer:GL_RENDERBUFFER];
你能否建议我最好的处理方法。
-(void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(EnterBackground:)
name:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(DidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
- (void)EnterBackground:(NSNotification*)notification{
NSLog(@"Enter in background");
[self.movieFile endProcessing];
[self.filter removeAllTargets];
[self.movieFile removeAllTargets];
}
- (void)DidBecomeActive:(NSNotification*)notification{
[_movieFile startProcessing];
}
不要忘记在 viewWillDisappear