1998-10-11 19:00:29 +02:00
|
|
|
/*
|
|
|
|
* MSACM32 library
|
|
|
|
*
|
|
|
|
* Copyright 1998 Patrik Stridvall
|
|
|
|
*/
|
|
|
|
|
1999-02-17 14:51:06 +01:00
|
|
|
#include "winbase.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
#include "winerror.h"
|
1999-03-14 17:35:05 +01:00
|
|
|
#include "windef.h"
|
1999-02-17 14:51:06 +01:00
|
|
|
#include "winuser.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
#include "debug.h"
|
|
|
|
#include "driver.h"
|
|
|
|
#include "heap.h"
|
|
|
|
#include "mmsystem.h"
|
|
|
|
#include "msacm.h"
|
|
|
|
#include "msacmdrv.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverAddA (MSACM32.2)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
MMRESULT WINAPI acmDriverAddA(
|
|
|
|
PHACMDRIVERID phadid, HINSTANCE hinstModule,
|
1998-10-11 19:00:29 +02:00
|
|
|
LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMLOCALDRIVER pld;
|
1998-10-11 19:00:29 +02:00
|
|
|
if(!phadid)
|
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
|
|
|
|
/* Check if any unknown flags */
|
|
|
|
if(fdwAdd &
|
|
|
|
~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
|
|
|
|
ACM_DRIVERADDF_GLOBAL))
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
|
|
|
|
/* Check if any incompatible flags */
|
|
|
|
if((fdwAdd & ACM_DRIVERADDF_FUNCTION) &&
|
|
|
|
(fdwAdd & ACM_DRIVERADDF_NOTIFYHWND))
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
pld = HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMLOCALDRIVER));
|
|
|
|
pld->pfnDriverProc = (DRIVERPROC)
|
|
|
|
GetProcAddress(hinstModule, "DriverProc");
|
|
|
|
*phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, NULL, pld);
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
/* FIXME: lParam, dwPriority and fdwAdd ignored */
|
|
|
|
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverAddW (MSACM32.3)
|
|
|
|
* FIXME
|
|
|
|
* Not implemented
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
MMRESULT WINAPI acmDriverAddW(
|
|
|
|
PHACMDRIVERID phadid, HINSTANCE hinstModule,
|
1998-10-11 19:00:29 +02:00
|
|
|
LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
|
|
|
|
{
|
|
|
|
FIXME(msacm, "(%p, 0x%08x, %ld, %ld, %ld): stub\n",
|
|
|
|
phadid, hinstModule, lParam, dwPriority, fdwAdd
|
|
|
|
);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return MMSYSERR_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverClose (MSACM32.4)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
MMRESULT WINAPI acmDriverClose(
|
|
|
|
HACMDRIVER had, DWORD fdwClose)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVER p;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
if(fdwClose)
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
p = MSACM_GetDriver(had);
|
1998-10-11 19:00:29 +02:00
|
|
|
if(!p)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
|
|
|
|
p->obj.pACMDriverID->pACMDriver = NULL;
|
|
|
|
|
|
|
|
/* FIXME: CloseDriver32 not implemented */
|
|
|
|
#if 0
|
|
|
|
if(p->hDrvr)
|
1999-02-26 12:11:13 +01:00
|
|
|
CloseDriver(p->hDrvr, 0, 0);
|
1998-10-11 19:00:29 +02:00
|
|
|
#endif
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, p);
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverDetailsA (MSACM32.5)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
MMRESULT WINAPI acmDriverDetailsA(
|
|
|
|
HACMDRIVERID hadid, PACMDRIVERDETAILSA padd, DWORD fdwDetails)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID p;
|
|
|
|
MMRESULT mmr;
|
|
|
|
BOOL bOpenTemporary;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
p = MSACM_GetDriverID(hadid);
|
1998-10-11 19:00:29 +02:00
|
|
|
if(!p)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
|
|
|
|
if(fdwDetails)
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
|
|
|
|
bOpenTemporary = !p->pACMDriver;
|
|
|
|
if(bOpenTemporary) {
|
|
|
|
bOpenTemporary = TRUE;
|
1999-02-26 12:11:13 +01:00
|
|
|
acmDriverOpen((PHACMDRIVER) &p->pACMDriver, hadid, 0);
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME
|
|
|
|
* How does the driver know if the ANSI or
|
|
|
|
* the UNICODE variant of PACMDRIVERDETAILS is used?
|
|
|
|
* It might check cbStruct or does it only accept ANSI.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
mmr = (MMRESULT) acmDriverMessage(
|
|
|
|
(HACMDRIVER) p->pACMDriver, ACMDM_DRIVER_DETAILS,
|
1998-10-11 19:00:29 +02:00
|
|
|
(LPARAM) padd, 0
|
|
|
|
);
|
|
|
|
|
|
|
|
if(bOpenTemporary) {
|
1999-02-26 12:11:13 +01:00
|
|
|
acmDriverClose((HACMDRIVER) p->pACMDriver, 0);
|
1998-10-11 19:00:29 +02:00
|
|
|
p->pACMDriver = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mmr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverDetailsW (MSACM32.6)
|
|
|
|
* FIXME
|
|
|
|
* Not implemented
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
MMRESULT WINAPI acmDriverDetailsW(
|
|
|
|
HACMDRIVERID hadid, PACMDRIVERDETAILSW padd, DWORD fdwDetails)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
|
|
|
FIXME(msacm, "(0x%08x, %p, %ld): stub\n", hadid, padd, fdwDetails);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return MMSYSERR_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverEnum (MSACM32.7)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
MMRESULT WINAPI acmDriverEnum(
|
|
|
|
ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID p;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
if(!fnCallback)
|
|
|
|
{
|
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(fdwEnum && ~(ACM_DRIVERENUMF_NOLOCAL|ACM_DRIVERENUMF_DISABLED))
|
|
|
|
{
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
p = MSACM_pFirstACMDriverID;
|
1998-10-11 19:00:29 +02:00
|
|
|
while(p)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
(*fnCallback)((HACMDRIVERID) p, dwInstance, ACMDRIVERDETAILS_SUPPORTF_CODEC);
|
1998-10-11 19:00:29 +02:00
|
|
|
p = p->pNextACMDriverID;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverID (MSACM32.8)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
MMRESULT WINAPI acmDriverID(
|
|
|
|
HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMOBJ pao;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
pao = MSACM_GetObj(hao);
|
1998-10-11 19:00:29 +02:00
|
|
|
if(!pao)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
|
|
|
|
if(!phadid)
|
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
|
|
|
|
if(fdwDriverID)
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
*phadid = (HACMDRIVERID) pao->pACMDriverID;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverMessage (MSACM32.9)
|
|
|
|
* FIXME
|
|
|
|
* Not implemented
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
LRESULT WINAPI acmDriverMessage(
|
|
|
|
HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVER pad = MSACM_GetDriver(had);
|
1998-10-11 19:00:29 +02:00
|
|
|
if(!pad)
|
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
|
|
|
|
/* FIXME: Check if uMsg legal */
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
if(!SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2))
|
1998-10-11 19:00:29 +02:00
|
|
|
return MMSYSERR_NOTSUPPORTED;
|
|
|
|
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverOpen (MSACM32.10)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
MMRESULT WINAPI acmDriverOpen(
|
|
|
|
PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID padid;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
if(!phad)
|
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
padid = MSACM_GetDriverID(hadid);
|
1998-10-11 19:00:29 +02:00
|
|
|
if(!padid)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
|
|
|
|
if(fdwOpen)
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
|
|
|
|
if(padid->pACMDriver)
|
|
|
|
{
|
|
|
|
/* FIXME: Is it allowed? */
|
|
|
|
ERR(msacm, "Can't open driver twice\n");
|
|
|
|
return MMSYSERR_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
padid->pACMDriver = HeapAlloc(
|
1999-02-26 12:11:13 +01:00
|
|
|
MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER)
|
1998-10-11 19:00:29 +02:00
|
|
|
);
|
|
|
|
padid->pACMDriver->obj.pACMDriverID = padid;
|
|
|
|
|
|
|
|
if(!padid->pACMLocalDriver)
|
|
|
|
padid->pACMDriver->hDrvr =
|
1999-02-26 12:11:13 +01:00
|
|
|
OpenDriverA(padid->pszDriverAlias, "drivers32", 0);
|
1998-10-11 19:00:29 +02:00
|
|
|
else
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
padid->pACMDriver->hDrvr = MSACM_OpenDriverProc(
|
1998-10-11 19:00:29 +02:00
|
|
|
padid->pACMLocalDriver->pfnDriverProc
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!padid->pACMDriver->hDrvr)
|
|
|
|
return MMSYSERR_ERROR;
|
|
|
|
|
|
|
|
/* FIXME: Create a WINE_ACMDRIVER32 */
|
1999-02-26 12:11:13 +01:00
|
|
|
*phad = (HACMDRIVER) NULL;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
return MMSYSERR_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverPriority (MSACM32.11)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
MMRESULT WINAPI acmDriverPriority(
|
|
|
|
HACMDRIVERID hadid, DWORD dwPriority, DWORD fdwPriority)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID padid;
|
1998-10-11 19:00:29 +02:00
|
|
|
CHAR szSubKey[17];
|
|
|
|
CHAR szBuffer[256];
|
|
|
|
LONG lBufferLength = sizeof(szBuffer);
|
|
|
|
LONG lError;
|
|
|
|
HKEY hPriorityKey;
|
|
|
|
DWORD dwPriorityCounter;
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
padid = MSACM_GetDriverID(hadid);
|
1998-10-11 19:00:29 +02:00
|
|
|
if(!padid)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
|
|
|
|
/* Check for unknown flags */
|
|
|
|
if(fdwPriority &
|
|
|
|
~(ACM_DRIVERPRIORITYF_ENABLE|ACM_DRIVERPRIORITYF_DISABLE|
|
|
|
|
ACM_DRIVERPRIORITYF_BEGIN|ACM_DRIVERPRIORITYF_END))
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
|
|
|
|
/* Check for incompatible flags */
|
|
|
|
if((fdwPriority & ACM_DRIVERPRIORITYF_ENABLE) &&
|
|
|
|
(fdwPriority & ACM_DRIVERPRIORITYF_DISABLE))
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
|
|
|
|
/* Check for incompatible flags */
|
|
|
|
if((fdwPriority & ACM_DRIVERPRIORITYF_BEGIN) &&
|
|
|
|
(fdwPriority & ACM_DRIVERPRIORITYF_END))
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
lError = RegOpenKeyA(HKEY_CURRENT_USER,
|
1998-10-11 19:00:29 +02:00
|
|
|
"Software\\Microsoft\\Multimedia\\"
|
|
|
|
"Audio Compression Manager\\Priority v4.00",
|
|
|
|
&hPriorityKey
|
|
|
|
);
|
|
|
|
/* FIXME: Create key */
|
|
|
|
if(lError != ERROR_SUCCESS)
|
|
|
|
return MMSYSERR_ERROR;
|
|
|
|
|
|
|
|
for(dwPriorityCounter = 1; ; dwPriorityCounter++)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
wsnprintfA(szSubKey, 17, "Priorty%ld", dwPriorityCounter);
|
|
|
|
lError = RegQueryValueA(hPriorityKey, szSubKey, szBuffer, &lBufferLength);
|
1998-10-11 19:00:29 +02:00
|
|
|
if(lError != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
FIXME(msacm, "(0x%08x, %ld, %ld): stub (partial)\n",
|
|
|
|
hadid, dwPriority, fdwPriority
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hPriorityKey);
|
|
|
|
|
|
|
|
return MMSYSERR_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverRemove (MSACM32.12)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
MMRESULT WINAPI acmDriverRemove(
|
|
|
|
HACMDRIVERID hadid, DWORD fdwRemove)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
PWINE_ACMDRIVERID padid;
|
1998-10-11 19:00:29 +02:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
padid = MSACM_GetDriverID(hadid);
|
1998-10-11 19:00:29 +02:00
|
|
|
if(!padid)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
|
|
|
|
if(fdwRemove)
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
MSACM_UnregisterDriver(padid);
|
1998-10-11 19:00:29 +02:00
|
|
|
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|