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
|
1999-10-31 19:29:16 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* TODO
|
|
|
|
* + asynchronous conversion is not implemented
|
|
|
|
* + callback/notification
|
|
|
|
* * acmStreamMessage
|
|
|
|
* + properly close ACM streams
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
1999-02-17 14:51:06 +01:00
|
|
|
#include "winbase.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
#include "winerror.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1998-10-11 19:00:29 +02:00
|
|
|
#include "mmsystem.h"
|
2004-08-11 21:35:34 +02:00
|
|
|
#define NOBITMAP
|
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"
|
1998-10-11 19:00:29 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msacm);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
static PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
|
|
|
|
{
|
2004-03-12 21:24:50 +01:00
|
|
|
TRACE("(%p)\n", has);
|
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
return (PWINE_ACMSTREAM)has;
|
|
|
|
}
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2016-08-28 09:07:30 +02:00
|
|
|
static BOOL ACM_ValidatePointers(PACMDRVSTREAMHEADER padsh)
|
|
|
|
{
|
|
|
|
/* check that pointers have not been modified */
|
|
|
|
return !(padsh->pbPreparedSrc != padsh->pbSrc ||
|
|
|
|
padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
|
|
|
|
padsh->pbPreparedDst != padsh->pbDst ||
|
|
|
|
padsh->cbPreparedDstLength < padsh->cbDstLength);
|
|
|
|
}
|
|
|
|
|
1998-10-11 19:00:29 +02:00
|
|
|
/***********************************************************************
|
2001-06-11 22:14:43 +02:00
|
|
|
* acmStreamClose (MSACM32.@)
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
1999-10-31 19:29:16 +01:00
|
|
|
MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-10-31 19:29:16 +01:00
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
MMRESULT ret;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2022-02-15 07:28:35 +01:00
|
|
|
TRACE("(%p, %ld)\n", has, fdwClose);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
if ((was = ACM_GetStream(has)) == NULL) {
|
2004-03-12 21:24:50 +01:00
|
|
|
WARN("invalid handle\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
}
|
2006-01-18 12:13:51 +01:00
|
|
|
ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_CLOSE, (LPARAM)&was->drvInst, 0);
|
1999-10-31 19:29:16 +01:00
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
1999-12-05 03:17:18 +01:00
|
|
|
if (was->hAcmDriver)
|
2002-06-01 01:06:46 +02:00
|
|
|
acmDriverClose(was->hAcmDriver, 0L);
|
1999-10-31 19:29:16 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, was);
|
|
|
|
}
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-11 22:14:43 +02:00
|
|
|
* acmStreamConvert (MSACM32.@)
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash,
|
1999-10-31 19:29:16 +01:00
|
|
|
DWORD fdwConvert)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-10-31 19:29:16 +01:00
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
MMRESULT ret = MMSYSERR_NOERROR;
|
|
|
|
PACMDRVSTREAMHEADER padsh;
|
|
|
|
|
2022-02-15 07:28:35 +01:00
|
|
|
TRACE("(%p, %p, %ld)\n", has, pash, fdwConvert);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-03-12 21:24:50 +01:00
|
|
|
if ((was = ACM_GetStream(has)) == NULL) {
|
|
|
|
WARN("invalid handle\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return MMSYSERR_INVALHANDLE;
|
2004-03-12 21:24:50 +01:00
|
|
|
}
|
|
|
|
if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) {
|
|
|
|
WARN("invalid parameter\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return MMSYSERR_INVALPARAM;
|
2004-03-12 21:24:50 +01:00
|
|
|
}
|
|
|
|
if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED)) {
|
|
|
|
WARN("unprepared header\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return ACMERR_UNPREPARED;
|
2004-03-12 21:24:50 +01:00
|
|
|
}
|
1999-10-31 19:29:16 +01:00
|
|
|
|
2006-01-04 15:27:35 +01:00
|
|
|
pash->cbSrcLengthUsed = 0;
|
|
|
|
pash->cbDstLengthUsed = 0;
|
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
/* 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;
|
|
|
|
|
2016-08-28 09:07:30 +02:00
|
|
|
if (!ACM_ValidatePointers(padsh)) {
|
2004-03-12 21:24:50 +01:00
|
|
|
WARN("invalid parameter\n");
|
2016-08-28 09:07:30 +02:00
|
|
|
return MMSYSERR_INVALPARAM;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-10-31 19:29:16 +01:00
|
|
|
|
|
|
|
padsh->fdwConvert = fdwConvert;
|
|
|
|
|
2006-01-18 12:13:51 +01:00
|
|
|
ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_CONVERT, (LPARAM)&was->drvInst, (LPARAM)padsh);
|
1999-10-31 19:29:16 +01:00
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_DONE;
|
|
|
|
}
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-11 22:14:43 +02:00
|
|
|
* acmStreamMessage (MSACM32.@)
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
MMRESULT WINAPI acmStreamMessage(HACMSTREAM has, UINT uMsg, LPARAM lParam1,
|
1999-10-31 19:29:16 +01:00
|
|
|
LPARAM lParam2)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
2022-02-15 07:28:35 +01:00
|
|
|
FIXME("(%p, %u, %Id, %Id): stub\n", has, uMsg, lParam1, lParam2);
|
1999-10-31 19:29:16 +01:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return MMSYSERR_ERROR;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-11 22:14:43 +02:00
|
|
|
* acmStreamOpen (MSACM32.@)
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
2009-02-05 09:52:31 +01:00
|
|
|
MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had,
|
|
|
|
PWAVEFORMATEX pwfxSrc, PWAVEFORMATEX pwfxDst,
|
|
|
|
PWAVEFILTER pwfltr, DWORD_PTR dwCallback,
|
|
|
|
DWORD_PTR dwInstance, DWORD fdwOpen)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-10-31 19:29:16 +01:00
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
PWINE_ACMDRIVER wad;
|
|
|
|
MMRESULT ret;
|
|
|
|
int wfxSrcSize;
|
|
|
|
int wfxDstSize;
|
2004-03-12 21:24:50 +01:00
|
|
|
WAVEFORMATEX wfxSrc, wfxDst;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2022-02-15 07:28:35 +01:00
|
|
|
TRACE("(%p, %p, %p, %p, %p, %Id, %Id, %ld)\n",
|
1999-10-31 19:29:16 +01:00
|
|
|
phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
|
|
|
|
|
2004-03-12 21:24:50 +01:00
|
|
|
/* NOTE: pwfxSrc and/or pwfxDst can point to a structure smaller than
|
|
|
|
* WAVEFORMATEX so don't use them directly when not sure */
|
|
|
|
if (pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) {
|
|
|
|
memcpy(&wfxSrc, pwfxSrc, sizeof(PCMWAVEFORMAT));
|
|
|
|
wfxSrc.wBitsPerSample = pwfxSrc->wBitsPerSample;
|
|
|
|
wfxSrc.cbSize = 0;
|
|
|
|
pwfxSrc = &wfxSrc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pwfxDst->wFormatTag == WAVE_FORMAT_PCM) {
|
|
|
|
memcpy(&wfxDst, pwfxDst, sizeof(PCMWAVEFORMAT));
|
|
|
|
wfxDst.wBitsPerSample = pwfxDst->wBitsPerSample;
|
|
|
|
wfxDst.cbSize = 0;
|
|
|
|
pwfxDst = &wfxDst;
|
|
|
|
}
|
|
|
|
|
2022-02-15 07:28:35 +01:00
|
|
|
TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
|
2002-06-01 01:06:46 +02:00
|
|
|
pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec,
|
1999-10-31 19:29:16 +01:00
|
|
|
pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize);
|
|
|
|
|
2022-02-15 07:28:35 +01:00
|
|
|
TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
|
2002-06-01 01:06:46 +02:00
|
|
|
pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec,
|
1999-10-31 19:29:16 +01:00
|
|
|
pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize);
|
|
|
|
|
2003-01-23 22:21:02 +01:00
|
|
|
/* (WS) In query mode, phas should be NULL. If it is not, then instead
|
|
|
|
* of returning an error we are making sure it is NULL, preventing some
|
|
|
|
* applications that pass garbage for phas from crashing.
|
|
|
|
*/
|
|
|
|
if (fdwOpen & ACM_STREAMOPENF_QUERY) phas = NULL;
|
|
|
|
|
2004-03-12 21:24:50 +01:00
|
|
|
if (pwfltr && (pwfxSrc->wFormatTag != pwfxDst->wFormatTag)) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
}
|
2000-09-09 22:32:10 +02:00
|
|
|
|
|
|
|
wfxSrcSize = wfxDstSize = sizeof(WAVEFORMATEX);
|
|
|
|
if (pwfxSrc->wFormatTag != WAVE_FORMAT_PCM) wfxSrcSize += pwfxSrc->cbSize;
|
|
|
|
if (pwfxDst->wFormatTag != WAVE_FORMAT_PCM) wfxDstSize += pwfxDst->cbSize;
|
1999-10-31 19:29:16 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
was = HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize +
|
2001-05-22 21:21:16 +02:00
|
|
|
((pwfltr) ? sizeof(WAVEFILTER) : 0));
|
2004-03-12 21:24:50 +01:00
|
|
|
if (was == NULL) {
|
|
|
|
WARN("no memory\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return MMSYSERR_NOMEM;
|
2004-03-12 21:24:50 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
was->drvInst.cbStruct = sizeof(was->drvInst);
|
|
|
|
was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was));
|
|
|
|
memcpy(was->drvInst.pwfxSrc, pwfxSrc, wfxSrcSize);
|
|
|
|
was->drvInst.pwfxDst = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was) + wfxSrcSize);
|
|
|
|
memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize);
|
|
|
|
if (pwfltr) {
|
|
|
|
was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)was + sizeof(*was) + wfxSrcSize + wfxDstSize);
|
|
|
|
memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER));
|
|
|
|
} else {
|
|
|
|
was->drvInst.pwfltr = NULL;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
was->drvInst.dwCallback = dwCallback;
|
1999-10-31 19:29:16 +01:00
|
|
|
was->drvInst.dwInstance = dwInstance;
|
|
|
|
was->drvInst.fdwOpen = fdwOpen;
|
2002-06-01 01:06:46 +02:00
|
|
|
was->drvInst.fdwDriver = 0L;
|
|
|
|
was->drvInst.dwDriver = 0L;
|
2001-05-22 21:21:16 +02:00
|
|
|
/* real value will be stored once ACMDM_STREAM_OPEN succeeds */
|
|
|
|
was->drvInst.has = 0L;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
if (had) {
|
|
|
|
if (!(wad = MSACM_GetDriver(had))) {
|
|
|
|
ret = MMSYSERR_INVALPARAM;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-26 06:33:00 +02:00
|
|
|
was->obj.dwType = WINE_ACMOBJ_STREAM;
|
1999-10-31 19:29:16 +01:00
|
|
|
was->obj.pACMDriverID = wad->obj.pACMDriverID;
|
|
|
|
was->pDrv = wad;
|
1999-12-05 03:17:18 +01:00
|
|
|
was->hAcmDriver = 0; /* not to close it in acmStreamClose */
|
|
|
|
|
2006-01-18 12:13:51 +01:00
|
|
|
ret = MSACM_Message((HACMDRIVER)wad, ACMDM_STREAM_OPEN, (LPARAM)&was->drvInst, 0L);
|
1999-10-31 19:29:16 +01:00
|
|
|
if (ret != MMSYSERR_NOERROR)
|
|
|
|
goto errCleanUp;
|
|
|
|
} else {
|
|
|
|
PWINE_ACMDRIVERID wadi;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
ret = ACMERR_NOTPOSSIBLE;
|
|
|
|
for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID) {
|
2002-06-01 01:06:46 +02:00
|
|
|
if ((wadi->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) ||
|
2001-04-23 20:14:41 +02:00
|
|
|
!MSACM_FindFormatTagInCache(wadi, pwfxSrc->wFormatTag, NULL) ||
|
|
|
|
!MSACM_FindFormatTagInCache(wadi, pwfxDst->wFormatTag, NULL))
|
|
|
|
continue;
|
1999-10-31 19:29:16 +01:00
|
|
|
ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L);
|
2001-04-23 20:14:41 +02:00
|
|
|
if (ret != MMSYSERR_NOERROR)
|
|
|
|
continue;
|
|
|
|
if ((wad = MSACM_GetDriver(had)) != 0) {
|
|
|
|
was->obj.dwType = WINE_ACMOBJ_STREAM;
|
|
|
|
was->obj.pACMDriverID = wad->obj.pACMDriverID;
|
|
|
|
was->pDrv = wad;
|
|
|
|
was->hAcmDriver = had;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-01-18 12:13:51 +01:00
|
|
|
ret = MSACM_Message((HACMDRIVER)wad, ACMDM_STREAM_OPEN, (LPARAM)&was->drvInst, 0L);
|
2003-07-02 02:40:14 +02:00
|
|
|
TRACE("%s => %08x\n", debugstr_w(wadi->pszDriverAlias), ret);
|
2001-04-23 20:14:41 +02:00
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
if (fdwOpen & ACM_STREAMOPENF_QUERY) {
|
2012-01-18 00:08:12 +01:00
|
|
|
MSACM_Message((HACMDRIVER)wad, ACMDM_STREAM_CLOSE, (LPARAM)&was->drvInst, 0);
|
2001-04-23 20:14:41 +02:00
|
|
|
acmDriverClose(had, 0L);
|
1999-12-06 00:08:42 +01:00
|
|
|
}
|
2001-04-23 20:14:41 +02:00
|
|
|
break;
|
1999-10-31 19:29:16 +01:00
|
|
|
}
|
|
|
|
}
|
2001-04-23 20:14:41 +02:00
|
|
|
/* no match, close this acm driver and try next one */
|
|
|
|
acmDriverClose(had, 0L);
|
1999-10-31 19:29:16 +01:00
|
|
|
}
|
|
|
|
if (ret != MMSYSERR_NOERROR) {
|
|
|
|
ret = ACMERR_NOTPOSSIBLE;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = MMSYSERR_NOERROR;
|
2001-05-22 21:21:16 +02:00
|
|
|
was->drvInst.has = (HACMSTREAM)was;
|
1999-12-06 00:08:42 +01:00
|
|
|
if (!(fdwOpen & ACM_STREAMOPENF_QUERY)) {
|
|
|
|
if (phas)
|
|
|
|
*phas = (HACMSTREAM)was;
|
|
|
|
TRACE("=> (%d)\n", ret);
|
1999-10-31 19:29:16 +01:00
|
|
|
return ret;
|
1999-12-06 00:08:42 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
errCleanUp:
|
1999-12-06 00:08:42 +01:00
|
|
|
if (phas)
|
2002-12-02 19:10:57 +01:00
|
|
|
*phas = NULL;
|
1999-10-31 19:29:16 +01:00
|
|
|
HeapFree(MSACM_hHeap, 0, was);
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-11 22:14:43 +02:00
|
|
|
* acmStreamPrepareHeader (MSACM32.@)
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
|
1999-10-31 19:29:16 +01:00
|
|
|
DWORD fdwPrepare)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-10-31 19:29:16 +01:00
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
MMRESULT ret = MMSYSERR_NOERROR;
|
|
|
|
PACMDRVSTREAMHEADER padsh;
|
|
|
|
|
2022-02-15 07:28:35 +01:00
|
|
|
TRACE("(%p, %p, %ld)\n", has, pash, fdwPrepare);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-03-12 21:24:50 +01:00
|
|
|
if ((was = ACM_GetStream(has)) == NULL) {
|
|
|
|
WARN("invalid handle\n");
|
2016-08-28 09:07:28 +02:00
|
|
|
return MMSYSERR_INVALHANDLE;
|
2004-03-12 21:24:50 +01:00
|
|
|
}
|
|
|
|
if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) {
|
|
|
|
WARN("invalid parameter\n");
|
2016-08-28 09:07:28 +02:00
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
}
|
|
|
|
if (fdwPrepare) {
|
|
|
|
WARN("invalid use of reserved parameter\n");
|
|
|
|
return MMSYSERR_INVALFLAG;
|
2004-03-12 21:24:50 +01:00
|
|
|
}
|
2017-01-17 17:48:02 +01:00
|
|
|
if ((was->drvInst.pwfxSrc->wFormatTag == WAVE_FORMAT_ADPCM ||
|
|
|
|
was->drvInst.pwfxSrc->wFormatTag == WAVE_FORMAT_PCM) &&
|
|
|
|
pash->cbSrcLength < was->drvInst.pwfxSrc->nBlockAlign) {
|
2022-02-15 07:28:35 +01:00
|
|
|
WARN("source smaller than block align (%ld < %d)\n",
|
2016-08-28 09:07:29 +02:00
|
|
|
pash->cbSrcLength, was->drvInst.pwfxSrc->nBlockAlign);
|
|
|
|
return pash->cbSrcLength ? ACMERR_NOTPOSSIBLE : MMSYSERR_INVALPARAM;
|
|
|
|
}
|
1999-10-31 19:29:16 +01:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2009-02-17 22:36:06 +01:00
|
|
|
ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_PREPARE, (LPARAM)&was->drvInst, (LPARAM)padsh);
|
1999-10-31 19:29:16 +01:00
|
|
|
if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
|
|
|
|
ret = MMSYSERR_NOERROR;
|
2013-11-04 17:06:02 +01:00
|
|
|
padsh->fdwStatus &= ~ACMSTREAMHEADER_STATUSF_INQUEUE;
|
1999-10-31 19:29:16 +01:00
|
|
|
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;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-11 22:14:43 +02:00
|
|
|
* acmStreamReset (MSACM32.@)
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
1999-10-31 19:29:16 +01:00
|
|
|
MMRESULT WINAPI acmStreamReset(HACMSTREAM has, DWORD fdwReset)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-10-31 19:29:16 +01:00
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
MMRESULT ret = MMSYSERR_NOERROR;
|
|
|
|
|
2022-02-15 07:28:35 +01:00
|
|
|
TRACE("(%p, %ld)\n", has, fdwReset);
|
1999-10-31 19:29:16 +01:00
|
|
|
|
|
|
|
if (fdwReset) {
|
2004-03-12 21:24:50 +01:00
|
|
|
WARN("invalid flag\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
ret = MMSYSERR_INVALFLAG;
|
|
|
|
} else if ((was = ACM_GetStream(has)) == NULL) {
|
2004-03-12 21:24:50 +01:00
|
|
|
WARN("invalid handle\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
} else if (was->drvInst.fdwOpen & ACM_STREAMOPENF_ASYNC) {
|
2006-01-18 12:13:51 +01:00
|
|
|
ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_RESET, (LPARAM)&was->drvInst, 0);
|
1999-10-31 19:29:16 +01:00
|
|
|
}
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-11 22:14:43 +02:00
|
|
|
* acmStreamSize (MSACM32.@)
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput,
|
1999-10-31 19:29:16 +01:00
|
|
|
LPDWORD pdwOutputBytes, DWORD fdwSize)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-10-31 19:29:16 +01:00
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
ACMDRVSTREAMSIZE adss;
|
|
|
|
MMRESULT ret;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2022-02-15 07:28:35 +01:00
|
|
|
TRACE("(%p, %ld, %p, %ld)\n", has, cbInput, pdwOutputBytes, fdwSize);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
if ((was = ACM_GetStream(has)) == NULL) {
|
2004-03-12 21:24:50 +01:00
|
|
|
WARN("invalid handle\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return MMSYSERR_INVALHANDLE;
|
|
|
|
}
|
|
|
|
if ((fdwSize & ~ACM_STREAMSIZEF_QUERYMASK) != 0) {
|
2004-03-12 21:24:50 +01:00
|
|
|
WARN("invalid flag\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pdwOutputBytes = 0L;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 19:29:16 +01: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;
|
2002-06-01 01:06:46 +02:00
|
|
|
default:
|
2004-03-12 21:24:50 +01:00
|
|
|
WARN("invalid flag\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return MMSYSERR_INVALFLAG;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 19:29:16 +01:00
|
|
|
adss.cbStruct = sizeof(adss);
|
|
|
|
adss.fdwSize = fdwSize;
|
2006-01-18 12:13:51 +01:00
|
|
|
ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_SIZE,
|
2005-09-12 17:14:06 +02:00
|
|
|
(LPARAM)&was->drvInst, (LPARAM)&adss);
|
1999-10-31 19:29:16 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2022-02-15 07:28:35 +01:00
|
|
|
TRACE("=> (%d) [%lu]\n", ret, *pdwOutputBytes);
|
1999-10-31 19:29:16 +01:00
|
|
|
return ret;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-11 22:14:43 +02:00
|
|
|
* acmStreamUnprepareHeader (MSACM32.@)
|
1998-10-11 19:00:29 +02:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
|
1999-10-31 19:29:16 +01:00
|
|
|
DWORD fdwUnprepare)
|
1998-10-11 19:00:29 +02:00
|
|
|
{
|
1999-10-31 19:29:16 +01:00
|
|
|
PWINE_ACMSTREAM was;
|
|
|
|
MMRESULT ret = MMSYSERR_NOERROR;
|
|
|
|
PACMDRVSTREAMHEADER padsh;
|
|
|
|
|
2022-02-15 07:28:35 +01:00
|
|
|
TRACE("(%p, %p, %ld)\n", has, pash, fdwUnprepare);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-03-12 21:24:50 +01:00
|
|
|
if ((was = ACM_GetStream(has)) == NULL) {
|
|
|
|
WARN("invalid handle\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return MMSYSERR_INVALHANDLE;
|
2004-03-12 21:24:50 +01:00
|
|
|
}
|
|
|
|
if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER)) {
|
|
|
|
WARN("invalid parameter\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return MMSYSERR_INVALPARAM;
|
2004-03-12 21:24:50 +01:00
|
|
|
}
|
|
|
|
if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED)) {
|
|
|
|
WARN("unprepared header\n");
|
1999-10-31 19:29:16 +01:00
|
|
|
return ACMERR_UNPREPARED;
|
2004-03-12 21:24:50 +01:00
|
|
|
}
|
1999-10-31 19:29:16 +01:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2016-08-28 09:07:30 +02:00
|
|
|
if (!ACM_ValidatePointers(padsh)) {
|
2004-03-12 21:24:50 +01:00
|
|
|
WARN("invalid parameter\n");
|
2016-08-28 09:07:30 +02:00
|
|
|
return MMSYSERR_INVALPARAM;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-10-31 19:29:16 +01:00
|
|
|
|
|
|
|
padsh->fdwConvert = fdwUnprepare;
|
|
|
|
|
2006-01-18 12:13:51 +01:00
|
|
|
ret = MSACM_Message((HACMDRIVER)was->pDrv, ACMDM_STREAM_UNPREPARE, (LPARAM)&was->drvInst, (LPARAM)padsh);
|
1999-10-31 19:29:16 +01:00
|
|
|
if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
|
|
|
|
ret = MMSYSERR_NOERROR;
|
2013-11-04 17:06:02 +01:00
|
|
|
padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_INQUEUE|ACMSTREAMHEADER_STATUSF_PREPARED);
|
1999-10-31 19:29:16 +01:00
|
|
|
}
|
|
|
|
TRACE("=> (%d)\n", ret);
|
|
|
|
return ret;
|
1998-10-11 19:00:29 +02:00
|
|
|
}
|