Module: wine Branch: master Commit: 442db8a131c8ca12e9a169e60fd2c169ad89dfd1 URL: https://gitlab.winehq.org/wine/wine/-/commit/442db8a131c8ca12e9a169e60fd2c16...
Author: Rémi Bernon rbernon@codeweavers.com Date: Wed Oct 25 09:47:48 2023 +0200
dmime: Send notification messages from segment_play_chunk.
---
dlls/dmime/dmime_private.h | 2 ++ dlls/dmime/performance.c | 38 +++++++++++++++++--------------------- dlls/dmime/segmentstate.c | 22 ++++++++++++++++++---- dlls/dmime/tests/dmime.c | 7 +++---- 4 files changed, 40 insertions(+), 29 deletions(-)
diff --git a/dlls/dmime/dmime_private.h b/dlls/dmime/dmime_private.h index 212ee254192..e1a2374facf 100644 --- a/dlls/dmime/dmime_private.h +++ b/dlls/dmime/dmime_private.h @@ -82,6 +82,8 @@ extern HRESULT wave_track_create_from_chunk(IStream *stream, struct chunk_entry IDirectMusicTrack8 **ret_iface);
extern HRESULT performance_get_dsound(IDirectMusicPerformance8 *iface, IDirectSound **dsound); +extern HRESULT performance_send_segment_start(IDirectMusicPerformance8 *iface, MUSIC_TIME music_time, + IDirectMusicSegmentState *state); extern HRESULT performance_send_segment_tick(IDirectMusicPerformance8 *iface, MUSIC_TIME music_time, IDirectMusicSegmentState *state); extern HRESULT performance_send_segment_end(IDirectMusicPerformance8 *iface, MUSIC_TIME music_time, diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index 6f77f8677ba..a08c00502d9 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -276,7 +276,7 @@ static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusi return CONTAINING_RECORD(iface, struct performance, IDirectMusicPerformance8_iface); }
-static HRESULT performance_send_segment_start(IDirectMusicPerformance8 *iface, MUSIC_TIME music_time, +HRESULT performance_send_segment_start(IDirectMusicPerformance8 *iface, MUSIC_TIME music_time, IDirectMusicSegmentState *state) { struct performance *This = impl_from_IDirectMusicPerformance8(iface); @@ -319,6 +319,18 @@ HRESULT performance_send_segment_end(IDirectMusicPerformance8 *iface, MUSIC_TIME struct performance *This = impl_from_IDirectMusicPerformance8(iface); HRESULT hr;
+ if (FAILED(hr = performance_send_notification_pmsg(This, music_time - 1450, This->notification_segment, + GUID_NOTIFICATION_SEGMENT, DMUS_NOTIFICATION_SEGALMOSTEND, (IUnknown *)state))) + return hr; + if (FAILED(hr = performance_send_notification_pmsg(This, music_time, This->notification_segment, + GUID_NOTIFICATION_SEGMENT, DMUS_NOTIFICATION_SEGEND, (IUnknown *)state))) + return hr; + if (FAILED(hr = performance_send_pmsg(This, music_time, DMUS_PMSGF_TOOL_IMMEDIATE, + DMUS_PMSGT_DIRTY, NULL))) + return hr; + if (FAILED(hr = performance_send_notification_pmsg(This, music_time, This->notification_performance, + GUID_NOTIFICATION_PERFORMANCE, DMUS_NOTIFICATION_MUSICSTOPPED, NULL))) + return hr; if (FAILED(hr = performance_send_pmsg(This, music_time, DMUS_PMSGF_TOOL_ATTIME, DMUS_PMSGT_INTERNAL_SEGMENT_END, (IUnknown *)state))) return hr; @@ -1253,8 +1265,8 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface, { struct performance *This = impl_from_IDirectMusicPerformance8(iface); IDirectMusicSegmentState *state; - MUSIC_TIME length, music_time; IDirectMusicSegment *segment; + MUSIC_TIME music_time; HRESULT hr;
FIXME("(%p, %p, %s, %p, %#lx, %I64d, %p, %p, %p): stub\n", This, source, debugstr_w(segment_name), @@ -1275,25 +1287,9 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface,
EnterCriticalSection(&This->safe);
- hr = IDirectMusicSegment_GetLength(segment, &length); - if (SUCCEEDED(hr)) - hr = performance_send_segment_start(iface, music_time, state); - if (SUCCEEDED(hr)) - hr = segment_state_play(state, iface); - - if (SUCCEEDED(hr)) - hr = performance_send_notification_pmsg(This, music_time + length - 1450, This->notification_segment, - GUID_NOTIFICATION_SEGMENT, DMUS_NOTIFICATION_SEGALMOSTEND, (IUnknown *)state); - if (SUCCEEDED(hr)) - hr = performance_send_notification_pmsg(This, music_time + length, This->notification_segment, - GUID_NOTIFICATION_SEGMENT, DMUS_NOTIFICATION_SEGEND, (IUnknown *)state); - if (SUCCEEDED(hr)) - hr = performance_send_pmsg(This, music_time + length, DMUS_PMSGF_TOOL_IMMEDIATE, DMUS_PMSGT_DIRTY, NULL); - if (SUCCEEDED(hr)) - hr = performance_send_notification_pmsg(This, music_time + length, This->notification_performance, - GUID_NOTIFICATION_PERFORMANCE, DMUS_NOTIFICATION_MUSICSTOPPED, NULL); - - if (SUCCEEDED(hr) && segment_state) + if (FAILED(hr = segment_state_play(state, iface))) + ERR("Failed to play segment state, hr %#lx\n", hr); + else if (segment_state) { *segment_state = state; IDirectMusicSegmentState_AddRef(state); diff --git a/dlls/dmime/segmentstate.c b/dlls/dmime/segmentstate.c index fa49d06836b..f2f895de881 100644 --- a/dlls/dmime/segmentstate.c +++ b/dlls/dmime/segmentstate.c @@ -215,8 +215,8 @@ HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time IDirectMusicSegmentState *iface; struct segment_state *This; IDirectMusicTrack *track; - UINT i, duration; HRESULT hr; + UINT i;
TRACE("(%p, %lu, %p)\n", segment, start_time, ret_iface);
@@ -264,9 +264,6 @@ HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time } }
- duration = This->end_point - This->start_point; - if (SUCCEEDED(hr)) hr = performance_send_segment_end(performance, start_time + duration, iface); - if (SUCCEEDED(hr)) *ret_iface = iface; else IDirectMusicSegmentState_Release(iface); return hr; @@ -303,7 +300,18 @@ 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; + + if (FAILED(hr = performance_send_segment_end(performance, end_time, iface))) + { + ERR("Failed to send segment end, hr %#lx\n", hr); + return hr; + } + return S_FALSE; + } + return S_OK; }
@@ -314,6 +322,12 @@ HRESULT segment_state_play(IDirectMusicSegmentState *iface, IDirectMusicPerforma
TRACE("%p %p\n", iface, performance);
+ if (FAILED(hr = performance_send_segment_start(performance, This->start_time, iface))) + { + ERR("Failed to send segment start, hr %#lx\n", hr); + return hr; + } + if (FAILED(hr = segment_state_play_chunk(This, performance, 10000000, DMUS_TRACKF_START | DMUS_TRACKF_SEEK | DMUS_TRACKF_DIRTY))) return hr; diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index 05dc653a935..79fbb902868 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -3147,8 +3147,8 @@ static void test_notification_pmsg(void) ok(hr == S_OK, "got %#lx\n", hr);
ret = test_tool_wait_message(tool, 50, &msg); - todo_wine ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret); - if (ret == WAIT_TIMEOUT) ret = test_tool_wait_message(tool, 500, &msg); + ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret); + ret = test_tool_wait_message(tool, 500, &msg); ok(!ret, "got %#lx\n", ret); check_dmus_dirty_pmsg(msg, music_time + length); hr = IDirectMusicPerformance_FreePMsg(performance, msg); @@ -3312,8 +3312,7 @@ static void test_notification_pmsg(void) ok(hr == S_OK, "got %#lx\n", hr);
ret = test_tool_wait_message(tool, 500, &msg); - todo_wine ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret); - if (!ret) IDirectMusicPerformance_FreePMsg(performance, msg); + ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret);
IDirectMusicSegmentState_Release(state); IDirectMusicSegment_Release(segment);