0

Let me first start by saying that I'm a total objective-c newbie, and I'm picking up an existing codebase, so I'm trying to frantically read about NSRunLoop, etc. but I would love some extra help.

Basically, I have inherited code that looks like:

[[NSRunLoop mainRunLoop] runUntilDate:[NSDate distantFuture]];
[_captureSession startRunning];
return [NSNumber numberWithInt:0];

in a function that's supposed to return, but instead blocks forever on startRunning. I need this to return, and I'm not sure why it's blocking. Some more code scattered about that may be helpful:

_captureDecompressedVideoOutput = [[QTCaptureDecompressedVideoOutput alloc]
                                    init];
[_captureDecompressedVideoOutput setDelegate:self];
[_captureDecompressedVideoOutput performSelectorOnMainThread:@selector(setPixelBufferAttributes:) withObject:captureDictionary waitUntilDone:NO];

any idea what's going on?

user358829
  • 741
  • 1
  • 7
  • 17

1 Answers1

0

well, I stuck [_captureSession startRunning] in a separate function, then replaced the call with

self performSelectorInBackground:@selector(backgroundCapture) withObject:nil];

so it ran in a thread. not only did the blocking not interfere with the method returning (since it was on a separate thread) but the call didn't even block now that it was running on it's own thread. Bizarre.

user358829
  • 741
  • 1
  • 7
  • 17
  • I saw some similar weird behavior using QTCapture session on OSX 10.8 using XCode 4.5. I found [this sample command line app] that runs okay, but only if it's run using [NSThread start]... I just started over using AVCaptureSession (which I knew was available on iOS, but only recently realized is also available on Mac), which was much more straightforward. (The only hiccup I ran into was that you have to say "setWantsLayer" and "setLayer" to give a view a CALayer to use with AVCaptureVideoPreviewLayer.) I also gather that AVCaptueSession is supposed to be supplanting QTCaptureSession... – bellkev Oct 31 '12 at 07:12