Commit 377ba8a7 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmime: Use an internal performance message for segment end.

parent aec78ade
...@@ -81,6 +81,8 @@ extern HRESULT wave_track_create_from_chunk(IStream *stream, struct chunk_entry ...@@ -81,6 +81,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_end(IDirectMusicPerformance8 *iface, MUSIC_TIME music_time,
IDirectMusicSegmentState *state);
/***************************************************************************** /*****************************************************************************
* Auxiliary definitions * Auxiliary definitions
......
...@@ -24,6 +24,12 @@ ...@@ -24,6 +24,12 @@
WINE_DEFAULT_DEBUG_CHANNEL(dmime); WINE_DEFAULT_DEBUG_CHANNEL(dmime);
enum dmus_internal_message_type
{
DMUS_PMSGT_INTERNAL_FIRST = 0x10,
DMUS_PMSGT_INTERNAL_SEGMENT_END = DMUS_PMSGT_INTERNAL_FIRST,
};
struct pchannel_block { struct pchannel_block {
DWORD block_num; /* Block 0 is PChannels 0-15, Block 1 is PChannels 16-31, etc */ DWORD block_num; /* Block 0 is PChannels 0-15, Block 1 is PChannels 16-31, etc */
struct { struct {
...@@ -158,7 +164,8 @@ static DWORD WINAPI message_thread_proc(void *args) ...@@ -158,7 +164,8 @@ static DWORD WINAPI message_thread_proc(void *args)
return 0; return 0;
} }
static HRESULT performance_send_dirty_pmsg(struct performance *This, MUSIC_TIME music_time) static HRESULT performance_send_pmsg(struct performance *This, MUSIC_TIME music_time, DWORD flags,
DWORD type, IUnknown *object)
{ {
IDirectMusicPerformance8 *performance = &This->IDirectMusicPerformance8_iface; IDirectMusicPerformance8 *performance = &This->IDirectMusicPerformance8_iface;
IDirectMusicGraph *graph = &This->IDirectMusicGraph_iface; IDirectMusicGraph *graph = &This->IDirectMusicGraph_iface;
...@@ -169,10 +176,11 @@ static HRESULT performance_send_dirty_pmsg(struct performance *This, MUSIC_TIME ...@@ -169,10 +176,11 @@ static HRESULT performance_send_dirty_pmsg(struct performance *This, MUSIC_TIME
return hr; return hr;
msg->mtTime = music_time; msg->mtTime = music_time;
msg->dwFlags = DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_QUEUE; msg->dwFlags = DMUS_PMSGF_MUSICTIME | flags;
msg->dwType = DMUS_PMSGT_DIRTY; msg->dwType = type;
if ((msg->punkUser = object)) IUnknown_AddRef(object);
if (FAILED(hr = IDirectMusicGraph_StampPMsg(graph, msg)) if ((type < DMUS_PMSGT_INTERNAL_FIRST && FAILED(hr = IDirectMusicGraph_StampPMsg(graph, msg)))
|| FAILED(hr = IDirectMusicPerformance8_SendPMsg(performance, msg))) || FAILED(hr = IDirectMusicPerformance8_SendPMsg(performance, msg)))
IDirectMusicPerformance8_FreePMsg(performance, msg); IDirectMusicPerformance8_FreePMsg(performance, msg);
...@@ -252,6 +260,19 @@ static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusi ...@@ -252,6 +260,19 @@ static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusi
return CONTAINING_RECORD(iface, struct performance, IDirectMusicPerformance8_iface); return CONTAINING_RECORD(iface, struct performance, IDirectMusicPerformance8_iface);
} }
HRESULT performance_send_segment_end(IDirectMusicPerformance8 *iface, MUSIC_TIME music_time,
IDirectMusicSegmentState *state)
{
struct performance *This = impl_from_IDirectMusicPerformance8(iface);
HRESULT hr;
if (FAILED(hr = performance_send_pmsg(This, music_time, DMUS_PMSGF_TOOL_ATTIME,
DMUS_PMSGT_INTERNAL_SEGMENT_END, (IUnknown *)state)))
return hr;
return S_OK;
}
/* IDirectMusicPerformance8 IUnknown part: */ /* IDirectMusicPerformance8 IUnknown part: */
static HRESULT WINAPI performance_QueryInterface(IDirectMusicPerformance8 *iface, REFIID riid, void **ret_iface) static HRESULT WINAPI performance_QueryInterface(IDirectMusicPerformance8 *iface, REFIID riid, void **ret_iface)
{ {
...@@ -1050,8 +1071,7 @@ static HRESULT WINAPI performance_CloseDown(IDirectMusicPerformance8 *iface) ...@@ -1050,8 +1071,7 @@ static HRESULT WINAPI performance_CloseDown(IDirectMusicPerformance8 *iface)
list_remove(&message->entry); list_remove(&message->entry);
list_init(&message->entry); list_init(&message->entry);
/* process notifications to end any pending segment states */ if (message->msg.dwType == DMUS_PMSGT_INTERNAL_SEGMENT_END)
if (message->msg.dwType == DMUS_PMSGT_NOTIFICATION)
hr = IDirectMusicTool_ProcessPMsg(&This->IDirectMusicTool_iface, hr = IDirectMusicTool_ProcessPMsg(&This->IDirectMusicTool_iface,
(IDirectMusicPerformance *)iface, &message->msg); (IDirectMusicPerformance *)iface, &message->msg);
else else
...@@ -1210,7 +1230,7 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface, ...@@ -1210,7 +1230,7 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface,
hr = performance_send_notification_pmsg(This, start_time, This->notification_segment, hr = performance_send_notification_pmsg(This, start_time, This->notification_segment,
GUID_NOTIFICATION_SEGMENT, DMUS_NOTIFICATION_SEGSTART, (IUnknown *)state); GUID_NOTIFICATION_SEGMENT, DMUS_NOTIFICATION_SEGSTART, (IUnknown *)state);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = performance_send_dirty_pmsg(This, start_time); hr = performance_send_pmsg(This, start_time, DMUS_PMSGF_TOOL_QUEUE, DMUS_PMSGT_DIRTY, NULL);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = segment_state_play(state, iface); hr = segment_state_play(state, iface);
...@@ -1222,7 +1242,7 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface, ...@@ -1222,7 +1242,7 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface,
hr = performance_send_notification_pmsg(This, start_time + length, This->notification_segment, hr = performance_send_notification_pmsg(This, start_time + length, This->notification_segment,
GUID_NOTIFICATION_SEGMENT, DMUS_NOTIFICATION_SEGALMOSTEND, (IUnknown *)state); GUID_NOTIFICATION_SEGMENT, DMUS_NOTIFICATION_SEGALMOSTEND, (IUnknown *)state);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = performance_send_dirty_pmsg(This, start_time + length); hr = performance_send_pmsg(This, start_time + length, DMUS_PMSGF_TOOL_QUEUE, DMUS_PMSGT_DIRTY, NULL);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = performance_send_notification_pmsg(This, start_time + length, This->notification_performance, hr = performance_send_notification_pmsg(This, start_time + length, This->notification_performance,
GUID_NOTIFICATION_PERFORMANCE, DMUS_NOTIFICATION_MUSICSTOPPED, NULL); GUID_NOTIFICATION_PERFORMANCE, DMUS_NOTIFICATION_MUSICSTOPPED, NULL);
...@@ -1764,14 +1784,6 @@ static HRESULT WINAPI performance_tool_ProcessPMsg(IDirectMusicTool *iface, ...@@ -1764,14 +1784,6 @@ static HRESULT WINAPI performance_tool_ProcessPMsg(IDirectMusicTool *iface,
struct message *previous; struct message *previous;
BOOL enabled = FALSE; BOOL enabled = FALSE;
if (IsEqualGUID(&notif->guidNotificationType, &GUID_NOTIFICATION_SEGMENT)
&& notif->dwNotificationOption == DMUS_NOTIFICATION_SEGEND)
{
if (FAILED(hr = segment_state_end_play((IDirectMusicSegmentState *)notif->punkUser,
(IDirectMusicPerformance8 *)performance)))
WARN("Failed to end segment state %p, hr %#lx\n", notif->punkUser, hr);
}
if (IsEqualGUID(&notif->guidNotificationType, &GUID_NOTIFICATION_PERFORMANCE)) if (IsEqualGUID(&notif->guidNotificationType, &GUID_NOTIFICATION_PERFORMANCE))
enabled = This->notification_performance; enabled = This->notification_performance;
if (IsEqualGUID(&notif->guidNotificationType, &GUID_NOTIFICATION_SEGMENT)) if (IsEqualGUID(&notif->guidNotificationType, &GUID_NOTIFICATION_SEGMENT))
...@@ -1799,6 +1811,12 @@ static HRESULT WINAPI performance_tool_ProcessPMsg(IDirectMusicTool *iface, ...@@ -1799,6 +1811,12 @@ static HRESULT WINAPI performance_tool_ProcessPMsg(IDirectMusicTool *iface,
WARN("Failed to play wave buffer, hr %#lx\n", hr); WARN("Failed to play wave buffer, hr %#lx\n", hr);
break; break;
case DMUS_PMSGT_INTERNAL_SEGMENT_END:
if (FAILED(hr = segment_state_end_play((IDirectMusicSegmentState *)msg->punkUser,
(IDirectMusicPerformance8 *)performance)))
WARN("Failed to end segment state %p, hr %#lx\n", msg->punkUser, hr);
break;
default: default:
FIXME("Unhandled message type %#lx\n", msg->dwType); FIXME("Unhandled message type %#lx\n", msg->dwType);
break; break;
......
...@@ -214,8 +214,8 @@ HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time ...@@ -214,8 +214,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);
...@@ -263,6 +263,9 @@ HRESULT segment_state_create(IDirectMusicSegment *segment, MUSIC_TIME start_time ...@@ -263,6 +263,9 @@ 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;
......
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