Changeset - r2212:46691544e1af
[Not reviewed]
master
0 1 0
tron - 19 years ago 2005-07-27 21:45:34
tron@openttd.org
(svn r2730) -Fix: Fail if the sequencer can't play audio
Also check the return value of CreateThread()
1 file changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general)
music/win32_m.c
Show inline comments
 
@@ -117,29 +117,36 @@ static DWORD WINAPI MidiThread(LPVOID ar
 
			_midi.playing = false;
 

	
 
		WaitForMultipleObjects(1, &_midi.wait_obj, FALSE, 1000);
 
	} while (!_midi.terminate);
 

	
 
	DeleteObject(_midi.wait_obj);
 
	return 0;
 
}
 

	
 
static const char *Win32MidiStart(const char * const *parm)
 
{
 
	DWORD threadId;
 
	char buf[16];
 

	
 
	mciSendStringA("capability sequencer has audio", buf, lengthof(buf), 0);
 
	if (strcmp(buf, "true") != 0) return "MCI sequencer can't play audio";
 

	
 
	memset(&_midi, 0, sizeof(_midi));
 
	_midi.new_vol = -1;
 
	CreateThread(NULL, 8192, MidiThread, 0, 0, &threadId);
 
	return 0;
 

	
 
	if (CreateThread(NULL, 8192, MidiThread, 0, 0, &threadId) == NULL)
 
		return "Failed to create thread";
 

	
 
	return NULL;
 
}
 

	
 
static void Win32MidiStop(void)
 
{
 
	_midi.terminate = true;
 
	SetEvent(_midi.wait_obj);
 
}
 

	
 
const HalMusicDriver _win32_music_driver = {
 
	Win32MidiStart,
 
	Win32MidiStop,
 
	Win32MidiPlaySong,
0 comments (0 inline, 0 general)