Skip to content

Commit

Permalink
dmime: Use segment_append_track in Clone and parse_track_form.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbernon authored and julliard committed Sep 19, 2023
1 parent 0bdc248 commit a4c1dec
Showing 1 changed file with 11 additions and 35 deletions.
46 changes: 11 additions & 35 deletions dlls/dmime/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,12 @@ static HRESULT WINAPI segment_Clone(IDirectMusicSegment8 *iface, MUSIC_TIME star
struct segment *This = impl_from_IDirectMusicSegment8(iface);
struct segment *clone;
IDirectMusicTrack *track;
struct track_entry *track_item, *cloned_item;
HRESULT hr;
BOOL track_clone_fail = FALSE;
struct track_entry *entry;
HRESULT hr = S_OK;

TRACE("(%p, %ld, %ld, %p)\n", This, start, end, segment);

if (!segment)
return E_POINTER;
if (!segment) return E_POINTER;

if (!(clone = segment_create()))
{
Expand All @@ -423,32 +421,16 @@ static HRESULT WINAPI segment_Clone(IDirectMusicSegment8 *iface, MUSIC_TIME star
}

clone->header = This->header;
clone->pGraph = This->pGraph;
if (clone->pGraph)
IDirectMusicGraph_AddRef(clone->pGraph);

LIST_FOR_EACH_ENTRY(track_item, &This->tracks, struct track_entry, entry) {
if (SUCCEEDED(hr = IDirectMusicTrack_Clone(track_item->pTrack, start, end, &track))) {
if ((cloned_item = malloc(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;
if ((clone->pGraph = This->pGraph)) IDirectMusicGraph_AddRef(clone->pGraph);

LIST_FOR_EACH_ENTRY(entry, &This->tracks, struct track_entry, entry)
{
if (FAILED(hr = IDirectMusicTrack_Clone(entry->pTrack, start, end, &track))) break;
if (FAILED(hr = segment_append_track(clone, track, entry->dwGroupBits, entry->flags))) break;
}

*segment = (IDirectMusicSegment *)&clone->IDirectMusicSegment8_iface;

return track_clone_fail ? S_FALSE : S_OK;
return FAILED(hr) ? S_FALSE : S_OK;
}

static HRESULT WINAPI segment_SetStartPoint(IDirectMusicSegment8 *iface, MUSIC_TIME start)
Expand Down Expand Up @@ -635,7 +617,6 @@ static HRESULT parse_track_form(struct segment *This, IStream *stream, const str
DMUS_IO_TRACK_HEADER thdr;
DMUS_IO_TRACK_EXTRAS_HEADER txhdr = {0};
HRESULT hr;
struct track_entry *item;

TRACE("Parsing track form in %p: %s\n", stream, debugstr_chunk(riff));

Expand Down Expand Up @@ -691,12 +672,7 @@ static HRESULT parse_track_form(struct segment *This, IStream *stream, const str
if (FAILED(hr))
goto done;

hr = IDirectMusicSegment8_InsertTrack(&This->IDirectMusicSegment8_iface, track, thdr.dwGroup);
if (FAILED(hr))
goto done;

item = LIST_ENTRY(list_tail(&This->tracks), struct track_entry, entry);
item->flags = txhdr.dwFlags;
hr = segment_append_track(This, track, thdr.dwGroup, txhdr.dwFlags);

done:
if (ps)
Expand Down

0 comments on commit a4c1dec

Please sign in to comment.