Commit 1ddce716 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Made msacm32 really load ACM drivers.

parent 5f930d89
......@@ -8,7 +8,6 @@ MODULE = msacm32
SPEC_SRCS = msacm32.spec
C_SRCS = \
builtin.c \
driver.c \
filter.c \
format.c \
......
/*
* MSACM32 library
*
* Copyright 1998 Patrik Stridvall
*/
#include "winbase.h"
#include "winerror.h"
#include "windef.h"
#include "debugtools.h"
#include "driver.h"
#include "heap.h"
#include "mmsystem.h"
#include "msacm.h"
#include "msacmdrv.h"
/***********************************************************************
* MSACM_BuiltinDrivers
*/
LONG WINAPI MSACM_DummyDriverProc(
DWORD dwDriverId, HDRVR hdrvr, UINT msg,
LONG lParam1, LONG lParam2);
WINE_ACMBUILTINDRIVER MSACM_BuiltinDrivers[] = {
{ "MSACM.dummy", &MSACM_DummyDriverProc },
{ NULL, NULL }
};
/***********************************************************************
* MSACM_DummyDriverProc
*/
LONG WINAPI MSACM_DummyDriverProc(
DWORD dwDriverId, HDRVR hdrvr, UINT msg,
LONG lParam1, LONG lParam2)
{
switch(msg)
{
case DRV_LOAD:
case DRV_ENABLE:
case DRV_OPEN:
case DRV_CLOSE:
case DRV_DISABLE:
case DRV_FREE:
case DRV_CONFIGURE:
case DRV_QUERYCONFIGURE:
case DRV_INSTALL:
case DRV_REMOVE:
case DRV_EXITSESSION:
case DRV_EXITAPPLICATION:
case DRV_POWER:
case ACMDM_DRIVER_NOTIFY:
case ACMDM_DRIVER_DETAILS:
case ACMDM_HARDWARE_WAVE_CAPS_INPUT:
case ACMDM_HARDWARE_WAVE_CAPS_OUTPUT:
case ACMDM_FORMATTAG_DETAILS:
case ACMDM_FORMAT_DETAILS:
case ACMDM_FORMAT_SUGGEST:
case ACMDM_FILTERTAG_DETAILS:
case ACMDM_FILTER_DETAILS:
case ACMDM_STREAM_OPEN:
case ACMDM_STREAM_CLOSE:
case ACMDM_STREAM_SIZE:
case ACMDM_STREAM_CONVERT:
case ACMDM_STREAM_RESET:
case ACMDM_STREAM_PREPARE:
case ACMDM_STREAM_UNPREPARE:
case ACMDM_STREAM_UPDATE:
default:
/* FIXME: DefDriverProc not implemented */
#if 0
DefDriverProc(dwDriverId, hdrvr, msg, lParam1, lParam2);
#endif
break;
}
return 0;
}
/* -*- tab-width: 8; c-basic-offset: 4 -*- */
/*
* MSACM32 library
*
* Copyright 1998 Patrik Stridvall
* 1999 Eric Pouech
*/
#include <string.h>
......@@ -14,8 +17,11 @@
#include "mmsystem.h"
#include "msacm.h"
#include "msacmdrv.h"
#include "wineacm.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(msacm)
/**********************************************************************/
HANDLE MSACM_hHeap = (HANDLE) NULL;
......@@ -25,89 +31,66 @@ PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
/***********************************************************************
* MSACM_RegisterDriver32()
*/
PWINE_ACMDRIVERID MSACM_RegisterDriver(
LPSTR pszDriverAlias, LPSTR pszFileName,
PWINE_ACMLOCALDRIVER pLocalDriver)
{
PWINE_ACMDRIVERID padid;
padid = (PWINE_ACMDRIVERID) HeapAlloc(
MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID)
);
padid->pszDriverAlias =
HEAP_strdupA(MSACM_hHeap, 0, pszDriverAlias);
padid->pszFileName =
HEAP_strdupA(MSACM_hHeap, 0, pszFileName);
padid->pACMLocalDriver = pLocalDriver;
padid->bEnabled = TRUE;
padid->pACMDriver = NULL;
padid->pNextACMDriverID = NULL;
padid->pPreviousACMDriverID =
MSACM_pLastACMDriverID;
MSACM_pLastACMDriverID = padid;
if(!MSACM_pFirstACMDriverID)
MSACM_pFirstACMDriverID = padid;
return padid;
PWINE_ACMDRIVERID MSACM_RegisterDriver(LPSTR pszDriverAlias, LPSTR pszFileName,
HINSTANCE hinstModule)
{
PWINE_ACMDRIVERID padid;
TRACE("('%s', '%s', 0x%08x)\n", pszDriverAlias, pszFileName, hinstModule);
padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
padid->pszDriverAlias = HEAP_strdupA(MSACM_hHeap, 0, pszDriverAlias);
padid->pszFileName = HEAP_strdupA(MSACM_hHeap, 0, pszFileName);
padid->hInstModule = hinstModule;
padid->bEnabled = TRUE;
padid->pACMDriver = NULL;
padid->pNextACMDriverID = NULL;
padid->pPreviousACMDriverID = MSACM_pLastACMDriverID;
if (MSACM_pLastACMDriverID)
MSACM_pLastACMDriverID->pNextACMDriverID = padid;
MSACM_pLastACMDriverID = padid;
if (!MSACM_pFirstACMDriverID)
MSACM_pFirstACMDriverID = padid;
return padid;
}
/***********************************************************************
* MSACM_RegisterAllDrivers32()
*/
void MSACM_RegisterAllDrivers()
void MSACM_RegisterAllDrivers(void)
{
PWINE_ACMBUILTINDRIVER pbd;
LPSTR pszBuffer;
DWORD dwBufferLength;
/* FIXME
* What if the user edits system.ini while the program is running?
* Does Windows handle that?
*/
if(!MSACM_pFirstACMDriverID)
return;
/* FIXME: Do not work! How do I determine the section length? */
dwBufferLength =
GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini");
pszBuffer = (LPSTR) HeapAlloc(
MSACM_hHeap, 0, dwBufferLength
);
if(GetPrivateProfileSectionA(
"drivers32", pszBuffer, dwBufferLength, "system.ini"))
{
char *s = pszBuffer;
while(*s)
{
if(!lstrncmpiA("MSACM.", s, 6))
{
char *s2 = s;
while(*s2 != '\0' && *s2 != '=') s2++;
if(*s2)
{
*s2++='\0';
MSACM_RegisterDriver(s, s2, NULL);
LPSTR pszBuffer;
DWORD dwBufferLength;
/* FIXME
* What if the user edits system.ini while the program is running?
* Does Windows handle that?
*/
if (MSACM_pFirstACMDriverID)
return;
/* FIXME: Do not work! How do I determine the section length? */
dwBufferLength = 1024;
/* EPP GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini"); */
pszBuffer = (LPSTR) HeapAlloc(MSACM_hHeap, 0, dwBufferLength);
if (GetPrivateProfileSectionA("drivers32", pszBuffer, dwBufferLength, "system.ini")) {
char* s = pszBuffer;
while (*s) {
if (!lstrncmpiA("MSACM.", s, 6)) {
char *s2 = s;
while (*s2 != '\0' && *s2 != '=') s2++;
if (*s2) {
*s2++ = '\0';
MSACM_RegisterDriver(s, s2, 0);
}
}
s += lstrlenA(s) + 1; /* Either next char or \0 */
s += lstrlenA(s) + 1; /* Either next char or \0 */
}
}
/* FIXME
* Check if any of the builtin driver was added
* when the external drivers was.
*/
pbd = MSACM_BuiltinDrivers;
while(pbd->pszDriverAlias)
{
PWINE_ACMLOCALDRIVER pld;
pld = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMLOCALDRIVER));
pld->pfnDriverProc = pbd->pfnDriverProc;
MSACM_RegisterDriver(pbd->pszDriverAlias, NULL, pld);
pbd++;
}
HeapFree(MSACM_hHeap, 0, pszBuffer);
HeapFree(MSACM_hHeap, 0, pszBuffer);
}
/***********************************************************************
......@@ -115,28 +98,31 @@ void MSACM_RegisterAllDrivers()
*/
PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
{
PWINE_ACMDRIVERID pNextACMDriverID;
if(p->pACMDriver)
acmDriverClose((HACMDRIVER) p->pACMDriver, 0);
if(p->pszDriverAlias)
HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
if(p->pszFileName)
HeapFree(MSACM_hHeap, 0, p->pszFileName);
if(p->pACMLocalDriver)
HeapFree(MSACM_hHeap, 0, p->pACMLocalDriver);
if(p->pPreviousACMDriverID)
p->pPreviousACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
if(p->pNextACMDriverID)
p->pNextACMDriverID->pPreviousACMDriverID = p->pPreviousACMDriverID;
pNextACMDriverID = p->pNextACMDriverID;
HeapFree(MSACM_hHeap, 0, p);
return pNextACMDriverID;
PWINE_ACMDRIVERID pNextACMDriverID;
if (p->pACMDriver)
acmDriverClose((HACMDRIVER) p->pACMDriver, 0);
if (p->pszDriverAlias)
HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
if (p->pszFileName)
HeapFree(MSACM_hHeap, 0, p->pszFileName);
if (p == MSACM_pFirstACMDriverID)
MSACM_pFirstACMDriverID = p->pNextACMDriverID;
if (p == MSACM_pLastACMDriverID)
MSACM_pLastACMDriverID = p->pPreviousACMDriverID;
if (p->pPreviousACMDriverID)
p->pPreviousACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
if (p->pNextACMDriverID)
p->pNextACMDriverID->pPreviousACMDriverID = p->pPreviousACMDriverID;
pNextACMDriverID = p->pNextACMDriverID;
HeapFree(MSACM_hHeap, 0, p);
return pNextACMDriverID;
}
/***********************************************************************
......@@ -144,10 +130,11 @@ PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
* FIXME
* Where should this function be called?
*/
void MSACM_UnregisterAllDrivers()
void MSACM_UnregisterAllDrivers(void)
{
PWINE_ACMDRIVERID p = MSACM_pFirstACMDriverID;
while(p) p = MSACM_UnregisterDriver(p);
PWINE_ACMDRIVERID p;
for (p = MSACM_pFirstACMDriverID; p; p = MSACM_UnregisterDriver(p));
}
/***********************************************************************
......@@ -155,7 +142,7 @@ void MSACM_UnregisterAllDrivers()
*/
PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
{
return (PWINE_ACMDRIVERID) hDriverID;
return (PWINE_ACMDRIVERID)hDriverID;
}
/***********************************************************************
......@@ -163,7 +150,7 @@ PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
*/
PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
{
return (PWINE_ACMDRIVER) hDriver;
return (PWINE_ACMDRIVER)hDriver;
}
/***********************************************************************
......@@ -171,32 +158,7 @@ PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
*/
PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj)
{
return (PWINE_ACMOBJ) hObj;
return (PWINE_ACMOBJ)hObj;
}
/***********************************************************************
* MSACM_OpenDriverProc32
* FIXME
* This function should be integrated with OpenDriver,
* renamed and moved there.
*/
HDRVR MSACM_OpenDriverProc(DRIVERPROC pfnDriverProc)
{
#if 0
LPDRIVERITEMA pDrvr;
/* FIXME: This is a very bad solution */
pDrvr = (LPDRIVERITEMA) HeapAlloc(MSACM_hHeap, HEAP_ZERO_MEMORY, sizeof(DRIVERITEMA));
pDrvr->count = 1;
pDrvr->driverproc = pfnDriverProc;
/* FIXME: Send DRV_OPEN among others to DriverProc */
return (HDRVR) pDrvr;
#else
return (HDRVR) 0;
#endif
}
/* -*- tab-width: 8; c-basic-offset: 4 -*- */
/*
* MSACM32 library
*
* Copyright 1998 Patrik Stridvall
* 1999 Eric Pouech
*/
#include "winbase.h"
......@@ -10,47 +13,46 @@
#include "debugtools.h"
#include "msacm.h"
#include "msacmdrv.h"
#include "wineacm.h"
#include "winversion.h"
DEFAULT_DEBUG_CHANNEL(msacm)
/**********************************************************************/
static DWORD MSACM_dwProcessesAttached = 0;
/***********************************************************************
* MSACM_LibMain32 (MSACM32.init)
*/
BOOL WINAPI MSACM32_LibMain(
HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
BOOL WINAPI MSACM32_LibMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch(fdwReason)
{
TRACE("0x%x 0x%lx %p\n", hInstDLL, fdwReason, lpvReserved);
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
if(MSACM_dwProcessesAttached == 0)
{
MSACM_hHeap = HeapCreate(0, 0x10000, 0);
MSACM_RegisterAllDrivers();
if (MSACM_dwProcessesAttached == 0) {
MSACM_hHeap = HeapCreate(0, 0x10000, 0);
MSACM_RegisterAllDrivers();
}
MSACM_dwProcessesAttached++;
break;
MSACM_dwProcessesAttached++;
break;
case DLL_PROCESS_DETACH:
MSACM_dwProcessesAttached--;
if(MSACM_dwProcessesAttached == 0)
{
MSACM_UnregisterAllDrivers();
HeapDestroy(MSACM_hHeap);
MSACM_hHeap = (HANDLE) NULL;
MSACM_dwProcessesAttached--;
if (MSACM_dwProcessesAttached == 0) {
MSACM_UnregisterAllDrivers();
HeapDestroy(MSACM_hHeap);
MSACM_hHeap = (HANDLE) NULL;
}
break;
break;
case DLL_THREAD_ATTACH:
break;
break;
case DLL_THREAD_DETACH:
break;
break;
default:
break;
break;
}
return TRUE;
return TRUE;
}
/***********************************************************************
......@@ -62,16 +64,15 @@ BOOL WINAPI MSACM32_LibMain(
/***********************************************************************
* acmGetVersion32 (MSACM32.34)
*/
DWORD WINAPI acmGetVersion()
DWORD WINAPI acmGetVersion(void)
{
switch(VERSION_GetVersion())
{
switch (VERSION_GetVersion()) {
default:
FIXME("%s not supported\n", VERSION_GetVersionName());
FIXME("%s not supported\n", VERSION_GetVersionName());
case WIN95:
return 0x04000000; /* 4.0.0 */
return 0x04000000; /* 4.0.0 */
case NT40:
return 0x04000565; /* 4.0.1381 */
return 0x04000565; /* 4.0.1381 */
}
}
......@@ -84,40 +85,38 @@ DWORD WINAPI acmGetVersion()
/***********************************************************************
* acmMetrics (MSACM32.36)
*/
MMRESULT WINAPI acmMetrics(
HACMOBJ hao, UINT uMetric, LPVOID pMetric)
MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
{
PWINE_ACMOBJ pao = MSACM_GetObj(hao);
BOOL bLocal = TRUE;
FIXME("(0x%08x, %d, %p): stub\n", hao, uMetric, pMetric);
switch(uMetric)
{
PWINE_ACMOBJ pao = MSACM_GetObj(hao);
BOOL bLocal = TRUE;
FIXME("(0x%08x, %d, %p): stub\n", hao, uMetric, pMetric);
switch (uMetric) {
case ACM_METRIC_COUNT_DRIVERS:
bLocal = FALSE;
bLocal = FALSE;
case ACM_METRIC_COUNT_LOCAL_DRIVERS:
if(!pao)
return MMSYSERR_INVALHANDLE;
return MMSYSERR_NOTSUPPORTED;
if (!pao)
return MMSYSERR_INVALHANDLE;
return MMSYSERR_NOTSUPPORTED;
case ACM_METRIC_COUNT_CODECS:
bLocal = FALSE;
bLocal = FALSE;
case ACM_METRIC_COUNT_LOCAL_CODECS:
return MMSYSERR_NOTSUPPORTED;
return MMSYSERR_NOTSUPPORTED;
case ACM_METRIC_COUNT_CONVERTERS:
bLocal = FALSE;
bLocal = FALSE;
case ACM_METRIC_COUNT_LOCAL_CONVERTERS:
return MMSYSERR_NOTSUPPORTED;
return MMSYSERR_NOTSUPPORTED;
case ACM_METRIC_COUNT_FILTERS:
bLocal = FALSE;
bLocal = FALSE;
case ACM_METRIC_COUNT_LOCAL_FILTERS:
return MMSYSERR_NOTSUPPORTED;
return MMSYSERR_NOTSUPPORTED;
case ACM_METRIC_COUNT_DISABLED:
bLocal = FALSE;
bLocal = FALSE;
case ACM_METRIC_COUNT_LOCAL_DISABLED:
if(!pao)
return MMSYSERR_INVALHANDLE;
return MMSYSERR_NOTSUPPORTED;
if (!pao)
return MMSYSERR_INVALHANDLE;
return MMSYSERR_NOTSUPPORTED;
case ACM_METRIC_COUNT_HARDWARE:
case ACM_METRIC_HARDWARE_WAVE_INPUT:
case ACM_METRIC_HARDWARE_WAVE_OUTPUT:
......@@ -126,7 +125,7 @@ MMRESULT WINAPI acmMetrics(
case ACM_METRIC_DRIVER_SUPPORT:
case ACM_METRIC_DRIVER_PRIORITY:
default:
return MMSYSERR_NOTSUPPORTED;
return MMSYSERR_NOTSUPPORTED;
}
return MMSYSERR_NOERROR;
return MMSYSERR_NOERROR;
}
/* -*- tab-width: 8; c-basic-offset: 4 -*- */
/***********************************************************************
* Wine specific - Win32
*/
typedef struct _WINE_ACMDRIVERID *PWINE_ACMDRIVERID;
typedef struct _WINE_ACMOBJ
{
PWINE_ACMDRIVERID pACMDriverID;
} WINE_ACMOBJ, *PWINE_ACMOBJ;
typedef struct _WINE_ACMDRIVER
{
WINE_ACMOBJ obj;
HDRVR hDrvr;
DRIVERPROC pfnDriverProc;
} WINE_ACMDRIVER, *PWINE_ACMDRIVER;
typedef struct _WINE_ACMSTREAM
{
WINE_ACMOBJ obj;
PWINE_ACMDRIVER pDrv;
ACMDRVSTREAMINSTANCE drvInst;
} WINE_ACMSTREAM, *PWINE_ACMSTREAM;
typedef struct _WINE_ACMDRIVERID
{
LPSTR pszDriverAlias;
LPSTR pszFileName;
HINSTANCE hInstModule; /* NULL if global */
DWORD dwProcessID; /* ID of process which installed a local driver */
BOOL bEnabled;
PWINE_ACMDRIVER pACMDriver; /* NULL if not open; shouldn't this be a list ? */
PWINE_ACMDRIVERID pNextACMDriverID;
PWINE_ACMDRIVERID pPreviousACMDriverID;
} WINE_ACMDRIVERID;
/* From internal.c */
extern HANDLE MSACM_hHeap;
extern PWINE_ACMDRIVERID MSACM_pFirstACMDriverID;
extern PWINE_ACMDRIVERID MSACM_pLastACMDriverID;
PWINE_ACMDRIVERID MSACM_RegisterDriver(
LPSTR pszDriverAlias, LPSTR pszFileName,
HINSTANCE hinstModule);
void MSACM_RegisterAllDrivers(void);
PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p);
void MSACM_UnregisterAllDrivers(void);
PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID);
PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver);
PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj);
......@@ -919,68 +919,6 @@ MMRESULT WINAPI acmStreamUnprepareHeader(
HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwUnprepare
);
/***********************************************************************
* Wine specific - Win32
*/
typedef struct _WINE_ACMBUILTINDRIVER
{
LPSTR pszDriverAlias;
DRIVERPROC pfnDriverProc;
} WINE_ACMBUILTINDRIVER, *PWINE_ACMBUILTINDRIVER;
typedef struct _WINE_ACMLOCALDRIVER
{
DRIVERPROC pfnDriverProc;
} WINE_ACMLOCALDRIVER, *PWINE_ACMLOCALDRIVER;
typedef struct _WINE_ACMDRIVERID *PWINE_ACMDRIVERID;
typedef struct _WINE_ACMOBJ
{
PWINE_ACMDRIVERID pACMDriverID;
} WINE_ACMOBJ, *PWINE_ACMOBJ;
typedef struct _WINE_ACMDRIVER
{
WINE_ACMOBJ obj;
HDRVR hDrvr;
} WINE_ACMDRIVER, *PWINE_ACMDRIVER;
typedef struct _WINE_ACMSTREAM
{
WINE_ACMOBJ obj;
/* FIME: More fields needed */
} WINE_ACMSTREAM, *PWINE_ACMSTREAM;
typedef struct _WINE_ACMDRIVERID
{
LPSTR pszDriverAlias;
LPSTR pszFileName;
PWINE_ACMLOCALDRIVER pACMLocalDriver;
BOOL bEnabled;
PWINE_ACMDRIVER pACMDriver; /* NULL if not open */
PWINE_ACMDRIVERID pNextACMDriverID;
PWINE_ACMDRIVERID pPreviousACMDriverID;
} WINE_ACMDRIVERID;
/* From builtin.c */
extern WINE_ACMBUILTINDRIVER MSACM_BuiltinDrivers[];
/* From interal.c */
extern HANDLE MSACM_hHeap;
extern PWINE_ACMDRIVERID MSACM_pFirstACMDriverID;
extern PWINE_ACMDRIVERID MSACM_pLastACMDriverID;
PWINE_ACMDRIVERID MSACM_RegisterDriver(
LPSTR pszDriverAlias, LPSTR pszFileName,
PWINE_ACMLOCALDRIVER pLocalDriver);
void MSACM_RegisterAllDrivers();
PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p);
void MSACM_UnregisterAllDrivers();
PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID);
PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver);
PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj);
HDRVR MSACM_OpenDriverProc(DRIVERPROC pfnDriverProc);
#ifdef __cplusplus
} /* extern "C" */
#endif /* defined(__cplusplus) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment