1
的應用程序,這是我的代碼凍結我的應用程序AVCaptureConnection凍結我的第二個呼叫
AVCaptureConnection *videoConnection = [videoOutput connectionWithMediaType:AVMediaTypeVideo];
if ([videoConnection isVideoOrientationSupported])
{
[videoConnection setVideoOrientation:AVCaptureVideoOrientationPortrait];
}
這是我videoOutput初始化
// Setup video capture
videoInput = [[AVCaptureDeviceInput deviceInputWithDevice: front? frontVideoDevice: rearVideoDevice error: &error] retain];
videoOutput = [[AVCaptureVideoDataOutput alloc] init];
[videoOutput setAlwaysDiscardsLateVideoFrames: YES];
// Set the video output to store frame in BGRA (It is supposed to be faster)
NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key];
[videoOutput setVideoSettings:videoSettings];
當我在第二次我的應用程序停止初始化會話迴應 但如果我刪除avcaptureconnection的代碼一切都很好
?
我認爲它是一個內存管理問題。你可以通過調試器檢查第二次調用它時是否有一個有效的對象'videoOutput'?你能發佈確切的錯誤消息嗎? – Pfitz
我得到沒有錯誤,這是問題,並正確分配videoOutput。但現在我注意到我得到了AVCaptureSessionRuntimeErrorNotification。 – Janub
您是否設置了異常斷點? – Pfitz