From d731e04a7ffc2bac45e975c9b35a16d3e632a91c Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Thu, 15 Nov 2001 00:37:15 +0000 Subject: direct show updates (audio support working) CVS patchset: 1040 CVS date: 2001/11/15 00:37:15 --- src/libw32dll/DirectShow/DS_AudioDecoder.c | 16 ++--- src/libw32dll/DirectShow/DS_Filter.c | 97 +++++++++++++++++------------- src/libw32dll/DirectShow/Makefile.am | 8 ++- src/libw32dll/DirectShow/outputpin.c | 2 +- src/libw32dll/DirectShow/outputpin.h | 2 +- 5 files changed, 72 insertions(+), 53 deletions(-) diff --git a/src/libw32dll/DirectShow/DS_AudioDecoder.c b/src/libw32dll/DirectShow/DS_AudioDecoder.c index c86da0675..e7a72f220 100644 --- a/src/libw32dll/DirectShow/DS_AudioDecoder.c +++ b/src/libw32dll/DirectShow/DS_AudioDecoder.c @@ -4,7 +4,6 @@ Copyright 2001 Eugene Kuznetsov (divx@euro.ru) *********************************************************/ -#define NOAVIFILE_HEADERS #include "DS_AudioDecoder.h" #include @@ -76,7 +75,12 @@ DS_AudioDecoder * DS_AudioDecoder_Create(const CodecInfo * info, const WAVEFORMA { ALLOCATOR_PROPERTIES props, props1; this->m_pDS_Filter = DS_Filter_Create((const char*)info->dll, &info->guid, &this->m_sOurType, &this->m_sDestType); - DS_Filter_Start(this->m_pDS_Filter); + if( !this->m_pDS_Filter ) { + free(this); + return NULL; + } + + DS_Filter_Start(this->m_pDS_Filter); props.cBuffers=1; props.cbBuffer=this->m_sOurType.lSampleSize; @@ -160,12 +164,10 @@ int DS_AudioDecoder_Convert(DS_AudioDecoder *this, const void* in_data, uint_t i int DS_AudioDecoder_GetSrcSize(DS_AudioDecoder *this, int dest_size) { - double efficiency; - int frames; - - efficiency = (double) this->in_fmt.nAvgBytesPerSec + double efficiency =(double) this->in_fmt.nAvgBytesPerSec / (this->in_fmt.nSamplesPerSec*this->in_fmt.nBlockAlign); - frames = (int)(dest_size*efficiency); + int frames = (int)(dest_size*efficiency);; + if (frames < 1) frames = 1; return frames * this->in_fmt.nBlockAlign; diff --git a/src/libw32dll/DirectShow/DS_Filter.c b/src/libw32dll/DirectShow/DS_Filter.c index 95adb3ccc..7bb7d70ee 100644 --- a/src/libw32dll/DirectShow/DS_Filter.c +++ b/src/libw32dll/DirectShow/DS_Filter.c @@ -1,8 +1,6 @@ #include "DS_Filter.h" #include "../wine/driver.h" -#define NOAVIFILE_HEADERS - #ifndef NOAVIFILE_HEADERS #include "except.h" #else @@ -17,8 +15,6 @@ typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**); -#define FATAL printf - //extern "C" int STDCALL LoadLibraryA(const char*); //extern "C" STDCALL void* GetProcAddress(int, const char*); // STDCALL has to be first NetBSD //extern "C" int STDCALL FreeLibrary(int); @@ -77,11 +73,6 @@ DS_Filter * DS_Filter_Create(const char* dllname, const GUID* id, this->m_iState = 0; CodecAlloc(); - /* __asm__ __volatile__( - "int $0x3\n" : : - );*/ - - /*try*/ { GETCLASS func; @@ -94,32 +85,44 @@ DS_Filter * DS_Filter_Create(const char* dllname, const GUID* id, unsigned int i; this->m_iHandle = LoadLibraryA(dllname); - if (!this->m_iHandle) - FATAL("Could not open DirectShow DLL: %.200s", dllname); - + if (!this->m_iHandle) { + printf("Could not open DirectShow DLL: %.200s\n", dllname); + return NULL; + } + func = (GETCLASS)GetProcAddress(this->m_iHandle, "DllGetClassObject"); - if (!func) - FATAL("Illegal or corrupt DirectShow DLL: %.200s", dllname); - + if (!func) { + printf("Illegal or corrupt DirectShow DLL: %.200s\n", dllname); + return NULL; + } + result = func(id, &IID_IClassFactory, (void**)&factory); - if (result || !factory) - FATAL("No such class object"); - + if (result || !factory) { + printf("No such class object\n"); + return NULL; + } + result = factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object); factory->vt->Release((IUnknown*)factory); - if (result || !object) - FATAL("Class factory failure"); - + if (result || !object) { + printf("Class factory failure\n"); + return NULL; + } + result = object->vt->QueryInterface(object, &IID_IBaseFilter, (void**)&this->m_pFilter); object->vt->Release((IUnknown*)object); - if (result || !this->m_pFilter) - FATAL("Object does not have IBaseFilter interface"); - + if (result || !this->m_pFilter) { + printf("Object does not have IBaseFilter interface\n"); + return NULL; + } + // enumerate pins result = this->m_pFilter->vt->EnumPins(this->m_pFilter, &enum_pins); - if (result || !enum_pins) - FATAL("Could not enumerate pins"); - + if (result || !enum_pins) { + printf("Could not enumerate pins\n"); + return NULL; + } + enum_pins->vt->Reset(enum_pins); result = enum_pins->vt->Next(enum_pins, (ULONG)256, (IPin**)array, &fetched); Debug printf("Pins enumeration returned %ld pins, error is %x\n", fetched, (int)result); @@ -140,22 +143,32 @@ DS_Filter * DS_Filter_Create(const char* dllname, const GUID* id, } array[i]->vt->Release((IUnknown*)(array[i])); } - if (!this->m_pInputPin) - FATAL("Input pin not found"); - if (!this->m_pOutputPin) - FATAL("Output pin not found"); + if (!this->m_pInputPin) { + printf("Input pin not found\n"); + return NULL; + } + + if (!this->m_pOutputPin) { + printf("Output pin not found\n"); + return NULL; + } result = this->m_pInputPin->vt->QueryInterface((IUnknown*)this->m_pInputPin, &IID_IMemInputPin, (void**)&this->m_pImp); - if (result) - FATAL("Error getting IMemInputPin interface"); + if (result) { + printf("Error getting IMemInputPin interface\n"); + return NULL; + } + this->m_pOurType = in_fmt; this->m_pDestType = out_fmt; result = this->m_pInputPin->vt->QueryAccept(this->m_pInputPin, this->m_pOurType); - if (result) - FATAL("Source format is not accepted"); - + if (result) { + printf("Source format is not accepted\n"); + return NULL; + } + this->m_pParentFilter = CBaseFilter2_Create(); this->m_pSrcFilter = CBaseFilter_Create(this->m_pOurType, this->m_pParentFilter); this->m_pOurInput = CBaseFilter_GetPin(this->m_pSrcFilter); @@ -164,9 +177,10 @@ DS_Filter * DS_Filter_Create(const char* dllname, const GUID* id, result = this->m_pInputPin->vt->ReceiveConnection(this->m_pInputPin, this->m_pOurInput, this->m_pOurType); - if (result) - FATAL("Error connecting to input pin"); - + if (result) { + printf("Error connecting to input pin\n"); + return NULL; + } this->m_pOurOutput = COutputPin_Create(this->m_pDestType); //extern void trapbug(); @@ -177,14 +191,15 @@ DS_Filter * DS_Filter_Create(const char* dllname, const GUID* id, if (result) { //printf("Tracking ACELP %d 0%x\n", result); - FATAL("Error connecting to output pin"); + printf("Error connecting to output pin\n"); + return NULL; } printf("Using DirectShow codec: %s\n", dllname); this->m_iState = 1; } /* - catch (FatalError& e) + catch (printfError& e) { //e.PrintAll(); destroy(); diff --git a/src/libw32dll/DirectShow/Makefile.am b/src/libw32dll/DirectShow/Makefile.am index dab35bb05..06f770682 100644 --- a/src/libw32dll/DirectShow/Makefile.am +++ b/src/libw32dll/DirectShow/Makefile.am @@ -3,20 +3,22 @@ noinst_LTLIBRARIES = libds_filter.la noinst_HEADERS = DS_Filter.h allocator.h cmediasample.h \ guids.h inputpin.h interfaces.h iunk.h outputpin.h \ - DS_AudioDecoder.h + DS_AudioDecoder.h +# DS_VideoDecoder.h libds_filter_la_SOURCES = guids.c inputpin.c outputpin.c allocator.c \ cmediasample.c DS_Filter.c DS_AudioDecoder.c +# DS_VideoDecoder.c ## ## CFLAGS = @GLOBAL_CFLAGS@ @X_CFLAGS@ -fno-omit-frame-pointer \ -Wmissing-prototypes -Wimplicit-function-declaration \ - -DWIN32_PATH=\"@w32_path@\" + -DWIN32_PATH=\"@w32_path@\" -DNOAVIFILE_HEADERS DEBUG_CFLAGS = @DEBUG_CFLAGS@ @X_CFLAGS@ -fno-omit-frame-pointer \ -Wmissing-prototypes -Wimplicit-function-declaration \ - -DWIN32_PATH=\\\"@w32_path@\\\" + -DWIN32_PATH=\\\"@w32_path@\\\" -DNOAVIFILE_HEADERS if HAVE_W32DLL ds_filter_lib = libds_filter.la diff --git a/src/libw32dll/DirectShow/outputpin.c b/src/libw32dll/DirectShow/outputpin.c index 739ea0a9e..32c8d153e 100644 --- a/src/libw32dll/DirectShow/outputpin.c +++ b/src/libw32dll/DirectShow/outputpin.c @@ -491,5 +491,5 @@ void COutputPin_SetPointer2(COutputPin *this,char* p) void COutputPin_SetFrameSizePointer(COutputPin *this,long* z) { this->mempin->frame_size_pointer = z; } -void COutputPin_SetNewFormat(COutputPin *this,const AM_MEDIA_TYPE * a) +void COutputPin_SetNewFormat(COutputPin *this, AM_MEDIA_TYPE * a) { memcpy(&this->type,a,sizeof(AM_MEDIA_TYPE)); } diff --git a/src/libw32dll/DirectShow/outputpin.h b/src/libw32dll/DirectShow/outputpin.h index 6313f5525..8f4fe1f63 100644 --- a/src/libw32dll/DirectShow/outputpin.h +++ b/src/libw32dll/DirectShow/outputpin.h @@ -36,6 +36,6 @@ void COutputPin_SetPointer2(COutputPin *this,char* p); void COutputPin_SetFrameSizePointer(COutputPin *this,long* z); -void COutputPin_SetNewFormat(COutputPin *this,const AM_MEDIA_TYPE * a); +void COutputPin_SetNewFormat(COutputPin *this, AM_MEDIA_TYPE * a); #endif /* DS_OUTPUTPIN_H */ -- cgit v1.2.3