Changeset - r2434:0fd20eb6a0fb
[Not reviewed]
master
0 1 0
Darkvater - 19 years ago 2005-09-17 13:15:16
darkvater@openttd.org
(svn r2960) - Fix: [ 1227779 ] Fix win32 midi volume level control which didn't work (glx)
1 file changed with 13 insertions and 1 deletions:
0 comments (0 inline, 0 general)
music/win32_m.c
Show inline comments
 
@@ -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 ar
 

	
 
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 
 
	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";
 

	
0 comments (0 inline, 0 general)