Commit 52ae3fad authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmime: Implement MusicToReferenceTime and ReferenceToMusicTime.

parent d407b3ca
......@@ -66,6 +66,7 @@ struct performance
struct DMUS_PMSGItem *imm_head;
IReferenceClock *master_clock;
REFERENCE_TIME init_time;
};
typedef struct DMUS_PMSGItem DMUS_PMSGItem;
......@@ -451,21 +452,41 @@ static HRESULT WINAPI performance_SendPMsg(IDirectMusicPerformance8 *iface, DMUS
}
static HRESULT WINAPI performance_MusicToReferenceTime(IDirectMusicPerformance8 *iface,
MUSIC_TIME mtTime, REFERENCE_TIME *prtTime)
MUSIC_TIME music_time, REFERENCE_TIME *time)
{
struct performance *This = impl_from_IDirectMusicPerformance8(iface);
struct performance *This = impl_from_IDirectMusicPerformance8(iface);
FIXME("(%p, %ld, %p): stub\n", This, mtTime, prtTime);
return S_OK;
FIXME("(%p, %ld, %p): semi-stub\n", This, music_time, time);
if (!time) return E_POINTER;
*time = 0;
if (!This->master_clock) return DMUS_E_NO_MASTER_CLOCK;
/* FIXME: This should be (music_time * 60) / (DMUS_PPQ * tempo)
* but it gives innacurate results */
*time = This->init_time + (music_time * 6510);
return S_OK;
}
static HRESULT WINAPI performance_ReferenceToMusicTime(IDirectMusicPerformance8 *iface,
REFERENCE_TIME rtTime, MUSIC_TIME *pmtTime)
REFERENCE_TIME time, MUSIC_TIME *music_time)
{
struct performance *This = impl_from_IDirectMusicPerformance8(iface);
struct performance *This = impl_from_IDirectMusicPerformance8(iface);
FIXME("(%p, 0x%s, %p): stub\n", This, wine_dbgstr_longlong(rtTime), pmtTime);
return S_OK;
FIXME("(%p, %I64d, %p): semi-stub\n", This, time, music_time);
if (!music_time) return E_POINTER;
*music_time = 0;
if (!This->master_clock) return DMUS_E_NO_MASTER_CLOCK;
/* FIXME: This should be (time * DMUS_PPQ * tempo) / 60
* but it gives innacurate results */
*music_time = (time - This->init_time) / 6510;
return S_OK;
}
static HRESULT WINAPI performance_IsPlaying(IDirectMusicPerformance8 *iface,
......@@ -1006,6 +1027,9 @@ static HRESULT WINAPI performance_InitAudio(IDirectMusicPerformance8 *iface, IDi
*dmusic = (IDirectMusic *)This->dmusic;
IDirectMusic_AddRef(*dmusic);
}
if (FAILED(hr = IDirectMusicPerformance8_GetTime(iface, &This->init_time, NULL))) return hr;
PostMessageToProcessMsgThread(This, PROCESSMSG_START);
return S_OK;
......
......@@ -1650,18 +1650,18 @@ static void test_performance_time(void)
hr = IDirectMusicPerformance_MusicToReferenceTime(performance, 0, NULL);
todo_wine ok(hr == E_POINTER, "got %#lx\n", hr);
ok(hr == E_POINTER, "got %#lx\n", hr);
time = 0xdeadbeef;
hr = IDirectMusicPerformance_MusicToReferenceTime(performance, 0, &time);
todo_wine ok(hr == DMUS_E_NO_MASTER_CLOCK, "got %#lx\n", hr);
todo_wine ok(time == 0, "got %I64d\n", time);
ok(hr == DMUS_E_NO_MASTER_CLOCK, "got %#lx\n", hr);
ok(time == 0, "got %I64d\n", time);
hr = IDirectMusicPerformance_ReferenceToMusicTime(performance, 0, NULL);
todo_wine ok(hr == E_POINTER, "got %#lx\n", hr);
ok(hr == E_POINTER, "got %#lx\n", hr);
music_time = 0xdeadbeef;
hr = IDirectMusicPerformance_ReferenceToMusicTime(performance, 0, &music_time);
todo_wine ok(hr == DMUS_E_NO_MASTER_CLOCK, "got %#lx\n", hr);
todo_wine ok(music_time == 0, "got %ld\n", music_time);
ok(hr == DMUS_E_NO_MASTER_CLOCK, "got %#lx\n", hr);
ok(music_time == 0, "got %ld\n", music_time);
dmusic = NULL;
......@@ -1684,38 +1684,38 @@ static void test_performance_time(void)
time = 0xdeadbeef;
hr = IDirectMusicPerformance_MusicToReferenceTime(performance, 1, &time);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(time - init_time >= 6505, "got %I64d\n", time - init_time);
ok(time - init_time >= 6505, "got %I64d\n", time - init_time);
ok(time - init_time <= 6515, "got %I64d\n", time - init_time);
time = 0xdeadbeef;
hr = IDirectMusicPerformance_MusicToReferenceTime(performance, 1000, &time);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(time - init_time >= 1000 * 6505, "got %I64d\n", time - init_time);
ok(time - init_time >= 1000 * 6505, "got %I64d\n", time - init_time);
ok(time - init_time <= 1000 * 6515, "got %I64d\n", time - init_time);
time = 0xdeadbeef;
hr = IDirectMusicPerformance_MusicToReferenceTime(performance, 2000, &time);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(time - init_time >= 2000 * 6505, "got %I64d\n", time - init_time);
ok(time - init_time >= 2000 * 6505, "got %I64d\n", time - init_time);
ok(time - init_time <= 2000 * 6515, "got %I64d\n", time - init_time);
music_time = 0xdeadbeef;
hr = IDirectMusicPerformance_ReferenceToMusicTime(performance, init_time, &music_time);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(music_time == 0, "got %ld\n", music_time);
ok(music_time == 0, "got %ld\n", music_time);
music_time = 0xdeadbeef;
hr = IDirectMusicPerformance_ReferenceToMusicTime(performance, init_time + 1000 * 6510, &music_time);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(music_time == 1000, "got %ld\n", music_time);
ok(music_time == 1000, "got %ld\n", music_time);
music_time = 0xdeadbeef;
hr = IDirectMusicPerformance_ReferenceToMusicTime(performance, init_time + 2000 * 6510, &music_time);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(music_time == 2000, "got %ld\n", music_time);
ok(music_time == 2000, "got %ld\n", music_time);
time = 0xdeadbeef;
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);
todo_wine ok(music_time == (time - init_time) / 6510, "got %ld\n", music_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);
hr = IDirectMusicPerformance_CloseDown(performance);
......
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