From ffa97e6626e43adf9c94de9a7322138e46436af4 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 16 Mar 2009 04:15:03 +0000 Subject: Patch #2658665: Implement getDevices() in backends/midi/dmedia.cpp svn-id: r39437 --- README | 24 +++++++++++++++++++++++- backends/midi/dmedia.cpp | 48 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/README b/README index 4066144951..f6345ae925 100644 --- a/README +++ b/README @@ -53,7 +53,7 @@ Table of Contents: * 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 @@ Once either TiMidity or FluidSynth are running, use the 'aconnect -o -l' 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 diff --git a/backends/midi/dmedia.cpp b/backends/midi/dmedia.cpp index eb639cc6c8..fc4c3d52c1 100644 --- a/backends/midi/dmedia.cpp +++ b/backends/midi/dmedia.cpp @@ -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 @@ MidiDriver_DMEDIA::MidiDriver_DMEDIA() { 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,12 +90,18 @@ int MidiDriver_DMEDIA::open() { if (getenv("SCUMMVM_MIDIPORT")) { _deviceNum = atoi(getenv("SCUMMVM_MIDIPORT")); _midiportName = mdGetName(_deviceNum); - } - else - { - _midiportName = mdGetName(0); - warning("SCUMMVM_MIDIPORT environment variable not set, using Port %s", _midiportName); - _deviceNum = 0; + } 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; + } + } + + } } _midiPort = mdOpenOutPort(_midiportName); @@ -152,7 +161,7 @@ void MidiDriver_DMEDIA::send(uint32 b) { 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