Commit 80e6310a authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmusic: Use the IDirectMusicObject interface for waves.

parent dc0431b8
...@@ -24,7 +24,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmime); ...@@ -24,7 +24,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmime);
struct wave_item { struct wave_item {
struct list entry; struct list entry;
DMUS_IO_WAVE_ITEM_HEADER header; DMUS_IO_WAVE_ITEM_HEADER header;
IUnknown *object; IDirectMusicObject *object;
IDirectSoundBuffer *buffer; IDirectSoundBuffer *buffer;
}; };
...@@ -106,7 +106,7 @@ static ULONG WINAPI wave_track_Release(IDirectMusicTrack8 *iface) ...@@ -106,7 +106,7 @@ static ULONG WINAPI wave_track_Release(IDirectMusicTrack8 *iface)
{ {
list_remove(&item->entry); list_remove(&item->entry);
if (item->buffer) IDirectSoundBuffer_Release(item->buffer); if (item->buffer) IDirectSoundBuffer_Release(item->buffer);
if (item->object) IUnknown_Release(item->object); if (item->object) IDirectMusicObject_Release(item->object);
free(item); free(item);
} }
...@@ -469,7 +469,7 @@ static HRESULT parse_wave_item(struct wave_part *part, IStream *stream, struct c ...@@ -469,7 +469,7 @@ static HRESULT parse_wave_item(struct wave_part *part, IStream *stream, struct c
hr = DMUS_E_UNSUPPORTED_STREAM; hr = DMUS_E_UNSUPPORTED_STREAM;
goto error; goto error;
} }
if (FAILED(hr = dmobj_parsereference(stream, &chunk, (IDirectMusicObject **)&item->object))) if (FAILED(hr = dmobj_parsereference(stream, &chunk, &item->object)))
goto error; goto error;
list_add_tail(&part->items, &item->entry); list_add_tail(&part->items, &item->entry);
......
...@@ -42,7 +42,7 @@ C_ASSERT(sizeof(struct pool) == offsetof(struct pool, cues[0])); ...@@ -42,7 +42,7 @@ C_ASSERT(sizeof(struct pool) == offsetof(struct pool, cues[0]));
struct wave_entry struct wave_entry
{ {
struct list entry; struct list entry;
IUnknown *wave; IDirectMusicObject *wave;
DWORD offset; DWORD offset;
}; };
...@@ -59,13 +59,13 @@ struct collection ...@@ -59,13 +59,13 @@ struct collection
struct list waves; struct list waves;
}; };
extern void collection_internal_addref(struct collection *collection) void collection_internal_addref(struct collection *collection)
{ {
ULONG ref = InterlockedIncrement( &collection->internal_ref ); ULONG ref = InterlockedIncrement( &collection->internal_ref );
TRACE( "collection %p, internal ref %lu.\n", collection, 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 ); ULONG ref = InterlockedDecrement( &collection->internal_ref );
TRACE( "collection %p, internal ref %lu.\n", collection, ref ); TRACE( "collection %p, internal ref %lu.\n", collection, ref );
...@@ -74,7 +74,7 @@ extern void collection_internal_release(struct collection *collection) ...@@ -74,7 +74,7 @@ extern void collection_internal_release(struct collection *collection)
free(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; struct wave_entry *wave_entry;
DWORD offset; DWORD offset;
......
...@@ -80,7 +80,7 @@ typedef struct port_info { ...@@ -80,7 +80,7 @@ typedef struct port_info {
struct collection; struct collection;
extern void collection_internal_addref(struct collection *collection); extern void collection_internal_addref(struct collection *collection);
extern void collection_internal_release(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 */ /* CLSID */
extern HRESULT music_create(IUnknown **ret_iface); extern HRESULT music_create(IUnknown **ret_iface);
......
...@@ -29,8 +29,9 @@ ...@@ -29,8 +29,9 @@
struct soundfont; struct soundfont;
struct chunk_entry; struct chunk_entry;
extern HRESULT wave_create_from_soundfont(struct soundfont *soundfont, UINT index, IUnknown **out); 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, IUnknown **out); extern HRESULT wave_create_from_chunk(IStream *stream, struct chunk_entry *parent, IDirectMusicObject **out);
extern HRESULT wave_download_to_port(IUnknown *iface, IDirectMusicPortDownload *port, DWORD *id); extern HRESULT wave_download_to_port(IDirectMusicObject *iface, IDirectMusicPortDownload *port, DWORD *id);
extern HRESULT wave_download_to_dsound(IUnknown *iface, IDirectSound *dsound, IDirectSoundBuffer **ret_iface); extern HRESULT wave_download_to_dsound(IDirectMusicObject *iface, IDirectSound *dsound,
extern HRESULT wave_get_duration(IUnknown *iface, REFERENCE_TIME *duration); IDirectSoundBuffer **ret_iface);
extern HRESULT wave_get_duration(IDirectMusicObject *iface, REFERENCE_TIME *duration);
...@@ -747,7 +747,7 @@ HRESULT instrument_download_to_port(IDirectMusicInstrument *iface, IDirectMusicP ...@@ -747,7 +747,7 @@ HRESULT instrument_download_to_port(IDirectMusicInstrument *iface, IDirectMusicP
IDirectMusicDownload *download; IDirectMusicDownload *download;
DWORD size, offset_count; DWORD size, offset_count;
struct region *region; struct region *region;
IUnknown *wave; IDirectMusicObject *wave;
HRESULT hr; HRESULT hr;
if (This->download) goto done; if (This->download) goto done;
...@@ -827,7 +827,7 @@ HRESULT instrument_download_to_port(IDirectMusicInstrument *iface, IDirectMusicP ...@@ -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))) if (SUCCEEDED(hr = collection_get_wave(This->collection, region->wave_link.ulTableIndex, &wave)))
{ {
hr = wave_download_to_port(wave, port, &dmus_region->WaveLink.ulTableIndex); hr = wave_download_to_port(wave, port, &dmus_region->WaveLink.ulTableIndex);
IUnknown_Release(wave); IDirectMusicObject_Release(wave);
} }
if (FAILED(hr)) goto failed; if (FAILED(hr)) goto failed;
......
...@@ -170,6 +170,11 @@ static HRESULT parse_wave_chunk(struct wave *This, IStream *stream, struct chunk ...@@ -170,6 +170,11 @@ static HRESULT parse_wave_chunk(struct wave *This, IStream *stream, struct chunk
return hr; 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, static HRESULT WINAPI wave_object_ParseDescriptor(IDirectMusicObject *iface,
IStream *stream, DMUS_OBJECTDESC *desc) IStream *stream, DMUS_OBJECTDESC *desc)
{ {
...@@ -259,7 +264,7 @@ static const IPersistStreamVtbl wave_persist_stream_vtbl = ...@@ -259,7 +264,7 @@ static const IPersistStreamVtbl wave_persist_stream_vtbl =
unimpl_IPersistStream_GetSizeMax, unimpl_IPersistStream_GetSizeMax,
}; };
static HRESULT wave_create(IUnknown **ret_iface) static HRESULT wave_create(IDirectMusicObject **ret_iface)
{ {
struct wave *obj; struct wave *obj;
...@@ -270,24 +275,24 @@ static HRESULT wave_create(IUnknown **ret_iface) ...@@ -270,24 +275,24 @@ static HRESULT wave_create(IUnknown **ret_iface)
obj->dmobj.IDirectMusicObject_iface.lpVtbl = &wave_object_vtbl; obj->dmobj.IDirectMusicObject_iface.lpVtbl = &wave_object_vtbl;
obj->dmobj.IPersistStream_iface.lpVtbl = &wave_persist_stream_vtbl; obj->dmobj.IPersistStream_iface.lpVtbl = &wave_persist_stream_vtbl;
*ret_iface = &obj->IUnknown_iface; *ret_iface = &obj->dmobj.IDirectMusicObject_iface;
return S_OK; 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; struct wave *This;
IUnknown *iface; IDirectMusicObject *iface;
HRESULT hr; HRESULT hr;
TRACE("(%p, %p, %p)\n", stream, parent, ret_iface); TRACE("(%p, %p, %p)\n", stream, parent, ret_iface);
if (FAILED(hr = wave_create(&iface))) return hr; 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))) if (FAILED(hr = parse_wave_chunk(This, stream, parent)))
{ {
IUnknown_Release(iface); IDirectMusicObject_Release(iface);
return DMUS_E_UNSUPPORTED_STREAM; return DMUS_E_UNSUPPORTED_STREAM;
} }
...@@ -324,7 +329,7 @@ HRESULT wave_create_from_chunk(IStream *stream, struct chunk_entry *parent, IUnk ...@@ -324,7 +329,7 @@ HRESULT wave_create_from_chunk(IStream *stream, struct chunk_entry *parent, IUnk
return S_OK; 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 sf_sample *sf_sample = soundfont->shdr + index;
struct sample *sample = NULL; struct sample *sample = NULL;
...@@ -333,7 +338,7 @@ HRESULT wave_create_from_soundfont(struct soundfont *soundfont, UINT index, IUnk ...@@ -333,7 +338,7 @@ HRESULT wave_create_from_soundfont(struct soundfont *soundfont, UINT index, IUnk
UINT data_size, offset; UINT data_size, offset;
struct wave *This; struct wave *This;
void *data = NULL; void *data = NULL;
IUnknown *iface; IDirectMusicObject *iface;
TRACE("(%p, %u, %p)\n", soundfont, index, ret_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 ...@@ -360,7 +365,7 @@ HRESULT wave_create_from_soundfont(struct soundfont *soundfont, UINT index, IUnk
if (FAILED(hr = wave_create(&iface))) goto failed; if (FAILED(hr = wave_create(&iface))) goto failed;
This = impl_from_IUnknown(iface); This = impl_from_IDirectMusicObject(iface);
This->format = format; This->format = format;
This->sample = sample; This->sample = sample;
This->data_size = data_size; This->data_size = data_size;
...@@ -403,7 +408,7 @@ failed: ...@@ -403,7 +408,7 @@ failed:
return hr; 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 struct download_buffer
{ {
...@@ -413,7 +418,7 @@ HRESULT wave_download_to_port(IUnknown *iface, IDirectMusicPortDownload *port, D ...@@ -413,7 +418,7 @@ HRESULT wave_download_to_port(IUnknown *iface, IDirectMusicPortDownload *port, D
DMUS_WAVEDATA data; DMUS_WAVEDATA data;
} *buffer; } *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]); DWORD size = offsetof(struct download_buffer, data.byData[This->data_size]);
IDirectMusicDownload *download; IDirectMusicDownload *download;
HRESULT hr; HRESULT hr;
...@@ -446,9 +451,9 @@ HRESULT wave_download_to_port(IUnknown *iface, IDirectMusicPortDownload *port, D ...@@ -446,9 +451,9 @@ HRESULT wave_download_to_port(IUnknown *iface, IDirectMusicPortDownload *port, D
return hr; 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 = DSBUFFERDESC desc =
{ {
.dwSize = sizeof(desc), .dwSize = sizeof(desc),
...@@ -485,9 +490,9 @@ HRESULT wave_download_to_dsound(IUnknown *iface, IDirectSound *dsound, IDirectSo ...@@ -485,9 +490,9 @@ HRESULT wave_download_to_dsound(IUnknown *iface, IDirectSound *dsound, IDirectSo
return S_OK; 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; *duration = (REFERENCE_TIME)This->data_size * 10000000 / This->format->nAvgBytesPerSec;
return S_OK; return S_OK;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment