dmusic: Implement IDirectMusicBuffer_GetStartTime and IDirectMusicBuffer_SetStartTime.

This commit is contained in:
Christian Costa 2012-04-26 08:08:51 +02:00 committed by Alexandre Julliard
parent 5c5ed245aa
commit 09a2dd6a3f
3 changed files with 37 additions and 7 deletions

View File

@ -115,9 +115,12 @@ static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER
return DMUS_E_INVALID_EVENT;
}
if (!This->write_pos)
This->start_time = ref_time;
header.cbEvent = sizeof(channel_message);
header.dwChannelGroup = channel_group;
header.rtDelta = ref_time;
header.rtDelta = ref_time - This->start_time;
header.dwFlags = DMUS_EVENT_STRUCTURED;
memcpy(This->data + This->write_pos, &header, sizeof(header));
@ -168,11 +171,18 @@ static HRESULT WINAPI IDirectMusicBufferImpl_GetRawBufferPtr(LPDIRECTMUSICBUFFER
return S_OK;
}
static HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime(LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME prt)
static HRESULT WINAPI IDirectMusicBufferImpl_GetStartTime(LPDIRECTMUSICBUFFER iface, LPREFERENCE_TIME ref_time)
{
IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
FIXME("(%p, %p): stub\n", This, prt);
TRACE("(%p)->(%p)\n", iface, ref_time);
if (!ref_time)
return E_POINTER;
if (!This->write_pos)
return DMUS_E_BUFFER_EMPTY;
*ref_time = This->start_time;
return S_OK;
}
@ -218,11 +228,13 @@ static HRESULT WINAPI IDirectMusicBufferImpl_GetBufferFormat(LPDIRECTMUSICBUFFER
return S_OK;
}
static HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt)
static HRESULT WINAPI IDirectMusicBufferImpl_SetStartTime(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME ref_time)
{
IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
FIXME("(%p, 0x%s): stub\n", This, wine_dbgstr_longlong(rt));
TRACE("(%p)->(0x%s)\n", This, wine_dbgstr_longlong(ref_time));
This->start_time = ref_time;
return S_OK;
}

View File

@ -114,6 +114,7 @@ struct IDirectMusicBufferImpl {
DWORD size;
LPBYTE data;
DWORD write_pos;
REFERENCE_TIME start_time;
};
/*****************************************************************************

View File

@ -113,6 +113,7 @@ static void test_dmbuffer(void)
GUID format;
DWORD size;
DWORD bytes;
REFERENCE_TIME time;
hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic, (LPVOID*)&dmusic);
if (hr != S_OK)
@ -136,14 +137,30 @@ static void test_dmbuffer(void)
ok(hr == S_OK, "IDirectMusicBuffer_GetMaxBytes returned %x\n", hr);
ok(size == 1024, "Buffer size is %u instead of 1024\n", size);
hr = IDirectMusicBuffer_PackStructured(dmbuffer, 10, 0, 0);
hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
ok(hr == DMUS_E_BUFFER_EMPTY, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
hr = IDirectMusicBuffer_SetStartTime(dmbuffer, 10);
ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
ok(hr == DMUS_E_BUFFER_EMPTY, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
hr = IDirectMusicBuffer_PackStructured(dmbuffer, 20, 0, 0);
ok(hr == DMUS_E_INVALID_EVENT, "IDirectMusicBuffer_PackStructured returned %x\n", hr);
hr = IDirectMusicBuffer_PackStructured(dmbuffer, 10, 0, 0x000090); /* note on : chan 0, note 0 & vel 0 */
hr = IDirectMusicBuffer_PackStructured(dmbuffer, 20, 0, 0x000090); /* note on : chan 0, note 0 & vel 0 */
ok(hr == S_OK, "IDirectMusicBuffer_PackStructured returned %x\n", hr);
hr = IDirectMusicBuffer_GetUsedBytes(dmbuffer, &bytes);
ok(hr == S_OK, "IDirectMusicBuffer_GetUsedBytes returned %x\n", hr);
ok(bytes == 24, "Buffer size is %u instead of 0\n", bytes);
hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
ok(time == 20, "Buffer start time is wrong\n");
hr = IDirectMusicBuffer_SetStartTime(dmbuffer, 30);
ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
ok(time == 30, "Buffer start time is wrong\n");
if (dmbuffer)
IDirectMusicBuffer_Release(dmbuffer);
IDirectMusic_Release(dmusic);