comparison 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
comparison
equal deleted inserted replaced
22303:14ed9bf94b71 22304:254733f57707
35 35
36 static void DS_Filter_Start(DS_Filter* This) 36 static void DS_Filter_Start(DS_Filter* This)
37 { 37 {
38 HRESULT hr; 38 HRESULT hr;
39 39
40 if (This->m_pAll)
41 return;
42
43 //Debug printf("DS_Filter_Start(%p)\n", This); 40 //Debug printf("DS_Filter_Start(%p)\n", This);
44 hr = This->m_pFilter->vt->Run(This->m_pFilter, (REFERENCE_TIME)0); 41 hr = This->m_pFilter->vt->Run(This->m_pFilter, (REFERENCE_TIME)0);
45 if (hr != 0) 42 if (hr != 0)
46 { 43 {
47 Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr); 44 Debug printf("WARNING: m_Filter->Run() failed, error code %x\n", (int)hr);
48 } 45 }
49 hr = This->m_pImp->vt->GetAllocator(This->m_pImp, &This->m_pAll);
50
51 if (hr || !This->m_pAll)
52 {
53 Debug printf("WARNING: error getting IMemAllocator interface %x\n", (int)hr);
54 This->m_pImp->vt->Release((IUnknown*)This->m_pImp);
55 return;
56 }
57 This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0);
58 } 46 }
59 47
60 static void DS_Filter_Stop(DS_Filter* This) 48 static void DS_Filter_Stop(DS_Filter* This)
61 { 49 {
62 if (This->m_pAll) 50 if (This->m_pAll)
112 AM_MEDIA_TYPE* out_fmt) 100 AM_MEDIA_TYPE* out_fmt)
113 { 101 {
114 int init = 0; 102 int init = 0;
115 // char eb[250]; 103 // char eb[250];
116 const char* em = NULL; 104 const char* em = NULL;
105 MemAllocator* tempAll;
106 ALLOCATOR_PROPERTIES props,props1;
117 HRESULT result; 107 HRESULT result;
118 DS_Filter* This = (DS_Filter*) malloc(sizeof(DS_Filter)); 108 DS_Filter* This = (DS_Filter*) malloc(sizeof(DS_Filter));
119 if (!This) 109 if (!This)
120 return NULL; 110 return NULL;
121 111
123 CodecAlloc(); 113 CodecAlloc();
124 #else 114 #else
125 CoInitialize(0L); 115 CoInitialize(0L);
126 #endif 116 #endif
127 117
118 /*
119 tempAll is not used anywhere.
120 MemAllocatorCreate() is called to ensure that RegisterComObject for IMemoryAllocator
121 will be called before possible call
122 to CoCreateInstance(...,&IID_IMemoryAllocator,...) from binary codec.
123 */
124 tempAll=MemAllocatorCreate();
128 This->m_pFilter = NULL; 125 This->m_pFilter = NULL;
129 This->m_pInputPin = NULL; 126 This->m_pInputPin = NULL;
130 This->m_pOutputPin = NULL; 127 This->m_pOutputPin = NULL;
131 This->m_pSrcFilter = NULL; 128 This->m_pSrcFilter = NULL;
132 This->m_pParentFilter = NULL; 129 This->m_pParentFilter = NULL;
246 if (result) 243 if (result)
247 { 244 {
248 em = "could not connect to input pin"; 245 em = "could not connect to input pin";
249 break; 246 break;
250 } 247 }
248 result = This->m_pImp->vt->GetAllocator(This->m_pImp, &This->m_pAll);
249 if (result || !This->m_pAll)
250 {
251 em="error getting IMemAllocator interface";
252 break;
253 }
254
255 //Seting allocator property according to our media type
256 props.cBuffers=1;
257 props.cbBuffer=This->m_pOurType->lSampleSize;
258 props.cbAlign=1;
259 props.cbPrefix=0;
260 This->m_pAll->vt->SetProperties(This->m_pAll, &props, &props1);
261
262 //Notify remote pin about choosed allocator
263 This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0);
251 264
252 This->m_pOurOutput = COutputPinCreate(This->m_pDestType); 265 This->m_pOurOutput = COutputPinCreate(This->m_pDestType);
253 266
254 result = This->m_pOutputPin->vt->ReceiveConnection(This->m_pOutputPin, 267 result = This->m_pOutputPin->vt->ReceiveConnection(This->m_pOutputPin,
255 (IPin*) This->m_pOurOutput, 268 (IPin*) This->m_pOurOutput,
261 } 274 }
262 275
263 init++; 276 init++;
264 break; 277 break;
265 } 278 }
279 tempAll->vt->Release(tempAll);
266 280
267 if (!init) 281 if (!init)
268 { 282 {
269 DS_Filter_Destroy(This); 283 DS_Filter_Destroy(This);
270 printf("Warning: DS_Filter() %s. (DLL=%.200s, r=0x%x)\n", em, dllname, result); 284 printf("Warning: DS_Filter() %s. (DLL=%.200s, r=0x%x)\n", em, dllname, result);