xcopy: Remove spaces before '\n's in the Korean translation.
[wine/hramrach.git] / dlls / qcap / enumpins.c
bloba4b1a9fa067fe5192239e0af3e79239d5645ba22
1 /*
2 * Implementation of IEnumPins Interface
4 * Copyright 2003 Robert Shearman
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.
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.
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
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wtypes.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "dshow.h"
32 #include "qcap_main.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(qcap);
38 typedef struct IEnumPinsImpl
40 const IEnumPinsVtbl * lpVtbl;
41 LONG refCount;
42 ENUMPINDETAILS enumPinDetails;
43 ULONG uIndex;
44 } IEnumPinsImpl;
46 static const struct IEnumPinsVtbl IEnumPinsImpl_Vtbl;
48 HRESULT IEnumPinsImpl_Construct(const ENUMPINDETAILS * pDetails, IEnumPins ** ppEnum)
50 IEnumPinsImpl * pEnumPins = CoTaskMemAlloc(sizeof(IEnumPinsImpl));
51 if (!pEnumPins)
53 *ppEnum = NULL;
54 return E_OUTOFMEMORY;
56 pEnumPins->lpVtbl = &IEnumPinsImpl_Vtbl;
57 pEnumPins->refCount = 1;
58 pEnumPins->uIndex = 0;
59 pEnumPins->enumPinDetails = *pDetails;
60 *ppEnum = (IEnumPins *)(&pEnumPins->lpVtbl);
61 ObjectRefCount(TRUE);
62 return S_OK;
65 static HRESULT WINAPI IEnumPinsImpl_QueryInterface(IEnumPins * iface, REFIID riid, LPVOID * ppv)
67 TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
69 *ppv = NULL;
71 if (IsEqualIID(riid, &IID_IUnknown))
72 *ppv = iface;
73 else if (IsEqualIID(riid, &IID_IEnumPins))
74 *ppv = iface;
76 if (*ppv)
78 IUnknown_AddRef((IUnknown *)(*ppv));
79 return S_OK;
82 FIXME("No interface for %s!\n", debugstr_guid(riid));
84 return E_NOINTERFACE;
87 static ULONG WINAPI IEnumPinsImpl_AddRef(IEnumPins * iface)
89 IEnumPinsImpl *This = (IEnumPinsImpl *)iface;
90 ULONG refCount = InterlockedIncrement(&This->refCount);
92 TRACE("()\n");
94 return refCount;
97 static ULONG WINAPI IEnumPinsImpl_Release(IEnumPins * iface)
99 IEnumPinsImpl *This = (IEnumPinsImpl *)iface;
100 ULONG refCount = InterlockedDecrement(&This->refCount);
102 TRACE("()\n");
104 if (!refCount)
106 CoTaskMemFree(This);
107 ObjectRefCount(FALSE);
109 return refCount;
112 static HRESULT WINAPI IEnumPinsImpl_Next(IEnumPins * iface, ULONG cPins, IPin ** ppPins, ULONG * pcFetched)
114 ULONG cFetched;
115 IEnumPinsImpl *This = (IEnumPinsImpl *)iface;
117 cFetched = min(This->enumPinDetails.cPins, This->uIndex + cPins) - This->uIndex;
119 TRACE("(%u, %p, %p)\n", cPins, ppPins, pcFetched);
121 if (cFetched > 0)
123 ULONG i;
124 for (i = 0; i < cFetched; i++) {
125 IPin_AddRef(This->enumPinDetails.ppPins[This->uIndex + i]);
126 ppPins[i] = This->enumPinDetails.ppPins[This->uIndex + i];
130 if ((cPins != 1) || pcFetched)
131 *pcFetched = cFetched;
133 This->uIndex += cFetched;
135 if (cFetched != cPins)
136 return S_FALSE;
137 return S_OK;
140 static HRESULT WINAPI IEnumPinsImpl_Skip(IEnumPins * iface, ULONG cPins)
142 IEnumPinsImpl *This = (IEnumPinsImpl *)iface;
144 TRACE("(%u)\n", cPins);
146 if (This->uIndex + cPins < This->enumPinDetails.cPins)
148 This->uIndex += cPins;
149 return S_OK;
151 return S_FALSE;
154 static HRESULT WINAPI IEnumPinsImpl_Reset(IEnumPins * iface)
156 IEnumPinsImpl *This = (IEnumPinsImpl *)iface;
158 TRACE("IEnumPinsImpl::Reset()\n");
160 This->uIndex = 0;
161 return S_OK;
164 static HRESULT WINAPI IEnumPinsImpl_Clone(IEnumPins * iface, IEnumPins ** ppEnum)
166 HRESULT hr;
167 IEnumPinsImpl *This = (IEnumPinsImpl *)iface;
169 TRACE("(%p)\n", ppEnum);
171 hr = IEnumPinsImpl_Construct(&This->enumPinDetails, ppEnum);
172 if (FAILED(hr))
173 return hr;
174 return IEnumPins_Skip(*ppEnum, This->uIndex);
177 static const IEnumPinsVtbl IEnumPinsImpl_Vtbl =
179 IEnumPinsImpl_QueryInterface,
180 IEnumPinsImpl_AddRef,
181 IEnumPinsImpl_Release,
182 IEnumPinsImpl_Next,
183 IEnumPinsImpl_Skip,
184 IEnumPinsImpl_Reset,
185 IEnumPinsImpl_Clone