summaryrefslogtreecommitdiffstats
path: root/loader
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-09-13 19:43:17 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-09-13 19:43:17 +0000
commitc7eafc3610b65eafe408d4959ded4c1aab44157a (patch)
tree18e034fefe8c9e37af6f49a902ca3bfe887531c4 /loader
parent0f6fe4b67312a11395c372831f7228fc78752714 (diff)
downloadmpv-c7eafc3610b65eafe408d4959ded4c1aab44157a.tar.bz2
mpv-c7eafc3610b65eafe408d4959ded4c1aab44157a.tar.xz
avifile sync - 95% cosmetics 5% bug
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7387 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'loader')
-rw-r--r--loader/afl.c94
-rw-r--r--loader/com.h25
-rw-r--r--loader/driver.c248
-rw-r--r--loader/driver.h21
-rw-r--r--loader/dshow/DS_Filter.c6
-rw-r--r--loader/dshow/allocator.c10
-rw-r--r--loader/dshow/allocator.h9
-rw-r--r--loader/dshow/cmediasample.c3
-rw-r--r--loader/dshow/guids.c63
-rw-r--r--loader/dshow/guids.h95
-rw-r--r--loader/dshow/inputpin.c2
-rw-r--r--loader/dshow/inputpin.h9
-rw-r--r--loader/dshow/interfaces.h37
-rw-r--r--loader/dshow/iunk.h5
-rw-r--r--loader/dshow/outputpin.c49
-rw-r--r--loader/dshow/outputpin.h12
-rw-r--r--loader/elfdll.c30
-rw-r--r--loader/ext.c27
-rw-r--r--loader/ext.h2
-rw-r--r--loader/ldt_keeper.c91
-rw-r--r--loader/ldt_keeper.h11
-rw-r--r--loader/loader.h267
-rw-r--r--loader/module.c40
-rw-r--r--loader/module.h6
-rw-r--r--loader/pe_image.c28
-rw-r--r--loader/pe_resource.c16
-rw-r--r--loader/registry.c117
-rw-r--r--loader/resource.c25
-rw-r--r--loader/win32.c268
-rw-r--r--loader/win32.h21
-rw-r--r--loader/wine/avifmt.h2
-rw-r--r--loader/wine/mmreg.h8
-rw-r--r--loader/wine/module.h10
-rw-r--r--loader/wine/msacm.h3
-rw-r--r--loader/wine/pe_image.h2
-rw-r--r--loader/wine/vfw.h24
-rw-r--r--loader/wineacm.h25
37 files changed, 753 insertions, 958 deletions
diff --git a/loader/afl.c b/loader/afl.c
index d80ffbd6f1..d1024b1a55 100644
--- a/loader/afl.c
+++ b/loader/afl.c
@@ -21,12 +21,6 @@
***************************************************************************/
#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "win32.h"
-
#include "wine/winbase.h"
#include "wine/windef.h"
#include "wine/winuser.h"
@@ -38,15 +32,16 @@
#include "wine/msacmdrv.h"
#include "wineacm.h"
#include "ext.h"
-
#include "driver.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#pragma pack(1)
#define OpenDriverA DrvOpen
#define CloseDriver DrvClose
-#pragma pack(1)
-
-static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
+static inline PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
{
return (PWINE_ACMSTREAM)has;
}
@@ -75,7 +70,7 @@ MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule,
* LoadDriver on it, to be sure we can call SendDriverMessage on the
* hDrvr handle.
*/
- *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, NULL, hinstModule);
+ *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, 0, hinstModule);
/* FIXME: lParam, dwPriority and fdwAdd ignored */
@@ -195,7 +190,6 @@ MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpe
HDRVR hdrv;
-
TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen);
if (!phad)
@@ -208,8 +202,9 @@ MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpe
if (fdwOpen)
return MMSYSERR_INVALFLAG;
- pad = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
- if (!pad) return MMSYSERR_NOMEM;
+ pad = (PWINE_ACMDRIVER) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
+ if (!pad)
+ return MMSYSERR_NOMEM;
pad->obj.pACMDriverID = padid;
icopen.fccType = mmioFOURCC('a', 'u', 'd', 'c');
@@ -217,7 +212,8 @@ MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpe
icopen.dwSize = sizeof(ICOPEN);
icopen.dwFlags = 0;
- if (!padid->hInstModule)
+ icopen.pV1Reserved = padid->pszFileName;
+ if (!padid->hInstModule)
pad->hDrvr = OpenDriverA((long)&icopen);
else
pad->hDrvr = padid->hInstModule;
@@ -226,7 +222,7 @@ MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpe
HeapFree(MSACM_hHeap, 0, pad);
return MMSYSERR_ERROR;
}
-
+
pad->pfnDriverProc = GetProcAddress(pad->hDrvr, "DriverProc");
/* insert new pad at beg of list */
@@ -235,7 +231,7 @@ MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpe
/* FIXME: Create a WINE_ACMDRIVER32 */
*phad = (HACMDRIVER)pad;
-
+
return MMSYSERR_NOERROR;
}
@@ -269,22 +265,19 @@ PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
/***********************************************************************
* MSACM_RegisterDriver32()
*/
-PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
+PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName,
+ WORD wFormatTag,
HINSTANCE hinstModule)
-//
-// File names are stored in driver.c. I reuse this variable to store driver ID
-// in it. If it's <0x10000, it is primary codec for corresponding format.
-//
-{
+{
PWINE_ACMDRIVERID padid;
- TRACE("('%s', '%x', 0x%08x)\n", pszDriverAlias, pszFileName, hinstModule);
+ TRACE("('%s', '%x', 0x%08x)\n", pszFileName, wFormatTag, hinstModule);
padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
- padid->pszDriverAlias = (char*)malloc(strlen(pszDriverAlias)+1);
- strcpy(padid->pszDriverAlias, pszDriverAlias);
+ padid->pszFileName = (char*)malloc(strlen(pszFileName)+1);
+ strcpy(padid->pszFileName, pszFileName);
// 1~strdup(pszDriverAlias);
- padid->pszFileName = pszFileName;
+ padid->wFormatTag = wFormatTag;
padid->hInstModule = hinstModule;
padid->bEnabled = TRUE;
padid->pACMDriverList = NULL;
@@ -299,23 +292,6 @@ PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
return padid;
}
-/***********************************************************************
- * MSACM_RegisterAllDrivers32()
- */
-void MSACM_RegisterAllDrivers(void)
-{
- LPSTR pszBuffer;
- DWORD dwBufferLength;
-
- if (MSACM_pFirstACMDriverID)
- return;
-
- MSACM_RegisterDriver("divxa32", (LPSTR)0x161, 0); // DivX/WMA [07]
- MSACM_RegisterDriver("msadp32", (LPSTR)0x2, 0); // MS ADPCM [08]
- MSACM_RegisterDriver("l3codeca", (LPSTR)0x55, 0); // MPEG Layer-3 [12]
-// MSACM_RegisterDriver("imaadp32", (LPSTR)0x11, 0); // IMA ADPCM [13]
-// MSACM_RegisterDriver("msgsm32", (LPSTR)0x32, 0); // MS GSM 6.10 [14]
-}
/***********************************************************************
* MSACM_UnregisterDriver32()
@@ -327,10 +303,8 @@ PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
while (p->pACMDriverList)
acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
- if (p->pszDriverAlias)
- HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
-// if (p->pszFileName)
-// HeapFree(MSACM_hHeap, 0, p->pszFileName);
+ if (p->pszFileName)
+ free(p->pszFileName);
if (p == MSACM_pFirstACMDriverID)
MSACM_pFirstACMDriverID = p->pNextACMDriverID;
@@ -400,8 +374,6 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
int wfxSrcSize;
int wfxDstSize;
- //printf("gcc-3.0 bug, pwfxSrc=%p, pwfxSrc->cbSize=%d\n", pwfxSrc, pwfxSrc->cbSize);
-
TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n",
phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
@@ -418,13 +390,15 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
wfxDstSize = SIZEOF_WFX(pwfxDst);
#undef SIZEOF_WFX
- was = HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0));
+ was = (PWINE_ACMSTREAM) HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0));
if (was == NULL)
return MMSYSERR_NOMEM;
-
was->drvInst.cbStruct = sizeof(was->drvInst);
was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was));
memcpy(was->drvInst.pwfxSrc, pwfxSrc, wfxSrcSize);
+ // LHACM is checking for 0x1
+ // but if this will not help
+ // was->drvInst.pwfxSrc->wFormatTag = 1;
was->drvInst.pwfxDst = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was) + wfxSrcSize);
memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize);
if (pwfltr) {
@@ -481,10 +455,14 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
}
}
acmDriverClose(had, 0L);*/
- if(MSACM_pFirstACMDriverID==NULL)
- MSACM_RegisterAllDrivers();
+ //if(MSACM_pFirstACMDriverID==NULL)
+ // MSACM_RegisterAllDrivers();
- for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) {
+ for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID)
+ {
+ /* Check Format */
+ if ((int)wadi->wFormatTag != (int)pwfxSrc->wFormatTag) continue;
+
ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L);
if (ret == MMSYSERR_NOERROR) {
if ((wad = MSACM_GetDriver(had)) != 0) {
@@ -493,6 +471,8 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
was->hAcmDriver = had;
ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
+ //lhacm - crash printf("RETOPEN %d\n", ret);
+ //ret = 0;
if (ret == MMSYSERR_NOERROR) {
if (fdwOpen & ACM_STREAMOPENF_QUERY) {
acmDriverClose(had, 0L);
@@ -514,6 +494,7 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
if (phas)
*phas = (HACMSTREAM)was;
TRACE("=> (%d)\n", ret);
+ CodecAlloc();
return ret;
}
errCleanUp:
@@ -540,6 +521,7 @@ MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
if (was->hAcmDriver)
acmDriverClose(was->hAcmDriver, 0L);
HeapFree(MSACM_hHeap, 0, was);
+ CodecRelease();
}
TRACE("=> (%d)\n", ret);
return ret;
@@ -556,7 +538,7 @@ MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash,
PACMDRVSTREAMHEADER padsh;
TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwConvert);
-
+
if ((was = ACM_GetStream(has)) == NULL)
return MMSYSERR_INVALHANDLE;
if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
diff --git a/loader/com.h b/loader/com.h
index 84a667f0fd..741b25232b 100644
--- a/loader/com.h
+++ b/loader/com.h
@@ -1,7 +1,14 @@
#ifndef AVIFILE_COM_H
#define AVIFILE_COM_H
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#else
#include <inttypes.h>
+#endif
/**
* Internal functions and structures for COM emulation code.
@@ -27,12 +34,12 @@ typedef struct
} GUID;
#endif
-extern GUID IID_IUnknown;
-extern GUID IID_IClassFactory;
+extern const GUID IID_IUnknown;
+extern const GUID IID_IClassFactory;
-typedef long (*GETCLASSOBJECT) (GUID* clsid, GUID* iid, void** ppv);
-int RegisterComClass(GUID* clsid, GETCLASSOBJECT gcs);
-int UnregisterComClass(GUID* clsid, GETCLASSOBJECT gcs);
+typedef long (*GETCLASSOBJECT) (GUID* clsid, const GUID* iid, void** ppv);
+int RegisterComClass(const GUID* clsid, GETCLASSOBJECT gcs);
+int UnregisterComClass(const GUID* clsid, GETCLASSOBJECT gcs);
#ifndef STDCALL
#define STDCALL __attribute__((__stdcall__))
@@ -42,7 +49,7 @@ struct IUnknown;
struct IClassFactory;
struct IUnknown_vt
{
- long STDCALL (*QueryInterface)(struct IUnknown* _this, GUID* iid, void** ppv);
+ long STDCALL (*QueryInterface)(struct IUnknown* _this, const GUID* iid, void** ppv);
long STDCALL (*AddRef)(struct IUnknown* _this) ;
long STDCALL (*Release)(struct IUnknown* _this) ;
} ;
@@ -54,10 +61,10 @@ typedef struct IUnknown
struct IClassFactory_vt
{
- long STDCALL (*QueryInterface)(struct IUnknown* _this, GUID* iid, void** ppv);
+ long STDCALL (*QueryInterface)(struct IUnknown* _this, const GUID* iid, void** ppv);
long STDCALL (*AddRef)(struct IUnknown* _this) ;
long STDCALL (*Release)(struct IUnknown* _this) ;
- long STDCALL (*CreateInstance)(struct IClassFactory* _this, struct IUnknown* pUnkOuter, GUID* riid, void** ppvObject);
+ long STDCALL (*CreateInstance)(struct IClassFactory* _this, struct IUnknown* pUnkOuter, const GUID* riid, void** ppvObject);
};
struct IClassFactory
@@ -66,7 +73,7 @@ struct IClassFactory
};
long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
- long dwClsContext, GUID* riid, void** ppv);
+ long dwClsContext, const GUID* riid, void** ppv);
#ifdef __cplusplus
};
diff --git a/loader/driver.c b/loader/driver.c
index 09dc49f8dc..b33942a7a8 100644
--- a/loader/driver.c
+++ b/loader/driver.c
@@ -1,4 +1,5 @@
-#include <config.h>
+#include "config.h"
+
#include <stdio.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
@@ -17,22 +18,26 @@
#include "ldt_keeper.h"
#include "driver.h"
+extern char* def_path;
#if 1
+
/*
* STORE_ALL/REST_ALL seems like an attempt to workaround problems due to
* WINAPI/no-WINAPI bustage.
*
- * There should be no need for the STORE_ALL/REST_ALL hack once all
+ * There should be no need for the STORE_ALL/REST_ALL hack once all
* function definitions agree with their prototypes (WINAPI-wise) and
* we make sure, that we do not call these functions without a proper
* prototype in scope.
*/
-#define STORE_ALL /**/
-#define REST_ALL /**/
+
+#define STORE_ALL
+#define REST_ALL
#else
+// this asm code is no longer needed
#define STORE_ALL \
- __asm__( \
+ __asm__ __volatile__ ( \
"push %%ebx\n\t" \
"push %%ecx\n\t" \
"push %%edx\n\t" \
@@ -40,7 +45,7 @@
"push %%edi\n\t"::)
#define REST_ALL \
- __asm__( \
+ __asm__ __volatile__ ( \
"pop %%edi\n\t" \
"pop %%esi\n\t" \
"pop %%edx\n\t" \
@@ -48,180 +53,125 @@
"pop %%ebx\n\t"::)
#endif
+static int needs_free=0;
+void SetCodecPath(const char* path)
+{
+ if(needs_free)free(def_path);
+ if(path==0)
+ {
+ def_path=WIN32_PATH;
+ needs_free=0;
+ return;
+ }
+ def_path = (char*) malloc(strlen(path)+1);
+ strcpy(def_path, path);
+ needs_free=1;
+}
-
-
static DWORD dwDrvID = 0;
-
-LRESULT WINAPI SendDriverMessage( HDRVR hDriver, UINT message,
- LPARAM lParam1, LPARAM lParam2 )
+LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
+ LPARAM lParam1, LPARAM lParam2)
{
DRVR* module=(DRVR*)hDriver;
int result;
-#ifdef DETAILED_OUT
+#ifndef __svr4__
+ char qw[300];
+#endif
+#ifdef DETAILED_OUT
printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
#endif
- if(module==0)return -1;
- if(module->hDriverModule==0)return -1;
- if(module->DriverProc==0)return -1;
+ if (!module || !module->hDriverModule || !module->DriverProc) return -1;
+#ifndef __svr4__
+ __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
+#endif
+
+ Setup_FS_Segment();
+
STORE_ALL;
- result=module->DriverProc(module->dwDriverID,1,message,lParam1,lParam2);
+ result=module->DriverProc(module->dwDriverID, hDriver, message, lParam1, lParam2);
REST_ALL;
-#ifdef DETAILED_OUT
+
+#ifndef __svr4__
+ __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
+#endif
+
+#ifdef DETAILED_OUT
printf("\t\tResult: %X\n", result);
-#endif
+#endif
return result;
-}
+}
-static NPDRVR DrvAlloc(HDRVR*lpDriver, LPUINT lpDrvResult)
+void DrvClose(HDRVR hDriver)
{
- NPDRVR npDriver;
- /* allocate and lock handle */
- if (lpDriver)
+ if (hDriver)
{
- if ( (*lpDriver = (HDRVR) malloc(sizeof(DRVR))) )
- {
- if ((npDriver = (NPDRVR) *lpDriver))
- {
- *lpDrvResult = MMSYSERR_NOERROR;
- return (npDriver);
- }
- free((NPDRVR)*lpDriver);
- }
- return (*lpDrvResult = MMSYSERR_NOMEM, (NPDRVR) 0);
+ DRVR* d = (DRVR*)hDriver;
+ if (d->hDriverModule)
+ {
+ Setup_FS_Segment();
+ if (d->DriverProc)
+ {
+ SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
+ d->dwDriverID = 0;
+ SendDriverMessage(hDriver, DRV_FREE, 0, 0);
+ }
+ FreeLibrary(d->hDriverModule);
+ }
+ free(d);
}
- return (*lpDrvResult = MMSYSERR_INVALPARAM, (NPDRVR) 0);
+ CodecRelease();
}
-
-static void DrvFree(HDRVR hDriver)
+//DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
+HDRVR DrvOpen(LPARAM lParam2)
{
+ NPDRVR hDriver;
int i;
- Setup_FS_Segment();
- if(hDriver)
- if(((DRVR*)hDriver)->hDriverModule)
- if(((DRVR*)hDriver)->DriverProc)
- (((DRVR*)hDriver)->DriverProc)(((DRVR*)hDriver)->dwDriverID, hDriver, DRV_CLOSE, 0, 0);
- if(hDriver) {
- if(((DRVR*)hDriver)->hDriverModule)
- if(((DRVR*)hDriver)->DriverProc)
- (((DRVR*)hDriver)->DriverProc)(0, hDriver, DRV_FREE, 0, 0);
- FreeLibrary(((DRVR*)hDriver)->hDriverModule);
- free((NPDRVR)hDriver);
- return;
- }
-}
-
-void DrvClose(HDRVR hdrvr)
-{
- DrvFree(hdrvr);
-}
-
-
-char* win32_codec_name=NULL; // must be set before calling DrvOpen() !!!
-
-HDRVR VFWAPI
-DrvOpen(LPARAM lParam2)
-{
- ICOPEN *icopen=(ICOPEN *) lParam2;
- UINT uDrvResult;
- HDRVR hDriver;
- NPDRVR npDriver;
- char unknown[0x24];
-// char* codec_name=icopen->fccHandler;
+ char unknown[0x124];
+ const char* filename = (const char*) ((ICOPEN*) lParam2)->pV1Reserved;
+#ifdef MPLAYER
Setup_LDT_Keeper();
+ printf("Loading codec DLL: '%s'\n",filename);
+#endif
- if (!(npDriver = DrvAlloc(&hDriver, &uDrvResult)))
+ hDriver = (NPDRVR) malloc(sizeof(DRVR));
+ if (!hDriver)
return ((HDRVR) 0);
+ memset((void*)hDriver, 0, sizeof(DRVR));
- if (!(npDriver->hDriverModule = LoadLibraryA(win32_codec_name))) {
- printf("Can't open library %s\n", win32_codec_name);
- DrvFree(hDriver);
- return ((HDRVR) 0);
- }
+ CodecAlloc();
+ Setup_FS_Segment();
-#if 0
+ hDriver->hDriverModule = LoadLibraryA(filename);
+ if (!hDriver->hDriverModule)
{
- unsigned char *p=((char*)npDriver->hDriverModule);
- double *dp;
- int i;
- p+=0x14c0;
- for(i=0;i<16;i++)printf(" %02X",p[i]); printf("\n");
- dp=(double*)p;
- printf("divx bitrate = %f\n",(float)(*dp));
-// *(double*)((char*)npDriver->hDriverModule+0x14c0)=bitrate;
+ printf("Can't open library %s\n", filename);
+ DrvClose((HDRVR)hDriver);
+ return ((HDRVR) 0);
}
-#endif
-
- if (!(npDriver->DriverProc = (DRIVERPROC)
- GetProcAddress(npDriver->hDriverModule, "DriverProc"))) {
-#if 1
- printf("Library %s is not a VfW/ACM valid codec\n", win32_codec_name);
-#else
- // Try DirectShow...
- GETCLASS func=(GETCLASS)GetProcAddress(npDriver->hDriverModule,"DllGetClassObject");
- if(!func)
- printf("Library %s is not a valid VfW/ACM/DShow codec\n", win32_codec_name);
- else {
- HRESULT result;
- struct IClassFactory* factory=0;
- struct IUnknown* object=0;
- GUID CLSID_Voxware={0x73f7a062, 0x8829, 0x11d1,
- {0xb5, 0x50, 0x00, 0x60, 0x97, 0x24, 0x2d, 0x8d}};
- GUID* id=&CLSID_Voxware;
-
- result=func(id, &IID_IClassFactory, (void**)&factory);
- if(result || (!factory)) printf("No such class object (wrong/missing GUID?)\n");
-
- printf("Calling factory->vt->CreateInstance()\n");
- printf("addr = %X\n",(unsigned int)factory->vt->CreateInstance);
- result=factory->vt->CreateInstance(factory, 0, &IID_IUnknown, (void**)&object);
- printf("Calling factory->vt->Release()\n");
- factory->vt->Release((struct IUnknown*)factory);
- if(result || (!object)) printf("Class factory failure\n");
-
- printf("DirectShow codecs not yet supported...\n");
- }
-#endif
-
- FreeLibrary(npDriver->hDriverModule);
- DrvFree(hDriver);
- return ((HDRVR) 0);
+ hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule,
+ "DriverProc");
+ if (!hDriver->DriverProc)
+ {
+ printf("Library %s is not a valid VfW/ACM codec\n", filename);
+ DrvClose((HDRVR)hDriver);
+ return ((HDRVR) 0);
}
- //TRACE("DriverProc == %X\n", npDriver->DriverProc);
- npDriver->dwDriverID = ++dwDrvID;
-
- Setup_FS_Segment();
+ TRACE("DriverProc == %X\n", hDriver->DriverProc);
+ SendDriverMessage((HDRVR)hDriver, DRV_LOAD, 0, 0);
+ TRACE("DRV_LOAD Ok!\n");
+ SendDriverMessage((HDRVR)hDriver, DRV_ENABLE, 0, 0);
+ TRACE("DRV_ENABLE Ok!\n");
+ hDriver->dwDriverID = ++dwDrvID; // generate new id
- STORE_ALL;
- (npDriver->DriverProc)(0, hDriver, DRV_LOAD, 0, 0);
- REST_ALL;
- //TRACE("DRV_LOAD Ok!\n");
- STORE_ALL;
- (npDriver->DriverProc)(0, hDriver, DRV_ENABLE, 0, 0);
- REST_ALL;
- //TRACE("DRV_ENABLE Ok!\n");
+ // open driver and remmeber proper DriverID
+ hDriver->dwDriverID = SendDriverMessage((HDRVR)hDriver, DRV_OPEN, (LPARAM) unknown, lParam2);
+ TRACE("DRV_OPEN Ok!(%X)\n", hDriver->dwDriverID);
- // open driver
- STORE_ALL;
- npDriver->dwDriverID=(npDriver->DriverProc)(npDriver->dwDriverID, hDriver, DRV_OPEN,
- (LPARAM) (LPSTR) unknown, lParam2);
- REST_ALL;
-
- //TRACE("DRV_OPEN Ok!(%X)\n", npDriver->dwDriverID);
-
- if (uDrvResult)
- {
- DrvFree(hDriver);
- hDriver = (HDRVR) 0;
- }
-
-// printf("Successfully loaded codec %s\n",win32_codec_name);
-
- return (hDriver);
+ printf("Loaded DLL driver %s\n", filename);
+ return (HDRVR)hDriver;
}
-
diff --git a/loader/driver.h b/loader/driver.h
index 59a7753353..751f0379e8 100644
--- a/loader/driver.h
+++ b/loader/driver.h
@@ -1,11 +1,22 @@
-
#ifndef loader_driver_h
#define loader_driver_h
-//#include "wine/windef.h"
-//#include "wine/vfw.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "wine/windef.h"
+#include "wine/driver.h"
-extern HDRVR VFWAPI DrvOpen(LPARAM lParam2);
-extern void DrvClose(HDRVR hdrvr);
+void SetCodecPath(const char* path);
+void CodecAlloc(void);
+void CodecRelease(void);
+
+HDRVR DrvOpen(LPARAM lParam2);
+void DrvClose(HDRVR hdrvr);
+
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/loader/dshow/DS_Filter.c b/loader/dshow/DS_Filter.c
index e1d11aa801..fb910ee99e 100644
--- a/loader/dshow/DS_Filter.c
+++ b/loader/dshow/DS_Filter.c
@@ -1,9 +1,10 @@
#include "DS_Filter.h"
#include "driver.h"
#include "com.h"
-#include "module.h"
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
+#include "win32.h" // printf macro
typedef long STDCALL (*GETCLASS) (const GUID*, const GUID*, void**);
@@ -145,7 +146,7 @@ DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id,
object->vt->Release((IUnknown*)object);
if (result || !This->m_pFilter)
{
- em = "object does not have IBaseFilter interface";
+ em = "object does not provide IBaseFilter interface";
break;
}
// enumerate pins
@@ -228,7 +229,6 @@ DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id,
break;
}
- printf("Using DirectShow codec: %s\n", dllname);
init++;
break;
}
diff --git a/loader/dshow/allocator.c b/loader/dshow/allocator.c
index bc129dc422..c5600f40d9 100644
--- a/loader/dshow/allocator.c
+++ b/loader/dshow/allocator.c
@@ -2,9 +2,17 @@
#include "com.h"
#include "wine/winerror.h"
#include <stdio.h>
+#include <stdlib.h>
static int AllocatorKeeper = 0;
+struct _avm_list_t
+{
+ struct _avm_list_t* next;
+ struct _avm_list_t* prev;
+ void* member;
+};
+
static inline int avm_list_size(avm_list_t* head)
{
avm_list_t* it = head;
@@ -100,7 +108,7 @@ static inline avm_list_t* avm_list_find(avm_list_t* head, void* member)
return NULL;
}
-static long MemAllocator_CreateAllocator(GUID* clsid, GUID* iid, void** ppv)
+static long MemAllocator_CreateAllocator(GUID* clsid, const GUID* iid, void** ppv)
{
IMemAllocator* p;
int result;
diff --git a/loader/dshow/allocator.h b/loader/dshow/allocator.h
index 8556370635..b4f6aaf703 100644
--- a/loader/dshow/allocator.h
+++ b/loader/dshow/allocator.h
@@ -4,14 +4,9 @@
#include "interfaces.h"
#include "cmediasample.h"
-typedef struct avm_list_t
-{
- struct avm_list_t* next;
- struct avm_list_t* prev;
- void* member;
-} avm_list_t;
-
+typedef struct _avm_list_t avm_list_t;
typedef struct _MemAllocator MemAllocator;
+
struct _MemAllocator
{
IMemAllocator_vt* vt;
diff --git a/loader/dshow/cmediasample.c b/loader/dshow/cmediasample.c
index eba60dd4a0..e618f68674 100644
--- a/loader/dshow/cmediasample.c
+++ b/loader/dshow/cmediasample.c
@@ -2,9 +2,10 @@
#include "wine/winerror.h"
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
static long STDCALL CMediaSample_QueryInterface(IUnknown* This,
- /* [in] */ IID* iid,
+ /* [in] */ const GUID* iid,
/* [iid_is][out] */ void **ppv)
{
Debug printf("CMediaSample_QueryInterface(%p) called\n", This);
diff --git a/loader/dshow/guids.c b/loader/dshow/guids.c
index f1ee0aaa37..9dae571fad 100644
--- a/loader/dshow/guids.c
+++ b/loader/dshow/guids.c
@@ -1,68 +1,67 @@
#include "guids.h"
int DSHOW_DEBUG = 0;
-GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0,
+const GUID CLSID_DivxDecompressorCF={0x82CCd3E0, 0xF71A, 0x11D0,
{ 0x9f, 0xe5, 0x00, 0x60, 0x97, 0x78, 0xaa, 0xaa}};
-GUID IID_IDivxFilterInterface={0xd132ee97, 0x3e38, 0x4030,
+const GUID IID_IDivxFilterInterface={0xd132ee97, 0x3e38, 0x4030,
{0x8b, 0x17, 0x59, 0x16, 0x3b, 0x30, 0xa1, 0xf5}};
-GUID CLSID_IV50_Decoder={0x30355649, 0x0000, 0x0010,
+const GUID CLSID_IV50_Decoder={0x30355649, 0x0000, 0x0010,