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 --- backends/midi/dmedia.cpp | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'backends/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