dmusic: Midi message takes 4 bytes space but only 3 are relevant.
This commit is contained in:
parent
d1cfbbb62c
commit
9f05f54540
|
@ -109,7 +109,7 @@ static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER
|
||||||
if (new_write_pos > This->size)
|
if (new_write_pos > This->size)
|
||||||
return DMUS_E_BUFFER_FULL;
|
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))
|
if (!(channel_message & 0x80))
|
||||||
{
|
{
|
||||||
|
@ -120,7 +120,7 @@ static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER
|
||||||
if (!This->write_pos)
|
if (!This->write_pos)
|
||||||
This->start_time = ref_time;
|
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.dwChannelGroup = channel_group;
|
||||||
header.rtDelta = ref_time - This->start_time;
|
header.rtDelta = ref_time - This->start_time;
|
||||||
header.dwFlags = DMUS_EVENT_STRUCTURED;
|
header.dwFlags = DMUS_EVENT_STRUCTURED;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "dmusici.h"
|
#include "dmusici.h"
|
||||||
#include "dmksctrl.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];
|
static char string[39];
|
||||||
sprintf(string, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
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;
|
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)
|
static void test_dmusic(void)
|
||||||
{
|
{
|
||||||
IDirectMusic *dmusic = NULL;
|
IDirectMusic *dmusic = NULL;
|
||||||
|
@ -127,6 +137,7 @@ static void test_dmbuffer(void)
|
||||||
DWORD size;
|
DWORD size;
|
||||||
DWORD bytes;
|
DWORD bytes;
|
||||||
REFERENCE_TIME time;
|
REFERENCE_TIME time;
|
||||||
|
LPBYTE data;
|
||||||
|
|
||||||
hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic, (LPVOID*)&dmusic);
|
hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic, (LPVOID*)&dmusic);
|
||||||
if (hr != S_OK)
|
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);
|
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 */
|
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);
|
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);
|
hr = IDirectMusicBuffer_GetUsedBytes(dmbuffer, &bytes);
|
||||||
ok(hr == S_OK, "IDirectMusicBuffer_GetUsedBytes returned %x\n", hr);
|
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);
|
hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
|
||||||
ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
|
ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
|
||||||
ok(time == 20, "Buffer start time is wrong\n");
|
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);
|
ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
|
||||||
hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
|
hr = IDirectMusicBuffer_GetStartTime(dmbuffer, &time);
|
||||||
ok(hr == S_OK, "IDirectMusicBuffer_GetStartTime returned %x\n", hr);
|
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)
|
if (dmbuffer)
|
||||||
IDirectMusicBuffer_Release(dmbuffer);
|
IDirectMusicBuffer_Release(dmbuffer);
|
||||||
|
|
Loading…
Reference in New Issue