Module: wine Branch: master Commit: 950b8a9699fc640b0b58126ce38d25ddaf91dac9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=950b8a9699fc640b0b58126ce3...
Author: Michael Stefaniuc mstefani@winehq.org Date: Mon May 1 23:58:50 2017 +0200
dmusic: Avoid an intermediate copy in PackStructured().
Signed-off-by: Michael Stefaniuc mstefani@winehq.org Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/dmusic/buffer.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlls/dmusic/buffer.c b/dlls/dmusic/buffer.c index dbc8058..9b0ca84 100644 --- a/dlls/dmusic/buffer.c +++ b/dlls/dmusic/buffer.c @@ -101,7 +101,7 @@ static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER { IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface); 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);
@@ -119,13 +119,13 @@ static HRESULT WINAPI IDirectMusicBufferImpl_PackStructured(LPDIRECTMUSICBUFFER if (!This->write_pos) This->start_time = ref_time;
- 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; + header = (DMUS_EVENTHEADER*)&This->data[This->write_pos]; + 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;
- memcpy(This->data + This->write_pos, &header, sizeof(header)); - *(DWORD*)(This->data + This->write_pos + sizeof(header)) = channel_message; + *(DWORD*)&header[1] = channel_message; This->write_pos = new_write_pos;
return S_OK;