1999-10-31 03:23:49 +01:00
|
|
|
/* -*- tab-width: 8; c-basic-offset: 4 -*- */
|
2002-06-01 01:06:46 +02:00
|
|
|
/*
|
1999-10-31 03:23:49 +01:00
|
|
|
* Wine Wave mapper driver
|
|
|
|
*
|
2001-04-14 00:28:06 +02:00
|
|
|
* Copyright 1999,2001 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 03:23:49 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* TODOs
|
|
|
|
* + better protection against evilish dwUser parameters
|
|
|
|
* + use asynchronous ACM conversion
|
2001-04-14 00:28:06 +02:00
|
|
|
* + don't use callback functions when none is required in open
|
|
|
|
* + the buffer sizes may not be accurate, so there may be some
|
|
|
|
* remaining bytes in src and dst buffers after ACM conversions...
|
|
|
|
* those should be taken care of...
|
1999-10-31 03:23:49 +01:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
2000-12-19 05:53:20 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
1999-10-31 03:23:49 +01:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "mmddk.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "mmreg.h"
|
1999-10-31 03:23:49 +01:00
|
|
|
#include "msacm.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-10-31 03:23:49 +01:00
|
|
|
|
2004-06-14 19:55:03 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wavemap);
|
1999-10-31 03:23:49 +01:00
|
|
|
|
|
|
|
typedef struct tagWAVEMAPDATA {
|
1999-11-21 01:51:05 +01:00
|
|
|
struct tagWAVEMAPDATA* self;
|
2002-10-30 21:25:38 +01:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
HWAVEOUT hOuterWave;
|
|
|
|
HWAVEOUT hInnerWave;
|
|
|
|
} out;
|
|
|
|
struct {
|
|
|
|
HWAVEIN hOuterWave;
|
|
|
|
HWAVEIN hInnerWave;
|
|
|
|
} in;
|
|
|
|
} u;
|
1999-10-31 03:23:49 +01:00
|
|
|
HACMSTREAM hAcmStream;
|
|
|
|
/* needed data to filter callbacks. Only needed when hAcmStream is not 0 */
|
2009-05-20 17:52:49 +02:00
|
|
|
DWORD_PTR dwCallback;
|
|
|
|
DWORD_PTR dwClientInstance;
|
1999-10-31 03:23:49 +01:00
|
|
|
DWORD dwFlags;
|
2002-10-31 01:54:27 +01:00
|
|
|
/* ratio to compute position from a PCM playback to any format */
|
|
|
|
DWORD avgSpeedOuter;
|
|
|
|
DWORD avgSpeedInner;
|
2005-02-23 13:42:32 +01:00
|
|
|
/* channel size of inner and outer */
|
|
|
|
DWORD nSamplesPerSecOuter;
|
|
|
|
DWORD nSamplesPerSecInner;
|
1999-10-31 03:23:49 +01:00
|
|
|
} WAVEMAPDATA;
|
|
|
|
|
2007-05-27 18:52:34 +02:00
|
|
|
static BOOL WAVEMAP_IsData(const WAVEMAPDATA* wm)
|
1999-11-21 01:51:05 +01:00
|
|
|
{
|
|
|
|
return (!IsBadReadPtr(wm, sizeof(WAVEMAPDATA)) && wm->self == wm);
|
|
|
|
}
|
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
/*======================================================================*
|
|
|
|
* WAVE OUT part *
|
|
|
|
*======================================================================*/
|
|
|
|
|
2005-11-28 20:53:22 +01:00
|
|
|
static void CALLBACK wodCallback(HWAVEOUT hWave, UINT uMsg, DWORD_PTR dwInstance,
|
2009-02-17 22:04:58 +01:00
|
|
|
DWORD_PTR dwParam1, DWORD_PTR dwParam2)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
|
|
|
WAVEMAPDATA* wom = (WAVEMAPDATA*)dwInstance;
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
TRACE("(%p %u %ld %lx %lx);\n", hWave, uMsg, dwInstance, dwParam1, dwParam2);
|
2001-04-14 00:28:06 +02:00
|
|
|
|
|
|
|
if (!WAVEMAP_IsData(wom)) {
|
|
|
|
ERR("Bad data\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-22 20:08:48 +02:00
|
|
|
if (uMsg != WOM_OPEN && hWave != wom->u.out.hInnerWave)
|
2002-10-30 21:25:38 +01:00
|
|
|
ERR("Shouldn't happen (%p %p)\n", hWave, wom->u.out.hInnerWave);
|
1999-10-31 03:23:49 +01:00
|
|
|
|
|
|
|
switch (uMsg) {
|
|
|
|
case WOM_OPEN:
|
|
|
|
case WOM_CLOSE:
|
|
|
|
/* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
|
|
|
|
break;
|
|
|
|
case WOM_DONE:
|
2001-04-14 00:28:06 +02:00
|
|
|
if (wom->hAcmStream) {
|
1999-10-31 03:23:49 +01:00
|
|
|
LPWAVEHDR lpWaveHdrDst = (LPWAVEHDR)dwParam1;
|
|
|
|
PACMSTREAMHEADER ash = (PACMSTREAMHEADER)((LPSTR)lpWaveHdrDst - sizeof(ACMSTREAMHEADER));
|
|
|
|
LPWAVEHDR lpWaveHdrSrc = (LPWAVEHDR)ash->dwUser;
|
|
|
|
|
|
|
|
lpWaveHdrSrc->dwFlags &= ~WHDR_INQUEUE;
|
|
|
|
lpWaveHdrSrc->dwFlags |= WHDR_DONE;
|
2009-02-17 22:04:58 +01:00
|
|
|
dwParam1 = (DWORD_PTR)lpWaveHdrSrc;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown msg %u\n", uMsg);
|
|
|
|
}
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
DriverCallback(wom->dwCallback, HIWORD(wom->dwFlags), (HDRVR)wom->u.out.hOuterWave,
|
2002-08-09 03:02:25 +02:00
|
|
|
uMsg, wom->dwClientInstance, dwParam1, dwParam2);
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
/******************************************************************
|
|
|
|
* wodOpenHelper
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static DWORD wodOpenHelper(WAVEMAPDATA* wom, UINT idx,
|
|
|
|
LPWAVEOPENDESC lpDesc, LPWAVEFORMATEX lpwfx,
|
1999-10-31 03:23:49 +01:00
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
2004-06-14 19:55:03 +02:00
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %04x %p %p %08x)\n", wom, idx, lpDesc, lpwfx, dwFlags);
|
1999-10-31 03:23:49 +01:00
|
|
|
|
|
|
|
/* destination is always PCM, so the formulas below apply */
|
|
|
|
lpwfx->nBlockAlign = (lpwfx->nChannels * lpwfx->wBitsPerSample) / 8;
|
|
|
|
lpwfx->nAvgBytesPerSec = lpwfx->nSamplesPerSec * lpwfx->nBlockAlign;
|
2001-05-21 20:32:17 +02:00
|
|
|
if (dwFlags & WAVE_FORMAT_QUERY) {
|
|
|
|
ret = acmStreamOpen(NULL, 0, lpDesc->lpFormat, lpwfx, NULL, 0L, 0L, ACM_STREAMOPENF_QUERY);
|
|
|
|
} else {
|
|
|
|
ret = acmStreamOpen(&wom->hAcmStream, 0, lpDesc->lpFormat, lpwfx, NULL, 0L, 0L, 0L);
|
|
|
|
}
|
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
2009-02-17 22:04:58 +01:00
|
|
|
ret = waveOutOpen(&wom->u.out.hInnerWave, idx, lpwfx,
|
|
|
|
(DWORD_PTR)wodCallback, (DWORD_PTR)wom,
|
|
|
|
(dwFlags & ~CALLBACK_TYPEMASK) | CALLBACK_FUNCTION);
|
2001-05-21 20:32:17 +02:00
|
|
|
if (ret != MMSYSERR_NOERROR && !(dwFlags & WAVE_FORMAT_QUERY)) {
|
|
|
|
acmStreamClose(wom->hAcmStream, 0);
|
|
|
|
wom->hAcmStream = 0;
|
|
|
|
}
|
|
|
|
}
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("ret = %08x\n", ret);
|
2001-05-21 20:32:17 +02:00
|
|
|
return ret;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
2009-05-20 17:52:49 +02:00
|
|
|
static DWORD wodOpen(DWORD_PTR *lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2001-11-13 22:58:32 +01:00
|
|
|
UINT ndlo, ndhi;
|
1999-10-31 03:23:49 +01:00
|
|
|
UINT i;
|
|
|
|
WAVEMAPDATA* wom = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA));
|
2004-06-01 21:41:18 +02:00
|
|
|
DWORD res;
|
1999-10-31 03:23:49 +01:00
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %p %08x)\n", lpdwUser, lpDesc, dwFlags);
|
1999-10-31 03:23:49 +01:00
|
|
|
|
2004-06-14 19:55:03 +02:00
|
|
|
if (!wom) {
|
|
|
|
WARN("no memory\n");
|
1999-10-31 03:23:49 +01:00
|
|
|
return MMSYSERR_NOMEM;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
1999-10-31 03:23:49 +01:00
|
|
|
|
2001-11-13 22:58:32 +01:00
|
|
|
ndhi = waveOutGetNumDevs();
|
|
|
|
if (dwFlags & WAVE_MAPPED) {
|
2004-06-14 19:55:03 +02:00
|
|
|
if (lpDesc->uMappedDeviceID >= ndhi) {
|
|
|
|
WARN("invalid parameter: dwFlags WAVE_MAPPED\n");
|
2005-03-15 16:39:03 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, wom);
|
2004-06-14 19:55:03 +02:00
|
|
|
return MMSYSERR_INVALPARAM;
|
|
|
|
}
|
2001-11-13 22:58:32 +01:00
|
|
|
ndlo = lpDesc->uMappedDeviceID;
|
|
|
|
ndhi = ndlo + 1;
|
|
|
|
dwFlags &= ~WAVE_MAPPED;
|
|
|
|
} else {
|
|
|
|
ndlo = 0;
|
|
|
|
}
|
1999-11-21 01:51:05 +01:00
|
|
|
wom->self = wom;
|
2001-04-14 00:28:06 +02:00
|
|
|
wom->dwCallback = lpDesc->dwCallback;
|
|
|
|
wom->dwFlags = dwFlags;
|
|
|
|
wom->dwClientInstance = lpDesc->dwInstance;
|
2002-10-30 21:25:38 +01:00
|
|
|
wom->u.out.hOuterWave = (HWAVEOUT)lpDesc->hWave;
|
2002-10-31 01:54:27 +01:00
|
|
|
wom->avgSpeedOuter = wom->avgSpeedInner = lpDesc->lpFormat->nAvgBytesPerSec;
|
2005-02-23 13:42:32 +01:00
|
|
|
wom->nSamplesPerSecOuter = wom->nSamplesPerSecInner = lpDesc->lpFormat->nSamplesPerSec;
|
1999-11-21 01:51:05 +01:00
|
|
|
|
2001-11-13 22:58:32 +01:00
|
|
|
for (i = ndlo; i < ndhi; i++) {
|
1999-10-31 03:23:49 +01:00
|
|
|
/* if no ACM stuff is involved, no need to handle callbacks at this
|
|
|
|
* level, this will be done transparently
|
|
|
|
*/
|
2009-02-17 22:04:58 +01:00
|
|
|
if (waveOutOpen(&wom->u.out.hInnerWave, i, lpDesc->lpFormat,
|
|
|
|
(DWORD_PTR)wodCallback, (DWORD_PTR)wom,
|
|
|
|
(dwFlags & ~CALLBACK_TYPEMASK) | CALLBACK_FUNCTION | WAVE_FORMAT_DIRECT) == MMSYSERR_NOERROR) {
|
1999-10-31 03:23:49 +01:00
|
|
|
wom->hAcmStream = 0;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-16 12:22:06 +01:00
|
|
|
if ((dwFlags & WAVE_FORMAT_DIRECT) == 0) {
|
2002-10-07 20:22:57 +02:00
|
|
|
WAVEFORMATEX wfx;
|
1999-10-31 03:23:49 +01:00
|
|
|
|
2002-10-07 20:22:57 +02:00
|
|
|
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
wfx.cbSize = 0; /* normally, this field is not used for PCM format, just in case */
|
|
|
|
/* try some ACM stuff */
|
1999-10-31 03:23:49 +01:00
|
|
|
|
2002-10-07 20:22:57 +02:00
|
|
|
#define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \
|
2004-06-01 21:41:18 +02:00
|
|
|
switch (res=wodOpenHelper(wom, i, lpDesc, &wfx, dwFlags | WAVE_FORMAT_DIRECT)) { \
|
2005-02-23 13:42:32 +01:00
|
|
|
case MMSYSERR_NOERROR: wom->avgSpeedInner = wfx.nAvgBytesPerSec; wom->nSamplesPerSecInner = wfx.nSamplesPerSec; goto found; \
|
2003-05-11 05:30:51 +02:00
|
|
|
case WAVERR_BADFORMAT: break; \
|
|
|
|
default: goto error; \
|
|
|
|
}
|
2002-10-07 20:22:57 +02:00
|
|
|
|
2005-11-16 12:22:06 +01:00
|
|
|
if (lpDesc->lpFormat->wFormatTag != WAVE_FORMAT_PCM) {
|
|
|
|
/* Format changed so keep sample rate and number of channels
|
|
|
|
* the same and just change the bit depth
|
|
|
|
*/
|
|
|
|
for (i = ndlo; i < ndhi; i++) {
|
|
|
|
wfx.nSamplesPerSec=lpDesc->lpFormat->nSamplesPerSec;
|
|
|
|
wfx.nChannels = lpDesc->lpFormat->nChannels;
|
|
|
|
TRY(wfx.nSamplesPerSec, 16);
|
|
|
|
TRY(wfx.nSamplesPerSec, 8);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Our resampling algorithm is quite primitive so first try
|
|
|
|
* to just change the bit depth and number of channels
|
|
|
|
*/
|
|
|
|
for (i = ndlo; i < ndhi; i++) {
|
|
|
|
wfx.nSamplesPerSec=lpDesc->lpFormat->nSamplesPerSec;
|
|
|
|
wfx.nChannels = lpDesc->lpFormat->nChannels;
|
|
|
|
TRY(wfx.nSamplesPerSec, 16);
|
|
|
|
TRY(wfx.nSamplesPerSec, 8);
|
|
|
|
wfx.nChannels ^= 3;
|
|
|
|
TRY(wfx.nSamplesPerSec, 16);
|
|
|
|
TRY(wfx.nSamplesPerSec, 8);
|
|
|
|
}
|
2002-12-15 02:12:27 +01:00
|
|
|
|
2005-11-16 12:22:06 +01:00
|
|
|
for (i = ndlo; i < ndhi; i++) {
|
|
|
|
/* first try with same stereo/mono option as source */
|
|
|
|
wfx.nChannels = lpDesc->lpFormat->nChannels;
|
|
|
|
TRY(96000, 16);
|
|
|
|
TRY(48000, 16);
|
|
|
|
TRY(44100, 16);
|
|
|
|
TRY(22050, 16);
|
|
|
|
TRY(11025, 16);
|
2002-10-07 20:22:57 +02:00
|
|
|
|
2005-11-16 12:22:06 +01:00
|
|
|
/* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */
|
|
|
|
wfx.nChannels ^= 3;
|
|
|
|
TRY(96000, 16);
|
|
|
|
TRY(48000, 16);
|
|
|
|
TRY(44100, 16);
|
|
|
|
TRY(22050, 16);
|
|
|
|
TRY(11025, 16);
|
2002-10-07 20:22:57 +02:00
|
|
|
|
2005-11-16 12:22:06 +01:00
|
|
|
/* first try with same stereo/mono option as source */
|
|
|
|
wfx.nChannels = lpDesc->lpFormat->nChannels;
|
|
|
|
TRY(96000, 8);
|
|
|
|
TRY(48000, 8);
|
|
|
|
TRY(44100, 8);
|
|
|
|
TRY(22050, 8);
|
|
|
|
TRY(11025, 8);
|
2002-10-07 20:22:57 +02:00
|
|
|
|
2005-11-16 12:22:06 +01:00
|
|
|
/* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */
|
|
|
|
wfx.nChannels ^= 3;
|
|
|
|
TRY(96000, 8);
|
|
|
|
TRY(48000, 8);
|
|
|
|
TRY(44100, 8);
|
|
|
|
TRY(22050, 8);
|
|
|
|
TRY(11025, 8);
|
|
|
|
}
|
2002-10-07 20:22:57 +02:00
|
|
|
}
|
1999-10-31 03:23:49 +01:00
|
|
|
#undef TRY
|
2002-10-07 20:22:57 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, wom);
|
2004-06-14 19:55:03 +02:00
|
|
|
WARN("ret = WAVERR_BADFORMAT\n");
|
2002-12-12 23:23:15 +01:00
|
|
|
return WAVERR_BADFORMAT;
|
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
found:
|
1999-12-06 00:09:13 +01:00
|
|
|
if (dwFlags & WAVE_FORMAT_QUERY) {
|
|
|
|
*lpdwUser = 0L;
|
|
|
|
HeapFree(GetProcessHeap(), 0, wom);
|
|
|
|
} else {
|
2009-02-17 22:04:58 +01:00
|
|
|
*lpdwUser = (DWORD_PTR)wom;
|
1999-12-06 00:09:13 +01:00
|
|
|
}
|
1999-10-31 03:23:49 +01:00
|
|
|
return MMSYSERR_NOERROR;
|
2003-05-11 05:30:51 +02:00
|
|
|
error:
|
|
|
|
HeapFree(GetProcessHeap(), 0, wom);
|
2004-06-01 21:41:18 +02:00
|
|
|
if (res==ACMERR_NOTPOSSIBLE) {
|
|
|
|
WARN("ret = WAVERR_BADFORMAT\n");
|
|
|
|
return WAVERR_BADFORMAT;
|
|
|
|
}
|
2006-10-09 21:23:23 +02:00
|
|
|
WARN("ret = 0x%08x\n", res);
|
2004-12-20 18:09:12 +01:00
|
|
|
return res;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD wodClose(WAVEMAPDATA* wom)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", wom);
|
1999-10-31 03:23:49 +01:00
|
|
|
|
2004-06-14 19:55:03 +02:00
|
|
|
ret = waveOutClose(wom->u.out.hInnerWave);
|
1999-10-31 03:23:49 +01:00
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
if (wom->hAcmStream) {
|
2001-01-03 22:33:17 +01:00
|
|
|
ret = acmStreamClose(wom->hAcmStream, 0);
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, wom);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD wodWrite(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2)
|
|
|
|
{
|
|
|
|
PACMSTREAMHEADER ash;
|
|
|
|
LPWAVEHDR lpWaveHdrDst;
|
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %p %08x)\n", wom, lpWaveHdrSrc, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
if (!wom->hAcmStream) {
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveOutWrite(wom->u.out.hInnerWave, lpWaveHdrSrc, dwParam2);
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
lpWaveHdrSrc->dwFlags |= WHDR_INQUEUE;
|
|
|
|
ash = (PACMSTREAMHEADER)lpWaveHdrSrc->reserved;
|
2002-04-01 23:02:27 +02:00
|
|
|
/* acmStreamConvert will actually check that the new size is less than initial size */
|
|
|
|
ash->cbSrcLength = lpWaveHdrSrc->dwBufferLength;
|
2004-06-14 19:55:03 +02:00
|
|
|
if (acmStreamConvert(wom->hAcmStream, ash, 0L) != MMSYSERR_NOERROR) {
|
|
|
|
WARN("acmStreamConvert failed\n");
|
1999-10-31 03:23:49 +01:00
|
|
|
return MMSYSERR_ERROR;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
lpWaveHdrDst = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER));
|
2002-10-07 20:22:57 +02:00
|
|
|
if (ash->cbSrcLength > ash->cbSrcLengthUsed)
|
|
|
|
FIXME("Not all src buffer has been written, expect bogus sound\n");
|
|
|
|
else if (ash->cbSrcLength < ash->cbSrcLengthUsed)
|
2011-07-27 13:38:43 +02:00
|
|
|
ERR("Codec has read more data than it is allowed to\n");
|
2002-10-07 20:22:57 +02:00
|
|
|
|
2004-06-14 19:55:03 +02:00
|
|
|
if (ash->cbDstLengthUsed == 0) {
|
2002-04-01 23:02:27 +02:00
|
|
|
/* something went wrong in decoding */
|
|
|
|
FIXME("Got 0 length\n");
|
|
|
|
return MMSYSERR_ERROR;
|
|
|
|
}
|
1999-10-31 03:23:49 +01:00
|
|
|
lpWaveHdrDst->dwBufferLength = ash->cbDstLengthUsed;
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveOutWrite(wom->u.out.hInnerWave, lpWaveHdrDst, sizeof(*lpWaveHdrDst));
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD wodPrepare(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2)
|
|
|
|
{
|
|
|
|
PACMSTREAMHEADER ash;
|
|
|
|
DWORD size;
|
|
|
|
DWORD dwRet;
|
|
|
|
LPWAVEHDR lpWaveHdrDst;
|
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %p %08x)\n", wom, lpWaveHdrSrc, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
|
|
|
if (!wom->hAcmStream)
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveOutPrepareHeader(wom->u.out.hInnerWave, lpWaveHdrSrc, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
|
|
|
if (acmStreamSize(wom->hAcmStream, lpWaveHdrSrc->dwBufferLength, &size, ACM_STREAMSIZEF_SOURCE) != MMSYSERR_NOERROR) {
|
|
|
|
WARN("acmStreamSize failed\n");
|
1999-10-31 03:23:49 +01:00
|
|
|
return MMSYSERR_ERROR;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
1999-10-31 03:23:49 +01:00
|
|
|
|
|
|
|
ash = HeapAlloc(GetProcessHeap(), 0, sizeof(ACMSTREAMHEADER) + sizeof(WAVEHDR) + size);
|
2004-06-14 19:55:03 +02:00
|
|
|
if (ash == NULL) {
|
|
|
|
WARN("no memory\n");
|
1999-10-31 03:23:49 +01:00
|
|
|
return MMSYSERR_NOMEM;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
1999-10-31 03:23:49 +01:00
|
|
|
|
|
|
|
ash->cbStruct = sizeof(*ash);
|
|
|
|
ash->fdwStatus = 0L;
|
2009-02-17 22:04:58 +01:00
|
|
|
ash->dwUser = (DWORD_PTR)lpWaveHdrSrc;
|
2005-09-02 14:26:21 +02:00
|
|
|
ash->pbSrc = (LPBYTE)lpWaveHdrSrc->lpData;
|
1999-10-31 03:23:49 +01:00
|
|
|
ash->cbSrcLength = lpWaveHdrSrc->dwBufferLength;
|
|
|
|
/* ash->cbSrcLengthUsed */
|
|
|
|
ash->dwSrcUser = lpWaveHdrSrc->dwUser; /* FIXME ? */
|
2005-09-02 14:26:21 +02:00
|
|
|
ash->pbDst = (LPBYTE)ash + sizeof(ACMSTREAMHEADER) + sizeof(WAVEHDR);
|
1999-10-31 03:23:49 +01:00
|
|
|
ash->cbDstLength = size;
|
|
|
|
/* ash->cbDstLengthUsed */
|
|
|
|
ash->dwDstUser = 0; /* FIXME ? */
|
2001-01-03 22:33:17 +01:00
|
|
|
dwRet = acmStreamPrepareHeader(wom->hAcmStream, ash, 0L);
|
2004-06-14 19:55:03 +02:00
|
|
|
if (dwRet != MMSYSERR_NOERROR) {
|
|
|
|
WARN("acmStreamPrepareHeader failed\n");
|
1999-10-31 03:23:49 +01:00
|
|
|
goto errCleanUp;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
1999-10-31 03:23:49 +01:00
|
|
|
|
|
|
|
lpWaveHdrDst = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER));
|
2005-09-02 14:26:21 +02:00
|
|
|
lpWaveHdrDst->lpData = (LPSTR)ash->pbDst;
|
1999-10-31 03:23:49 +01:00
|
|
|
lpWaveHdrDst->dwBufferLength = size; /* conversion is not done yet */
|
|
|
|
lpWaveHdrDst->dwFlags = 0;
|
|
|
|
lpWaveHdrDst->dwLoops = 0;
|
2002-10-30 21:25:38 +01:00
|
|
|
dwRet = waveOutPrepareHeader(wom->u.out.hInnerWave, lpWaveHdrDst, sizeof(*lpWaveHdrDst));
|
2004-06-14 19:55:03 +02:00
|
|
|
if (dwRet != MMSYSERR_NOERROR) {
|
|
|
|
WARN("waveOutPrepareHeader failed\n");
|
1999-10-31 03:23:49 +01:00
|
|
|
goto errCleanUp;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
1999-10-31 03:23:49 +01:00
|
|
|
|
2009-02-17 22:04:58 +01:00
|
|
|
lpWaveHdrSrc->reserved = (DWORD_PTR)ash;
|
1999-10-31 03:23:49 +01:00
|
|
|
lpWaveHdrSrc->dwFlags = WHDR_PREPARED;
|
|
|
|
TRACE("=> (0)\n");
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
errCleanUp:
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("=> (%d)\n", dwRet);
|
1999-10-31 03:23:49 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, ash);
|
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD wodUnprepare(WAVEMAPDATA* wom, LPWAVEHDR lpWaveHdrSrc, DWORD dwParam2)
|
|
|
|
{
|
|
|
|
PACMSTREAMHEADER ash;
|
|
|
|
LPWAVEHDR lpWaveHdrDst;
|
|
|
|
DWORD dwRet1, dwRet2;
|
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %p %08x)\n", wom, lpWaveHdrSrc, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
if (!wom->hAcmStream) {
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveOutUnprepareHeader(wom->u.out.hInnerWave, lpWaveHdrSrc, dwParam2);
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
ash = (PACMSTREAMHEADER)lpWaveHdrSrc->reserved;
|
2001-01-03 22:33:17 +01:00
|
|
|
dwRet1 = acmStreamUnprepareHeader(wom->hAcmStream, ash, 0L);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
lpWaveHdrDst = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER));
|
2002-10-30 21:25:38 +01:00
|
|
|
dwRet2 = waveOutUnprepareHeader(wom->u.out.hInnerWave, lpWaveHdrDst, sizeof(*lpWaveHdrDst));
|
1999-10-31 03:23:49 +01:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, ash);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
lpWaveHdrSrc->dwFlags &= ~WHDR_PREPARED;
|
|
|
|
return (dwRet1 == MMSYSERR_NOERROR) ? dwRet2 : dwRet1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD wodGetPosition(WAVEMAPDATA* wom, LPMMTIME lpTime, DWORD dwParam2)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
DWORD val;
|
2005-03-02 13:17:28 +01:00
|
|
|
MMTIME timepos;
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %p %08x)\n", wom, lpTime, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
2008-03-05 22:34:59 +01:00
|
|
|
timepos = *lpTime;
|
2005-03-02 13:17:28 +01:00
|
|
|
|
|
|
|
/* For TIME_MS, we're going to recalculate using TIME_BYTES */
|
|
|
|
if (lpTime->wType == TIME_MS)
|
|
|
|
timepos.wType = TIME_BYTES;
|
|
|
|
|
2005-04-11 14:49:04 +02:00
|
|
|
/* This can change timepos.wType if the requested type is not supported */
|
2005-03-02 13:17:28 +01:00
|
|
|
val = waveOutGetPosition(wom->u.out.hInnerWave, &timepos, dwParam2);
|
|
|
|
|
2005-04-11 14:49:04 +02:00
|
|
|
if (timepos.wType == TIME_BYTES)
|
2005-03-02 13:17:28 +01:00
|
|
|
{
|
|
|
|
DWORD dwInnerSamplesPerOuter = wom->nSamplesPerSecInner / wom->nSamplesPerSecOuter;
|
|
|
|
if (dwInnerSamplesPerOuter > 0)
|
|
|
|
{
|
|
|
|
DWORD dwInnerBytesPerSample = wom->avgSpeedInner / wom->nSamplesPerSecInner;
|
|
|
|
DWORD dwInnerBytesPerOuterSample = dwInnerBytesPerSample * dwInnerSamplesPerOuter;
|
|
|
|
DWORD remainder = 0;
|
|
|
|
|
|
|
|
/* If we are up sampling (going from lower sample rate to higher),
|
2006-02-24 16:11:36 +01:00
|
|
|
** we need to make a special accommodation for times when we've
|
2005-03-02 13:17:28 +01:00
|
|
|
** written a partial output sample. This happens frequently
|
|
|
|
** to us because we use msacm to do our up sampling, and it
|
|
|
|
** will up sample on an unaligned basis.
|
|
|
|
** For example, if you convert a 2 byte wide 8,000 'outer'
|
|
|
|
** buffer to a 2 byte wide 48,000 inner device, you would
|
|
|
|
** expect 2 bytes of input to produce 12 bytes of output.
|
|
|
|
** Instead, msacm will produce 8 bytes of output.
|
|
|
|
** But reporting our position as 1 byte of output is
|
|
|
|
** nonsensical; the output buffer position needs to be
|
|
|
|
** aligned on outer sample size, and aggressively rounded up.
|
|
|
|
*/
|
|
|
|
remainder = timepos.u.cb % dwInnerBytesPerOuterSample;
|
|
|
|
if (remainder > 0)
|
|
|
|
{
|
|
|
|
timepos.u.cb -= remainder;
|
|
|
|
timepos.u.cb += dwInnerBytesPerOuterSample;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lpTime->u.cb = MulDiv(timepos.u.cb, wom->avgSpeedOuter, wom->avgSpeedInner);
|
|
|
|
|
|
|
|
/* Once we have the TIME_BYTES right, we can easily convert to TIME_MS */
|
|
|
|
if (lpTime->wType == TIME_MS)
|
2005-04-11 14:49:04 +02:00
|
|
|
lpTime->u.ms = MulDiv(lpTime->u.cb, 1000, wom->avgSpeedOuter);
|
|
|
|
else
|
|
|
|
lpTime->wType = TIME_BYTES;
|
2005-03-02 13:17:28 +01:00
|
|
|
}
|
2005-04-11 14:49:04 +02:00
|
|
|
else if (lpTime->wType == TIME_SAMPLES && timepos.wType == TIME_SAMPLES)
|
|
|
|
lpTime->u.sample = MulDiv(timepos.u.sample, wom->nSamplesPerSecOuter, wom->nSamplesPerSecInner);
|
2005-03-02 13:17:28 +01:00
|
|
|
else
|
|
|
|
/* other time types don't require conversion */
|
|
|
|
lpTime->u = timepos.u;
|
|
|
|
|
2002-10-31 01:54:27 +01:00
|
|
|
return val;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
2004-12-06 21:55:25 +01:00
|
|
|
static DWORD wodGetDevCaps(UINT wDevID, WAVEMAPDATA* wom, LPWAVEOUTCAPSW lpWaveCaps, DWORD dwParam2)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%04x %p %p %08x)\n",wDevID, wom, lpWaveCaps, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
1999-11-21 01:51:05 +01:00
|
|
|
/* if opened low driver, forward message */
|
|
|
|
if (WAVEMAP_IsData(wom))
|
2009-02-17 22:04:58 +01:00
|
|
|
return waveOutGetDevCapsW((UINT_PTR)wom->u.out.hInnerWave, lpWaveCaps, dwParam2);
|
2004-06-01 22:19:30 +02:00
|
|
|
/* else if no drivers, nothing to map so return bad device */
|
2004-06-14 19:55:03 +02:00
|
|
|
if (waveOutGetNumDevs() == 0) {
|
|
|
|
WARN("bad device id\n");
|
2004-06-01 22:19:30 +02:00
|
|
|
return MMSYSERR_BADDEVICEID;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
1999-11-21 01:51:05 +01:00
|
|
|
/* otherwise, return caps of mapper itself */
|
|
|
|
if (wDevID == (UINT)-1 || wDevID == (UINT16)-1) {
|
2004-12-06 21:55:25 +01:00
|
|
|
WAVEOUTCAPSW woc;
|
2004-06-04 19:57:40 +02:00
|
|
|
woc.wMid = 0x00FF;
|
|
|
|
woc.wPid = 0x0001;
|
2008-04-27 09:27:39 +02:00
|
|
|
woc.vDriverVersion = 0x0332;
|
2020-10-03 20:28:20 +02:00
|
|
|
lstrcpyW(woc.szPname, L"Wine wave out mapper");
|
2004-06-04 19:57:40 +02:00
|
|
|
woc.dwFormats =
|
2004-06-01 22:19:30 +02:00
|
|
|
WAVE_FORMAT_96M08 | WAVE_FORMAT_96S08 | WAVE_FORMAT_96M16 | WAVE_FORMAT_96S16 |
|
|
|
|
WAVE_FORMAT_48M08 | WAVE_FORMAT_48S08 | WAVE_FORMAT_48M16 | WAVE_FORMAT_48S16 |
|
1999-11-21 01:51:05 +01:00
|
|
|
WAVE_FORMAT_4M08 | WAVE_FORMAT_4S08 | WAVE_FORMAT_4M16 | WAVE_FORMAT_4S16 |
|
|
|
|
WAVE_FORMAT_2M08 | WAVE_FORMAT_2S08 | WAVE_FORMAT_2M16 | WAVE_FORMAT_2S16 |
|
|
|
|
WAVE_FORMAT_1M08 | WAVE_FORMAT_1S08 | WAVE_FORMAT_1M16 | WAVE_FORMAT_1S16;
|
2004-06-04 19:57:40 +02:00
|
|
|
woc.wChannels = 2;
|
2015-12-29 21:03:59 +01:00
|
|
|
woc.wReserved1 = 0;
|
2004-06-04 19:57:40 +02:00
|
|
|
woc.dwSupport = WAVECAPS_VOLUME | WAVECAPS_LRVOLUME;
|
|
|
|
memcpy(lpWaveCaps, &woc, min(dwParam2, sizeof(woc)));
|
1999-11-21 01:51:05 +01:00
|
|
|
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
ERR("This shouldn't happen\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
return MMSYSERR_ERROR;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
1999-11-21 01:51:05 +01:00
|
|
|
static DWORD wodGetVolume(UINT wDevID, WAVEMAPDATA* wom, LPDWORD lpVol)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
TRACE("(%04x %p %p)\n",wDevID, wom, lpVol);
|
|
|
|
|
1999-11-21 01:51:05 +01:00
|
|
|
if (WAVEMAP_IsData(wom))
|
2002-12-15 03:59:50 +01:00
|
|
|
return waveOutGetVolume(wom->u.out.hInnerWave, lpVol);
|
1999-11-21 01:51:05 +01:00
|
|
|
return MMSYSERR_NOERROR;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
1999-11-21 01:51:05 +01:00
|
|
|
static DWORD wodSetVolume(UINT wDevID, WAVEMAPDATA* wom, DWORD vol)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%04x %p %08x)\n",wDevID, wom, vol);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
1999-11-21 01:51:05 +01:00
|
|
|
if (WAVEMAP_IsData(wom))
|
2002-12-15 03:59:50 +01:00
|
|
|
return waveOutSetVolume(wom->u.out.hInnerWave, vol);
|
1999-11-21 01:51:05 +01:00
|
|
|
return MMSYSERR_NOERROR;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD wodPause(WAVEMAPDATA* wom)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
TRACE("(%p)\n",wom);
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveOutPause(wom->u.out.hInnerWave);
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD wodRestart(WAVEMAPDATA* wom)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
TRACE("(%p)\n",wom);
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveOutRestart(wom->u.out.hInnerWave);
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD wodReset(WAVEMAPDATA* wom)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
TRACE("(%p)\n",wom);
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveOutReset(wom->u.out.hInnerWave);
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
2000-01-04 01:25:57 +01:00
|
|
|
static DWORD wodBreakLoop(WAVEMAPDATA* wom)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
TRACE("(%p)\n",wom);
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveOutBreakLoop(wom->u.out.hInnerWave);
|
2000-01-04 01:25:57 +01:00
|
|
|
}
|
|
|
|
|
2001-01-03 22:33:17 +01:00
|
|
|
static DWORD wodMapperStatus(WAVEMAPDATA* wom, DWORD flags, LPVOID ptr)
|
|
|
|
{
|
|
|
|
UINT id;
|
|
|
|
DWORD ret = MMSYSERR_NOTSUPPORTED;
|
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %08x %p)\n",wom, flags, ptr);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
2001-01-03 22:33:17 +01:00
|
|
|
switch (flags) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case WAVEOUT_MAPPER_STATUS_DEVICE:
|
2002-10-30 21:25:38 +01:00
|
|
|
ret = waveOutGetID(wom->u.out.hInnerWave, &id);
|
2001-01-03 22:33:17 +01:00
|
|
|
*(LPDWORD)ptr = id;
|
|
|
|
break;
|
|
|
|
case WAVEOUT_MAPPER_STATUS_MAPPED:
|
2006-10-09 21:23:23 +02:00
|
|
|
FIXME("Unsupported flag=%d\n", flags);
|
2002-06-01 01:06:46 +02:00
|
|
|
*(LPDWORD)ptr = 0; /* FIXME ?? */
|
2001-01-03 22:33:17 +01:00
|
|
|
break;
|
|
|
|
case WAVEOUT_MAPPER_STATUS_FORMAT:
|
2006-10-09 21:23:23 +02:00
|
|
|
FIXME("Unsupported flag=%d\n", flags);
|
2001-01-03 22:33:17 +01:00
|
|
|
/* ptr points to a WAVEFORMATEX struct - before or after streaming ? */
|
|
|
|
*(LPDWORD)ptr = 0;
|
|
|
|
break;
|
|
|
|
default:
|
2006-10-09 21:23:23 +02:00
|
|
|
FIXME("Unsupported flag=%d\n", flags);
|
2001-01-03 22:33:17 +01:00
|
|
|
*(LPDWORD)ptr = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-04-12 12:14:57 +02:00
|
|
|
static DWORD wodMapperReconfigure(WAVEMAPDATA* wom, DWORD dwParam1, DWORD dwParam2)
|
|
|
|
{
|
2006-10-09 21:23:23 +02:00
|
|
|
FIXME("(%p %08x %08x) stub!\n", wom, dwParam1, dwParam2);
|
2005-04-12 12:14:57 +02:00
|
|
|
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
/**************************************************************************
|
2002-07-19 02:30:16 +02:00
|
|
|
* wodMessage (MSACM.@)
|
1999-10-31 03:23:49 +01:00
|
|
|
*/
|
2009-02-17 22:04:58 +01:00
|
|
|
DWORD WINAPI WAVEMAP_wodMessage(UINT wDevID, UINT wMsg, DWORD_PTR dwUser,
|
|
|
|
DWORD_PTR dwParam1, DWORD_PTR dwParam2)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2009-02-17 22:04:58 +01:00
|
|
|
TRACE("(%u, %04X, %08lX, %08lX, %08lX);\n",
|
1999-10-31 03:23:49 +01:00
|
|
|
wDevID, wMsg, dwUser, dwParam1, dwParam2);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
switch (wMsg) {
|
|
|
|
case DRVM_INIT:
|
|
|
|
case DRVM_EXIT:
|
|
|
|
case DRVM_ENABLE:
|
|
|
|
case DRVM_DISABLE:
|
|
|
|
/* FIXME: Pretend this is supported */
|
|
|
|
return 0;
|
2009-05-20 17:52:49 +02:00
|
|
|
case WODM_OPEN: return wodOpen ((DWORD_PTR*)dwUser, (LPWAVEOPENDESC)dwParam1,dwParam2);
|
1999-10-31 03:23:49 +01:00
|
|
|
case WODM_CLOSE: return wodClose ((WAVEMAPDATA*)dwUser);
|
|
|
|
case WODM_WRITE: return wodWrite ((WAVEMAPDATA*)dwUser, (LPWAVEHDR)dwParam1, dwParam2);
|
|
|
|
case WODM_PAUSE: return wodPause ((WAVEMAPDATA*)dwUser);
|
|
|
|
case WODM_GETPOS: return wodGetPosition ((WAVEMAPDATA*)dwUser, (LPMMTIME)dwParam1, dwParam2);
|
2000-01-04 01:25:57 +01:00
|
|
|
case WODM_BREAKLOOP: return wodBreakLoop ((WAVEMAPDATA*)dwUser);
|
1999-10-31 03:23:49 +01:00
|
|
|
case WODM_PREPARE: return wodPrepare ((WAVEMAPDATA*)dwUser, (LPWAVEHDR)dwParam1, dwParam2);
|
|
|
|
case WODM_UNPREPARE: return wodUnprepare ((WAVEMAPDATA*)dwUser, (LPWAVEHDR)dwParam1, dwParam2);
|
2004-12-06 21:55:25 +01:00
|
|
|
case WODM_GETDEVCAPS: return wodGetDevCaps (wDevID, (WAVEMAPDATA*)dwUser, (LPWAVEOUTCAPSW)dwParam1,dwParam2);
|
1999-10-31 03:23:49 +01:00
|
|
|
case WODM_GETNUMDEVS: return 1;
|
|
|
|
case WODM_GETPITCH: return MMSYSERR_NOTSUPPORTED;
|
|
|
|
case WODM_SETPITCH: return MMSYSERR_NOTSUPPORTED;
|
|
|
|
case WODM_GETPLAYBACKRATE: return MMSYSERR_NOTSUPPORTED;
|
|
|
|
case WODM_SETPLAYBACKRATE: return MMSYSERR_NOTSUPPORTED;
|
1999-11-21 01:51:05 +01:00
|
|
|
case WODM_GETVOLUME: return wodGetVolume (wDevID, (WAVEMAPDATA*)dwUser, (LPDWORD)dwParam1);
|
|
|
|
case WODM_SETVOLUME: return wodSetVolume (wDevID, (WAVEMAPDATA*)dwUser, dwParam1);
|
1999-10-31 03:23:49 +01:00
|
|
|
case WODM_RESTART: return wodRestart ((WAVEMAPDATA*)dwUser);
|
|
|
|
case WODM_RESET: return wodReset ((WAVEMAPDATA*)dwUser);
|
2001-01-03 22:33:17 +01:00
|
|
|
case WODM_MAPPER_STATUS: return wodMapperStatus ((WAVEMAPDATA*)dwUser, dwParam1, (LPVOID)dwParam2);
|
2005-04-12 12:14:57 +02:00
|
|
|
case DRVM_MAPPER_RECONFIGURE: return wodMapperReconfigure((WAVEMAPDATA*)dwUser, dwParam1, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
/* known but not supported */
|
|
|
|
case DRV_QUERYDEVICEINTERFACESIZE:
|
|
|
|
case DRV_QUERYDEVICEINTERFACE:
|
|
|
|
return MMSYSERR_NOTSUPPORTED;
|
1999-10-31 03:23:49 +01:00
|
|
|
default:
|
|
|
|
FIXME("unknown message %d!\n", wMsg);
|
|
|
|
}
|
|
|
|
return MMSYSERR_NOTSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*======================================================================*
|
|
|
|
* WAVE IN part *
|
|
|
|
*======================================================================*/
|
|
|
|
|
2009-02-17 22:04:58 +01:00
|
|
|
static void CALLBACK widCallback(HWAVEIN hWave, UINT uMsg, DWORD_PTR dwInstance,
|
|
|
|
DWORD_PTR dwParam1, DWORD_PTR dwParam2)
|
2001-04-14 00:28:06 +02:00
|
|
|
{
|
2009-02-17 22:04:58 +01:00
|
|
|
WAVEMAPDATA* wim = (WAVEMAPDATA*)dwInstance;
|
2001-04-14 00:28:06 +02:00
|
|
|
|
2009-02-17 22:04:58 +01:00
|
|
|
TRACE("(%p %u %lx %lx %lx);\n", hWave, uMsg, dwInstance, dwParam1, dwParam2);
|
2001-04-14 00:28:06 +02:00
|
|
|
|
|
|
|
if (!WAVEMAP_IsData(wim)) {
|
2001-11-13 22:58:32 +01:00
|
|
|
ERR("Bad data\n");
|
2001-04-14 00:28:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-21 17:05:15 +02:00
|
|
|
if (uMsg != WIM_OPEN && hWave != wim->u.in.hInnerWave)
|
2002-10-30 21:25:38 +01:00
|
|
|
ERR("Shouldn't happen (%p %p)\n", hWave, wim->u.in.hInnerWave);
|
2001-04-14 00:28:06 +02:00
|
|
|
|
|
|
|
switch (uMsg) {
|
|
|
|
case WIM_OPEN:
|
|
|
|
case WIM_CLOSE:
|
|
|
|
/* dwParam1 & dwParam2 are supposed to be 0, nothing to do */
|
|
|
|
break;
|
|
|
|
case WIM_DATA:
|
|
|
|
if (wim->hAcmStream) {
|
|
|
|
LPWAVEHDR lpWaveHdrSrc = (LPWAVEHDR)dwParam1;
|
|
|
|
PACMSTREAMHEADER ash = (PACMSTREAMHEADER)((LPSTR)lpWaveHdrSrc - sizeof(ACMSTREAMHEADER));
|
|
|
|
LPWAVEHDR lpWaveHdrDst = (LPWAVEHDR)ash->dwUser;
|
|
|
|
|
|
|
|
/* convert data just gotten from waveIn into requested format */
|
|
|
|
if (acmStreamConvert(wim->hAcmStream, ash, 0L) != MMSYSERR_NOERROR) {
|
|
|
|
ERR("ACM conversion failed\n");
|
|
|
|
return;
|
|
|
|
} else {
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("Converted %d bytes into %d\n", ash->cbSrcLengthUsed, ash->cbDstLengthUsed);
|
2001-04-14 00:28:06 +02:00
|
|
|
}
|
|
|
|
/* and setup the wavehdr to return accordingly */
|
|
|
|
lpWaveHdrDst->dwFlags &= ~WHDR_INQUEUE;
|
|
|
|
lpWaveHdrDst->dwFlags |= WHDR_DONE;
|
|
|
|
lpWaveHdrDst->dwBytesRecorded = ash->cbDstLengthUsed;
|
2009-02-17 22:04:58 +01:00
|
|
|
dwParam1 = (DWORD_PTR)lpWaveHdrDst;
|
2001-04-14 00:28:06 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown msg %u\n", uMsg);
|
|
|
|
}
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
DriverCallback(wim->dwCallback, HIWORD(wim->dwFlags), (HDRVR)wim->u.in.hOuterWave,
|
2002-08-09 03:02:25 +02:00
|
|
|
uMsg, wim->dwClientInstance, dwParam1, dwParam2);
|
2001-04-14 00:28:06 +02:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static DWORD widOpenHelper(WAVEMAPDATA* wim, UINT idx,
|
|
|
|
LPWAVEOPENDESC lpDesc, LPWAVEFORMATEX lpwfx,
|
2001-04-14 00:28:06 +02:00
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %04x %p %p %08x)\n", wim, idx, lpDesc, lpwfx, dwFlags);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
/* source is always PCM, so the formulas below apply */
|
|
|
|
lpwfx->nBlockAlign = (lpwfx->nChannels * lpwfx->wBitsPerSample) / 8;
|
|
|
|
lpwfx->nAvgBytesPerSec = lpwfx->nSamplesPerSec * lpwfx->nBlockAlign;
|
2001-05-21 20:32:17 +02:00
|
|
|
if (dwFlags & WAVE_FORMAT_QUERY) {
|
|
|
|
ret = acmStreamOpen(NULL, 0, lpwfx, lpDesc->lpFormat, NULL, 0L, 0L, ACM_STREAMOPENF_QUERY);
|
|
|
|
} else {
|
|
|
|
ret = acmStreamOpen(&wim->hAcmStream, 0, lpwfx, lpDesc->lpFormat, NULL, 0L, 0L, 0L);
|
|
|
|
}
|
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
2009-02-17 22:04:58 +01:00
|
|
|
ret = waveInOpen(&wim->u.in.hInnerWave, idx, lpwfx,
|
|
|
|
(DWORD_PTR)widCallback, (DWORD_PTR)wim,
|
|
|
|
(dwFlags & ~CALLBACK_TYPEMASK) | CALLBACK_FUNCTION);
|
2001-05-21 20:32:17 +02:00
|
|
|
if (ret != MMSYSERR_NOERROR && !(dwFlags & WAVE_FORMAT_QUERY)) {
|
|
|
|
acmStreamClose(wim->hAcmStream, 0);
|
|
|
|
wim->hAcmStream = 0;
|
|
|
|
}
|
|
|
|
}
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("ret = %08x\n", ret);
|
2001-05-21 20:32:17 +02:00
|
|
|
return ret;
|
2001-04-14 00:28:06 +02:00
|
|
|
}
|
|
|
|
|
2009-05-20 17:52:49 +02:00
|
|
|
static DWORD widOpen(DWORD_PTR *lpdwUser, LPWAVEOPENDESC lpDesc, DWORD dwFlags)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2001-11-13 22:58:32 +01:00
|
|
|
UINT ndlo, ndhi;
|
1999-10-31 03:23:49 +01:00
|
|
|
UINT i;
|
|
|
|
WAVEMAPDATA* wim = HeapAlloc(GetProcessHeap(), 0, sizeof(WAVEMAPDATA));
|
2004-06-01 21:41:18 +02:00
|
|
|
DWORD res;
|
1999-10-31 03:23:49 +01:00
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %p %08x)\n", lpdwUser, lpDesc, dwFlags);
|
1999-10-31 03:23:49 +01:00
|
|
|
|
2004-06-14 19:55:03 +02:00
|
|
|
if (!wim) {
|
|
|
|
WARN("no memory\n");
|
2001-04-14 00:28:06 +02:00
|
|
|
return MMSYSERR_NOMEM;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
1999-11-21 01:51:05 +01:00
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
wim->self = wim;
|
|
|
|
wim->dwCallback = lpDesc->dwCallback;
|
|
|
|
wim->dwFlags = dwFlags;
|
|
|
|
wim->dwClientInstance = lpDesc->dwInstance;
|
2002-10-30 21:25:38 +01:00
|
|
|
wim->u.in.hOuterWave = (HWAVEIN)lpDesc->hWave;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-02-15 01:00:12 +01:00
|
|
|
ndhi = waveInGetNumDevs();
|
2001-11-13 22:58:32 +01:00
|
|
|
if (dwFlags & WAVE_MAPPED) {
|
|
|
|
if (lpDesc->uMappedDeviceID >= ndhi) return MMSYSERR_INVALPARAM;
|
|
|
|
ndlo = lpDesc->uMappedDeviceID;
|
|
|
|
ndhi = ndlo + 1;
|
|
|
|
dwFlags &= ~WAVE_MAPPED;
|
|
|
|
} else {
|
|
|
|
ndlo = 0;
|
|
|
|
}
|
|
|
|
|
2002-10-31 01:54:27 +01:00
|
|
|
wim->avgSpeedOuter = wim->avgSpeedInner = lpDesc->lpFormat->nAvgBytesPerSec;
|
2005-02-23 13:42:32 +01:00
|
|
|
wim->nSamplesPerSecOuter = wim->nSamplesPerSecInner = lpDesc->lpFormat->nSamplesPerSec;
|
2002-10-31 01:54:27 +01:00
|
|
|
|
2001-11-13 22:58:32 +01:00
|
|
|
for (i = ndlo; i < ndhi; i++) {
|
2009-02-17 22:04:58 +01:00
|
|
|
if (waveInOpen(&wim->u.in.hInnerWave, i, lpDesc->lpFormat,
|
|
|
|
(DWORD_PTR)widCallback, (DWORD_PTR)wim,
|
|
|
|
(dwFlags & ~CALLBACK_TYPEMASK) | CALLBACK_FUNCTION | WAVE_FORMAT_DIRECT) == MMSYSERR_NOERROR) {
|
2001-04-14 00:28:06 +02:00
|
|
|
wim->hAcmStream = 0;
|
|
|
|
goto found;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
}
|
2001-04-14 00:28:06 +02:00
|
|
|
|
2002-10-07 20:22:57 +02:00
|
|
|
if ((dwFlags & WAVE_FORMAT_DIRECT) == 0)
|
|
|
|
{
|
|
|
|
WAVEFORMATEX wfx;
|
2001-04-14 00:28:06 +02:00
|
|
|
|
2002-10-07 20:22:57 +02:00
|
|
|
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
wfx.cbSize = 0; /* normally, this field is not used for PCM format, just in case */
|
|
|
|
/* try some ACM stuff */
|
2004-06-04 19:57:40 +02:00
|
|
|
|
2002-10-07 20:22:57 +02:00
|
|
|
#define TRY(sps,bps) wfx.nSamplesPerSec = (sps); wfx.wBitsPerSample = (bps); \
|
2004-06-01 21:41:18 +02:00
|
|
|
switch (res=widOpenHelper(wim, i, lpDesc, &wfx, dwFlags | WAVE_FORMAT_DIRECT)) { \
|
2005-02-23 13:42:32 +01:00
|
|
|
case MMSYSERR_NOERROR: wim->avgSpeedInner = wfx.nAvgBytesPerSec; wim->nSamplesPerSecInner = wfx.nSamplesPerSec; goto found; \
|
2003-05-11 05:30:51 +02:00
|
|
|
case WAVERR_BADFORMAT: break; \
|
|
|
|
default: goto error; \
|
|
|
|
}
|
2004-06-04 19:57:40 +02:00
|
|
|
|
2002-10-07 20:22:57 +02:00
|
|
|
for (i = ndlo; i < ndhi; i++) {
|
2003-02-15 01:00:12 +01:00
|
|
|
wfx.nSamplesPerSec=lpDesc->lpFormat->nSamplesPerSec;
|
|
|
|
/* first try with same stereo/mono option as source */
|
|
|
|
wfx.nChannels = lpDesc->lpFormat->nChannels;
|
|
|
|
TRY(wfx.nSamplesPerSec, 16);
|
|
|
|
TRY(wfx.nSamplesPerSec, 8);
|
|
|
|
wfx.nChannels ^= 3;
|
|
|
|
TRY(wfx.nSamplesPerSec, 16);
|
|
|
|
TRY(wfx.nSamplesPerSec, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = ndlo; i < ndhi; i++) {
|
|
|
|
wfx.nSamplesPerSec=lpDesc->lpFormat->nSamplesPerSec;
|
|
|
|
/* first try with same stereo/mono option as source */
|
|
|
|
wfx.nChannels = lpDesc->lpFormat->nChannels;
|
|
|
|
TRY(96000, 16);
|
|
|
|
TRY(48000, 16);
|
|
|
|
TRY(44100, 16);
|
|
|
|
TRY(22050, 16);
|
|
|
|
TRY(11025, 16);
|
2004-06-04 19:57:40 +02:00
|
|
|
|
2003-02-15 01:00:12 +01:00
|
|
|
/* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */
|
|
|
|
wfx.nChannels ^= 3;
|
|
|
|
TRY(96000, 16);
|
|
|
|
TRY(48000, 16);
|
|
|
|
TRY(44100, 16);
|
|
|
|
TRY(22050, 16);
|
|
|
|
TRY(11025, 16);
|
|
|
|
|
2002-10-07 20:22:57 +02:00
|
|
|
/* first try with same stereo/mono option as source */
|
|
|
|
wfx.nChannels = lpDesc->lpFormat->nChannels;
|
2003-02-15 01:00:12 +01:00
|
|
|
TRY(96000, 8);
|
|
|
|
TRY(48000, 8);
|
2002-10-07 20:22:57 +02:00
|
|
|
TRY(44100, 8);
|
|
|
|
TRY(22050, 8);
|
|
|
|
TRY(11025, 8);
|
2004-06-04 19:57:40 +02:00
|
|
|
|
2002-10-07 20:22:57 +02:00
|
|
|
/* 2^3 => 1, 1^3 => 2, so if stereo, try mono (and the other way around) */
|
|
|
|
wfx.nChannels ^= 3;
|
2003-02-15 01:00:12 +01:00
|
|
|
TRY(96000, 8);
|
|
|
|
TRY(48000, 8);
|
2002-10-07 20:22:57 +02:00
|
|
|
TRY(44100, 8);
|
|
|
|
TRY(22050, 8);
|
|
|
|
TRY(11025, 8);
|
|
|
|
}
|
2001-04-14 00:28:06 +02:00
|
|
|
#undef TRY
|
2002-10-07 20:22:57 +02:00
|
|
|
}
|
2001-04-14 00:28:06 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, wim);
|
2004-06-14 19:55:03 +02:00
|
|
|
WARN("ret = WAVERR_BADFORMAT\n");
|
2003-03-10 20:03:08 +01:00
|
|
|
return WAVERR_BADFORMAT;
|
2001-04-14 00:28:06 +02:00
|
|
|
found:
|
|
|
|
if (dwFlags & WAVE_FORMAT_QUERY) {
|
|
|
|
*lpdwUser = 0L;
|
|
|
|
HeapFree(GetProcessHeap(), 0, wim);
|
|
|
|
} else {
|
2009-02-17 22:04:58 +01:00
|
|
|
*lpdwUser = (DWORD_PTR)wim;
|
2015-10-24 10:55:18 +02:00
|
|
|
TRACE("Ok (stream=%p)\n", wim->hAcmStream);
|
2001-04-14 00:28:06 +02:00
|
|
|
}
|
|
|
|
return MMSYSERR_NOERROR;
|
2003-05-11 05:30:51 +02:00
|
|
|
error:
|
|
|
|
HeapFree(GetProcessHeap(), 0, wim);
|
2004-06-01 21:41:18 +02:00
|
|
|
if (res==ACMERR_NOTPOSSIBLE) {
|
|
|
|
WARN("ret = WAVERR_BADFORMAT\n");
|
|
|
|
return WAVERR_BADFORMAT;
|
|
|
|
}
|
2006-10-09 21:23:23 +02:00
|
|
|
WARN("ret = 0x%08x\n", res);
|
2004-12-20 18:09:12 +01:00
|
|
|
return res;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD widClose(WAVEMAPDATA* wim)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", wim);
|
2001-04-14 00:28:06 +02:00
|
|
|
|
2004-06-14 19:55:03 +02:00
|
|
|
ret = waveInClose(wim->u.in.hInnerWave);
|
2001-04-14 00:28:06 +02:00
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
if (wim->hAcmStream) {
|
|
|
|
ret = acmStreamClose(wim->hAcmStream, 0);
|
|
|
|
}
|
|
|
|
if (ret == MMSYSERR_NOERROR) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, wim);
|
|
|
|
}
|
|
|
|
}
|
1999-10-31 03:23:49 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
static DWORD widAddBuffer(WAVEMAPDATA* wim, LPWAVEHDR lpWaveHdrDst, DWORD dwParam2)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2001-04-14 00:28:06 +02:00
|
|
|
PACMSTREAMHEADER ash;
|
|
|
|
LPWAVEHDR lpWaveHdrSrc;
|
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %p %08x)\n", wim, lpWaveHdrDst, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
if (!wim->hAcmStream) {
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveInAddBuffer(wim->u.in.hInnerWave, lpWaveHdrDst, dwParam2);
|
2001-04-14 00:28:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
lpWaveHdrDst->dwFlags |= WHDR_INQUEUE;
|
|
|
|
ash = (PACMSTREAMHEADER)lpWaveHdrDst->reserved;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
lpWaveHdrSrc = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER));
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveInAddBuffer(wim->u.in.hInnerWave, lpWaveHdrSrc, sizeof(*lpWaveHdrSrc));
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
static DWORD widPrepare(WAVEMAPDATA* wim, LPWAVEHDR lpWaveHdrDst, DWORD dwParam2)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2001-04-14 00:28:06 +02:00
|
|
|
PACMSTREAMHEADER ash;
|
|
|
|
DWORD size;
|
|
|
|
DWORD dwRet;
|
|
|
|
LPWAVEHDR lpWaveHdrSrc;
|
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %p %08x)\n", wim, lpWaveHdrDst, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
if (!wim->hAcmStream) {
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveInPrepareHeader(wim->u.in.hInnerWave, lpWaveHdrDst, dwParam2);
|
2001-04-14 00:28:06 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if (acmStreamSize(wim->hAcmStream, lpWaveHdrDst->dwBufferLength, &size,
|
2004-06-14 19:55:03 +02:00
|
|
|
ACM_STREAMSIZEF_DESTINATION) != MMSYSERR_NOERROR) {
|
|
|
|
WARN("acmStreamSize failed\n");
|
2001-04-14 00:28:06 +02:00
|
|
|
return MMSYSERR_ERROR;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
2001-04-14 00:28:06 +02:00
|
|
|
|
|
|
|
ash = HeapAlloc(GetProcessHeap(), 0, sizeof(ACMSTREAMHEADER) + sizeof(WAVEHDR) + size);
|
2004-06-14 19:55:03 +02:00
|
|
|
if (ash == NULL) {
|
|
|
|
WARN("no memory\n");
|
2001-04-14 00:28:06 +02:00
|
|
|
return MMSYSERR_NOMEM;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
2001-04-14 00:28:06 +02:00
|
|
|
|
|
|
|
ash->cbStruct = sizeof(*ash);
|
|
|
|
ash->fdwStatus = 0L;
|
2009-02-17 22:04:58 +01:00
|
|
|
ash->dwUser = (DWORD_PTR)lpWaveHdrDst;
|
2005-09-02 14:26:21 +02:00
|
|
|
ash->pbSrc = (LPBYTE)ash + sizeof(ACMSTREAMHEADER) + sizeof(WAVEHDR);
|
2001-04-14 00:28:06 +02:00
|
|
|
ash->cbSrcLength = size;
|
|
|
|
/* ash->cbSrcLengthUsed */
|
|
|
|
ash->dwSrcUser = 0L; /* FIXME ? */
|
2005-09-02 14:26:21 +02:00
|
|
|
ash->pbDst = (LPBYTE)lpWaveHdrDst->lpData;
|
2001-04-14 00:28:06 +02:00
|
|
|
ash->cbDstLength = lpWaveHdrDst->dwBufferLength;
|
|
|
|
/* ash->cbDstLengthUsed */
|
|
|
|
ash->dwDstUser = lpWaveHdrDst->dwUser; /* FIXME ? */
|
|
|
|
dwRet = acmStreamPrepareHeader(wim->hAcmStream, ash, 0L);
|
2004-06-14 19:55:03 +02:00
|
|
|
if (dwRet != MMSYSERR_NOERROR) {
|
|
|
|
WARN("acmStreamPrepareHeader failed\n");
|
2001-04-14 00:28:06 +02:00
|
|
|
goto errCleanUp;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
2001-04-14 00:28:06 +02:00
|
|
|
|
|
|
|
lpWaveHdrSrc = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER));
|
2005-09-02 14:26:21 +02:00
|
|
|
lpWaveHdrSrc->lpData = (LPSTR)ash->pbSrc;
|
2001-04-14 00:28:06 +02:00
|
|
|
lpWaveHdrSrc->dwBufferLength = size; /* conversion is not done yet */
|
|
|
|
lpWaveHdrSrc->dwFlags = 0;
|
|
|
|
lpWaveHdrSrc->dwLoops = 0;
|
2002-10-30 21:25:38 +01:00
|
|
|
dwRet = waveInPrepareHeader(wim->u.in.hInnerWave, lpWaveHdrSrc, sizeof(*lpWaveHdrSrc));
|
2004-06-14 19:55:03 +02:00
|
|
|
if (dwRet != MMSYSERR_NOERROR) {
|
|
|
|
WARN("waveInPrepareHeader failed\n");
|
2001-04-14 00:28:06 +02:00
|
|
|
goto errCleanUp;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
2001-04-14 00:28:06 +02:00
|
|
|
|
2009-02-17 22:04:58 +01:00
|
|
|
lpWaveHdrDst->reserved = (DWORD_PTR)ash;
|
2001-04-14 00:28:06 +02:00
|
|
|
lpWaveHdrDst->dwFlags = WHDR_PREPARED;
|
|
|
|
TRACE("=> (0)\n");
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
errCleanUp:
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("=> (%d)\n", dwRet);
|
2001-04-14 00:28:06 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, ash);
|
|
|
|
return dwRet;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
static DWORD widUnprepare(WAVEMAPDATA* wim, LPWAVEHDR lpWaveHdrDst, DWORD dwParam2)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2001-04-14 00:28:06 +02:00
|
|
|
PACMSTREAMHEADER ash;
|
|
|
|
LPWAVEHDR lpWaveHdrSrc;
|
|
|
|
DWORD dwRet1, dwRet2;
|
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %p %08x)\n", wim, lpWaveHdrDst, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
if (!wim->hAcmStream) {
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveInUnprepareHeader(wim->u.in.hInnerWave, lpWaveHdrDst, dwParam2);
|
2001-04-14 00:28:06 +02:00
|
|
|
}
|
|
|
|
ash = (PACMSTREAMHEADER)lpWaveHdrDst->reserved;
|
|
|
|
dwRet1 = acmStreamUnprepareHeader(wim->hAcmStream, ash, 0L);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
lpWaveHdrSrc = (LPWAVEHDR)((LPSTR)ash + sizeof(ACMSTREAMHEADER));
|
2002-10-30 21:25:38 +01:00
|
|
|
dwRet2 = waveInUnprepareHeader(wim->u.in.hInnerWave, lpWaveHdrSrc, sizeof(*lpWaveHdrSrc));
|
2001-04-14 00:28:06 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, ash);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-04-14 00:28:06 +02:00
|
|
|
lpWaveHdrDst->dwFlags &= ~WHDR_PREPARED;
|
|
|
|
return (dwRet1 == MMSYSERR_NOERROR) ? dwRet2 : dwRet1;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD widGetPosition(WAVEMAPDATA* wim, LPMMTIME lpTime, DWORD dwParam2)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
DWORD val;
|
2005-04-11 14:49:04 +02:00
|
|
|
MMTIME timepos;
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %p %08x)\n", wim, lpTime, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
2008-03-05 22:34:59 +01:00
|
|
|
timepos = *lpTime;
|
2005-04-11 14:49:04 +02:00
|
|
|
|
|
|
|
/* For TIME_MS, we're going to recalculate using TIME_BYTES */
|
|
|
|
if (lpTime->wType == TIME_MS)
|
|
|
|
timepos.wType = TIME_BYTES;
|
|
|
|
|
|
|
|
/* This can change timepos.wType if the requested type is not supported */
|
|
|
|
val = waveInGetPosition(wim->u.in.hInnerWave, &timepos, dwParam2);
|
|
|
|
|
|
|
|
if (timepos.wType == TIME_BYTES)
|
|
|
|
{
|
|
|
|
DWORD dwInnerSamplesPerOuter = wim->nSamplesPerSecInner / wim->nSamplesPerSecOuter;
|
|
|
|
if (dwInnerSamplesPerOuter > 0)
|
|
|
|
{
|
|
|
|
DWORD dwInnerBytesPerSample = wim->avgSpeedInner / wim->nSamplesPerSecInner;
|
|
|
|
DWORD dwInnerBytesPerOuterSample = dwInnerBytesPerSample * dwInnerSamplesPerOuter;
|
|
|
|
DWORD remainder = 0;
|
|
|
|
|
|
|
|
/* If we are up sampling (going from lower sample rate to higher),
|
2006-02-24 16:11:36 +01:00
|
|
|
** we need to make a special accommodation for times when we've
|
2005-04-11 14:49:04 +02:00
|
|
|
** written a partial output sample. This happens frequently
|
|
|
|
** to us because we use msacm to do our up sampling, and it
|
|
|
|
** will up sample on an unaligned basis.
|
|
|
|
** For example, if you convert a 2 byte wide 8,000 'outer'
|
|
|
|
** buffer to a 2 byte wide 48,000 inner device, you would
|
|
|
|
** expect 2 bytes of input to produce 12 bytes of output.
|
|
|
|
** Instead, msacm will produce 8 bytes of output.
|
|
|
|
** But reporting our position as 1 byte of output is
|
|
|
|
** nonsensical; the output buffer position needs to be
|
|
|
|
** aligned on outer sample size, and aggressively rounded up.
|
|
|
|
*/
|
|
|
|
remainder = timepos.u.cb % dwInnerBytesPerOuterSample;
|
|
|
|
if (remainder > 0)
|
|
|
|
{
|
|
|
|
timepos.u.cb -= remainder;
|
|
|
|
timepos.u.cb += dwInnerBytesPerOuterSample;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lpTime->u.cb = MulDiv(timepos.u.cb, wim->avgSpeedOuter, wim->avgSpeedInner);
|
|
|
|
|
|
|
|
/* Once we have the TIME_BYTES right, we can easily convert to TIME_MS */
|
|
|
|
if (lpTime->wType == TIME_MS)
|
|
|
|
lpTime->u.ms = MulDiv(lpTime->u.cb, 1000, wim->avgSpeedOuter);
|
|
|
|
else
|
|
|
|
lpTime->wType = TIME_BYTES;
|
|
|
|
}
|
|
|
|
else if (lpTime->wType == TIME_SAMPLES && timepos.wType == TIME_SAMPLES)
|
|
|
|
lpTime->u.sample = MulDiv(timepos.u.sample, wim->nSamplesPerSecOuter, wim->nSamplesPerSecInner);
|
|
|
|
else
|
|
|
|
/* other time types don't require conversion */
|
|
|
|
lpTime->u = timepos.u;
|
|
|
|
|
2002-10-31 01:54:27 +01:00
|
|
|
return val;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
2004-12-06 21:55:25 +01:00
|
|
|
static DWORD widGetDevCaps(UINT wDevID, WAVEMAPDATA* wim, LPWAVEINCAPSW lpWaveCaps, DWORD dwParam2)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%04x, %p %p %08x)\n", wDevID, wim, lpWaveCaps, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
1999-11-21 01:51:05 +01:00
|
|
|
/* if opened low driver, forward message */
|
|
|
|
if (WAVEMAP_IsData(wim))
|
2009-02-17 22:04:58 +01:00
|
|
|
return waveInGetDevCapsW((UINT_PTR)wim->u.in.hInnerWave, lpWaveCaps, dwParam2);
|
2004-06-01 22:19:30 +02:00
|
|
|
/* else if no drivers, nothing to map so return bad device */
|
2004-06-14 19:55:03 +02:00
|
|
|
if (waveInGetNumDevs() == 0) {
|
|
|
|
WARN("bad device id\n");
|
2004-06-01 22:19:30 +02:00
|
|
|
return MMSYSERR_BADDEVICEID;
|
2004-06-14 19:55:03 +02:00
|
|
|
}
|
1999-11-21 01:51:05 +01:00
|
|
|
/* otherwise, return caps of mapper itself */
|
|
|
|
if (wDevID == (UINT)-1 || wDevID == (UINT16)-1) {
|
2004-12-06 21:55:25 +01:00
|
|
|
WAVEINCAPSW wic;
|
2004-06-04 19:57:40 +02:00
|
|
|
wic.wMid = 0x00FF;
|
|
|
|
wic.wPid = 0x0001;
|
|
|
|
wic.vDriverVersion = 0x0001;
|
2020-10-03 20:28:20 +02:00
|
|
|
lstrcpyW(wic.szPname, L"Wine wave in mapper");
|
2004-06-04 19:57:40 +02:00
|
|
|
wic.dwFormats =
|
2004-06-01 22:19:30 +02:00
|
|
|
WAVE_FORMAT_96M08 | WAVE_FORMAT_96S08 | WAVE_FORMAT_96M16 | WAVE_FORMAT_96S16 |
|
|
|
|
WAVE_FORMAT_48M08 | WAVE_FORMAT_48S08 | WAVE_FORMAT_48M16 | WAVE_FORMAT_48S16 |
|
1999-11-21 01:51:05 +01:00
|
|
|
WAVE_FORMAT_4M08 | WAVE_FORMAT_4S08 | WAVE_FORMAT_4M16 | WAVE_FORMAT_4S16 |
|
|
|
|
WAVE_FORMAT_2M08 | WAVE_FORMAT_2S08 | WAVE_FORMAT_2M16 | WAVE_FORMAT_2S16 |
|
2002-06-01 01:06:46 +02:00
|
|
|
WAVE_FORMAT_1M08 | WAVE_FORMAT_1S08 | WAVE_FORMAT_1M16 | WAVE_FORMAT_1S16;
|
2004-06-04 19:57:40 +02:00
|
|
|
wic.wChannels = 2;
|
2015-12-29 21:03:59 +01:00
|
|
|
wic.wReserved1 = 0;
|
2004-06-04 19:57:40 +02:00
|
|
|
memcpy(lpWaveCaps, &wic, min(dwParam2, sizeof(wic)));
|
|
|
|
|
1999-11-21 01:51:05 +01:00
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
ERR("This shouldn't happen\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
return MMSYSERR_ERROR;
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD widStop(WAVEMAPDATA* wim)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
TRACE("(%p)\n", wim);
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveInStop(wim->u.in.hInnerWave);
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD widStart(WAVEMAPDATA* wim)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
TRACE("(%p)\n", wim);
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveInStart(wim->u.in.hInnerWave);
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD widReset(WAVEMAPDATA* wim)
|
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
TRACE("(%p)\n", wim);
|
|
|
|
|
2002-10-30 21:25:38 +01:00
|
|
|
return waveInReset(wim->u.in.hInnerWave);
|
1999-10-31 03:23:49 +01:00
|
|
|
}
|
|
|
|
|
2001-01-03 22:33:17 +01:00
|
|
|
static DWORD widMapperStatus(WAVEMAPDATA* wim, DWORD flags, LPVOID ptr)
|
|
|
|
{
|
|
|
|
UINT id;
|
|
|
|
DWORD ret = MMSYSERR_NOTSUPPORTED;
|
|
|
|
|
2006-10-09 21:23:23 +02:00
|
|
|
TRACE("(%p %08x %p)\n", wim, flags, ptr);
|
2004-06-14 19:55:03 +02:00
|
|
|
|
2001-01-03 22:33:17 +01:00
|
|
|
switch (flags) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case WAVEIN_MAPPER_STATUS_DEVICE:
|
2002-10-30 21:25:38 +01:00
|
|
|
ret = waveInGetID(wim->u.in.hInnerWave, &id);
|
2001-01-03 22:33:17 +01:00
|
|
|
*(LPDWORD)ptr = id;
|
|
|
|
break;
|
|
|
|
case WAVEIN_MAPPER_STATUS_MAPPED:
|
2006-10-09 21:23:23 +02:00
|
|
|
FIXME("Unsupported yet flag=%d\n", flags);
|
2002-06-01 01:06:46 +02:00
|
|
|
*(LPDWORD)ptr = 0; /* FIXME ?? */
|
2001-01-03 22:33:17 +01:00
|
|
|
break;
|
|
|
|
case WAVEIN_MAPPER_STATUS_FORMAT:
|
2006-10-09 21:23:23 +02:00
|
|
|
FIXME("Unsupported flag=%d\n", flags);
|
2001-01-03 22:33:17 +01:00
|
|
|
/* ptr points to a WAVEFORMATEX struct - before or after streaming ? */
|
2002-06-01 01:06:46 +02:00
|
|
|
*(LPDWORD)ptr = 0; /* FIXME ?? */
|
2001-01-03 22:33:17 +01:00
|
|
|
break;
|
|
|
|
default:
|
2006-10-09 21:23:23 +02:00
|
|
|
FIXME("Unsupported flag=%d\n", flags);
|
2001-01-03 22:33:17 +01:00
|
|
|
*(LPDWORD)ptr = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-04-12 12:14:57 +02:00
|
|
|
static DWORD widMapperReconfigure(WAVEMAPDATA* wim, DWORD dwParam1, DWORD dwParam2)
|
|
|
|
{
|
2006-10-09 21:23:23 +02:00
|
|
|
FIXME("(%p %08x %08x) stub!\n", wim, dwParam1, dwParam2);
|
2005-04-12 12:14:57 +02:00
|
|
|
|
|
|
|
return MMSYSERR_NOERROR;
|
|
|
|
}
|
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
/**************************************************************************
|
2002-07-19 02:30:16 +02:00
|
|
|
* widMessage (MSACM.@)
|
1999-10-31 03:23:49 +01:00
|
|
|
*/
|
2009-02-17 22:04:58 +01:00
|
|
|
DWORD WINAPI WAVEMAP_widMessage(WORD wDevID, WORD wMsg, DWORD_PTR dwUser,
|
|
|
|
DWORD_PTR dwParam1, DWORD_PTR dwParam2)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2009-02-17 22:04:58 +01:00
|
|
|
TRACE("(%u, %04X, %08lX, %08lX, %08lX);\n",
|
1999-10-31 03:23:49 +01:00
|
|
|
wDevID, wMsg, dwUser, dwParam1, dwParam2);
|
|
|
|
|
|
|
|
switch (wMsg) {
|
|
|
|
case DRVM_INIT:
|
|
|
|
case DRVM_EXIT:
|
|
|
|
case DRVM_ENABLE:
|
|
|
|
case DRVM_DISABLE:
|
|
|
|
/* FIXME: Pretend this is supported */
|
|
|
|
return 0;
|
|
|
|
|
2009-05-20 17:52:49 +02:00
|
|
|
case WIDM_OPEN: return widOpen ((DWORD_PTR*)dwUser, (LPWAVEOPENDESC)dwParam1, dwParam2);
|
1999-10-31 03:23:49 +01:00
|
|
|
case WIDM_CLOSE: return widClose ((WAVEMAPDATA*)dwUser);
|
|
|
|
|
|
|
|
case WIDM_ADDBUFFER: return widAddBuffer ((WAVEMAPDATA*)dwUser, (LPWAVEHDR)dwParam1, dwParam2);
|
|
|
|
case WIDM_PREPARE: return widPrepare ((WAVEMAPDATA*)dwUser, (LPWAVEHDR)dwParam1, dwParam2);
|
|
|
|
case WIDM_UNPREPARE: return widUnprepare ((WAVEMAPDATA*)dwUser, (LPWAVEHDR)dwParam1, dwParam2);
|
2004-12-06 21:55:25 +01:00
|
|
|
case WIDM_GETDEVCAPS: return widGetDevCaps (wDevID, (WAVEMAPDATA*)dwUser, (LPWAVEINCAPSW)dwParam1, dwParam2);
|
1999-10-31 03:23:49 +01:00
|
|
|
case WIDM_GETNUMDEVS: return 1;
|
|
|
|
case WIDM_GETPOS: return widGetPosition ((WAVEMAPDATA*)dwUser, (LPMMTIME)dwParam1, dwParam2);
|
|
|
|
case WIDM_RESET: return widReset ((WAVEMAPDATA*)dwUser);
|
|
|
|
case WIDM_START: return widStart ((WAVEMAPDATA*)dwUser);
|
|
|
|
case WIDM_STOP: return widStop ((WAVEMAPDATA*)dwUser);
|
2001-01-03 22:33:17 +01:00
|
|
|
case WIDM_MAPPER_STATUS: return widMapperStatus ((WAVEMAPDATA*)dwUser, dwParam1, (LPVOID)dwParam2);
|
2005-04-12 12:14:57 +02:00
|
|
|
case DRVM_MAPPER_RECONFIGURE: return widMapperReconfigure((WAVEMAPDATA*)dwUser, dwParam1, dwParam2);
|
2004-06-14 19:55:03 +02:00
|
|
|
/* known but not supported */
|
|
|
|
case DRV_QUERYDEVICEINTERFACESIZE:
|
|
|
|
case DRV_QUERYDEVICEINTERFACE:
|
|
|
|
return MMSYSERR_NOTSUPPORTED;
|
1999-10-31 03:23:49 +01:00
|
|
|
default:
|
|
|
|
FIXME("unknown message %u!\n", wMsg);
|
|
|
|
}
|
|
|
|
return MMSYSERR_NOTSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*======================================================================*
|
|
|
|
* Driver part *
|
|
|
|
*======================================================================*/
|
|
|
|
|
|
|
|
static struct WINE_WAVEMAP* oss = NULL;
|
|
|
|
|
|
|
|
/**************************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* WAVEMAP_drvOpen [internal]
|
1999-10-31 03:23:49 +01:00
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static LRESULT WAVEMAP_drvOpen(LPSTR str)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
TRACE("(%p)\n", str);
|
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
if (oss)
|
|
|
|
return 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
/* I know, this is ugly, but who cares... */
|
|
|
|
oss = (struct WINE_WAVEMAP*)1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* WAVEMAP_drvClose [internal]
|
1999-10-31 03:23:49 +01:00
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static LRESULT WAVEMAP_drvClose(DWORD_PTR dwDevID)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2004-06-14 19:55:03 +02:00
|
|
|
TRACE("(%08lx)\n", dwDevID);
|
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
if (oss) {
|
|
|
|
oss = NULL;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2002-07-19 02:30:16 +02:00
|
|
|
* DriverProc (MSACM.@)
|
1999-10-31 03:23:49 +01:00
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
LRESULT CALLBACK WAVEMAP_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
|
|
|
|
LPARAM dwParam1, LPARAM dwParam2)
|
1999-10-31 03:23:49 +01:00
|
|
|
{
|
2005-11-28 20:53:22 +01:00
|
|
|
TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
|
2001-04-14 00:28:06 +02:00
|
|
|
dwDevID, hDriv, wMsg, dwParam1, dwParam2);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-10-31 03:23:49 +01:00
|
|
|
switch(wMsg) {
|
|
|
|
case DRV_LOAD: return 1;
|
|
|
|
case DRV_FREE: return 1;
|
|
|
|
case DRV_OPEN: return WAVEMAP_drvOpen((LPSTR)dwParam1);
|
|
|
|
case DRV_CLOSE: return WAVEMAP_drvClose(dwDevID);
|
|
|
|
case DRV_ENABLE: return 1;
|
|
|
|
case DRV_DISABLE: return 1;
|
|
|
|
case DRV_QUERYCONFIGURE: return 1;
|
2002-10-30 21:25:38 +01:00
|
|
|
case DRV_CONFIGURE: MessageBoxA(0, "WAVEMAP MultiMedia Driver !", "Wave mapper Driver", MB_OK); return 1;
|
1999-10-31 03:23:49 +01:00
|
|
|
case DRV_INSTALL: return DRVCNF_RESTART;
|
|
|
|
case DRV_REMOVE: return DRVCNF_RESTART;
|
|
|
|
default:
|
|
|
|
return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
|
|
|
|
}
|
|
|
|
}
|