Commit 16aee076 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

qcap/audiorecord: Implement IAMStreamConfig::SetFormat() and IAMStreamConfig::GetFormat().

Needed by the Microsoft Silverlight configuration tool. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=36230
parent 32cb8bd1
......@@ -42,6 +42,8 @@ struct audio_record
FILTER_STATE state;
CONDITION_VARIABLE state_cv;
CRITICAL_SECTION state_cs;
AM_MEDIA_TYPE format;
};
static struct audio_record *impl_from_strmbase_filter(struct strmbase_filter *filter)
......@@ -213,15 +215,52 @@ static ULONG WINAPI stream_config_Release(IAMStreamConfig *iface)
static HRESULT WINAPI stream_config_SetFormat(IAMStreamConfig *iface, AM_MEDIA_TYPE *mt)
{
FIXME("iface %p, mt %p, stub!\n", iface, mt);
struct audio_record *filter = impl_from_IAMStreamConfig(iface);
HRESULT hr;
TRACE("iface %p, mt %p.\n", iface, mt);
strmbase_dump_media_type(mt);
return E_NOTIMPL;
if (!mt)
return E_POINTER;
EnterCriticalSection(&filter->filter.filter_cs);
if ((hr = CopyMediaType(&filter->format, mt)))
{
LeaveCriticalSection(&filter->filter.filter_cs);
return hr;
}
LeaveCriticalSection(&filter->filter.filter_cs);
return S_OK;
}
static HRESULT WINAPI stream_config_GetFormat(IAMStreamConfig *iface, AM_MEDIA_TYPE **mt)
static HRESULT WINAPI stream_config_GetFormat(IAMStreamConfig *iface, AM_MEDIA_TYPE **ret_mt)
{
FIXME("iface %p, mt %p, stub!\n", iface, mt);
return E_NOTIMPL;
struct audio_record *filter = impl_from_IAMStreamConfig(iface);
AM_MEDIA_TYPE *mt;
HRESULT hr;
TRACE("iface %p, mt %p.\n", iface, ret_mt);
if (!(mt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))))
return E_OUTOFMEMORY;
EnterCriticalSection(&filter->filter.filter_cs);
if ((hr = CopyMediaType(mt, &filter->format)))
{
LeaveCriticalSection(&filter->filter.filter_cs);
CoTaskMemFree(mt);
return hr;
}
LeaveCriticalSection(&filter->filter.filter_cs);
*ret_mt = mt;
return S_OK;
}
static HRESULT WINAPI stream_config_GetNumberOfCapabilities(IAMStreamConfig *iface,
......@@ -306,6 +345,7 @@ static void audio_record_destroy(struct strmbase_filter *iface)
filter->state_cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&filter->state_cs);
CloseHandle(filter->event);
FreeMediaType(&filter->format);
strmbase_source_cleanup(&filter->source);
strmbase_filter_cleanup(&filter->filter);
free(filter);
......@@ -596,6 +636,7 @@ static const IPersistPropertyBagVtbl PersistPropertyBagVtbl =
HRESULT audio_record_create(IUnknown *outer, IUnknown **out)
{
struct audio_record *object;
HRESULT hr;
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
......@@ -606,6 +647,13 @@ HRESULT audio_record_create(IUnknown *outer, IUnknown **out)
return E_OUTOFMEMORY;
}
if ((hr = fill_media_type(0, &object->format)))
{
CloseHandle(object->event);
free(object);
return hr;
}
object->IPersistPropertyBag_iface.lpVtbl = &PersistPropertyBagVtbl;
strmbase_filter_init(&object->filter, outer, &CLSID_AudioRecord, &filter_ops);
......
......@@ -1009,26 +1009,21 @@ static void test_stream_config(IBaseFilter *filter)
IEnumMediaTypes_Release(enummt);
hr = IAMStreamConfig_GetFormat(config, &mt);
todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
if (hr == S_OK)
{
hr = IAMStreamConfig_GetStreamCaps(config, 0, &mt2, (BYTE *)&caps);
todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
if (hr == S_OK)
{
ok(compare_media_types(mt, mt2), "Media types didn't match.\n");
DeleteMediaType(mt2);
}
hr = IAMStreamConfig_SetFormat(config, NULL);
todo_wine ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
mt->majortype = MEDIATYPE_Video;
hr = IAMStreamConfig_SetFormat(config, mt);
todo_wine ok(hr == VFW_E_INVALIDMEDIATYPE, "Got hr %#lx.\n", hr);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
DeleteMediaType(mt);
}
hr = IAMStreamConfig_GetStreamCaps(config, 0, &mt2, (BYTE *)&caps);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
ok(compare_media_types(mt, mt2), "Media types didn't match.\n");
DeleteMediaType(mt2);
hr = IAMStreamConfig_SetFormat(config, NULL);
ok(hr == E_POINTER, "Got hr %#lx.\n", hr);
mt->majortype = MEDIATYPE_Video;
hr = IAMStreamConfig_SetFormat(config, mt);
todo_wine ok(hr == VFW_E_INVALIDMEDIATYPE, "Got hr %#lx.\n", hr);
DeleteMediaType(mt);
for (i = 0; i < count; ++i)
{
......@@ -1038,15 +1033,12 @@ static void test_stream_config(IBaseFilter *filter)
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IAMStreamConfig_SetFormat(config, mt);
todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IAMStreamConfig_GetFormat(config, &mt2);
todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
if (hr == S_OK)
{
ok(compare_media_types(mt, mt2), "Media types didn't match.\n");
DeleteMediaType(mt2);
}
ok(hr == S_OK, "Got hr %#lx.\n", hr);
ok(compare_media_types(mt, mt2), "Media types didn't match.\n");
DeleteMediaType(mt2);
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