ReactOS 0.4.15-dev-8109-gd7be748
enumfilters.c
Go to the documentation of this file.
1/*
2 * Implementation of IEnumFilters Interface
3 *
4 * Copyright 2004 Christian Costa
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "quartz_private.h"
22
23#include "wine/debug.h"
24
26
27typedef struct IEnumFiltersImpl
28{
37
38static const struct IEnumFiltersVtbl IEnumFiltersImpl_Vtbl;
39
41{
42 return CONTAINING_RECORD(iface, IEnumFiltersImpl, IEnumFilters_iface);
43}
44
45HRESULT IEnumFiltersImpl_Construct(IGraphVersion * pVersionSource, IBaseFilter *** pppFilters, ULONG * pNumFilters, IEnumFilters ** ppEnum)
46{
47 /* Note: The incoming IBaseFilter interfaces are not AddRef'd here as in Windows,
48 * they should have been previously AddRef'd. */
49 IEnumFiltersImpl * pEnumFilters = CoTaskMemAlloc(sizeof(IEnumFiltersImpl));
50 HRESULT hr;
51 LONG currentVersion;
52
53 TRACE("(%p, %p, %p)\n", pppFilters, pNumFilters, ppEnum);
54
55 *ppEnum = NULL;
56
57 if (!pEnumFilters)
58 {
59 return E_OUTOFMEMORY;
60 }
61
62 pEnumFilters->IEnumFilters_iface.lpVtbl = &IEnumFiltersImpl_Vtbl;
63 pEnumFilters->refCount = 1;
64 pEnumFilters->uIndex = 0;
65 pEnumFilters->pNumFilters = pNumFilters;
66 pEnumFilters->pppFilters = pppFilters;
67 IGraphVersion_AddRef(pVersionSource);
68 pEnumFilters->pVersionSource = pVersionSource;
69
70 /* Store the current version of the graph */
71 hr = IGraphVersion_QueryVersion(pVersionSource, &currentVersion);
72 pEnumFilters->Version = (hr==S_OK) ? currentVersion : 0;
73
74 *ppEnum = &pEnumFilters->IEnumFilters_iface;
75 return S_OK;
76}
77
79{
80 TRACE("(%p)->(%s, %p)\n", iface, qzdebugstr_guid(riid), ppv);
81
82 *ppv = NULL;
83
85 *ppv = iface;
86 else if (IsEqualIID(riid, &IID_IEnumFilters))
87 *ppv = iface;
88
89 if (*ppv)
90 {
91 IUnknown_AddRef((IUnknown *)(*ppv));
92 return S_OK;
93 }
94
95 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
96
97 return E_NOINTERFACE;
98}
99
101{
103 ULONG refCount = InterlockedIncrement(&This->refCount);
104
105 TRACE("(%p)->()\n", iface);
106
107 return refCount;
108}
109
111{
113 ULONG refCount = InterlockedDecrement(&This->refCount);
114
115 TRACE("(%p)->()\n", iface);
116
117 if (!refCount)
118 {
119 IGraphVersion_Release(This->pVersionSource);
121 return 0;
122 }
123 else
124 return refCount;
125}
126
127static HRESULT WINAPI IEnumFiltersImpl_Next(IEnumFilters * iface, ULONG cFilters, IBaseFilter ** ppFilters, ULONG * pcFetched)
128{
129 ULONG cFetched;
130 ULONG i;
131 LONG currentVersion;
133 HRESULT hr;
134
135 cFetched = min(*This->pNumFilters, This->uIndex + cFilters) - This->uIndex;
136
137 TRACE("(%p)->(%u, %p, %p)\n", iface, cFilters, ppFilters, pcFetched);
138
139 /* First of all check if the graph has changed */
140 hr = IGraphVersion_QueryVersion(This->pVersionSource, &currentVersion);
141 if (hr==S_OK && This->Version != currentVersion)
143
144
145 if (!ppFilters)
146 return E_POINTER;
147
148 for (i = 0; i < cFetched; i++)
149 {
150 ppFilters[i] = (*This->pppFilters)[This->uIndex + i];
151 IBaseFilter_AddRef(ppFilters[i]);
152 }
153
154 This->uIndex += cFetched;
155
156 if (pcFetched)
157 *pcFetched = cFetched;
158
159 if (cFetched != cFilters)
160 return S_FALSE;
161 return S_OK;
162}
163
165{
167
168 TRACE("(%p)->(%u)\n", iface, cFilters);
169
170 if (This->uIndex + cFilters < *This->pNumFilters)
171 {
172 This->uIndex += cFilters;
173 return S_OK;
174 }
175 return S_FALSE;
176}
177
179{
181 HRESULT hr;
182 LONG currentVersion;
183
184 TRACE("(%p)->()\n", iface);
185
186 This->uIndex = 0;
187 hr = IGraphVersion_QueryVersion(This->pVersionSource, &currentVersion);
188 if (hr == S_OK)
189 This->Version = currentVersion;
190 return S_OK;
191}
192
194{
195 HRESULT hr;
197
198 TRACE("(%p)->(%p)\n", iface, ppEnum);
199
200 hr = IEnumFiltersImpl_Construct(This->pVersionSource, This->pppFilters, This->pNumFilters, ppEnum);
201 if (FAILED(hr))
202 return hr;
203 return IEnumFilters_Skip(*ppEnum, This->uIndex);
204}
205
206static const IEnumFiltersVtbl IEnumFiltersImpl_Vtbl =
207{
215};
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
#define FIXME(fmt,...)
Definition: debug.h:114
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
const char * qzdebugstr_guid(const GUID *id)
Definition: main.c:279
static ULONG WINAPI IEnumFiltersImpl_AddRef(IEnumFilters *iface)
Definition: enumfilters.c:100
static HRESULT WINAPI IEnumFiltersImpl_Reset(IEnumFilters *iface)
Definition: enumfilters.c:178
static HRESULT WINAPI IEnumFiltersImpl_Clone(IEnumFilters *iface, IEnumFilters **ppEnum)
Definition: enumfilters.c:193
static ULONG WINAPI IEnumFiltersImpl_Release(IEnumFilters *iface)
Definition: enumfilters.c:110
static HRESULT WINAPI IEnumFiltersImpl_Next(IEnumFilters *iface, ULONG cFilters, IBaseFilter **ppFilters, ULONG *pcFetched)
Definition: enumfilters.c:127
static IEnumFiltersImpl * impl_from_IEnumFilters(IEnumFilters *iface)
Definition: enumfilters.c:40
static HRESULT WINAPI IEnumFiltersImpl_QueryInterface(IEnumFilters *iface, REFIID riid, LPVOID *ppv)
Definition: enumfilters.c:78
HRESULT IEnumFiltersImpl_Construct(IGraphVersion *pVersionSource, IBaseFilter ***pppFilters, ULONG *pNumFilters, IEnumFilters **ppEnum)
Definition: enumfilters.c:45
static const struct IEnumFiltersVtbl IEnumFiltersImpl_Vtbl
Definition: enumfilters.c:38
static HRESULT WINAPI IEnumFiltersImpl_Skip(IEnumFilters *iface, ULONG cFilters)
Definition: enumfilters.c:164
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define min(a, b)
Definition: monoChain.cc:55
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
IEnumFilters IEnumFilters_iface
Definition: enumfilters.c:29
ULONG * pNumFilters
Definition: enumfilters.c:34
IBaseFilter *** pppFilters
Definition: enumfilters.c:33
IGraphVersion * pVersionSource
Definition: enumfilters.c:31
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define VFW_E_ENUM_OUT_OF_SYNC
Definition: vfwmsgs.h:42
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_POINTER
Definition: winerror.h:2365