Module: wine Branch: master Commit: 09a2dd6a3fe440d7ae887e2de16e1db7f3c3f712 URL: http://source.winehq.org/git/wine.git/?a=commit;h=09a2dd6a3fe440d7ae887e2de1...
Author: Christian Costa titan.costa@gmail.com Date: Thu Apr 26 08:08:51 2012 +0200
dmusic: Implement IDirectMusicBuffer_GetStartTime and IDirectMusicBuffer_SetStartTime.
---
dlls/dmusic/buffer.c | 22 +++++++++++++++++----- dlls/dmusic/dmusic_private.h | 1 + dlls/dmusic/tests/dmusic.c | 21 +++++++++++++++++++-- 3 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/dlls/dmusic/buffer.c b/dlls/dmusic/buffer.c index f4ea22c..ca53db3 100644 --- a/dlls/dmusic/buffer.c +++ b/dlls/dmusic/buffer.c @@ -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; } diff --git a/dlls/dmusic/dmusic_private.h b/dlls/dmusic/dmusic_private.h index f4897ac..23d010d 100644 --- a/dlls/dmusic/dmusic_private.h +++ b/dlls/dmusic/dmusic_private.h @@ -114,6 +114,7 @@ struct IDirectMusicBufferImpl { DWORD size; LPBYTE data; DWORD write_pos; + REFERENCE_TIME start_time; };
/***************************************************************************** diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c index 71e89fd..a05afcc 100644 --- a/dlls/dmusic/tests/dmusic.c +++ b/dlls/dmusic/tests/dmusic.c @@ -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);