Commit f03ae651 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

qcap/audiorecord: Enumerate the currently set media type first.

parent b0f7f843
...@@ -114,13 +114,17 @@ audio_formats[] = ...@@ -114,13 +114,17 @@ audio_formats[] =
{96000, 16, 1}, {96000, 16, 1},
}; };
static HRESULT fill_media_type(unsigned int index, AM_MEDIA_TYPE *mt) static HRESULT fill_media_type(struct audio_record *filter, unsigned int index, AM_MEDIA_TYPE *mt)
{ {
WAVEFORMATEX *format; WAVEFORMATEX *format;
if (index >= ARRAY_SIZE(audio_formats)) if (index >= 1 + ARRAY_SIZE(audio_formats))
return VFW_S_NO_MORE_ITEMS; return VFW_S_NO_MORE_ITEMS;
if (!index)
return CopyMediaType(mt, &filter->format);
--index;
if (!(format = CoTaskMemAlloc(sizeof(*format)))) if (!(format = CoTaskMemAlloc(sizeof(*format))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -147,7 +151,9 @@ static HRESULT fill_media_type(unsigned int index, AM_MEDIA_TYPE *mt) ...@@ -147,7 +151,9 @@ static HRESULT fill_media_type(unsigned int index, AM_MEDIA_TYPE *mt)
static HRESULT audio_record_source_get_media_type(struct strmbase_pin *iface, static HRESULT audio_record_source_get_media_type(struct strmbase_pin *iface,
unsigned int index, AM_MEDIA_TYPE *mt) unsigned int index, AM_MEDIA_TYPE *mt)
{ {
return fill_media_type(index, mt); struct audio_record *filter = impl_from_strmbase_filter(iface->filter);
return fill_media_type(filter, index, mt);
} }
static HRESULT WINAPI audio_record_source_DecideBufferSize(struct strmbase_source *iface, static HRESULT WINAPI audio_record_source_DecideBufferSize(struct strmbase_source *iface,
...@@ -283,7 +289,7 @@ static HRESULT WINAPI stream_config_GetNumberOfCapabilities(IAMStreamConfig *ifa ...@@ -283,7 +289,7 @@ static HRESULT WINAPI stream_config_GetNumberOfCapabilities(IAMStreamConfig *ifa
TRACE("filter %p, count %p, size %p.\n", filter, count, size); TRACE("filter %p, count %p, size %p.\n", filter, count, size);
*count = ARRAY_SIZE(audio_formats); *count = 1 + ARRAY_SIZE(audio_formats);
*size = sizeof(AUDIO_STREAM_CONFIG_CAPS); *size = sizeof(AUDIO_STREAM_CONFIG_CAPS);
return S_OK; return S_OK;
} }
...@@ -298,13 +304,13 @@ static HRESULT WINAPI stream_config_GetStreamCaps(IAMStreamConfig *iface, ...@@ -298,13 +304,13 @@ static HRESULT WINAPI stream_config_GetStreamCaps(IAMStreamConfig *iface,
TRACE("filter %p, index %d, ret_mt %p, caps %p.\n", filter, index, ret_mt, caps); TRACE("filter %p, index %d, ret_mt %p, caps %p.\n", filter, index, ret_mt, caps);
if (index >= ARRAY_SIZE(audio_formats)) if (index >= 1 + ARRAY_SIZE(audio_formats))
return S_FALSE; return S_FALSE;
if (!(mt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)))) if (!(mt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
if ((hr = fill_media_type(index, mt)) != S_OK) if ((hr = fill_media_type(filter, index, mt)) != S_OK)
{ {
CoTaskMemFree(mt); CoTaskMemFree(mt);
return hr; return hr;
...@@ -795,7 +801,7 @@ HRESULT audio_record_create(IUnknown *outer, IUnknown **out) ...@@ -795,7 +801,7 @@ HRESULT audio_record_create(IUnknown *outer, IUnknown **out)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
if ((hr = fill_media_type(0, &object->format))) if ((hr = fill_media_type(object, 1, &object->format)))
{ {
CloseHandle(object->event); CloseHandle(object->event);
free(object); free(object);
......
...@@ -1122,13 +1122,13 @@ static void test_stream_config(IBaseFilter *filter) ...@@ -1122,13 +1122,13 @@ static void test_stream_config(IBaseFilter *filter)
IPin_EnumMediaTypes(source, &enummt); IPin_EnumMediaTypes(source, &enummt);
hr = IEnumMediaTypes_Next(enummt, 1, &mt2, NULL); hr = IEnumMediaTypes_Next(enummt, 1, &mt2, NULL);
ok(hr == S_OK, "Got hr %#lx.\n", hr); ok(hr == S_OK, "Got hr %#lx.\n", hr);
todo_wine_if (i > 0) ok(compare_media_types(mt, mt2), "Media types didn't match.\n"); ok(compare_media_types(mt, mt2), "Media types didn't match.\n");
DeleteMediaType(mt2); DeleteMediaType(mt2);
IEnumMediaTypes_Release(enummt); IEnumMediaTypes_Release(enummt);
hr = IAMStreamConfig_GetStreamCaps(config, 0, &mt2, (BYTE *)&caps); hr = IAMStreamConfig_GetStreamCaps(config, 0, &mt2, (BYTE *)&caps);
ok(hr == S_OK, "Got hr %#lx.\n", hr); ok(hr == S_OK, "Got hr %#lx.\n", hr);
todo_wine_if (i > 0) ok(compare_media_types(mt, mt2), "Media types didn't match.\n"); ok(compare_media_types(mt, mt2), "Media types didn't match.\n");
DeleteMediaType(mt2); DeleteMediaType(mt2);
DeleteMediaType(mt); DeleteMediaType(mt);
......
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