strmbase: Access our own media types directly in source_Connect().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-02-05 19:50:05 -06:00 committed by Alexandre Julliard
parent 1d1ca2f883
commit e14c5430cc
1 changed files with 15 additions and 19 deletions

View File

@ -431,8 +431,9 @@ static inline struct strmbase_source *impl_source_from_IPin( IPin *iface )
static HRESULT WINAPI source_Connect(IPin *iface, IPin *peer, const AM_MEDIA_TYPE *mt) static HRESULT WINAPI source_Connect(IPin *iface, IPin *peer, const AM_MEDIA_TYPE *mt)
{ {
struct strmbase_source *pin = impl_source_from_IPin(iface); struct strmbase_source *pin = impl_source_from_IPin(iface);
AM_MEDIA_TYPE *candidate; AM_MEDIA_TYPE candidate, *candidate_ptr;
IEnumMediaTypes *enummt; IEnumMediaTypes *enummt;
unsigned int i;
ULONG count; ULONG count;
HRESULT hr; HRESULT hr;
@ -464,37 +465,32 @@ static HRESULT WINAPI source_Connect(IPin *iface, IPin *peer, const AM_MEDIA_TYP
return hr; return hr;
} }
if (SUCCEEDED(IPin_EnumMediaTypes(iface, &enummt))) for (i = 0; pin->pFuncsTable->base.pin_get_media_type(&pin->pin, i, &candidate) == S_OK; ++i)
{ {
while (IEnumMediaTypes_Next(enummt, 1, &candidate, NULL) == S_OK) strmbase_dump_media_type(&candidate);
if ((!mt || CompareMediaTypes(mt, &candidate, TRUE))
&& pin->pFuncsTable->pfnAttemptConnection(pin, peer, &candidate) == S_OK)
{ {
if ((!mt || CompareMediaTypes(mt, candidate, TRUE)) LeaveCriticalSection(&pin->pin.filter->csFilter);
&& pin->pFuncsTable->pfnAttemptConnection(pin, peer, candidate) == S_OK) FreeMediaType(&candidate);
{ return S_OK;
LeaveCriticalSection(&pin->pin.filter->csFilter);
DeleteMediaType(candidate);
IEnumMediaTypes_Release(enummt);
return S_OK;
}
DeleteMediaType(candidate);
} }
FreeMediaType(&candidate);
IEnumMediaTypes_Release(enummt);
} }
if (SUCCEEDED(IPin_EnumMediaTypes(peer, &enummt))) if (SUCCEEDED(IPin_EnumMediaTypes(peer, &enummt)))
{ {
while (IEnumMediaTypes_Next(enummt, 1, &candidate, &count) == S_OK) while (IEnumMediaTypes_Next(enummt, 1, &candidate_ptr, &count) == S_OK)
{ {
if ((!mt || CompareMediaTypes(mt, candidate, TRUE)) if ((!mt || CompareMediaTypes(mt, candidate_ptr, TRUE))
&& pin->pFuncsTable->pfnAttemptConnection(pin, peer, candidate) == S_OK) && pin->pFuncsTable->pfnAttemptConnection(pin, peer, candidate_ptr) == S_OK)
{ {
LeaveCriticalSection(&pin->pin.filter->csFilter); LeaveCriticalSection(&pin->pin.filter->csFilter);
DeleteMediaType(candidate); DeleteMediaType(candidate_ptr);
IEnumMediaTypes_Release(enummt); IEnumMediaTypes_Release(enummt);
return S_OK; return S_OK;
} }
DeleteMediaType(candidate); DeleteMediaType(candidate_ptr);
} }
IEnumMediaTypes_Release(enummt); IEnumMediaTypes_Release(enummt);