Module: wine Branch: master Commit: c04e686ad5801b581b43ca58926692075eb39e89 URL: https://gitlab.winehq.org/wine/wine/-/commit/c04e686ad5801b581b43ca589266920...
Author: Rémi Bernon rbernon@codeweavers.com Date: Tue Sep 19 17:28:30 2023 +0200
dmime/tests: Test wave segments and DMUS_WAVE_PMSG.
---
dlls/dmime/tests/Makefile.in | 2 + dlls/dmime/tests/dmime.c | 168 +++++++++++++++++++++++++++++++++++++++++++ dlls/dmime/tests/resource.rc | 23 ++++++ dlls/dmime/tests/test.wav | Bin 0 -> 4488 bytes 4 files changed, 193 insertions(+)
diff --git a/dlls/dmime/tests/Makefile.in b/dlls/dmime/tests/Makefile.in index f4c47038e54..2491f9ff1b8 100644 --- a/dlls/dmime/tests/Makefile.in +++ b/dlls/dmime/tests/Makefile.in @@ -4,3 +4,5 @@ IMPORTS = user32 ole32 dsound C_SRCS = \ dmime.c \ performance.c + +RC_SRCS = resource.rc diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index e011488d126..e76949e71c7 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -55,6 +55,28 @@ static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOO } }
+static void load_resource(const WCHAR *name, WCHAR *filename) +{ + static WCHAR path[MAX_PATH]; + DWORD written; + HANDLE file; + HRSRC res; + void *ptr; + + GetTempPathW(ARRAY_SIZE(path), path); + GetTempFileNameW(path, name, 0, filename); + + file = CreateFileW(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0); + ok(file != INVALID_HANDLE_VALUE, "failed to create %s, error %lu\n", debugstr_w(filename), GetLastError()); + + res = FindResourceW(NULL, name, (const WCHAR *)RT_RCDATA); + ok(res != 0, "couldn't find resource\n"); + ptr = LockResource(LoadResource(GetModuleHandleW(NULL ), res )); + WriteFile(file, ptr, SizeofResource(GetModuleHandleW(NULL ), res ), &written, NULL); + ok(written == SizeofResource(GetModuleHandleW(NULL ), res ), "couldn't write resource\n"); + CloseHandle(file); +} + struct test_tool { IDirectMusicTool IDirectMusicTool_iface; @@ -2244,6 +2266,151 @@ static void test_notification_pmsg(void) IDirectMusicTool_Release(tool); }
+static void test_wave_pmsg(void) +{ + static const DWORD message_types[] = + { + DMUS_PMSGT_DIRTY, + DMUS_PMSGT_WAVE, + }; + IDirectMusicPerformance *performance; + IDirectMusicSegment *segment; + IDirectMusicLoader8 *loader; + IDirectMusicGraph *graph; + WCHAR test_wav[MAX_PATH]; + IDirectMusicTool *tool; + DMUS_WAVE_PMSG *wave; + MUSIC_TIME length; + 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 = IDirectMusicPerformance_SetGraph(performance, 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); + IDirectMusicGraph_Release(graph); + + hr = IDirectMusicPerformance8_InitAudio((IDirectMusicPerformance8 *)performance, NULL, NULL, NULL, + DMUS_APATH_SHARED_STEREOPLUSREVERB, 64, DMUS_AUDIOF_ALL, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + + + load_resource(L"test.wav", test_wav); + + hr = CoCreateInstance(&CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusicLoader8, (void **)&loader); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicLoader8_LoadObjectFromFile(loader, &CLSID_DirectMusicSegment, + &IID_IDirectMusicSegment, test_wav, (void **)&segment); + ok(hr == S_OK, "got %#lx\n", hr); + IDirectMusicLoader8_Release(loader); + + + length = 0xdeadbeef; + hr = IDirectMusicSegment_GetLength(segment, &length); + ok(hr == S_OK, "got %#lx\n", hr); + todo_wine ok(length == 1, "got %lu\n", length); + + + /* without Download, no DMUS_PMSGT_WAVE is sent */ + + hr = IDirectMusicPerformance_PlaySegment(performance, segment, 0, 0, NULL); + 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(msg->dwType == DMUS_PMSGT_DIRTY, "got %p\n", msg); + hr = IDirectMusicPerformance_FreePMsg(performance, msg); + 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(msg->dwType == DMUS_PMSGT_DIRTY, "got %p\n", msg); + hr = IDirectMusicPerformance_FreePMsg(performance, msg); + ok(hr == S_OK, "got %#lx\n", hr); + } + + ret = test_tool_wait_message(tool, 100, &msg); + ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret); + ok(!msg, "got %p\n", msg); + + + /* a single DMUS_PMSGT_WAVE message is sent with punkUser set */ + + hr = IDirectMusicSegment8_Download((IDirectMusicSegment8 *)segment, (IUnknown *)performance); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = IDirectMusicPerformance_PlaySegment(performance, segment, 0, 0, NULL); + 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(msg->dwType == DMUS_PMSGT_DIRTY, "got %p\n", msg); + hr = IDirectMusicPerformance_FreePMsg(performance, msg); + ok(hr == S_OK, "got %#lx\n", hr); + } + + ret = test_tool_wait_message(tool, 500, (DMUS_PMSG **)&wave); + todo_wine ok(!ret, "got %#lx\n", ret); + if (!ret) + { + ok(wave->dwType == DMUS_PMSGT_WAVE, "got %p\n", wave); + ok(!!wave->punkUser, "got %p\n", wave->punkUser); + ok(wave->rtStartOffset == 0, "got %I64d\n", wave->rtStartOffset); + ok(wave->rtDuration == 1000000, "got %I64d\n", wave->rtDuration); + ok(wave->lOffset == 0, "got %lu\n", wave->lOffset); + ok(wave->lVolume == 0, "got %lu\n", wave->lVolume); + ok(wave->lPitch == 0, "got %lu\n", wave->lPitch); + ok(wave->bFlags == 0, "got %#x\n", wave->bFlags); + hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)wave); + 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(msg->dwType == DMUS_PMSGT_DIRTY, "got %p\n", msg); + hr = IDirectMusicPerformance_FreePMsg(performance, msg); + ok(hr == S_OK, "got %#lx\n", hr); + } + + hr = IDirectMusicSegment8_Unload((IDirectMusicSegment8 *)segment, (IUnknown *)performance); + ok(hr == S_OK, "got %#lx\n", hr); + + ret = test_tool_wait_message(tool, 100, &msg); + ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret); + ok(!msg, "got %p\n", msg); + + + IDirectMusicSegment_Release(segment); + + + hr = IDirectMusicPerformance_CloseDown(performance); + ok(hr == S_OK, "got %#lx\n", hr); + + IDirectMusicPerformance_Release(performance); + IDirectMusicTool_Release(tool); +} + START_TEST(dmime) { CoInitialize(NULL); @@ -2272,6 +2439,7 @@ START_TEST(dmime) test_performance_time(); test_performance_pmsg(); test_notification_pmsg(); + test_wave_pmsg();
CoUninitialize(); } diff --git a/dlls/dmime/tests/resource.rc b/dlls/dmime/tests/resource.rc new file mode 100644 index 00000000000..d49b647b934 --- /dev/null +++ b/dlls/dmime/tests/resource.rc @@ -0,0 +1,23 @@ +/* + * Copyright 2023 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "windef.h" + +/* ffmpeg -f lavfi -i "sine=frequency=600" -t 0.1 -ar 44100 -f wav -acodec pcm_u8 test.wav */ +/* @makedep: test.wav */ +test.wav RCDATA test.wav diff --git a/dlls/dmime/tests/test.wav b/dlls/dmime/tests/test.wav new file mode 100644 index 00000000000..51d23936196 Binary files /dev/null and b/dlls/dmime/tests/test.wav differ