Re: Newbie documentation for MIDI
Re: Newbie documentation for MIDI
- Subject: Re: Newbie documentation for MIDI
- From: Kurt Revis <email@hidden>
- Date: Sat, 30 Nov 2002 23:57:56 -0800
On Tuesday, November 26, 2002, at 11:48 AM, Philippe Wicker wrote:
I don't know how notification posting works, but I assume it is
similar to posting a carbon event.
Not really. It's pretty simple: when a notification is posted to a
notification center, the notification center just looks up all objects
which are observing that notification, and sends a message to each
observer in turn. There's no queuing behavior at all.
The idea is to write "events" in a non blocking FIFO which is
periodically polled by the UI thread (CFRunLoop with timer ?).
Here's something similar which no one mentioned last week. You can
create a run loop source and attach it to one thread--say your app's
main thread, where all UI interaction happens. Then you can cause this
run loop source to activate from a different thread, like this:
// It's up to you to set these up:
CFRunLoopRef mainThreadRunLoop;
// Gotten via CFRunLoopGetCurrent() while running in the main
thread
CFRunLoopSourceRef runLoopSource;
// call CFRunLoopSourceCreate() to create this,
// and CFRunLoopAddSource() to add it to the main thread's run
loop
// In the work thread:
// Signal the run loop source, so it runs
CFRunLoopSourceSignal(runLoopSource);
// And make sure the run loop wakes up right away (otherwise it may
take a few seconds)
CFRunLoopWakeUp(mainThreadRunLoop);
// Sometime soon the runLoopSource's callback will get called in
the main thread.
This is basically equivalent to using an NSPort or CFMachPort, I think,
but I don't know if the exact blocking details are the same (if this
matters to you). This method doesn't require any periodic polling, and
it only uses CoreFoundation so there's no Objective-C required.
--
Kurt Revis
email@hidden
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.