Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenenumpins.c
Go to the documentation of this file.
00001 /* 00002 * Implementation of IEnumPins Interface 00003 * 00004 * Copyright 2003 Robert Shearman 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00019 */ 00020 00021 #include "quartz_private.h" 00022 00023 #include "wine/debug.h" 00024 00025 WINE_DEFAULT_DEBUG_CHANNEL(quartz); 00026 00027 typedef struct IEnumPinsImpl 00028 { 00029 const IEnumPinsVtbl * lpVtbl; 00030 LONG refCount; 00031 ULONG uIndex; 00032 IBaseFilter *base; 00033 FNOBTAINPIN receive_pin; 00034 DWORD synctime; 00035 } IEnumPinsImpl; 00036 00037 static const struct IEnumPinsVtbl IEnumPinsImpl_Vtbl; 00038 00039 HRESULT IEnumPinsImpl_Construct(IEnumPins ** ppEnum, FNOBTAINPIN receive_pin, IBaseFilter *base) 00040 { 00041 IEnumPinsImpl * pEnumPins; 00042 00043 if (!ppEnum) 00044 return E_POINTER; 00045 00046 pEnumPins = CoTaskMemAlloc(sizeof(IEnumPinsImpl)); 00047 if (!pEnumPins) 00048 { 00049 *ppEnum = NULL; 00050 return E_OUTOFMEMORY; 00051 } 00052 pEnumPins->lpVtbl = &IEnumPinsImpl_Vtbl; 00053 pEnumPins->refCount = 1; 00054 pEnumPins->uIndex = 0; 00055 pEnumPins->receive_pin = receive_pin; 00056 pEnumPins->base = base; 00057 IBaseFilter_AddRef(base); 00058 *ppEnum = (IEnumPins *)(&pEnumPins->lpVtbl); 00059 00060 receive_pin(base, ~0, NULL, &pEnumPins->synctime); 00061 00062 TRACE("Created new enumerator (%p)\n", *ppEnum); 00063 return S_OK; 00064 } 00065 00066 static HRESULT WINAPI IEnumPinsImpl_QueryInterface(IEnumPins * iface, REFIID riid, LPVOID * ppv) 00067 { 00068 TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv); 00069 00070 *ppv = NULL; 00071 00072 if (IsEqualIID(riid, &IID_IUnknown)) 00073 *ppv = iface; 00074 else if (IsEqualIID(riid, &IID_IEnumPins)) 00075 *ppv = iface; 00076 00077 if (*ppv) 00078 { 00079 IUnknown_AddRef((IUnknown *)(*ppv)); 00080 return S_OK; 00081 } 00082 00083 FIXME("No interface for %s!\n", qzdebugstr_guid(riid)); 00084 00085 return E_NOINTERFACE; 00086 } 00087 00088 static ULONG WINAPI IEnumPinsImpl_AddRef(IEnumPins * iface) 00089 { 00090 IEnumPinsImpl *This = (IEnumPinsImpl *)iface; 00091 ULONG refCount = InterlockedIncrement(&This->refCount); 00092 00093 TRACE("(%p)->() AddRef from %d\n", This, refCount - 1); 00094 00095 return refCount; 00096 } 00097 00098 static ULONG WINAPI IEnumPinsImpl_Release(IEnumPins * iface) 00099 { 00100 IEnumPinsImpl *This = (IEnumPinsImpl *)iface; 00101 ULONG refCount = InterlockedDecrement(&This->refCount); 00102 00103 TRACE("(%p)->() Release from %d\n", This, refCount + 1); 00104 00105 if (!refCount) 00106 { 00107 IBaseFilter_Release(This->base); 00108 CoTaskMemFree(This); 00109 return 0; 00110 } 00111 else 00112 return refCount; 00113 } 00114 00115 static HRESULT WINAPI IEnumPinsImpl_Next(IEnumPins * iface, ULONG cPins, IPin ** ppPins, ULONG * pcFetched) 00116 { 00117 IEnumPinsImpl *This = (IEnumPinsImpl *)iface; 00118 DWORD synctime = This->synctime; 00119 HRESULT hr = S_OK; 00120 ULONG i = 0; 00121 00122 TRACE("(%u, %p, %p)\n", cPins, ppPins, pcFetched); 00123 00124 if (!ppPins) 00125 return E_POINTER; 00126 00127 if (cPins > 1 && !pcFetched) 00128 return E_INVALIDARG; 00129 00130 if (pcFetched) 00131 *pcFetched = 0; 00132 00133 while (i < cPins && hr == S_OK) 00134 { 00135 hr = This->receive_pin(This->base, This->uIndex + i, &ppPins[i], &synctime); 00136 00137 if (hr == S_OK) 00138 ++i; 00139 00140 if (synctime != This->synctime) 00141 break; 00142 } 00143 00144 if (!i && synctime != This->synctime) 00145 return VFW_E_ENUM_OUT_OF_SYNC; 00146 00147 if (pcFetched) 00148 *pcFetched = i; 00149 This->uIndex += i; 00150 00151 if (i < cPins) 00152 return S_FALSE; 00153 return S_OK; 00154 } 00155 00156 static HRESULT WINAPI IEnumPinsImpl_Skip(IEnumPins * iface, ULONG cPins) 00157 { 00158 IEnumPinsImpl *This = (IEnumPinsImpl *)iface; 00159 DWORD synctime = This->synctime; 00160 HRESULT hr; 00161 IPin *pin = NULL; 00162 00163 TRACE("(%u)\n", cPins); 00164 00165 hr = This->receive_pin(This->base, This->uIndex + cPins, &pin, &synctime); 00166 if (pin) 00167 IPin_Release(pin); 00168 00169 if (synctime != This->synctime) 00170 return VFW_E_ENUM_OUT_OF_SYNC; 00171 00172 if (hr == S_OK) 00173 This->uIndex += cPins; 00174 00175 return hr; 00176 } 00177 00178 static HRESULT WINAPI IEnumPinsImpl_Reset(IEnumPins * iface) 00179 { 00180 IEnumPinsImpl *This = (IEnumPinsImpl *)iface; 00181 00182 TRACE("IEnumPinsImpl::Reset()\n"); 00183 This->receive_pin(This->base, ~0, NULL, &This->synctime); 00184 00185 This->uIndex = 0; 00186 return S_OK; 00187 } 00188 00189 static HRESULT WINAPI IEnumPinsImpl_Clone(IEnumPins * iface, IEnumPins ** ppEnum) 00190 { 00191 HRESULT hr; 00192 IEnumPinsImpl *This = (IEnumPinsImpl *)iface; 00193 00194 TRACE("(%p)\n", ppEnum); 00195 00196 hr = IEnumPinsImpl_Construct(ppEnum, This->receive_pin, This->base); 00197 if (FAILED(hr)) 00198 return hr; 00199 return IEnumPins_Skip(*ppEnum, This->uIndex); 00200 } 00201 00202 static const IEnumPinsVtbl IEnumPinsImpl_Vtbl = 00203 { 00204 IEnumPinsImpl_QueryInterface, 00205 IEnumPinsImpl_AddRef, 00206 IEnumPinsImpl_Release, 00207 IEnumPinsImpl_Next, 00208 IEnumPinsImpl_Skip, 00209 IEnumPinsImpl_Reset, 00210 IEnumPinsImpl_Clone 00211 }; Generated on Fri May 25 2012 04:19:47 for ReactOS by
1.7.6.1
|