Signed-off-by: Michael Stefaniuc mstefani@winehq.org --- dlls/dmusic/port.c | 59 ++++++++++---------------------------- dlls/dmusic/tests/dmusic.c | 21 ++++++++++++++ 2 files changed, 36 insertions(+), 44 deletions(-)
diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c index d593d739a9e..8549c62c4b1 100644 --- a/dlls/dmusic/port.c +++ b/dlls/dmusic/port.c @@ -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) -{ - struct synth_port *This = synth_from_IDirectMusicPort(iface); - WAVEFORMATEX format; - FIXME("(%p, %p, %p, %p): stub\n", This, pWaveFormatEx, pdwWaveFormatExSize, pdwBufferSize); - - if (pWaveFormatEx == NULL) - { - if (pdwWaveFormatExSize) - *pdwWaveFormatExSize = sizeof(format); - else - return E_POINTER; - } - else - { - if (pdwWaveFormatExSize == NULL) - return E_POINTER; - - /* 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 (*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 (pdwBufferSize) - *pdwBufferSize = 44100 * 2 * 2; - else - return E_POINTER; - - return S_OK; +static HRESULT WINAPI synth_port_GetFormat(IDirectMusicPort *iface, WAVEFORMATEX *format, + DWORD *fmtsize, DWORD *bufsize) +{ + struct synth_port *This = synth_from_IDirectMusicPort(iface); + HRESULT hr; + + TRACE("(%p, %p, %p, %p)\n", This, format, fmtsize, bufsize); + + if (FAILED(hr = IDirectMusicSynth_GetFormat(This->synth, format, fmtsize))) + return hr; + + if (bufsize) + hr = IDirectMusicSynthSink_GetDesiredBufferSize(This->synth_sink, bufsize); + + return hr; }
static const IDirectMusicPortVtbl synth_port_vtbl = { diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c index d8fc6affd9b..37b517fe0ca 100644 --- a/dlls/dmusic/tests/dmusic.c +++ b/dlls/dmusic/tests/dmusic.c @@ -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); }