Commit 442db8a1 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmime: Send notification messages from segment_play_chunk.

parent 56043971
...@@ -82,6 +82,8 @@ extern HRESULT wave_track_create_from_chunk(IStream *stream, struct chunk_entry ...@@ -82,6 +82,8 @@ extern HRESULT wave_track_create_from_chunk(IStream *stream, struct chunk_entry
IDirectMusicTrack8 **ret_iface); IDirectMusicTrack8 **ret_iface);
extern HRESULT performance_get_dsound(IDirectMusicPerformance8 *iface, IDirectSound **dsound); 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, extern HRESULT performance_send_segment_tick(IDirectMusicPerformance8 *iface, MUSIC_TIME music_time,
IDirectMusicSegmentState *state); IDirectMusicSegmentState *state);
extern HRESULT performance_send_segment_end(IDirectMusicPerformance8 *iface, MUSIC_TIME music_time, extern HRESULT performance_send_segment_end(IDirectMusicPerformance8 *iface, MUSIC_TIME music_time,
......
...@@ -276,7 +276,7 @@ static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusi ...@@ -276,7 +276,7 @@ static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusi
return CONTAINING_RECORD(iface, struct performance, IDirectMusicPerformance8_iface); 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) IDirectMusicSegmentState *state)
{ {
struct performance *This = impl_from_IDirectMusicPerformance8(iface); struct performance *This = impl_from_IDirectMusicPerformance8(iface);
...@@ -319,6 +319,18 @@ HRESULT performance_send_segment_end(IDirectMusicPerformance8 *iface, MUSIC_TIME ...@@ -319,6 +319,18 @@ HRESULT performance_send_segment_end(IDirectMusicPerformance8 *iface, MUSIC_TIME
struct performance *This = impl_from_IDirectMusicPerformance8(iface); struct performance *This = impl_from_IDirectMusicPerformance8(iface);
HRESULT hr; 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, if (FAILED(hr = performance_send_pmsg(This, music_time, DMUS_PMSGF_TOOL_ATTIME,
DMUS_PMSGT_INTERNAL_SEGMENT_END, (IUnknown *)state))) DMUS_PMSGT_INTERNAL_SEGMENT_END, (IUnknown *)state)))
return hr; return hr;
...@@ -1253,8 +1265,8 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface, ...@@ -1253,8 +1265,8 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface,
{ {
struct performance *This = impl_from_IDirectMusicPerformance8(iface); struct performance *This = impl_from_IDirectMusicPerformance8(iface);
IDirectMusicSegmentState *state; IDirectMusicSegmentState *state;
MUSIC_TIME length, music_time;
IDirectMusicSegment *segment; IDirectMusicSegment *segment;
MUSIC_TIME music_time;
HRESULT hr; HRESULT hr;
FIXME("(%p, %p, %s, %p, %#lx, %I64d, %p, %p, %p): stub\n", This, source, debugstr_w(segment_name), 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, ...@@ -1275,25 +1287,9 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface,
EnterCriticalSection(&This->safe); EnterCriticalSection(&This->safe);
hr = IDirectMusicSegment_GetLength(segment, &length); if (FAILED(hr = segment_state_play(state, iface)))
if (SUCCEEDED(hr)) ERR("Failed to play segment state, hr %#lx\n", hr);
hr = performance_send_segment_start(iface, music_time, state); else if (segment_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)
{ {
*segment_state = state; *segment_state = state;
IDirectMusicSegmentState_AddRef(state); IDirectMusicSegmentState_AddRef(state);
......
...@@ -215,8 +215,8 @@ HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time ...@@ -215,8 +215,8 @@ HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time
IDirectMusicSegmentState *iface; IDirectMusicSegmentState *iface;
struct segment_state *This; struct segment_state *This;
IDirectMusicTrack *track; IDirectMusicTrack *track;
UINT i, duration;
HRESULT hr; HRESULT hr;
UINT i;
TRACE("(%p, %lu, %p)\n", segment, start_time, ret_iface); TRACE("(%p, %lu, %p)\n", segment, start_time, ret_iface);
...@@ -264,9 +264,6 @@ HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time ...@@ -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; if (SUCCEEDED(hr)) *ret_iface = iface;
else IDirectMusicSegmentState_Release(iface); else IDirectMusicSegmentState_Release(iface);
return hr; return hr;
...@@ -303,7 +300,18 @@ static HRESULT segment_state_play_chunk(struct segment_state *This, IDirectMusic ...@@ -303,7 +300,18 @@ static HRESULT segment_state_play_chunk(struct segment_state *This, IDirectMusic
This->played = played; This->played = played;
if (This->start_point + This->played >= This->end_point) 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_FALSE;
}
return S_OK; return S_OK;
} }
...@@ -314,6 +322,12 @@ HRESULT segment_state_play(IDirectMusicSegmentState *iface, IDirectMusicPerforma ...@@ -314,6 +322,12 @@ HRESULT segment_state_play(IDirectMusicSegmentState *iface, IDirectMusicPerforma
TRACE("%p %p\n", iface, performance); 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, if (FAILED(hr = segment_state_play_chunk(This, performance, 10000000,
DMUS_TRACKF_START | DMUS_TRACKF_SEEK | DMUS_TRACKF_DIRTY))) DMUS_TRACKF_START | DMUS_TRACKF_SEEK | DMUS_TRACKF_DIRTY)))
return hr; return hr;
......
...@@ -3147,8 +3147,8 @@ static void test_notification_pmsg(void) ...@@ -3147,8 +3147,8 @@ static void test_notification_pmsg(void)
ok(hr == S_OK, "got %#lx\n", hr); ok(hr == S_OK, "got %#lx\n", hr);
ret = test_tool_wait_message(tool, 50, &msg); ret = test_tool_wait_message(tool, 50, &msg);
todo_wine ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret); ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret);
if (ret == WAIT_TIMEOUT) ret = test_tool_wait_message(tool, 500, &msg); ret = test_tool_wait_message(tool, 500, &msg);
ok(!ret, "got %#lx\n", ret); ok(!ret, "got %#lx\n", ret);
check_dmus_dirty_pmsg(msg, music_time + length); check_dmus_dirty_pmsg(msg, music_time + length);
hr = IDirectMusicPerformance_FreePMsg(performance, msg); hr = IDirectMusicPerformance_FreePMsg(performance, msg);
...@@ -3312,8 +3312,7 @@ static void test_notification_pmsg(void) ...@@ -3312,8 +3312,7 @@ static void test_notification_pmsg(void)
ok(hr == S_OK, "got %#lx\n", hr); ok(hr == S_OK, "got %#lx\n", hr);
ret = test_tool_wait_message(tool, 500, &msg); ret = test_tool_wait_message(tool, 500, &msg);
todo_wine ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret); ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret);
if (!ret) IDirectMusicPerformance_FreePMsg(performance, msg);
IDirectMusicSegmentState_Release(state); IDirectMusicSegmentState_Release(state);
IDirectMusicSegment_Release(segment); IDirectMusicSegment_Release(segment);
......
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