Commit 7a9e45ac authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmime/tests: Test tempo track Play and DMUS_PMSGT_TEMPO messages.

parent f13fa16f
......@@ -3888,6 +3888,179 @@ static void test_band_track_play(void)
IDirectMusicTool_Release(tool);
}
#define check_dmus_tempo_pmsg(a, b, c) check_dmus_tempo_pmsg_(__LINE__, a, b, c)
static void check_dmus_tempo_pmsg_(int line, DMUS_TEMPO_PMSG *msg, MUSIC_TIME time, double tempo)
{
ok_(__FILE__, line)(msg->dwSize == sizeof(*msg), "got dwSize %lu\n", msg->dwSize);
ok_(__FILE__, line)(msg->rtTime != 0, "got rtTime %I64u\n", msg->rtTime);
ok_(__FILE__, line)(abs(msg->mtTime - time) < 10, "got mtTime %lu\n", msg->mtTime);
ok_(__FILE__, line)(!msg->dwPChannel, "got dwPChannel %lu\n", msg->dwPChannel);
ok_(__FILE__, line)(!!msg->dwVirtualTrackID, "got dwVirtualTrackID %lu\n", msg->dwVirtualTrackID);
ok_(__FILE__, line)(msg->dwType == DMUS_PMSGT_TEMPO, "got dwType %#lx\n", msg->dwType);
ok_(__FILE__, line)(!msg->dwVoiceID, "got dwVoiceID %lu\n", msg->dwVoiceID);
ok_(__FILE__, line)(msg->dwGroupID == -1, "got dwGroupID %lu\n", msg->dwGroupID);
ok_(__FILE__, line)(!msg->punkUser, "got punkUser %p\n", msg->punkUser);
ok_(__FILE__, line)(msg->dblTempo == tempo, "got tempo %f\n", msg->dblTempo);
}
static void test_tempo_track_play(void)
{
static const DWORD message_types[] =
{
DMUS_PMSGT_MIDI,
DMUS_PMSGT_NOTE,
DMUS_PMSGT_SYSEX,
DMUS_PMSGT_NOTIFICATION,
DMUS_PMSGT_TEMPO,
DMUS_PMSGT_CURVE,
DMUS_PMSGT_TIMESIG,
DMUS_PMSGT_PATCH,
DMUS_PMSGT_TRANSPOSE,
DMUS_PMSGT_CHANNEL_PRIORITY,
DMUS_PMSGT_STOP,
DMUS_PMSGT_DIRTY,
DMUS_PMSGT_WAVE,
DMUS_PMSGT_LYRIC,
DMUS_PMSGT_SCRIPTLYRIC,
DMUS_PMSGT_USER,
};
static const LARGE_INTEGER zero = {0};
DMUS_IO_TEMPO_ITEM tempo_items[] =
{
{.lTime = 100, .dblTempo = 80},
{.lTime = 300, .dblTempo = 60},
{.lTime = 200, .dblTempo = 20},
{.lTime = 4000, .dblTempo = 50},
};
IDirectMusicPerformance *performance;
IDirectMusicSegment *segment;
IDirectMusicGraph *graph;
IDirectMusicTrack *track;
IPersistStream *persist;
IDirectMusicTool *tool;
DMUS_TEMPO_PMSG *tempo;
DMUS_TEMPO_PARAM param;
IStream *stream;
DMUS_PMSG *msg;
HRESULT hr;
DWORD ret;
hr = test_tool_create(message_types, ARRAY_SIZE(message_types), &tool);
ok(hr == S_OK, "got %#lx\n", hr);
hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectMusicPerformance, (void **)&performance);
ok(hr == S_OK, "got %#lx\n", hr);
hr = CoCreateInstance(&CLSID_DirectMusicGraph, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectMusicGraph, (void **)&graph);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IDirectMusicGraph_InsertTool(graph, (IDirectMusicTool *)tool, NULL, 0, -1);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IDirectMusicPerformance_SetGraph(performance, graph);
ok(hr == S_OK, "got %#lx\n", hr);
IDirectMusicGraph_Release(graph);
/* create a segment and load a simple RIFF stream */
hr = CoCreateInstance(&CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectMusicSegment, (void **)&segment);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IDirectMusicSegment_QueryInterface(segment, &IID_IPersistStream, (void **)&persist);
ok(hr == S_OK, "got %#lx\n", hr);
hr = CreateStreamOnHGlobal(0, TRUE, &stream);
ok(hr == S_OK, "got %#lx\n", hr);
CHUNK_RIFF(stream, "DMSG")
{
/* set a non-zero segment length, or nothing will be played */
DMUS_IO_SEGMENT_HEADER head = {.mtLength = 1000};
CHUNK_DATA(stream, "segh", head);
CHUNK_DATA(stream, "guid", CLSID_DirectMusicSegment);
}
CHUNK_END;
hr = IStream_Seek(stream, zero, 0, NULL);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IPersistStream_Load(persist, stream);
ok(hr == S_OK, "got %#lx\n", hr);
IPersistStream_Release(persist);
IStream_Release(stream);
/* add a tempo track to our segment */
hr = CoCreateInstance(&CLSID_DirectMusicTempoTrack, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectMusicTrack, (void **)&track);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IDirectMusicSegment_QueryInterface(track, &IID_IPersistStream, (void **)&persist);
ok(hr == S_OK, "got %#lx\n", hr);
hr = CreateStreamOnHGlobal(0, TRUE, &stream);
ok(hr == S_OK, "got %#lx\n", hr);
CHUNK_ARRAY(stream, "tetr", tempo_items);
hr = IStream_Seek(stream, zero, 0, NULL);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IPersistStream_Load(persist, stream);
ok(hr == S_OK, "got %#lx\n", hr);
IPersistStream_Release(persist);
IStream_Release(stream);
hr = IDirectMusicSegment_GetParam(segment, &GUID_TempoParam, -1, DMUS_SEG_ALLTRACKS, 0, NULL, &param);
ok(hr == DMUS_E_TRACK_NOT_FOUND, "got %#lx\n", hr);
hr = IDirectMusicSegment_InsertTrack(segment, (IDirectMusicTrack *)track, 1);
ok(hr == S_OK, "got %#lx\n", hr);
IDirectMusicTrack_Release(track);
/* now play the segment, and check produced messages */
hr = IDirectMusicPerformance_Init(performance, NULL, 0, 0);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IDirectMusicPerformance_PlaySegment(performance, segment, 0x800, 0, NULL);
ok(hr == S_OK, "got %#lx\n", hr);
ret = test_tool_wait_message(tool, 500, &msg);
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);
ret = test_tool_wait_message(tool, 500, (DMUS_PMSG **)&tempo);
ok(!ret, "got %#lx\n", ret);
todo_wine ok(tempo->dwType == DMUS_PMSGT_TEMPO, "got %#lx\n", tempo->dwType);
if (tempo->dwType != DMUS_PMSGT_TEMPO) goto skip_tests;
check_dmus_tempo_pmsg(tempo, 100, 80);
hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)tempo);
ok(hr == S_OK, "got %#lx\n", hr);
ret = test_tool_wait_message(tool, 500, (DMUS_PMSG **)&tempo);
todo_wine ok(!ret, "got %#lx\n", ret);
check_dmus_tempo_pmsg(tempo, 300, 60);
hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)tempo);
ok(hr == S_OK, "got %#lx\n", hr);
ret = test_tool_wait_message(tool, 500, &msg);
todo_wine 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);
skip_tests:
IDirectMusicSegment_Release(segment);
hr = IDirectMusicPerformance_CloseDown(performance);
ok(hr == S_OK, "got %#lx\n", hr);
IDirectMusicPerformance_Release(performance);
IDirectMusicTool_Release(tool);
}
static void test_connect_to_collection(void)
{
IDirectMusicCollection *collection;
......@@ -4208,6 +4381,7 @@ START_TEST(dmime)
test_wave_pmsg();
test_sequence_track();
test_band_track_play();
test_tempo_track_play();
test_connect_to_collection();
test_segment_state();
......
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