dmusic: Implement IDirectMusicBuffer::PackUnstructured().

Henri Verbeet hverbeet at gmail.com
Mon May 1 08:45:05 CDT 2017


On 1 May 2017 at 02:05, Michael Stefaniuc <mstefani at winehq.org> wrote:
> -static HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured(LPDIRECTMUSICBUFFER iface, REFERENCE_TIME rt, DWORD dwChannelGroup, DWORD cb, LPBYTE lpb)
> +static HRESULT WINAPI IDirectMusicBufferImpl_PackUnstructured(IDirectMusicBuffer *iface,
> +        REFERENCE_TIME ref_time, DWORD channel_group, DWORD len, BYTE *data)
>  {
>      IDirectMusicBufferImpl *This = impl_from_IDirectMusicBuffer(iface);
> +    DWORD new_write_pos = This->write_pos + DMUS_EVENT_SIZE(len);
> +    DMUS_EVENTHEADER header;
> +
> +    TRACE("(%p, 0x%s, %d, %d, %p)\n", This, wine_dbgstr_longlong(ref_time), channel_group, len, data);
>
> -    FIXME("(%p, 0x%s, %d, %d, %p): stub\n", This, wine_dbgstr_longlong(rt), dwChannelGroup, cb, lpb);
> +    if (new_write_pos > This->size)
> +        return DMUS_E_BUFFER_FULL;
> +
> +    if (!This->write_pos)
> +        This->start_time = ref_time;
> +
> +    header.cbEvent = len;
> +    header.dwChannelGroup = channel_group;
> +    header.rtDelta = ref_time - This->start_time;
> +    header.dwFlags = 0;
> +
> +    memcpy(This->data + This->write_pos, &header, sizeof(header));
> +    memcpy(This->data + This->write_pos + sizeof(header), data, len);
The difference is of course largely stylistic, but note that you could
also do something like the following:

    DMUS_EVENTHEADER *header;
    ...
    header = (DMUS_EVENTHEADER *)&This->data[This->write_pos];
    ...
    memcpy(&header[1], data, len);



More information about the wine-devel mailing list