Fixes https://bugs.winehq.org/show_bug.cgi?id=53941
Should be a fairly safe change as both methods were returning S_OK without touching the return pointer. Also Chicken Tournament is the first application in my collection that uses those methods.
From: Michael Stefaniuc mstefani@winehq.org
--- dlls/dmime/segment.c | 52 ++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 21 deletions(-)
diff --git a/dlls/dmime/segment.c b/dlls/dmime/segment.c index b1dd21c1242..b7d7f2142b8 100644 --- a/dlls/dmime/segment.c +++ b/dlls/dmime/segment.c @@ -826,28 +826,38 @@ static const IPersistStreamVtbl persiststream_vtbl = { unimpl_IPersistStream_GetSizeMax };
+IDirectMusicSegment8Impl *create_segment(void) +{ + IDirectMusicSegment8Impl *obj; + + if (!(obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj)))) + return NULL; + + obj->IDirectMusicSegment8_iface.lpVtbl = &dmsegment8_vtbl; + obj->ref = 1; + dmobject_init(&obj->dmobj, &CLSID_DirectMusicSegment, (IUnknown *)&obj->IDirectMusicSegment8_iface); + obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl; + obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl; + list_init (&obj->Tracks); + + DMIME_LockModule(); + + return obj; +} + /* for ClassFactory */ -HRESULT create_dmsegment(REFIID lpcGUID, void **ppobj) +HRESULT create_dmsegment(REFIID guid, void **ret_iface) { - IDirectMusicSegment8Impl* obj; - HRESULT hr; + IDirectMusicSegment8Impl *obj; + HRESULT hr;
- obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSegment8Impl)); - if (NULL == obj) { - *ppobj = NULL; - return E_OUTOFMEMORY; - } - obj->IDirectMusicSegment8_iface.lpVtbl = &dmsegment8_vtbl; - obj->ref = 1; - dmobject_init(&obj->dmobj, &CLSID_DirectMusicSegment, - (IUnknown *)&obj->IDirectMusicSegment8_iface); - obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl; - obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl; - list_init (&obj->Tracks); - - DMIME_LockModule(); - hr = IDirectMusicSegment8_QueryInterface(&obj->IDirectMusicSegment8_iface, lpcGUID, ppobj); - IDirectMusicSegment8_Release(&obj->IDirectMusicSegment8_iface); - - return hr; + if (!(obj = create_segment())) { + *ret_iface = NULL; + return E_OUTOFMEMORY; + } + + hr = IDirectMusicSegment8_QueryInterface(&obj->IDirectMusicSegment8_iface, guid, ret_iface); + IDirectMusicSegment8_Release(&obj->IDirectMusicSegment8_iface); + + return hr; }
From: Michael Stefaniuc mstefani@winehq.org
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53941 --- dlls/dmime/segment.c | 50 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/dlls/dmime/segment.c b/dlls/dmime/segment.c index b7d7f2142b8..bf44c5e73b3 100644 --- a/dlls/dmime/segment.c +++ b/dlls/dmime/segment.c @@ -35,6 +35,8 @@ typedef struct IDirectMusicSegment8Impl { struct list Tracks; } IDirectMusicSegment8Impl;
+IDirectMusicSegment8Impl *create_segment(void); + static inline IDirectMusicSegment8Impl *impl_from_IDirectMusicSegment8(IDirectMusicSegment8 *iface) { return CONTAINING_RECORD(iface, IDirectMusicSegment8Impl, IDirectMusicSegment8_iface); @@ -410,12 +412,50 @@ static HRESULT WINAPI IDirectMusicSegment8Impl_SetParam(IDirectMusicSegment8 *if return S_OK; }
-static HRESULT WINAPI IDirectMusicSegment8Impl_Clone(IDirectMusicSegment8 *iface, - MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicSegment **ppSegment) +static HRESULT WINAPI IDirectMusicSegment8Impl_Clone(IDirectMusicSegment8 *iface, MUSIC_TIME start, MUSIC_TIME end, + IDirectMusicSegment **segment) { - IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface); - FIXME("(%p, %ld, %ld, %p): stub\n", This, mtStart, mtEnd, ppSegment); - return S_OK; + IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface); + IDirectMusicSegment8Impl *clone; + IDirectMusicTrack *track; + DMUS_PRIVATE_SEGMENT_TRACK *track_item, *cloned_item; + HRESULT hr; + BOOL track_clone_fail = FALSE; + + TRACE("(%p, %ld, %ld, %p)\n", This, start, end, segment); + + if (!segment) + return E_POINTER; + + if (!(clone = create_segment())) { + *segment = NULL; + return E_OUTOFMEMORY; + } + + clone->header = This->header; + clone->pGraph = This->pGraph; + if (clone->pGraph) + IDirectMusicGraph_AddRef(clone->pGraph); + + LIST_FOR_EACH_ENTRY(track_item, &This->Tracks, DMUS_PRIVATE_SEGMENT_TRACK, entry) { + if (SUCCEEDED(hr = IDirectMusicTrack_Clone(track_item->pTrack, start, end, &track))) { + if ((cloned_item = HeapAlloc(GetProcessHeap(), 0, sizeof(*cloned_item)))) { + cloned_item->dwGroupBits = track_item->dwGroupBits; + cloned_item->flags = track_item->flags; + cloned_item->pTrack = track; + list_add_tail(&clone->Tracks, &cloned_item->entry); + continue; + } else { + IDirectMusicTrack_Release(track); + } + } + WARN("Failed to clone track %p: %#lx\n", track_item->pTrack, hr); + track_clone_fail = TRUE; + } + + *segment = (IDirectMusicSegment *)&clone->IDirectMusicSegment8_iface; + + return track_clone_fail ? S_FALSE : S_OK; }
static HRESULT WINAPI IDirectMusicSegment8Impl_SetStartPoint(IDirectMusicSegment8 *iface,
From: Michael Stefaniuc mstefani@winehq.org
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53941 --- dlls/dmcompos/composer.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/dlls/dmcompos/composer.c b/dlls/dmcompos/composer.c index a13a77bff94..a2a58396ee5 100644 --- a/dlls/dmcompos/composer.c +++ b/dlls/dmcompos/composer.c @@ -77,12 +77,38 @@ static ULONG WINAPI IDirectMusicComposerImpl_Release(IDirectMusicComposer *iface
/* IDirectMusicComposerImpl IDirectMusicComposer part: */ static HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromTemplate(IDirectMusicComposer *iface, - IDirectMusicStyle *pStyle, IDirectMusicSegment *pTemplate, WORD wActivity, - IDirectMusicChordMap *pChordMap, IDirectMusicSegment **ppSegment) + IDirectMusicStyle *style, IDirectMusicSegment *template, WORD activity, IDirectMusicChordMap *chordmap, + IDirectMusicSegment **segment) { - IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface); - FIXME("(%p, %p, %p, %d, %p, %p): stub\n", This, pStyle, pTemplate, wActivity, pChordMap, ppSegment); - return S_OK; + IDirectMusicComposerImpl *This = impl_from_IDirectMusicComposer(iface); + IDirectMusicTrack *track; + HRESULT hr; + + FIXME("(%p, %p, %p, %d, %p, %p): semi-stub\n", This, style, template, activity, chordmap, segment); + + if (!segment) + return E_POINTER; + if (!template) + return E_INVALIDARG; + + if (!style) { + hr = IDirectMusicSegment_GetTrack(template, &CLSID_DirectMusicStyleTrack, 0xFFFFFFFF, + DMUS_SEG_ANYTRACK, &track); + if (FAILED(hr)) + return E_INVALIDARG; + else + IDirectMusicTrack_Release(track); /* Temp to not leak memory */ + } + if (!chordmap) { + hr = IDirectMusicSegment_GetTrack(template, &CLSID_DirectMusicChordMapTrack, 0xFFFFFFFF, + DMUS_SEG_ANYTRACK, &track); + if (FAILED(hr)) + return E_INVALIDARG; + else + IDirectMusicTrack_Release(track); /* Temp to not leak memory */ + } + + return IDirectMusicSegment_Clone(template, -1, 0, segment); }
static HRESULT WINAPI IDirectMusicComposerImpl_ComposeSegmentFromShape(IDirectMusicComposer *iface,