Sound Manager & MIDI callbacks, interrupts and threads
Sound Manager & MIDI callbacks, interrupts and threads
- Subject: Sound Manager & MIDI callbacks, interrupts and threads
- From: Andy Robinson <email@hidden>
- Date: Sat, 16 Feb 2002 10:30:04 +0000
I have a couple of callbacks in an app I'm now converting to OS-X Mach-
O, which I'm worried about. They work fine but I'm worried about
possible collision/crashes.
One is Sound Manager - I'm doing audio output, so I pass a callback func
to SndNewChannel which gets notified when a block is consumed.
The other is MIDI input, where we give a callback to MIDIInputPortCreate
which gets called when MIDI data arrives.
Both these callbacks communicate with the main app code via queues, so
there are brief moments of queue-manipulation when it would be fatal for
one to interrupt the other and access the queue.
On classic Mac (AFAI understand it) these callbacks were called at
"interrupt time" so there was never any danger of the main app
interrupting the callback. To prevent the callback interrupting the main
app I would briefly disable interrupts using InterruptDisableLib.c as
provided by Apple. This uses assembly code which doesn't work on Mach-O.
I'm not at all clear what the situation is now. Is the callback running
in some pre-emptive thread? Do I need to worry about the main app
interrupting the callback? And how can I prevent (for brief moments) the
callback interrupting the main app?
There's all kinds of badly-documented stuff about threads, semaphores
etc to be found, but I have no idea what I should actually be using.
Any guidance would be welcome, thank you.
Andy Robinson, Seventh String Software, www.seventhstring.demon.co.uk
_______________________________________________
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.