dmusic: Implement IDirectMusicBufferImpl_PackStructured.
This commit is contained in:
parent
51942db811
commit
fbd0aba739
|
@ -96,11 +96,33 @@ static HRESULT WINAPI IDirectMusicBufferImpl_TotalTime(LPDIRECTMUSICBUFFER iface
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD dwChannelMessage)
|
||||
static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME ref_time, DWORD channel_group, DWORD channel_message)
|
||||
{
|
||||
IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
|
||||
DWORD new_write_pos = This->write_pos + sizeof(DMUS_EVENTHEADER) + sizeof(DWORD);
|
||||
DMUS_EVENTHEADER header;
|
||||
|
||||
FIXME("(%p, 0x%s, %d, %d): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, dwChannelMessage);
|
||||
TRACE("(%p)->(0x%s, %u, 0x%x)\n", iface, wine_dbgstr_longlong(ref_time), channel_group, channel_message);
|
||||
|
||||
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 */
|
||||
|
||||
if (!(channel_message & 0x80))
|
||||
{
|
||||
/* Status byte MSB is always set */
|
||||
return DMUS_E_INVALID_EVENT;
|
||||
}
|
||||
|
||||
header.cbEvent = sizeof(channel_message);
|
||||
header.dwChannelGroup = channel_group;
|
||||
header.rtDelta = ref_time;
|
||||
header.dwFlags = DMUS_EVENT_STRUCTURED;
|
||||
|
||||
memcpy(This->data + This->write_pos, &header, sizeof(header));
|
||||
*(DWORD*)(This->data + This->write_pos + sizeof(header)) = channel_message;
|
||||
This->write_pos = new_write_pos;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ struct IDirectMusicBufferImpl {
|
|||
GUID format;
|
||||
DWORD size;
|
||||
LPBYTE data;
|
||||
DWORD write_pos;
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
|
|
|
@ -135,6 +135,11 @@ 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);
|
||||
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 */
|
||||
ok(hr == S_OK, "IDirectMusicBuffer_PackStructured returned %x\n", hr);
|
||||
|
||||
if (dmbuffer)
|
||||
IDirectMusicBuffer_Release(dmbuffer);
|
||||
IDirectMusic_Release(dmusic);
|
||||
|
|
Loading…
Reference in New Issue