Ticket #9056: scummvm_midi_device.patch

File scummvm_midi_device.patch, 2.8 KB (added by SF/tafuri, 15 years ago)

SVN Diff (patch)

  • backends/midi/windows.cpp

     
    3030
    3131#include "sound/musicplugin.h"
    3232#include "sound/mpu401.h"
     33#include "common/config-manager.h"
    3334
    3435#include <mmsystem.h>
    3536
     
    4647        HANDLE _streamEvent;
    4748        HMIDIOUT _mo;
    4849        bool _isOpen;
     50        UINT _device;
    4951
    5052        void check_error(MMRESULT result);
    5153
    5254public:
    53         MidiDriver_WIN() : _isOpen(false) { }
     55        MidiDriver_WIN(UINT device = MIDI_MAPPER) : _device(device), _isOpen(false) { }
    5456        int open();
    5557        void close();
    5658        void send(uint32 b);
     
    6163        if (_isOpen)
    6264                return MERR_ALREADY_OPEN;
    6365
     66        if(_device < 0 || _device >= midiOutGetNumDevs())
     67                _device = MIDI_MAPPER;
     68
    6469        _streamEvent = CreateEvent(NULL, true, true, NULL);
    65         MMRESULT res = midiOutOpen((HMIDIOUT *)&_mo, MIDI_MAPPER, (DWORD_PTR)_streamEvent, 0, CALLBACK_EVENT);
     70        MMRESULT res = midiOutOpen((HMIDIOUT *)&_mo, _device, (DWORD_PTR)_streamEvent, 0, CALLBACK_EVENT);
    6671        if (res != MMSYSERR_NOERROR) {
    6772                check_error(res);
    6873                CloseHandle(_streamEvent);
     
    170175}
    171176
    172177Common::Error WindowsMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
    173         *mididriver = new MidiDriver_WIN();
    174178
     179        *mididriver = new MidiDriver_WIN(ConfMan.getInt("midi_device"));
    175180        return Common::kNoError;
    176181}
    177182
  • base/commandLine.cpp

     
    100100        "  --extrapath=PATH         Extra path to additional game data\n"
    101101        "  --soundfont=FILE         Select the SoundFont for MIDI playback (only\n"
    102102        "                           supported by some MIDI drivers)\n"
     103
     104#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
     105        "  --midi-device=DEVICE     Select a specific midi device\n"
     106#endif
    103107        "  --multi-midi             Enable combination AdLib and native MIDI\n"
    104108        "  --native-mt32            True Roland MT-32 (disable GM emulation)\n"
    105109        "  --enable-gs              Enable Roland GS mode for MIDI playback\n"
     
    167171        ConfMan.registerDefault("sfx_mute", false);
    168172        ConfMan.registerDefault("speech_mute", false);
    169173
     174#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
     175        ConfMan.registerDefault("midi_device", -1);
     176#endif
    170177        ConfMan.registerDefault("multi_midi", false);
    171178        ConfMan.registerDefault("native_mt32", false);
    172179        ConfMan.registerDefault("enable_gs", false);
     
    445452                        DO_LONG_OPTION_BOOL("disable-sdl-parachute")
    446453                        END_OPTION
    447454
     455#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
     456                        DO_LONG_OPTION_INT("midi-device")
     457                        END_OPTION
     458#endif
     459
    448460                        DO_LONG_OPTION_BOOL("multi-midi")
    449461                        END_OPTION
    450462