Final Fantasy VIII does this, more or less, and needs Init to succeed.
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 | 88 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+)
diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index 1266c5d053b..8a7eeea38cb 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -1809,6 +1809,93 @@ static void test_parsedescriptor(void) } }
+static void test_performance_init(void) +{ + DMUS_PORTPARAMS params = + { + .dwSize = sizeof(params), + .dwValidParams = DMUS_PORTPARAMS_EFFECTS, + .dwEffectFlags = 1, + }; + IDirectMusicPerformance8 *performance; + IDirectSound *dsound, *tmp_dsound; + IDirectMusicPort *port; + IDirectMusic *dmusic; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound, (void **)&dsound); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectSound_Initialize(dsound, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectSound_SetCooperativeLevel(dsound, GetDesktopWindow(), DSSCL_PRIORITY); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = CoCreateInstance(&CLSID_DirectMusic, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusic, (void **)&dmusic); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusic_SetDirectSound(dmusic, dsound, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusic_CreatePort(dmusic, &CLSID_DirectMusicSynth, ¶ms, &port, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPort_Activate(port, TRUE); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPort_SetNumChannelGroups(port, 1); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusicPerformance8, (void **)&performance); + ok(hr == S_OK, "got %#lx\n", hr); + + /* Init with a different dsound succeeds even if port is active already */ + + hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound, (void **)&tmp_dsound); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectSound_Initialize(tmp_dsound, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectSound_SetCooperativeLevel(tmp_dsound, GetDesktopWindow(), DSSCL_PRIORITY); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_Init(performance, &dmusic, tmp_dsound, 0); + todo_wine ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_AddPort(performance, NULL); + todo_wine ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_CloseDown(performance); + ok(hr == S_OK, "got %#lx\n", hr); + IDirectSound_Release(tmp_dsound); + + + /* InitAudio also works fine */ + + tmp_dsound = NULL; + hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &tmp_dsound, NULL, + DMUS_APATH_SHARED_STEREOPLUSREVERB, 0, 0, NULL); + todo_wine ok(hr == S_OK, "got %#lx\n", hr); + ok(tmp_dsound != dsound, "got %p\n", tmp_dsound); + hr = IDirectMusicPerformance8_CloseDown(performance); + ok(hr == S_OK, "got %#lx\n", hr); + if (tmp_dsound) IDirectSound_Release(tmp_dsound); + + + /* Init twice fails */ + + hr = IDirectMusicPerformance8_Init(performance, NULL, NULL, 0); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_Init(performance, NULL, NULL, 0); + ok(hr == DMUS_E_ALREADY_INITED, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_InitAudio(performance, NULL, NULL, NULL, 0, 0, 0, NULL); + ok(hr == DMUS_E_ALREADY_INITED, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_CloseDown(performance); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance8_CloseDown(performance); + ok(hr == S_OK, "got %#lx\n", hr); + + + IDirectMusicPerformance8_Release(performance); + + IDirectMusicPort_Release(port); + IDirectMusic_Release(dmusic); + + IDirectSound_Release(dsound); +} + static void test_performance_tool(void) { IDirectMusicPerformance *performance; @@ -3176,6 +3263,7 @@ START_TEST(dmime) test_segment_param(); test_track(); test_parsedescriptor(); + test_performance_init(); test_performance_tool(); test_performance_graph(); test_performance_time();
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 | 8 +- dlls/dmime/tests/performance.c | 4 +- 3 files changed, 82 insertions(+), 78 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 8a7eeea38cb..9c3f95eef80 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -1854,9 +1854,9 @@ static void test_performance_init(void) hr = IDirectSound_SetCooperativeLevel(tmp_dsound, GetDesktopWindow(), DSSCL_PRIORITY); ok(hr == S_OK, "got %#lx\n", hr); hr = IDirectMusicPerformance8_Init(performance, &dmusic, tmp_dsound, 0); - todo_wine ok(hr == S_OK, "got %#lx\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); hr = IDirectMusicPerformance8_AddPort(performance, NULL); - todo_wine ok(hr == S_OK, "got %#lx\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); hr = IDirectMusicPerformance8_CloseDown(performance); ok(hr == S_OK, "got %#lx\n", hr); IDirectSound_Release(tmp_dsound); @@ -1867,11 +1867,11 @@ static void test_performance_init(void) tmp_dsound = NULL; hr = IDirectMusicPerformance8_InitAudio(performance, &dmusic, &tmp_dsound, NULL, DMUS_APATH_SHARED_STEREOPLUSREVERB, 0, 0, NULL); - todo_wine ok(hr == S_OK, "got %#lx\n", hr); + ok(hr == S_OK, "got %#lx\n", hr); ok(tmp_dsound != dsound, "got %p\n", tmp_dsound); hr = IDirectMusicPerformance8_CloseDown(performance); ok(hr == S_OK, "got %#lx\n", hr); - if (tmp_dsound) IDirectSound_Release(tmp_dsound); + IDirectSound_Release(tmp_dsound);
/* Init twice fails */ diff --git a/dlls/dmime/tests/performance.c b/dlls/dmime/tests/performance.c index 5cb91a78387..67ceef15d90 100644 --- a/dlls/dmime/tests/performance.c +++ b/dlls/dmime/tests/performance.c @@ -184,7 +184,7 @@ static HRESULT test_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); @@ -198,7 +198,7 @@ static HRESULT test_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);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmime/performance.c | 28 ++++++++++++++++------------ dlls/dmime/tests/performance.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/performance.c b/dlls/dmime/tests/performance.c index 67ceef15d90..0e93ddc82b4 100644 --- a/dlls/dmime/tests/performance.c +++ b/dlls/dmime/tests/performance.c @@ -112,9 +112,9 @@ static HRESULT test_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=137841
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
dmime: dmime.c:2545: Test failed: got guidNotificationType {547b7537-5265-0802-0000-0000d0ea0d00}
Two comments to the first patch:
- We already have Init / InitAudio tests in test_InitAudio() from tests/performance.c. Having them in two different files is unexpected. - The comments in the test confused me and I had to read the code to understand them * First part of the test just retests that after a manually initialized dmusic the performance Init() still succeeds (fixed some app crashes there before). The addition to test_InitAudio() is that a port is created and activated. * The other main take away is that the performance Init() or InitAudio() succeeds again after a CloseDown(). But the comment makes it sound as Init() would succeed if we'd just use a different dsound.
For "dmime: Initialize performance in Init rather than InitAudio.": I've had to read my old commits there as I had centralized that in InitAudio(). Duplicated code and InitAudio() calling Init() the wrong way. Anyway main motivation to do it this way was the usual older method calls new method approach, e.g. Foo() ==> FooEx().\ But later I've learned that that switches the performance to a different operation mode.
Anyway, I'm not opposed to the patch, only concern I had in the back of my mind is if Init() and InitAudio() aren't too different for one to call the other.
I believe Init is a lower-level operation mode, and they added the audio paths later to abstract some details and avoid having to manually manage ports. This means that the newer method doesn't provide more flexibility here, but instead, less.
When audio paths are used, it is still possible to use PChannelInfo to query performance channels / port association. Hence, my understanding is that InitAudio still uses the performance the old way (and like it is implemented), but it handles the port allocation for the audio paths, and forbid the caller from messing with them.
With this in mind, I believe that InitAudio should call Init, and then adds some logic on top, not the other way around.
I'll have a look at the comments, see what you mean, and hopefully clarify them.
On Wed Sep 27 20:15:02 2023 +0000, Rémi Bernon wrote:
I believe Init is a lower-level operation mode, and they added the audio paths later to abstract some details and avoid having to manually manage ports. This means that the newer method doesn't provide more flexibility here, but instead, less. When audio paths are used, it is still possible to use PChannelInfo to query performance channels / port association. Hence, my understanding is that InitAudio still uses the performance the old way (and like it is implemented), but it handles the port allocation for the audio paths, and forbid the caller from messing with them. With this in mind, I believe that InitAudio should call Init, and then adds some logic on top, not the other way around. I'll have a look at the comments, see what you mean, and hopefully clarify them.
Yes and no. It isn't just an abstraction layer on top of the ports.\ They have extended IDirectMusicSynth to support the AudioPaths. So that could do more than what the old performance could achieve.\ Only issue is that the information is actively erased from the public documentation.\ https://learn.microsoft.com/en-us/windows/win32/api/dmusics/nn-dmusics-idire... \ I remember to have seen AudioPath explicitly mentioned on the Synth8 methods.
Interesting would be to test if one has to pass DMUS_PORT_FEATURE_AUDIOPATH to IDirectMusic_CreatePort() for the port to support AudioPaths.
Anyway all that shouldn't block InitAudio() using Init(). The differences can be then handled by the presence of audio_paths_enabled boolean.