[Scummvm-git-logs] scummvm master -> 6f8f27ecb28fca750e0ceaa09779d78164eaaaac

criezy criezy at scummvm.org
Fri Oct 6 01:03:41 CEST 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9a07050888 MACOSX: Allow selecting device for CoreMidi
6f8f27ecb2 MACOSX: Change name for CoreAudio MIDI device


Commit: 9a070508880d555fb7e02b5a35f7d175d316a5a3
    https://github.com/scummvm/scummvm/commit/9a070508880d555fb7e02b5a35f7d175d316a5a3
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-10-06T00:03:37+01:00

Commit Message:
MACOSX: Allow selecting device for CoreMidi

Changed paths:
    backends/midi/coremidi.cpp


diff --git a/backends/midi/coremidi.cpp b/backends/midi/coremidi.cpp
index e2ec840..37d58c5 100644
--- a/backends/midi/coremidi.cpp
+++ b/backends/midi/coremidi.cpp
@@ -53,7 +53,7 @@ http://lists.apple.com/archives/coreaudio-api/2003/Jul/msg00137.html
  */
 class MidiDriver_CoreMIDI : public MidiDriver_MPU401 {
 public:
-	MidiDriver_CoreMIDI();
+	MidiDriver_CoreMIDI(ItemCount device);
 	~MidiDriver_CoreMIDI();
 	int open();
 	bool isOpen() const { return mOutPort != 0 && mDest != 0; }
@@ -62,13 +62,14 @@ public:
 	void sysEx(const byte *msg, uint16 length);
 
 private:
+	ItemCount mDevice;
 	MIDIClientRef	mClient;
 	MIDIPortRef		mOutPort;
 	MIDIEndpointRef	mDest;
 };
 
-MidiDriver_CoreMIDI::MidiDriver_CoreMIDI()
-	: mClient(0), mOutPort(0), mDest(0) {
+MidiDriver_CoreMIDI::MidiDriver_CoreMIDI(ItemCount device)
+	: mDevice(device), mClient(0), mOutPort(0), mDest(0) {
 
 	OSStatus err;
 	err = MIDIClientCreate(CFSTR("ScummVM MIDI Driver for OS X"), NULL, NULL, &mClient);
@@ -88,9 +89,9 @@ int MidiDriver_CoreMIDI::open() {
 
 	mOutPort = 0;
 
-	int dests = MIDIGetNumberOfDestinations();
-	if (dests > 0 && mClient) {
-		mDest = MIDIGetDestination(0);
+	ItemCount dests = MIDIGetNumberOfDestinations();
+	if (mDevice < dests && mClient) {
+		mDest = MIDIGetDestination(mDevice);
 		err = MIDIOutputPortCreate( mClient,
 									CFSTR("scummvm_output_port"),
 									&mOutPort);
@@ -195,20 +196,59 @@ public:
 
 	MusicDevices getDevices() const;
 	Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
+
+private:
+	bool getDeviceName(ItemCount deviceIndex, Common::String &outName) const;
 };
 
 MusicDevices CoreMIDIMusicPlugin::getDevices() const {
+	// TODO: Is it possible to get the music type for each device?
+	// Maybe look at the kMIDIPropertyModel property?
+
 	MusicDevices devices;
-	// TODO: Return a different music type depending on the configuration
-	// TODO: List the available devices
-	devices.push_back(MusicDevice(this, "", MT_GM));
+	ItemCount deviceCount = MIDIGetNumberOfDestinations();
+	for (ItemCount i = 0 ; i < deviceCount ; ++i) {
+		Common::String name;
+		if (getDeviceName(i, name))
+			devices.push_back(MusicDevice(this, name, MT_GM));
+	}
 	return devices;
 }
 
-Common::Error CoreMIDIMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
-	*mididriver = new MidiDriver_CoreMIDI();
+Common::Error CoreMIDIMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle device) const {
+	ItemCount deviceCount = MIDIGetNumberOfDestinations();
+	for (ItemCount i = 0 ; i < deviceCount ; ++i) {
+		Common::String name;
+		if (getDeviceName(i, name)) {
+			MusicDevice md(this, name, MT_GM);
+			if (md.getHandle() == device) {
+				*mididriver = new MidiDriver_CoreMIDI(i);
+				return Common::kNoError;
+			}
+		}
+	}
+
+	return Common::kUnknownError;
+}
 
-	return Common::kNoError;
+bool CoreMIDIMusicPlugin::getDeviceName(ItemCount deviceIndex, Common::String &outName) const {
+	MIDIEndpointRef dest = MIDIGetDestination(deviceIndex);
+	if (!dest)
+		return false;
+	CFStringRef name = nil;
+	if (MIDIObjectGetStringProperty(dest, kMIDIPropertyDisplayName, &name) == noErr) {
+		char buffer[128];
+		if (CFStringGetCString(name, buffer, sizeof(buffer), kCFStringEncodingASCII)) {
+			outName = buffer;
+			CFRelease(name);
+			return true;
+		}
+		CFRelease(name);
+	}
+	// Rather than fail use a default name
+	warning("Failed to get name for CoreMIDi device %lu", deviceIndex);
+	outName = Common::String::format("Unknown Device %lu", deviceIndex);
+	return true;
 }
 
 //#if PLUGIN_ENABLED_DYNAMIC(COREMIDI)


Commit: 6f8f27ecb28fca750e0ceaa09779d78164eaaaac
    https://github.com/scummvm/scummvm/commit/6f8f27ecb28fca750e0ceaa09779d78164eaaaac
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2017-10-06T00:03:37+01:00

Commit Message:
MACOSX: Change name for CoreAudio MIDI device

Also remove a couple of TODOs. I think we can limit the CoreAudio
plugin to the Apple DLS softsynth since with have the CoreMidi
plugin to access other MIDI devices.

Changed paths:
    backends/midi/coreaudio.cpp


diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp
index 74c590c..1407719 100644
--- a/backends/midi/coreaudio.cpp
+++ b/backends/midi/coreaudio.cpp
@@ -308,7 +308,7 @@ void MidiDriver_CORE::sysEx(const byte *msg, uint16 length) {
 class CoreAudioMusicPlugin : public MusicPluginObject {
 public:
 	const char *getName() const {
-		return "CoreAudio";
+		return "Apple DLS Software Synthesizer";
 	}
 
 	const char *getId() const {
@@ -321,8 +321,6 @@ public:
 
 MusicDevices CoreAudioMusicPlugin::getDevices() const {
 	MusicDevices devices;
-	// TODO: Return a different music type depending on the configuration
-	// TODO: List the available devices
 	devices.push_back(MusicDevice(this, "", MT_GM));
 	return devices;
 }





More information about the Scummvm-git-logs mailing list