source: trunk/src/quartz/basepin.c@ 8266

Last change on this file since 8266 was 6952, checked in by sandervl, 24 years ago

Wine 20011004 resync

File size: 17.6 KB
Line 
1/*
2 * Implements IPin and IMemInputPin. (internal)
3 *
4 * hidenori@a2.ctktv.ne.jp
5 */
6
7#include "config.h"
8
9#include "windef.h"
10#include "winbase.h"
11#include "wingdi.h"
12#include "winuser.h"
13#include "winerror.h"
14#include "wine/obj_base.h"
15#include "strmif.h"
16#include "vfwmsgs.h"
17#include "wine/unicode.h"
18
19#include "debugtools.h"
20DEFAULT_DEBUG_CHANNEL(quartz);
21
22#include "quartz_private.h"
23#include "basefilt.h"
24#include "memalloc.h"
25
26
27/***************************************************************************
28 *
29 * CPinBaseImpl
30 *
31 */
32
33static HRESULT WINAPI
34CPinBaseImpl_fnQueryInterface(IPin* iface,REFIID riid,void** ppobj)
35{
36 ICOM_THIS(CPinBaseImpl,iface);
37
38 TRACE("(%p)->()\n",This);
39
40 return IUnknown_QueryInterface(This->punkControl,riid,ppobj);
41}
42
43static ULONG WINAPI
44CPinBaseImpl_fnAddRef(IPin* iface)
45{
46 ICOM_THIS(CPinBaseImpl,iface);
47
48 TRACE("(%p)->()\n",This);
49
50 return IUnknown_AddRef(This->punkControl);
51}
52
53static ULONG WINAPI
54CPinBaseImpl_fnRelease(IPin* iface)
55{
56 ICOM_THIS(CPinBaseImpl,iface);
57
58 TRACE("(%p)->()\n",This);
59
60 return IUnknown_Release(This->punkControl);
61}
62
63static HRESULT WINAPI
64CPinBaseImpl_fnConnect(IPin* iface,IPin* pPin,const AM_MEDIA_TYPE* pmt)
65{
66 ICOM_THIS(CPinBaseImpl,iface);
67 HRESULT hr = E_NOTIMPL;
68 ULONG i;
69
70 FIXME("(%p)->(%p,%p) stub!\n",This,pPin,pmt);
71
72 if ( !This->bOutput )
73 return E_UNEXPECTED;
74 if ( pPin == NULL || pmt == NULL )
75 return E_POINTER;
76
77 EnterCriticalSection( This->pcsPin );
78
79 if ( This->pPinConnectedTo != NULL )
80 {
81 hr = VFW_E_ALREADY_CONNECTED;
82 goto err;
83 }
84
85 /* FIXME - return fail if running */
86
87 if ( pmt != NULL )
88 {
89 hr = IPin_QueryAccept(iface,pmt);
90 if ( FAILED(hr) )
91 goto err;
92 hr = IPin_ReceiveConnection(pPin,iface,pmt);
93 if ( FAILED(hr) )
94 goto err;
95 }
96 else
97 {
98 for ( i = 0; i < This->cAcceptTypes; i++ )
99 {
100 pmt = &This->pmtAcceptTypes[i];
101 hr = IPin_QueryAccept(iface,pmt);
102 if ( SUCCEEDED(hr) )
103 {
104 hr = IPin_ReceiveConnection(pPin,iface,pmt);
105 if ( SUCCEEDED(hr) )
106 {
107 goto connected;
108 }
109 }
110 }
111
112 hr = VFW_E_TYPE_NOT_ACCEPTED;
113 goto err;
114 }
115
116 if ( FAILED(hr) )
117 goto err;
118
119connected:;
120 This->pmtConn = QUARTZ_MediaType_Duplicate( pmt );
121 if ( This->pmtConn == NULL )
122 {
123 hr = E_OUTOFMEMORY;
124 IPin_Disconnect(pPin);
125 goto err;
126 }
127 hr = S_OK;
128
129 This->pPinConnectedTo = pPin; IPin_AddRef(pPin);
130
131err:
132 LeaveCriticalSection( This->pcsPin );
133
134 return hr;
135}
136
137static HRESULT WINAPI
138CPinBaseImpl_fnReceiveConnection(IPin* iface,IPin* pPin,const AM_MEDIA_TYPE* pmt)
139{
140 ICOM_THIS(CPinBaseImpl,iface);
141 HRESULT hr = E_NOTIMPL;
142
143 FIXME("(%p)->(%p,%p) stub!\n",This,pPin,pmt);
144
145 if ( This->bOutput )
146 return E_UNEXPECTED;
147 if ( pPin == NULL || pmt == NULL )
148 return E_POINTER;
149
150 EnterCriticalSection( This->pcsPin );
151
152 if ( This->pPinConnectedTo != NULL )
153 {
154 hr = VFW_E_ALREADY_CONNECTED;
155 goto err;
156 }
157
158 /* FIXME - return fail if running */
159
160
161 hr = IPin_QueryAccept(iface,pmt);
162 if ( FAILED(hr) )
163 goto err;
164
165 This->pmtConn = QUARTZ_MediaType_Duplicate( pmt );
166 if ( This->pmtConn == NULL )
167 {
168 hr = E_OUTOFMEMORY;
169 goto err;
170 }
171 hr = S_OK;
172
173 This->pPinConnectedTo = pPin; IPin_AddRef(pPin);
174err:
175 LeaveCriticalSection( This->pcsPin );
176
177 return hr;
178}
179
180static HRESULT WINAPI
181CPinBaseImpl_fnDisconnect(IPin* iface)
182{
183 ICOM_THIS(CPinBaseImpl,iface);
184 HRESULT hr = NOERROR;
185
186 FIXME("(%p)->() stub!\n",This);
187
188 EnterCriticalSection( This->pcsPin );
189
190 /* FIXME - return fail if running */
191
192 if ( This->pPinConnectedTo != NULL )
193 {
194 /* FIXME - cleanup */
195
196 if ( This->pmtConn != NULL )
197 {
198 QUARTZ_MediaType_Destroy( This->pmtConn );
199 This->pmtConn = NULL;
200 }
201
202 IPin_Release(This->pPinConnectedTo);
203 This->pPinConnectedTo = NULL;
204 hr = NOERROR;
205 }
206 else
207 {
208 hr = S_FALSE; /* FIXME - is this correct??? */
209 }
210
211 LeaveCriticalSection( This->pcsPin );
212
213 return hr;
214}
215
216static HRESULT WINAPI
217CPinBaseImpl_fnConnectedTo(IPin* iface,IPin** ppPin)
218{
219 ICOM_THIS(CPinBaseImpl,iface);
220 HRESULT hr = VFW_E_NOT_CONNECTED;
221
222 TRACE("(%p)->(%p)\n",This,ppPin);
223
224 if ( ppPin == NULL )
225 return E_POINTER;
226
227 EnterCriticalSection( This->pcsPin );
228
229 *ppPin = This->pPinConnectedTo;
230 if ( This->pPinConnectedTo != NULL )
231 {
232 IPin_AddRef(This->pPinConnectedTo);
233 hr = NOERROR;
234 }
235
236 LeaveCriticalSection( This->pcsPin );
237
238 return hr;
239}
240
241static HRESULT WINAPI
242CPinBaseImpl_fnConnectionMediaType(IPin* iface,AM_MEDIA_TYPE* pmt)
243{
244 ICOM_THIS(CPinBaseImpl,iface);
245 HRESULT hr = E_FAIL;
246
247 TRACE("(%p)->(%p)\n",This,pmt);
248
249 if ( pmt == NULL )
250 return E_POINTER;
251
252 EnterCriticalSection( This->pcsPin );
253
254 if ( This->pmtConn != NULL )
255 {
256 hr = QUARTZ_MediaType_Copy( pmt, This->pmtConn );
257 }
258 else
259 {
260 ZeroMemory( pmt, sizeof(AM_MEDIA_TYPE) );
261 pmt->bFixedSizeSamples = TRUE;
262 pmt->lSampleSize = 1;
263 hr = NOERROR;
264 }
265
266 LeaveCriticalSection( This->pcsPin );
267
268 return hr;
269}
270
271static HRESULT WINAPI
272CPinBaseImpl_fnQueryPinInfo(IPin* iface,PIN_INFO* pinfo)
273{
274 ICOM_THIS(CPinBaseImpl,iface);
275
276 TRACE("(%p)->(%p)\n",This,pinfo);
277
278 if ( pinfo == NULL )
279 return E_POINTER;
280
281 EnterCriticalSection( This->pcsPin );
282
283 ZeroMemory( pinfo, sizeof(PIN_INFO) );
284 pinfo->pFilter = (IBaseFilter*)(This->pFilter);
285 if ( pinfo->pFilter != NULL )
286 IBaseFilter_AddRef( pinfo->pFilter );
287 pinfo->dir = This->bOutput ? PINDIR_OUTPUT : PINDIR_INPUT;
288 if ( This->cbIdLen <= sizeof(pinfo->achName) )
289 memcpy( pinfo->achName, This->pwszId, This->cbIdLen );
290 else
291 {
292 memcpy( pinfo->achName, This->pwszId, sizeof(pinfo->achName) );
293 pinfo->achName[sizeof(pinfo->achName)/sizeof(pinfo->achName[0])-1] = 0;
294 }
295
296 LeaveCriticalSection( This->pcsPin );
297
298 return NOERROR;
299}
300
301static HRESULT WINAPI
302CPinBaseImpl_fnQueryDirection(IPin* iface,PIN_DIRECTION* pdir)
303{
304 ICOM_THIS(CPinBaseImpl,iface);
305
306 TRACE("(%p)->(%p)\n",This,pdir);
307
308 if ( pdir == NULL )
309 return E_POINTER;
310
311 *pdir = This->bOutput ? PINDIR_OUTPUT : PINDIR_INPUT;
312
313 return NOERROR;
314}
315
316static HRESULT WINAPI
317CPinBaseImpl_fnQueryId(IPin* iface,LPWSTR* lpwszId)
318{
319 ICOM_THIS(CPinBaseImpl,iface);
320
321 TRACE("(%p)->(%p)\n",This,lpwszId);
322
323 if ( lpwszId == NULL )
324 return E_POINTER;
325
326 *lpwszId = (WCHAR*)CoTaskMemAlloc( This->cbIdLen );
327 if ( *lpwszId == NULL )
328 return E_OUTOFMEMORY;
329 memcpy( *lpwszId, This->pwszId, This->cbIdLen );
330
331 return NOERROR;
332}
333
334static HRESULT WINAPI
335CPinBaseImpl_fnQueryAccept(IPin* iface,const AM_MEDIA_TYPE* pmt)
336{
337 ICOM_THIS(CPinBaseImpl,iface);
338 HRESULT hr;
339
340 TRACE("(%p)->(%p)\n",This,pmt);
341
342 if ( pmt == NULL )
343 return E_POINTER;
344
345 hr = NOERROR;
346 EnterCriticalSection( This->pcsPin );
347 if ( This->pHandlers->pCheckMediaType != NULL )
348 hr = This->pHandlers->pCheckMediaType(This,pmt);
349 LeaveCriticalSection( This->pcsPin );
350
351 return hr;
352}
353
354static HRESULT WINAPI
355CPinBaseImpl_fnEnumMediaTypes(IPin* iface,IEnumMediaTypes** ppenum)
356{
357 ICOM_THIS(CPinBaseImpl,iface);
358 HRESULT hr;
359
360 TRACE("(%p)->(%p)\n",This,ppenum);
361
362 if ( ppenum == NULL )
363 return E_POINTER;
364
365 hr = E_NOTIMPL;
366
367 EnterCriticalSection( This->pcsPin );
368 if ( This->cAcceptTypes > 0 )
369 hr = QUARTZ_CreateEnumMediaTypes(
370 ppenum, This->pmtAcceptTypes, This->cAcceptTypes );
371 LeaveCriticalSection( This->pcsPin );
372
373 return hr;
374}
375
376static HRESULT WINAPI
377CPinBaseImpl_fnQueryInternalConnections(IPin* iface,IPin** ppPin,ULONG* pul)
378{
379 ICOM_THIS(CPinBaseImpl,iface);
380
381 TRACE("(%p)->(%p,%p)\n",This,ppPin,pul);
382
383 /* E_NOTIMPL means 'no internal connections'. */
384 return E_NOTIMPL;
385}
386
387static HRESULT WINAPI
388CPinBaseImpl_fnEndOfStream(IPin* iface)
389{
390 ICOM_THIS(CPinBaseImpl,iface);
391 HRESULT hr = E_NOTIMPL;
392
393 TRACE("(%p)->()\n",This);
394
395 if ( This->bOutput )
396 return E_UNEXPECTED;
397
398 EnterCriticalSection( This->pcsPin );
399 if ( This->pHandlers->pEndOfStream != NULL )
400 hr = This->pHandlers->pEndOfStream(This);
401 LeaveCriticalSection( This->pcsPin );
402
403 return hr;
404}
405
406static HRESULT WINAPI
407CPinBaseImpl_fnBeginFlush(IPin* iface)
408{
409 ICOM_THIS(CPinBaseImpl,iface);
410 HRESULT hr = E_NOTIMPL;
411
412 TRACE("(%p)->()\n",This);
413
414 if ( This->bOutput )
415 return E_UNEXPECTED;
416
417 EnterCriticalSection( This->pcsPin );
418 if ( This->pHandlers->pBeginFlush != NULL )
419 hr = This->pHandlers->pBeginFlush(This);
420 LeaveCriticalSection( This->pcsPin );
421
422 return hr;
423}
424
425static HRESULT WINAPI
426CPinBaseImpl_fnEndFlush(IPin* iface)
427{
428 ICOM_THIS(CPinBaseImpl,iface);
429 HRESULT hr = E_NOTIMPL;
430
431 TRACE("(%p)->()\n",This);
432
433 if ( This->bOutput )
434 return E_UNEXPECTED;
435
436 EnterCriticalSection( This->pcsPin );
437 if ( This->pHandlers->pEndFlush != NULL )
438 hr = This->pHandlers->pEndFlush(This);
439 LeaveCriticalSection( This->pcsPin );
440
441 return hr;
442}
443
444static HRESULT WINAPI
445CPinBaseImpl_fnNewSegment(IPin* iface,REFERENCE_TIME rtStart,REFERENCE_TIME rtStop,double rate)
446{
447 ICOM_THIS(CPinBaseImpl,iface);
448 HRESULT hr = E_NOTIMPL;
449
450 TRACE("(%p)->()\n",This);
451
452 if ( This->bOutput )
453 return E_UNEXPECTED;
454
455 EnterCriticalSection( This->pcsPin );
456 if ( This->pHandlers->pNewSegment != NULL )
457 hr = This->pHandlers->pNewSegment(This,rtStart,rtStop,rate);
458 LeaveCriticalSection( This->pcsPin );
459
460 return hr;
461}
462
463
464
465
466static ICOM_VTABLE(IPin) ipin =
467{
468 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
469 /* IUnknown fields */
470 CPinBaseImpl_fnQueryInterface,
471 CPinBaseImpl_fnAddRef,
472 CPinBaseImpl_fnRelease,
473 /* IPin fields */
474 CPinBaseImpl_fnConnect,
475 CPinBaseImpl_fnReceiveConnection,
476 CPinBaseImpl_fnDisconnect,
477 CPinBaseImpl_fnConnectedTo,
478 CPinBaseImpl_fnConnectionMediaType,
479 CPinBaseImpl_fnQueryPinInfo,
480 CPinBaseImpl_fnQueryDirection,
481 CPinBaseImpl_fnQueryId,
482 CPinBaseImpl_fnQueryAccept,
483 CPinBaseImpl_fnEnumMediaTypes,
484 CPinBaseImpl_fnQueryInternalConnections,
485 CPinBaseImpl_fnEndOfStream,
486 CPinBaseImpl_fnBeginFlush,
487 CPinBaseImpl_fnEndFlush,
488 CPinBaseImpl_fnNewSegment,
489};
490
491
492HRESULT CPinBaseImpl_InitIPin(
493 CPinBaseImpl* This, IUnknown* punkControl,
494 CRITICAL_SECTION* pcsPin,
495 CBaseFilterImpl* pFilter, LPCWSTR pwszId,
496 BOOL bOutput,
497 const CBasePinHandlers* pHandlers )
498{
499 HRESULT hr = NOERROR;
500
501 TRACE("(%p,%p,%p)\n",This,punkControl,pFilter);
502
503 if ( punkControl == NULL )
504 {
505 ERR( "punkControl must not be NULL\n" );
506 return E_INVALIDARG;
507 }
508
509 ICOM_VTBL(This) = &ipin;
510 This->punkControl = punkControl;
511 This->pHandlers = pHandlers;
512 This->cbIdLen = sizeof(WCHAR)*(strlenW(pwszId)+1);
513 This->pwszId = NULL;
514 This->bOutput = bOutput;
515 This->pmtAcceptTypes = NULL;
516 This->cAcceptTypes = 0;
517 This->pcsPin = pcsPin;
518 This->pFilter = pFilter;
519 This->pPinConnectedTo = NULL;
520 This->pmtConn = NULL;
521
522 This->pwszId = (WCHAR*)QUARTZ_AllocMem( This->cbIdLen );
523 if ( This->pwszId == NULL )
524 {
525 hr = E_OUTOFMEMORY;
526 goto err;
527 }
528 memcpy( This->pwszId, pwszId, This->cbIdLen );
529
530 return NOERROR;
531
532err:;
533 CPinBaseImpl_UninitIPin( This );
534 return hr;
535}
536
537void CPinBaseImpl_UninitIPin( CPinBaseImpl* This )
538{
539 TRACE("(%p)\n",This);
540
541 IPin_Disconnect( (IPin*)(This) );
542
543 if ( This->pwszId != NULL )
544 {
545 QUARTZ_FreeMem( This->pwszId );
546 This->pwszId = NULL;
547 }
548}
549
550
551/***************************************************************************
552 *
553 * CMemInputPinBaseImpl
554 *
555 */
556
557
558static HRESULT WINAPI
559CMemInputPinBaseImpl_fnQueryInterface(IMemInputPin* iface,REFIID riid,void** ppobj)
560{
561 ICOM_THIS(CMemInputPinBaseImpl,iface);
562
563 TRACE("(%p)->()\n",This);
564
565 return IUnknown_QueryInterface(This->punkControl,riid,ppobj);
566}
567
568static ULONG WINAPI
569CMemInputPinBaseImpl_fnAddRef(IMemInputPin* iface)
570{
571 ICOM_THIS(CMemInputPinBaseImpl,iface);
572
573 TRACE("(%p)->()\n",This);
574
575 return IUnknown_AddRef(This->punkControl);
576}
577
578static ULONG WINAPI
579CMemInputPinBaseImpl_fnRelease(IMemInputPin* iface)
580{
581 ICOM_THIS(CMemInputPinBaseImpl,iface);
582
583 TRACE("(%p)->()\n",This);
584
585 return IUnknown_Release(This->punkControl);
586}
587
588
589static HRESULT WINAPI
590CMemInputPinBaseImpl_fnGetAllocator(IMemInputPin* iface,IMemAllocator** ppAllocator)
591{
592 ICOM_THIS(CMemInputPinBaseImpl,iface);
593 HRESULT hr = NOERROR;
594 IUnknown* punk;
595
596 TRACE("(%p)->()\n",This);
597
598 if ( ppAllocator == NULL )
599 return E_POINTER;
600
601 EnterCriticalSection( This->pPin->pcsPin );
602
603 if ( This->pAllocator == NULL )
604 {
605 hr = QUARTZ_CreateMemoryAllocator(NULL,(void**)&punk);
606 if ( hr == NOERROR )
607 {
608 hr = IUnknown_QueryInterface(punk,
609 &IID_IMemAllocator,(void**)&This->pAllocator);
610 IUnknown_Release(punk);
611 }
612 }
613
614 if ( hr == NOERROR )
615 {
616 *ppAllocator = This->pAllocator;
617 IMemAllocator_AddRef(This->pAllocator);
618 }
619
620 LeaveCriticalSection( This->pPin->pcsPin );
621
622 return hr;
623}
624
625static HRESULT WINAPI
626CMemInputPinBaseImpl_fnNotifyAllocator(IMemInputPin* iface,IMemAllocator* pAllocator,BOOL bReadonly)
627{
628 ICOM_THIS(CMemInputPinBaseImpl,iface);
629
630 TRACE("(%p)->()\n",This);
631
632 if ( pAllocator == NULL )
633 return E_POINTER;
634
635 EnterCriticalSection( This->pPin->pcsPin );
636
637 if ( This->pAllocator != NULL )
638 {
639 IMemAllocator_Release(This->pAllocator);
640 This->pAllocator = NULL;
641 }
642 This->pAllocator = pAllocator;
643 IMemAllocator_AddRef(This->pAllocator);
644
645 This->bReadonly = bReadonly;
646
647 LeaveCriticalSection( This->pPin->pcsPin );
648
649 return NOERROR;
650}
651
652static HRESULT WINAPI
653CMemInputPinBaseImpl_fnGetAllocatorRequirements(IMemInputPin* iface,ALLOCATOR_PROPERTIES* pProp)
654{
655 ICOM_THIS(CMemInputPinBaseImpl,iface);
656
657 TRACE("(%p)->(%p)\n",This,pProp);
658
659 if ( pProp == NULL )
660 return E_POINTER;
661
662 /* E_MOTIMPL means 'no requirements' */
663 return E_NOTIMPL;
664}
665
666static HRESULT WINAPI
667CMemInputPinBaseImpl_fnReceive(IMemInputPin* iface,IMediaSample* pSample)
668{
669 ICOM_THIS(CMemInputPinBaseImpl,iface);
670 HRESULT hr = E_NOTIMPL;
671
672 TRACE("(%p)->(%p)\n",This,pSample);
673
674 EnterCriticalSection( This->pPin->pcsPin );
675 if ( This->pPin->pHandlers->pReceive != NULL )
676 hr = This->pPin->pHandlers->pReceive(This->pPin,pSample);
677 LeaveCriticalSection( This->pPin->pcsPin );
678
679 return hr;
680}
681
682static HRESULT WINAPI
683CMemInputPinBaseImpl_fnReceiveMultiple(IMemInputPin* iface,IMediaSample** ppSample,long nSample,long* pnSampleProcessed)
684{
685 ICOM_THIS(CMemInputPinBaseImpl,iface);
686 long n;
687 HRESULT hr;
688
689 TRACE("(%p)->()\n",This);
690
691 if ( ppSample == NULL || pnSampleProcessed == NULL )
692 return E_POINTER;
693
694 EnterCriticalSection( This->pPin->pcsPin );
695
696 hr = NOERROR;
697 for ( n = 0; n < nSample; n++ )
698 {
699 hr = IMemInputPin_Receive(iface,ppSample[n]);
700 if ( FAILED(hr) )
701 break;
702 }
703
704 LeaveCriticalSection( This->pPin->pcsPin );
705
706 *pnSampleProcessed = n;
707 return hr;
708}
709
710static HRESULT WINAPI
711CMemInputPinBaseImpl_fnReceiveCanBlock(IMemInputPin* iface)
712{
713 ICOM_THIS(CMemInputPinBaseImpl,iface);
714 HRESULT hr = E_NOTIMPL;
715
716 TRACE("(%p)->()\n",This);
717
718 EnterCriticalSection( This->pPin->pcsPin );
719 if ( This->pPin->pHandlers->pReceiveCanBlock != NULL )
720 hr = This->pPin->pHandlers->pReceiveCanBlock(This->pPin);
721 LeaveCriticalSection( This->pPin->pcsPin );
722
723 return hr;
724}
725
726
727static ICOM_VTABLE(IMemInputPin) imeminputpin =
728{
729 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
730 /* IUnknown fields */
731 CMemInputPinBaseImpl_fnQueryInterface,
732 CMemInputPinBaseImpl_fnAddRef,
733 CMemInputPinBaseImpl_fnRelease,
734 /* IMemInputPin fields */
735 CMemInputPinBaseImpl_fnGetAllocator,
736 CMemInputPinBaseImpl_fnNotifyAllocator,
737 CMemInputPinBaseImpl_fnGetAllocatorRequirements,
738 CMemInputPinBaseImpl_fnReceive,
739 CMemInputPinBaseImpl_fnReceiveMultiple,
740 CMemInputPinBaseImpl_fnReceiveCanBlock,
741};
742
743HRESULT CMemInputPinBaseImpl_InitIMemInputPin(
744 CMemInputPinBaseImpl* This, IUnknown* punkControl,
745 CPinBaseImpl* pPin )
746{
747 TRACE("(%p,%p)\n",This,punkControl);
748
749 if ( punkControl == NULL )
750 {
751 ERR( "punkControl must not be NULL\n" );
752 return E_INVALIDARG;
753 }
754
755 ICOM_VTBL(This) = &imeminputpin;
756 This->punkControl = punkControl;
757 This->pPin = pPin;
758 This->pAllocator = NULL;
759 This->bReadonly = FALSE;
760
761 return NOERROR;
762}
763
764void CMemInputPinBaseImpl_UninitIMemInputPin(
765 CMemInputPinBaseImpl* This )
766{
767 TRACE("(%p)\n",This);
768
769 if ( This->pAllocator != NULL )
770 {
771 IMemAllocator_Release(This->pAllocator);
772 This->pAllocator = NULL;
773 }
774}
775
776/***************************************************************************
777 *
778 * CQualityControlPassThruImpl
779 *
780 */
781
782static HRESULT WINAPI
783CQualityControlPassThruImpl_fnQueryInterface(IQualityControl* iface,REFIID riid,void** ppobj)
784{
785 ICOM_THIS(CQualityControlPassThruImpl,iface);
786
787 TRACE("(%p)->()\n",This);
788
789 return IUnknown_QueryInterface(This->punkControl,riid,ppobj);
790}
791
792static ULONG WINAPI
793CQualityControlPassThruImpl_fnAddRef(IQualityControl* iface)
794{
795 ICOM_THIS(CQualityControlPassThruImpl,iface);
796
797 TRACE("(%p)->()\n",This);
798
799 return IUnknown_AddRef(This->punkControl);
800}
801
802static ULONG WINAPI
803CQualityControlPassThruImpl_fnRelease(IQualityControl* iface)
804{
805 ICOM_THIS(CQualityControlPassThruImpl,iface);
806
807 TRACE("(%p)->()\n",This);
808
809 return IUnknown_Release(This->punkControl);
810}
811
812
813static HRESULT WINAPI
814CQualityControlPassThruImpl_fnNotify(IQualityControl* iface,IBaseFilter* pFilter,Quality q)
815{
816 ICOM_THIS(CQualityControlPassThruImpl,iface);
817 HRESULT hr = S_FALSE;
818
819 TRACE("(%p)->()\n",This);
820
821 if ( This->pControl != NULL )
822 return IQualityControl_Notify( This->pControl, pFilter, q );
823
824 EnterCriticalSection( This->pPin->pcsPin );
825 if ( This->pPin->pHandlers->pQualityNotify != NULL )
826 hr = This->pPin->pHandlers->pQualityNotify(This->pPin,pFilter,q);
827 LeaveCriticalSection( This->pPin->pcsPin );
828
829 return hr;
830}
831
832static HRESULT WINAPI
833CQualityControlPassThruImpl_fnSetSink(IQualityControl* iface,IQualityControl* pControl)
834{
835 ICOM_THIS(CQualityControlPassThruImpl,iface);
836
837 TRACE("(%p)->()\n",This);
838
839 This->pControl = pControl; /* AddRef() must not be called */
840
841 return NOERROR;
842}
843
844static ICOM_VTABLE(IQualityControl) iqualitycontrol =
845{
846 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
847 /* IUnknown fields */
848 CQualityControlPassThruImpl_fnQueryInterface,
849 CQualityControlPassThruImpl_fnAddRef,
850 CQualityControlPassThruImpl_fnRelease,
851 /* IQualityControl fields */
852 CQualityControlPassThruImpl_fnNotify,
853 CQualityControlPassThruImpl_fnSetSink,
854};
855
856HRESULT CQualityControlPassThruImpl_InitIQualityControl(
857 CQualityControlPassThruImpl* This, IUnknown* punkControl,
858 CPinBaseImpl* pPin )
859{
860 TRACE("(%p,%p)\n",This,punkControl);
861
862 if ( punkControl == NULL )
863 {
864 ERR( "punkControl must not be NULL\n" );
865 return E_INVALIDARG;
866 }
867
868 ICOM_VTBL(This) = &iqualitycontrol;
869 This->punkControl = punkControl;
870 This->pPin = pPin;
871
872 return NOERROR;
873}
874
875void CQualityControlPassThruImpl_UninitIQualityControl(
876 CQualityControlPassThruImpl* This )
877{
878}
879
Note: See TracBrowser for help on using the repository browser.