From c7eafc3610b65eafe408d4959ded4c1aab44157a Mon Sep 17 00:00:00 2001 From: arpi Date: Fri, 13 Sep 2002 19:43:17 +0000 Subject: avifile sync - 95% cosmetics 5% bug git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7387 b3059339-0415-0410-9bf9-f77b7e298cf2 --- loader/afl.c | 94 ++++++++++++++++++++++++------------------------------------ 1 file changed, 38 insertions(+), 56 deletions(-) (limited to 'loader/afl.c') 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 -#include -#include - -#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 +#include +#include +#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)) -- cgit v1.2.3