amstream: Create the stream filter when the multimedia stream is created.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-08-28 20:24:33 -05:00 committed by Alexandre Julliard
parent c8b94b6300
commit 3256484a14
2 changed files with 21 additions and 36 deletions

View File

@ -36,7 +36,7 @@ typedef struct {
IGraphBuilder* pFilterGraph;
IMediaSeeking* media_seeking;
IMediaControl* media_control;
IMediaStreamFilter *media_stream_filter;
IMediaStreamFilter *filter;
IPin* ipin;
ULONG nbStreams;
IAMMediaStream **pStreams;
@ -54,6 +54,7 @@ static const struct IAMMultiMediaStreamVtbl AM_Vtbl;
HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj)
{
IAMMultiMediaStreamImpl *object;
HRESULT hr;
TRACE("(%p,%p)\n", pUnkOuter, ppObj);
@ -67,6 +68,14 @@ HRESULT AM_create(IUnknown *pUnkOuter, LPVOID *ppObj)
object->IAMMultiMediaStream_iface.lpVtbl = &AM_Vtbl;
object->ref = 1;
if (FAILED(hr = CoCreateInstance(&CLSID_MediaStreamFilter, NULL,
CLSCTX_INPROC_SERVER, &IID_IMediaStreamFilter, (void **)&object->filter)))
{
ERR("Failed to create stream filter, hr %#x.\n", hr);
heap_free(object);
return hr;
}
*ppObj = &object->IAMMultiMediaStream_iface;
return S_OK;
@ -117,8 +126,7 @@ static ULONG WINAPI IAMMultiMediaStreamImpl_Release(IAMMultiMediaStream* iface)
CoTaskMemFree(This->pStreams);
if (This->ipin)
IPin_Release(This->ipin);
if (This->media_stream_filter)
IMediaStreamFilter_Release(This->media_stream_filter);
IMediaStreamFilter_Release(This->filter);
if (This->media_seeking)
IMediaSeeking_Release(This->media_seeking);
if (This->media_control)
@ -258,9 +266,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream* if
if (SUCCEEDED(hr))
hr = IGraphBuilder_QueryInterface(This->pFilterGraph, &IID_IMediaControl, (void**)&This->media_control);
if (SUCCEEDED(hr))
hr = CoCreateInstance(&CLSID_MediaStreamFilter, NULL, CLSCTX_INPROC_SERVER, &IID_IMediaStreamFilter, (void**)&This->media_stream_filter);
if (SUCCEEDED(hr))
hr = IGraphBuilder_AddFilter(This->pFilterGraph, (IBaseFilter*)This->media_stream_filter, filternameW);
hr = IGraphBuilder_AddFilter(This->pFilterGraph, (IBaseFilter*)This->filter, filternameW);
if (SUCCEEDED(hr))
{
IMediaEventEx* media_event = NULL;
@ -276,9 +282,6 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_Initialize(IAMMultiMediaStream* if
if (FAILED(hr))
{
if (This->media_stream_filter)
IMediaStreamFilter_Release(This->media_stream_filter);
This->media_stream_filter = NULL;
if (This->media_seeking)
IMediaSeeking_Release(This->media_seeking);
This->media_seeking = NULL;
@ -310,18 +313,16 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilterGraph(IAMMultiMediaStream
return S_OK;
}
static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilter(IAMMultiMediaStream* iface, IMediaStreamFilter** ppFilter)
static HRESULT WINAPI IAMMultiMediaStreamImpl_GetFilter(IAMMultiMediaStream *iface, IMediaStreamFilter **filter)
{
IAMMultiMediaStreamImpl *This = impl_from_IAMMultiMediaStream(iface);
IAMMultiMediaStreamImpl *mmstream = impl_from_IAMMultiMediaStream(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, ppFilter);
TRACE("mmstream %p, filter %p.\n", mmstream, filter);
if (!ppFilter)
if (!filter)
return E_POINTER;
*ppFilter = This->media_stream_filter;
if (*ppFilter)
IMediaStreamFilter_AddRef(*ppFilter);
IMediaStreamFilter_AddRef(*filter = mmstream->filter);
return S_OK;
}
@ -388,7 +389,7 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream
if (SUCCEEDED(hr))
{
/* Add stream to the media stream filter */
IMediaStreamFilter_AddMediaStream(This->media_stream_filter, pStream);
IMediaStreamFilter_AddMediaStream(This->filter, pStream);
}
return hr;

View File

@ -130,10 +130,6 @@ static void test_interfaces(void)
HRESULT hr;
ULONG ref;
/* FIXME: This call should not be necessary. */
hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
check_interface(mmstream, &IID_IAMMultiMediaStream, TRUE);
check_interface(mmstream, &IID_IMultiMediaStream, TRUE);
check_interface(mmstream, &IID_IUnknown, TRUE);
@ -636,15 +632,11 @@ static void test_enum_pins(void)
ULONG ref, count;
HRESULT hr;
/* FIXME: This call should not be necessary. */
hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_GetFilter(mmstream, &filter);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ref = get_refcount(filter);
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref);
hr = IMediaStreamFilter_EnumPins(filter, NULL);
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
@ -652,7 +644,7 @@ static void test_enum_pins(void)
hr = IMediaStreamFilter_EnumPins(filter, &enum1);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ref = get_refcount(filter);
ok(ref == 3, "Got unexpected refcount %d.\n", ref);
todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref);
ref = get_refcount(enum1);
ok(ref == 1, "Got unexpected refcount %d.\n", ref);
@ -771,10 +763,6 @@ static void test_find_pin(void)
HRESULT hr;
ULONG ref;
/* FIXME: This call should not be necessary. */
hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_GetFilter(mmstream, &filter);
ok(hr == S_OK, "Got hr %#x.\n", hr);
@ -809,10 +797,6 @@ static void test_pin_info(void)
WCHAR *id;
IPin *pin;
/* FIXME: This call should not be necessary. */
hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_GetFilter(mmstream, &filter);
ok(hr == S_OK, "Got hr %#x.\n", hr);