From e33a1695bab717d2dd3a7e5c289ed822437b187f Mon Sep 17 00:00:00 2001 From: voroshil Date: Fri, 23 Feb 2007 08:07:07 +0000 Subject: Fixed loading of VoxWare and wma9sp binary audio codecs using dshow engine. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22322 b3059339-0415-0410-9bf9-f77b7e298cf2 --- loader/dshow/DS_AudioDecoder.c | 9 +++------ loader/dshow/DS_Filter.c | 38 ++++++++++++++++++++++++++------------ loader/dshow/DS_VideoDecoder.c | 8 +------- loader/dshow/allocator.c | 10 ++++++++-- 4 files changed, 38 insertions(+), 27 deletions(-) (limited to 'loader/dshow') diff --git a/loader/dshow/DS_AudioDecoder.c b/loader/dshow/DS_AudioDecoder.c index a67509f2fb..c2ab624b46 100644 --- a/loader/dshow/DS_AudioDecoder.c +++ b/loader/dshow/DS_AudioDecoder.c @@ -104,14 +104,11 @@ DS_AudioDecoder * DS_AudioDecoder_Open(char* dllname, GUID* guid, WAVEFORMATEX* return NULL; } + //Commit should be done before binary codec start + this->m_pDS_Filter->m_pAll->vt->Commit(this->m_pDS_Filter->m_pAll); + this->m_pDS_Filter->Start(this->m_pDS_Filter); - props.cBuffers=1; - props.cbBuffer=this->m_sOurType.lSampleSize; - props.cbAlign=1; - props.cbPrefix=0; - this->m_pDS_Filter->m_pAll->vt->SetProperties(this->m_pDS_Filter->m_pAll, &props, &props1); - this->m_pDS_Filter->m_pAll->vt->Commit(this->m_pDS_Filter->m_pAll); } /* catch (FatalError& e) diff --git a/loader/dshow/DS_Filter.c b/loader/dshow/DS_Filter.c index 7d3b31ddc8..8d11c170cc 100644 --- a/loader/dshow/DS_Filter.c +++ b/loader/dshow/DS_Filter.c @@ -37,24 +37,12 @@ static void DS_Filter_Start(DS_Filter* This) { HRESULT hr; - if (This->m_pAll) - return; - //Debug printf("DS_Filter_Start(%p)\n", This); hr = This->m_pFilter->vt->Run(This->m_pFilter, (REFERENCE_TIME)0); if (hr != 0) { Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr); } - hr = This->m_pImp->vt->GetAllocator(This->m_pImp, &This->m_pAll); - - if (hr || !This->m_pAll) - { - Debug printf("WARNING: error getting IMemAllocator interface %x\n", (int)hr); - This->m_pImp->vt->Release((IUnknown*)This->m_pImp); - return; - } - This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0); } static void DS_Filter_Stop(DS_Filter* This) @@ -114,6 +102,8 @@ DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, int init = 0; // char eb[250]; const char* em = NULL; + MemAllocator* tempAll; + ALLOCATOR_PROPERTIES props,props1; HRESULT result; DS_Filter* This = (DS_Filter*) malloc(sizeof(DS_Filter)); if (!This) @@ -125,6 +115,13 @@ DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, CoInitialize(0L); #endif + /* + tempAll is not used anywhere. + MemAllocatorCreate() is called to ensure that RegisterComObject for IMemoryAllocator + will be called before possible call + to CoCreateInstance(...,&IID_IMemoryAllocator,...) from binary codec. + */ + tempAll=MemAllocatorCreate(); This->m_pFilter = NULL; This->m_pInputPin = NULL; This->m_pOutputPin = NULL; @@ -248,6 +245,22 @@ DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, em = "could not connect to input pin"; break; } + result = This->m_pImp->vt->GetAllocator(This->m_pImp, &This->m_pAll); + if (result || !This->m_pAll) + { + em="error getting IMemAllocator interface"; + break; + } + + //Seting allocator property according to our media type + props.cBuffers=1; + props.cbBuffer=This->m_pOurType->lSampleSize; + props.cbAlign=1; + props.cbPrefix=0; + This->m_pAll->vt->SetProperties(This->m_pAll, &props, &props1); + + //Notify remote pin about choosed allocator + This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0); This->m_pOurOutput = COutputPinCreate(This->m_pDestType); @@ -263,6 +276,7 @@ DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id, init++; break; } + tempAll->vt->Release(tempAll); if (!init) { diff --git a/loader/dshow/DS_VideoDecoder.c b/loader/dshow/DS_VideoDecoder.c index 248938dbf3..cfeedc0c3c 100644 --- a/loader/dshow/DS_VideoDecoder.c +++ b/loader/dshow/DS_VideoDecoder.c @@ -278,14 +278,8 @@ void DS_VideoDecoder_StartInternal(DS_VideoDecoder *this) ALLOCATOR_PROPERTIES props, props1; Debug printf("DS_VideoDecoder_StartInternal\n"); //cout << "DSSTART" << endl; - this->m_pDS_Filter->Start(this->m_pDS_Filter); - - props.cBuffers = 1; - props.cbBuffer = this->m_sDestType.lSampleSize; - props.cbAlign = 1; - props.cbPrefix = 0; - this->m_pDS_Filter->m_pAll->vt->SetProperties(this->m_pDS_Filter->m_pAll, &props, &props1); this->m_pDS_Filter->m_pAll->vt->Commit(this->m_pDS_Filter->m_pAll); + this->m_pDS_Filter->Start(this->m_pDS_Filter); this->iv.m_State = START; } diff --git a/loader/dshow/allocator.c b/loader/dshow/allocator.c index 3e2fc8c017..7eef9ada0f 100644 --- a/loader/dshow/allocator.c +++ b/loader/dshow/allocator.c @@ -146,8 +146,14 @@ static HRESULT STDCALL MemAllocator_SetProperties(IMemAllocator * This, return E_FAIL; *pActual = *pRequest; - //if (pActual->cbBuffer == 2) - // pActual->cbBuffer = 576; + /* + DirectShow DOCS ("Negotiating Allocators" chapter) says that allocator might not + honor the requested properties. Thus, since WMSP audio codecs requests bufer with two + bytes length for unknown reason, we should correct requested value. Otherwise above + codec don't want to load. + */ + if (pActual->cbBuffer == 2) + pActual->cbBuffer = 10240; //Enough for WMSP codec me->props = *pActual; -- cgit v1.2.3