mediastream_cocoa.m: use display_async instead of performSelectorInBackground,...

mediastream_cocoa.m: use display_async instead of performSelectorInBackground, otherwise nanosleeps are not respected by Darwin... (+reformat tabs)
parent 8e8dd84a
......@@ -53,7 +53,9 @@ extern int apple_main(int argc, char **argv);
NSLog(@"Disabling App nap for tester");
self->activity = [[[NSProcessInfo processInfo] beginActivityWithOptions:0x00FFFFFF reason:@"No app nap for ms2 tester"] retain];
}
[self performSelectorInBackground:@selector(runLoop) withObject:nil];
dispatch_async(dispatch_get_main_queue(), ^{
[self runLoop];
});
}
-(void)applicationDidFinishLaunching: (NSNotification*) aNotification
......@@ -91,7 +93,7 @@ int main(int argc, char **argv)
MyApplicationDelegate *aMyApplicationDelegate = [[MyApplicationDelegate alloc] init];
aMyApplicationDelegate->argc = argc;
aMyApplicationDelegate->argv = argv;
[NSApp setDelegate: aMyApplicationDelegate];
[NSApp setDelegate: aMyApplicationDelegate];
[aPool release];
[NSApp run];
return 0;
......
......@@ -4,16 +4,17 @@
struct _MediastreamDatas;
typedef struct _MediastreamDatas MediastreamDatas;
extern const char * usage;
extern MediastreamDatas* init_default_args();
extern BOOL parse_args(int argc, char** argv, MediastreamDatas* plop);
extern BOOL parse_args(int argc, char** argv, MediastreamDatas* args);
extern void setup_media_streams(MediastreamDatas* args);
extern void mediastream_run_loop(MediastreamDatas* args);
extern void clear_mediastreams(MediastreamDatas* args);
@interface MyApplicationDelegate: NSObject
{
NSWindow *window;
MediastreamDatas* args;
NSWindow *window;
MediastreamDatas* args;
}
-(void)registerArgs:(MediastreamDatas*) args;
-(void)applicationWillFinishLaunching: (NSNotification*) aNotification;
......@@ -24,19 +25,21 @@ extern void clear_mediastreams(MediastreamDatas* args);
@implementation MyApplicationDelegate
-(void)registerArgs:(MediastreamDatas*) a {
args = a;
args = a;
}
-(void) run_mediastreamer_loop {
setup_media_streams(args);
mediastream_run_loop(args);
setup_media_streams(args);
mediastream_run_loop(args);
clear_mediastreams(args);
exit(0);
}
-(void)applicationWillFinishLaunching: (NSNotification*) aNotification
{
[self performSelectorInBackground:@selector(run_mediastreamer_loop) withObject:nil];
dispatch_async(dispatch_get_main_queue(), ^{
[self run_mediastreamer_loop];
});
}
-(void)applicationDidFinishLaunching: (NSNotification*) aNotification
......@@ -45,34 +48,35 @@ extern void clear_mediastreams(MediastreamDatas* args);
-(BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSApplication *)theApplication
{
return YES;
return YES;
}
-(void)dealloc
{
[window release];
[super dealloc];
[window release];
[super dealloc];
}
@end
int main(int argc, char **argv)
{
MediastreamDatas* args = init_default_args();
if (!parse_args(argc, argv, args)) {
NSLog(@"Arguments parsing fail (argc=%d)", argc);
exit(-1);
}
static const ProcessSerialNumber thePSN = { 0, kCurrentProcess };
TransformProcessType(&thePSN, kProcessTransformToForegroundApplication);
SetFrontProcess(&thePSN);
NSAutoreleasePool *aPool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
MyApplicationDelegate *aMyApplicationDelegate = [[MyApplicationDelegate alloc] init];
[aMyApplicationDelegate registerArgs:args];
[NSApp setDelegate: aMyApplicationDelegate];
[aPool release];
[NSApp run];
return 0;
MediastreamDatas* args = init_default_args();
if (!parse_args(argc, argv, args)) {
NSLog(@"Arguments parsing fail (argc=%d)", argc);
NSLog(@"%s\n", usage);
exit(-1);
}
static const ProcessSerialNumber thePSN = { 0, kCurrentProcess };
TransformProcessType(&thePSN, kProcessTransformToForegroundApplication);
SetFrontProcess(&thePSN);
NSAutoreleasePool *aPool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
MyApplicationDelegate *aMyApplicationDelegate = [[MyApplicationDelegate alloc] init];
[aMyApplicationDelegate registerArgs:args];
[NSApp setDelegate: aMyApplicationDelegate];
[aPool release];
[NSApp run];
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment