quartz: Merge enumregfilters.c into filtermapper.c.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f7718d6453
commit
d42b598399
|
@ -9,7 +9,6 @@ C_SRCS = \
|
|||
avidec.c \
|
||||
dsoundrender.c \
|
||||
enummoniker.c \
|
||||
enumregfilters.c \
|
||||
filesource.c \
|
||||
filtergraph.c \
|
||||
filtermapper.c \
|
||||
|
|
|
@ -1,224 +0,0 @@
|
|||
/*
|
||||
* Implementation of IEnumRegFilters Interface
|
||||
*
|
||||
* Copyright 2004 Christian Costa
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "quartz_private.h"
|
||||
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
||||
|
||||
typedef struct IEnumRegFiltersImpl
|
||||
{
|
||||
IEnumRegFilters IEnumRegFilters_iface;
|
||||
LONG refCount;
|
||||
ULONG size;
|
||||
REGFILTER* RegFilters;
|
||||
ULONG uIndex;
|
||||
} IEnumRegFiltersImpl;
|
||||
|
||||
static inline IEnumRegFiltersImpl *impl_from_IEnumRegFilters(IEnumRegFilters *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, IEnumRegFiltersImpl, IEnumRegFilters_iface);
|
||||
}
|
||||
|
||||
static const struct IEnumRegFiltersVtbl IEnumRegFiltersImpl_Vtbl;
|
||||
|
||||
HRESULT IEnumRegFiltersImpl_Construct(REGFILTER* pInRegFilters, const ULONG size, IEnumRegFilters ** ppEnum)
|
||||
{
|
||||
IEnumRegFiltersImpl* pEnumRegFilters;
|
||||
REGFILTER* pRegFilters = NULL;
|
||||
unsigned int i;
|
||||
|
||||
TRACE("(%p, %d, %p)\n", pInRegFilters, size, ppEnum);
|
||||
|
||||
pEnumRegFilters = CoTaskMemAlloc(sizeof(IEnumRegFiltersImpl));
|
||||
if (!pEnumRegFilters)
|
||||
{
|
||||
*ppEnum = NULL;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
/* Accept size of 0 */
|
||||
if (size)
|
||||
{
|
||||
pRegFilters = CoTaskMemAlloc(sizeof(REGFILTER)*size);
|
||||
if (!pRegFilters)
|
||||
{
|
||||
CoTaskMemFree(pEnumRegFilters);
|
||||
*ppEnum = NULL;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < size; i++)
|
||||
{
|
||||
pRegFilters[i].Clsid = pInRegFilters[i].Clsid;
|
||||
pRegFilters[i].Name = CoTaskMemAlloc((lstrlenW(pInRegFilters[i].Name)+1)*sizeof(WCHAR));
|
||||
if (!pRegFilters[i].Name)
|
||||
{
|
||||
while(i)
|
||||
CoTaskMemFree(pRegFilters[--i].Name);
|
||||
CoTaskMemFree(pRegFilters);
|
||||
CoTaskMemFree(pEnumRegFilters);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
CopyMemory(pRegFilters[i].Name, pInRegFilters[i].Name, (lstrlenW(pInRegFilters[i].Name)+1)*sizeof(WCHAR));
|
||||
}
|
||||
|
||||
pEnumRegFilters->IEnumRegFilters_iface.lpVtbl = &IEnumRegFiltersImpl_Vtbl;
|
||||
pEnumRegFilters->refCount = 1;
|
||||
pEnumRegFilters->uIndex = 0;
|
||||
pEnumRegFilters->RegFilters = pRegFilters;
|
||||
pEnumRegFilters->size = size;
|
||||
|
||||
*ppEnum = &pEnumRegFilters->IEnumRegFilters_iface;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IEnumRegFiltersImpl_QueryInterface(IEnumRegFilters * iface, REFIID riid, LPVOID * ppv)
|
||||
{
|
||||
TRACE("(%p)->(%s, %p)\n", iface, qzdebugstr_guid(riid), ppv);
|
||||
|
||||
*ppv = NULL;
|
||||
|
||||
if (IsEqualIID(riid, &IID_IUnknown))
|
||||
*ppv = iface;
|
||||
else if (IsEqualIID(riid, &IID_IEnumRegFilters))
|
||||
*ppv = iface;
|
||||
|
||||
if (*ppv)
|
||||
{
|
||||
IUnknown_AddRef((IUnknown *)(*ppv));
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
|
||||
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI IEnumRegFiltersImpl_AddRef(IEnumRegFilters * iface)
|
||||
{
|
||||
IEnumRegFiltersImpl *This = impl_from_IEnumRegFilters(iface);
|
||||
ULONG refCount = InterlockedIncrement(&This->refCount);
|
||||
|
||||
TRACE("(%p)\n", iface);
|
||||
|
||||
return refCount;
|
||||
}
|
||||
|
||||
static ULONG WINAPI IEnumRegFiltersImpl_Release(IEnumRegFilters * iface)
|
||||
{
|
||||
IEnumRegFiltersImpl *This = impl_from_IEnumRegFilters(iface);
|
||||
ULONG refCount = InterlockedDecrement(&This->refCount);
|
||||
|
||||
TRACE("(%p)\n", iface);
|
||||
|
||||
if (!refCount)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for(i = 0; i < This->size; i++)
|
||||
{
|
||||
CoTaskMemFree(This->RegFilters[i].Name);
|
||||
}
|
||||
CoTaskMemFree(This->RegFilters);
|
||||
CoTaskMemFree(This);
|
||||
return 0;
|
||||
} else
|
||||
return refCount;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IEnumRegFiltersImpl_Next(IEnumRegFilters * iface, ULONG cFilters, REGFILTER ** ppRegFilter, ULONG * pcFetched)
|
||||
{
|
||||
ULONG cFetched;
|
||||
IEnumRegFiltersImpl *This = impl_from_IEnumRegFilters(iface);
|
||||
unsigned int i;
|
||||
|
||||
cFetched = min(This->size, This->uIndex + cFilters) - This->uIndex;
|
||||
|
||||
TRACE("(%p)->(%u, %p, %p)\n", iface, cFilters, ppRegFilter, pcFetched);
|
||||
|
||||
if (cFetched > 0)
|
||||
{
|
||||
for(i = 0; i < cFetched; i++)
|
||||
{
|
||||
/* The string in the REGFILTER structure must be allocated in the same block as the REGFILTER structure itself */
|
||||
ppRegFilter[i] = CoTaskMemAlloc(sizeof(REGFILTER)+(lstrlenW(This->RegFilters[This->uIndex + i].Name)+1)*sizeof(WCHAR));
|
||||
if (!ppRegFilter[i])
|
||||
{
|
||||
while(i)
|
||||
{
|
||||
CoTaskMemFree(ppRegFilter[--i]);
|
||||
ppRegFilter[i] = NULL;
|
||||
}
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
ppRegFilter[i]->Clsid = This->RegFilters[This->uIndex + i].Clsid;
|
||||
ppRegFilter[i]->Name = (WCHAR*)((char*)ppRegFilter[i]+sizeof(REGFILTER));
|
||||
CopyMemory(ppRegFilter[i]->Name, This->RegFilters[This->uIndex + i].Name,
|
||||
(lstrlenW(This->RegFilters[This->uIndex + i].Name)+1)*sizeof(WCHAR));
|
||||
}
|
||||
|
||||
This->uIndex += cFetched;
|
||||
if (pcFetched)
|
||||
*pcFetched = cFetched;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IEnumRegFiltersImpl_Skip(IEnumRegFilters * iface, ULONG n)
|
||||
{
|
||||
TRACE("(%p)->(%u)\n", iface, n);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IEnumRegFiltersImpl_Reset(IEnumRegFilters * iface)
|
||||
{
|
||||
IEnumRegFiltersImpl *This = impl_from_IEnumRegFilters(iface);
|
||||
|
||||
TRACE("(%p)\n", iface);
|
||||
|
||||
This->uIndex = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IEnumRegFiltersImpl_Clone(IEnumRegFilters * iface, IEnumRegFilters ** ppEnum)
|
||||
{
|
||||
TRACE("(%p)->(%p)\n", iface, ppEnum);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const IEnumRegFiltersVtbl IEnumRegFiltersImpl_Vtbl =
|
||||
{
|
||||
IEnumRegFiltersImpl_QueryInterface,
|
||||
IEnumRegFiltersImpl_AddRef,
|
||||
IEnumRegFiltersImpl_Release,
|
||||
IEnumRegFiltersImpl_Next,
|
||||
IEnumRegFiltersImpl_Skip,
|
||||
IEnumRegFiltersImpl_Reset,
|
||||
IEnumRegFiltersImpl_Clone
|
||||
};
|
|
@ -42,6 +42,164 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
||||
|
||||
struct enum_reg_filters
|
||||
{
|
||||
IEnumRegFilters IEnumRegFilters_iface;
|
||||
LONG refcount;
|
||||
|
||||
unsigned int index, count;
|
||||
REGFILTER *filters;
|
||||
};
|
||||
|
||||
static struct enum_reg_filters *impl_from_IEnumRegFilters(IEnumRegFilters *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, struct enum_reg_filters, IEnumRegFilters_iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI enum_reg_filters_QueryInterface(IEnumRegFilters *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_IEnumRegFilters))
|
||||
{
|
||||
IEnumRegFilters_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_reg_filters_AddRef(IEnumRegFilters *iface)
|
||||
{
|
||||
struct enum_reg_filters *enumerator = impl_from_IEnumRegFilters(iface);
|
||||
ULONG refcount = InterlockedIncrement(&enumerator->refcount);
|
||||
TRACE("%p increasing refcount to %u.\n", enumerator, refcount);
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static ULONG WINAPI enum_reg_filters_Release(IEnumRegFilters *iface)
|
||||
{
|
||||
struct enum_reg_filters *enumerator = impl_from_IEnumRegFilters(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)
|
||||
free(enumerator->filters[i].Name);
|
||||
free(enumerator->filters);
|
||||
free(enumerator);
|
||||
}
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI enum_reg_filters_Next(IEnumRegFilters *iface, ULONG count,
|
||||
REGFILTER **filters, ULONG *ret_count)
|
||||
{
|
||||
struct enum_reg_filters *enumerator = impl_from_IEnumRegFilters(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)
|
||||
{
|
||||
REGFILTER *filter = &enumerator->filters[enumerator->index + i];
|
||||
|
||||
if (!(filters[i] = CoTaskMemAlloc(sizeof(REGFILTER) + (wcslen(filter->Name) + 1) * sizeof(WCHAR))))
|
||||
{
|
||||
while (i--)
|
||||
CoTaskMemFree(filters[i]);
|
||||
memset(filters, 0, count * sizeof(*filters));
|
||||
*ret_count = 0;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
filters[i]->Clsid = filter->Clsid;
|
||||
filters[i]->Name = (WCHAR *)(filters[i] + 1);
|
||||
wcscpy(filters[i]->Name, filter->Name);
|
||||
}
|
||||
|
||||
enumerator->index += i;
|
||||
if (ret_count)
|
||||
*ret_count = i;
|
||||
return i ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI enum_reg_filters_Skip(IEnumRegFilters *iface, ULONG count)
|
||||
{
|
||||
TRACE("iface %p, count %u, unimplemented.\n", iface, count);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI enum_reg_filters_Reset(IEnumRegFilters *iface)
|
||||
{
|
||||
struct enum_reg_filters *enumerator = impl_from_IEnumRegFilters(iface);
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
enumerator->index = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI enum_reg_filters_Clone(IEnumRegFilters *iface, IEnumRegFilters **out)
|
||||
{
|
||||
TRACE("iface %p, out %p, unimplemented.\n", iface, out);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const IEnumRegFiltersVtbl enum_reg_filters_vtbl =
|
||||
{
|
||||
enum_reg_filters_QueryInterface,
|
||||
enum_reg_filters_AddRef,
|
||||
enum_reg_filters_Release,
|
||||
enum_reg_filters_Next,
|
||||
enum_reg_filters_Skip,
|
||||
enum_reg_filters_Reset,
|
||||
enum_reg_filters_Clone,
|
||||
};
|
||||
|
||||
static HRESULT enum_reg_filters_create(REGFILTER *filters, unsigned int count, IEnumRegFilters **out)
|
||||
{
|
||||
struct enum_reg_filters *object;
|
||||
unsigned int i;
|
||||
|
||||
*out = NULL;
|
||||
|
||||
if (!(object = calloc(1, sizeof(*object))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (!(object->filters = malloc(count * sizeof(*object->filters))))
|
||||
{
|
||||
free(object);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
object->filters[i].Clsid = filters[i].Clsid;
|
||||
if (!(object->filters[i].Name = wcsdup(filters[i].Name)))
|
||||
{
|
||||
while (i--)
|
||||
free(object->filters[i].Name);
|
||||
free(object->filters);
|
||||
free(object);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
object->IEnumRegFilters_iface.lpVtbl = &enum_reg_filters_vtbl;
|
||||
object->refcount = 1;
|
||||
object->count = count;
|
||||
|
||||
TRACE("Created enumerator %p.\n", object);
|
||||
*out = &object->IEnumRegFilters_iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
typedef struct FilterMapper3Impl
|
||||
{
|
||||
IUnknown IUnknown_inner;
|
||||
|
@ -1030,7 +1188,7 @@ static HRESULT WINAPI FilterMapper_EnumMatchingFilters(
|
|||
if (!nb_mon)
|
||||
{
|
||||
IEnumMoniker_Release(ppEnumMoniker);
|
||||
return IEnumRegFiltersImpl_Construct(NULL, 0, ppEnum);
|
||||
return enum_reg_filters_create(NULL, 0, ppEnum);
|
||||
}
|
||||
|
||||
regfilters = CoTaskMemAlloc(nb_mon * sizeof(REGFILTER));
|
||||
|
@ -1087,7 +1245,7 @@ static HRESULT WINAPI FilterMapper_EnumMatchingFilters(
|
|||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IEnumRegFiltersImpl_Construct(regfilters, idx, ppEnum);
|
||||
hr = enum_reg_filters_create(regfilters, idx, ppEnum);
|
||||
}
|
||||
|
||||
for (idx = 0; idx < nb_mon; idx++)
|
||||
|
|
|
@ -81,8 +81,6 @@ HRESULT vmr9_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
|
|||
|
||||
HRESULT EnumMonikerImpl_Create(IMoniker ** ppMoniker, ULONG nMonikerCount, IEnumMoniker ** ppEnum) DECLSPEC_HIDDEN;
|
||||
|
||||
HRESULT IEnumRegFiltersImpl_Construct(REGFILTER * pInRegFilters, const ULONG size, IEnumRegFilters ** ppEnum) DECLSPEC_HIDDEN;
|
||||
|
||||
extern const char * qzdebugstr_guid(const GUID * id) DECLSPEC_HIDDEN;
|
||||
extern void video_unregister_windowclass(void) DECLSPEC_HIDDEN;
|
||||
|
||||
|
|
Loading…
Reference in New Issue