From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55792 --- dlls/dmime/wavetrack.c | 6 +++--- dlls/dmusic/collection.c | 8 ++++---- dlls/dmusic/dmusic_private.h | 2 +- dlls/dmusic/dmusic_wave.h | 11 ++++++----- dlls/dmusic/instrument.c | 4 ++-- dlls/dmusic/wave.c | 35 ++++++++++++++++++++--------------- 6 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/dlls/dmime/wavetrack.c b/dlls/dmime/wavetrack.c index fcf57c1148d..5ba9fb675f5 100644 --- a/dlls/dmime/wavetrack.c +++ b/dlls/dmime/wavetrack.c @@ -24,7 +24,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmime); struct wave_item { struct list entry; DMUS_IO_WAVE_ITEM_HEADER header; - IUnknown *object; + IDirectMusicObject *object; IDirectSoundBuffer *buffer; };
@@ -106,7 +106,7 @@ static ULONG WINAPI wave_track_Release(IDirectMusicTrack8 *iface) { list_remove(&item->entry); if (item->buffer) IDirectSoundBuffer_Release(item->buffer); - if (item->object) IUnknown_Release(item->object); + if (item->object) IDirectMusicObject_Release(item->object); free(item); }
@@ -469,7 +469,7 @@ static HRESULT parse_wave_item(struct wave_part *part, IStream *stream, struct c hr = DMUS_E_UNSUPPORTED_STREAM; goto error; } - if (FAILED(hr = dmobj_parsereference(stream, &chunk, (IDirectMusicObject **)&item->object))) + if (FAILED(hr = dmobj_parsereference(stream, &chunk, &item->object))) goto error;
list_add_tail(&part->items, &item->entry); diff --git a/dlls/dmusic/collection.c b/dlls/dmusic/collection.c index bf21d3148e3..5cf129cfdd1 100644 --- a/dlls/dmusic/collection.c +++ b/dlls/dmusic/collection.c @@ -42,7 +42,7 @@ C_ASSERT(sizeof(struct pool) == offsetof(struct pool, cues[0])); struct wave_entry { struct list entry; - IUnknown *wave; + IDirectMusicObject *wave; DWORD offset; };
@@ -59,13 +59,13 @@ struct collection struct list waves; };
-extern void collection_internal_addref(struct collection *collection) +void collection_internal_addref(struct collection *collection) { ULONG ref = InterlockedIncrement( &collection->internal_ref ); TRACE( "collection %p, internal ref %lu.\n", collection, ref ); }
-extern void collection_internal_release(struct collection *collection) +void collection_internal_release(struct collection *collection) { ULONG ref = InterlockedDecrement( &collection->internal_ref ); TRACE( "collection %p, internal ref %lu.\n", collection, ref ); @@ -74,7 +74,7 @@ extern void collection_internal_release(struct collection *collection) free(collection); }
-extern HRESULT collection_get_wave(struct collection *collection, DWORD index, IUnknown **out) +HRESULT collection_get_wave(struct collection *collection, DWORD index, IDirectMusicObject **out) { struct wave_entry *wave_entry; DWORD offset; diff --git a/dlls/dmusic/dmusic_private.h b/dlls/dmusic/dmusic_private.h index 0bb3d5aaf83..c3e627481a7 100644 --- a/dlls/dmusic/dmusic_private.h +++ b/dlls/dmusic/dmusic_private.h @@ -80,7 +80,7 @@ typedef struct port_info { struct collection; extern void collection_internal_addref(struct collection *collection); extern void collection_internal_release(struct collection *collection); -extern HRESULT collection_get_wave(struct collection *collection, DWORD index, IUnknown **out); +extern HRESULT collection_get_wave(struct collection *collection, DWORD index, IDirectMusicObject **out);
/* CLSID */ extern HRESULT music_create(IUnknown **ret_iface); diff --git a/dlls/dmusic/dmusic_wave.h b/dlls/dmusic/dmusic_wave.h index 43396250261..f5ebaed2892 100644 --- a/dlls/dmusic/dmusic_wave.h +++ b/dlls/dmusic/dmusic_wave.h @@ -29,8 +29,9 @@ struct soundfont; struct chunk_entry;
-extern HRESULT wave_create_from_soundfont(struct soundfont *soundfont, UINT index, IUnknown **out); -extern HRESULT wave_create_from_chunk(IStream *stream, struct chunk_entry *parent, IUnknown **out); -extern HRESULT wave_download_to_port(IUnknown *iface, IDirectMusicPortDownload *port, DWORD *id); -extern HRESULT wave_download_to_dsound(IUnknown *iface, IDirectSound *dsound, IDirectSoundBuffer **ret_iface); -extern HRESULT wave_get_duration(IUnknown *iface, REFERENCE_TIME *duration); +extern HRESULT wave_create_from_soundfont(struct soundfont *soundfont, UINT index, IDirectMusicObject **out); +extern HRESULT wave_create_from_chunk(IStream *stream, struct chunk_entry *parent, IDirectMusicObject **out); +extern HRESULT wave_download_to_port(IDirectMusicObject *iface, IDirectMusicPortDownload *port, DWORD *id); +extern HRESULT wave_download_to_dsound(IDirectMusicObject *iface, IDirectSound *dsound, + IDirectSoundBuffer **ret_iface); +extern HRESULT wave_get_duration(IDirectMusicObject *iface, REFERENCE_TIME *duration); diff --git a/dlls/dmusic/instrument.c b/dlls/dmusic/instrument.c index 7a0f8a2f1eb..8311c690877 100644 --- a/dlls/dmusic/instrument.c +++ b/dlls/dmusic/instrument.c @@ -747,7 +747,7 @@ HRESULT instrument_download_to_port(IDirectMusicInstrument *iface, IDirectMusicP IDirectMusicDownload *download; DWORD size, offset_count; struct region *region; - IUnknown *wave; + IDirectMusicObject *wave; HRESULT hr;
if (This->download) goto done; @@ -827,7 +827,7 @@ HRESULT instrument_download_to_port(IDirectMusicInstrument *iface, IDirectMusicP if (SUCCEEDED(hr = collection_get_wave(This->collection, region->wave_link.ulTableIndex, &wave))) { hr = wave_download_to_port(wave, port, &dmus_region->WaveLink.ulTableIndex); - IUnknown_Release(wave); + IDirectMusicObject_Release(wave); } if (FAILED(hr)) goto failed;
diff --git a/dlls/dmusic/wave.c b/dlls/dmusic/wave.c index e5e7c4dc2a0..0db895f2038 100644 --- a/dlls/dmusic/wave.c +++ b/dlls/dmusic/wave.c @@ -170,6 +170,11 @@ static HRESULT parse_wave_chunk(struct wave *This, IStream *stream, struct chunk return hr; }
+static inline struct wave *impl_from_IDirectMusicObject(IDirectMusicObject *iface) +{ + return CONTAINING_RECORD(iface, struct wave, dmobj.IDirectMusicObject_iface); +} + static HRESULT WINAPI wave_object_ParseDescriptor(IDirectMusicObject *iface, IStream *stream, DMUS_OBJECTDESC *desc) { @@ -259,7 +264,7 @@ static const IPersistStreamVtbl wave_persist_stream_vtbl = unimpl_IPersistStream_GetSizeMax, };
-static HRESULT wave_create(IUnknown **ret_iface) +static HRESULT wave_create(IDirectMusicObject **ret_iface) { struct wave *obj;
@@ -270,24 +275,24 @@ static HRESULT wave_create(IUnknown **ret_iface) obj->dmobj.IDirectMusicObject_iface.lpVtbl = &wave_object_vtbl; obj->dmobj.IPersistStream_iface.lpVtbl = &wave_persist_stream_vtbl;
- *ret_iface = &obj->IUnknown_iface; + *ret_iface = &obj->dmobj.IDirectMusicObject_iface; return S_OK; }
-HRESULT wave_create_from_chunk(IStream *stream, struct chunk_entry *parent, IUnknown **ret_iface) +HRESULT wave_create_from_chunk(IStream *stream, struct chunk_entry *parent, IDirectMusicObject **ret_iface) { struct wave *This; - IUnknown *iface; + IDirectMusicObject *iface; HRESULT hr;
TRACE("(%p, %p, %p)\n", stream, parent, ret_iface);
if (FAILED(hr = wave_create(&iface))) return hr; - This = impl_from_IUnknown(iface); + This = impl_from_IDirectMusicObject(iface);
if (FAILED(hr = parse_wave_chunk(This, stream, parent))) { - IUnknown_Release(iface); + IDirectMusicObject_Release(iface); return DMUS_E_UNSUPPORTED_STREAM; }
@@ -324,7 +329,7 @@ HRESULT wave_create_from_chunk(IStream *stream, struct chunk_entry *parent, IUnk return S_OK; }
-HRESULT wave_create_from_soundfont(struct soundfont *soundfont, UINT index, IUnknown **ret_iface) +HRESULT wave_create_from_soundfont(struct soundfont *soundfont, UINT index, IDirectMusicObject **ret_iface) { struct sf_sample *sf_sample = soundfont->shdr + index; struct sample *sample = NULL; @@ -333,7 +338,7 @@ HRESULT wave_create_from_soundfont(struct soundfont *soundfont, UINT index, IUnk UINT data_size, offset; struct wave *This; void *data = NULL; - IUnknown *iface; + IDirectMusicObject *iface;
TRACE("(%p, %u, %p)\n", soundfont, index, ret_iface);
@@ -360,7 +365,7 @@ HRESULT wave_create_from_soundfont(struct soundfont *soundfont, UINT index, IUnk
if (FAILED(hr = wave_create(&iface))) goto failed;
- This = impl_from_IUnknown(iface); + This = impl_from_IDirectMusicObject(iface); This->format = format; This->sample = sample; This->data_size = data_size; @@ -403,7 +408,7 @@ failed: return hr; }
-HRESULT wave_download_to_port(IUnknown *iface, IDirectMusicPortDownload *port, DWORD *id) +HRESULT wave_download_to_port(IDirectMusicObject *iface, IDirectMusicPortDownload *port, DWORD *id) { struct download_buffer { @@ -413,7 +418,7 @@ HRESULT wave_download_to_port(IUnknown *iface, IDirectMusicPortDownload *port, D DMUS_WAVEDATA data; } *buffer;
- struct wave *This = impl_from_IUnknown(iface); + struct wave *This = impl_from_IDirectMusicObject(iface); DWORD size = offsetof(struct download_buffer, data.byData[This->data_size]); IDirectMusicDownload *download; HRESULT hr; @@ -446,9 +451,9 @@ HRESULT wave_download_to_port(IUnknown *iface, IDirectMusicPortDownload *port, D return hr; }
-HRESULT wave_download_to_dsound(IUnknown *iface, IDirectSound *dsound, IDirectSoundBuffer **ret_iface) +HRESULT wave_download_to_dsound(IDirectMusicObject *iface, IDirectSound *dsound, IDirectSoundBuffer **ret_iface) { - struct wave *This = impl_from_IUnknown(iface); + struct wave *This = impl_from_IDirectMusicObject(iface); DSBUFFERDESC desc = { .dwSize = sizeof(desc), @@ -485,9 +490,9 @@ HRESULT wave_download_to_dsound(IUnknown *iface, IDirectSound *dsound, IDirectSo return S_OK; }
-HRESULT wave_get_duration(IUnknown *iface, REFERENCE_TIME *duration) +HRESULT wave_get_duration(IDirectMusicObject *iface, REFERENCE_TIME *duration) { - struct wave *This = impl_from_IUnknown(iface); + struct wave *This = impl_from_IDirectMusicObject(iface); *duration = (REFERENCE_TIME)This->data_size * 10000000 / This->format->nAvgBytesPerSec; return S_OK; }