Module: wine Branch: master Commit: 9f05f54540f04e50e67cba7aed73ae67277df24d URL: http://source.winehq.org/git/wine.git/?a=commit;h=9f05f54540f04e50e67cba7aed...
Author: Christian Costa titan.costa@gmail.com Date: Fri May 4 08:40:38 2012 +0200
dmusic: Midi message takes 4 bytes space but only 3 are relevant.
---
dlls/dmusic/buffer.c | 4 +- dlls/dmusic/tests/dmusic.c | 50 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/dlls/dmusic/buffer.c b/dlls/dmusic/buffer.c index bf60470..2fd76b5 100644 --- a/dlls/dmusic/buffer.c +++ b/dlls/dmusic/buffer.c @@ -109,7 +109,7 @@ static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER if (new_write_pos > This->size) return DMUS_E_BUFFER_FULL;
- /* Channel_message 0xZZYYXX is a midi message where XX = status byte, YY = byte 1 and ZZ = byte 2 */ + /* Channel_message 0xZZYYXX (3 bytes) is a midi message where XX = status byte, YY = byte 1 and ZZ = byte 2 */
if (!(channel_message & 0x80)) { @@ -120,7 +120,7 @@ static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER if (!This->write_pos) This->start_time = ref_time;
- header.cbEvent = sizeof(channel_message); + header.cbEvent = 3; /* Midi message takes 4 bytes space but only 3 are relevant */ header.dwChannelGroup = channel_group; header.rtDelta = ref_time - This->start_time; header.dwFlags = DMUS_EVENT_STRUCTURED; diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c index fb4b307..24ae90d 100644 --- a/dlls/dmusic/tests/dmusic.c +++ b/dlls/dmusic/tests/dmusic.c @@ -29,7 +29,7 @@ #include "dmusici.h" #include "dmksctrl.h"
-static inline char* debugstr_guid(CONST GUID *id) +static inline const char* debugstr_guid(CONST GUID *id) { static char string[39]; sprintf(string, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", @@ -39,6 +39,16 @@ static inline char* debugstr_guid(CONST GUID *id) return string; }
+static inline const char* debugstr_longlong(ULONGLONG ll) +{ + static char string[17]; + if (sizeof(ll) > sizeof(unsigned long) && ll >> 32) + sprintf(string, "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll); + else + sprintf(string, "%lx", (unsigned long)ll); + return string; +} + static void test_dmusic(void) { IDirectMusic *dmusic = NULL; @@ -127,6 +137,7 @@ static void test_dmbuffer(void) DWORD size; DWORD bytes; REFERENCE_TIME time; + LPBYTE data;
hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic, (LPVOID*)&dmusic); if (hr != S_OK) @@ -161,18 +172,49 @@ static void test_dmbuffer(void) ok(hr == DMUS_E_INVALID_EVENT, "IDirectMusicBuffer_PackStructured returned %x\n", hr); 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_PackStructured(dmbuffer, 30, 0, 0x000080); /* note off : 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); + ok(bytes == 48, "Buffer size is %u instead of 48\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); + hr = IDirectMusicBuffer_SetStartTime(dmbuffer, 40); 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"); + ok(time == 40, "Buffer start time is wrong\n"); + + hr = IDirectMusicBuffer_GetRawBufferPtr(dmbuffer, &data); + ok(hr == S_OK, "IDirectMusicBuffer_GetRawBufferPtr returned %x\n", hr); + if (hr == S_OK) + { + DMUS_EVENTHEADER* header; + DWORD message; + + /* Check message 1 */ + header = (DMUS_EVENTHEADER*)data; + data += sizeof(DMUS_EVENTHEADER); + ok(header->cbEvent == 3, "cbEvent is %u instead of 3\n", header->cbEvent); + ok(header->dwChannelGroup == 0, "dwChannelGroup is %u instead of 0\n", header->dwChannelGroup); + ok(header->rtDelta == 0, "rtDelta is %s instead of 0\n", debugstr_longlong(header->rtDelta)); + ok(header->dwFlags == DMUS_EVENT_STRUCTURED, "dwFlags is %x instead of %x\n", header->dwFlags, DMUS_EVENT_STRUCTURED); + message = *(DWORD*)data & 0xffffff; /* Only 3 bytes are relevant */ + data += sizeof(DWORD); + ok(message == 0x000090, "Message is %0x instead of 0x000090\n", message); + + /* Check message 2 */ + header = (DMUS_EVENTHEADER*)data; + data += sizeof(DMUS_EVENTHEADER); + ok(header->cbEvent == 3, "cbEvent is %u instead of 3\n", header->cbEvent); + ok(header->dwChannelGroup == 0, "dwChannelGroup is %u instead of 0\n", header->dwChannelGroup); + ok(header->rtDelta == 10, "rtDelta is %s instead of 0\n", debugstr_longlong(header->rtDelta)); + ok(header->dwFlags == DMUS_EVENT_STRUCTURED, "dwFlags is %x instead of %x\n", header->dwFlags, DMUS_EVENT_STRUCTURED); + message = *(DWORD*)data & 0xffffff; /* Only 3 bytes are relevant */ + ok(message == 0x000080, "Message 2 is %0x instead of 0x000080\n", message); + }
if (dmbuffer) IDirectMusicBuffer_Release(dmbuffer);