1999-10-31 19:29:16 +01:00
|
|
|
/* -*- tab-width: 8; c-basic-offset: 4 -*- */
|
|
|
|
|
1998-10-11 19:00:29 +02:00
|
|
|
/*
|
|
|
|
* MSACM32 library
|
|
|
|
*
|
|
|
|
* Copyright 1998 Patrik Stridvall
|
1999-10-31 19:29:16 +01:00
|
|
|
* 1999 Eric Pouech
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
|
|
|
|
1999-09-11 18:27:20 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
1999-02-17 14:51:06 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "wingdi.h"
|
1999-02-17 14:51:06 +01:00
|
|
|
#include "winuser.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "mmsystem.h"
|
|
|
|
#include "msacm.h"
|
|
|
|
#include "msacmdrv.h"
|
1999-10-31 19:29:16 +01:00
|
|
|
#include "wineacm.h"
|
1999-05-14 10:17:14 +02:00
|
|
|
#include "debugtools.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
|
2000-11-13 05:16:05 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(msacm);
|
1999-10-31 19:29:16 +01:00
|
|
|
|
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
|
|
|
|
|
|
|
/***********************************************************************
|
2000-08-26 06:33:00 +02:00
|
|
|
* MSACM_RegisterDriver()
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
1999-10-31 19:29:16 +01:00
|
|
|
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));
|
2000-08-26 06:33:00 +02:00
|
|
|
padid->obj.dwType = WINE_ACMOBJ_DRIVERID;
|
|
|
|
padid->obj.pACMDriverID = padid;
|
2000-11-13 05:16:05 +01:00
|
|
|
padid->pszDriverAlias = NULL;
|
|
|
|
if (pszDriverAlias)
|
|
|
|
{
|
|
|
|
padid->pszDriverAlias = HeapAlloc( MSACM_hHeap, 0, strlen(pszDriverAlias)+1 );
|
|
|
|
strcpy( padid->pszDriverAlias, pszDriverAlias );
|
|
|
|
}
|
|
|
|
padid->pszFileName = NULL;
|
|
|
|
if (pszFileName)
|
|
|
|
{
|
|
|
|
padid->pszFileName = HeapAlloc( MSACM_hHeap, 0, strlen(pszFileName)+1 );
|
|
|
|
strcpy( padid->pszFileName, pszFileName );
|
|
|
|
}
|
1999-10-31 19:29:16 +01:00
|
|
|
padid->hInstModule = hinstModule;
|
|
|
|
padid->bEnabled = TRUE;
|
1999-12-12 22:28:09 +01:00
|
|
|
padid->pACMDriverList = NULL;
|
1999-10-31 19:29:16 +01:00
|
|
|
padid->pNextACMDriverID = NULL;
|
1999-12-12 22:28:09 +01:00
|
|
|
padid->pPrevACMDriverID = MSACM_pLastACMDriverID;
|
1999-10-31 19:29:16 +01:00
|
|
|
if (MSACM_pLastACMDriverID)
|
|
|
|
MSACM_pLastACMDriverID->pNextACMDriverID = padid;
|
|
|
|
MSACM_pLastACMDriverID = padid;
|
|
|
|
if (!MSACM_pFirstACMDriverID)
|
|
|
|
MSACM_pFirstACMDriverID = padid;
|
|
|
|
|
|
|
|
return padid;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-08-26 06:33:00 +02:00
|
|
|
* MSACM_RegisterAllDrivers()
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
1999-10-31 19:29:16 +01:00
|
|
|
void MSACM_RegisterAllDrivers(void)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-10-31 19:29:16 +01:00
|
|
|
LPSTR pszBuffer;
|
|
|
|
DWORD dwBufferLength;
|
2000-10-12 22:46:49 +02:00
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
/* 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) {
|
2000-09-26 01:30:56 +02:00
|
|
|
if (!strncasecmp("MSACM.", s, 6)) {
|
1999-10-31 19:29:16 +01:00
|
|
|
char *s2 = s;
|
|
|
|
while (*s2 != '\0' && *s2 != '=') s2++;
|
|
|
|
if (*s2) {
|
2000-10-12 22:46:49 +02:00
|
|
|
*s2 = '\0';
|
|
|
|
MSACM_RegisterDriver(s, s2 + 1, 0);
|
|
|
|
*s2 = '=';
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
}
|
2000-08-14 16:41:19 +02:00
|
|
|
s += strlen(s) + 1; /* Either next char or \0 */
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
}
|
1999-10-31 19:29:16 +01:00
|
|
|
|
|
|
|
HeapFree(MSACM_hHeap, 0, pszBuffer);
|
2000-10-12 22:46:49 +02:00
|
|
|
|
|
|
|
MSACM_RegisterDriver("msacm32.dll", "msacm32.dll", 0);
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-08-26 06:33:00 +02:00
|
|
|
* MSACM_UnregisterDriver()
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-10-31 19:29:16 +01:00
|
|
|
PWINE_ACMDRIVERID pNextACMDriverID;
|
|
|
|
|
1999-12-12 22:28:09 +01:00
|
|
|
while (p->pACMDriverList)
|
|
|
|
acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
|
1999-10-31 19:29:16 +01:00
|
|
|
|
|
|
|
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)
|
1999-12-12 22:28:09 +01:00
|
|
|
MSACM_pLastACMDriverID = p->pPrevACMDriverID;
|
1999-10-31 19:29:16 +01:00
|
|
|
|
1999-12-12 22:28:09 +01:00
|
|
|
if (p->pPrevACMDriverID)
|
|
|
|
p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
|
1999-10-31 19:29:16 +01:00
|
|
|
if (p->pNextACMDriverID)
|
1999-12-12 22:28:09 +01:00
|
|
|
p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID;
|
1999-10-31 19:29:16 +01:00
|
|
|
|
|
|
|
pNextACMDriverID = p->pNextACMDriverID;
|
|
|
|
|
|
|
|
HeapFree(MSACM_hHeap, 0, p);
|
|
|
|
|
|
|
|
return pNextACMDriverID;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-08-26 06:33:00 +02:00
|
|
|
* MSACM_UnregisterAllDrivers()
|
1998-10-11 19:00:29 +02:00
|
|
|
* FIXME
|
|
|
|
* Where should this function be called?
|
|
|
|
*/
|
1999-10-31 19:29:16 +01:00
|
|
|
void MSACM_UnregisterAllDrivers(void)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-10-31 19:29:16 +01:00
|
|
|
PWINE_ACMDRIVERID p;
|
|
|
|
|
|
|
|
for (p = MSACM_pFirstACMDriverID; p; p = MSACM_UnregisterDriver(p));
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-08-26 06:33:00 +02:00
|
|
|
* MSACM_GetObj()
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
2000-08-26 06:33:00 +02:00
|
|
|
PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj, DWORD type)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
2000-08-26 06:33:00 +02:00
|
|
|
PWINE_ACMOBJ pao = (PWINE_ACMOBJ)hObj;
|
|
|
|
|
2000-10-02 05:33:20 +02:00
|
|
|
if (pao == NULL || IsBadReadPtr(pao, sizeof(WINE_ACMOBJ)) ||
|
2000-08-26 06:33:00 +02:00
|
|
|
((type != WINE_ACMOBJ_DONTCARE) && (type != pao->dwType)))
|
|
|
|
return NULL;
|
|
|
|
return pao;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-08-26 06:33:00 +02:00
|
|
|
* MSACM_GetDriverID()
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
2000-08-26 06:33:00 +02:00
|
|
|
PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
2000-08-26 06:33:00 +02:00
|
|
|
return (PWINE_ACMDRIVERID)MSACM_GetObj((HACMOBJ)hDriverID, WINE_ACMOBJ_DRIVERID);
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-08-26 06:33:00 +02:00
|
|
|
* MSACM_GetDriver()
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
2000-08-26 06:33:00 +02:00
|
|
|
PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
2000-08-26 06:33:00 +02:00
|
|
|
return (PWINE_ACMDRIVER)MSACM_GetObj((HACMOBJ)hDriver, WINE_ACMOBJ_DRIVER);
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
2000-08-26 06:33:00 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_Message()
|
|
|
|
*/
|
|
|
|
MMRESULT MSACM_Message(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
|
|
|
|
{
|
|
|
|
PWINE_ACMDRIVER pad = MSACM_GetDriver(had);
|
1998-10-11 19:00:29 +02:00
|
|
|
|
2000-08-26 06:33:00 +02:00
|
|
|
return pad ? SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2) : MMSYSERR_INVALHANDLE;
|
|
|
|
}
|