Re: Should MIDINotifyProc work in command-line programs?
Re: Should MIDINotifyProc work in command-line programs?
- Subject: Re: Should MIDINotifyProc work in command-line programs?
- From: Kurt Revis <email@hidden>
- Date: Thu, 19 Sep 2002 13:59:22 -0700
On Thursday, September 19, 2002, at 12:48 PM, John Lazzaro wrote:
The ideal solution would be a function I could insert in my
own run-loop, that would trigger the CoreMIDI run-loop manually ... in
a quick look through the CoreMIDI headers, I couldn't find such a
function. Any ideas?
Are you running your own run loop via CFRunLoopRun()? If so, are you
running it in the default mode or in your own custom mode? Or when you
say "run loop" do you mean something other than a CFRunLoop?
My understanding is that the notifications will be received in the same
run loop (that is, the same thread) as is current when
MIDIClientCreate() is called. I don't know if they are always
delivered in the default mode, or the mode which is current when
MIDIClientCreate() is called.
I just gave this a try and it works for me. (The fflush()es may be
superfluous... I needed them to get the output to show up in the
Project Builder run pane.)
#include <CoreFoundation/CoreFoundation.h>
#include <CoreMIDI/CoreMIDI.h>
void midiNotifyProc(const MIDINotification *message, void *refCon)
{
printf("Received notification.\n");
fflush(stdout);
}
int main (int argc, const char * argv[])
{
OSStatus err;
MIDIClientRef client;
err = MIDIClientCreate(CFSTR("foo"), midiNotifyProc, NULL, &client);
if (err) {
printf("Error on MIDIClientCreate()\n");
return 0;
}
printf("Waiting.\n");
fflush(stdout);
CFRunLoopRun();
return 0;
}
--
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.