Skip to content

Commit

Permalink
Get the run loop working
Browse files Browse the repository at this point in the history
  • Loading branch information
mathk committed Jun 6, 2011
1 parent 10c7f68 commit f15b027
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
2 changes: 2 additions & 0 deletions gst-objc-ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ void gst_addStObjectGetter (Class cls);

/* install the hook for idle task */
void gst_installSuspendLoop ();

void gst_installEventLoop ();
36 changes: 20 additions & 16 deletions gst-objc-ext.m
Original file line number Diff line number Diff line change
Expand Up @@ -855,40 +855,44 @@ void gst_initFFIType ()

}

void
gst_runOneStepLoop ()
static NSEvent* event = nil;
static NSAutoreleasePool * pool;

mst_Boolean
gst_objcPollEvent (int ms)
{
NSAutoreleasePool * pool = [NSAutoreleasePool new];
pool = [NSAutoreleasePool new];
if (nil != NSApp)
{
if ([NSApp isRunning] == NO)
{
[NSApp setRunning];
[NSApp finishLaunching];
}
NSEvent * e = [NSApp nextEventMatchingMask: NSAnyEventMask
if (event != nil)
return false;

event = [NSApp nextEventMatchingMask: NSAnyEventMask
untilDate: [NSDate distantFuture]
inMode: NSDefaultRunLoopMode
dequeue: YES];

if (e != nil)
{
[NSApp sendEvent: e];
}
}
[pool drain];
return true;
}

void
gst_idleTask ()
gst_objcDispatch ()
{
usleep(20000);
if (event != nil)
{
[NSApp sendEvent: event];
event = nil;
}
[pool drain];
}

void
gst_installSuspendLoop ()
gst_installEventLoop ()
{
//gst_proxy->setSigsuspend ((PTR)gst_idleTask);
gst_proxy->setEventLoopHandlers (gst_objcPollEvent, gst_objcDispatch);
}


1 change: 1 addition & 0 deletions gst-objc.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
proxy->defineCFunc ("objc_retain", gst_retain);
proxy->defineCFunc ("objc_release", gst_release);
proxy->defineCFunc ("objc_installSuspendLoop", gst_installSuspendLoop);
proxy->defineCFunc ("objc_installEventLoop", gst_installEventLoop);
proxy->defineCFunc ("gstRectFill", gst_rectFill);
pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Load complete");
Expand Down
4 changes: 4 additions & 0 deletions gst-objc/ObjcRuntime.st
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ Object subclass: ObjcRuntime [
<cCall: 'objc_installSuspendLoop' returning: #void args: #()>
]

objcInstallEventLoop [
<cCall: 'objc_installEventLoop' returning: #void args: #()>
]

objcAllocateClassPairSuper: aSuperName name: aName indexable: aInt [
| class |
class := ObjcClass fromPtr: (self primObjcAllocateClassPairSuper: (self at: aSuperName) objcPtr name: aName indexable: aInt).
Expand Down

0 comments on commit f15b027

Please sign in to comment.