[Scummvm-cvs-logs] CVS: scummvm/backends/midi coreaudio.cpp,1.7,1.8

Max Horn fingolfin at users.sourceforge.net
Thu Dec 25 09:24:03 CET 2003


Update of /cvsroot/scummvm/scummvm/backends/midi
In directory sc8-pr-cvs1:/tmp/cvs-serv3002

Modified Files:
	coreaudio.cpp 
Log Message:
disable the reverb hack for now; at hacked in sound font support (specify 'soundfont' config option with path to a .SF2 file); simplify code a bit by using OpenDefaultComponent; allow usage of any music device, not just the DLSSynth (this may or may not help people with real MIDI devices)

Index: coreaudio.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/midi/coreaudio.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- coreaudio.cpp	2 Jul 2003 23:24:05 -0000	1.7
+++ coreaudio.cpp	25 Dec 2003 17:23:49 -0000	1.8
@@ -20,6 +20,8 @@
 
 #ifdef MACOSX
 
+#include "stdafx.h"
+#include "common/config-manager.h"
 #include "sound/mpu401.h"
 
 #include <AudioUnit/AudioUnit.h>
@@ -29,7 +31,7 @@
 // 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
+//#define COREAUDIO_REVERB_HACK
 
 
 /* CoreAudio MIDI driver
@@ -54,19 +56,42 @@
 	if (au_output != NULL)
 		return MERR_ALREADY_OPEN;
 
-	int err;
+	OSStatus err;
 	AudioUnitConnection auconnect;
-	ComponentDescription compdesc;
-	Component compid;
 
 	// Open the Music Device
-	compdesc.componentType = kAudioUnitComponentType;
-	compdesc.componentSubType = kAudioUnitSubType_MusicDevice;
-	compdesc.componentManufacturer = kAudioUnitID_DLSSynth;
-	compdesc.componentFlags = 0;
-	compdesc.componentFlagsMask = 0;
-	compid = FindNextComponent(NULL, &compdesc);
-	au_MusicDevice = (AudioUnit) OpenComponent(compid);
+	au_MusicDevice = (AudioUnit) OpenDefaultComponent(kAudioUnitComponentType, kAudioUnitSubType_MusicDevice);
+	
+	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
+	// QuickTime Preferences, and use that automatically.
+	if (ConfMan.hasKey("soundfont")) {
+		FSRef	fsref;
+		FSSpec	fsSpec;
+		const char *soundfont = ConfMan.get("soundfont").c_str();
+	
+		err = FSPathMakeRef ((const byte *)soundfont, &fsref, NULL);
+
+		if (err == noErr) {
+			err = FSGetCatalogInfo (&fsref, kFSCatInfoNone, NULL, NULL, &fsSpec, NULL);
+		}
+	
+		if (err == noErr) {
+			err = AudioUnitSetProperty (
+				au_MusicDevice,
+				kMusicDeviceProperty_SoundBankFSSpec, kAudioUnitScope_Global,
+				0,
+				&fsSpec, sizeof(fsSpec)
+			);
+		}
+
+		if (err != noErr)
+			warning("Failed loading custom sound font '%s' (error %d)\n", soundfont, err);
+	}
 
 	// open the output unit
 	au_output = (AudioUnit) OpenDefaultComponent(kAudioUnitComponentType, kAudioUnitSubType_Output);





More information about the Scummvm-git-logs mailing list