[BRLTTY] [PATCH] Finish up Darwin MIDI error handling
Peter Lundblad
plundblad at google.com
Fri Nov 10 10:46:22 EST 2006
Hi,
Below is a tiny patch that finishes up the error handling for the
Darwin MIDI support.
Have a nice weekend,
//Peter
Index: Programs/sys_midi_darwin.h
===================================================================
--- Programs/sys_midi_darwin.h (revision 2683)
+++ Programs/sys_midi_darwin.h (working copy)
@@ -118,8 +118,10 @@
void
closeMidiDevice (MidiDevice *midi) {
+ int result;
if (midi) {
- DisposeAUGraph(midi->graph);
+ if ((result = DisposeAUGraph(midi->graph)) != noErr)
+ LogPrint(LOG_ERR, "Can't dispose audio graph component: %d", result);
free(midi);
}
}
@@ -131,9 +133,12 @@
int
setMidiInstrument (MidiDevice *midi, unsigned char channel, unsigned char instrument) {
- MusicDeviceMIDIEvent(midi->synth, 0xC0 | channel, instrument, 0, 0);
+ int result;
+ if ((result = MusicDeviceMIDIEvent(midi->synth, 0xC0 | channel, instrument,
+ 0, 0)) != noErr)
+ LogPrint(LOG_ERR, "Can't set MIDI instrument: %d", result);
- return 1;
+ return result == noErr;
}
int
@@ -148,7 +153,13 @@
int
startMidiNote (MidiDevice *midi, unsigned char channel, unsigned char note, unsigned char volume) {
- MusicDeviceMIDIEvent(midi->synth, 0x90 | channel, note, volume, 0);
+ int result;
+
+ if ((result = MusicDeviceMIDIEvent(midi->synth, 0x90 | channel, note,
+ volume, 0)) != noErr) {
+ LogPrint(LOG_ERR, "Can't start MIDI note: %d", result);
+ return 0;
+ }
midi->note = note;
return 1;
@@ -156,7 +167,16 @@
int
stopMidiNote (MidiDevice *midi, unsigned char channel) {
- return startMidiNote(midi, channel, midi->note, 0);
+ int result;
+
+ if ((result = MusicDeviceMIDIEvent(midi->synth, 0x90 | channel, midi->note,
+ 0, 0)) != noErr) {
+ LogPrint(LOG_ERR, "Can't stop MIDI note: %d", result);
+ return 0;
+ }
+ midi->note = 0;
+
+ return 1;
}
int
More information about the BRLTTY
mailing list