1998-10-11 19:00:29 +02:00
|
|
|
/*
|
|
|
|
* MSACM32 library
|
|
|
|
*
|
|
|
|
* Copyright 1998 Patrik Stridvall
|
|
|
|
*/
|
|
|
|
|
1999-09-11 18:27:20 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
1999-02-17 14:51:06 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "driver.h"
|
|
|
|
#include "heap.h"
|
|
|
|
#include "mmsystem.h"
|
|
|
|
#include "msacm.h"
|
|
|
|
#include "msacmdrv.h"
|
1999-05-14 10:17:14 +02:00
|
|
|
#include "debugtools.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
HANDLE MSACM_hHeap = (HANDLE) NULL;
|
|
|
|
PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL;
|
|
|
|
PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_RegisterDriver32()
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID MSACM_RegisterDriver(
|
1998-10-11 19:00:29 +02:00
|
|
|
LPSTR pszDriverAlias, LPSTR pszFileName,
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMLOCALDRIVER pLocalDriver)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID padid;
|
|
|
|
padid = (PWINE_ACMDRIVERID) HeapAlloc(
|
|
|
|
MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID)
|
1998-10-11 19:00:29 +02:00
|
|
|
);
|
|
|
|
padid->pszDriverAlias =
|
1999-02-26 12:11:13 +01:00
|
|
|
HEAP_strdupA(MSACM_hHeap, 0, pszDriverAlias);
|
1998-10-11 19:00:29 +02:00
|
|
|
padid->pszFileName =
|
1999-02-26 12:11:13 +01:00
|
|
|
HEAP_strdupA(MSACM_hHeap, 0, pszFileName);
|
1998-10-11 19:00:29 +02:00
|
|
|
padid->pACMLocalDriver = pLocalDriver;
|
|
|
|
padid->bEnabled = TRUE;
|
|
|
|
padid->pACMDriver = NULL;
|
|
|
|
padid->pNextACMDriverID = NULL;
|
|
|
|
padid->pPreviousACMDriverID =
|
1999-02-26 12:11:13 +01:00
|
|
|
MSACM_pLastACMDriverID;
|
|
|
|
MSACM_pLastACMDriverID = padid;
|
|
|
|
if(!MSACM_pFirstACMDriverID)
|
|
|
|
MSACM_pFirstACMDriverID = padid;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
return padid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_RegisterAllDrivers32()
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
void MSACM_RegisterAllDrivers()
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMBUILTINDRIVER pbd;
|
1998-10-11 19:00:29 +02:00
|
|
|
LPSTR pszBuffer;
|
|
|
|
DWORD dwBufferLength;
|
|
|
|
|
|
|
|
/* FIXME
|
|
|
|
* What if the user edits system.ini while the program is running?
|
|
|
|
* Does Windows handle that?
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
if(!MSACM_pFirstACMDriverID)
|
1998-10-11 19:00:29 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* FIXME: Do not work! How do I determine the section length? */
|
|
|
|
dwBufferLength =
|
1999-02-26 12:11:13 +01:00
|
|
|
GetPrivateProfileSectionA("drivers32", NULL, 0, "system.ini");
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
pszBuffer = (LPSTR) HeapAlloc(
|
1999-02-26 12:11:13 +01:00
|
|
|
MSACM_hHeap, 0, dwBufferLength
|
1998-10-11 19:00:29 +02:00
|
|
|
);
|
1999-02-26 12:11:13 +01:00
|
|
|
if(GetPrivateProfileSectionA(
|
1998-10-11 19:00:29 +02:00
|
|
|
"drivers32", pszBuffer, dwBufferLength, "system.ini"))
|
|
|
|
{
|
|
|
|
char *s = pszBuffer;
|
|
|
|
while(*s)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
if(!lstrncmpiA("MSACM.", s, 6))
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
|
|
|
char *s2 = s;
|
|
|
|
while(*s2 != '\0' && *s2 != '=') s2++;
|
|
|
|
if(*s2)
|
|
|
|
{
|
|
|
|
*s2++='\0';
|
1999-02-26 12:11:13 +01:00
|
|
|
MSACM_RegisterDriver(s, s2, NULL);
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
}
|
1999-02-26 12:11:13 +01:00
|
|
|
s += lstrlenA(s) + 1; /* Either next char or \0 */
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME
|
|
|
|
* Check if any of the builtin driver was added
|
|
|
|
* when the external drivers was.
|
|
|
|
*/
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
pbd = MSACM_BuiltinDrivers;
|
1998-10-11 19:00:29 +02:00
|
|
|
while(pbd->pszDriverAlias)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMLOCALDRIVER pld;
|
|
|
|
pld = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMLOCALDRIVER));
|
1998-10-11 19:00:29 +02:00
|
|
|
pld->pfnDriverProc = pbd->pfnDriverProc;
|
1999-02-26 12:11:13 +01:00
|
|
|
MSACM_RegisterDriver(pbd->pszDriverAlias, NULL, pld);
|
1998-10-11 19:00:29 +02:00
|
|
|
pbd++;
|
|
|
|
}
|
1999-02-26 12:11:13 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, pszBuffer);
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_UnregisterDriver32()
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID pNextACMDriverID;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
if(p->pACMDriver)
|
1999-02-26 12:11:13 +01:00
|
|
|
acmDriverClose((HACMDRIVER) p->pACMDriver, 0);
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
if(p->pszDriverAlias)
|
1999-02-26 12:11:13 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
|
1998-10-11 19:00:29 +02:00
|
|
|
if(p->pszFileName)
|
1999-02-26 12:11:13 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, p->pszFileName);
|
1998-10-11 19:00:29 +02:00
|
|
|
if(p->pACMLocalDriver)
|
1999-02-26 12:11:13 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, p->pACMLocalDriver);
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
if(p->pPreviousACMDriverID)
|
|
|
|
p->pPreviousACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
|
|
|
|
if(p->pNextACMDriverID)
|
|
|
|
p->pNextACMDriverID->pPreviousACMDriverID = p->pPreviousACMDriverID;
|
|
|
|
|
|
|
|
pNextACMDriverID = p->pNextACMDriverID;
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, p);
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
return pNextACMDriverID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_UnregisterAllDrivers32()
|
|
|
|
* FIXME
|
|
|
|
* Where should this function be called?
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
void MSACM_UnregisterAllDrivers()
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID p = MSACM_pFirstACMDriverID;
|
|
|
|
while(p) p = MSACM_UnregisterDriver(p);
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_GetDriverID32()
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
return (PWINE_ACMDRIVERID) hDriverID;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_GetDriver32()
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
return (PWINE_ACMDRIVER) hDriver;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_GetObj32()
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
return (PWINE_ACMOBJ) hObj;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_OpenDriverProc32
|
|
|
|
* FIXME
|
|
|
|
* This function should be integrated with OpenDriver,
|
|
|
|
* renamed and moved there.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HDRVR MSACM_OpenDriverProc(DRIVERPROC pfnDriverProc)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-01-26 18:26:54 +01:00
|
|
|
#if 0
|
1999-02-26 12:11:13 +01:00
|
|
|
LPDRIVERITEMA pDrvr;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
/* FIXME: This is a very bad solution */
|
1999-02-26 12:11:13 +01:00
|
|
|
pDrvr = (LPDRIVERITEMA) HeapAlloc(MSACM_hHeap, HEAP_ZERO_MEMORY, sizeof(DRIVERITEMA));
|
1998-10-11 19:00:29 +02:00
|
|
|
pDrvr->count = 1;
|
|
|
|
pDrvr->driverproc = pfnDriverProc;
|
|
|
|
|
|
|
|
/* FIXME: Send DRV_OPEN among others to DriverProc */
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
return (HDRVR) pDrvr;
|
1999-01-26 18:26:54 +01:00
|
|
|
#else
|
1999-02-26 12:11:13 +01:00
|
|
|
return (HDRVR) 0;
|
1999-01-26 18:26:54 +01:00
|
|
|
#endif
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|