winmm: Support TIME_MIDI position in MIDI stream.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2018-07-11 22:33:25 +09:00 committed by Alexandre Julliard
parent 0a788caf8b
commit 95c21f3f94
2 changed files with 20 additions and 5 deletions

View File

@ -698,7 +698,7 @@ static void test_midiStream(UINT udev, HWND hwnd)
test_position(hm, TIME_MS, TIME_MS);
test_position(hm, TIME_TICKS, TIME_TICKS);
todo_wine test_position(hm, TIME_MIDI, TIME_MIDI);
test_position(hm, TIME_MIDI, TIME_MIDI);
test_position(hm, TIME_SMPTE, TIME_MS);
test_position(hm, TIME_SAMPLES, TIME_MS);
test_position(hm, TIME_BYTES, TIME_MS);
@ -933,7 +933,7 @@ static void test_midiStream(UINT udev, HWND hwnd)
/* TIME_MIDI value is a quarter of TIME_TICKS, rounded */
expected = (ret + midiprop.tdiv.dwTimeDiv/8) / (midiprop.tdiv.dwTimeDiv/4);
ret = get_position(hm, TIME_MIDI);
todo_wine ok(ret == expected, "expected song pointer %u, got %u\n", expected, ret);
ok(ret == expected, "expected song pointer %u, got %u\n", expected, ret);
ok(records.count == 2, "expected 2 MM_MOM_DONE messages, got %d\n", records.count);

View File

@ -1508,9 +1508,17 @@ MMRESULT WINAPI midiStreamPosition(HMIDISTRM hMidiStrm, LPMMTIME lpMMT, UINT cbm
} else {
EnterCriticalSection(&lpMidiStrm->lock);
switch (lpMMT->wType) {
default:
FIXME("Unsupported time type %x\n", lpMMT->wType);
/* fall through */
case TIME_MIDI:
if (lpMidiStrm->dwTimeDiv < 0x8000) {
DWORD tdiv, pulses;
tdiv = (lpMidiStrm->dwTimeDiv > 24) ? lpMidiStrm->dwTimeDiv : 24;
pulses = midistream_get_current_pulse(lpMidiStrm);
lpMMT->u.midi.songptrpos = (pulses + tdiv/8) / (tdiv/4);
if (!lpMMT->u.midi.songptrpos && pulses) lpMMT->u.midi.songptrpos++;
TRACE("=> song position %d (pulses %u, tdiv %u)\n", lpMMT->u.midi.songptrpos, pulses, tdiv);
break;
}
/* fall through */
case TIME_BYTES:
case TIME_SAMPLES:
lpMMT->wType = TIME_MS;
@ -1523,6 +1531,13 @@ MMRESULT WINAPI midiStreamPosition(HMIDISTRM hMidiStrm, LPMMTIME lpMMT, UINT cbm
lpMMT->u.ticks = midistream_get_current_pulse(lpMidiStrm);
TRACE("=> %d ticks\n", lpMMT->u.ticks);
break;
default:
FIXME("Unsupported time type %x\n", lpMMT->wType);
/* use TIME_MS instead */
lpMMT->wType = TIME_MS;
lpMMT->u.ms = midistream_get_playing_position(lpMidiStrm);
TRACE("=> %d ms\n", lpMMT->u.ms);
break;
}
LeaveCriticalSection(&lpMidiStrm->lock);
}