From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmime/segmentstate.c | 46 +++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/dlls/dmime/segmentstate.c b/dlls/dmime/segmentstate.c index 544620b0045..6391f44fd9a 100644 --- a/dlls/dmime/segmentstate.c +++ b/dlls/dmime/segmentstate.c @@ -269,22 +269,15 @@ HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time return hr; }
-static HRESULT segment_state_play_chunk(struct segment_state *This, IDirectMusicPerformance8 *performance, - REFERENCE_TIME duration, DWORD track_flags) +static HRESULT segment_state_play_until(struct segment_state *This, IDirectMusicPerformance8 *performance, + MUSIC_TIME end_time, DWORD track_flags) { IDirectMusicSegmentState *iface = (IDirectMusicSegmentState *)&This->IDirectMusicSegmentState8_iface; - MUSIC_TIME next_time, played; struct track_entry *entry; - REFERENCE_TIME time; HRESULT hr = S_OK; + MUSIC_TIME played;
- if (FAILED(hr = IDirectMusicPerformance8_MusicToReferenceTime(performance, - This->start_time + This->played, &time))) - return hr; - if (FAILED(hr = IDirectMusicPerformance8_ReferenceToMusicTime(performance, - time + duration, &next_time))) - return hr; - played = min(next_time - This->start_time, This->end_point - This->start_point); + played = min(end_time - This->start_time, This->end_point - This->start_point);
LIST_FOR_EACH_ENTRY(entry, &This->tracks, struct track_entry, entry) { @@ -299,20 +292,31 @@ static HRESULT segment_state_play_chunk(struct segment_state *This, IDirectMusic }
This->played = played; - if (This->start_point + This->played >= This->end_point) - { - MUSIC_TIME end_time = This->start_time + This->played; + return This->start_point + This->played >= This->end_point ? S_FALSE : S_OK; +}
- if (FAILED(hr = performance_send_segment_end(performance, end_time, iface, FALSE))) - { - ERR("Failed to send segment end, hr %#lx\n", hr); - return hr; - } +static HRESULT segment_state_play_chunk(struct segment_state *This, IDirectMusicPerformance8 *performance, + REFERENCE_TIME duration, DWORD track_flags) +{ + IDirectMusicSegmentState *iface = (IDirectMusicSegmentState *)&This->IDirectMusicSegmentState8_iface; + MUSIC_TIME next_time; + REFERENCE_TIME time; + HRESULT hr; + + if (FAILED(hr = IDirectMusicPerformance8_MusicToReferenceTime(performance, + This->start_time + This->played, &time))) + return hr; + if (FAILED(hr = IDirectMusicPerformance8_ReferenceToMusicTime(performance, + time + duration, &next_time))) + return hr;
- return S_FALSE; + if ((hr = segment_state_play_until(This, performance, next_time, track_flags)) == S_FALSE) + { + MUSIC_TIME end_time = This->start_time + This->played; + return performance_send_segment_end(performance, end_time, iface, FALSE); }
- return S_OK; + return hr; }
HRESULT segment_state_play(IDirectMusicSegmentState *iface, IDirectMusicPerformance8 *performance)