src/music/win32_m.cpp
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6450 1c2016673250
child 6720 35756db7e577
equal deleted inserted replaced
9894:70d78ac95d6c 9895:7bd07f43b0e3
    21 	_midi.playing = true;
    21 	_midi.playing = true;
    22 	_midi.stop_song = false;
    22 	_midi.stop_song = false;
    23 	SetEvent(_midi.wait_obj);
    23 	SetEvent(_midi.wait_obj);
    24 }
    24 }
    25 
    25 
    26 static void Win32MidiStopSong(void)
    26 static void Win32MidiStopSong()
    27 {
    27 {
    28 	if (_midi.playing) {
    28 	if (_midi.playing) {
    29 		_midi.stop_song = true;
    29 		_midi.stop_song = true;
    30 		_midi.start_song[0] = '\0';
    30 		_midi.start_song[0] = '\0';
    31 		SetEvent(_midi.wait_obj);
    31 		SetEvent(_midi.wait_obj);
    32 	}
    32 	}
    33 }
    33 }
    34 
    34 
    35 static bool Win32MidiIsSongPlaying(void)
    35 static bool Win32MidiIsSongPlaying()
    36 {
    36 {
    37 	return _midi.playing;
    37 	return _midi.playing;
    38 }
    38 }
    39 
    39 
    40 static void Win32MidiSetVolume(byte vol)
    40 static void Win32MidiSetVolume(byte vol)
    60 	if (MidiSendCommand("open \"%s\" type sequencer alias song", filename) != 0) return false;
    60 	if (MidiSendCommand("open \"%s\" type sequencer alias song", filename) != 0) return false;
    61 
    61 
    62 	return MidiSendCommand("play song from 0") == 0;
    62 	return MidiSendCommand("play song from 0") == 0;
    63 }
    63 }
    64 
    64 
    65 static void MidiIntStopSong(void)
    65 static void MidiIntStopSong()
    66 {
    66 {
    67 	MidiSendCommand("close all");
    67 	MidiSendCommand("close all");
    68 }
    68 }
    69 
    69 
    70 static void MidiIntSetVolume(int vol)
    70 static void MidiIntSetVolume(int vol)
    71 {
    71 {
    72 	DWORD v = (vol * 65535 / 127);
    72 	DWORD v = (vol * 65535 / 127);
    73 	midiOutSetVolume((HMIDIOUT)_midi.devid, v + (v << 16));
    73 	midiOutSetVolume((HMIDIOUT)_midi.devid, v + (v << 16));
    74 }
    74 }
    75 
    75 
    76 static bool MidiIntIsSongPlaying(void)
    76 static bool MidiIntIsSongPlaying()
    77 {
    77 {
    78 	char buf[16];
    78 	char buf[16];
    79 	mciSendStringA("status song mode", buf, sizeof(buf), 0);
    79 	mciSendStringA("status song mode", buf, sizeof(buf), 0);
    80 	return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
    80 	return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0;
    81 }
    81 }
   144 	if (CreateThread(NULL, 8192, MidiThread, 0, 0, &threadId) == NULL) return "Failed to create thread";
   144 	if (CreateThread(NULL, 8192, MidiThread, 0, 0, &threadId) == NULL) return "Failed to create thread";
   145 
   145 
   146 	return NULL;
   146 	return NULL;
   147 }
   147 }
   148 
   148 
   149 static void Win32MidiStop(void)
   149 static void Win32MidiStop()
   150 {
   150 {
   151 	_midi.terminate = true;
   151 	_midi.terminate = true;
   152 	SetEvent(_midi.wait_obj);
   152 	SetEvent(_midi.wait_obj);
   153 }
   153 }
   154 
   154