Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/strmbase/mediatype.c | 43 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 26 deletions(-)
diff --git a/dlls/strmbase/mediatype.c b/dlls/strmbase/mediatype.c index 8ad2e22efc9..66b5fa1721b 100644 --- a/dlls/strmbase/mediatype.c +++ b/dlls/strmbase/mediatype.c @@ -172,44 +172,35 @@ static ULONG WINAPI IEnumMediaTypesImpl_Release(IEnumMediaTypes * iface) return ref; }
-static HRESULT WINAPI IEnumMediaTypesImpl_Next(IEnumMediaTypes * iface, ULONG cMediaTypes, AM_MEDIA_TYPE ** ppMediaTypes, ULONG * pcFetched) +static HRESULT WINAPI IEnumMediaTypesImpl_Next(IEnumMediaTypes *iface, + ULONG count, AM_MEDIA_TYPE **mts, ULONG *ret_count) { - ULONG cFetched; - IEnumMediaTypesImpl *This = impl_from_IEnumMediaTypes(iface); - - TRACE("(%p)->(%u, %p, %p)\n", iface, cMediaTypes, ppMediaTypes, pcFetched); + IEnumMediaTypesImpl *enummt = impl_from_IEnumMediaTypes(iface); + ULONG i;
- cFetched = min(This->count, This->uIndex + cMediaTypes) - This->uIndex; + TRACE("iface %p, count %u, mts %p, ret_count %p.\n", iface, count, mts, ret_count);
- if (This->currentVersion != This->mediaVersionFunction(This->basePin)) + if (enummt->currentVersion != enummt->mediaVersionFunction(enummt->basePin)) return VFW_E_ENUM_OUT_OF_SYNC;
- TRACE("Next uIndex: %u, cFetched: %u\n", This->uIndex, cFetched); - - if (cFetched > 0) + for (i = 0; i < count && enummt->uIndex + i < enummt->count; i++) { - ULONG i; - for (i = 0; i < cFetched; i++) + if (!(mts[i] = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))) + || FAILED(enummt->enumMediaFunction(enummt->basePin, enummt->uIndex + i, mts[i]))) { - if (!(ppMediaTypes[i] = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))) - || FAILED(This->enumMediaFunction(This->basePin, This->uIndex + i, ppMediaTypes[i]))) - { - while (i--) - DeleteMediaType(ppMediaTypes[i]); - *pcFetched = 0; - return E_OUTOFMEMORY; - } + while (i--) + DeleteMediaType(mts[i]); + *ret_count = 0; + return E_OUTOFMEMORY; } }
- if ((cMediaTypes != 1) || pcFetched) - *pcFetched = cFetched; + if ((count != 1) || ret_count) + *ret_count = i;
- This->uIndex += cFetched; + enummt->uIndex += i;
- if (cFetched != cMediaTypes) - return S_FALSE; - return S_OK; + return i == count ? S_OK : S_FALSE; }
static HRESULT WINAPI IEnumMediaTypesImpl_Skip(IEnumMediaTypes * iface, ULONG cMediaTypes)