dmime: Implement band track IDirectMusicTrack_Play.

This commit is contained in:
Rémi Bernon 2023-10-12 09:02:05 +02:00 committed by Alexandre Julliard
parent fd68076c36
commit e3b23cb66e
5 changed files with 66 additions and 27 deletions

View file

@ -486,3 +486,37 @@ HRESULT band_connect_to_collection(IDirectMusicBand *iface, IDirectMusicCollecti
return S_OK;
}
HRESULT band_send_messages(IDirectMusicBand *iface, IDirectMusicPerformance *performance,
IDirectMusicGraph *graph, MUSIC_TIME time, DWORD track_id)
{
struct band *This = impl_from_IDirectMusicBand(iface);
struct instrument_entry *entry;
HRESULT hr = S_OK;
LIST_FOR_EACH_ENTRY_REV(entry, &This->instruments, struct instrument_entry, entry)
{
DMUS_PATCH_PMSG *msg;
if (FAILED(hr = IDirectMusicPerformance_AllocPMsg(performance, sizeof(*msg),
(DMUS_PMSG **)&msg)))
break;
msg->mtTime = time;
msg->dwFlags = DMUS_PMSGF_MUSICTIME;
msg->dwPChannel = entry->instrument.dwPChannel;
msg->dwVirtualTrackID = track_id;
msg->dwType = DMUS_PMSGT_PATCH;
msg->dwGroupID = 1;
msg->byInstrument = entry->instrument.dwPatch;
if (FAILED(hr = IDirectMusicGraph_StampPMsg(graph, (DMUS_PMSG *)msg))
|| FAILED(hr = IDirectMusicPerformance_SendPMsg(performance, (DMUS_PMSG *)msg)))
{
IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)msg);
break;
}
}
return hr;
}

View file

@ -159,22 +159,38 @@ static HRESULT WINAPI band_track_EndPlay(IDirectMusicTrack8 *iface, void *state_
}
static HRESULT WINAPI band_track_Play(IDirectMusicTrack8 *iface, void *state_data,
MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD flags,
IDirectMusicPerformance *performance, IDirectMusicSegmentState *segment_state,
DWORD virtual_id)
MUSIC_TIME start_time, MUSIC_TIME end_time, MUSIC_TIME time_offset, DWORD segment_flags,
IDirectMusicPerformance *performance, IDirectMusicSegmentState *segment_state, DWORD track_id)
{
struct band_track *This = impl_from_IDirectMusicTrack8(iface);
IDirectMusicGraph *graph;
struct band_entry *entry;
HRESULT hr;
FIXME("(%p, %p, %ld, %ld, %ld, %lx, %p, %p, %ld): semi-stub\n", This, state_data, mtStart, mtEnd, mtOffset, flags, performance, segment_state, virtual_id);
TRACE("(%p, %p, %ld, %ld, %ld, %#lx, %p, %p, %ld)\n", This, state_data, start_time, end_time,
time_offset, segment_flags, performance, segment_state, track_id);
/* Sends following pMSG:
- DMUS_PATCH_PMSG
- DMUS_TRANSPOSE_PMSG
- DMUS_CHANNEL_PRIORITY_PMSG
- DMUS_MIDI_PMSG
*/
if (!performance) return DMUS_S_END;
return S_OK;
if (start_time != 0) FIXME("start_time %ld not implemented\n", start_time);
if (end_time != -1) FIXME("end_time %ld not implemented\n", end_time);
if (time_offset != 0) FIXME("time_offset %ld not implemented\n", time_offset);
if (segment_flags) FIXME("segment_flags %#lx not implemented\n", segment_flags);
if (segment_state) FIXME("segment_state %p not implemented\n", segment_state);
if (FAILED(hr = IDirectMusicPerformance_QueryInterface(performance,
&IID_IDirectMusicGraph, (void **)&graph)))
return hr;
LIST_FOR_EACH_ENTRY(entry, &This->bands, struct band_entry, entry)
{
if (FAILED(hr = band_send_messages(entry->band, performance, graph,
entry->head.lBandTimeLogical, track_id)))
break;
}
IDirectMusicGraph_Release(graph);
return hr;
}
static HRESULT WINAPI band_track_GetParam(IDirectMusicTrack8 *iface, REFGUID type, MUSIC_TIME time,

View file

@ -48,5 +48,7 @@ extern HRESULT create_dmband(REFIID riid, void **ret_iface);
extern HRESULT create_dmbandtrack(REFIID riid, void **ret_iface);
extern HRESULT band_connect_to_collection(IDirectMusicBand *iface, IDirectMusicCollection *collection);
extern HRESULT band_send_messages(IDirectMusicBand *iface, IDirectMusicPerformance *performance,
IDirectMusicGraph *graph, MUSIC_TIME time, DWORD track_id);
#endif /* __WINE_DMBAND_PRIVATE_H */

View file

@ -233,7 +233,6 @@ static void test_bandtrack(void)
hr = IDirectMusicTrack8_EndPlay(dmt8, NULL);
ok(hr == S_OK, "IDirectMusicTrack8_EndPlay failed: %#lx\n", hr);
hr = IDirectMusicTrack8_Play(dmt8, NULL, 0, 0, 0, 0, NULL, NULL, 0);
todo_wine
ok(hr == DMUS_S_END, "IDirectMusicTrack8_Play failed: %#lx\n", hr);
hr = IDirectMusicTrack8_GetParam(dmt8, NULL, 0, NULL, NULL);
ok(hr == E_POINTER, "IDirectMusicTrack8_GetParam failed: %#lx\n", hr);

View file

@ -3756,39 +3756,27 @@ static void test_band_track_play(void)
ret = test_tool_wait_message(tool, 500, (DMUS_PMSG **)&patch);
ok(!ret, "got %#lx\n", ret);
if (patch->dwType == DMUS_PMSGT_PATCH)
{
check_dmus_patch_pmsg(patch, 0, 1, 0, 1);
}
hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)patch);
ok(hr == S_OK, "got %#lx\n", hr);
ret = test_tool_wait_message(tool, 500, (DMUS_PMSG **)&patch);
todo_wine ok(!ret, "got %#lx\n", ret);
if (!ret)
{
ok(!ret, "got %#lx\n", ret);
check_dmus_patch_pmsg(patch, 1000, 2, 0, 3);
hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)patch);
ok(hr == S_OK, "got %#lx\n", hr);
}
ret = test_tool_wait_message(tool, 500, (DMUS_PMSG **)&patch);
todo_wine ok(!ret, "got %#lx\n", ret);
if (!ret)
{
ok(!ret, "got %#lx\n", ret);
check_dmus_patch_pmsg(patch, 1000, 1, 0, 2);
hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)patch);
ok(hr == S_OK, "got %#lx\n", hr);
}
ret = test_tool_wait_message(tool, 500, &msg);
todo_wine ok(!ret, "got %#lx\n", ret);
if (!ret)
{
ok(!ret, "got %#lx\n", ret);
ok(msg->dwType == DMUS_PMSGT_DIRTY, "got %#lx\n", msg->dwType);
hr = IDirectMusicPerformance_FreePMsg(performance, msg);
ok(hr == S_OK, "got %#lx\n", hr);
}
IDirectMusicSegment_Release(segment);