diff options
author | Darkvater <darkvater@openttd.org> | 2005-09-17 13:15:16 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2005-09-17 13:15:16 +0000 |
commit | 72ef17dace7824af99c4ed38d3455f004a091861 (patch) | |
tree | 00718875a77bef751a2bd90030642f7b3c7afc0f /music | |
parent | c930f8f8c0c60e192e50db9a032e55ff671db131 (diff) | |
download | openttd-72ef17dace7824af99c4ed38d3455f004a091861.tar.xz |
(svn r2960) - Fix: [ 1227779 ] Fix win32 midi volume level control which didn't work (glx)
Diffstat (limited to 'music')
-rw-r--r-- | music/win32_m.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/music/win32_m.c b/music/win32_m.c index c0be6e246..866157ee6 100644 --- a/music/win32_m.c +++ b/music/win32_m.c @@ -12,6 +12,7 @@ static struct { bool playing; int new_vol; HANDLE wait_obj; + uint devid; char start_song[260]; } _midi; @@ -72,7 +73,7 @@ static void MidiIntStopSong(void) static void MidiIntSetVolume(int vol) { uint v = (vol * 65535 / 127); - midiOutSetVolume((HMIDIOUT)-1, v + (v << 16)); + midiOutSetVolume((HMIDIOUT)_midi.devid, v + (v << 16)); } static bool MidiIntIsSongPlaying(void) @@ -125,7 +126,9 @@ static DWORD WINAPI MidiThread(LPVOID arg) static const char *Win32MidiStart(const char * const *parm) { + MIDIOUTCAPS midicaps; DWORD threadId; + uint dev, nbdev; char buf[16]; mciSendStringA("capability sequencer has audio", buf, lengthof(buf), 0); @@ -134,6 +137,15 @@ static const char *Win32MidiStart(const char * const *parm) memset(&_midi, 0, sizeof(_midi)); _midi.new_vol = -1; + /* Get midi device */ + _midi.devid = MIDI_MAPPER; + for (dev = 0, nbdev = midiOutGetNumDevs(); dev < nbdev; dev++) { + if (midiOutGetDevCaps(dev, &midicaps, sizeof(midicaps)) == 0 && (midicaps.dwSupport & MIDICAPS_VOLUME)) { + _midi.devid = dev; + break; + } + } + if (CreateThread(NULL, 8192, MidiThread, 0, 0, &threadId) == NULL) return "Failed to create thread"; |