Commit 9f72f8c2 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

quartz: Merge enummoniker.c into filtermapper.c.

parent d42b5983
......@@ -8,7 +8,6 @@ C_SRCS = \
acmwrapper.c \
avidec.c \
dsoundrender.c \
enummoniker.c \
filesource.c \
filtergraph.c \
filtermapper.c \
......
/*
* IEnumMoniker implementation
*
* Copyright 2003 Robert Shearman
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "quartz_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
typedef struct EnumMonikerImpl
{
IEnumMoniker IEnumMoniker_iface;
LONG ref;
IMoniker ** ppMoniker;
ULONG nMonikerCount;
ULONG index;
} EnumMonikerImpl;
static const IEnumMonikerVtbl EnumMonikerImpl_Vtbl;
static inline EnumMonikerImpl *impl_from_IEnumMoniker(IEnumMoniker *iface)
{
return CONTAINING_RECORD(iface, EnumMonikerImpl, IEnumMoniker_iface);
}
static ULONG WINAPI EnumMonikerImpl_AddRef(LPENUMMONIKER iface);
HRESULT EnumMonikerImpl_Create(IMoniker ** ppMoniker, ULONG nMonikerCount, IEnumMoniker ** ppEnum)
{
/* NOTE: assumes that array of IMonikers has already been AddRef'd
* I.e. this function does not AddRef the array of incoming
* IMonikers */
EnumMonikerImpl * pemi = CoTaskMemAlloc(sizeof(EnumMonikerImpl));
TRACE("(%p, %d, %p)\n", ppMoniker, nMonikerCount, ppEnum);
*ppEnum = NULL;
if (!pemi)
return E_OUTOFMEMORY;
pemi->IEnumMoniker_iface.lpVtbl = &EnumMonikerImpl_Vtbl;
pemi->ref = 1;
pemi->ppMoniker = CoTaskMemAlloc(nMonikerCount * sizeof(IMoniker*));
memcpy(pemi->ppMoniker, ppMoniker, nMonikerCount*sizeof(IMoniker*));
pemi->nMonikerCount = nMonikerCount;
pemi->index = 0;
*ppEnum = &pemi->IEnumMoniker_iface;
return S_OK;
}
/**********************************************************************
* IEnumMoniker_QueryInterface (also IUnknown)
*/
static HRESULT WINAPI EnumMonikerImpl_QueryInterface(
LPENUMMONIKER iface,
REFIID riid,
LPVOID *ppvObj)
{
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (This == NULL || ppvObj == NULL) return E_POINTER;
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IEnumMoniker))
{
*ppvObj = iface;
EnumMonikerImpl_AddRef(iface);
return S_OK;
}
*ppvObj = NULL;
FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
/**********************************************************************
* IEnumMoniker_AddRef (also IUnknown)
*/
static ULONG WINAPI EnumMonikerImpl_AddRef(LPENUMMONIKER iface)
{
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
ULONG ref;
if (This == NULL) return E_POINTER;
ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->() AddRef from %d\n", iface, ref - 1);
return ref;
}
/**********************************************************************
* IEnumMoniker_Release (also IUnknown)
*/
static ULONG WINAPI EnumMonikerImpl_Release(LPENUMMONIKER iface)
{
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->() Release from %d\n", iface, ref + 1);
if (!ref)
{
ULONG i;
for (i = 0; i < This->nMonikerCount; i++)
IMoniker_Release(This->ppMoniker[i]);
CoTaskMemFree(This->ppMoniker);
This->ppMoniker = NULL;
CoTaskMemFree(This);
return 0;
}
return ref;
}
static HRESULT WINAPI EnumMonikerImpl_Next(LPENUMMONIKER iface, ULONG celt, IMoniker ** rgelt, ULONG * pceltFetched)
{
ULONG fetched;
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
TRACE("(%p)->(%d, %p, %p)\n", iface, celt, rgelt, pceltFetched);
for (fetched = 0; (This->index + fetched < This->nMonikerCount) && (fetched < celt); fetched++)
{
rgelt[fetched] = This->ppMoniker[This->index + fetched];
IMoniker_AddRef(rgelt[fetched]);
}
This->index += fetched;
TRACE("-- fetched %d\n", fetched);
if (pceltFetched)
*pceltFetched = fetched;
if (fetched != celt)
return S_FALSE;
else
return S_OK;
}
static HRESULT WINAPI EnumMonikerImpl_Skip(LPENUMMONIKER iface, ULONG celt)
{
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
TRACE("(%p)->(%d)\n", iface, celt);
This->index += celt;
return S_OK;
}
static HRESULT WINAPI EnumMonikerImpl_Reset(LPENUMMONIKER iface)
{
EnumMonikerImpl *This = impl_from_IEnumMoniker(iface);
TRACE("(%p)->()\n", iface);
This->index = 0;
return S_OK;
}
static HRESULT WINAPI EnumMonikerImpl_Clone(LPENUMMONIKER iface, IEnumMoniker ** ppenum)
{
FIXME("(%p)->(%p): stub\n", iface, ppenum);
return E_NOTIMPL;
}
/**********************************************************************
* IEnumMoniker_Vtbl
*/
static const IEnumMonikerVtbl EnumMonikerImpl_Vtbl =
{
EnumMonikerImpl_QueryInterface,
EnumMonikerImpl_AddRef,
EnumMonikerImpl_Release,
EnumMonikerImpl_Next,
EnumMonikerImpl_Skip,
EnumMonikerImpl_Reset,
EnumMonikerImpl_Clone
};
......@@ -200,6 +200,140 @@ static HRESULT enum_reg_filters_create(REGFILTER *filters, unsigned int count, I
return S_OK;
}
struct enum_moniker
{
IEnumMoniker IEnumMoniker_iface;
LONG refcount;
unsigned int index, count;
IMoniker **filters;
};
static struct enum_moniker *impl_from_IEnumMoniker(IEnumMoniker *iface)
{
return CONTAINING_RECORD(iface, struct enum_moniker, IEnumMoniker_iface);
}
static HRESULT WINAPI enum_moniker_QueryInterface(IEnumMoniker *iface, REFIID iid, void **out)
{
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IEnumMoniker))
{
IEnumMoniker_AddRef(iface);
*out = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
*out = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI enum_moniker_AddRef(IEnumMoniker *iface)
{
struct enum_moniker *enumerator = impl_from_IEnumMoniker(iface);
ULONG refcount = InterlockedIncrement(&enumerator->refcount);
TRACE("%p increasing refcount to %u.\n", enumerator, refcount);
return refcount;
}
static ULONG WINAPI enum_moniker_Release(IEnumMoniker *iface)
{
struct enum_moniker *enumerator = impl_from_IEnumMoniker(iface);
ULONG refcount = InterlockedDecrement(&enumerator->refcount);
unsigned int i;
TRACE("%p decreasing refcount to %u.\n", enumerator, refcount);
if (!refcount)
{
for (i = 0; i < enumerator->count; ++i)
IMoniker_Release(enumerator->filters[i]);
free(enumerator->filters);
free(enumerator);
}
return refcount;
}
static HRESULT WINAPI enum_moniker_Next(IEnumMoniker *iface, ULONG count,
IMoniker **filters, ULONG *ret_count)
{
struct enum_moniker *enumerator = impl_from_IEnumMoniker(iface);
unsigned int i;
TRACE("iface %p, count %u, filters %p, ret_count %p.\n", iface, count, filters, ret_count);
for (i = 0; i < count && enumerator->index + i < enumerator->count; ++i)
IMoniker_AddRef(filters[i] = enumerator->filters[enumerator->index + i]);
enumerator->index += i;
if (ret_count)
*ret_count = i;
return i ? S_OK : S_FALSE;
}
static HRESULT WINAPI enum_moniker_Skip(IEnumMoniker *iface, ULONG count)
{
struct enum_moniker *enumerator = impl_from_IEnumMoniker(iface);
TRACE("iface %p, count %u.\n", iface, count);
enumerator->index += count;
return S_OK;
}
static HRESULT WINAPI enum_moniker_Reset(IEnumMoniker *iface)
{
struct enum_moniker *enumerator = impl_from_IEnumMoniker(iface);
TRACE("iface %p.\n", iface);
enumerator->index = 0;
return S_OK;
}
static HRESULT WINAPI enum_moniker_Clone(IEnumMoniker *iface, IEnumMoniker **out)
{
TRACE("iface %p, out %p, unimplemented.\n", iface, out);
return E_NOTIMPL;
}
static const IEnumMonikerVtbl enum_moniker_vtbl =
{
enum_moniker_QueryInterface,
enum_moniker_AddRef,
enum_moniker_Release,
enum_moniker_Next,
enum_moniker_Skip,
enum_moniker_Reset,
enum_moniker_Clone,
};
static HRESULT enum_moniker_create(IMoniker **filters, unsigned int count, IEnumMoniker **out)
{
struct enum_moniker *object;
*out = NULL;
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
if (!(object->filters = malloc(count * sizeof(*object->filters))))
{
free(object);
return E_OUTOFMEMORY;
}
memcpy(object->filters, filters, count * sizeof(*filters));
object->IEnumMoniker_iface.lpVtbl = &enum_moniker_vtbl;
object->refcount = 1;
object->count = count;
TRACE("Created enumerator %p.\n", object);
*out = &object->IEnumMoniker_iface;
return S_OK;
}
typedef struct FilterMapper3Impl
{
IUnknown IUnknown_inner;
......@@ -1070,7 +1204,7 @@ static HRESULT WINAPI FilterMapper3_EnumMatchingFilters(
/* no need to AddRef here as already AddRef'd above */
ppMoniker[i] = ((struct MONIKER_MERIT *)monikers.pData)[i].pMoniker;
}
hr = EnumMonikerImpl_Create(ppMoniker, nMonikerCount, ppEnum);
hr = enum_moniker_create(ppMoniker, nMonikerCount, ppEnum);
CoTaskMemFree(ppMoniker);
}
......
......@@ -79,8 +79,6 @@ HRESULT video_renderer_default_create(IUnknown *outer, IUnknown **out) DECLSPEC_
HRESULT vmr7_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
HRESULT vmr9_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
HRESULT EnumMonikerImpl_Create(IMoniker ** ppMoniker, ULONG nMonikerCount, IEnumMoniker ** ppEnum) DECLSPEC_HIDDEN;
extern const char * qzdebugstr_guid(const GUID * id) DECLSPEC_HIDDEN;
extern void video_unregister_windowclass(void) DECLSPEC_HIDDEN;
......
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