ReactOS  0.4.15-dev-484-g89e716a7
output_pin.cpp File Reference
#include "precomp.h"
Include dependency graph for output_pin.cpp:

Go to the source code of this file.

Classes

class  COutputPin
 

Functions

DWORD WINAPI COutputPin_IoThreadStartup (LPVOID lpParameter)
 
HRESULT STDMETHODCALLTYPE COutputPin_SetState (IPin *Pin, KSSTATE State)
 
HRESULT WINAPI COutputPin_Constructor (IBaseFilter *ParentFilter, LPCWSTR PinName, ULONG PinId, KSPIN_COMMUNICATION Communication, REFIID riid, LPVOID *ppv)
 

Function Documentation

◆ COutputPin_Constructor()

HRESULT WINAPI COutputPin_Constructor ( IBaseFilter ParentFilter,
LPCWSTR  PinName,
ULONG  PinId,
KSPIN_COMMUNICATION  Communication,
REFIID  riid,
LPVOID ppv 
)

Definition at line 2801 of file output_pin.cpp.

2808 {
2809  COutputPin * handler = new COutputPin(ParentFilter, PinName, PinId, Communication);
2810 
2811  if (!handler)
2812  return E_OUTOFMEMORY;
2813 
2814  if (FAILED(handler->QueryInterface(riid, ppv)))
2815  {
2816  /* not supported */
2817  delete handler;
2818  return E_NOINTERFACE;
2819  }
2820 
2821  return S_OK;
2822 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_OK
Definition: intsafe.h:59
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786

Referenced by CKsProxy::CreatePins().

◆ COutputPin_IoThreadStartup()

DWORD WINAPI COutputPin_IoThreadStartup ( LPVOID  lpParameter)

Definition at line 2554 of file output_pin.cpp.

2556 {
2558  assert(Pin);
2559 
2560  return Pin->IoProcessRoutine();
2561 }
#define assert(x)
Definition: debug.h:53
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
LPVOID lpParameter
Definition: kernel32.h:241

◆ COutputPin_SetState()

HRESULT STDMETHODCALLTYPE COutputPin_SetState ( IPin Pin,
KSSTATE  State 
)

Definition at line 2607 of file output_pin.cpp.

2610 {
2611  HRESULT hr = S_OK;
2613  KSSTATE CurState;
2615  COutputPin * pPin = (COutputPin*)Pin;
2616 
2617 #ifdef KSPROXY_TRACE
2618  WCHAR Buffer[200];
2619 #endif
2620 
2623  Property.Flags = KSPROPERTY_TYPE_SET;
2624 
2625  EnterCriticalSection(&pPin->m_Lock);
2626 
2627  if (pPin->m_State <= State)
2628  {
2629  if (pPin->m_State == KSSTATE_STOP)
2630  {
2631  hr = pPin->InitializeIOThread();
2632  if (FAILED(hr))
2633  {
2634  // failed to initialize I/O thread
2635 #ifdef KSPROXY_TRACE
2636  OutputDebugStringW(L"Failed to initialize I/O Thread\n");
2637 #endif
2638  LeaveCriticalSection(&pPin->m_Lock);
2639  return hr;
2640  }
2641  CurState = KSSTATE_ACQUIRE;
2642  hr = pPin->KsProperty(&Property, sizeof(KSPROPERTY), &CurState, sizeof(KSSTATE), &BytesReturned);
2643 
2644 #ifdef KSPROXY_TRACE
2645  swprintf(Buffer, L"COutputPin_SetState Setting State CurState: KSSTATE_STOP KSSTATE_ACQUIRE PinName %s hr %lx\n", pPin->m_PinName, hr);
2647 #endif
2648 
2649  if (FAILED(hr))
2650  {
2651  LeaveCriticalSection(&pPin->m_Lock);
2652  return hr;
2653  }
2654 
2655  pPin->m_State = CurState;
2656 
2657  if (pPin->m_State == State)
2658  {
2659  LeaveCriticalSection(&pPin->m_Lock);
2660  return hr;
2661  }
2662  }
2663  if (pPin->m_State == KSSTATE_ACQUIRE)
2664  {
2665  CurState = KSSTATE_PAUSE;
2666  hr = pPin->KsProperty(&Property, sizeof(KSPROPERTY), &CurState, sizeof(KSSTATE), &BytesReturned);
2667 
2668 #ifdef KSPROXY_TRACE
2669  swprintf(Buffer, L"COutputPin_SetState Setting State CurState KSSTATE_ACQUIRE KSSTATE_PAUSE PinName %s hr %lx\n", pPin->m_PinName, hr);
2671 #endif
2672 
2673  if (FAILED(hr))
2674  {
2675  LeaveCriticalSection(&pPin->m_Lock);
2676  return hr;
2677  }
2678 
2679  pPin->m_State = CurState;
2680 
2681  if (pPin->m_State == State)
2682  {
2683  LeaveCriticalSection(&pPin->m_Lock);
2684  return hr;
2685  }
2686  }
2687  if (State == KSSTATE_RUN && pPin->m_State == KSSTATE_PAUSE)
2688  {
2689  CurState = KSSTATE_RUN;
2690  hr = pPin->KsProperty(&Property, sizeof(KSPROPERTY), &CurState, sizeof(KSSTATE), &BytesReturned);
2691 
2692 #ifdef KSPROXY_TRACE
2693  swprintf(Buffer, L"COutputPin_SetState Setting State CurState: KSSTATE_PAUSE KSSTATE_RUN PinName %s hr %lx\n", pPin->m_PinName, hr);
2695 #endif
2696 
2697  if (SUCCEEDED(hr))
2698  {
2699  pPin->m_State = CurState;
2700  // signal start event
2701  SetEvent(pPin->m_hStartEvent);
2702  }
2703  }
2704 
2705  LeaveCriticalSection(&pPin->m_Lock);
2706  return hr;
2707  }
2708  else
2709  {
2710  if (pPin->m_State == KSSTATE_RUN)
2711  {
2712  // setting pending stop flag
2713  pPin->m_StopInProgress = true;
2714 
2715  // release any waiting threads
2717 
2718  // wait until i/o thread is done
2720 
2721  CurState = KSSTATE_PAUSE;
2722  hr = pPin->KsProperty(&Property, sizeof(KSPROPERTY), &CurState, sizeof(KSSTATE), &BytesReturned);
2723 
2724 #ifdef KSPROXY_TRACE
2725  swprintf(Buffer, L"COutputPin_SetState Setting State CurState: KSSTATE_RUN KSSTATE_PAUSE PinName %s hr %lx\n", pPin->m_PinName, hr);
2727 #endif
2728 
2729  if (FAILED(hr))
2730  {
2731  LeaveCriticalSection(&pPin->m_Lock);
2732  return hr;
2733  }
2734 
2735  pPin->m_State = CurState;
2736 
2737  if (FAILED(hr))
2738  {
2739  LeaveCriticalSection(&pPin->m_Lock);
2740  return hr;
2741  }
2742  }
2743  if (pPin->m_State == KSSTATE_PAUSE)
2744  {
2745  CurState = KSSTATE_ACQUIRE;
2746  hr = pPin->KsProperty(&Property, sizeof(KSPROPERTY), &CurState, sizeof(KSSTATE), &BytesReturned);
2747 
2748 #ifdef KSPROXY_TRACE
2749  swprintf(Buffer, L"COutputPin_SetState Setting State CurState: KSSTATE_PAUSE KSSTATE_ACQUIRE PinName %s hr %lx\n", pPin->m_PinName, hr);
2751 #endif
2752 
2753  if (FAILED(hr))
2754  {
2755  LeaveCriticalSection(&pPin->m_Lock);
2756  return hr;
2757  }
2758 
2759  pPin->m_State = CurState;
2760 
2761  if (pPin->m_State == State)
2762  {
2763  LeaveCriticalSection(&pPin->m_Lock);
2764  return hr;
2765  }
2766  }
2767 
2768  CloseHandle(pPin->m_hStopEvent);
2769  CloseHandle(pPin->m_hStartEvent);
2771 
2772  /* close event handles */
2773  pPin->m_hStopEvent = NULL;
2774  pPin->m_hStartEvent = NULL;
2775  pPin->m_hBufferAvailable = NULL;
2776 
2777  CurState = KSSTATE_STOP;
2778  hr = pPin->KsProperty(&Property, sizeof(KSPROPERTY), &CurState, sizeof(KSSTATE), &BytesReturned);
2779 
2780 #ifdef KSPROXY_TRACE
2781  swprintf(Buffer, L"COutputPin_SetState Setting State CurState: KSSTATE_ACQUIRE KSSTATE_STOP PinName %s hr %lx\n", pPin->m_PinName, hr);
2783 #endif
2784 
2785  if (SUCCEEDED(hr))
2786  {
2787  // store state
2788  pPin->m_State = CurState;
2789  }
2790 
2791  // unset pending stop flag
2792  pPin->m_StopInProgress = false;
2793 
2794  LeaveCriticalSection(&pPin->m_Lock);
2795  return hr;
2796  }
2797 }
BOOL m_StopInProgress
Definition: output_pin.cpp:201
HANDLE m_hBufferAvailable
Definition: output_pin.cpp:199
#define CloseHandle
Definition: compat.h:407
HRESULT hr
Definition: shlfolder.c:183
LPCWSTR m_PinName
Definition: output_pin.cpp:176
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define KSPROPSETID_Connection
Definition: ks.h:346
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
HRESULT WINAPI InitializeIOThread()
IN PDCB IN VBO IN ULONG IN BOOLEAN Pin
Definition: fatprocs.h:424
HANDLE m_hStartEvent
Definition: output_pin.cpp:198
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const WCHAR L[]
Definition: oid.c:1250
_In_ DWORD Property
Definition: setupapi.h:1545
#define S_OK
Definition: intsafe.h:59
KSSTATE m_State
Definition: output_pin.cpp:204
KSSTATE
Definition: ks.h:1214
HANDLE m_hStopEvent
Definition: output_pin.cpp:200
_In_ FILTER_INFORMATION_CLASS _In_ ULONG _Out_ PULONG BytesReturned
Definition: fltkernel.h:1716
unsigned int ULONG
Definition: retypes.h:1
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define INFINITE
Definition: serial.h:102
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
HRESULT STDMETHODCALLTYPE KsProperty(PKSPROPERTY Property, ULONG PropertyLength, LPVOID PropertyData, ULONG DataLength, ULONG *BytesReturned)
#define SUCCEEDED(hr)
Definition: intsafe.h:57
CRITICAL_SECTION m_Lock
Definition: output_pin.cpp:205

Referenced by CKsProxy::SetPinState().