dmusic: Forward GetFormat() to the corresponding synth & sink methods.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2022-02-22 00:49:59 +01:00 committed by Alexandre Julliard
parent ec69d69f2a
commit 5815ba4548
2 changed files with 31 additions and 39 deletions

View File

@ -510,50 +510,21 @@ static HRESULT WINAPI synth_port_SetDirectSound(IDirectMusicPort *iface, IDirect
return S_OK;
}
static HRESULT WINAPI synth_port_GetFormat(IDirectMusicPort *iface, WAVEFORMATEX *pWaveFormatEx,
DWORD *pdwWaveFormatExSize, DWORD *pdwBufferSize)
static HRESULT WINAPI synth_port_GetFormat(IDirectMusicPort *iface, WAVEFORMATEX *format,
DWORD *fmtsize, DWORD *bufsize)
{
struct synth_port *This = synth_from_IDirectMusicPort(iface);
WAVEFORMATEX format;
FIXME("(%p, %p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSize, pdwBufferSize);
struct synth_port *This = synth_from_IDirectMusicPort(iface);
HRESULT hr;
if (pWaveFormatEx == NULL)
{
if (pdwWaveFormatExSize)
*pdwWaveFormatExSize = sizeof(format);
else
return E_POINTER;
}
else
{
if (pdwWaveFormatExSize == NULL)
return E_POINTER;
TRACE("(%p, %p, %p, %p)\n", This, format, fmtsize, bufsize);
/* Just fill this in with something that will not crash Direct Sound for now. */
/* It won't be used anyway until Performances are completed */
format.wFormatTag = WAVE_FORMAT_PCM;
format.nChannels = 2; /* This->params.dwAudioChannels; */
format.nSamplesPerSec = 44100; /* This->params.dwSampleRate; */
format.wBitsPerSample = 16; /* FIXME: check this */
format.nBlockAlign = (format.wBitsPerSample * format.nChannels) / 8;
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
format.cbSize = 0;
if (FAILED(hr = IDirectMusicSynth_GetFormat(This->synth, format, fmtsize)))
return hr;
if (*pdwWaveFormatExSize >= sizeof(format))
{
CopyMemory(pWaveFormatEx, &format, min(sizeof(format), *pdwWaveFormatExSize));
*pdwWaveFormatExSize = sizeof(format); /* FIXME check if this is set */
}
else
return E_POINTER; /* FIXME find right error */
}
if (bufsize)
hr = IDirectMusicSynthSink_GetDesiredBufferSize(This->synth_sink, bufsize);
if (pdwBufferSize)
*pdwBufferSize = 44100 * 2 * 2;
else
return E_POINTER;
return S_OK;
return hr;
}
static const IDirectMusicPortVtbl synth_port_vtbl = {

View File

@ -877,6 +877,9 @@ static void test_synthport(void)
IDirectMusicPort *port;
DMUS_BUFFERDESC desc;
DMUS_PORTCAPS caps;
WAVEFORMATEX fmt;
DWORD fmtsize, bufsize;
HRESULT hr;
port = create_synth_port(&dmusic);
@ -922,6 +925,24 @@ static void test_synthport(void)
ok(caps.dwEffectFlags == DMUS_EFFECT_REVERB, "Unexpected dwEffectFlags returned: %#lx\n", caps.dwEffectFlags);
trace("Port wszDescription: %s\n", wine_dbgstr_w(caps.wszDescription));
/* GetFormat */
hr = IDirectMusicPort_GetFormat(port, NULL, NULL, NULL);
ok(hr == E_POINTER, "GetFormat failed: %#lx\n", hr);
hr = IDirectMusicPort_GetFormat(port, NULL, &fmtsize, NULL);
ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
ok(fmtsize == sizeof(fmt), "format size; %ld\n", fmtsize);
fmtsize = 0;
hr = IDirectMusicPort_GetFormat(port, &fmt, &fmtsize, NULL);
ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
ok(fmtsize == sizeof(fmt), "format size; %ld\n", fmtsize);
hr = IDirectMusicPort_GetFormat(port, NULL, NULL, &bufsize);
ok(hr == E_POINTER, "GetFormat failed: %#lx\n", hr);
hr = IDirectMusicPort_GetFormat(port, NULL, &fmtsize, &bufsize);
ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
hr = IDirectMusicPort_GetFormat(port, &fmt, &fmtsize, &bufsize);
ok(hr == S_OK, "GetFormat failed: %#lx\n", hr);
ok(bufsize == fmt.nSamplesPerSec * fmt.nChannels * 4, "buffer size: %ld\n", bufsize);
IDirectMusicPort_Release(port);
IDirectMusic_Release(dmusic);
}