2001-02-24 20:28:24 +00:00
|
|
|
/**************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
This file will contain an interface to ACM drivers.
|
|
|
|
Its content will be based mainly on wine/dlls/msacm32
|
|
|
|
actually, for audio decompression only the following functions
|
|
|
|
are needed:
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
acmStreamOpen ( takes formats of src and dest, returns stream handle )
|
|
|
|
acmStreamPrepareHeader ( takes stream handler and info on data )
|
|
|
|
acmStreamConvert ( the same as PrepareHeader )
|
|
|
|
acmStreamUnprepareHeader
|
|
|
|
acmStreamClose
|
|
|
|
acmStreamSize
|
|
|
|
maybe acmStreamReset
|
2009-07-06 23:26:13 +00:00
|
|
|
|
|
|
|
In future I'll also add functions for format enumeration,
|
2001-02-24 20:28:24 +00:00
|
|
|
but not right now.
|
|
|
|
|
2006-06-22 13:34:00 +00:00
|
|
|
Modified for use with MPlayer, detailed changelog at
|
|
|
|
http://svn.mplayerhq.hu/mplayer/trunk/
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
***************************************************************************/
|
2001-10-04 02:21:47 +00:00
|
|
|
#include "config.h"
|
2006-11-26 18:33:41 +00:00
|
|
|
#include "debug.h"
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2001-10-04 02:21:47 +00:00
|
|
|
#include "wine/winbase.h"
|
|
|
|
#include "wine/windef.h"
|
|
|
|
#include "wine/winuser.h"
|
|
|
|
#include "wine/vfw.h"
|
|
|
|
#include "wine/winestring.h"
|
|
|
|
#include "wine/driver.h"
|
|
|
|
#include "wine/winerror.h"
|
|
|
|
#include "wine/msacm.h"
|
|
|
|
#include "wine/msacmdrv.h"
|
2001-02-24 20:28:24 +00:00
|
|
|
#include "wineacm.h"
|
2003-04-24 18:48:30 +00:00
|
|
|
#ifndef __MINGW32__
|
2001-07-12 15:27:48 +00:00
|
|
|
#include "ext.h"
|
2003-04-24 18:48:30 +00:00
|
|
|
#endif
|
2008-06-08 10:43:30 +00:00
|
|
|
#include "drv.h"
|
2001-07-12 15:27:48 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#pragma pack(1)
|
2001-02-24 20:28:24 +00:00
|
|
|
#define OpenDriverA DrvOpen
|
|
|
|
#define CloseDriver DrvClose
|
2001-07-12 15:27:48 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
static inline PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
|
|
|
return (PWINE_ACMSTREAM)has;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverAddA (MSACM32.2)
|
|
|
|
*/
|
|
|
|
MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule,
|
|
|
|
LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
|
|
|
|
{
|
|
|
|
if (!phadid)
|
|
|
|
return MMSYSERR_INVALPARAM;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
/* Check if any unknown flags */
|
2009-07-06 23:26:13 +00:00
|
|
|
if (fdwAdd &
|
2001-02-24 20:28:24 +00:00
|
|
|
~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
|
|
|
|
ACM_DRIVERADDF_GLOBAL))
|
|
|
|
return MMSYSERR_INVALFLAG;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
/* Check if any incompatible flags */
|
2009-07-06 23:26:13 +00:00
|
|
|
if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) &&
|
2001-02-24 20:28:24 +00:00
|
|
|
(fdwAdd & ACM_DRIVERADDF_NOTIFYHWND))
|
|
|
|
return MMSYSERR_INVALFLAG;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
|
|
|
/* FIXME: in fact, should GetModuleFileName(hinstModule) and do a
|
2001-02-24 20:28:24 +00:00
|
|
|
* LoadDriver on it, to be sure we can call SendDriverMessage on the
|
|
|
|
* hDrvr handle.
|
|
|
|
*/
|
2002-09-13 19:43:17 +00:00
|
|
|
*phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, 0, hinstModule);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
/* FIXME: lParam, dwPriority and fdwAdd ignored */
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverClose (MSACM32.4)
|
|
|
|
*/
|
|
|
|
MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
|
|
|
|
{
|
|
|
|
PWINE_ACMDRIVER p;
|
|
|
|
PWINE_ACMDRIVER* tp;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (fdwClose)
|
|
|
|
return MMSYSERR_INVALFLAG;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
p = MSACM_GetDriver(had);
|
|
|
|
if (!p)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
|
|
|
|
for (tp = &(p->obj.pACMDriverID->pACMDriverList); *tp; *tp = (*tp)->pNextACMDriver) {
|
|
|
|
if (*tp == p) {
|
|
|
|
*tp = (*tp)->pNextACMDriver;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (p->hDrvr && !p->obj.pACMDriverID->pACMDriverList)
|
|
|
|
CloseDriver(p->hDrvr);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
HeapFree(MSACM_hHeap, 0, p);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverEnum (MSACM32.7)
|
|
|
|
*/
|
|
|
|
MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum)
|
|
|
|
{
|
|
|
|
PWINE_ACMDRIVERID p;
|
|
|
|
DWORD fdwSupport;
|
|
|
|
|
|
|
|
if (!fnCallback) {
|
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (fdwEnum && ~(ACM_DRIVERENUMF_NOLOCAL|ACM_DRIVERENUMF_DISABLED)) {
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
for (p = MSACM_pFirstACMDriverID; p; p = p->pNextACMDriverID) {
|
|
|
|
fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
|
|
|
|
if (!p->bEnabled) {
|
|
|
|
if (fdwEnum & ACM_DRIVERENUMF_DISABLED)
|
|
|
|
fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
(*fnCallback)((HACMDRIVERID) p, dwInstance, fdwSupport);
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverID (MSACM32.8)
|
|
|
|
*/
|
|
|
|
MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID)
|
|
|
|
{
|
|
|
|
PWINE_ACMOBJ pao;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
pao = MSACM_GetObj(hao);
|
|
|
|
if (!pao)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (!phadid)
|
|
|
|
return MMSYSERR_INVALPARAM;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (fdwDriverID)
|
|
|
|
return MMSYSERR_INVALFLAG;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
*phadid = (HACMDRIVERID) pao->pACMDriverID;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverMessage (MSACM32.9)
|
|
|
|
* FIXME
|
|
|
|
* Not implemented
|
|
|
|
*/
|
|
|
|
LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
|
|
|
|
{
|
|
|
|
PWINE_ACMDRIVER pad = MSACM_GetDriver(had);
|
|
|
|
if (!pad)
|
|
|
|
return MMSYSERR_INVALPARAM;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
/* FIXME: Check if uMsg legal */
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (!SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2))
|
|
|
|
return MMSYSERR_NOTSUPPORTED;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverOpen (MSACM32.10)
|
|
|
|
*/
|
|
|
|
MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
|
|
|
|
{
|
|
|
|
PWINE_ACMDRIVERID padid;
|
|
|
|
PWINE_ACMDRIVER pad;
|
|
|
|
ICOPEN icopen;
|
|
|
|
|
|
|
|
|
|
|
|
TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen);
|
|
|
|
|
|
|
|
if (!phad)
|
|
|
|
return MMSYSERR_INVALPARAM;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
|
|
|
padid = MSACM_GetDriverID(hadid);
|
2001-02-24 20:28:24 +00:00
|
|
|
if (!padid)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (fdwOpen)
|
|
|
|
return MMSYSERR_INVALFLAG;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
pad = (PWINE_ACMDRIVER) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
|
|
|
|
if (!pad)
|
|
|
|
return MMSYSERR_NOMEM;
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
pad->obj.pACMDriverID = padid;
|
|
|
|
icopen.fccType = mmioFOURCC('a', 'u', 'd', 'c');
|
|
|
|
icopen.fccHandler = (long)padid->pszFileName;
|
|
|
|
icopen.dwSize = sizeof(ICOPEN);
|
|
|
|
icopen.dwFlags = 0;
|
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
icopen.pV1Reserved = padid->pszFileName;
|
|
|
|
if (!padid->hInstModule)
|
2001-02-24 20:28:24 +00:00
|
|
|
pad->hDrvr = OpenDriverA((long)&icopen);
|
|
|
|
else
|
|
|
|
pad->hDrvr = padid->hInstModule;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (!pad->hDrvr) {
|
|
|
|
HeapFree(MSACM_hHeap, 0, pad);
|
|
|
|
return MMSYSERR_ERROR;
|
|
|
|
}
|
2002-09-13 19:43:17 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
pad->pfnDriverProc = GetProcAddress(pad->hDrvr, "DriverProc");
|
|
|
|
|
|
|
|
/* insert new pad at beg of list */
|
|
|
|
pad->pNextACMDriver = padid->pACMDriverList;
|
|
|
|
padid->pACMDriverList = pad;
|
|
|
|
|
|
|
|
/* FIXME: Create a WINE_ACMDRIVER32 */
|
|
|
|
*phad = (HACMDRIVER)pad;
|
2002-09-13 19:43:17 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmDriverRemove (MSACM32.12)
|
|
|
|
*/
|
|
|
|
MMRESULT WINAPI acmDriverRemove(HACMDRIVERID hadid, DWORD fdwRemove)
|
|
|
|
{
|
|
|
|
PWINE_ACMDRIVERID padid;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
padid = MSACM_GetDriverID(hadid);
|
|
|
|
if (!padid)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (fdwRemove)
|
|
|
|
return MMSYSERR_INVALFLAG;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
MSACM_UnregisterDriver(padid);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/
|
|
|
|
|
|
|
|
HANDLE MSACM_hHeap = (HANDLE) NULL;
|
|
|
|
PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL;
|
|
|
|
PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
|
|
|
|
|
|
|
|
/***********************************************************************
|
2009-07-06 23:26:13 +00:00
|
|
|
* MSACM_RegisterDriver32()
|
2001-02-24 20:28:24 +00:00
|
|
|
*/
|
2002-09-13 19:43:17 +00:00
|
|
|
PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName,
|
|
|
|
WORD wFormatTag,
|
2001-02-24 20:28:24 +00:00
|
|
|
HINSTANCE hinstModule)
|
2002-09-13 19:43:17 +00:00
|
|
|
{
|
2001-02-24 20:28:24 +00:00
|
|
|
PWINE_ACMDRIVERID padid;
|
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
TRACE("('%s', '%x', 0x%08x)\n", pszFileName, wFormatTag, hinstModule);
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2003-04-21 19:16:31 +00:00
|
|
|
#ifndef WIN32_LOADER
|
|
|
|
MSACM_hHeap = GetProcessHeap();
|
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
|
2006-07-02 03:59:36 +00:00
|
|
|
padid->pszFileName = malloc(strlen(pszFileName)+1);
|
2002-09-13 19:43:17 +00:00
|
|
|
strcpy(padid->pszFileName, pszFileName);
|
2001-02-24 20:28:24 +00:00
|
|
|
// 1~strdup(pszDriverAlias);
|
2002-09-13 19:43:17 +00:00
|
|
|
padid->wFormatTag = wFormatTag;
|
2001-02-24 20:28:24 +00:00
|
|
|
padid->hInstModule = hinstModule;
|
|
|
|
padid->bEnabled = TRUE;
|
|
|
|
padid->pACMDriverList = NULL;
|
|
|
|
padid->pNextACMDriverID = NULL;
|
|
|
|
padid->pPrevACMDriverID = MSACM_pLastACMDriverID;
|
|
|
|
if (MSACM_pLastACMDriverID)
|
|
|
|
MSACM_pLastACMDriverID->pNextACMDriverID = padid;
|
|
|
|
MSACM_pLastACMDriverID = padid;
|
|
|
|
if (!MSACM_pFirstACMDriverID)
|
|
|
|
MSACM_pFirstACMDriverID = padid;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return padid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_UnregisterDriver32()
|
|
|
|
*/
|
|
|
|
PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
|
|
|
|
{
|
|
|
|
PWINE_ACMDRIVERID pNextACMDriverID;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
while (p->pACMDriverList)
|
|
|
|
acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2010-11-14 09:12:34 +00:00
|
|
|
free(p->pszFileName);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (p == MSACM_pFirstACMDriverID)
|
|
|
|
MSACM_pFirstACMDriverID = p->pNextACMDriverID;
|
|
|
|
if (p == MSACM_pLastACMDriverID)
|
|
|
|
MSACM_pLastACMDriverID = p->pPrevACMDriverID;
|
|
|
|
|
|
|
|
if (p->pPrevACMDriverID)
|
|
|
|
p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
|
|
|
|
if (p->pNextACMDriverID)
|
|
|
|
p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
pNextACMDriverID = p->pNextACMDriverID;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
HeapFree(MSACM_hHeap, 0, p);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return pNextACMDriverID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_UnregisterAllDrivers32()
|
|
|
|
* FIXME
|
|
|
|
* Where should this function be called?
|
|
|
|
*/
|
|
|
|
void MSACM_UnregisterAllDrivers(void)
|
|
|
|
{
|
|
|
|
PWINE_ACMDRIVERID p;
|
|
|
|
|
|
|
|
for (p = MSACM_pFirstACMDriverID; p; p = MSACM_UnregisterDriver(p));
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2009-07-06 23:26:13 +00:00
|
|
|
* MSACM_GetDriverID32()
|
2001-02-24 20:28:24 +00:00
|
|
|
*/
|
|
|
|
PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
|
|
|
|
{
|
|
|
|
return (PWINE_ACMDRIVERID)hDriverID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_GetDriver32()
|
|
|
|
*/
|
|
|
|
PWINE_ACMDRIVER MSACM_GetDriver(HACMDRIVER hDriver)
|
|
|
|
{
|
|
|
|
return (PWINE_ACMDRIVER)hDriver;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MSACM_GetObj32()
|
|
|
|
*/
|
|
|
|
PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj)
|
|
|
|
{
|
|
|
|
return (PWINE_ACMOBJ)hObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmStreamOpen (MSACM32.40)
|
|
|
|
*/
|
|
|
|
MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc,
|
|
|
|
PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD dwCallback,
|
|
|
|
DWORD dwInstance, DWORD fdwOpen)
|
|
|
|
{
|
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
PWINE_ACMDRIVER wad;
|
|
|
|
MMRESULT ret;
|
|
|
|
int wfxSrcSize;
|
|
|
|
int wfxDstSize;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n",
|
|
|
|
phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
|
|
|
|
|
2009-07-06 23:26:13 +00:00
|
|
|
TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
|
|
|
|
pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec,
|
2001-02-24 20:28:24 +00:00
|
|
|
pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize);
|
|
|
|
|
2009-07-06 23:26:13 +00:00
|
|
|
TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
|
|
|
|
pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec,
|
2001-02-24 20:28:24 +00:00
|
|
|
pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize);
|
|
|
|
|
|
|
|
#define SIZEOF_WFX(wfx) (sizeof(WAVEFORMATEX) + ((wfx->wFormatTag == WAVE_FORMAT_PCM) ? 0 : wfx->cbSize))
|
|
|
|
wfxSrcSize = SIZEOF_WFX(pwfxSrc);
|
|
|
|
wfxDstSize = SIZEOF_WFX(pwfxDst);
|
|
|
|
#undef SIZEOF_WFX
|
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
was = (PWINE_ACMSTREAM) HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0));
|
2001-02-24 20:28:24 +00:00
|
|
|
if (was == NULL)
|
|
|
|
return MMSYSERR_NOMEM;
|
|
|
|
was->drvInst.cbStruct = sizeof(was->drvInst);
|
2010-09-12 11:44:42 +00:00
|
|
|
was->drvInst.pwfxSrc = (PWAVEFORMATEX)(was + 1);
|
2001-02-24 20:28:24 +00:00
|
|
|
memcpy(was->drvInst.pwfxSrc, pwfxSrc, wfxSrcSize);
|
2002-09-13 19:43:17 +00:00
|
|
|
// LHACM is checking for 0x1
|
|
|
|
// but if this will not help
|
|
|
|
// was->drvInst.pwfxSrc->wFormatTag = 1;
|
2010-09-12 11:44:42 +00:00
|
|
|
was->drvInst.pwfxDst = (PWAVEFORMATEX)((LPSTR)(was + 1) + wfxSrcSize);
|
2001-02-24 20:28:24 +00:00
|
|
|
memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize);
|
|
|
|
if (pwfltr) {
|
2010-09-12 11:44:42 +00:00
|
|
|
was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)(was + 1) + wfxSrcSize + wfxDstSize);
|
2001-02-24 20:28:24 +00:00
|
|
|
memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER));
|
|
|
|
} else {
|
|
|
|
was->drvInst.pwfltr = NULL;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
was->drvInst.dwCallback = dwCallback;
|
2001-02-24 20:28:24 +00:00
|
|
|
was->drvInst.dwInstance = dwInstance;
|
|
|
|
was->drvInst.fdwOpen = fdwOpen;
|
2009-07-06 23:26:13 +00:00
|
|
|
was->drvInst.fdwDriver = 0L;
|
|
|
|
was->drvInst.dwDriver = 0L;
|
2001-02-24 20:28:24 +00:00
|
|
|
was->drvInst.has = (HACMSTREAM)was;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if (had) {
|
|
|
|
if (!(wad = MSACM_GetDriver(had))) {
|
|
|
|
ret = MMSYSERR_INVALPARAM;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
was->obj.pACMDriverID = wad->obj.pACMDriverID;
|
|
|
|
was->pDrv = wad;
|
|
|
|
was->hAcmDriver = 0; /* not to close it in acmStreamClose */
|
|
|
|
|
|
|
|
ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
|
|
|
|
if (ret != MMSYSERR_NOERROR)
|
|
|
|
goto errCleanUp;
|
|
|
|
} else {
|
|
|
|
PWINE_ACMDRIVERID wadi;
|
2007-09-10 11:31:51 +00:00
|
|
|
//short drv_tag;
|
2001-02-24 20:28:24 +00:00
|
|
|
ret = ACMERR_NOTPOSSIBLE;
|
|
|
|
/* if(pwfxSrc->wFormatTag==1)//compression
|
|
|
|
drv_tag=pwfxDst->wFormatTag;
|
|
|
|
else
|
|
|
|
if(pwfxDst->wFormatTag==1)//decompression
|
|
|
|
drv_tag=pwfxSrc->wFormatTag;
|
|
|
|
else
|
|
|
|
goto errCleanUp;
|
|
|
|
|
2009-07-06 23:26:13 +00:00
|
|
|
ret=acmDriverOpen2(drv_tag);
|
2001-02-24 20:28:24 +00:00
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
if ((wad = MSACM_GetDriver(had)) != 0) {
|
|
|
|
was->obj.pACMDriverID = wad->obj.pACMDriverID;
|
|
|
|
was->pDrv = wad;
|
|
|
|
was->hAcmDriver = had;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
|
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
if (fdwOpen & ACM_STREAMOPENF_QUERY) {
|
|
|
|
acmDriverClose(had, 0L);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
acmDriverClose(had, 0L);*/
|
2002-09-13 19:43:17 +00:00
|
|
|
//if(MSACM_pFirstACMDriverID==NULL)
|
|
|
|
// MSACM_RegisterAllDrivers();
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2002-09-13 19:43:17 +00:00
|
|
|
for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID)
|
|
|
|
{
|
|
|
|
/* Check Format */
|
|
|
|
if ((int)wadi->wFormatTag != (int)pwfxSrc->wFormatTag) continue;
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L);
|
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
if ((wad = MSACM_GetDriver(had)) != 0) {
|
|
|
|
was->obj.pACMDriverID = wad->obj.pACMDriverID;
|
|
|
|
was->pDrv = wad;
|
|
|
|
was->hAcmDriver = had;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
|
2002-09-13 19:43:17 +00:00
|
|
|
//lhacm - crash printf("RETOPEN %d\n", ret);
|
|
|
|
//ret = 0;
|
2001-02-24 20:28:24 +00:00
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
if (fdwOpen & ACM_STREAMOPENF_QUERY) {
|
|
|
|
acmDriverClose(had, 0L);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
// no match, close this acm driver and try next one
|
2001-02-24 20:28:24 +00:00
|
|
|
acmDriverClose(had, 0L);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ret != MMSYSERR_NOERROR) {
|
|
|
|
ret = ACMERR_NOTPOSSIBLE;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = MMSYSERR_NOERROR;
|
|
|
|
if (!(fdwOpen & ACM_STREAMOPENF_QUERY)) {
|
|
|
|
if (phas)
|
|
|
|
*phas = (HACMSTREAM)was;
|
|
|
|
TRACE("=> (%d)\n", ret);
|
2003-04-21 19:16:31 +00:00
|
|
|
#ifdef WIN32_LOADER
|
2002-09-13 19:43:17 +00:00
|
|
|
CodecAlloc();
|
2003-04-21 19:16:31 +00:00
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
errCleanUp:
|
2001-02-24 20:28:24 +00:00
|
|
|
if (phas)
|
|
|
|
*phas = (HACMSTREAM)0;
|
|
|
|
HeapFree(MSACM_hHeap, 0, was);
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
|
|
|
|
{
|
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
MMRESULT ret;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
TRACE("(0x%08x, %ld)\n", has, fdwClose);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if ((was = ACM_GetStream(has)) == NULL) {
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
}
|
|
|
|
ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CLOSE, (DWORD)&was->drvInst, 0);
|
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
if (was->hAcmDriver)
|
2009-07-06 23:26:13 +00:00
|
|
|
acmDriverClose(was->hAcmDriver, 0L);
|
2001-02-24 20:28:24 +00:00
|
|
|
HeapFree(MSACM_hHeap, 0, was);
|
2003-04-21 19:16:31 +00:00
|
|
|
#ifdef WIN32_LOADER
|
2002-09-13 19:43:17 +00:00
|
|
|
CodecRelease();
|
2003-04-21 19:16:31 +00:00
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmStreamConvert (MSACM32.38)
|
|
|
|
*/
|
2009-07-06 23:26:13 +00:00
|
|
|
MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash,
|
2001-02-24 20:28:24 +00:00
|
|
|
DWORD fdwConvert)
|
|
|
|
{
|
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
MMRESULT ret = MMSYSERR_NOERROR;
|
|
|
|
PACMDRVSTREAMHEADER padsh;
|
|
|
|
|
|
|
|
TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwConvert);
|
2002-09-13 19:43:17 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if ((was = ACM_GetStream(has)) == NULL)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
|
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
|
|
|
|
if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED))
|
|
|
|
return ACMERR_UNPREPARED;
|
|
|
|
|
|
|
|
/* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
|
|
|
|
* size. some fields are private to msacm internals, and are exposed
|
|
|
|
* in ACMSTREAMHEADER in the dwReservedDriver array
|
|
|
|
*/
|
|
|
|
padsh = (PACMDRVSTREAMHEADER)pash;
|
|
|
|
|
|
|
|
/* check that pointers have not been modified */
|
|
|
|
if (padsh->pbPreparedSrc != padsh->pbSrc ||
|
|
|
|
padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
|
|
|
|
padsh->pbPreparedDst != padsh->pbDst ||
|
|
|
|
padsh->cbPreparedDstLength < padsh->cbDstLength) {
|
|
|
|
return MMSYSERR_INVALPARAM;
|
2009-07-06 23:26:13 +00:00
|
|
|
}
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
padsh->fdwConvert = fdwConvert;
|
|
|
|
|
|
|
|
ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CONVERT, (DWORD)&was->drvInst, (DWORD)padsh);
|
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_DONE;
|
|
|
|
}
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmStreamPrepareHeader (MSACM32.41)
|
|
|
|
*/
|
2009-07-06 23:26:13 +00:00
|
|
|
MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
|
2001-02-24 20:28:24 +00:00
|
|
|
DWORD fdwPrepare)
|
|
|
|
{
|
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
MMRESULT ret = MMSYSERR_NOERROR;
|
|
|
|
PACMDRVSTREAMHEADER padsh;
|
|
|
|
|
|
|
|
TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwPrepare);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if ((was = ACM_GetStream(has)) == NULL)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
|
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
if (fdwPrepare)
|
|
|
|
ret = MMSYSERR_INVALFLAG;
|
|
|
|
|
|
|
|
if (pash->fdwStatus & ACMSTREAMHEADER_STATUSF_DONE)
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
|
|
|
|
/* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
|
|
|
|
* size. some fields are private to msacm internals, and are exposed
|
|
|
|
* in ACMSTREAMHEADER in the dwReservedDriver array
|
|
|
|
*/
|
|
|
|
padsh = (PACMDRVSTREAMHEADER)pash;
|
|
|
|
|
|
|
|
padsh->fdwConvert = fdwPrepare;
|
|
|
|
padsh->padshNext = NULL;
|
|
|
|
padsh->fdwDriver = padsh->dwDriver = 0L;
|
|
|
|
|
|
|
|
padsh->fdwPrepared = 0;
|
|
|
|
padsh->dwPrepared = 0;
|
|
|
|
padsh->pbPreparedSrc = 0;
|
|
|
|
padsh->cbPreparedSrcLength = 0;
|
|
|
|
padsh->pbPreparedDst = 0;
|
|
|
|
padsh->cbPreparedDstLength = 0;
|
|
|
|
|
|
|
|
ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_PREPARE, (DWORD)&was->drvInst, (DWORD)padsh);
|
|
|
|
if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
|
|
|
|
ret = MMSYSERR_NOERROR;
|
|
|
|
padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE);
|
|
|
|
padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_PREPARED;
|
|
|
|
padsh->fdwPrepared = padsh->fdwStatus;
|
|
|
|
padsh->dwPrepared = 0;
|
|
|
|
padsh->pbPreparedSrc = padsh->pbSrc;
|
|
|
|
padsh->cbPreparedSrcLength = padsh->cbSrcLength;
|
|
|
|
padsh->pbPreparedDst = padsh->pbDst;
|
|
|
|
padsh->cbPreparedDstLength = padsh->cbDstLength;
|
|
|
|
} else {
|
|
|
|
padsh->fdwPrepared = 0;
|
|
|
|
padsh->dwPrepared = 0;
|
|
|
|
padsh->pbPreparedSrc = 0;
|
|
|
|
padsh->cbPreparedSrcLength = 0;
|
|
|
|
padsh->pbPreparedDst = 0;
|
|
|
|
padsh->cbPreparedDstLength = 0;
|
|
|
|
}
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmStreamReset (MSACM32.42)
|
|
|
|
*/
|
|
|
|
MMRESULT WINAPI acmStreamReset(HACMSTREAM has, DWORD fdwReset)
|
|
|
|
{
|
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
MMRESULT ret = MMSYSERR_NOERROR;
|
|
|
|
|
|
|
|
TRACE("(0x%08x, %ld)\n", has, fdwReset);
|
|
|
|
|
|
|
|
if (fdwReset) {
|
|
|
|
ret = MMSYSERR_INVALFLAG;
|
|
|
|
} else if ((was = ACM_GetStream(has)) == NULL) {
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
} else if (was->drvInst.fdwOpen & ACM_STREAMOPENF_ASYNC) {
|
|
|
|
ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_RESET, (DWORD)&was->drvInst, 0);
|
|
|
|
}
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmStreamSize (MSACM32.43)
|
|
|
|
*/
|
2009-07-06 23:26:13 +00:00
|
|
|
MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput,
|
2001-02-24 20:28:24 +00:00
|
|
|
LPDWORD pdwOutputBytes, DWORD fdwSize)
|
|
|
|
{
|
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
ACMDRVSTREAMSIZE adss;
|
|
|
|
MMRESULT ret;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
TRACE("(0x%08x, %ld, %p, %ld)\n", has, cbInput, pdwOutputBytes, fdwSize);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if ((was = ACM_GetStream(has)) == NULL) {
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
}
|
|
|
|
if ((fdwSize & ~ACM_STREAMSIZEF_QUERYMASK) != 0) {
|
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdwOutputBytes = 0L;
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
|
|
|
|
case ACM_STREAMSIZEF_DESTINATION:
|
|
|
|
adss.cbDstLength = cbInput;
|
|
|
|
adss.cbSrcLength = 0;
|
|
|
|
break;
|
|
|
|
case ACM_STREAMSIZEF_SOURCE:
|
|
|
|
adss.cbSrcLength = cbInput;
|
|
|
|
adss.cbDstLength = 0;
|
|
|
|
break;
|
2009-07-06 23:26:13 +00:00
|
|
|
default:
|
2001-02-24 20:28:24 +00:00
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
}
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
adss.cbStruct = sizeof(adss);
|
|
|
|
adss.fdwSize = fdwSize;
|
2009-07-06 23:26:13 +00:00
|
|
|
ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_SIZE,
|
2001-02-24 20:28:24 +00:00
|
|
|
(DWORD)&was->drvInst, (DWORD)&adss);
|
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
|
|
|
|
case ACM_STREAMSIZEF_DESTINATION:
|
|
|
|
*pdwOutputBytes = adss.cbSrcLength;
|
|
|
|
break;
|
|
|
|
case ACM_STREAMSIZEF_SOURCE:
|
|
|
|
*pdwOutputBytes = adss.cbDstLength;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("=> (%d) [%lu]\n", ret, *pdwOutputBytes);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* acmStreamUnprepareHeader (MSACM32.44)
|
|
|
|
*/
|
2009-07-06 23:26:13 +00:00
|
|
|
MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
|
2001-02-24 20:28:24 +00:00
|
|
|
DWORD fdwUnprepare)
|
|
|
|
{
|
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
MMRESULT ret = MMSYSERR_NOERROR;
|
|
|
|
PACMDRVSTREAMHEADER padsh;
|
|
|
|
|
|
|
|
TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwUnprepare);
|
2009-07-06 23:26:13 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
if ((was = ACM_GetStream(has)) == NULL)
|
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
|
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
|
|
|
|
if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED))
|
|
|
|
return ACMERR_UNPREPARED;
|
|
|
|
|
|
|
|
/* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
|
|
|
|
* size. some fields are private to msacm internals, and are exposed
|
|
|
|
* in ACMSTREAMHEADER in the dwReservedDriver array
|
|
|
|
*/
|
|
|
|
padsh = (PACMDRVSTREAMHEADER)pash;
|
|
|
|
|
|
|
|
/* check that pointers have not been modified */
|
|
|
|
if (padsh->pbPreparedSrc != padsh->pbSrc ||
|
|
|
|
padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
|
|
|
|
padsh->pbPreparedDst != padsh->pbDst ||
|
|
|
|
padsh->cbPreparedDstLength < padsh->cbDstLength) {
|
|
|
|
return MMSYSERR_INVALPARAM;
|
2009-07-06 23:26:13 +00:00
|
|
|
}
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
padsh->fdwConvert = fdwUnprepare;
|
|
|
|
|
|
|
|
ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_UNPREPARE, (DWORD)&was->drvInst, (DWORD)padsh);
|
|
|
|
if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
|
|
|
|
ret = MMSYSERR_NOERROR;
|
|
|
|
padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE|ACMSTREAMHEADER_STATUSF_PREPARED);
|
|
|
|
}
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|