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
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-09-11 18:27:20 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#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"
|
2001-04-23 20:14:41 +02:00
|
|
|
#include "winreg.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
#include "mmsystem.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "mmreg.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
#include "msacm.h"
|
|
|
|
#include "msacmdrv.h"
|
1999-10-31 19:29:16 +01:00
|
|
|
#include "wineacm.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msacm);
|
1999-10-31 19:29:16 +01:00
|
|
|
|
1998-10-11 19:00:29 +02:00
|
|
|
/**********************************************************************/
|
|
|
|
|
2003-01-15 00:43:41 +01:00
|
|
|
HANDLE MSACM_hHeap = NULL;
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL;
|
2009-01-08 22:30:53 +01:00
|
|
|
static PWINE_ACMDRIVERID MSACM_pLastACMDriverID;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
2006-01-18 12:06:56 +01:00
|
|
|
static DWORD MSACM_suspendBroadcastCount = 0;
|
|
|
|
static BOOL MSACM_pendingBroadcast = FALSE;
|
2006-01-18 12:10:59 +01:00
|
|
|
static PWINE_ACMNOTIFYWND MSACM_pFirstACMNotifyWnd = NULL;
|
|
|
|
static PWINE_ACMNOTIFYWND MSACM_pLastACMNotifyWnd = NULL;
|
2006-01-18 12:06:56 +01:00
|
|
|
|
2006-01-18 11:44:26 +01:00
|
|
|
static void MSACM_ReorderDriversByPriority(void);
|
|
|
|
|
2006-01-18 12:07:42 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_RegisterDriverFromRegistry()
|
|
|
|
*/
|
|
|
|
PWINE_ACMDRIVERID MSACM_RegisterDriverFromRegistry(LPCWSTR pszRegEntry)
|
|
|
|
{
|
|
|
|
static const WCHAR msacmW[] = {'M','S','A','C','M','.'};
|
|
|
|
static const WCHAR drvkey[] = {'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s',' ','N','T','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'D','r','i','v','e','r','s','3','2','\0'};
|
|
|
|
WCHAR buf[2048];
|
|
|
|
DWORD bufLen, lRet;
|
|
|
|
HKEY hKey;
|
|
|
|
PWINE_ACMDRIVERID padid = NULL;
|
|
|
|
|
|
|
|
/* The requested registry entry must have the format msacm.XXXXX in order to
|
|
|
|
be recognized in any future sessions of msacm
|
|
|
|
*/
|
2019-06-12 09:38:13 +02:00
|
|
|
if (0 == wcsnicmp(pszRegEntry, msacmW, ARRAY_SIZE(msacmW))) {
|
2006-01-18 12:07:42 +01:00
|
|
|
lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, drvkey, 0, KEY_QUERY_VALUE, &hKey);
|
|
|
|
if (lRet != ERROR_SUCCESS) {
|
2006-10-12 21:35:06 +02:00
|
|
|
WARN("unable to open registry key - 0x%08x\n", lRet);
|
2006-01-18 12:07:42 +01:00
|
|
|
} else {
|
|
|
|
bufLen = sizeof(buf);
|
|
|
|
lRet = RegQueryValueExW(hKey, pszRegEntry, NULL, NULL, (LPBYTE)buf, &bufLen);
|
|
|
|
if (lRet != ERROR_SUCCESS) {
|
2006-10-12 21:35:06 +02:00
|
|
|
WARN("unable to query requested subkey %s - 0x%08x\n", debugstr_w(pszRegEntry), lRet);
|
2006-01-18 12:07:42 +01:00
|
|
|
} else {
|
|
|
|
MSACM_RegisterDriver(pszRegEntry, buf, 0);
|
|
|
|
}
|
|
|
|
RegCloseKey( hKey );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return padid;
|
|
|
|
}
|
|
|
|
|
2001-04-23 20:14:41 +02:00
|
|
|
#if 0
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_DumpCache
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static void MSACM_DumpCache(PWINE_ACMDRIVERID padid)
|
2001-04-23 20:14:41 +02:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
TRACE("cFilterTags=%lu cFormatTags=%lu fdwSupport=%08lx\n",
|
|
|
|
padid->cFilterTags, padid->cFormatTags, padid->fdwSupport);
|
|
|
|
for (i = 0; i < padid->cache->cFormatTags; i++) {
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("\tdwFormatTag=%lu cbwfx=%lu\n",
|
2001-04-23 20:14:41 +02:00
|
|
|
padid->aFormatTag[i].dwFormatTag, padid->aFormatTag[i].cbwfx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_FindFormatTagInCache [internal]
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2001-04-23 20:14:41 +02:00
|
|
|
* Returns TRUE is the format tag fmtTag is present in the cache.
|
|
|
|
* If so, idx is set to its index.
|
|
|
|
*/
|
2007-05-27 18:52:30 +02:00
|
|
|
BOOL MSACM_FindFormatTagInCache(const WINE_ACMDRIVERID* padid, DWORD fmtTag, LPDWORD idx)
|
2001-04-23 20:14:41 +02:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < padid->cFormatTags; i++) {
|
|
|
|
if (padid->aFormatTag[i].dwFormatTag == fmtTag) {
|
|
|
|
if (idx) *idx = i;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_FillCache
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static BOOL MSACM_FillCache(PWINE_ACMDRIVERID padid)
|
2001-04-23 20:14:41 +02:00
|
|
|
{
|
2002-02-08 18:11:22 +01:00
|
|
|
HACMDRIVER had = 0;
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int ntag;
|
2002-02-08 18:11:22 +01:00
|
|
|
ACMDRIVERDETAILSW add;
|
|
|
|
ACMFORMATTAGDETAILSW aftd;
|
2001-04-23 20:14:41 +02:00
|
|
|
|
|
|
|
if (acmDriverOpen(&had, (HACMDRIVERID)padid, 0) != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
padid->aFormatTag = NULL;
|
|
|
|
add.cbStruct = sizeof(add);
|
|
|
|
if (MSACM_Message(had, ACMDM_DRIVER_DETAILS, (LPARAM)&add, 0))
|
|
|
|
goto errCleanUp;
|
|
|
|
|
|
|
|
if (add.cFormatTags > 0) {
|
2002-06-01 01:06:46 +02:00
|
|
|
padid->aFormatTag = HeapAlloc(MSACM_hHeap, HEAP_ZERO_MEMORY,
|
2001-04-23 20:14:41 +02:00
|
|
|
add.cFormatTags * sizeof(padid->aFormatTag[0]));
|
|
|
|
if (!padid->aFormatTag) goto errCleanUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
padid->cFormatTags = add.cFormatTags;
|
|
|
|
padid->cFilterTags = add.cFilterTags;
|
|
|
|
padid->fdwSupport = add.fdwSupport;
|
|
|
|
|
|
|
|
aftd.cbStruct = sizeof(aftd);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-04-23 20:14:41 +02:00
|
|
|
for (ntag = 0; ntag < add.cFormatTags; ntag++) {
|
2002-02-08 18:11:22 +01:00
|
|
|
aftd.dwFormatTagIndex = ntag;
|
|
|
|
if (MSACM_Message(had, ACMDM_FORMATTAG_DETAILS, (LPARAM)&aftd, ACM_FORMATTAGDETAILSF_INDEX)) {
|
2003-07-02 02:40:14 +02:00
|
|
|
TRACE("IIOs (%s)\n", debugstr_w(padid->pszDriverAlias));
|
2001-04-23 20:14:41 +02:00
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
padid->aFormatTag[ntag].dwFormatTag = aftd.dwFormatTag;
|
2002-02-08 18:11:22 +01:00
|
|
|
padid->aFormatTag[ntag].cbwfx = aftd.cbFormatSize;
|
2001-04-23 20:14:41 +02:00
|
|
|
}
|
2002-02-08 18:11:22 +01:00
|
|
|
|
2001-04-23 20:14:41 +02:00
|
|
|
acmDriverClose(had, 0);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
errCleanUp:
|
|
|
|
if (had) acmDriverClose(had, 0);
|
|
|
|
HeapFree(MSACM_hHeap, 0, padid->aFormatTag);
|
|
|
|
padid->aFormatTag = NULL;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_GetRegistryKey
|
|
|
|
*/
|
2003-07-02 02:40:14 +02:00
|
|
|
static LPWSTR MSACM_GetRegistryKey(const WINE_ACMDRIVERID* padid)
|
2001-04-23 20:14:41 +02:00
|
|
|
{
|
2003-07-02 02:40:14 +02:00
|
|
|
static const WCHAR baseKey[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'A','u','d','i','o','C','o','m','p','r','e','s','s','i','o','n','M','a','n','a','g','e','r','\\',
|
|
|
|
'D','r','i','v','e','r','C','a','c','h','e','\\','\0'};
|
|
|
|
LPWSTR ret;
|
2001-04-23 20:14:41 +02:00
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!padid->pszDriverAlias) {
|
|
|
|
ERR("No alias needed for registry entry\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-06-12 09:38:13 +02:00
|
|
|
len = lstrlenW(baseKey);
|
|
|
|
ret = HeapAlloc(MSACM_hHeap, 0, (len + lstrlenW(padid->pszDriverAlias) + 1) * sizeof(WCHAR));
|
2001-04-23 20:14:41 +02:00
|
|
|
if (!ret) return NULL;
|
|
|
|
|
2019-06-12 09:38:13 +02:00
|
|
|
lstrcpyW(ret, baseKey);
|
|
|
|
lstrcpyW(ret + len, padid->pszDriverAlias);
|
2003-07-02 02:40:14 +02:00
|
|
|
CharLowerW(ret + len);
|
2001-04-23 20:14:41 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_ReadCache
|
|
|
|
*/
|
|
|
|
static BOOL MSACM_ReadCache(PWINE_ACMDRIVERID padid)
|
|
|
|
{
|
2003-07-02 02:40:14 +02:00
|
|
|
LPWSTR key = MSACM_GetRegistryKey(padid);
|
2001-04-23 20:14:41 +02:00
|
|
|
HKEY hKey;
|
|
|
|
DWORD type, size;
|
|
|
|
|
|
|
|
if (!key) return FALSE;
|
|
|
|
|
|
|
|
padid->aFormatTag = NULL;
|
|
|
|
|
2003-07-02 02:40:14 +02:00
|
|
|
if (RegCreateKeyW(HKEY_LOCAL_MACHINE, key, &hKey))
|
2001-04-23 20:14:41 +02:00
|
|
|
goto errCleanUp;
|
|
|
|
|
|
|
|
size = sizeof(padid->cFormatTags);
|
|
|
|
if (RegQueryValueExA(hKey, "cFormatTags", 0, &type, (void*)&padid->cFormatTags, &size))
|
|
|
|
goto errCleanUp;
|
|
|
|
size = sizeof(padid->cFilterTags);
|
|
|
|
if (RegQueryValueExA(hKey, "cFilterTags", 0, &type, (void*)&padid->cFilterTags, &size))
|
|
|
|
goto errCleanUp;
|
|
|
|
size = sizeof(padid->fdwSupport);
|
|
|
|
if (RegQueryValueExA(hKey, "fdwSupport", 0, &type, (void*)&padid->fdwSupport, &size))
|
|
|
|
goto errCleanUp;
|
|
|
|
|
|
|
|
if (padid->cFormatTags > 0) {
|
|
|
|
size = padid->cFormatTags * sizeof(padid->aFormatTag[0]);
|
|
|
|
padid->aFormatTag = HeapAlloc(MSACM_hHeap, HEAP_ZERO_MEMORY, size);
|
|
|
|
if (!padid->aFormatTag) goto errCleanUp;
|
|
|
|
if (RegQueryValueExA(hKey, "aFormatTagCache", 0, &type, (void*)padid->aFormatTag, &size))
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
HeapFree(MSACM_hHeap, 0, key);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
errCleanUp:
|
|
|
|
HeapFree(MSACM_hHeap, 0, key);
|
|
|
|
HeapFree(MSACM_hHeap, 0, padid->aFormatTag);
|
|
|
|
padid->aFormatTag = NULL;
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_WriteCache
|
|
|
|
*/
|
2007-05-27 18:52:30 +02:00
|
|
|
static BOOL MSACM_WriteCache(const WINE_ACMDRIVERID *padid)
|
2001-04-23 20:14:41 +02:00
|
|
|
{
|
2003-07-02 02:40:14 +02:00
|
|
|
LPWSTR key = MSACM_GetRegistryKey(padid);
|
2001-04-23 20:14:41 +02:00
|
|
|
HKEY hKey;
|
|
|
|
|
|
|
|
if (!key) return FALSE;
|
|
|
|
|
2003-07-02 02:40:14 +02:00
|
|
|
if (RegCreateKeyW(HKEY_LOCAL_MACHINE, key, &hKey))
|
2001-04-23 20:14:41 +02:00
|
|
|
goto errCleanUp;
|
|
|
|
|
2007-05-27 18:52:30 +02:00
|
|
|
if (RegSetValueExA(hKey, "cFormatTags", 0, REG_DWORD, (const void*)&padid->cFormatTags, sizeof(DWORD)))
|
2001-04-23 20:14:41 +02:00
|
|
|
goto errCleanUp;
|
2007-05-27 18:52:30 +02:00
|
|
|
if (RegSetValueExA(hKey, "cFilterTags", 0, REG_DWORD, (const void*)&padid->cFilterTags, sizeof(DWORD)))
|
2001-04-23 20:14:41 +02:00
|
|
|
goto errCleanUp;
|
2007-05-27 18:52:30 +02:00
|
|
|
if (RegSetValueExA(hKey, "fdwSupport", 0, REG_DWORD, (const void*)&padid->fdwSupport, sizeof(DWORD)))
|
2001-04-23 20:14:41 +02:00
|
|
|
goto errCleanUp;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (RegSetValueExA(hKey, "aFormatTagCache", 0, REG_BINARY,
|
|
|
|
(void*)padid->aFormatTag,
|
2001-04-23 20:14:41 +02:00
|
|
|
padid->cFormatTags * sizeof(padid->aFormatTag[0])))
|
|
|
|
goto errCleanUp;
|
|
|
|
HeapFree(MSACM_hHeap, 0, key);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
errCleanUp:
|
|
|
|
HeapFree(MSACM_hHeap, 0, key);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1998-10-11 19:00:29 +02:00
|
|
|
/***********************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* MSACM_RegisterDriver()
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
2004-04-20 02:34:52 +02:00
|
|
|
PWINE_ACMDRIVERID MSACM_RegisterDriver(LPCWSTR pszDriverAlias, LPCWSTR pszFileName,
|
2006-01-18 12:16:57 +01:00
|
|
|
PWINE_ACMLOCALDRIVER pLocalDriver)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2001-05-22 21:21:16 +02:00
|
|
|
PWINE_ACMDRIVERID padid;
|
1999-10-31 19:29:16 +01:00
|
|
|
|
2003-07-02 02:40:14 +02:00
|
|
|
TRACE("(%s, %s, %p)\n",
|
2006-01-18 12:16:57 +01:00
|
|
|
debugstr_w(pszDriverAlias), debugstr_w(pszFileName), pLocalDriver);
|
1999-10-31 19:29:16 +01:00
|
|
|
|
2005-03-24 22:01:35 +01:00
|
|
|
padid = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
|
2009-01-31 21:53:36 +01:00
|
|
|
if (!padid)
|
|
|
|
return NULL;
|
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)
|
|
|
|
{
|
2019-06-12 09:38:13 +02:00
|
|
|
padid->pszDriverAlias = HeapAlloc( MSACM_hHeap, 0, (lstrlenW(pszDriverAlias)+1) * sizeof(WCHAR) );
|
2009-01-31 21:53:36 +01:00
|
|
|
if (!padid->pszDriverAlias) {
|
|
|
|
HeapFree(MSACM_hHeap, 0, padid);
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-06-12 09:38:13 +02:00
|
|
|
lstrcpyW( padid->pszDriverAlias, pszDriverAlias );
|
2000-11-13 05:16:05 +01:00
|
|
|
}
|
|
|
|
padid->pszFileName = NULL;
|
|
|
|
if (pszFileName)
|
|
|
|
{
|
2019-06-12 09:38:13 +02:00
|
|
|
padid->pszFileName = HeapAlloc( MSACM_hHeap, 0, (lstrlenW(pszFileName)+1) * sizeof(WCHAR) );
|
2009-01-31 21:53:36 +01:00
|
|
|
if (!padid->pszFileName) {
|
|
|
|
HeapFree(MSACM_hHeap, 0, padid->pszDriverAlias);
|
|
|
|
HeapFree(MSACM_hHeap, 0, padid);
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-06-12 09:38:13 +02:00
|
|
|
lstrcpyW( padid->pszFileName, pszFileName );
|
2000-11-13 05:16:05 +01:00
|
|
|
}
|
2006-01-18 12:16:57 +01:00
|
|
|
padid->pLocalDriver = pLocalDriver;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-12-12 22:28:09 +01:00
|
|
|
padid->pACMDriverList = NULL;
|
2006-01-18 12:16:57 +01:00
|
|
|
|
|
|
|
if (pLocalDriver) {
|
|
|
|
padid->pPrevACMDriverID = NULL;
|
|
|
|
padid->pNextACMDriverID = MSACM_pFirstACMDriverID;
|
|
|
|
if (MSACM_pFirstACMDriverID)
|
|
|
|
MSACM_pFirstACMDriverID->pPrevACMDriverID = padid;
|
|
|
|
MSACM_pFirstACMDriverID = padid;
|
|
|
|
if (!MSACM_pLastACMDriverID)
|
|
|
|
MSACM_pLastACMDriverID = padid;
|
|
|
|
} else {
|
|
|
|
padid->pNextACMDriverID = NULL;
|
|
|
|
padid->pPrevACMDriverID = MSACM_pLastACMDriverID;
|
|
|
|
if (MSACM_pLastACMDriverID)
|
|
|
|
MSACM_pLastACMDriverID->pNextACMDriverID = padid;
|
|
|
|
MSACM_pLastACMDriverID = padid;
|
|
|
|
if (!MSACM_pFirstACMDriverID)
|
|
|
|
MSACM_pFirstACMDriverID = padid;
|
|
|
|
}
|
2001-04-23 20:14:41 +02:00
|
|
|
/* disable the driver if we cannot load the cache */
|
2006-01-18 12:16:57 +01:00
|
|
|
if ((!padid->pszDriverAlias || !MSACM_ReadCache(padid)) && !MSACM_FillCache(padid)) {
|
2003-07-02 02:40:14 +02:00
|
|
|
WARN("Couldn't load cache for ACM driver (%s)\n", debugstr_w(pszFileName));
|
2001-04-23 20:14:41 +02:00
|
|
|
MSACM_UnregisterDriver(padid);
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-01-18 12:16:57 +01:00
|
|
|
|
|
|
|
if (pLocalDriver) padid->fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_LOCAL;
|
1999-10-31 19:29:16 +01:00
|
|
|
return padid;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2002-06-01 01:06:46 +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
|
|
|
{
|
2004-04-20 02:34:52 +02:00
|
|
|
static const WCHAR msacm32[] = {'m','s','a','c','m','3','2','.','d','l','l','\0'};
|
|
|
|
static const WCHAR msacmW[] = {'M','S','A','C','M','.'};
|
|
|
|
static const WCHAR drv32[] = {'d','r','i','v','e','r','s','3','2','\0'};
|
|
|
|
static const WCHAR sys[] = {'s','y','s','t','e','m','.','i','n','i','\0'};
|
2004-06-30 20:11:39 +02:00
|
|
|
static const WCHAR drvkey[] = {'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s',' ','N','T','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'D','r','i','v','e','r','s','3','2','\0'};
|
2011-06-15 22:22:39 +02:00
|
|
|
DWORD i, cnt, bufLen, lRet, type;
|
|
|
|
WCHAR buf[2048], valname[64], *name, *s;
|
2004-06-30 20:11:39 +02:00
|
|
|
FILETIME lastWrite;
|
|
|
|
HKEY hKey;
|
|
|
|
|
|
|
|
/* FIXME: What if the user edits system.ini while the program is running?
|
|
|
|
* Does Windows handle that? */
|
|
|
|
if (MSACM_pFirstACMDriverID) return;
|
|
|
|
|
|
|
|
lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, drvkey, 0, KEY_QUERY_VALUE, &hKey);
|
|
|
|
if (lRet == ERROR_SUCCESS) {
|
|
|
|
RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
for (i = 0; i < cnt; i++) {
|
2018-07-26 00:05:50 +02:00
|
|
|
bufLen = ARRAY_SIZE(buf);
|
2004-06-30 20:11:39 +02:00
|
|
|
lRet = RegEnumKeyExW(hKey, i, buf, &bufLen, 0, 0, 0, &lastWrite);
|
|
|
|
if (lRet != ERROR_SUCCESS) continue;
|
2019-06-12 09:38:13 +02:00
|
|
|
if (wcsnicmp(buf, msacmW, ARRAY_SIZE(msacmW))) continue;
|
|
|
|
if (!(name = wcschr(buf, '='))) continue;
|
2004-06-30 20:11:39 +02:00
|
|
|
*name = 0;
|
|
|
|
MSACM_RegisterDriver(buf, name + 1, 0);
|
|
|
|
}
|
2011-06-15 22:22:39 +02:00
|
|
|
i = 0;
|
2018-07-26 00:05:50 +02:00
|
|
|
cnt = ARRAY_SIZE(valname);
|
2011-06-15 22:22:39 +02:00
|
|
|
bufLen = sizeof(buf);
|
|
|
|
while(RegEnumValueW(hKey, i, valname, &cnt, 0,
|
|
|
|
&type, (BYTE*)buf, &bufLen) == ERROR_SUCCESS){
|
2019-06-12 09:38:13 +02:00
|
|
|
if (!wcsnicmp(valname, msacmW, ARRAY_SIZE(msacmW)))
|
2011-06-15 22:22:39 +02:00
|
|
|
MSACM_RegisterDriver(valname, buf, 0);
|
|
|
|
++i;
|
|
|
|
}
|
2004-06-30 20:11:39 +02:00
|
|
|
RegCloseKey( hKey );
|
|
|
|
}
|
2000-10-12 22:46:49 +02:00
|
|
|
|
2018-07-26 00:05:50 +02:00
|
|
|
if (GetPrivateProfileSectionW(drv32, buf, ARRAY_SIZE(buf), sys))
|
2003-07-02 02:40:14 +02:00
|
|
|
{
|
2019-06-12 09:38:13 +02:00
|
|
|
for(s = buf; *s; s += lstrlenW(s) + 1)
|
2004-06-30 20:11:39 +02:00
|
|
|
{
|
2019-06-12 09:38:13 +02:00
|
|
|
if (wcsnicmp(s, msacmW, ARRAY_SIZE(msacmW))) continue;
|
|
|
|
if (!(name = wcschr(s, '='))) continue;
|
2004-06-30 20:11:39 +02:00
|
|
|
*name = 0;
|
|
|
|
MSACM_RegisterDriver(s, name + 1, 0);
|
|
|
|
*name = '=';
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
}
|
2006-01-18 11:44:26 +01:00
|
|
|
MSACM_ReorderDriversByPriority();
|
2003-07-02 02:40:14 +02:00
|
|
|
MSACM_RegisterDriver(msacm32, msacm32, 0);
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
2006-01-18 12:10:59 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_RegisterNotificationWindow()
|
|
|
|
*/
|
|
|
|
PWINE_ACMNOTIFYWND MSACM_RegisterNotificationWindow(HWND hNotifyWnd, DWORD dwNotifyMsg)
|
|
|
|
{
|
|
|
|
PWINE_ACMNOTIFYWND panwnd;
|
|
|
|
|
2006-10-12 21:35:06 +02:00
|
|
|
TRACE("(%p,0x%08x)\n", hNotifyWnd, dwNotifyMsg);
|
2006-01-18 12:10:59 +01:00
|
|
|
|
|
|
|
panwnd = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMNOTIFYWND));
|
|
|
|
panwnd->obj.dwType = WINE_ACMOBJ_NOTIFYWND;
|
|
|
|
panwnd->obj.pACMDriverID = 0;
|
|
|
|
panwnd->hNotifyWnd = hNotifyWnd;
|
|
|
|
panwnd->dwNotifyMsg = dwNotifyMsg;
|
|
|
|
panwnd->fdwSupport = 0;
|
|
|
|
|
|
|
|
panwnd->pNextACMNotifyWnd = NULL;
|
|
|
|
panwnd->pPrevACMNotifyWnd = MSACM_pLastACMNotifyWnd;
|
|
|
|
if (MSACM_pLastACMNotifyWnd)
|
|
|
|
MSACM_pLastACMNotifyWnd->pNextACMNotifyWnd = panwnd;
|
|
|
|
MSACM_pLastACMNotifyWnd = panwnd;
|
|
|
|
if (!MSACM_pFirstACMNotifyWnd)
|
|
|
|
MSACM_pFirstACMNotifyWnd = panwnd;
|
|
|
|
|
|
|
|
return panwnd;
|
|
|
|
}
|
|
|
|
|
2006-01-18 12:06:56 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_BroadcastNotification()
|
|
|
|
*/
|
|
|
|
void MSACM_BroadcastNotification(void)
|
|
|
|
{
|
|
|
|
if (MSACM_suspendBroadcastCount <= 0) {
|
2006-01-18 12:10:59 +01:00
|
|
|
PWINE_ACMNOTIFYWND panwnd;
|
|
|
|
|
|
|
|
for (panwnd = MSACM_pFirstACMNotifyWnd; panwnd; panwnd = panwnd->pNextACMNotifyWnd)
|
|
|
|
if (!(panwnd->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED))
|
|
|
|
SendMessageW(panwnd->hNotifyWnd, panwnd->dwNotifyMsg, 0, 0);
|
2006-01-18 12:06:56 +01:00
|
|
|
} else {
|
|
|
|
MSACM_pendingBroadcast = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_DisableNotifications()
|
|
|
|
*/
|
|
|
|
void MSACM_DisableNotifications(void)
|
|
|
|
{
|
|
|
|
MSACM_suspendBroadcastCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_EnableNotifications()
|
|
|
|
*/
|
|
|
|
void MSACM_EnableNotifications(void)
|
|
|
|
{
|
|
|
|
if (MSACM_suspendBroadcastCount > 0) {
|
|
|
|
MSACM_suspendBroadcastCount--;
|
|
|
|
if (MSACM_suspendBroadcastCount == 0 && MSACM_pendingBroadcast) {
|
|
|
|
MSACM_pendingBroadcast = FALSE;
|
|
|
|
MSACM_BroadcastNotification();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-18 12:10:59 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_UnRegisterNotificationWindow()
|
|
|
|
*/
|
2007-05-27 18:52:30 +02:00
|
|
|
PWINE_ACMNOTIFYWND MSACM_UnRegisterNotificationWindow(const WINE_ACMNOTIFYWND *panwnd)
|
2006-01-18 12:10:59 +01:00
|
|
|
{
|
|
|
|
PWINE_ACMNOTIFYWND p;
|
|
|
|
|
|
|
|
for (p = MSACM_pFirstACMNotifyWnd; p; p = p->pNextACMNotifyWnd) {
|
|
|
|
if (p == panwnd) {
|
|
|
|
PWINE_ACMNOTIFYWND pNext = p->pNextACMNotifyWnd;
|
|
|
|
|
|
|
|
if (p->pPrevACMNotifyWnd) p->pPrevACMNotifyWnd->pNextACMNotifyWnd = p->pNextACMNotifyWnd;
|
|
|
|
if (p->pNextACMNotifyWnd) p->pNextACMNotifyWnd->pPrevACMNotifyWnd = p->pPrevACMNotifyWnd;
|
|
|
|
if (MSACM_pFirstACMNotifyWnd == p) MSACM_pFirstACMNotifyWnd = p->pNextACMNotifyWnd;
|
|
|
|
if (MSACM_pLastACMNotifyWnd == p) MSACM_pLastACMNotifyWnd = p->pPrevACMNotifyWnd;
|
|
|
|
HeapFree(MSACM_hHeap, 0, p);
|
|
|
|
|
|
|
|
return pNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-18 12:06:56 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_RePositionDriver()
|
|
|
|
*/
|
|
|
|
void MSACM_RePositionDriver(PWINE_ACMDRIVERID padid, DWORD dwPriority)
|
|
|
|
{
|
|
|
|
PWINE_ACMDRIVERID pTargetPosition = NULL;
|
|
|
|
|
|
|
|
/* Remove selected driver from linked list */
|
|
|
|
if (MSACM_pFirstACMDriverID == padid) {
|
|
|
|
MSACM_pFirstACMDriverID = padid->pNextACMDriverID;
|
|
|
|
}
|
|
|
|
if (MSACM_pLastACMDriverID == padid) {
|
|
|
|
MSACM_pLastACMDriverID = padid->pPrevACMDriverID;
|
|
|
|
}
|
|
|
|
if (padid->pPrevACMDriverID != NULL) {
|
|
|
|
padid->pPrevACMDriverID->pNextACMDriverID = padid->pNextACMDriverID;
|
|
|
|
}
|
|
|
|
if (padid->pNextACMDriverID != NULL) {
|
|
|
|
padid->pNextACMDriverID->pPrevACMDriverID = padid->pPrevACMDriverID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look up position where selected driver should be */
|
|
|
|
if (dwPriority == 1) {
|
|
|
|
pTargetPosition = padid->pPrevACMDriverID;
|
|
|
|
while (pTargetPosition->pPrevACMDriverID != NULL &&
|
|
|
|
!(pTargetPosition->pPrevACMDriverID->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_LOCAL)) {
|
|
|
|
pTargetPosition = pTargetPosition->pPrevACMDriverID;
|
|
|
|
}
|
|
|
|
} else if (dwPriority == -1) {
|
|
|
|
pTargetPosition = padid->pNextACMDriverID;
|
|
|
|
while (pTargetPosition->pNextACMDriverID != NULL) {
|
|
|
|
pTargetPosition = pTargetPosition->pNextACMDriverID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Place selected driver in selected position */
|
|
|
|
padid->pPrevACMDriverID = pTargetPosition->pPrevACMDriverID;
|
|
|
|
padid->pNextACMDriverID = pTargetPosition;
|
|
|
|
if (padid->pPrevACMDriverID != NULL) {
|
|
|
|
padid->pPrevACMDriverID->pNextACMDriverID = padid;
|
|
|
|
} else {
|
|
|
|
MSACM_pFirstACMDriverID = padid;
|
|
|
|
}
|
|
|
|
if (padid->pNextACMDriverID != NULL) {
|
|
|
|
padid->pNextACMDriverID->pPrevACMDriverID = padid;
|
|
|
|
} else {
|
|
|
|
MSACM_pLastACMDriverID = padid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-18 11:44:26 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_ReorderDriversByPriority()
|
|
|
|
* Reorders all drivers based on the priority list indicated by the registry key:
|
|
|
|
* HKCU\\Software\\Microsoft\\Multimedia\\Audio Compression Manager\\Priority v4.00
|
|
|
|
*/
|
|
|
|
static void MSACM_ReorderDriversByPriority(void)
|
|
|
|
{
|
|
|
|
PWINE_ACMDRIVERID padid;
|
|
|
|
unsigned int iNumDrivers;
|
|
|
|
PWINE_ACMDRIVERID * driverList = NULL;
|
|
|
|
HKEY hPriorityKey = NULL;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
/* Count drivers && alloc corresponding memory for list */
|
|
|
|
iNumDrivers = 0;
|
|
|
|
for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) iNumDrivers++;
|
|
|
|
if (iNumDrivers > 1)
|
|
|
|
{
|
|
|
|
LONG lError;
|
|
|
|
static const WCHAR basePriorityKey[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'M','u','l','t','i','m','e','d','i','a','\\',
|
|
|
|
'A','u','d','i','o',' ','C','o','m','p','r','e','s','s','i','o','n',' ','M','a','n','a','g','e','r','\\',
|
|
|
|
'P','r','i','o','r','i','t','y',' ','v','4','.','0','0','\0'
|
|
|
|
};
|
|
|
|
unsigned int i;
|
|
|
|
LONG lBufferLength;
|
|
|
|
WCHAR szBuffer[256];
|
|
|
|
|
|
|
|
driverList = HeapAlloc(MSACM_hHeap, 0, iNumDrivers * sizeof(PWINE_ACMDRIVERID));
|
|
|
|
if (!driverList)
|
|
|
|
{
|
|
|
|
ERR("out of memory\n");
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
lError = RegOpenKeyW(HKEY_CURRENT_USER, basePriorityKey, &hPriorityKey);
|
|
|
|
if (lError != ERROR_SUCCESS) {
|
|
|
|
TRACE("RegOpenKeyW failed, possibly key does not exist yet\n");
|
|
|
|
hPriorityKey = NULL;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy drivers into list to simplify linked list modification */
|
|
|
|
for (i = 0, padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID, i++)
|
|
|
|
{
|
|
|
|
driverList[i] = padid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query each of the priorities in turn. Alias key is in lowercase.
|
|
|
|
The general form of the priority record is the following:
|
|
|
|
"PriorityN" --> "1, msacm.driveralias"
|
|
|
|
where N is an integer, and the value is a string of the driver
|
|
|
|
alias, prefixed by "1, " for an enabled driver, or "0, " for a
|
|
|
|
disabled driver.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < iNumDrivers; i++)
|
|
|
|
{
|
|
|
|
static const WCHAR priorityTmpl[] = {'P','r','i','o','r','i','t','y','%','l','d','\0'};
|
|
|
|
WCHAR szSubKey[17];
|
|
|
|
unsigned int iTargetPosition;
|
|
|
|
unsigned int iCurrentPosition;
|
|
|
|
WCHAR * pAlias;
|
|
|
|
static const WCHAR sPrefix[] = {'m','s','a','c','m','.','\0'};
|
|
|
|
|
|
|
|
/* Build expected entry name */
|
2019-06-12 09:38:13 +02:00
|
|
|
swprintf(szSubKey, 17, priorityTmpl, i + 1);
|
2006-01-18 11:44:26 +01:00
|
|
|
lBufferLength = sizeof(szBuffer);
|
|
|
|
lError = RegQueryValueExW(hPriorityKey, szSubKey, NULL, NULL, (LPBYTE)szBuffer, (LPDWORD)&lBufferLength);
|
|
|
|
if (lError != ERROR_SUCCESS) continue;
|
|
|
|
|
|
|
|
/* Recovered driver alias should be at this position */
|
|
|
|
iTargetPosition = i;
|
|
|
|
|
|
|
|
/* Locate driver alias in driver list */
|
2019-06-12 09:38:13 +02:00
|
|
|
pAlias = wcsstr(szBuffer, sPrefix);
|
2006-01-18 11:44:26 +01:00
|
|
|
if (pAlias == NULL) continue;
|
|
|
|
|
|
|
|
for (iCurrentPosition = 0; iCurrentPosition < iNumDrivers; iCurrentPosition++) {
|
2019-06-12 09:38:13 +02:00
|
|
|
if (wcsicmp(driverList[iCurrentPosition]->pszDriverAlias, pAlias) == 0)
|
2006-01-18 11:44:26 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (iCurrentPosition < iNumDrivers && iTargetPosition != iCurrentPosition) {
|
|
|
|
padid = driverList[iTargetPosition];
|
|
|
|
driverList[iTargetPosition] = driverList[iCurrentPosition];
|
|
|
|
driverList[iCurrentPosition] = padid;
|
|
|
|
|
|
|
|
/* Locate enabled status */
|
|
|
|
if (szBuffer[0] == '1') {
|
|
|
|
driverList[iTargetPosition]->fdwSupport &= ~ACMDRIVERDETAILS_SUPPORTF_DISABLED;
|
|
|
|
} else if (szBuffer[0] == '0') {
|
|
|
|
driverList[iTargetPosition]->fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Re-assign pointers so that linked list traverses the ordered array */
|
|
|
|
for (i = 0; i < iNumDrivers; i++) {
|
|
|
|
driverList[i]->pPrevACMDriverID = (i > 0) ? driverList[i - 1] : NULL;
|
|
|
|
driverList[i]->pNextACMDriverID = (i < iNumDrivers - 1) ? driverList[i + 1] : NULL;
|
|
|
|
}
|
|
|
|
MSACM_pFirstACMDriverID = driverList[0];
|
|
|
|
MSACM_pLastACMDriverID = driverList[iNumDrivers - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
errCleanUp:
|
|
|
|
if (hPriorityKey != NULL) RegCloseKey(hPriorityKey);
|
2006-05-10 00:33:53 +02:00
|
|
|
HeapFree(MSACM_hHeap, 0, driverList);
|
2006-01-18 11:44:26 +01:00
|
|
|
}
|
|
|
|
|
2006-01-18 12:06:56 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_WriteCurrentPriorities()
|
|
|
|
* Writes out current order of driver priorities to registry key:
|
|
|
|
* HKCU\\Software\\Microsoft\\Multimedia\\Audio Compression Manager\\Priority v4.00
|
|
|
|
*/
|
|
|
|
void MSACM_WriteCurrentPriorities(void)
|
|
|
|
{
|
|
|
|
LONG lError;
|
|
|
|
HKEY hPriorityKey;
|
|
|
|
static const WCHAR basePriorityKey[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'M','u','l','t','i','m','e','d','i','a','\\',
|
|
|
|
'A','u','d','i','o',' ','C','o','m','p','r','e','s','s','i','o','n',' ','M','a','n','a','g','e','r','\\',
|
|
|
|
'P','r','i','o','r','i','t','y',' ','v','4','.','0','0','\0'
|
|
|
|
};
|
|
|
|
PWINE_ACMDRIVERID padid;
|
|
|
|
DWORD dwPriorityCounter;
|
|
|
|
static const WCHAR priorityTmpl[] = {'P','r','i','o','r','i','t','y','%','l','d','\0'};
|
|
|
|
static const WCHAR valueTmpl[] = {'%','c',',',' ','%','s','\0'};
|
|
|
|
static const WCHAR converterAlias[] = {'I','n','t','e','r','n','a','l',' ','P','C','M',' ','C','o','n','v','e','r','t','e','r','\0'};
|
|
|
|
WCHAR szSubKey[17];
|
|
|
|
WCHAR szBuffer[256];
|
|
|
|
|
|
|
|
/* Delete ACM priority key and create it anew */
|
|
|
|
lError = RegDeleteKeyW(HKEY_CURRENT_USER, basePriorityKey);
|
|
|
|
if (lError != ERROR_SUCCESS && lError != ERROR_FILE_NOT_FOUND) {
|
2006-10-12 21:35:06 +02:00
|
|
|
ERR("unable to remove current key %s (0x%08x) - priority changes won't persist past application end.\n",
|
2006-01-18 12:06:56 +01:00
|
|
|
debugstr_w(basePriorityKey), lError);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
lError = RegCreateKeyW(HKEY_CURRENT_USER, basePriorityKey, &hPriorityKey);
|
|
|
|
if (lError != ERROR_SUCCESS) {
|
2006-10-12 21:35:06 +02:00
|
|
|
ERR("unable to create key %s (0x%08x) - priority changes won't persist past application end.\n",
|
2006-01-18 12:06:56 +01:00
|
|
|
debugstr_w(basePriorityKey), lError);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write current list of priorities */
|
|
|
|
for (dwPriorityCounter = 0, padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID) {
|
|
|
|
if (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_LOCAL) continue;
|
|
|
|
if (padid->pszDriverAlias == NULL) continue; /* internal PCM converter is last */
|
|
|
|
|
|
|
|
/* Build required value name */
|
|
|
|
dwPriorityCounter++;
|
2019-06-12 09:38:13 +02:00
|
|
|
swprintf(szSubKey, 17, priorityTmpl, dwPriorityCounter);
|
2006-01-18 12:06:56 +01:00
|
|
|
|
|
|
|
/* Value has a 1 in front for enabled drivers and 0 for disabled drivers */
|
2019-06-12 09:38:13 +02:00
|
|
|
swprintf(szBuffer, 256, valueTmpl, (padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) ? '0' : '1', padid->pszDriverAlias);
|
|
|
|
wcslwr(szBuffer);
|
2006-01-18 12:06:56 +01:00
|
|
|
|
2019-06-12 09:38:13 +02:00
|
|
|
lError = RegSetValueExW(hPriorityKey, szSubKey, 0, REG_SZ, (BYTE *)szBuffer, (lstrlenW(szBuffer) + 1) * sizeof(WCHAR));
|
2006-01-18 12:06:56 +01:00
|
|
|
if (lError != ERROR_SUCCESS) {
|
2006-10-12 21:35:06 +02:00
|
|
|
ERR("unable to write value for %s under key %s (0x%08x)\n",
|
2006-01-18 12:06:56 +01:00
|
|
|
debugstr_w(padid->pszDriverAlias), debugstr_w(basePriorityKey), lError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Build required value name */
|
|
|
|
dwPriorityCounter++;
|
2019-06-12 09:38:13 +02:00
|
|
|
swprintf(szSubKey, 17, priorityTmpl, dwPriorityCounter);
|
2006-01-18 12:06:56 +01:00
|
|
|
|
|
|
|
/* Value has a 1 in front for enabled drivers and 0 for disabled drivers */
|
2019-06-12 09:38:13 +02:00
|
|
|
swprintf(szBuffer, 256, valueTmpl, '1', converterAlias);
|
2006-01-18 12:06:56 +01:00
|
|
|
|
2019-06-12 09:38:13 +02:00
|
|
|
lError = RegSetValueExW(hPriorityKey, szSubKey, 0, REG_SZ, (BYTE *)szBuffer, (lstrlenW(szBuffer) + 1) * sizeof(WCHAR));
|
2006-01-18 12:06:56 +01:00
|
|
|
if (lError != ERROR_SUCCESS) {
|
2006-10-12 21:35:06 +02:00
|
|
|
ERR("unable to write value for %s under key %s (0x%08x)\n",
|
2006-01-18 12:06:56 +01:00
|
|
|
debugstr_w(converterAlias), debugstr_w(basePriorityKey), lError);
|
|
|
|
}
|
|
|
|
RegCloseKey(hPriorityKey);
|
|
|
|
}
|
|
|
|
|
2009-01-07 21:26:15 +01:00
|
|
|
static PWINE_ACMLOCALDRIVER MSACM_pFirstACMLocalDriver;
|
|
|
|
static PWINE_ACMLOCALDRIVER MSACM_pLastACMLocalDriver;
|
|
|
|
|
|
|
|
static PWINE_ACMLOCALDRIVER MSACM_UnregisterLocalDriver(PWINE_ACMLOCALDRIVER paldrv)
|
|
|
|
{
|
|
|
|
PWINE_ACMLOCALDRIVER pNextACMLocalDriver;
|
2019-01-26 09:20:10 +01:00
|
|
|
LONG ref;
|
2009-01-07 21:26:15 +01:00
|
|
|
|
|
|
|
if (paldrv->pACMInstList) {
|
|
|
|
ERR("local driver instances still present after closing all drivers - memory leak\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-01-26 09:20:10 +01:00
|
|
|
ref = InterlockedDecrement(&paldrv->ref);
|
|
|
|
if (ref)
|
|
|
|
return paldrv;
|
|
|
|
|
2009-01-07 21:26:15 +01:00
|
|
|
if (paldrv == MSACM_pFirstACMLocalDriver)
|
|
|
|
MSACM_pFirstACMLocalDriver = paldrv->pNextACMLocalDrv;
|
|
|
|
if (paldrv == MSACM_pLastACMLocalDriver)
|
|
|
|
MSACM_pLastACMLocalDriver = paldrv->pPrevACMLocalDrv;
|
|
|
|
|
|
|
|
if (paldrv->pPrevACMLocalDrv)
|
|
|
|
paldrv->pPrevACMLocalDrv->pNextACMLocalDrv = paldrv->pNextACMLocalDrv;
|
|
|
|
if (paldrv->pNextACMLocalDrv)
|
|
|
|
paldrv->pNextACMLocalDrv->pPrevACMLocalDrv = paldrv->pPrevACMLocalDrv;
|
|
|
|
|
|
|
|
pNextACMLocalDriver = paldrv->pNextACMLocalDrv;
|
|
|
|
|
|
|
|
HeapFree(MSACM_hHeap, 0, paldrv);
|
|
|
|
|
|
|
|
return pNextACMLocalDriver;
|
|
|
|
}
|
|
|
|
|
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;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-12-12 22:28:09 +01:00
|
|
|
while (p->pACMDriverList)
|
|
|
|
acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, p->pszDriverAlias);
|
|
|
|
HeapFree(MSACM_hHeap, 0, p->pszFileName);
|
2001-04-23 20:14:41 +02:00
|
|
|
HeapFree(MSACM_hHeap, 0, p->aFormatTag);
|
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
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;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
pNextACMDriverID = p->pNextACMDriverID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-01-18 12:16:57 +01:00
|
|
|
if (p->pLocalDriver) MSACM_UnregisterLocalDriver(p->pLocalDriver);
|
1999-10-31 19:29:16 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, p);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
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
|
|
|
*/
|
1999-10-31 19:29:16 +01:00
|
|
|
void MSACM_UnregisterAllDrivers(void)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
2006-01-18 12:10:59 +01:00
|
|
|
PWINE_ACMNOTIFYWND panwnd = MSACM_pFirstACMNotifyWnd;
|
2002-06-01 01:06:46 +02:00
|
|
|
PWINE_ACMDRIVERID p = MSACM_pFirstACMDriverID;
|
1999-10-31 19:29:16 +01:00
|
|
|
|
2001-04-23 20:14:41 +02:00
|
|
|
while (p) {
|
|
|
|
MSACM_WriteCache(p);
|
|
|
|
p = MSACM_UnregisterDriver(p);
|
|
|
|
}
|
2006-01-18 12:10:59 +01:00
|
|
|
|
|
|
|
while (panwnd) {
|
|
|
|
panwnd = MSACM_UnRegisterNotificationWindow(panwnd);
|
2006-01-18 12:16:57 +01:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2002-06-01 01:06:46 +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
|
|
|
}
|
|
|
|
|
2006-01-18 12:10:59 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_GetNotifyWnd()
|
|
|
|
*/
|
|
|
|
PWINE_ACMNOTIFYWND MSACM_GetNotifyWnd(HACMDRIVERID hDriver)
|
|
|
|
{
|
|
|
|
return (PWINE_ACMNOTIFYWND)MSACM_GetObj((HACMOBJ)hDriver, WINE_ACMOBJ_NOTIFYWND);
|
|
|
|
}
|
|
|
|
|
2006-01-18 12:16:57 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_GetLocalDriver()
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
PWINE_ACMLOCALDRIVER MSACM_GetLocalDriver(HACMDRIVER hDriver)
|
|
|
|
{
|
|
|
|
return (PWINE_ACMLOCALDRIVER)MSACM_GetObj((HACMOBJ)hDriver, WINE_ACMOBJ_LOCALDRIVER);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
#define MSACM_DRIVER_SendMessage(PDRVRINST, msg, lParam1, lParam2) \
|
|
|
|
(PDRVRINST)->pLocalDriver->lpDrvProc((PDRVRINST)->dwDriverID, (HDRVR)(PDRVRINST), msg, lParam1, lParam2)
|
2006-01-18 12:10:59 +01: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
|
|
|
|
2006-01-18 12:16:57 +01:00
|
|
|
if (!pad) return MMSYSERR_INVALHANDLE;
|
|
|
|
if (pad->hDrvr) return SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2);
|
|
|
|
if (pad->pLocalDrvrInst) return MSACM_DRIVER_SendMessage(pad->pLocalDrvrInst, uMsg, lParam1, lParam2);
|
|
|
|
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PWINE_ACMLOCALDRIVER MSACM_RegisterLocalDriver(HMODULE hModule, DRIVERPROC lpDriverProc)
|
|
|
|
{
|
|
|
|
PWINE_ACMLOCALDRIVER paldrv;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", hModule, lpDriverProc);
|
|
|
|
if (!hModule || !lpDriverProc) return NULL;
|
|
|
|
|
|
|
|
/* look up previous instance of local driver module */
|
|
|
|
for (paldrv = MSACM_pFirstACMLocalDriver; paldrv; paldrv = paldrv->pNextACMLocalDrv)
|
|
|
|
{
|
2019-01-26 09:20:10 +01:00
|
|
|
if (paldrv->hModule == hModule && paldrv->lpDrvProc == lpDriverProc)
|
|
|
|
{
|
|
|
|
InterlockedIncrement(&paldrv->ref);
|
|
|
|
return paldrv;
|
|
|
|
}
|
2006-01-18 12:16:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
paldrv = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMLOCALDRIVER));
|
|
|
|
paldrv->obj.dwType = WINE_ACMOBJ_LOCALDRIVER;
|
|
|
|
paldrv->obj.pACMDriverID = 0;
|
|
|
|
paldrv->hModule = hModule;
|
|
|
|
paldrv->lpDrvProc = lpDriverProc;
|
|
|
|
paldrv->pACMInstList = NULL;
|
2019-01-26 09:20:10 +01:00
|
|
|
paldrv->ref = 1;
|
2006-01-18 12:16:57 +01:00
|
|
|
|
|
|
|
paldrv->pNextACMLocalDrv = NULL;
|
|
|
|
paldrv->pPrevACMLocalDrv = MSACM_pLastACMLocalDriver;
|
|
|
|
if (MSACM_pLastACMLocalDriver)
|
|
|
|
MSACM_pLastACMLocalDriver->pNextACMLocalDrv = paldrv;
|
|
|
|
MSACM_pLastACMLocalDriver = paldrv;
|
|
|
|
if (!MSACM_pFirstACMLocalDriver)
|
|
|
|
MSACM_pFirstACMLocalDriver = paldrv;
|
|
|
|
|
|
|
|
return paldrv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MSACM_GetNumberOfModuleRefs [internal]
|
|
|
|
*
|
|
|
|
* Returns the number of open drivers which share the same module.
|
|
|
|
* Inspired from implementation in dlls/winmm/driver.c
|
|
|
|
*/
|
|
|
|
static unsigned MSACM_GetNumberOfModuleRefs(HMODULE hModule, DRIVERPROC lpDrvProc, WINE_ACMLOCALDRIVERINST ** found)
|
|
|
|
{
|
|
|
|
PWINE_ACMLOCALDRIVER lpDrv;
|
|
|
|
unsigned count = 0;
|
|
|
|
|
|
|
|
if (found) *found = NULL;
|
|
|
|
for (lpDrv = MSACM_pFirstACMLocalDriver; lpDrv; lpDrv = lpDrv->pNextACMLocalDrv)
|
|
|
|
{
|
|
|
|
if (lpDrv->hModule == hModule && lpDrv->lpDrvProc == lpDrvProc)
|
|
|
|
{
|
|
|
|
PWINE_ACMLOCALDRIVERINST pInst = lpDrv->pACMInstList;
|
|
|
|
|
|
|
|
while (pInst) {
|
|
|
|
if (found && !*found) *found = pInst;
|
|
|
|
count++;
|
|
|
|
pInst = pInst->pNextACMInst;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MSACM_RemoveFromList [internal]
|
|
|
|
*
|
|
|
|
* Generates all the logic to handle driver closure / deletion
|
|
|
|
* Removes a driver struct to the list of open drivers.
|
|
|
|
*/
|
|
|
|
static BOOL MSACM_RemoveFromList(PWINE_ACMLOCALDRIVERINST lpDrv)
|
|
|
|
{
|
|
|
|
PWINE_ACMLOCALDRIVER pDriverBase = lpDrv->pLocalDriver;
|
|
|
|
PWINE_ACMLOCALDRIVERINST pPrevInst;
|
|
|
|
|
|
|
|
/* last of this driver in list ? */
|
|
|
|
if (MSACM_GetNumberOfModuleRefs(pDriverBase->hModule, pDriverBase->lpDrvProc, NULL) == 1) {
|
|
|
|
MSACM_DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L);
|
|
|
|
MSACM_DRIVER_SendMessage(lpDrv, DRV_FREE, 0L, 0L);
|
|
|
|
}
|
|
|
|
|
|
|
|
pPrevInst = NULL;
|
|
|
|
if (pDriverBase->pACMInstList != lpDrv) {
|
|
|
|
pPrevInst = pDriverBase->pACMInstList;
|
|
|
|
while (pPrevInst && pPrevInst->pNextACMInst != lpDrv)
|
|
|
|
pPrevInst = pPrevInst->pNextACMInst;
|
|
|
|
if (!pPrevInst) {
|
|
|
|
ERR("requested to remove invalid instance %p\n", pPrevInst);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!pPrevInst) {
|
|
|
|
/* first driver instance on list */
|
|
|
|
pDriverBase->pACMInstList = lpDrv->pNextACMInst;
|
|
|
|
} else {
|
|
|
|
pPrevInst->pNextACMInst = lpDrv->pNextACMInst;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MSACM_AddToList [internal]
|
|
|
|
*
|
|
|
|
* Adds a driver struct to the list of open drivers.
|
|
|
|
* Generates all the logic to handle driver creation / open.
|
|
|
|
*/
|
|
|
|
static BOOL MSACM_AddToList(PWINE_ACMLOCALDRIVERINST lpNewDrv, LPARAM lParam2)
|
|
|
|
{
|
|
|
|
PWINE_ACMLOCALDRIVER pDriverBase = lpNewDrv->pLocalDriver;
|
|
|
|
|
|
|
|
/* first of this driver in list ? */
|
|
|
|
if (MSACM_GetNumberOfModuleRefs(pDriverBase->hModule, pDriverBase->lpDrvProc, NULL) == 0) {
|
|
|
|
if (MSACM_DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) {
|
|
|
|
FIXME("DRV_LOAD failed on driver %p\n", lpNewDrv);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* returned value is not checked */
|
|
|
|
MSACM_DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L);
|
|
|
|
}
|
|
|
|
|
|
|
|
lpNewDrv->pNextACMInst = NULL;
|
|
|
|
if (pDriverBase->pACMInstList == NULL) {
|
|
|
|
pDriverBase->pACMInstList = lpNewDrv;
|
|
|
|
} else {
|
|
|
|
PWINE_ACMLOCALDRIVERINST lpDrvInst = pDriverBase->pACMInstList;
|
|
|
|
|
|
|
|
while (lpDrvInst->pNextACMInst != NULL)
|
|
|
|
lpDrvInst = lpDrvInst->pNextACMInst;
|
|
|
|
|
|
|
|
lpDrvInst->pNextACMInst = lpNewDrv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now just open a new instance of a driver on this module */
|
|
|
|
lpNewDrv->dwDriverID = MSACM_DRIVER_SendMessage(lpNewDrv, DRV_OPEN, 0, lParam2);
|
|
|
|
|
|
|
|
if (lpNewDrv->dwDriverID == 0) {
|
|
|
|
FIXME("DRV_OPEN failed on driver %p\n", lpNewDrv);
|
|
|
|
MSACM_RemoveFromList(lpNewDrv);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PWINE_ACMLOCALDRIVERINST MSACM_OpenLocalDriver(PWINE_ACMLOCALDRIVER paldrv, LPARAM lParam2)
|
|
|
|
{
|
|
|
|
PWINE_ACMLOCALDRIVERINST pDrvInst;
|
|
|
|
|
|
|
|
pDrvInst = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMLOCALDRIVERINST));
|
2011-12-06 21:52:51 +01:00
|
|
|
if (!pDrvInst)
|
|
|
|
return NULL;
|
|
|
|
|
2006-01-18 12:16:57 +01:00
|
|
|
pDrvInst->pLocalDriver = paldrv;
|
|
|
|
pDrvInst->dwDriverID = 0;
|
|
|
|
pDrvInst->pNextACMInst = NULL;
|
|
|
|
pDrvInst->bSession = FALSE;
|
|
|
|
|
|
|
|
/* Win32 installable drivers must support a two phase opening scheme:
|
|
|
|
* + first open with NULL as lParam2 (session instance),
|
|
|
|
* + then do a second open with the real non null lParam2)
|
|
|
|
*/
|
|
|
|
if (MSACM_GetNumberOfModuleRefs(paldrv->hModule, paldrv->lpDrvProc, NULL) == 0 && lParam2)
|
|
|
|
{
|
|
|
|
PWINE_ACMLOCALDRIVERINST ret;
|
|
|
|
|
|
|
|
if (!MSACM_AddToList(pDrvInst, 0L))
|
|
|
|
{
|
|
|
|
ERR("load0 failed\n");
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
ret = MSACM_OpenLocalDriver(paldrv, lParam2);
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
ERR("load1 failed\n");
|
2011-12-06 21:52:51 +01:00
|
|
|
/* If MSACM_CloseLocalDriver returns TRUE,
|
|
|
|
* then pDrvInst has been freed
|
|
|
|
*/
|
|
|
|
if (!MSACM_CloseLocalDriver(pDrvInst))
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
return NULL;
|
2006-01-18 12:16:57 +01:00
|
|
|
}
|
|
|
|
pDrvInst->bSession = TRUE;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!MSACM_AddToList(pDrvInst, lParam2))
|
|
|
|
{
|
|
|
|
ERR("load failed\n");
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("=> %p\n", pDrvInst);
|
|
|
|
return pDrvInst;
|
|
|
|
exit:
|
|
|
|
HeapFree(MSACM_hHeap, 0, pDrvInst);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT MSACM_CloseLocalDriver(PWINE_ACMLOCALDRIVERINST paldrv)
|
|
|
|
{
|
|
|
|
if (MSACM_RemoveFromList(paldrv)) {
|
|
|
|
PWINE_ACMLOCALDRIVERINST lpDrv0;
|
|
|
|
PWINE_ACMLOCALDRIVER pDriverBase = paldrv->pLocalDriver;
|
|
|
|
|
|
|
|
MSACM_DRIVER_SendMessage(paldrv, DRV_CLOSE, 0, 0);
|
|
|
|
paldrv->dwDriverID = 0;
|
|
|
|
|
|
|
|
if (paldrv->bSession)
|
|
|
|
ERR("should not directly close session instance (%p)\n", paldrv);
|
|
|
|
|
|
|
|
/* if driver has an opened session instance, we have to close it too */
|
|
|
|
if (MSACM_GetNumberOfModuleRefs(pDriverBase->hModule, pDriverBase->lpDrvProc, &lpDrv0) == 1 &&
|
|
|
|
lpDrv0->bSession)
|
|
|
|
{
|
|
|
|
MSACM_DRIVER_SendMessage(lpDrv0, DRV_CLOSE, 0L, 0L);
|
|
|
|
lpDrv0->dwDriverID = 0;
|
|
|
|
MSACM_RemoveFromList(lpDrv0);
|
2017-03-01 11:48:16 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, lpDrv0);
|
2006-01-18 12:16:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(MSACM_hHeap, 0, paldrv);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
ERR("unable to close driver instance\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|