diff options
author | Max Horn | 2005-04-18 18:02:07 +0000 |
---|---|---|
committer | Max Horn | 2005-04-18 18:02:07 +0000 |
commit | 3ea96a13a053e803435e93b20cf07d01d0c3d821 (patch) | |
tree | a8294dddf6d1359dc0af4ce5a4044ff6ec7d5088 /backends/midi | |
parent | ed2ed47701b8531d153c4c4fc933543e7be24b93 (diff) | |
download | scummvm-rg350-3ea96a13a053e803435e93b20cf07d01d0c3d821.tar.gz scummvm-rg350-3ea96a13a053e803435e93b20cf07d01d0c3d821.tar.bz2 scummvm-rg350-3ea96a13a053e803435e93b20cf07d01d0c3d821.zip |
If we don't want to use reverb, then at least disable it properly, not via a bad hack
svn-id: r17671
Diffstat (limited to 'backends/midi')
-rw-r--r-- | backends/midi/coreaudio.cpp | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 48d92383a3..d885a1c2c9 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -28,11 +28,11 @@ #include <AudioUnit/AudioUnit.h> -// FIXME - the following disables reverb support in the QuickTime / CoreAudio -// midi backends. For some reasons, reverb will suck away a *lot* of CPU time. -// Until we know for sure what is causing this and if there is a better way to -// fix the problem, we just disable all reverb for these backends. -//#define COREAUDIO_REVERB_HACK +// Activating the following switch disables reverb support in the CoreAudio +// midi backend. Reverb will suck away a *lot* of CPU time, so on slower +// systems, you may want to turn it off completely. +// TODO: Maybe make this a config option? +//#define COREAUDIO_DISABLE_REVERB /* CoreAudio MIDI driver @@ -59,13 +59,21 @@ int MidiDriver_CORE::open() { OSStatus err; AudioUnitConnection auconnect; + ComponentDescription compdesc; + Component compid; // Open the Music Device - au_MusicDevice = (AudioUnit) OpenDefaultComponent(kAudioUnitComponentType, kAudioUnitSubType_MusicDevice); + compdesc.componentType = kAudioUnitComponentType; + compdesc.componentSubType = kAudioUnitSubType_MusicDevice; + compdesc.componentManufacturer = kAudioUnitID_DLSSynth; + compdesc.componentFlags = 0; + compdesc.componentFlagsMask = 0; + compid = FindNextComponent(NULL, &compdesc); + au_MusicDevice = static_cast<AudioUnit>(OpenComponent(compid)); if (au_MusicDevice == 0) error("Failed opening CoreAudio music device"); - + // Load custom soundfont, if specified // FIXME: This is kind of a temporary hack. Better (IMO) would be to // query QuickTime for whatever custom soundfont was set in the @@ -96,6 +104,8 @@ int MidiDriver_CORE::open() { // open the output unit au_output = (AudioUnit) OpenDefaultComponent(kAudioUnitComponentType, kAudioUnitSubType_Output); + if (au_output == 0) + error("Failed opening output audio unit"); // connect the units auconnect.sourceAudioUnit = au_MusicDevice; @@ -105,6 +115,12 @@ int MidiDriver_CORE::open() { AudioUnitSetProperty(au_output, kAudioUnitProperty_MakeConnection, kAudioUnitScope_Input, 0, (void *)&auconnect, sizeof(AudioUnitConnection)); +#ifdef COREAUDIO_DISABLE_REVERB + UInt32 usesReverb = 0; + AudioUnitSetProperty (au_MusicDevice, kMusicDeviceProperty_UsesInternalReverb, + kAudioUnitScope_Global, 0, &usesReverb, sizeof (usesReverb)); +#endif + // initialize the units AudioUnitInitialize(au_MusicDevice); AudioUnitInitialize(au_output); @@ -123,24 +139,25 @@ void MidiDriver_CORE::close() { // Cleanup CloseComponent(au_output); + au_output = 0; CloseComponent(au_MusicDevice); + au_MusicDevice = 0; } void MidiDriver_CORE::send(uint32 b) { + assert(au_output != NULL); + assert(au_MusicDevice != NULL); unsigned char first_byte, second_byte, status_byte; status_byte = (b & 0x000000FF); first_byte = (b & 0x0000FF00) >> 8; second_byte = (b & 0x00FF0000) >> 16; -#ifdef COREAUDIO_REVERB_HACK - if ((status_byte&0xF0) == 0xB0 && first_byte == 0x5b) - return; -#endif - MusicDeviceMIDIEvent(au_MusicDevice, status_byte, first_byte, second_byte, 0); } void MidiDriver_CORE::sysEx(byte *msg, uint16 length) { + assert(au_output != NULL); + assert(au_MusicDevice != NULL); MusicDeviceSysEx(au_MusicDevice, msg, length); } |