//Initialization HRESULT CTimeStretchFilter::Init() { HRESULT hr = InitAllocator(); if (FAILED(hr)) return hr; m_hSampleEvents.push_back(m_hInputAvailableEvent); m_hSampleEvents.push_back(m_hOOBCommandAvailableEvent); m_hSampleEvents.push_back(m_hStopThreadEvent); m_dwSampleWaitObjects.push_back(S_OK); m_dwSampleWaitObjects.push_back(MPAR_S_OOB_COMMAND_AVAILABLE); m_dwSampleWaitObjects.push_back(MPAR_S_THREAD_STOPPING); setTempoChange(0); setPitchSemiTones(0); setSetting(SETTING_USE_QUICKSEEK, m_pSettings->m_bQuality_USE_QUICKSEEK); setSetting(SETTING_USE_AA_FILTER, m_pSettings->m_bQuality_USE_AA_FILTER); setSetting(SETTING_AA_FILTER_LENGTH, m_pSettings->m_lQuality_AA_FILTER_LENGTH); setSetting(SETTING_SEQUENCE_MS, m_pSettings->m_lQuality_SEQUENCE_MS); setSetting(SETTING_SEEKWINDOW_MS, m_pSettings->m_lQuality_SEEKWINDOW_MS); setSetting(SETTING_OVERLAP_MS, m_pSettings->m_lQuality_SEQUENCE_MS); return CQueuedAudioSink::Init(); }
HRESULT CChannelMixer::Init() { HRESULT hr = InitAllocator(); if (FAILED(hr)) return hr; return CBaseAudioSink::Init(); }
HRESULT CSampleRateConverter::Init() { HRESULT hr = InitAllocator(); if (FAILED(hr)) return hr; return CBaseAudioSink::Init(); }
// we need to return an addref'ed allocator, even if it is the preferred // one, since he doesn't know whether it is the preferred one or not. STDMETHODIMP CAsyncOutputPin::RequestAllocator( IMemAllocator* pPreferred, ALLOCATOR_PROPERTIES* pProps, IMemAllocator ** ppActual) { CheckPointer(pProps, E_POINTER); ASSERT(m_pIo); // we care about alignment but nothing else if (!pProps->cbAlign || !m_pIo->IsAligned(pProps->cbAlign)) m_pIo->Alignment(&pProps->cbAlign); ALLOCATOR_PROPERTIES Actual; HRESULT hr; if (pPreferred) { hr = pPreferred->SetProperties(pProps, &Actual); if (SUCCEEDED(hr) && m_pIo->IsAligned(Actual.cbAlign)) { pPreferred->AddRef(); *ppActual = pPreferred; return S_OK; } } // create our own allocator IMemAllocator* pAlloc; hr = InitAllocator(&pAlloc); if (FAILED(hr)) return hr; //...and see if we can make it suitable hr = pAlloc->SetProperties(pProps, &Actual); if (SUCCEEDED(hr) && m_pIo->IsAligned(Actual.cbAlign)) { // we need to release our refcount on pAlloc, and addref // it to pass a refcount to the caller - this is a net nothing. *ppActual = pAlloc; return S_OK; } // failed to find a suitable allocator pAlloc->Release(); // if we failed because of the IsAligned test, the error code will // not be failure if (SUCCEEDED(hr)) hr = VFW_E_BADALIGN; return hr; }
HRESULT OutpinVideo::PostConnectVideo(IPin* p) { GraphUtil::IMemInputPinPtr pInputPin; HRESULT hr = p->QueryInterface(&pInputPin); if (FAILED(hr)) return hr; GraphUtil::IMemAllocatorPtr pAllocator; hr = CVP8Sample::CreateAllocator(&pAllocator); if (FAILED(hr)) return VFW_E_NO_ALLOCATOR; return InitAllocator(pInputPin, pAllocator); }
HRESULT CBaseOutputPin::DecideAllocator(IMemInputPin *pPin, IMemAllocator **ppAlloc) { HRESULT hr = NOERROR; *ppAlloc = NULL; // get downstream prop request // the derived class may modify this in DecideBufferSize, but // we assume that he will consistently modify it the same way, // so we only get it once ALLOCATOR_PROPERTIES prop; ZeroMemory(&prop, sizeof(prop)); // whatever he returns, we assume prop is either all zeros // or he has filled it out. pPin->GetAllocatorRequirements(&prop); // if he doesn't care about alignment, then set it to 1 if (prop.cbAlign == 0) { prop.cbAlign = 1; } /* Try the allocator provided by the input pin */ hr = pPin->GetAllocator(ppAlloc); if (SUCCEEDED(hr)) { hr = DecideBufferSize(*ppAlloc, &prop); if (SUCCEEDED(hr)) { hr = pPin->NotifyAllocator(*ppAlloc, FALSE); if (SUCCEEDED(hr)) { return NOERROR; } } } /* If the GetAllocator failed we may not have an interface */ if (*ppAlloc) { (*ppAlloc)->Release(); *ppAlloc = NULL; } /* Try the output pin's allocator by the same method */ hr = InitAllocator(ppAlloc); if (SUCCEEDED(hr)) { // note - the properties passed here are in the same // structure as above and may have been modified by // the previous call to DecideBufferSize hr = DecideBufferSize(*ppAlloc, &prop); if (SUCCEEDED(hr)) { hr = pPin->NotifyAllocator(*ppAlloc, FALSE); if (SUCCEEDED(hr)) { return NOERROR; } } } /* Likewise we may not have an interface to release */ if (*ppAlloc) { (*ppAlloc)->Release(); *ppAlloc = NULL; } return hr; }