this is my first post, so let me send me many thanks to all the posting guys outside there (I use SO extensively passively - great!)
I'm working on an video exporting tool for Mac OS X using the good old Quicktime API.
Brief: I cut frames from multiple input movies an arrange them (scaled) to a new output movie (kind of media-kiosk).
As many of the needed QT functionality (e.g. writing timecode ...) need to be nested in a 32-bit Application, I decided to do this offline using a 32 bit command line tool. The tool renders frame by frame (offline) and prints the current progress in values between 0.0 and 1.0
It is invoked by the main application (Cocoa, GUI, the modern stuff) via NSTask. The stout is caught by a NSPipe.
I took a look at some examples and 'll give you quick overview over my code:
NSTask *task;
NSPipe *pipe;
float progress;
// prepare the offline process
//
//
-(void) prepareOfflineExport {
task = [[NSTask alloc] init];
pipe = [[NSPipe alloc] init];
[task setLaunchPath:pathToRenderer];
[task setStandardOutput:pipe];
}
// arguments are passed outside
// invoke the process
//
-(void) startOfflineExport {
progress = 0.0f;
NSArray *argv = [NSArray arrayWithObjects: /* command line args */, nil];
[task setArguments:argv];
NSFileHandle *fh = [pipe fileHandleForReading];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataReady:) name:NSFileHandleReadCompletionNotification object:fh];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskTerminated:) name:NSTaskDidTerminateNotification object:task];
[task launch];
[fh readInBackgroundAndNotify];
}
// called when data ready
//
//
-(void) dataReady:(NSNotification*)n {
NSData *d = [[n userInfo] valueForKey:NSFileHandleNotificationData];
if([d length]) {
NSString *s = [[NSString alloc] initWithData:d encoding:NSUTF8StringEncoding];
progress = [s floatValue];
}
}
// called when process exits
//
//
-(void) taskTerminated:(NSNotification*)n {
task = nil;
progress = 1.0f;
}
Now the Problem:
When launching the application inside Xcode (via "run"), everything works fine. The Invocation is done proper, the process is visible in the activity monitor and the NSLevelIndicator (on the guy of the innovating app) is proceeding well according the (float) progress variable.
BUT: if i "archive" the application and execute it outside of Xcode, the stdout of my Command Line Tool never seem to reach the application. I tried writing a debug file in
-(void) dataReady:(NSNotification*)n
No chance, it is never called! I tested the issue on several Macs, same problem...
Did I make an obvious mistake or is there some preferences to configure (Sandboxing is off), maybe known issues that I overlooked?
Thank you for help
Greetings Mat