Re: Newbie documentation for MIDI
Re: Newbie documentation for MIDI
- Subject: Re: Newbie documentation for MIDI
- From: Philippe Wicker <email@hidden>
- Date: Tue, 26 Nov 2002 20:48:04 +0100
On Tuesday, November 26, 2002, at 06:35 PM, Robert Grant wrote:
Use Notifications!
Sounds like you're using Cocoa and so what you want to do is a piece of
cake. I do something similar for my flashing LEDs in Rax.
CoreMIDI invokes your call back in a separate thread so you're already
multi-threaded
for free. Just post a Notification in the callback thread and the main
UI thread will
pick it up and process it nicely.
I don't know how notification posting works, but I assume it is similar
to posting a carbon event. Posting an event is a potentially blocking
operation, the system has to acquire a lock on a queue. The posting
thread may be preempted because the queue is locked.The UI thread may
also be preempted while locking the queue, keeping the posting thread
in a sleeping state, until it regains the CPU and unlocks the queue.
The locking time is - theoretically - unbounded. So this mechanism
should not be used when the posting thread has real time constraints
which is the case for the MIDI or AUDIO callback's threads. This may be
less important for a MIDI thread than for an AUDIO thread. In the first
case (MIDI thread), the result will be some occasional high latency
values. In the second case (AUDIO thread), the result will be some
glitches (audio drops).
I don't know the solution for that problem. I'll have to think of it
because I need to solve this point for my own project. The idea is to
write "events" in a non blocking FIFO which is periodically polled by
the UI thread (CFRunLoop with timer ?).
Philippe Wicker
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.