diff loader/dshow/DS_Filter.c @ 22304:254733f57707

Fixed loading of VoxWare and wma9sp binary audio codecs using dshow engine.
author voroshil
date Fri, 23 Feb 2007 08:07:07 +0000
parents 0783dd397f74
children 49f01f8fbd60
line wrap: on
line diff
--- a/loader/dshow/DS_Filter.c	Fri Feb 23 03:08:54 2007 +0000
+++ b/loader/dshow/DS_Filter.c	Fri Feb 23 08:07:07 2007 +0000
@@ -37,24 +37,12 @@
 {
     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 @@
     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 @@
     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 @@
 	    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 @@
 	init++;
         break;
     }
+    tempAll->vt->Release(tempAll);
 
     if (!init)
     {