[Scummvm-cvs-logs] SF.net SVN: scummvm:[39437] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Mar 16 05:15:04 CET 2009


Revision: 39437
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39437&view=rev
Author:   fingolfin
Date:     2009-03-16 04:15:03 +0000 (Mon, 16 Mar 2009)

Log Message:
-----------
Patch #2658665: Implement getDevices() in backends/midi/dmedia.cpp

Modified Paths:
--------------
    scummvm/trunk/README
    scummvm/trunk/backends/midi/dmedia.cpp

Modified: scummvm/trunk/README
===================================================================
--- scummvm/trunk/README	2009-03-16 03:55:09 UTC (rev 39436)
+++ scummvm/trunk/README	2009-03-16 04:15:03 UTC (rev 39437)
@@ -53,7 +53,7 @@
  * 7.3 MT-32 emulation
  * 7.4 MIDI emulation
  * 7.5 Native MIDI support
- * 7.6 UNIX native and ALSA sequencer support
+ * 7.6 UNIX native, ALSA and dmedia sequencer support
  * 7.7 TiMidity++ MIDI server support
  * 7.8 Using compressed audio files (MP3, Ogg Vorbis, Flac)
  * 7.9 Output sample rate
@@ -1537,6 +1537,28 @@
 command as described earlier in this section.
 
 
+7.6.2) Playing sound with IRIX dmedia sequencer:                 [UNIX ONLY]
+---- ------------------------------------------
+If you are using IRIX,  driver with the sequencer support, you can 
+set the environment variable SCUMMVM_PORT or the config file parameter
+dmedia_port to your sequencer port. The default is to use the first port.
+
+To get a list of configured midi interfaces on your system, run startmidi
+without parameters. Exaple output:
+
+  2 MIDI interfaces configured:
+          Serial Port 2
+          Software Synth
+
+In this example, you can configure ScummVM to use the "Software Synth"
+instead of the default "Serial Port 2" by adding a line
+
+   dmedia_port=Software Synth
+
+to your configuration file in the section [scummvm], or setting 
+SCUMMVM_PORT=Software Synth in your environment.
+
+
 7.7) Using TiMidity++ MIDI server:
 ---- -----------------------------
 If you system lacks any MIDI sequencer, but you still want better MIDI

Modified: scummvm/trunk/backends/midi/dmedia.cpp
===================================================================
--- scummvm/trunk/backends/midi/dmedia.cpp	2009-03-16 03:55:09 UTC (rev 39436)
+++ scummvm/trunk/backends/midi/dmedia.cpp	2009-03-16 04:15:03 UTC (rev 39437)
@@ -31,6 +31,7 @@
 
 #include "common/scummsys.h"
 #include "common/util.h"
+#include "common/config-manager.h"
 #include "sound/musicplugin.h"
 #include "sound/mpu401.h"
 
@@ -71,15 +72,17 @@
 
 int MidiDriver_DMEDIA::open() {
 	int numinterfaces;
+	int i;
+	const char *var;
+	char *portName;
 
 	if (_isOpen)
 		return MERR_ALREADY_OPEN;
 	_isOpen = true;
 
-	warning("dmedia init");
 	numinterfaces = mdInit();
 	if (numinterfaces <= 0) {
-		fprintf(stderr,"No MIDI interfaces configured.\n");
+		fprintf(stderr, "No MIDI interfaces configured.\n");
 		perror("Cannot initialize libmd for sound output");
 		return -1;
 	}
@@ -87,13 +90,19 @@
 	if (getenv("SCUMMVM_MIDIPORT")) {
 		_deviceNum = atoi(getenv("SCUMMVM_MIDIPORT"));
 		_midiportName = mdGetName(_deviceNum);
+	} else {
+		var = ConfMan.get("dmedia_port").c_str();
+		if (strlen(var) > 0) {
+			for (i = 0; i < numinterfaces; i++) {
+				portName = mdGetName(i);
+				if (strcmp(var, portName) == 0) {
+					_deviceNum = i;
+					_midiportName = portName;
+				}
+			}
+
+		}
 	}
-		else
-	{
-		_midiportName = mdGetName(0);
-		warning("SCUMMVM_MIDIPORT environment variable not set, using Port %s", _midiportName);
-		_deviceNum = 0;
-	}
 
 	_midiPort = mdOpenOutPort(_midiportName);
 	if (!_midiPort) {
@@ -152,7 +161,7 @@
 	if (mdSend(_midiPort, &event, 1) != 1) {
 		warning("failed sending MIDI event (dump follows...)");
 		warning("MIDI Event (len=%u):", event.msglen);
-		for (int i=0; i<event.msglen; i++) warning("%02x ",(int)event.msg[i]);
+		for (int i = 0; i < event.msglen; i++) warning("%02x ", (int)event.msg[i]);
 	}
 }
 
@@ -171,7 +180,8 @@
 	event.msg[2] = 0;
 
 	if (mdSend(_midiPort, &event, 1) != 1) {
-		fprintf(stderr,"failed sending MIDI SYSEX event (dump follows...)\n");
+		fprintf(stderr, "failed sending MIDI SYSEX event (dump follows...)\n");
+		for (int i = 0; i < event.msglen; i++) warning("%02x ", (int)event.msg[i]);
 	}
 }
 
@@ -193,10 +203,24 @@
 };
 
 MusicDevices DMediaMusicPlugin::getDevices() const {
+	int numinterfaces;
+	int i;
+	char *portName;
 	MusicDevices devices;
+
 	// TODO: Return a different music type depending on the configuration
-	// TODO: List the available devices
-	devices.push_back(MusicDevice(this, "", MT_GM));
+
+	numinterfaces = mdInit();
+	if (numinterfaces <= 0) {
+		fprintf(stderr, "No MIDI interfaces configured.\n");
+	}
+
+	for (i=0; i<numinterfaces; i++) {
+		portName = mdGetName(0);
+		fprintf(stderr, "device %i %s\n", i, portName);
+		devices.push_back(MusicDevice(this, portName, MT_GM));
+	}
+
 	return devices;
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list