// return a non-addrefed CBasePin * for the user to addref if he holds onto it
// for longer than his pointer to us. We create the pins dynamically when they
// are asked for rather than in the constructor. This is because we want to
// give the derived class an oppportunity to return different pin objects
// As soon as any pin is needed we create both (this is different from the
// usual transform filter) because enumerators, allocators etc are passed
// through from one pin to another and it becomes very painful if the other
// pin isn\'t there. If we fail to create either pin we ensure we fail both.
CBasePin *
CTransInPlaceFilter::GetPin(int n)
{
HRESULT hr = S_OK;
// Create an input pin if not already done
if (m_pInput == NULL) {
m_pInput = new CTransInPlaceInputPin( NAME(\"TransInPlace input pin\")
, this // Owner filter
, &hr // Result code
, L\"Input\" // Pin name
);
// Constructor for CTransInPlaceInputPin can\'t fail
ASSERT(SUCCEEDED(hr));
}
// Create an output pin if not already done
if (m_pInput!=NULL && m_pOutput == NULL) {
m_pOutput = new CTransInPlaceOutputPin( NAME(\"TransInPlace output pin\")
, this // Owner filter
, &hr // Result code
, L\"Output\" // Pin name
);
// a failed return code should delete the object
ASSERT(SUCCEEDED(hr));
if (m_pOutput == NULL) {
delete m_pInput;
m_pInput = NULL;
}
}
// Return the appropriate pin
ASSERT (n>=0 && n<=1);
if (n == 0) {
return m_pInput;
} else if (n==1) {
return m_pOutput;
} else {
return NULL;
}
} // GetPin
|