Commit 95c21f3f authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

winmm: Support TIME_MIDI position in MIDI stream.

parent 0a788caf
......@@ -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);
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment