From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmime/performance.c | 35 ++++++++++++++++++----------------- dlls/dmime/tests/dmime.c | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index 67fcdfd2d67..b74d3f47e7b 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -492,25 +492,26 @@ static HRESULT WINAPI performance_IsPlaying(IDirectMusicPerformance8 *iface, return S_FALSE; }
-static HRESULT WINAPI performance_GetTime(IDirectMusicPerformance8 *iface, REFERENCE_TIME *prtNow, MUSIC_TIME *pmtNow) +static HRESULT WINAPI performance_GetTime(IDirectMusicPerformance8 *iface, REFERENCE_TIME *time, MUSIC_TIME *music_time) { - struct performance *This = impl_from_IDirectMusicPerformance8(iface); - HRESULT hr = S_OK; - REFERENCE_TIME rtCur = 0; + struct performance *This = impl_from_IDirectMusicPerformance8(iface); + IReferenceClock *clock; + REFERENCE_TIME now; + HRESULT hr;
- /*TRACE("(%p, %p, %p)\n", This, prtNow, pmtNow); */ - if (This->procThreadTicStarted) { - rtCur = ((REFERENCE_TIME) GetTickCount() * 10000) - This->procThreadStartTime; - } else { - /*return DMUS_E_NO_MASTER_CLOCK;*/ - } - if (NULL != prtNow) { - *prtNow = rtCur; - } - if (NULL != pmtNow) { - hr = IDirectMusicPerformance8_ReferenceToMusicTime(iface, rtCur, pmtNow); - } - return hr; + TRACE("(%p, %p, %p)\n", iface, time, music_time); + + if (!This->dmusic) return DMUS_E_NO_MASTER_CLOCK; + if (SUCCEEDED(hr = IDirectMusic_GetMasterClock(This->dmusic, NULL, &clock))) + { + hr = IReferenceClock_GetTime(clock, &now); + IReferenceClock_Release(clock); + } + + if (FAILED(hr)) return hr; + if (time) *time = now; + if (music_time) hr = IDirectMusicPerformance8_ReferenceToMusicTime(iface, now, music_time); + return hr; }
static HRESULT WINAPI performance_AllocPMsg(IDirectMusicPerformance8 *iface, ULONG cb, DMUS_PMSG **ppPMSG) diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index 6e7fef20d10..8999d5564db 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -1714,7 +1714,7 @@ static void test_performance_time(void) music_time = 0xdeadbeef; hr = IDirectMusicPerformance_GetTime(performance, &time, &music_time); ok(hr == S_OK, "got %#lx\n", hr); - todo_wine ok(time - init_time <= 200 * 10000, "got %I64d\n", time - init_time); + ok(time - init_time <= 200 * 10000, "got %I64d\n", time - init_time); ok(music_time == (time - init_time) / 6510, "got %ld\n", music_time);