Commit c92d0101 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dmime: Implement the IDirectMusicSegment8_Clone() method.

parent 354ccf3f
......@@ -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,
......
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