Final Fantasy VIII does this, more or less, and needs Init to succeed.
-- v2: dmime: Return DMUS_E_AUDIOPATH_INACTIVE when audio paths are not enabled. dmime: Return DMUS_E_AUDIOPATHS_IN_USE when audio paths are in use. dmime: Initialize performance in Init rather than InitAudio. dmime: Set the port direct sound before activating it. dmime/tests: Test performance Init with a created port. dmime/tests: Move performance tests into dmime.c. dmime/tests: Remove some duplicated tests.
From: Rémi Bernon rbernon@codeweavers.com
These are now more extensively tested in dmime/tests/dmime.c. --- dlls/dmime/tests/performance.c | 147 --------------------------------- 1 file changed, 147 deletions(-)
diff --git a/dlls/dmime/tests/performance.c b/dlls/dmime/tests/performance.c index 5cb91a78387..6a8efcdf28a 100644 --- a/dlls/dmime/tests/performance.c +++ b/dlls/dmime/tests/performance.c @@ -489,151 +489,6 @@ static void test_COM(void) ok (refcount == 0, "refcount == %lu, expected 0\n", refcount); }
-static void test_notification_type(void) -{ - static unsigned char rifffile[8+4+8+16+8+256] = "RIFF\x24\x01\x00\x00WAVE" /* header: 4 ("WAVE") + (8 + 16) (format segment) + (8 + 256) (data segment) = 0x124 */ - "fmt \x10\x00\x00\x00\x01\x00\x20\x00\xAC\x44\x00\x00\x10\xB1\x02\x00\x04\x00\x10\x00" /* format segment: PCM, 2 chan, 44100 Hz, 16 bits */ - "data\x00\x01\x00\x00"; /* 256 byte data segment (silence) */ - - IDirectMusicPerformance8 *perf; - IDirectMusic *music = NULL; - IDirectMusicSegment8 *prime_segment8; - IDirectMusicSegment8 *segment8 = NULL; - IDirectMusicLoader8 *loader; - IDirectMusicAudioPath8 *path; - IDirectMusicSegmentState *state; - IDirectSound *dsound = NULL; - HRESULT hr; - DWORD result; - HANDLE messages; - DMUS_NOTIFICATION_PMSG *msg; - BOOL found_end = FALSE; - DMUS_OBJECTDESC desc = {0}; - - hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, - CLSCTX_INPROC_SERVER, &IID_IDirectMusicPerformance8, (void**)&perf); - ok(hr == S_OK, "CoCreateInstance failed: %#lx\n", hr); - - hr = IDirectMusicPerformance8_InitAudio(perf, &music, &dsound, NULL, DMUS_APATH_DYNAMIC_STEREO, 64, DMUS_AUDIOF_ALL, NULL); - ok(music != NULL, "Didn't get IDirectMusic pointer\n"); - ok(dsound != NULL, "Didn't get IDirectSound pointer\n"); - - hr = CoCreateInstance(&CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicLoader8, (void**)&loader); - ok(hr == S_OK, "CoCreateInstance failed: %#lx\n", hr); - - messages = CreateEventA( NULL, FALSE, FALSE, NULL ); - - hr = IDirectMusicPerformance8_AddNotificationType(perf, &GUID_NOTIFICATION_SEGMENT); - ok(hr == S_OK, "Failed: %#lx\n", hr); - - hr = IDirectMusicPerformance8_SetNotificationHandle(perf, messages, 0); - ok(hr == S_OK, "Failed: %#lx\n", hr); - - hr = IDirectMusicPerformance8_GetDefaultAudioPath(perf, &path); - ok(hr == S_OK, "Failed: %#lx\n", hr); - ok(path != NULL, "Didn't get IDirectMusicAudioPath pointer\n"); - - desc.dwSize = sizeof(DMUS_OBJECTDESC); - desc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_MEMORY; - desc.guidClass = CLSID_DirectMusicSegment; - desc.pbMemData = rifffile; - desc.llMemLength = sizeof(rifffile); - hr = IDirectMusicLoader8_GetObject(loader, &desc, &IID_IDirectMusicSegment8, (void**)&prime_segment8); - ok(hr == S_OK, "Failed: %#lx\n", hr); - ok(prime_segment8 != NULL, "Didn't get IDirectMusicSegment pointer\n"); - - hr = IDirectMusicSegment8_Download(prime_segment8, (IUnknown*)path); - ok(hr == S_OK, "Download failed: %#lx\n", hr); - - hr = IDirectMusicPerformance8_PlaySegmentEx(perf, (IUnknown*)prime_segment8, - NULL, NULL, DMUS_SEGF_SECONDARY, 0, &state, NULL, (IUnknown*)path); - ok(hr == S_OK, "PlaySegmentEx failed: %#lx\n", hr); - ok(state != NULL, "Didn't get IDirectMusicSegmentState pointer\n"); - - while (!found_end) { - result = WaitForSingleObject(messages, 500); - todo_wine ok(result == WAIT_OBJECT_0, "Failed: %ld\n", result); - if (result != WAIT_OBJECT_0) - break; - - msg = NULL; - hr = IDirectMusicPerformance8_GetNotificationPMsg(perf, &msg); - ok(hr == S_OK, "Failed: %#lx\n", hr); - ok(msg != NULL, "Unexpected NULL pointer\n"); - if (FAILED(hr) || !msg) - break; - - trace("Notification: %ld\n", msg->dwNotificationOption); - - if (msg->dwNotificationOption == DMUS_NOTIFICATION_SEGEND || - msg->dwNotificationOption == DMUS_NOTIFICATION_SEGALMOSTEND) { - ok(msg->punkUser != NULL, "Unexpected NULL pointer\n"); - if (msg->punkUser) { - IDirectMusicSegmentState8 *segmentstate; - IDirectMusicSegment *segment; - - hr = IUnknown_QueryInterface(msg->punkUser, &IID_IDirectMusicSegmentState8, (void**)&segmentstate); - ok(hr == S_OK, "Failed: %#lx\n", hr); - - hr = IDirectMusicSegmentState8_GetSegment(segmentstate, &segment); - ok(hr == S_OK, "Failed: %#lx\n", hr); - if (FAILED(hr)) { - IDirectMusicSegmentState8_Release(segmentstate); - break; - } - - hr = IDirectMusicSegment_QueryInterface(segment, &IID_IDirectMusicSegment8, (void**)&segment8); - ok(hr == S_OK, "Failed: %#lx\n", hr); - - found_end = TRUE; - - IDirectMusicSegment_Release(segment); - IDirectMusicSegmentState8_Release(segmentstate); - } - } - - IDirectMusicPerformance8_FreePMsg(perf, (DMUS_PMSG*)msg); - } - todo_wine ok(prime_segment8 == segment8, "Wrong end segment\n"); - todo_wine ok(found_end, "Didn't receive DMUS_NOTIFICATION_SEGEND message\n"); - - CloseHandle(messages); - - if(segment8) - IDirectMusicSegment8_Release(segment8); - IDirectSound_Release(dsound); - IDirectMusicSegmentState_Release(state); - IDirectMusicAudioPath_Release(path); - IDirectMusicLoader8_Release(loader); - IDirectMusic_Release(music); - IDirectMusicPerformance8_Release(perf); -} - -static void test_performance_graph(void) -{ - HRESULT hr; - IDirectMusicPerformance8 *perf; - IDirectMusicGraph *graph = NULL, *graph2; - - create_performance(&perf, NULL, NULL, FALSE); - hr = IDirectMusicPerformance8_Init(perf, NULL, NULL, NULL); - ok(hr == S_OK, "Init failed: %#lx\n", hr); - - hr = IDirectMusicPerformance8_GetGraph(perf, NULL); - ok(hr == E_POINTER, "Failed: %#lx\n", hr); - - hr = IDirectMusicPerformance8_GetGraph(perf, &graph2); - ok(hr == DMUS_E_NOT_FOUND, "Failed: %#lx\n", hr); - ok(graph2 == NULL, "unexpected pointer.\n"); - - hr = IDirectMusicPerformance8_QueryInterface(perf, &IID_IDirectMusicGraph, (void**)&graph); - ok(hr == S_OK, "Failed: %#lx\n", hr); - - if (graph) - IDirectMusicGraph_Release(graph); - destroy_performance(perf, NULL, NULL); -} - START_TEST( performance ) { HRESULT hr; @@ -653,8 +508,6 @@ START_TEST( performance ) test_COM(); test_createport(); test_pchannel(); - test_notification_type(); - test_performance_graph();
CoUninitialize(); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmime/tests/Makefile.in | 3 +- dlls/dmime/tests/dmime.c | 458 +++++++++++++++++++++++++++++ dlls/dmime/tests/performance.c | 513 --------------------------------- 3 files changed, 459 insertions(+), 515 deletions(-) delete mode 100644 dlls/dmime/tests/performance.c
diff --git a/dlls/dmime/tests/Makefile.in b/dlls/dmime/tests/Makefile.in index 2491f9ff1b8..f07cdf835e9 100644 --- a/dlls/dmime/tests/Makefile.in +++ b/dlls/dmime/tests/Makefile.in @@ -2,7 +2,6 @@ TESTDLL = dmime.dll IMPORTS = user32 ole32 dsound
C_SRCS = \ - dmime.c \ - performance.c + dmime.c
RC_SRCS = resource.rc diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index 1266c5d053b..12056f15376 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -21,12 +21,16 @@ #include <stdarg.h> #include <windef.h> #include <wine/test.h> +#include <initguid.h> #include <ole2.h> #include <dmusici.h> #include <dmusicf.h> #include <audioclient.h> #include <guiddef.h>
+DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); +DEFINE_GUID(GUID_Bunk,0xFFFFFFFF,0xFFFF,0xFFFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF); + static ULONG get_refcount(void *iface) { IUnknown *unknown = iface; @@ -551,6 +555,43 @@ static HRESULT test_loader_stream_create(IStream *stream, IDirectMusicLoader *lo return S_OK; }
+static void create_performance(IDirectMusicPerformance8 **performance, IDirectMusic **dmusic, + IDirectSound **dsound, BOOL set_cooplevel) +{ + HRESULT hr; + + hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusicPerformance8, (void **)performance); + ok(hr == S_OK, "DirectMusicPerformance create failed: %#lx\n", hr); + if (dmusic) { + hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, + (void **)dmusic); + ok(hr == S_OK, "DirectMusic create failed: %#lx\n", hr); + } + if (dsound) { + hr = DirectSoundCreate8(NULL, (IDirectSound8 **)dsound, NULL); + ok(hr == S_OK, "DirectSoundCreate failed: %#lx\n", hr); + if (set_cooplevel) { + hr = IDirectSound_SetCooperativeLevel(*dsound, GetForegroundWindow(), DSSCL_PRIORITY); + ok(hr == S_OK, "SetCooperativeLevel failed: %#lx\n", hr); + } + } +} + +static void destroy_performance(IDirectMusicPerformance8 *performance, IDirectMusic *dmusic, + IDirectSound *dsound) +{ + HRESULT hr; + + hr = IDirectMusicPerformance8_CloseDown(performance); + ok(hr == S_OK, "CloseDown failed: %#lx\n", hr); + IDirectMusicPerformance8_Release(performance); + if (dmusic) + IDirectMusic_Release(dmusic); + if (dsound) + IDirectSound_Release(dsound); +} + static BOOL missing_dmime(void) { IDirectMusicSegment8 *dms; @@ -945,6 +986,49 @@ static void test_COM_track(void) } }
+static void test_COM_performance(void) +{ + IDirectMusicPerformance *dmp = (IDirectMusicPerformance*)0xdeadbeef; + IDirectMusicPerformance *dmp2; + IDirectMusicPerformance8 *dmp8; + ULONG refcount; + HRESULT hr; + + /* COM aggregation */ + hr = CoCreateInstance(&CLSID_DirectMusicPerformance, (IUnknown *)0xdeadbeef, CLSCTX_INPROC_SERVER, + &IID_IUnknown, (void**)&dmp); + ok(hr == CLASS_E_NOAGGREGATION, + "DirectMusicPerformance create failed: %#lx, expected CLASS_E_NOAGGREGATION\n", hr); + ok(!dmp, "dmp = %p\n", dmp); + + /* Invalid RIID */ + hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusicObject, (void**)&dmp); + ok(hr == E_NOINTERFACE, "DirectMusicPerformance create failed: %#lx, expected E_NOINTERFACE\n", hr); + + /* Same refcount */ + hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusicPerformance, (void**)&dmp); + ok(hr == S_OK, "DirectMusicPerformance create failed: %#lx, expected S_OK\n", hr); + refcount = IDirectMusicPerformance_AddRef(dmp); + ok (refcount == 2, "refcount == %lu, expected 2\n", refcount); + hr = IDirectMusicPerformance_QueryInterface(dmp, &IID_IDirectMusicPerformance2, (void**)&dmp2); + ok(hr == S_OK, "QueryInterface for IID_IDirectMusicPerformance2 failed: %#lx\n", hr); + IDirectMusicPerformance_AddRef(dmp); + refcount = IDirectMusicPerformance_Release(dmp); + ok (refcount == 3, "refcount == %lu, expected 3\n", refcount); + hr = IDirectMusicPerformance_QueryInterface(dmp, &IID_IDirectMusicPerformance8, (void**)&dmp8); + ok(hr == S_OK, "QueryInterface for IID_IDirectMusicPerformance8 failed: %#lx\n", hr); + refcount = IDirectMusicPerformance_Release(dmp); + ok (refcount == 3, "refcount == %lu, expected 3\n", refcount); + refcount = IDirectMusicPerformance8_Release(dmp8); + ok (refcount == 2, "refcount == %lu, expected 2\n", refcount); + refcount = IDirectMusicPerformance_Release(dmp2); + ok (refcount == 1, "refcount == %lu, expected 1\n", refcount); + refcount = IDirectMusicPerformance_Release(dmp); + ok (refcount == 0, "refcount == %lu, expected 0\n", refcount); +} + static void test_audiopathconfig(void) { IDirectMusicObject *dmo; @@ -1809,6 +1893,376 @@ static void test_parsedescriptor(void) } }
+static void test_performance_InitAudio(void) +{ + IDirectMusicPerformance8 *performance; + IDirectMusic *dmusic; + IDirectSound *dsound; + IDirectMusicPort *port; + IDirectMusicAudioPath *path; + DWORD channel, group; + HRESULT hr; + ULONG ref; + + hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusicPerformance8, (void **)&performance); + if (hr != S_OK) { + win_skip("Cannot create DirectMusicPerformance object (%lx)\n", hr); + CoUninitialize(); + return; + } + + dsound = NULL; + hr = IDirectMusicPerformance8_InitAudio(performance, NULL, &dsound, NULL, + DMUS_APATH_SHARED_STEREOPLUSREVERB, 128, DMUS_AUDIOF_ALL, NULL); + if (hr != S_OK) { + IDirectMusicPerformance8_Release(performance); + win_skip("InitAudio failed (%lx)\n", hr); + return; + } + + hr = IDirectMusicPerformance8_PChannelInfo(performance, 128, &port, NULL, NULL); + ok(hr == E_INVALIDARG, "PChannelInfo failed, got %#lx\n", hr); + hr = IDirectMusicPerformance8_PChannelInfo(performance, 127, &port, NULL, NULL); + ok(hr == S_OK, "PChannelInfo failed, got %#lx\n", hr); + IDirectMusicPort_Release(port); + port = NULL; + hr = IDirectMusicPerformance8_PChannelInfo(performance, 0, &port, NULL, NULL); + ok(hr == S_OK, "PChannelInfo failed, got %#lx\n", hr); + ok(port != NULL, "IDirectMusicPort not set\n"); + hr = IDirectMusicPerformance8_AssignPChannel(performance, 0, port, 0, 0); + todo_wine ok(hr == DMUS_E_AUDIOPATHS_IN_USE, "AssignPChannel failed (%#lx)\n", hr); + hr = IDirectMusicPerformance8_AssignPChannelBlock(performance, 0, port, 0); + todo_wine ok(hr == DMUS_E_AUDIOPATHS_IN_USE, "AssignPChannelBlock failed (%#lx)\n", hr); + IDirectMusicPort_Release(port); + + hr = IDirectMusicPerformance8_GetDefaultAudioPath(performance, &path); + ok(hr == S_OK, "Failed to call GetDefaultAudioPath (%lx)\n", hr); + if (hr == S_OK) + IDirectMusicAudioPath_Release(path); + + hr = IDirectMusicPerformance8_CloseDown(performance); + ok(hr == S_OK, "Failed to call CloseDown (%lx)\n", hr); + + IDirectMusicPerformance8_Release(performance); + + /* Auto generated dmusic and dsound */ + create_performance(&performance, NULL, NULL, FALSE); + hr = IDirectMusicPerformance8_InitAudio(performance, NULL, NULL, NULL, 0, 64, 0, NULL); + ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); + hr = IDirectMusicPerformance8_PChannelInfo(performance, 0, &port, NULL, NULL); + ok(hr == E_INVALIDARG, "PChannelInfo failed, got %#lx\n", hr); + destroy_performance(performance, NULL, NULL); + + /* Refcounts for auto generated dmusic and dsound */ + create_performance(&performance, NULL, NULL, FALSE); + dmusic = NULL; + dsound = NULL; + hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &dsound, NULL, 0, 64, 0, NULL); + ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); + ref = get_refcount(dsound); + ok(ref == 3, "dsound ref count got %ld expected 3\n", ref); + ref = get_refcount(dmusic); + ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); + destroy_performance(performance, NULL, NULL); + + /* dsound without SetCooperativeLevel() */ + create_performance(&performance, NULL, &dsound, FALSE); + hr = IDirectMusicPerformance8_InitAudio(performance, NULL, &dsound, NULL, 0, 0, 0, NULL); + todo_wine ok(hr == DSERR_PRIOLEVELNEEDED, "InitAudio failed: %#lx\n", hr); + destroy_performance(performance, NULL, dsound); + + /* Using the wrong CLSID_DirectSound */ + create_performance(&performance, NULL, NULL, FALSE); + hr = DirectSoundCreate(NULL, &dsound, NULL); + ok(hr == S_OK, "DirectSoundCreate failed: %#lx\n", hr); + hr = IDirectMusicPerformance8_InitAudio(performance, NULL, &dsound, NULL, 0, 0, 0, NULL); + todo_wine ok(hr == E_NOINTERFACE, "InitAudio failed: %#lx\n", hr); + destroy_performance(performance, NULL, dsound); + + /* Init() works with just a CLSID_DirectSound */ + create_performance(&performance, NULL, NULL, FALSE); + hr = DirectSoundCreate(NULL, &dsound, NULL); + ok(hr == S_OK, "DirectSoundCreate failed: %#lx\n", hr); + hr = IDirectSound_SetCooperativeLevel(dsound, GetForegroundWindow(), DSSCL_PRIORITY); + ok(hr == S_OK, "SetCooperativeLevel failed: %#lx\n", hr); + hr = IDirectMusicPerformance8_Init(performance, NULL, dsound, NULL); + ok(hr == S_OK, "Init failed: %#lx\n", hr); + destroy_performance(performance, NULL, dsound); + + /* Init() followed by InitAudio() */ + create_performance(&performance, NULL, &dsound, TRUE); + hr = IDirectMusicPerformance8_Init(performance, NULL, dsound, NULL); + ok(hr == S_OK, "Init failed: %#lx\n", hr); + hr = IDirectMusicPerformance8_InitAudio(performance, NULL, &dsound, NULL, 0, 0, 0, NULL); + ok(hr == DMUS_E_ALREADY_INITED, "InitAudio failed: %#lx\n", hr); + destroy_performance(performance, NULL, dsound); + + /* Provided dmusic and dsound */ + create_performance(&performance, &dmusic, &dsound, TRUE); + hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &dsound, NULL, 0, 64, 0, NULL); + ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); + ref = get_refcount(dsound); + todo_wine ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); + ref = get_refcount(dmusic); + ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); + destroy_performance(performance, dmusic, dsound); + + /* Provided dmusic initialized with SetDirectSound */ + create_performance(&performance, &dmusic, &dsound, TRUE); + hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL); + ok(hr == S_OK, "SetDirectSound failed: %#lx\n", hr); + ref = get_refcount(dsound); + ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); + hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, NULL, NULL, 0, 64, 0, NULL); + ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); + ref = get_refcount(dsound); + todo_wine ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); + ref = get_refcount(dmusic); + ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); + destroy_performance(performance, dmusic, dsound); + + /* Provided dmusic and dsound, dmusic initialized with SetDirectSound */ + create_performance(&performance, &dmusic, &dsound, TRUE); + hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL); + ok(hr == S_OK, "SetDirectSound failed: %#lx\n", hr); + ref = get_refcount(dsound); + ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); + hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &dsound, NULL, 0, 64, 0, NULL); + ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); + ref = get_refcount(dsound); + ok(ref == 3, "dsound ref count got %ld expected 3\n", ref); + ref = get_refcount(dmusic); + ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); + destroy_performance(performance, dmusic, dsound); + + /* InitAudio with perf channel count not a multiple of 16 rounds up */ + create_performance(&performance, NULL, NULL, TRUE); + hr = IDirectMusicPerformance8_InitAudio(performance, NULL, NULL, NULL, + DMUS_APATH_SHARED_STEREOPLUSREVERB, 29, DMUS_AUDIOF_ALL, NULL); + ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); + hr = IDirectMusicPerformance8_PChannelInfo(performance, 31, &port, &group, &channel); + ok(hr == S_OK && group == 2 && channel == 15, + "PChannelInfo failed, got %#lx, %lu, %lu\n", hr, group, channel); + hr = IDirectMusicPerformance8_PChannelInfo(performance, 32, &port, NULL, NULL); + ok(hr == E_INVALIDARG, "PChannelInfo failed, got %#lx\n", hr); + destroy_performance(performance, NULL, NULL); +} + +static void test_performance_createport(void) +{ + IDirectMusicPerformance8 *perf; + IDirectMusic *music = NULL; + IDirectMusicPort *port = NULL; + DMUS_PORTCAPS portcaps; + DMUS_PORTPARAMS portparams; + DWORD i; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, + CLSCTX_INPROC_SERVER, &IID_IDirectMusicPerformance8, (void**)&perf); + ok(hr == S_OK, "CoCreateInstance failed: %#lx\n", hr); + + hr = IDirectMusicPerformance8_Init(perf, &music, NULL, NULL); + ok(hr == S_OK, "Init failed: %#lx\n", hr); + ok(music != NULL, "Didn't get IDirectMusic pointer\n"); + + i = 0; + while(1){ + portcaps.dwSize = sizeof(portcaps); + + hr = IDirectMusic_EnumPort(music, i, &portcaps); + ok(hr == S_OK || hr == S_FALSE || (i == 0 && hr == E_INVALIDARG), "EnumPort failed: %#lx\n", hr); + if(hr != S_OK) + break; + + ok(portcaps.dwSize == sizeof(portcaps), "Got unexpected portcaps struct size: %lu\n", portcaps.dwSize); + trace("portcaps(%lu).dwFlags: %#lx\n", i, portcaps.dwFlags); + trace("portcaps(%lu).guidPort: %s\n", i, wine_dbgstr_guid(&portcaps.guidPort)); + trace("portcaps(%lu).dwClass: %#lx\n", i, portcaps.dwClass); + trace("portcaps(%lu).dwType: %#lx\n", i, portcaps.dwType); + trace("portcaps(%lu).dwMemorySize: %#lx\n", i, portcaps.dwMemorySize); + trace("portcaps(%lu).dwMaxChannelGroups: %lu\n", i, portcaps.dwMaxChannelGroups); + trace("portcaps(%lu).dwMaxVoices: %lu\n", i, portcaps.dwMaxVoices); + trace("portcaps(%lu).dwMaxAudioChannels: %lu\n", i, portcaps.dwMaxAudioChannels); + trace("portcaps(%lu).dwEffectFlags: %#lx\n", i, portcaps.dwEffectFlags); + trace("portcaps(%lu).wszDescription: %s\n", i, wine_dbgstr_w(portcaps.wszDescription)); + + ++i; + } + + if(i == 0){ + win_skip("No ports available, skipping tests\n"); + return; + } + + portparams.dwSize = sizeof(portparams); + + /* dwValidParams == 0 -> S_OK, filled struct */ + portparams.dwValidParams = 0; + hr = IDirectMusic_CreatePort(music, &CLSID_DirectMusicSynth, &portparams, &port, NULL); + ok(hr == S_OK, "CreatePort failed: %#lx\n", hr); + ok(port != NULL, "Didn't get IDirectMusicPort pointer\n"); + ok(portparams.dwValidParams, "portparams struct was not filled in\n"); + IDirectMusicPort_Release(port); + port = NULL; + + /* dwValidParams != 0, invalid param -> S_FALSE, filled struct */ + portparams.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS; + portparams.dwChannelGroups = 0; + hr = IDirectMusic_CreatePort(music, &CLSID_DirectMusicSynth, &portparams, &port, NULL); + todo_wine ok(hr == S_FALSE, "CreatePort failed: %#lx\n", hr); + ok(port != NULL, "Didn't get IDirectMusicPort pointer\n"); + ok(portparams.dwValidParams, "portparams struct was not filled in\n"); + IDirectMusicPort_Release(port); + port = NULL; + + /* dwValidParams != 0, valid params -> S_OK */ + hr = IDirectMusic_CreatePort(music, &CLSID_DirectMusicSynth, &portparams, &port, NULL); + ok(hr == S_OK, "CreatePort failed: %#lx\n", hr); + ok(port != NULL, "Didn't get IDirectMusicPort pointer\n"); + IDirectMusicPort_Release(port); + port = NULL; + + /* GUID_NULL succeeds */ + portparams.dwValidParams = 0; + hr = IDirectMusic_CreatePort(music, &GUID_NULL, &portparams, &port, NULL); + ok(hr == S_OK, "CreatePort failed: %#lx\n", hr); + ok(port != NULL, "Didn't get IDirectMusicPort pointer\n"); + ok(portparams.dwValidParams, "portparams struct was not filled in\n"); + IDirectMusicPort_Release(port); + port = NULL; + + /* null GUID fails */ + portparams.dwValidParams = 0; + hr = IDirectMusic_CreatePort(music, NULL, &portparams, &port, NULL); + ok(hr == E_POINTER, "CreatePort failed: %#lx\n", hr); + ok(port == NULL, "Get IDirectMusicPort pointer? %p\n", port); + ok(portparams.dwValidParams == 0, "portparams struct was filled in?\n"); + + /* garbage GUID fails */ + portparams.dwValidParams = 0; + hr = IDirectMusic_CreatePort(music, &GUID_Bunk, &portparams, &port, NULL); + ok(hr == E_NOINTERFACE, "CreatePort failed: %#lx\n", hr); + ok(port == NULL, "Get IDirectMusicPort pointer? %p\n", port); + ok(portparams.dwValidParams == 0, "portparams struct was filled in?\n"); + + hr = IDirectMusicPerformance8_CloseDown(perf); + ok(hr == S_OK, "CloseDown failed: %#lx\n", hr); + + IDirectMusic_Release(music); + IDirectMusicPerformance8_Release(perf); +} + +static void test_performance_pchannel(void) +{ + IDirectMusicPerformance8 *perf; + IDirectMusicPort *port = NULL, *port2; + DWORD channel, group; + unsigned int i; + HRESULT hr; + + create_performance(&perf, NULL, NULL, TRUE); + hr = IDirectMusicPerformance8_Init(perf, NULL, NULL, NULL); + ok(hr == S_OK, "Init failed: %#lx\n", hr); + hr = IDirectMusicPerformance8_PChannelInfo(perf, 0, &port, NULL, NULL); + ok(hr == E_INVALIDARG && !port, "PChannelInfo failed, got %#lx, %p\n", hr, port); + + /* Add default port. Sets PChannels 0-15 to the corresponding channels in group 1 */ + hr = IDirectMusicPerformance8_AddPort(perf, NULL); + ok(hr == S_OK, "AddPort of default port failed: %#lx\n", hr); + hr = IDirectMusicPerformance8_PChannelInfo(perf, 0, NULL, NULL, NULL); + ok(hr == S_OK, "PChannelInfo failed, got %#lx\n", hr); + hr = IDirectMusicPerformance8_PChannelInfo(perf, 0, &port, NULL, NULL); + ok(hr == S_OK && port, "PChannelInfo failed, got %#lx, %p\n", hr, port); + for (i = 1; i < 16; i++) { + hr = IDirectMusicPerformance8_PChannelInfo(perf, i, &port2, &group, &channel); + ok(hr == S_OK && port == port2 && group == 1 && channel == i, + "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); + IDirectMusicPort_Release(port2); + } + + /* Unset PChannels fail to retrieve */ + hr = IDirectMusicPerformance8_PChannelInfo(perf, 16, &port2, NULL, NULL); + ok(hr == E_INVALIDARG, "PChannelInfo failed, got %#lx, %p\n", hr, port); + hr = IDirectMusicPerformance8_PChannelInfo(perf, MAXDWORD - 16, &port2, NULL, NULL); + ok(hr == E_INVALIDARG, "PChannelInfo failed, got %#lx, %p\n", hr, port); + + /* Channel group 0 can be set just fine */ + hr = IDirectMusicPerformance8_AssignPChannel(perf, 0, port, 0, 0); + ok(hr == S_OK, "AssignPChannel failed, got %#lx\n", hr); + hr = IDirectMusicPerformance8_AssignPChannelBlock(perf, 0, port, 0); + ok(hr == S_OK, "AssignPChannelBlock failed, got %#lx\n", hr); + for (i = 1; i < 16; i++) { + hr = IDirectMusicPerformance8_PChannelInfo(perf, i, &port2, &group, &channel); + ok(hr == S_OK && port == port2 && group == 0 && channel == i, + "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); + IDirectMusicPort_Release(port2); + } + + /* Last PChannel Block can be set only individually but not read */ + hr = IDirectMusicPerformance8_AssignPChannel(perf, MAXDWORD, port, 0, 3); + ok(hr == S_OK, "AssignPChannel failed, got %#lx\n", hr); + port2 = (IDirectMusicPort *)0xdeadbeef; + hr = IDirectMusicPerformance8_PChannelInfo(perf, MAXDWORD, &port2, NULL, NULL); + todo_wine ok(hr == E_INVALIDARG && port2 == (IDirectMusicPort *)0xdeadbeef, + "PChannelInfo failed, got %#lx, %p\n", hr, port2); + hr = IDirectMusicPerformance8_AssignPChannelBlock(perf, MAXDWORD, port, 0); + ok(hr == E_INVALIDARG, "AssignPChannelBlock failed, got %#lx\n", hr); + hr = IDirectMusicPerformance8_AssignPChannelBlock(perf, MAXDWORD / 16, port, 1); + todo_wine ok(hr == E_INVALIDARG, "AssignPChannelBlock failed, got %#lx\n", hr); + for (i = MAXDWORD - 15; i < MAXDWORD; i++) { + hr = IDirectMusicPerformance8_AssignPChannel(perf, i, port, 0, 0); + ok(hr == S_OK, "AssignPChannel failed, got %#lx\n", hr); + hr = IDirectMusicPerformance8_PChannelInfo(perf, i, &port2, NULL, NULL); + todo_wine ok(hr == E_INVALIDARG && port2 == (IDirectMusicPort *)0xdeadbeef, + "PChannelInfo failed, got %#lx, %p\n", hr, port2); + } + + /* Second to last PChannel Block can be set only individually and read */ + hr = IDirectMusicPerformance8_AssignPChannelBlock(perf, MAXDWORD / 16 - 1, port, 1); + todo_wine ok(hr == E_INVALIDARG, "AssignPChannelBlock failed, got %#lx\n", hr); + for (i = MAXDWORD - 31; i < MAXDWORD - 15; i++) { + hr = IDirectMusicPerformance8_AssignPChannel(perf, i, port, 1, 7); + ok(hr == S_OK, "AssignPChannel failed, got %#lx\n", hr); + hr = IDirectMusicPerformance8_PChannelInfo(perf, i, &port2, &group, &channel); + ok(hr == S_OK && port2 == port && group == 1 && channel == 7, + "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); + IDirectMusicPort_Release(port2); + } + + /* Third to last PChannel Block behaves normal */ + hr = IDirectMusicPerformance8_AssignPChannelBlock(perf, MAXDWORD / 16 - 2, port, 0); + ok(hr == S_OK, "AssignPChannelBlock failed, got %#lx\n", hr); + for (i = MAXDWORD - 47; i < MAXDWORD - 31; i++) { + hr = IDirectMusicPerformance8_PChannelInfo(perf, i, &port2, &group, &channel); + ok(hr == S_OK && port2 == port && group == 0 && channel == i % 16, + "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); + IDirectMusicPort_Release(port2); + } + + /* One PChannel set in a Block, rest is initialized too */ + hr = IDirectMusicPerformance8_AssignPChannel(perf, 4711, port, 1, 13); + ok(hr == S_OK, "AssignPChannel failed, got %#lx\n", hr); + hr = IDirectMusicPerformance8_PChannelInfo(perf, 4711, &port2, &group, &channel); + ok(hr == S_OK && port2 == port && group == 1 && channel == 13, + "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); + IDirectMusicPort_Release(port2); + group = channel = 0xdeadbeef; + hr = IDirectMusicPerformance8_PChannelInfo(perf, 4712, &port2, &group, &channel); + ok(hr == S_OK && port2 == port && group == 0 && channel == 8, + "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); + IDirectMusicPort_Release(port2); + group = channel = 0xdeadbeef; + hr = IDirectMusicPerformance8_PChannelInfo(perf, 4719, &port2, &group, &channel); + ok(hr == S_OK && port2 == port && group == 0 && channel == 15, + "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); + IDirectMusicPort_Release(port2); + + IDirectMusicPort_Release(port); + destroy_performance(perf, NULL, NULL); +} + static void test_performance_tool(void) { IDirectMusicPerformance *performance; @@ -3169,6 +3623,7 @@ START_TEST(dmime) test_COM_segment(); test_COM_segmentstate(); test_COM_track(); + test_COM_performance(); test_audiopathconfig(); test_graph(); test_segment(); @@ -3176,6 +3631,9 @@ START_TEST(dmime) test_segment_param(); test_track(); test_parsedescriptor(); + test_performance_InitAudio(); + test_performance_createport(); + test_performance_pchannel(); test_performance_tool(); test_performance_graph(); test_performance_time(); diff --git a/dlls/dmime/tests/performance.c b/dlls/dmime/tests/performance.c deleted file mode 100644 index 6a8efcdf28a..00000000000 --- a/dlls/dmime/tests/performance.c +++ /dev/null @@ -1,513 +0,0 @@ -/* - * Unit test suite for IDirectMusicPerformance - * - * Copyright 2010 Austin Lund - * - * 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 - */ - -#define COBJMACROS - -#include <stdarg.h> -#include <windef.h> -#include <initguid.h> -#include <wine/test.h> -#include <dmusici.h> - -#include <stdio.h> - -DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); -DEFINE_GUID(GUID_Bunk,0xFFFFFFFF,0xFFFF,0xFFFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF); - -static void create_performance(IDirectMusicPerformance8 **performance, IDirectMusic **dmusic, - IDirectSound **dsound, BOOL set_cooplevel) -{ - HRESULT hr; - - hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, - &IID_IDirectMusicPerformance8, (void **)performance); - ok(hr == S_OK, "DirectMusicPerformance create failed: %#lx\n", hr); - if (dmusic) { - hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, - (void **)dmusic); - ok(hr == S_OK, "DirectMusic create failed: %#lx\n", hr); - } - if (dsound) { - hr = DirectSoundCreate8(NULL, (IDirectSound8 **)dsound, NULL); - ok(hr == S_OK, "DirectSoundCreate failed: %#lx\n", hr); - if (set_cooplevel) { - hr = IDirectSound_SetCooperativeLevel(*dsound, GetForegroundWindow(), DSSCL_PRIORITY); - ok(hr == S_OK, "SetCooperativeLevel failed: %#lx\n", hr); - } - } -} - -static void destroy_performance(IDirectMusicPerformance8 *performance, IDirectMusic *dmusic, - IDirectSound *dsound) -{ - HRESULT hr; - - hr = IDirectMusicPerformance8_CloseDown(performance); - ok(hr == S_OK, "CloseDown failed: %#lx\n", hr); - IDirectMusicPerformance8_Release(performance); - if (dmusic) - IDirectMusic_Release(dmusic); - if (dsound) - IDirectSound_Release(dsound); -} - -static ULONG get_refcount(void *iface) -{ - IUnknown *unknown = iface; - IUnknown_AddRef(unknown); - return IUnknown_Release(unknown); -} - -static HRESULT test_InitAudio(void) -{ - IDirectMusicPerformance8 *performance; - IDirectMusic *dmusic; - IDirectSound *dsound; - IDirectMusicPort *port; - IDirectMusicAudioPath *path; - DWORD channel, group; - HRESULT hr; - ULONG ref; - - hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, - &IID_IDirectMusicPerformance8, (void **)&performance); - if (hr != S_OK) { - skip("Cannot create DirectMusicPerformance object (%lx)\n", hr); - CoUninitialize(); - return hr; - } - - dsound = NULL; - hr = IDirectMusicPerformance8_InitAudio(performance, NULL, &dsound, NULL, - DMUS_APATH_SHARED_STEREOPLUSREVERB, 128, DMUS_AUDIOF_ALL, NULL); - if (hr != S_OK) { - IDirectMusicPerformance8_Release(performance); - return hr; - } - - hr = IDirectMusicPerformance8_PChannelInfo(performance, 128, &port, NULL, NULL); - ok(hr == E_INVALIDARG, "PChannelInfo failed, got %#lx\n", hr); - hr = IDirectMusicPerformance8_PChannelInfo(performance, 127, &port, NULL, NULL); - ok(hr == S_OK, "PChannelInfo failed, got %#lx\n", hr); - IDirectMusicPort_Release(port); - port = NULL; - hr = IDirectMusicPerformance8_PChannelInfo(performance, 0, &port, NULL, NULL); - ok(hr == S_OK, "PChannelInfo failed, got %#lx\n", hr); - ok(port != NULL, "IDirectMusicPort not set\n"); - hr = IDirectMusicPerformance8_AssignPChannel(performance, 0, port, 0, 0); - todo_wine ok(hr == DMUS_E_AUDIOPATHS_IN_USE, "AssignPChannel failed (%#lx)\n", hr); - hr = IDirectMusicPerformance8_AssignPChannelBlock(performance, 0, port, 0); - todo_wine ok(hr == DMUS_E_AUDIOPATHS_IN_USE, "AssignPChannelBlock failed (%#lx)\n", hr); - IDirectMusicPort_Release(port); - - hr = IDirectMusicPerformance8_GetDefaultAudioPath(performance, &path); - ok(hr == S_OK, "Failed to call GetDefaultAudioPath (%lx)\n", hr); - if (hr == S_OK) - IDirectMusicAudioPath_Release(path); - - hr = IDirectMusicPerformance8_CloseDown(performance); - ok(hr == S_OK, "Failed to call CloseDown (%lx)\n", hr); - - IDirectMusicPerformance8_Release(performance); - - /* Auto generated dmusic and dsound */ - create_performance(&performance, NULL, NULL, FALSE); - hr = IDirectMusicPerformance8_InitAudio(performance, NULL, NULL, NULL, 0, 64, 0, NULL); - ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); - hr = IDirectMusicPerformance8_PChannelInfo(performance, 0, &port, NULL, NULL); - ok(hr == E_INVALIDARG, "PChannelInfo failed, got %#lx\n", hr); - destroy_performance(performance, NULL, NULL); - - /* Refcounts for auto generated dmusic and dsound */ - create_performance(&performance, NULL, NULL, FALSE); - dmusic = NULL; - dsound = NULL; - hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &dsound, NULL, 0, 64, 0, NULL); - ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); - ref = get_refcount(dsound); - ok(ref == 3, "dsound ref count got %ld expected 3\n", ref); - ref = get_refcount(dmusic); - ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); - destroy_performance(performance, NULL, NULL); - - /* dsound without SetCooperativeLevel() */ - create_performance(&performance, NULL, &dsound, FALSE); - hr = IDirectMusicPerformance8_InitAudio(performance, NULL, &dsound, NULL, 0, 0, 0, NULL); - todo_wine ok(hr == DSERR_PRIOLEVELNEEDED, "InitAudio failed: %#lx\n", hr); - destroy_performance(performance, NULL, dsound); - - /* Using the wrong CLSID_DirectSound */ - create_performance(&performance, NULL, NULL, FALSE); - hr = DirectSoundCreate(NULL, &dsound, NULL); - ok(hr == S_OK, "DirectSoundCreate failed: %#lx\n", hr); - hr = IDirectMusicPerformance8_InitAudio(performance, NULL, &dsound, NULL, 0, 0, 0, NULL); - todo_wine ok(hr == E_NOINTERFACE, "InitAudio failed: %#lx\n", hr); - destroy_performance(performance, NULL, dsound); - - /* Init() works with just a CLSID_DirectSound */ - create_performance(&performance, NULL, NULL, FALSE); - hr = DirectSoundCreate(NULL, &dsound, NULL); - ok(hr == S_OK, "DirectSoundCreate failed: %#lx\n", hr); - hr = IDirectSound_SetCooperativeLevel(dsound, GetForegroundWindow(), DSSCL_PRIORITY); - ok(hr == S_OK, "SetCooperativeLevel failed: %#lx\n", hr); - hr = IDirectMusicPerformance8_Init(performance, NULL, dsound, NULL); - ok(hr == S_OK, "Init failed: %#lx\n", hr); - destroy_performance(performance, NULL, dsound); - - /* Init() followed by InitAudio() */ - create_performance(&performance, NULL, &dsound, TRUE); - hr = IDirectMusicPerformance8_Init(performance, NULL, dsound, NULL); - ok(hr == S_OK, "Init failed: %#lx\n", hr); - hr = IDirectMusicPerformance8_InitAudio(performance, NULL, &dsound, NULL, 0, 0, 0, NULL); - ok(hr == DMUS_E_ALREADY_INITED, "InitAudio failed: %#lx\n", hr); - destroy_performance(performance, NULL, dsound); - - /* Provided dmusic and dsound */ - create_performance(&performance, &dmusic, &dsound, TRUE); - hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &dsound, NULL, 0, 64, 0, NULL); - ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); - ref = get_refcount(dsound); - todo_wine ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); - ref = get_refcount(dmusic); - ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); - destroy_performance(performance, dmusic, dsound); - - /* Provided dmusic initialized with SetDirectSound */ - create_performance(&performance, &dmusic, &dsound, TRUE); - hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL); - ok(hr == S_OK, "SetDirectSound failed: %#lx\n", hr); - ref = get_refcount(dsound); - ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); - hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, NULL, NULL, 0, 64, 0, NULL); - ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); - ref = get_refcount(dsound); - todo_wine ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); - ref = get_refcount(dmusic); - ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); - destroy_performance(performance, dmusic, dsound); - - /* Provided dmusic and dsound, dmusic initialized with SetDirectSound */ - create_performance(&performance, &dmusic, &dsound, TRUE); - hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL); - ok(hr == S_OK, "SetDirectSound failed: %#lx\n", hr); - ref = get_refcount(dsound); - ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); - hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &dsound, NULL, 0, 64, 0, NULL); - ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); - ref = get_refcount(dsound); - ok(ref == 3, "dsound ref count got %ld expected 3\n", ref); - ref = get_refcount(dmusic); - ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); - destroy_performance(performance, dmusic, dsound); - - /* InitAudio with perf channel count not a multiple of 16 rounds up */ - create_performance(&performance, NULL, NULL, TRUE); - hr = IDirectMusicPerformance8_InitAudio(performance, NULL, NULL, NULL, - DMUS_APATH_SHARED_STEREOPLUSREVERB, 29, DMUS_AUDIOF_ALL, NULL); - ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); - hr = IDirectMusicPerformance8_PChannelInfo(performance, 31, &port, &group, &channel); - ok(hr == S_OK && group == 2 && channel == 15, - "PChannelInfo failed, got %#lx, %lu, %lu\n", hr, group, channel); - hr = IDirectMusicPerformance8_PChannelInfo(performance, 32, &port, NULL, NULL); - ok(hr == E_INVALIDARG, "PChannelInfo failed, got %#lx\n", hr); - destroy_performance(performance, NULL, NULL); - - return S_OK; -} - -static void test_createport(void) -{ - IDirectMusicPerformance8 *perf; - IDirectMusic *music = NULL; - IDirectMusicPort *port = NULL; - DMUS_PORTCAPS portcaps; - DMUS_PORTPARAMS portparams; - DWORD i; - HRESULT hr; - - hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, - CLSCTX_INPROC_SERVER, &IID_IDirectMusicPerformance8, (void**)&perf); - ok(hr == S_OK, "CoCreateInstance failed: %#lx\n", hr); - - hr = IDirectMusicPerformance8_Init(perf, &music, NULL, NULL); - ok(hr == S_OK, "Init failed: %#lx\n", hr); - ok(music != NULL, "Didn't get IDirectMusic pointer\n"); - - i = 0; - while(1){ - portcaps.dwSize = sizeof(portcaps); - - hr = IDirectMusic_EnumPort(music, i, &portcaps); - ok(hr == S_OK || hr == S_FALSE || (i == 0 && hr == E_INVALIDARG), "EnumPort failed: %#lx\n", hr); - if(hr != S_OK) - break; - - ok(portcaps.dwSize == sizeof(portcaps), "Got unexpected portcaps struct size: %lu\n", portcaps.dwSize); - trace("portcaps(%lu).dwFlags: %#lx\n", i, portcaps.dwFlags); - trace("portcaps(%lu).guidPort: %s\n", i, wine_dbgstr_guid(&portcaps.guidPort)); - trace("portcaps(%lu).dwClass: %#lx\n", i, portcaps.dwClass); - trace("portcaps(%lu).dwType: %#lx\n", i, portcaps.dwType); - trace("portcaps(%lu).dwMemorySize: %#lx\n", i, portcaps.dwMemorySize); - trace("portcaps(%lu).dwMaxChannelGroups: %lu\n", i, portcaps.dwMaxChannelGroups); - trace("portcaps(%lu).dwMaxVoices: %lu\n", i, portcaps.dwMaxVoices); - trace("portcaps(%lu).dwMaxAudioChannels: %lu\n", i, portcaps.dwMaxAudioChannels); - trace("portcaps(%lu).dwEffectFlags: %#lx\n", i, portcaps.dwEffectFlags); - trace("portcaps(%lu).wszDescription: %s\n", i, wine_dbgstr_w(portcaps.wszDescription)); - - ++i; - } - - if(i == 0){ - win_skip("No ports available, skipping tests\n"); - return; - } - - portparams.dwSize = sizeof(portparams); - - /* dwValidParams == 0 -> S_OK, filled struct */ - portparams.dwValidParams = 0; - hr = IDirectMusic_CreatePort(music, &CLSID_DirectMusicSynth, &portparams, &port, NULL); - ok(hr == S_OK, "CreatePort failed: %#lx\n", hr); - ok(port != NULL, "Didn't get IDirectMusicPort pointer\n"); - ok(portparams.dwValidParams, "portparams struct was not filled in\n"); - IDirectMusicPort_Release(port); - port = NULL; - - /* dwValidParams != 0, invalid param -> S_FALSE, filled struct */ - portparams.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS; - portparams.dwChannelGroups = 0; - hr = IDirectMusic_CreatePort(music, &CLSID_DirectMusicSynth, &portparams, &port, NULL); - todo_wine ok(hr == S_FALSE, "CreatePort failed: %#lx\n", hr); - ok(port != NULL, "Didn't get IDirectMusicPort pointer\n"); - ok(portparams.dwValidParams, "portparams struct was not filled in\n"); - IDirectMusicPort_Release(port); - port = NULL; - - /* dwValidParams != 0, valid params -> S_OK */ - hr = IDirectMusic_CreatePort(music, &CLSID_DirectMusicSynth, &portparams, &port, NULL); - ok(hr == S_OK, "CreatePort failed: %#lx\n", hr); - ok(port != NULL, "Didn't get IDirectMusicPort pointer\n"); - IDirectMusicPort_Release(port); - port = NULL; - - /* GUID_NULL succeeds */ - portparams.dwValidParams = 0; - hr = IDirectMusic_CreatePort(music, &GUID_NULL, &portparams, &port, NULL); - ok(hr == S_OK, "CreatePort failed: %#lx\n", hr); - ok(port != NULL, "Didn't get IDirectMusicPort pointer\n"); - ok(portparams.dwValidParams, "portparams struct was not filled in\n"); - IDirectMusicPort_Release(port); - port = NULL; - - /* null GUID fails */ - portparams.dwValidParams = 0; - hr = IDirectMusic_CreatePort(music, NULL, &portparams, &port, NULL); - ok(hr == E_POINTER, "CreatePort failed: %#lx\n", hr); - ok(port == NULL, "Get IDirectMusicPort pointer? %p\n", port); - ok(portparams.dwValidParams == 0, "portparams struct was filled in?\n"); - - /* garbage GUID fails */ - portparams.dwValidParams = 0; - hr = IDirectMusic_CreatePort(music, &GUID_Bunk, &portparams, &port, NULL); - ok(hr == E_NOINTERFACE, "CreatePort failed: %#lx\n", hr); - ok(port == NULL, "Get IDirectMusicPort pointer? %p\n", port); - ok(portparams.dwValidParams == 0, "portparams struct was filled in?\n"); - - hr = IDirectMusicPerformance8_CloseDown(perf); - ok(hr == S_OK, "CloseDown failed: %#lx\n", hr); - - IDirectMusic_Release(music); - IDirectMusicPerformance8_Release(perf); -} - -static void test_pchannel(void) -{ - IDirectMusicPerformance8 *perf; - IDirectMusicPort *port = NULL, *port2; - DWORD channel, group; - unsigned int i; - HRESULT hr; - - create_performance(&perf, NULL, NULL, TRUE); - hr = IDirectMusicPerformance8_Init(perf, NULL, NULL, NULL); - ok(hr == S_OK, "Init failed: %#lx\n", hr); - hr = IDirectMusicPerformance8_PChannelInfo(perf, 0, &port, NULL, NULL); - ok(hr == E_INVALIDARG && !port, "PChannelInfo failed, got %#lx, %p\n", hr, port); - - /* Add default port. Sets PChannels 0-15 to the corresponding channels in group 1 */ - hr = IDirectMusicPerformance8_AddPort(perf, NULL); - ok(hr == S_OK, "AddPort of default port failed: %#lx\n", hr); - hr = IDirectMusicPerformance8_PChannelInfo(perf, 0, NULL, NULL, NULL); - ok(hr == S_OK, "PChannelInfo failed, got %#lx\n", hr); - hr = IDirectMusicPerformance8_PChannelInfo(perf, 0, &port, NULL, NULL); - ok(hr == S_OK && port, "PChannelInfo failed, got %#lx, %p\n", hr, port); - for (i = 1; i < 16; i++) { - hr = IDirectMusicPerformance8_PChannelInfo(perf, i, &port2, &group, &channel); - ok(hr == S_OK && port == port2 && group == 1 && channel == i, - "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); - IDirectMusicPort_Release(port2); - } - - /* Unset PChannels fail to retrieve */ - hr = IDirectMusicPerformance8_PChannelInfo(perf, 16, &port2, NULL, NULL); - ok(hr == E_INVALIDARG, "PChannelInfo failed, got %#lx, %p\n", hr, port); - hr = IDirectMusicPerformance8_PChannelInfo(perf, MAXDWORD - 16, &port2, NULL, NULL); - ok(hr == E_INVALIDARG, "PChannelInfo failed, got %#lx, %p\n", hr, port); - - /* Channel group 0 can be set just fine */ - hr = IDirectMusicPerformance8_AssignPChannel(perf, 0, port, 0, 0); - ok(hr == S_OK, "AssignPChannel failed, got %#lx\n", hr); - hr = IDirectMusicPerformance8_AssignPChannelBlock(perf, 0, port, 0); - ok(hr == S_OK, "AssignPChannelBlock failed, got %#lx\n", hr); - for (i = 1; i < 16; i++) { - hr = IDirectMusicPerformance8_PChannelInfo(perf, i, &port2, &group, &channel); - ok(hr == S_OK && port == port2 && group == 0 && channel == i, - "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); - IDirectMusicPort_Release(port2); - } - - /* Last PChannel Block can be set only individually but not read */ - hr = IDirectMusicPerformance8_AssignPChannel(perf, MAXDWORD, port, 0, 3); - ok(hr == S_OK, "AssignPChannel failed, got %#lx\n", hr); - port2 = (IDirectMusicPort *)0xdeadbeef; - hr = IDirectMusicPerformance8_PChannelInfo(perf, MAXDWORD, &port2, NULL, NULL); - todo_wine ok(hr == E_INVALIDARG && port2 == (IDirectMusicPort *)0xdeadbeef, - "PChannelInfo failed, got %#lx, %p\n", hr, port2); - hr = IDirectMusicPerformance8_AssignPChannelBlock(perf, MAXDWORD, port, 0); - ok(hr == E_INVALIDARG, "AssignPChannelBlock failed, got %#lx\n", hr); - hr = IDirectMusicPerformance8_AssignPChannelBlock(perf, MAXDWORD / 16, port, 1); - todo_wine ok(hr == E_INVALIDARG, "AssignPChannelBlock failed, got %#lx\n", hr); - for (i = MAXDWORD - 15; i < MAXDWORD; i++) { - hr = IDirectMusicPerformance8_AssignPChannel(perf, i, port, 0, 0); - ok(hr == S_OK, "AssignPChannel failed, got %#lx\n", hr); - hr = IDirectMusicPerformance8_PChannelInfo(perf, i, &port2, NULL, NULL); - todo_wine ok(hr == E_INVALIDARG && port2 == (IDirectMusicPort *)0xdeadbeef, - "PChannelInfo failed, got %#lx, %p\n", hr, port2); - } - - /* Second to last PChannel Block can be set only individually and read */ - hr = IDirectMusicPerformance8_AssignPChannelBlock(perf, MAXDWORD / 16 - 1, port, 1); - todo_wine ok(hr == E_INVALIDARG, "AssignPChannelBlock failed, got %#lx\n", hr); - for (i = MAXDWORD - 31; i < MAXDWORD - 15; i++) { - hr = IDirectMusicPerformance8_AssignPChannel(perf, i, port, 1, 7); - ok(hr == S_OK, "AssignPChannel failed, got %#lx\n", hr); - hr = IDirectMusicPerformance8_PChannelInfo(perf, i, &port2, &group, &channel); - ok(hr == S_OK && port2 == port && group == 1 && channel == 7, - "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); - IDirectMusicPort_Release(port2); - } - - /* Third to last PChannel Block behaves normal */ - hr = IDirectMusicPerformance8_AssignPChannelBlock(perf, MAXDWORD / 16 - 2, port, 0); - ok(hr == S_OK, "AssignPChannelBlock failed, got %#lx\n", hr); - for (i = MAXDWORD - 47; i < MAXDWORD - 31; i++) { - hr = IDirectMusicPerformance8_PChannelInfo(perf, i, &port2, &group, &channel); - ok(hr == S_OK && port2 == port && group == 0 && channel == i % 16, - "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); - IDirectMusicPort_Release(port2); - } - - /* One PChannel set in a Block, rest is initialized too */ - hr = IDirectMusicPerformance8_AssignPChannel(perf, 4711, port, 1, 13); - ok(hr == S_OK, "AssignPChannel failed, got %#lx\n", hr); - hr = IDirectMusicPerformance8_PChannelInfo(perf, 4711, &port2, &group, &channel); - ok(hr == S_OK && port2 == port && group == 1 && channel == 13, - "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); - IDirectMusicPort_Release(port2); - group = channel = 0xdeadbeef; - hr = IDirectMusicPerformance8_PChannelInfo(perf, 4712, &port2, &group, &channel); - ok(hr == S_OK && port2 == port && group == 0 && channel == 8, - "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); - IDirectMusicPort_Release(port2); - group = channel = 0xdeadbeef; - hr = IDirectMusicPerformance8_PChannelInfo(perf, 4719, &port2, &group, &channel); - ok(hr == S_OK && port2 == port && group == 0 && channel == 15, - "PChannelInfo failed, got %#lx, %p, %lu, %lu\n", hr, port2, group, channel); - IDirectMusicPort_Release(port2); - - IDirectMusicPort_Release(port); - destroy_performance(perf, NULL, NULL); -} - -static void test_COM(void) -{ - IDirectMusicPerformance *dmp = (IDirectMusicPerformance*)0xdeadbeef; - IDirectMusicPerformance *dmp2; - IDirectMusicPerformance8 *dmp8; - ULONG refcount; - HRESULT hr; - - /* COM aggregation */ - hr = CoCreateInstance(&CLSID_DirectMusicPerformance, (IUnknown *)0xdeadbeef, CLSCTX_INPROC_SERVER, - &IID_IUnknown, (void**)&dmp); - ok(hr == CLASS_E_NOAGGREGATION, - "DirectMusicPerformance create failed: %#lx, expected CLASS_E_NOAGGREGATION\n", hr); - ok(!dmp, "dmp = %p\n", dmp); - - /* Invalid RIID */ - hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, - &IID_IDirectMusicObject, (void**)&dmp); - ok(hr == E_NOINTERFACE, "DirectMusicPerformance create failed: %#lx, expected E_NOINTERFACE\n", hr); - - /* Same refcount */ - hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, - &IID_IDirectMusicPerformance, (void**)&dmp); - ok(hr == S_OK, "DirectMusicPerformance create failed: %#lx, expected S_OK\n", hr); - refcount = IDirectMusicPerformance_AddRef(dmp); - ok (refcount == 2, "refcount == %lu, expected 2\n", refcount); - hr = IDirectMusicPerformance_QueryInterface(dmp, &IID_IDirectMusicPerformance2, (void**)&dmp2); - ok(hr == S_OK, "QueryInterface for IID_IDirectMusicPerformance2 failed: %#lx\n", hr); - IDirectMusicPerformance_AddRef(dmp); - refcount = IDirectMusicPerformance_Release(dmp); - ok (refcount == 3, "refcount == %lu, expected 3\n", refcount); - hr = IDirectMusicPerformance_QueryInterface(dmp, &IID_IDirectMusicPerformance8, (void**)&dmp8); - ok(hr == S_OK, "QueryInterface for IID_IDirectMusicPerformance8 failed: %#lx\n", hr); - refcount = IDirectMusicPerformance_Release(dmp); - ok (refcount == 3, "refcount == %lu, expected 3\n", refcount); - refcount = IDirectMusicPerformance8_Release(dmp8); - ok (refcount == 2, "refcount == %lu, expected 2\n", refcount); - refcount = IDirectMusicPerformance_Release(dmp2); - ok (refcount == 1, "refcount == %lu, expected 1\n", refcount); - refcount = IDirectMusicPerformance_Release(dmp); - ok (refcount == 0, "refcount == %lu, expected 0\n", refcount); -} - -START_TEST( performance ) -{ - HRESULT hr; - - hr = CoInitialize(NULL); - if (FAILED(hr)) { - skip("Cannot initialize COM (%lx)\n", hr); - return; - } - - hr = test_InitAudio(); - if (hr != S_OK) { - skip("InitAudio failed (%lx)\n", hr); - return; - } - - test_COM(); - test_createport(); - test_pchannel(); - - CoUninitialize(); -}
From: Rémi Bernon rbernon@codeweavers.com
Final Fantasy VIII does this, more or less, and needs Init to succeed. --- dlls/dmime/tests/dmime.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index 12056f15376..f016af2f9e6 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -1895,6 +1895,12 @@ static void test_parsedescriptor(void)
static void test_performance_InitAudio(void) { + DMUS_PORTPARAMS params = + { + .dwSize = sizeof(params), + .dwValidParams = DMUS_PORTPARAMS_EFFECTS, + .dwEffectFlags = 1, + }; IDirectMusicPerformance8 *performance; IDirectMusic *dmusic; IDirectSound *dsound; @@ -2036,6 +2042,20 @@ static void test_performance_InitAudio(void) ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); destroy_performance(performance, dmusic, dsound);
+ /* Provided dmusic and dsound, dmusic initialized with SetDirectSound, port created and activated */ + create_performance(&performance, &dmusic, &dsound, TRUE); + hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL); + ok(hr == S_OK, "SetDirectSound failed: %#lx\n", hr); + hr = IDirectMusic_CreatePort(dmusic, &CLSID_DirectMusicSynth, ¶ms, &port, NULL); + ok(hr == S_OK, "CreatePort failed: %#lx\n", hr); + hr = IDirectMusicPort_Activate(port, TRUE); + ok(hr == S_OK, "Activate failed: %#lx\n", hr); + hr = IDirectMusicPort_SetNumChannelGroups(port, 1); + ok(hr == S_OK, "SetNumChannelGroups failed: %#lx\n", hr); + hr = IDirectMusicPerformance8_Init(performance, &dmusic, dsound, 0); + todo_wine ok(hr == S_OK, "Init failed: %#lx\n", hr); + destroy_performance(performance, dmusic, dsound); + /* InitAudio with perf channel count not a multiple of 16 rounds up */ create_performance(&performance, NULL, NULL, TRUE); hr = IDirectMusicPerformance8_InitAudio(performance, NULL, NULL, NULL,
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmime/performance.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index d8624427423..e2d070b0fbe 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -651,10 +651,14 @@ static HRESULT perf_dmport_create(struct performance *perf, DMUS_PORTPARAMS *par
if (FAILED(hr = IDirectMusic8_CreatePort(perf->dmusic, &guid, params, &port, NULL))) return hr; - if (FAILED(hr = IDirectMusicPort_Activate(port, TRUE))) { + + if (FAILED(hr = IDirectMusicPort_SetDirectSound(port, perf->dsound, NULL)) + || FAILED(hr = IDirectMusicPort_Activate(port, TRUE))) + { IDirectMusicPort_Release(port); return hr; } + for (i = 0; i < params->dwChannelGroups; i++) pchannel_block_set(&perf->pchannels, i, port, i + 1, FALSE);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmime/performance.c | 148 ++++++++++++++++++++------------------- dlls/dmime/tests/dmime.c | 6 +- 2 files changed, 79 insertions(+), 75 deletions(-)
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index e2d070b0fbe..a8c2016802c 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -40,10 +40,9 @@ struct performance IDirectMusicGraph IDirectMusicGraph_iface; IDirectMusicTool IDirectMusicTool_iface; LONG ref; - IDirectMusic8 *dmusic; + IDirectMusic *dmusic; IDirectSound *dsound; IDirectMusicGraph *pToolGraph; - DMUS_AUDIOPARAMS params; BOOL fAutoDownload; char cMasterGrooveLevel; float fMasterTempo; @@ -314,14 +313,74 @@ static ULONG WINAPI performance_Release(IDirectMusicPerformance8 *iface) return ref; }
-/* IDirectMusicPerformanceImpl IDirectMusicPerformance Interface part: */ +static HRESULT performance_init_dsound(struct performance *This, HWND hwnd) +{ + IDirectSound *dsound; + HRESULT hr; + + if (FAILED(hr = DirectSoundCreate(NULL, &dsound, NULL))) return hr; + + if (!hwnd) hwnd = GetForegroundWindow(); + hr = IDirectSound_SetCooperativeLevel(dsound, hwnd, DSSCL_PRIORITY); + + if (SUCCEEDED(hr)) This->dsound = dsound; + else IDirectSound_Release(dsound); + + return hr; +} + +static HRESULT performance_init_dmusic(struct performance *This, IDirectSound *dsound) +{ + IDirectMusic *dmusic; + HRESULT hr; + + if (FAILED(hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusic8, (void **)&dmusic))) + return hr; + + hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL); + + if (SUCCEEDED(hr)) This->dmusic = dmusic; + else IDirectSound_Release(dmusic); + + return hr; +} + static HRESULT WINAPI performance_Init(IDirectMusicPerformance8 *iface, IDirectMusic **dmusic, IDirectSound *dsound, HWND hwnd) { + struct performance *This = impl_from_IDirectMusicPerformance8(iface); + HRESULT hr; + TRACE("(%p, %p, %p, %p)\n", iface, dmusic, dsound, hwnd);
- return IDirectMusicPerformance8_InitAudio(iface, dmusic, dsound ? &dsound : NULL, hwnd, 0, 0, - 0, NULL); + if (This->dmusic) return DMUS_E_ALREADY_INITED; + + if ((This->dsound = dsound)) IDirectMusic8_AddRef(This->dsound); + else if (FAILED(hr = performance_init_dsound(This, hwnd))) return hr; + + if (dmusic && (This->dmusic = *dmusic)) IDirectMusic_AddRef(This->dmusic); + else if (FAILED(hr = performance_init_dmusic(This, This->dsound))) + { + IDirectMusicPerformance_CloseDown(iface); + return hr; + } + + if (FAILED(hr = IDirectMusic_GetMasterClock(This->dmusic, NULL, &This->master_clock)) + || FAILED(hr = IDirectMusicPerformance8_GetTime(iface, &This->init_time, NULL))) + { + IDirectMusicPerformance_CloseDown(iface); + return hr; + } + + PostMessageToProcessMsgThread(This, PROCESSMSG_START); + + if (dmusic && !*dmusic) + { + *dmusic = This->dmusic; + IDirectMusic_AddRef(*dmusic); + } + return S_OK; }
static HRESULT WINAPI performance_PlaySegment(IDirectMusicPerformance8 *iface, IDirectMusicSegment *pSegment, @@ -900,6 +959,7 @@ static HRESULT WINAPI performance_CloseDown(IDirectMusicPerformance8 *iface) IDirectMusic8_Release(This->dmusic); This->dmusic = NULL; } + return S_OK; }
@@ -960,57 +1020,21 @@ static HRESULT WINAPI performance_InitAudio(IDirectMusicPerformance8 *iface, IDi TRACE("(%p, %p, %p, %p, %lx, %lu, %lx, %p)\n", This, dmusic, dsound, hwnd, default_path_type, num_channels, flags, params);
- if (This->dmusic) - return DMUS_E_ALREADY_INITED; - - if (!dmusic || !*dmusic) { - hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic8, - (void **)&This->dmusic); - if (FAILED(hr)) - return hr; - } else { - This->dmusic = (IDirectMusic8 *)*dmusic; - IDirectMusic8_AddRef(This->dmusic); - } - - if (FAILED(hr = IDirectMusic_GetMasterClock(This->dmusic, NULL, &This->master_clock))) - goto error; + if (flags) FIXME("flags parameter not used\n"); + if (params) FIXME("params parameter not used\n");
- if (!dsound || !*dsound) { - hr = DirectSoundCreate8(NULL, (IDirectSound8 **)&This->dsound, NULL); - if (FAILED(hr)) - goto error; - hr = IDirectSound_SetCooperativeLevel(This->dsound, hwnd ? hwnd : GetForegroundWindow(), - DSSCL_PRIORITY); - if (FAILED(hr)) - goto error; - } else { - This->dsound = *dsound; - IDirectSound_AddRef(This->dsound); - } + if (FAILED(hr = IDirectMusicPerformance8_Init(iface, dmusic && *dmusic ? dmusic : NULL, + dsound ? *dsound : NULL, hwnd))) + return hr;
- hr = IDirectMusic8_SetDirectSound(This->dmusic, This->dsound, NULL); - if (FAILED(hr)) - goto error; - - if (!params) { - This->params.dwSize = sizeof(DMUS_AUDIOPARAMS); - This->params.fInitNow = FALSE; - This->params.dwValidData = DMUS_AUDIOPARAMS_FEATURES | DMUS_AUDIOPARAMS_VOICES | - DMUS_AUDIOPARAMS_SAMPLERATE | DMUS_AUDIOPARAMS_DEFAULTSYNTH; - This->params.dwVoices = 64; - This->params.dwSampleRate = 22050; - This->params.dwFeatures = flags; - This->params.clsidDefaultSynth = CLSID_DirectMusicSynthSink; - } else - This->params = *params; - - if (default_path_type) { + if (default_path_type) + { hr = IDirectMusicPerformance8_CreateStandardAudioPath(iface, default_path_type, num_channels, FALSE, &This->pDefaultPath); - if (FAILED(hr)) { - IDirectMusic8_SetDirectSound(This->dmusic, NULL, NULL); - goto error; + if (FAILED(hr)) + { + IDirectMusicPerformance_CloseDown(iface); + return hr; } }
@@ -1023,27 +1047,7 @@ static HRESULT WINAPI performance_InitAudio(IDirectMusicPerformance8 *iface, IDi IDirectMusic_AddRef(*dmusic); }
- if (FAILED(hr = IDirectMusicPerformance8_GetTime(iface, &This->init_time, NULL))) return hr; - - PostMessageToProcessMsgThread(This, PROCESSMSG_START); - return S_OK; - -error: - if (This->master_clock) - { - IReferenceClock_Release(This->master_clock); - This->master_clock = NULL; - } - if (This->dsound) { - IDirectSound_Release(This->dsound); - This->dsound = NULL; - } - if (This->dmusic) { - IDirectMusic8_Release(This->dmusic); - This->dmusic = NULL; - } - return hr; }
static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface, IUnknown *pSource, diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index f016af2f9e6..c1043fe90f3 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -2009,7 +2009,7 @@ static void test_performance_InitAudio(void) hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &dsound, NULL, 0, 64, 0, NULL); ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); ref = get_refcount(dsound); - todo_wine ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); + ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); ref = get_refcount(dmusic); ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); destroy_performance(performance, dmusic, dsound); @@ -2023,7 +2023,7 @@ static void test_performance_InitAudio(void) hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, NULL, NULL, 0, 64, 0, NULL); ok(hr == S_OK, "InitAudio failed: %#lx\n", hr); ref = get_refcount(dsound); - todo_wine ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); + ok(ref == 2, "dsound ref count got %ld expected 2\n", ref); ref = get_refcount(dmusic); ok(ref == 2, "dmusic ref count got %ld expected 2\n", ref); destroy_performance(performance, dmusic, dsound); @@ -2053,7 +2053,7 @@ static void test_performance_InitAudio(void) hr = IDirectMusicPort_SetNumChannelGroups(port, 1); ok(hr == S_OK, "SetNumChannelGroups failed: %#lx\n", hr); hr = IDirectMusicPerformance8_Init(performance, &dmusic, dsound, 0); - todo_wine ok(hr == S_OK, "Init failed: %#lx\n", hr); + ok(hr == S_OK, "Init failed: %#lx\n", hr); destroy_performance(performance, dmusic, dsound);
/* InitAudio with perf channel count not a multiple of 16 rounds up */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmime/performance.c | 28 ++++++++++++++++------------ dlls/dmime/tests/dmime.c | 4 ++-- 2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index a8c2016802c..7b606998616 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -50,6 +50,7 @@ struct performance /* performance channels */ struct wine_rb_tree pchannels;
+ BOOL audio_paths_enabled; IDirectMusicAudioPath *pDefaultPath; HANDLE hNotification; REFERENCE_TIME rtMinimum; @@ -730,8 +731,8 @@ static HRESULT WINAPI performance_AddPort(IDirectMusicPerformance8 *iface, IDire
FIXME("(%p, %p): semi-stub\n", This, port);
- if (!This->dmusic) - return DMUS_E_NOT_INIT; + if (!This->dmusic) return DMUS_E_NOT_INIT; + if (This->audio_paths_enabled) return DMUS_E_AUDIOPATHS_IN_USE;
if (!port) { DMUS_PORTPARAMS params = { @@ -753,11 +754,13 @@ static HRESULT WINAPI performance_AddPort(IDirectMusicPerformance8 *iface, IDire
static HRESULT WINAPI performance_RemovePort(IDirectMusicPerformance8 *iface, IDirectMusicPort *pPort) { - struct performance *This = impl_from_IDirectMusicPerformance8(iface); + struct performance *This = impl_from_IDirectMusicPerformance8(iface);
- FIXME("(%p, %p): stub\n", This, pPort); - IDirectMusicPort_Release (pPort); - return S_OK; + if (This->audio_paths_enabled) return DMUS_E_AUDIOPATHS_IN_USE; + + FIXME("(%p, %p): stub\n", This, pPort); + IDirectMusicPort_Release(pPort); + return S_OK; }
static HRESULT WINAPI performance_AssignPChannelBlock(IDirectMusicPerformance8 *iface, @@ -767,10 +770,9 @@ static HRESULT WINAPI performance_AssignPChannelBlock(IDirectMusicPerformance8 *
FIXME("(%p, %ld, %p, %ld): semi-stub\n", This, block_num, port, group);
- if (!port) - return E_POINTER; - if (block_num > MAXDWORD / 16) - return E_INVALIDARG; + if (!port) return E_POINTER; + if (block_num > MAXDWORD / 16) return E_INVALIDARG; + if (This->audio_paths_enabled) return DMUS_E_AUDIOPATHS_IN_USE;
pchannel_block_set(&This->pchannels, block_num, port, group, FALSE);
@@ -785,8 +787,8 @@ static HRESULT WINAPI performance_AssignPChannel(IDirectMusicPerformance8 *iface
FIXME("(%p)->(%ld, %p, %ld, %ld) semi-stub\n", This, pchannel, port, group, channel);
- if (!port) - return E_POINTER; + if (!port) return E_POINTER; + if (This->audio_paths_enabled) return DMUS_E_AUDIOPATHS_IN_USE;
block = pchannel_block_set(&This->pchannels, pchannel / 16, port, 0, TRUE); if (block) { @@ -959,6 +961,7 @@ static HRESULT WINAPI performance_CloseDown(IDirectMusicPerformance8 *iface) IDirectMusic8_Release(This->dmusic); This->dmusic = NULL; } + This->audio_paths_enabled = FALSE;
return S_OK; } @@ -1027,6 +1030,7 @@ static HRESULT WINAPI performance_InitAudio(IDirectMusicPerformance8 *iface, IDi dsound ? *dsound : NULL, hwnd))) return hr;
+ This->audio_paths_enabled = TRUE; if (default_path_type) { hr = IDirectMusicPerformance8_CreateStandardAudioPath(iface, default_path_type, diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index c1043fe90f3..119bfc74fc5 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -1937,9 +1937,9 @@ static void test_performance_InitAudio(void) ok(hr == S_OK, "PChannelInfo failed, got %#lx\n", hr); ok(port != NULL, "IDirectMusicPort not set\n"); hr = IDirectMusicPerformance8_AssignPChannel(performance, 0, port, 0, 0); - todo_wine ok(hr == DMUS_E_AUDIOPATHS_IN_USE, "AssignPChannel failed (%#lx)\n", hr); + ok(hr == DMUS_E_AUDIOPATHS_IN_USE, "AssignPChannel failed (%#lx)\n", hr); hr = IDirectMusicPerformance8_AssignPChannelBlock(performance, 0, port, 0); - todo_wine ok(hr == DMUS_E_AUDIOPATHS_IN_USE, "AssignPChannelBlock failed (%#lx)\n", hr); + ok(hr == DMUS_E_AUDIOPATHS_IN_USE, "AssignPChannelBlock failed (%#lx)\n", hr); IDirectMusicPort_Release(port);
hr = IDirectMusicPerformance8_GetDefaultAudioPath(performance, &path);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmime/performance.c | 102 ++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 55 deletions(-)
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index 7b606998616..bdb7475370a 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -1096,45 +1096,41 @@ static HRESULT WINAPI performance_ClonePMsg(IDirectMusicPerformance8 *iface, DMU }
static HRESULT WINAPI performance_CreateAudioPath(IDirectMusicPerformance8 *iface, - IUnknown *pSourceConfig, BOOL fActivate, IDirectMusicAudioPath **ppNewPath) + IUnknown *pSourceConfig, BOOL fActivate, IDirectMusicAudioPath **ret_iface) { - struct performance *This = impl_from_IDirectMusicPerformance8(iface); - IDirectMusicAudioPath *pPath; + struct performance *This = impl_from_IDirectMusicPerformance8(iface); + IDirectMusicAudioPath *pPath;
- FIXME("(%p, %p, %d, %p): stub\n", This, pSourceConfig, fActivate, ppNewPath); + FIXME("(%p, %p, %d, %p): stub\n", This, pSourceConfig, fActivate, ret_iface);
- if (NULL == ppNewPath) { - return E_POINTER; - } + if (!ret_iface) return E_POINTER; + if (!This->audio_paths_enabled) return DMUS_E_AUDIOPATH_INACTIVE;
- create_dmaudiopath(&IID_IDirectMusicAudioPath, (void**)&pPath); - set_audiopath_perf_pointer(pPath, iface); + create_dmaudiopath(&IID_IDirectMusicAudioPath, (void **)&pPath); + set_audiopath_perf_pointer(pPath, iface);
- /** TODO */ - - *ppNewPath = pPath; - - return IDirectMusicAudioPath_Activate(*ppNewPath, fActivate); + /** TODO */ + *ret_iface = pPath; + return IDirectMusicAudioPath_Activate(*ret_iface, fActivate); }
static HRESULT WINAPI performance_CreateStandardAudioPath(IDirectMusicPerformance8 *iface, - DWORD dwType, DWORD pchannel_count, BOOL fActivate, IDirectMusicAudioPath **ppNewPath) + DWORD dwType, DWORD pchannel_count, BOOL fActivate, IDirectMusicAudioPath **ret_iface) { - struct performance *This = impl_from_IDirectMusicPerformance8(iface); - IDirectMusicAudioPath *pPath; - DSBUFFERDESC desc; - WAVEFORMATEX format; - DMUS_PORTPARAMS params = {0}; - IDirectSoundBuffer *buffer, *primary_buffer; - HRESULT hr = S_OK; + struct performance *This = impl_from_IDirectMusicPerformance8(iface); + IDirectMusicAudioPath *pPath; + DSBUFFERDESC desc; + WAVEFORMATEX format; + DMUS_PORTPARAMS params = {0}; + IDirectSoundBuffer *buffer, *primary_buffer; + HRESULT hr = S_OK;
- FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, pchannel_count, fActivate, ppNewPath); + FIXME("(%p)->(%ld, %ld, %d, %p): semi-stub\n", This, dwType, pchannel_count, fActivate, ret_iface);
- if (NULL == ppNewPath) { - return E_POINTER; - } + if (!ret_iface) return E_POINTER; + if (!This->audio_paths_enabled) return DMUS_E_AUDIOPATH_INACTIVE;
- *ppNewPath = NULL; + *ret_iface = NULL;
/* Secondary buffer description */ memset(&format, 0, sizeof(format)); @@ -1204,46 +1200,42 @@ static HRESULT WINAPI performance_CreateStandardAudioPath(IDirectMusicPerformanc set_audiopath_dsound_buffer(pPath, buffer); set_audiopath_primary_dsound_buffer(pPath, primary_buffer);
- *ppNewPath = pPath; - - TRACE(" returning IDirectMusicAudioPath interface at %p.\n", *ppNewPath); - - return IDirectMusicAudioPath_Activate(*ppNewPath, fActivate); + *ret_iface = pPath; + TRACE(" returning IDirectMusicAudioPath interface at %p.\n", *ret_iface); + return IDirectMusicAudioPath_Activate(*ret_iface, fActivate); }
-static HRESULT WINAPI performance_SetDefaultAudioPath(IDirectMusicPerformance8 *iface, IDirectMusicAudioPath *pAudioPath) +static HRESULT WINAPI performance_SetDefaultAudioPath(IDirectMusicPerformance8 *iface, IDirectMusicAudioPath *audio_path) { - struct performance *This = impl_from_IDirectMusicPerformance8(iface); + struct performance *This = impl_from_IDirectMusicPerformance8(iface);
- FIXME("(%p, %p): semi-stub\n", This, pAudioPath); + FIXME("(%p, %p): semi-stub\n", This, audio_path);
- if (This->pDefaultPath) { - IDirectMusicAudioPath_Release(This->pDefaultPath); - This->pDefaultPath = NULL; - } - This->pDefaultPath = pAudioPath; - if (This->pDefaultPath) { - IDirectMusicAudioPath_AddRef(This->pDefaultPath); - set_audiopath_perf_pointer(This->pDefaultPath, iface); - } + if (!This->audio_paths_enabled) return DMUS_E_AUDIOPATH_INACTIVE;
- return S_OK; + if (This->pDefaultPath) IDirectMusicAudioPath_Release(This->pDefaultPath); + if ((This->pDefaultPath = audio_path)) + { + IDirectMusicAudioPath_AddRef(This->pDefaultPath); + set_audiopath_perf_pointer(This->pDefaultPath, iface); + } + + return S_OK; }
static HRESULT WINAPI performance_GetDefaultAudioPath(IDirectMusicPerformance8 *iface, - IDirectMusicAudioPath **ppAudioPath) + IDirectMusicAudioPath **ret_iface) { - struct performance *This = impl_from_IDirectMusicPerformance8(iface); + struct performance *This = impl_from_IDirectMusicPerformance8(iface);
- FIXME("(%p, %p): semi-stub (%p)\n", This, ppAudioPath, This->pDefaultPath); + FIXME("(%p, %p): semi-stub (%p)\n", This, ret_iface, This->pDefaultPath);
- if (NULL != This->pDefaultPath) { - *ppAudioPath = This->pDefaultPath; - IDirectMusicAudioPath_AddRef(*ppAudioPath); - } else { - *ppAudioPath = NULL; - } - return S_OK; + if (!ret_iface) return E_POINTER; + if (!This->audio_paths_enabled) return DMUS_E_AUDIOPATH_INACTIVE; + + if ((*ret_iface = This->pDefaultPath)) IDirectMusicAudioPath_AddRef(*ret_iface); + + return S_OK; }
static HRESULT WINAPI performance_GetParamEx(IDirectMusicPerformance8 *iface, REFGUID rguidType, DWORD dwTrackID,
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=138020
Your paranoid android.
=== w7u_el (32 bit report) ===
dmime: dmime.c:2932: Test failed: got dwType 0xb dmime.c:2932: Test failed: got guidNotificationType {08d6be46-2b83-080c-e0bb-6301d0ea0d00} dmime.c:2932: Test failed: got dwNotificationOption 0x38 dmime.c:3000: Test failed: got guidNotificationType {81f75bc5-4e5d-11d2-bcc7-00a0c922e6eb} dmime.c:3000: Test failed: got dwNotificationOption 0x1 dmime.c:3009: Test failed: got guidNotificationType {d2ac2899-b39b-11d1-8704-00600893b1bd} dmime.c:3009: Test failed: got dwNotificationOption 0x2
I've merged the tests with the older tests, moving the performance tests to dmime.c.
My rationale is that there is already a lot of dmusic tests files, with every module, and it makes running tests, locally or on the testbot, for checking things more tedious. Having a separate test source has the same drawbacks and I don't really see the advantages.
This merge request was approved by Michael Stefaniuc.
Test failures are not DMusic related