Commit aaad7959 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

mmdevapi: Implement SAC_IsAudioObjectFormatSupported().

parent ba50573f
...@@ -49,6 +49,36 @@ static UINT32 AudioObjectType_to_index(AudioObjectType type) ...@@ -49,6 +49,36 @@ static UINT32 AudioObjectType_to_index(AudioObjectType type)
return o - 2; return o - 2;
} }
static const char *debugstr_fmtex(const WAVEFORMATEX *fmt)
{
static char buf[2048];
if (!fmt)
{
strcpy(buf, "(null)");
}
else if(fmt->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
{
const WAVEFORMATEXTENSIBLE *fmtex = (const WAVEFORMATEXTENSIBLE *)fmt;
snprintf(buf, sizeof(buf), "tag: 0x%x (%s), ch: %u (mask: 0x%lx), rate: %lu, depth: %u",
fmt->wFormatTag, debugstr_guid(&fmtex->SubFormat),
fmt->nChannels, fmtex->dwChannelMask, fmt->nSamplesPerSec,
fmt->wBitsPerSample);
}
else
{
snprintf(buf, sizeof(buf), "tag: 0x%x, ch: %u, rate: %lu, depth: %u",
fmt->wFormatTag, fmt->nChannels, fmt->nSamplesPerSec,
fmt->wBitsPerSample);
}
return buf;
}
static BOOL formats_equal(const WAVEFORMATEX *fmt1, const WAVEFORMATEX *fmt2)
{
return !memcmp(fmt1, fmt2, sizeof(*fmt1)) && !memcmp(fmt1 + 1, fmt2 + 1, fmt1->cbSize);
}
typedef struct SpatialAudioImpl SpatialAudioImpl; typedef struct SpatialAudioImpl SpatialAudioImpl;
typedef struct SpatialAudioStreamImpl SpatialAudioStreamImpl; typedef struct SpatialAudioStreamImpl SpatialAudioStreamImpl;
typedef struct SpatialAudioObjectImpl SpatialAudioObjectImpl; typedef struct SpatialAudioObjectImpl SpatialAudioObjectImpl;
...@@ -610,9 +640,20 @@ static HRESULT WINAPI SAC_GetMaxFrameCount(ISpatialAudioClient *iface, ...@@ -610,9 +640,20 @@ static HRESULT WINAPI SAC_GetMaxFrameCount(ISpatialAudioClient *iface,
static HRESULT WINAPI SAC_IsAudioObjectFormatSupported(ISpatialAudioClient *iface, static HRESULT WINAPI SAC_IsAudioObjectFormatSupported(ISpatialAudioClient *iface,
const WAVEFORMATEX *format) const WAVEFORMATEX *format)
{ {
SpatialAudioImpl *This = impl_from_ISpatialAudioClient(iface); SpatialAudioImpl *sac = impl_from_ISpatialAudioClient(iface);
FIXME("(%p)->(%p)\n", This, format);
return E_NOTIMPL; TRACE("sac %p, format %s.\n", sac, debugstr_fmtex(format));
if (!format)
return E_POINTER;
if (!formats_equal(&sac->object_fmtex.Format, format))
{
FIXME("Reporting format %s as unsupported.\n", debugstr_fmtex(format));
return E_INVALIDARG;
}
return S_OK;
} }
static HRESULT WINAPI SAC_IsSpatialAudioStreamAvailable(ISpatialAudioClient *iface, static HRESULT WINAPI SAC_IsSpatialAudioStreamAvailable(ISpatialAudioClient *iface,
...@@ -630,23 +671,6 @@ static WAVEFORMATEX *clone_fmtex(const WAVEFORMATEX *src) ...@@ -630,23 +671,6 @@ static WAVEFORMATEX *clone_fmtex(const WAVEFORMATEX *src)
return r; return r;
} }
static const char *debugstr_fmtex(const WAVEFORMATEX *fmt)
{
static char buf[2048];
if(fmt->wFormatTag == WAVE_FORMAT_EXTENSIBLE){
const WAVEFORMATEXTENSIBLE *fmtex = (const WAVEFORMATEXTENSIBLE *)fmt;
snprintf(buf, sizeof(buf), "tag: 0x%x (%s), ch: %u (mask: 0x%lx), rate: %lu, depth: %u",
fmt->wFormatTag, debugstr_guid(&fmtex->SubFormat),
fmt->nChannels, fmtex->dwChannelMask, fmt->nSamplesPerSec,
fmt->wBitsPerSample);
}else{
snprintf(buf, sizeof(buf), "tag: 0x%x, ch: %u, rate: %lu, depth: %u",
fmt->wFormatTag, fmt->nChannels, fmt->nSamplesPerSec,
fmt->wBitsPerSample);
}
return buf;
}
static void static_mask_to_channels(AudioObjectType static_mask, WORD *count, DWORD *mask, UINT32 *map) static void static_mask_to_channels(AudioObjectType static_mask, WORD *count, DWORD *mask, UINT32 *map)
{ {
UINT32 out_chan = 0, map_idx = 0; UINT32 out_chan = 0, map_idx = 0;
...@@ -776,8 +800,7 @@ static HRESULT WINAPI SAC_ActivateSpatialAudioStream(ISpatialAudioClient *iface, ...@@ -776,8 +800,7 @@ static HRESULT WINAPI SAC_ActivateSpatialAudioStream(ISpatialAudioClient *iface,
return E_INVALIDARG; return E_INVALIDARG;
} }
if(!params->ObjectFormat || if(!(params->ObjectFormat && formats_equal(params->ObjectFormat, &This->object_fmtex.Format))) {
memcmp(params->ObjectFormat, &This->object_fmtex.Format, sizeof(*params->ObjectFormat) + params->ObjectFormat->cbSize)){
*stream = NULL; *stream = NULL;
return AUDCLNT_E_UNSUPPORTED_FORMAT; return AUDCLNT_E_UNSUPPORTED_FORMAT;
} }
......
...@@ -64,6 +64,27 @@ static void test_formats(void) ...@@ -64,6 +64,27 @@ static void test_formats(void)
ok(fmt->nAvgBytesPerSec == 192000, "Wrong avg bytes per sec, expected 192000 got %lu\n", fmt->nAvgBytesPerSec); ok(fmt->nAvgBytesPerSec == 192000, "Wrong avg bytes per sec, expected 192000 got %lu\n", fmt->nAvgBytesPerSec);
ok(fmt->cbSize == 0, "Wrong cbSize for simple format, expected 0, got %hu\n", fmt->cbSize); ok(fmt->cbSize == 0, "Wrong cbSize for simple format, expected 0, got %hu\n", fmt->cbSize);
hr = ISpatialAudioClient_IsAudioObjectFormatSupported(sac, NULL);
ok(hr == E_POINTER, "Got %#lx.\n", hr);
memcpy(&format, fmt, sizeof(format));
hr = ISpatialAudioClient_IsAudioObjectFormatSupported(sac, &format);
ok(hr == S_OK, "Got %#lx.\n", hr);
format.nBlockAlign *= 2;
hr = ISpatialAudioClient_IsAudioObjectFormatSupported(sac, &format);
todo_wine ok(hr == S_OK, "Got %#lx.\n", hr);
memcpy(&format, fmt, sizeof(format));
format.wBitsPerSample *= 2;
hr = ISpatialAudioClient_IsAudioObjectFormatSupported(sac, &format);
ok(hr == E_INVALIDARG, "Got %#lx.\n", hr);
memcpy(&format, fmt, sizeof(format));
format.nChannels = 2;
hr = ISpatialAudioClient_IsAudioObjectFormatSupported(sac, &format);
ok(hr == E_INVALIDARG, "Got %#lx.\n", hr);
memcpy(&format, fmt, sizeof(format)); memcpy(&format, fmt, sizeof(format));
IAudioFormatEnumerator_Release(afe); IAudioFormatEnumerator_Release(afe);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment