dmusic: Avoid an intermediate copy in PackStructured().

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2017-05-01 23:58:50 +02:00 committed by Alexandre Julliard
parent 7cd7f14696
commit 950b8a9699
1 changed files with 7 additions and 7 deletions

View File

@ -101,7 +101,7 @@ static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER
{ {
IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface); IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
DWORD new_write_pos = This->write_pos + DMUS_EVENT_SIZE(sizeof(channel_message)); DWORD new_write_pos = This->write_pos + DMUS_EVENT_SIZE(sizeof(channel_message));
DMUS_EVENTHEADER header; DMUS_EVENTHEADER *header;
TRACE("(%p)->(0x%s, %u, 0x%x)\n", iface, wine_dbgstr_longlong(ref_time), channel_group, channel_message); TRACE("(%p)->(0x%s, %u, 0x%x)\n", iface, wine_dbgstr_longlong(ref_time), channel_group, channel_message);
@ -119,13 +119,13 @@ 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 = 3; /* Midi message takes 4 bytes space but only 3 are relevant */ header = (DMUS_EVENTHEADER*)&This->data[This->write_pos];
header.dwChannelGroup = channel_group; header->cbEvent = 3; /* Midi message takes 4 bytes space but only 3 are relevant */
header.rtDelta = ref_time - This->start_time; header->dwChannelGroup = channel_group;
header.dwFlags = DMUS_EVENT_STRUCTURED; header->rtDelta = ref_time - This->start_time;
header->dwFlags = DMUS_EVENT_STRUCTURED;
memcpy(This->data + This->write_pos, &header, sizeof(header)); *(DWORD*)&header[1] = channel_message;
*(DWORD*)(This->data + This->write_pos + sizeof(header)) = channel_message;
This->write_pos = new_write_pos; This->write_pos = new_write_pos;
return S_OK; return S_OK;