2002-06-01 01:06:46 +02:00
|
|
|
/*
|
2009-10-31 09:11:55 +01:00
|
|
|
* Wine Driver for MCI wave forms
|
1998-11-24 17:36:18 +01:00
|
|
|
*
|
1999-09-05 18:31:37 +02:00
|
|
|
* Copyright 1994 Martin Ayotte
|
2005-12-06 21:21:48 +01:00
|
|
|
* 1999,2000,2005 Eric Pouech
|
2001-01-03 22:36:56 +01:00
|
|
|
* 2000 Francois Jacques
|
2009-11-10 08:40:55 +01:00
|
|
|
* 2009 Jörg Höhle
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-11-24 17:36:18 +01:00
|
|
|
*/
|
|
|
|
|
2009-10-20 07:34:57 +02:00
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.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-04-22 17:26:11 +02:00
|
|
|
#include "winuser.h"
|
1999-09-05 18:31:37 +02:00
|
|
|
#include "mmddk.h"
|
2002-10-17 18:43:42 +02:00
|
|
|
#include "wownt32.h"
|
2001-01-03 22:36:56 +01:00
|
|
|
#include "digitalv.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2005-02-09 23:26:25 +01:00
|
|
|
#include "wine/unicode.h"
|
1998-11-24 17:36:18 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mciwave);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
typedef struct {
|
1999-09-05 18:31:37 +02:00
|
|
|
UINT wDevID;
|
|
|
|
HANDLE hWave;
|
1998-11-24 17:36:18 +01:00
|
|
|
int nUseCount; /* Incremented for each shared open */
|
2005-12-06 21:21:48 +01:00
|
|
|
HMMIO hFile; /* mmio file handle open as Element */
|
2009-11-05 23:10:06 +01:00
|
|
|
MCIDEVICEID wNotifyDeviceID; /* MCI device ID with a pending notification */
|
2009-11-10 08:40:55 +01:00
|
|
|
HANDLE hCallback; /* Callback handle for pending notification */
|
2009-11-05 23:10:06 +01:00
|
|
|
LPWSTR lpFileName; /* Name of file (if any) */
|
2001-04-14 00:27:11 +02:00
|
|
|
WAVEFORMATEX wfxRef;
|
2009-10-18 19:04:14 +02:00
|
|
|
LPWAVEFORMATEX lpWaveFormat; /* Points to wfxRef until set by OPEN or RECORD */
|
1999-09-05 18:31:37 +02:00
|
|
|
BOOL fInput; /* FALSE = Output, TRUE = Input */
|
2000-01-09 03:38:24 +01:00
|
|
|
volatile WORD dwStatus; /* one from MCI_MODE_xxxx */
|
1998-11-24 17:36:18 +01:00
|
|
|
DWORD dwMciTimeFormat;/* One of the supported MCI_FORMAT_xxxx */
|
2000-10-20 00:36:54 +02:00
|
|
|
DWORD dwPosition; /* position in bytes in chunk */
|
1999-12-12 22:26:09 +01:00
|
|
|
HANDLE hEvent; /* for synchronization */
|
2005-07-13 13:59:15 +02:00
|
|
|
LONG dwEventCount; /* for synchronization */
|
2001-01-03 22:36:56 +01:00
|
|
|
MMCKINFO ckMainRIFF; /* main RIFF chunk */
|
|
|
|
MMCKINFO ckWaveData; /* data chunk */
|
1998-11-24 17:36:18 +01:00
|
|
|
} WINE_MCIWAVE;
|
|
|
|
|
1999-09-27 15:38:57 +02:00
|
|
|
/* ===================================================================
|
|
|
|
* ===================================================================
|
|
|
|
* FIXME: should be using the new mmThreadXXXX functions from WINMM
|
|
|
|
* instead of those
|
|
|
|
* it would require to add a wine internal flag to mmThreadCreate
|
1999-12-05 03:18:35 +01:00
|
|
|
* in order to pass a 32 bit function instead of a 16 bit one
|
1999-09-27 15:38:57 +02:00
|
|
|
* ===================================================================
|
|
|
|
* =================================================================== */
|
|
|
|
|
2009-10-17 10:08:43 +02:00
|
|
|
typedef DWORD (*async_cmd)(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt, HANDLE evt);
|
2009-10-17 10:08:37 +02:00
|
|
|
|
1999-09-27 15:38:57 +02:00
|
|
|
struct SCA {
|
2009-10-17 10:08:37 +02:00
|
|
|
async_cmd cmd;
|
2009-10-17 10:08:43 +02:00
|
|
|
HANDLE evt;
|
1999-09-27 15:38:57 +02:00
|
|
|
UINT wDevID;
|
2007-05-31 16:01:28 +02:00
|
|
|
DWORD_PTR dwParam1;
|
|
|
|
DWORD_PTR dwParam2;
|
1999-09-27 15:38:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_SCAStarter [internal]
|
|
|
|
*/
|
|
|
|
static DWORD CALLBACK MCI_SCAStarter(LPVOID arg)
|
|
|
|
{
|
|
|
|
struct SCA* sca = (struct SCA*)arg;
|
|
|
|
DWORD ret;
|
|
|
|
|
2009-10-17 10:08:37 +02:00
|
|
|
TRACE("In thread before async command (%08x,%08lx,%08lx)\n",
|
|
|
|
sca->wDevID, sca->dwParam1, sca->dwParam2);
|
2009-10-17 10:08:43 +02:00
|
|
|
ret = sca->cmd(sca->wDevID, sca->dwParam1 | MCI_WAIT, sca->dwParam2, sca->evt);
|
2009-10-17 10:08:37 +02:00
|
|
|
TRACE("In thread after async command (%08x,%08lx,%08lx)\n",
|
|
|
|
sca->wDevID, sca->dwParam1, sca->dwParam2);
|
1999-09-27 15:38:57 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, sca);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_SendCommandAsync [internal]
|
|
|
|
*/
|
2009-10-17 10:08:37 +02:00
|
|
|
static DWORD MCI_SendCommandAsync(UINT wDevID, async_cmd cmd, DWORD_PTR dwParam1,
|
2007-05-31 16:01:28 +02:00
|
|
|
DWORD_PTR dwParam2, UINT size)
|
1999-09-27 15:38:57 +02:00
|
|
|
{
|
2009-10-17 10:08:43 +02:00
|
|
|
HANDLE handles[2];
|
2001-01-29 00:10:52 +01:00
|
|
|
struct SCA* sca = HeapAlloc(GetProcessHeap(), 0, sizeof(struct SCA) + size);
|
1999-09-27 15:38:57 +02:00
|
|
|
|
|
|
|
if (sca == 0)
|
|
|
|
return MCIERR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
sca->wDevID = wDevID;
|
2009-10-17 10:08:37 +02:00
|
|
|
sca->cmd = cmd;
|
1999-09-27 15:38:57 +02:00
|
|
|
sca->dwParam1 = dwParam1;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-01-29 00:10:52 +01:00
|
|
|
if (size && dwParam2) {
|
2007-05-31 16:01:28 +02:00
|
|
|
sca->dwParam2 = (DWORD_PTR)sca + sizeof(struct SCA);
|
2002-06-01 01:06:46 +02:00
|
|
|
/* copy structure passed by program in dwParam2 to be sure
|
|
|
|
* we can still use it whatever the program does
|
1999-09-27 15:38:57 +02:00
|
|
|
*/
|
|
|
|
memcpy((LPVOID)sca->dwParam2, (LPVOID)dwParam2, size);
|
|
|
|
} else {
|
|
|
|
sca->dwParam2 = dwParam2;
|
|
|
|
}
|
|
|
|
|
2009-10-17 10:08:43 +02:00
|
|
|
if ((sca->evt = handles[1] = CreateEventW(NULL, FALSE, FALSE, NULL)) == NULL ||
|
|
|
|
(handles[0] = CreateThread(NULL, 0, MCI_SCAStarter, sca, 0, NULL)) == 0) {
|
2006-08-06 12:28:32 +02:00
|
|
|
WARN("Couldn't allocate thread for async command handling, sending synchronously\n");
|
2009-10-17 10:08:43 +02:00
|
|
|
if (handles[1]) CloseHandle(handles[1]);
|
|
|
|
sca->evt = NULL;
|
1999-09-27 15:38:57 +02:00
|
|
|
return MCI_SCAStarter(&sca);
|
|
|
|
}
|
2009-10-17 10:08:43 +02:00
|
|
|
|
|
|
|
SetThreadPriority(handles[0], THREAD_PRIORITY_TIME_CRITICAL);
|
|
|
|
/* wait until either:
|
|
|
|
* - the thread has finished (handles[0], likely an error)
|
|
|
|
* - init phase of async command is done (handles[1])
|
|
|
|
*/
|
|
|
|
WaitForMultipleObjects(2, handles, FALSE, INFINITE);
|
|
|
|
CloseHandle(handles[0]);
|
|
|
|
CloseHandle(handles[1]);
|
1999-09-27 15:38:57 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
/*======================================================================*
|
2006-08-06 12:28:32 +02:00
|
|
|
* MCI WAVE implementation *
|
1998-11-24 17:36:18 +01:00
|
|
|
*======================================================================*/
|
|
|
|
|
1999-09-05 18:31:37 +02:00
|
|
|
static DWORD WAVE_mciResume(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms);
|
1999-05-24 10:18:53 +02:00
|
|
|
|
1999-05-02 12:21:49 +02:00
|
|
|
/**************************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* MCIWAVE_drvOpen [internal]
|
1999-05-02 12:21:49 +02:00
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static LRESULT WAVE_drvOpen(LPCWSTR str, LPMCI_OPEN_DRIVER_PARMSW modp)
|
1999-05-02 12:21:49 +02:00
|
|
|
{
|
2002-05-12 01:02:55 +02:00
|
|
|
WINE_MCIWAVE* wmw;
|
|
|
|
|
|
|
|
if (modp == NULL) return 0xFFFFFFFF;
|
|
|
|
|
|
|
|
wmw = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINE_MCIWAVE));
|
1999-05-02 12:21:49 +02:00
|
|
|
|
1999-07-15 16:36:15 +02:00
|
|
|
if (!wmw)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
wmw->wDevID = modp->wDeviceID;
|
2007-05-31 16:01:28 +02:00
|
|
|
mciSetDriverData(wmw->wDevID, (DWORD_PTR)wmw);
|
1999-07-24 12:45:24 +02:00
|
|
|
modp->wCustomCommandTable = MCI_NO_COMMAND_TABLE;
|
1999-07-15 16:36:15 +02:00
|
|
|
modp->wType = MCI_DEVTYPE_WAVEFORM_AUDIO;
|
2001-04-14 00:27:11 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
wmw->wfxRef.wFormatTag = WAVE_FORMAT_PCM;
|
2001-04-14 00:27:11 +02:00
|
|
|
wmw->wfxRef.nChannels = 1; /* MONO */
|
|
|
|
wmw->wfxRef.nSamplesPerSec = 11025;
|
|
|
|
wmw->wfxRef.nAvgBytesPerSec = 11025;
|
2002-06-01 01:06:46 +02:00
|
|
|
wmw->wfxRef.nBlockAlign = 1;
|
2001-04-14 00:27:11 +02:00
|
|
|
wmw->wfxRef.wBitsPerSample = 8;
|
|
|
|
wmw->wfxRef.cbSize = 0; /* don't care */
|
|
|
|
|
1999-07-15 16:36:15 +02:00
|
|
|
return modp->wDeviceID;
|
1999-05-02 12:21:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* MCIWAVE_drvClose [internal]
|
1999-05-02 12:21:49 +02:00
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static LRESULT WAVE_drvClose(MCIDEVICEID dwDevID)
|
1999-05-02 12:21:49 +02:00
|
|
|
{
|
1999-07-15 16:36:15 +02:00
|
|
|
WINE_MCIWAVE* wmw = (WINE_MCIWAVE*)mciGetDriverData(dwDevID);
|
1999-05-02 12:21:49 +02:00
|
|
|
|
1999-07-15 16:36:15 +02:00
|
|
|
if (wmw) {
|
2002-06-01 01:06:46 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, wmw);
|
1999-07-15 16:36:15 +02:00
|
|
|
mciSetDriverData(dwDevID, 0);
|
1999-05-02 12:21:49 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2002-05-12 01:02:55 +02:00
|
|
|
return (dwDevID == 0xFFFFFFFF) ? 1 : 0;
|
1999-05-02 12:21:49 +02:00
|
|
|
}
|
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
/**************************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* WAVE_mciGetOpenDev [internal]
|
1998-11-24 17:36:18 +01:00
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static WINE_MCIWAVE *WAVE_mciGetOpenDev(MCIDEVICEID wDevID)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
1999-07-15 16:36:15 +02:00
|
|
|
WINE_MCIWAVE* wmw = (WINE_MCIWAVE*)mciGetDriverData(wDevID);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 12:21:49 +02:00
|
|
|
if (wmw == NULL || wmw->nUseCount == 0) {
|
1999-05-24 10:18:53 +02:00
|
|
|
WARN("Invalid wDevID=%u\n", wDevID);
|
1998-11-24 17:36:18 +01:00
|
|
|
return 0;
|
|
|
|
}
|
1999-05-02 12:21:49 +02:00
|
|
|
return wmw;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
|
2009-11-10 08:40:55 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciNotify [internal]
|
|
|
|
*
|
|
|
|
* Notifications in MCI work like a 1-element queue.
|
|
|
|
* Each new notification request supersedes the previous one.
|
|
|
|
* This affects Play and Record; other commands are immediate.
|
|
|
|
*/
|
|
|
|
static void WAVE_mciNotify(DWORD_PTR hWndCallBack, WINE_MCIWAVE* wmw, UINT wStatus)
|
|
|
|
{
|
2009-11-05 20:21:07 +01:00
|
|
|
/* We simply save one parameter by not passing the wDevID local
|
|
|
|
* to the command. They are the same (via mciGetDriverData).
|
|
|
|
*/
|
2009-11-05 23:10:06 +01:00
|
|
|
MCIDEVICEID wDevID = wmw->wNotifyDeviceID;
|
2009-11-10 08:40:55 +01:00
|
|
|
HANDLE old = InterlockedExchangePointer(&wmw->hCallback, NULL);
|
|
|
|
if (old) mciDriverNotify(old, wDevID, MCI_NOTIFY_SUPERSEDED);
|
|
|
|
mciDriverNotify(HWND_32(LOWORD(hWndCallBack)), wDevID, wStatus);
|
|
|
|
}
|
|
|
|
|
1999-07-24 12:45:24 +02:00
|
|
|
/**************************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* WAVE_ConvertByteToTimeFormat [internal]
|
1999-07-24 12:45:24 +02:00
|
|
|
*/
|
|
|
|
static DWORD WAVE_ConvertByteToTimeFormat(WINE_MCIWAVE* wmw, DWORD val, LPDWORD lpRet)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
2000-10-20 00:36:54 +02:00
|
|
|
DWORD ret = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
switch (wmw->dwMciTimeFormat) {
|
|
|
|
case MCI_FORMAT_MILLISECONDS:
|
2002-04-08 22:10:10 +02:00
|
|
|
ret = MulDiv(val,1000,wmw->lpWaveFormat->nAvgBytesPerSec);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_FORMAT_BYTES:
|
|
|
|
ret = val;
|
|
|
|
break;
|
2009-10-18 14:10:31 +02:00
|
|
|
case MCI_FORMAT_SAMPLES:
|
|
|
|
ret = MulDiv(val,wmw->lpWaveFormat->nSamplesPerSec,wmw->lpWaveFormat->nAvgBytesPerSec);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
default:
|
2006-10-12 21:34:28 +02:00
|
|
|
WARN("Bad time format %u!\n", wmw->dwMciTimeFormat);
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("val=%u=0x%08x [tf=%u] => ret=%u\n", val, val, wmw->dwMciTimeFormat, ret);
|
1999-07-24 12:45:24 +02:00
|
|
|
*lpRet = 0;
|
1998-11-24 17:36:18 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-07-24 12:45:24 +02:00
|
|
|
/**************************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* WAVE_ConvertTimeFormatToByte [internal]
|
1999-07-24 12:45:24 +02:00
|
|
|
*/
|
1998-11-24 17:36:18 +01:00
|
|
|
static DWORD WAVE_ConvertTimeFormatToByte(WINE_MCIWAVE* wmw, DWORD val)
|
|
|
|
{
|
|
|
|
DWORD ret = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
switch (wmw->dwMciTimeFormat) {
|
|
|
|
case MCI_FORMAT_MILLISECONDS:
|
2009-10-18 14:10:31 +02:00
|
|
|
ret = MulDiv(val,wmw->lpWaveFormat->nAvgBytesPerSec,1000);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_FORMAT_BYTES:
|
|
|
|
ret = val;
|
|
|
|
break;
|
2009-10-18 14:10:31 +02:00
|
|
|
case MCI_FORMAT_SAMPLES:
|
|
|
|
ret = MulDiv(val,wmw->lpWaveFormat->nAvgBytesPerSec,wmw->lpWaveFormat->nSamplesPerSec);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
default:
|
2006-10-12 21:34:28 +02:00
|
|
|
WARN("Bad time format %u!\n", wmw->dwMciTimeFormat);
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("val=%u=0x%08x [tf=%u] => ret=%u\n", val, val, wmw->dwMciTimeFormat, ret);
|
1998-11-24 17:36:18 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-07-24 12:45:24 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciReadFmt [internal]
|
|
|
|
*/
|
2007-05-26 18:55:33 +02:00
|
|
|
static DWORD WAVE_mciReadFmt(WINE_MCIWAVE* wmw, const MMCKINFO* pckMainRIFF)
|
1998-12-01 09:27:22 +01:00
|
|
|
{
|
|
|
|
MMCKINFO mmckInfo;
|
1999-12-05 03:18:35 +01:00
|
|
|
long r;
|
2009-10-20 07:34:57 +02:00
|
|
|
LPWAVEFORMATEX pwfx;
|
1999-12-05 03:18:35 +01:00
|
|
|
|
1998-12-01 09:27:22 +01:00
|
|
|
mmckInfo.ckid = mmioFOURCC('f', 'm', 't', ' ');
|
|
|
|
if (mmioDescend(wmw->hFile, &mmckInfo, pckMainRIFF, MMIO_FINDCHUNK) != 0)
|
|
|
|
return MCIERR_INVALID_FILE;
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08X\n",
|
1998-12-01 09:27:22 +01:00
|
|
|
(LPSTR)&mmckInfo.ckid, (LPSTR)&mmckInfo.fccType, mmckInfo.cksize);
|
1999-12-05 03:18:35 +01:00
|
|
|
|
2009-10-20 07:34:57 +02:00
|
|
|
pwfx = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
|
|
|
|
if (!pwfx) return MCIERR_OUT_OF_MEMORY;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-20 07:34:57 +02:00
|
|
|
r = mmioRead(wmw->hFile, (HPSTR)pwfx, mmckInfo.cksize);
|
|
|
|
if (r < sizeof(PCMWAVEFORMAT)) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, pwfx);
|
|
|
|
return MCIERR_INVALID_FILE;
|
|
|
|
}
|
|
|
|
TRACE("wFormatTag=%04X !\n", pwfx->wFormatTag);
|
|
|
|
TRACE("nChannels=%d\n", pwfx->nChannels);
|
|
|
|
TRACE("nSamplesPerSec=%d\n", pwfx->nSamplesPerSec);
|
|
|
|
TRACE("nAvgBytesPerSec=%d\n", pwfx->nAvgBytesPerSec);
|
|
|
|
TRACE("nBlockAlign=%d\n", pwfx->nBlockAlign);
|
|
|
|
TRACE("wBitsPerSample=%u !\n", pwfx->wBitsPerSample);
|
1999-12-05 03:18:35 +01:00
|
|
|
if (r >= (long)sizeof(WAVEFORMATEX))
|
2009-10-20 07:34:57 +02:00
|
|
|
TRACE("cbSize=%u !\n", pwfx->cbSize);
|
|
|
|
if ((pwfx->wFormatTag != WAVE_FORMAT_PCM)
|
|
|
|
&& (r < sizeof(WAVEFORMATEX) || (r < sizeof(WAVEFORMATEX) + pwfx->cbSize))) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, pwfx);
|
|
|
|
return MCIERR_INVALID_FILE;
|
|
|
|
}
|
|
|
|
wmw->lpWaveFormat = pwfx;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-12-05 03:18:35 +01:00
|
|
|
mmioAscend(wmw->hFile, &mmckInfo, 0);
|
2000-10-20 00:36:54 +02:00
|
|
|
wmw->ckWaveData.ckid = mmioFOURCC('d', 'a', 't', 'a');
|
|
|
|
if (mmioDescend(wmw->hFile, &wmw->ckWaveData, pckMainRIFF, MMIO_FINDCHUNK) != 0) {
|
1999-07-15 16:36:15 +02:00
|
|
|
TRACE("can't find data chunk\n");
|
1998-12-01 09:27:22 +01:00
|
|
|
return MCIERR_INVALID_FILE;
|
1999-07-15 16:36:15 +02:00
|
|
|
}
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("Chunk Found ckid=%.4s fccType=%.4s cksize=%08X\n",
|
2000-10-20 00:36:54 +02:00
|
|
|
(LPSTR)&wmw->ckWaveData.ckid, (LPSTR)&wmw->ckWaveData.fccType, wmw->ckWaveData.cksize);
|
1998-12-01 09:27:22 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-12-06 21:21:48 +01:00
|
|
|
/**************************************************************************
|
2009-10-31 09:11:55 +01:00
|
|
|
* WAVE_mciDefaultFmt [internal]
|
2009-10-18 19:04:14 +02:00
|
|
|
*
|
|
|
|
* wmw->lpWaveFormat points to the default wave format at wmw->wfxRef
|
|
|
|
* until either Open File or Record. It becomes immutable afterwards,
|
|
|
|
* i.e. Set wave format or channels etc. is subsequently refused.
|
2005-12-06 21:21:48 +01:00
|
|
|
*/
|
2009-10-18 19:04:14 +02:00
|
|
|
static void WAVE_mciDefaultFmt(WINE_MCIWAVE* wmw)
|
2005-12-06 21:21:48 +01:00
|
|
|
{
|
2009-10-18 19:04:14 +02:00
|
|
|
wmw->lpWaveFormat = &wmw->wfxRef;
|
2005-12-06 21:21:48 +01:00
|
|
|
wmw->lpWaveFormat->wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
wmw->lpWaveFormat->nChannels = 1;
|
2009-10-18 14:14:11 +02:00
|
|
|
wmw->lpWaveFormat->nSamplesPerSec = 11025;
|
|
|
|
wmw->lpWaveFormat->nAvgBytesPerSec = 11025;
|
2005-12-06 21:21:48 +01:00
|
|
|
wmw->lpWaveFormat->nBlockAlign = 1;
|
|
|
|
wmw->lpWaveFormat->wBitsPerSample = 8;
|
2009-10-18 19:04:14 +02:00
|
|
|
wmw->lpWaveFormat->cbSize = 0;
|
2005-12-06 21:21:48 +01:00
|
|
|
}
|
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciCreateRIFFSkeleton [internal]
|
|
|
|
*/
|
|
|
|
static DWORD WAVE_mciCreateRIFFSkeleton(WINE_MCIWAVE* wmw)
|
|
|
|
{
|
|
|
|
MMCKINFO ckWaveFormat;
|
2003-01-11 23:47:21 +01:00
|
|
|
LPMMCKINFO lpckRIFF = &(wmw->ckMainRIFF);
|
|
|
|
LPMMCKINFO lpckWaveData = &(wmw->ckWaveData);
|
2000-10-20 00:36:54 +02:00
|
|
|
|
|
|
|
lpckRIFF->ckid = FOURCC_RIFF;
|
|
|
|
lpckRIFF->fccType = mmioFOURCC('W', 'A', 'V', 'E');
|
|
|
|
lpckRIFF->cksize = 0;
|
|
|
|
|
2003-01-11 23:47:21 +01:00
|
|
|
if (MMSYSERR_NOERROR != mmioCreateChunk(wmw->hFile, lpckRIFF, MMIO_CREATERIFF))
|
2000-10-20 00:36:54 +02:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
ckWaveFormat.fccType = 0;
|
|
|
|
ckWaveFormat.ckid = mmioFOURCC('f', 'm', 't', ' ');
|
2003-01-11 23:47:21 +01:00
|
|
|
ckWaveFormat.cksize = sizeof(PCMWAVEFORMAT);
|
2000-10-20 00:36:54 +02:00
|
|
|
|
2009-10-20 07:34:57 +02:00
|
|
|
/* Set wave format accepts PCM only, however open an
|
2009-10-18 19:04:14 +02:00
|
|
|
* existing ADPCM file, record into it and the MCI will
|
|
|
|
* happily save back in that format. */
|
2009-10-20 07:34:57 +02:00
|
|
|
if (wmw->lpWaveFormat->wFormatTag == WAVE_FORMAT_PCM) {
|
|
|
|
if (wmw->lpWaveFormat->nBlockAlign !=
|
|
|
|
wmw->lpWaveFormat->nChannels * wmw->lpWaveFormat->wBitsPerSample/8) {
|
|
|
|
WORD size = wmw->lpWaveFormat->nChannels *
|
|
|
|
wmw->lpWaveFormat->wBitsPerSample/8;
|
|
|
|
WARN("Incorrect nBlockAlign (%d), setting it to %d\n",
|
|
|
|
wmw->lpWaveFormat->nBlockAlign, size);
|
|
|
|
wmw->lpWaveFormat->nBlockAlign = size;
|
|
|
|
}
|
|
|
|
if (wmw->lpWaveFormat->nAvgBytesPerSec !=
|
|
|
|
wmw->lpWaveFormat->nSamplesPerSec * wmw->lpWaveFormat->nBlockAlign) {
|
|
|
|
DWORD speed = wmw->lpWaveFormat->nSamplesPerSec *
|
|
|
|
wmw->lpWaveFormat->nBlockAlign;
|
|
|
|
WARN("Incorrect nAvgBytesPerSec (%d), setting it to %d\n",
|
|
|
|
wmw->lpWaveFormat->nAvgBytesPerSec, speed);
|
|
|
|
wmw->lpWaveFormat->nAvgBytesPerSec = speed;
|
|
|
|
}
|
2000-10-20 00:36:54 +02:00
|
|
|
}
|
2009-10-18 19:04:14 +02:00
|
|
|
if (wmw->lpWaveFormat == &wmw->wfxRef) {
|
|
|
|
LPWAVEFORMATEX pwfx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WAVEFORMATEX));
|
|
|
|
if (!pwfx) return MCIERR_OUT_OF_MEMORY;
|
2009-10-20 07:34:57 +02:00
|
|
|
/* Set wave format accepts PCM only so the size is known. */
|
|
|
|
assert(wmw->wfxRef.wFormatTag == WAVE_FORMAT_PCM);
|
2009-10-18 19:04:14 +02:00
|
|
|
*pwfx = wmw->wfxRef;
|
|
|
|
wmw->lpWaveFormat = pwfx;
|
|
|
|
}
|
2003-01-11 23:47:21 +01:00
|
|
|
|
|
|
|
if (MMSYSERR_NOERROR != mmioCreateChunk(wmw->hFile, &ckWaveFormat, 0))
|
2000-10-20 00:36:54 +02:00
|
|
|
goto err;
|
|
|
|
|
2009-10-20 07:34:57 +02:00
|
|
|
if (-1 == mmioWrite(wmw->hFile, (HPCSTR)wmw->lpWaveFormat, (WAVE_FORMAT_PCM==wmw->lpWaveFormat->wFormatTag)
|
|
|
|
? sizeof(PCMWAVEFORMAT) : sizeof(WAVEFORMATEX)+wmw->lpWaveFormat->cbSize))
|
2002-06-01 01:06:46 +02:00
|
|
|
goto err;
|
2000-10-20 00:36:54 +02:00
|
|
|
|
2003-01-11 23:47:21 +01:00
|
|
|
if (MMSYSERR_NOERROR != mmioAscend(wmw->hFile, &ckWaveFormat, 0))
|
2000-10-20 00:36:54 +02:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
lpckWaveData->cksize = 0;
|
|
|
|
lpckWaveData->fccType = 0;
|
|
|
|
lpckWaveData->ckid = mmioFOURCC('d', 'a', 't', 'a');
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
/* create data chunk */
|
2003-01-11 23:47:21 +01:00
|
|
|
if (MMSYSERR_NOERROR != mmioCreateChunk(wmw->hFile, lpckWaveData, 0))
|
2000-10-20 00:36:54 +02:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
err:
|
2009-10-18 19:04:14 +02:00
|
|
|
/* mciClose takes care of wmw->lpWaveFormat. */
|
2000-10-20 00:36:54 +02:00
|
|
|
return MCIERR_INVALID_FILE;
|
|
|
|
}
|
|
|
|
|
2005-12-06 21:21:48 +01:00
|
|
|
static DWORD create_tmp_file(HMMIO* hFile, LPWSTR* pszTmpFileName)
|
|
|
|
{
|
|
|
|
WCHAR szTmpPath[MAX_PATH];
|
|
|
|
WCHAR szPrefix[4];
|
|
|
|
DWORD dwRet = MMSYSERR_NOERROR;
|
|
|
|
|
|
|
|
szPrefix[0] = 'M';
|
|
|
|
szPrefix[1] = 'C';
|
|
|
|
szPrefix[2] = 'I';
|
|
|
|
szPrefix[3] = '\0';
|
|
|
|
|
2008-02-18 20:39:32 +01:00
|
|
|
if (!GetTempPathW(sizeof(szTmpPath)/sizeof(szTmpPath[0]), szTmpPath)) {
|
2005-12-06 21:21:48 +01:00
|
|
|
WARN("can't retrieve temp path!\n");
|
2009-11-05 23:10:06 +01:00
|
|
|
*pszTmpFileName = NULL;
|
2005-12-06 21:21:48 +01:00
|
|
|
return MCIERR_FILE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pszTmpFileName = HeapAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
MAX_PATH * sizeof(WCHAR));
|
|
|
|
if (!GetTempFileNameW(szTmpPath, szPrefix, 0, *pszTmpFileName)) {
|
|
|
|
WARN("can't retrieve temp file name!\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, *pszTmpFileName);
|
|
|
|
return MCIERR_FILE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("%s!\n", debugstr_w(*pszTmpFileName));
|
|
|
|
|
|
|
|
if (*pszTmpFileName && (strlenW(*pszTmpFileName) > 0)) {
|
|
|
|
|
|
|
|
*hFile = mmioOpenW(*pszTmpFileName, NULL,
|
|
|
|
MMIO_ALLOCBUF | MMIO_READWRITE | MMIO_CREATE);
|
|
|
|
|
|
|
|
if (*hFile == 0) {
|
|
|
|
WARN("can't create file=%s!\n", debugstr_w(*pszTmpFileName));
|
|
|
|
/* temporary file could not be created. clean filename. */
|
|
|
|
HeapFree(GetProcessHeap(), 0, *pszTmpFileName);
|
|
|
|
dwRet = MCIERR_FILE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
2009-11-05 23:10:06 +01:00
|
|
|
static LRESULT WAVE_mciOpenFile(WINE_MCIWAVE* wmw, LPCWSTR filename)
|
2005-12-06 21:21:48 +01:00
|
|
|
{
|
|
|
|
LRESULT dwRet = MMSYSERR_NOERROR;
|
2009-11-05 23:10:06 +01:00
|
|
|
LPWSTR fn;
|
2005-12-06 21:21:48 +01:00
|
|
|
|
|
|
|
fn = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(filename) + 1) * sizeof(WCHAR));
|
|
|
|
if (!fn) return MCIERR_OUT_OF_MEMORY;
|
|
|
|
strcpyW(fn, filename);
|
2009-11-05 23:10:06 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName);
|
|
|
|
wmw->lpFileName = fn;
|
2005-12-06 21:21:48 +01:00
|
|
|
|
|
|
|
if (strlenW(filename) > 0) {
|
|
|
|
/* FIXME : what should be done if wmw->hFile is already != 0, or the driver is playin' */
|
|
|
|
TRACE("MCI_OPEN_ELEMENT %s!\n", debugstr_w(filename));
|
|
|
|
|
|
|
|
wmw->hFile = mmioOpenW((LPWSTR)filename, NULL,
|
|
|
|
MMIO_ALLOCBUF | MMIO_DENYWRITE | MMIO_READ);
|
|
|
|
|
|
|
|
if (wmw->hFile == 0) {
|
|
|
|
WARN("can't find file=%s!\n", debugstr_w(filename));
|
|
|
|
dwRet = MCIERR_FILE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LPMMCKINFO lpckMainRIFF = &wmw->ckMainRIFF;
|
|
|
|
|
|
|
|
/* make sure we're are the beginning of the file */
|
|
|
|
mmioSeek(wmw->hFile, 0, SEEK_SET);
|
|
|
|
|
|
|
|
/* first reading of this file. read the waveformat chunk */
|
|
|
|
if (mmioDescend(wmw->hFile, lpckMainRIFF, NULL, 0) != 0) {
|
|
|
|
dwRet = MCIERR_INVALID_FILE;
|
|
|
|
} else {
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("ParentChunk ckid=%.4s fccType=%.4s cksize=%08X\n",
|
2005-12-06 21:21:48 +01:00
|
|
|
(LPSTR)&(lpckMainRIFF->ckid),
|
|
|
|
(LPSTR) &(lpckMainRIFF->fccType),
|
|
|
|
(lpckMainRIFF->cksize));
|
|
|
|
|
|
|
|
if ((lpckMainRIFF->ckid != FOURCC_RIFF) ||
|
|
|
|
lpckMainRIFF->fccType != mmioFOURCC('W', 'A', 'V', 'E')) {
|
|
|
|
dwRet = MCIERR_INVALID_FILE;
|
|
|
|
} else {
|
|
|
|
dwRet = WAVE_mciReadFmt(wmw, lpckMainRIFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciOpen [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static LRESULT WAVE_mciOpen(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_WAVE_OPEN_PARMSW lpOpenParms)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
1998-12-01 09:27:22 +01:00
|
|
|
DWORD dwRet = 0;
|
1999-07-15 16:36:15 +02:00
|
|
|
WINE_MCIWAVE* wmw = (WINE_MCIWAVE*)mciGetDriverData(wDevID);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("(%04X, %08X, %p)\n", wDevID, dwFlags, lpOpenParms);
|
1999-05-02 12:21:49 +02:00
|
|
|
if (lpOpenParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
|
|
|
|
1999-02-14 12:26:34 +01:00
|
|
|
if (dwFlags & MCI_OPEN_SHAREABLE)
|
2009-11-02 23:52:49 +01:00
|
|
|
return MCIERR_UNSUPPORTED_FUNCTION;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (wmw->nUseCount > 0) {
|
1999-02-14 12:26:34 +01:00
|
|
|
/* The driver is already opened on this channel
|
|
|
|
* Wave driver cannot be shared
|
|
|
|
*/
|
|
|
|
return MCIERR_DEVICE_OPEN;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
2000-10-20 00:36:54 +02:00
|
|
|
|
1999-02-14 12:26:34 +01:00
|
|
|
wmw->nUseCount++;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
wmw->fInput = FALSE;
|
1999-09-05 18:31:37 +02:00
|
|
|
wmw->hWave = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
wmw->dwStatus = MCI_MODE_NOT_READY;
|
2005-12-06 21:21:48 +01:00
|
|
|
wmw->hFile = 0;
|
2009-11-05 23:10:06 +01:00
|
|
|
wmw->lpFileName = NULL; /* will be set by WAVE_mciOpenFile */
|
2009-11-10 08:40:55 +01:00
|
|
|
wmw->hCallback = NULL;
|
2009-10-18 19:04:14 +02:00
|
|
|
WAVE_mciDefaultFmt(wmw);
|
1999-05-02 12:21:49 +02:00
|
|
|
|
2001-01-03 22:36:56 +01:00
|
|
|
TRACE("wDevID=%04X (lpParams->wDeviceID=%08X)\n", wDevID, lpOpenParms->wDeviceID);
|
2009-11-05 20:21:07 +01:00
|
|
|
/* Logs show the native winmm calls us with 0 still in lpOpenParms.wDeviceID */
|
|
|
|
wmw->wNotifyDeviceID = wDevID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (dwFlags & MCI_OPEN_ELEMENT) {
|
1999-02-13 13:38:09 +01:00
|
|
|
if (dwFlags & MCI_OPEN_ELEMENT_ID) {
|
2002-06-01 01:06:46 +02:00
|
|
|
/* could it be that (DWORD)lpOpenParms->lpstrElementName
|
|
|
|
* contains the hFile value ?
|
1999-02-13 13:38:09 +01:00
|
|
|
*/
|
|
|
|
dwRet = MCIERR_UNRECOGNIZED_COMMAND;
|
1998-11-24 17:36:18 +01:00
|
|
|
} else {
|
2005-12-06 21:21:48 +01:00
|
|
|
dwRet = WAVE_mciOpenFile(wmw, lpOpenParms->lpstrElementName);
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
}
|
2002-10-19 01:48:57 +02:00
|
|
|
TRACE("hFile=%p\n", wmw->hFile);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-01 09:27:22 +01:00
|
|
|
if (dwRet == 0) {
|
1999-02-13 13:38:09 +01:00
|
|
|
wmw->dwPosition = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-13 13:38:09 +01:00
|
|
|
wmw->dwStatus = MCI_MODE_STOP;
|
2009-11-10 08:40:55 +01:00
|
|
|
|
|
|
|
if (dwFlags & MCI_NOTIFY)
|
|
|
|
WAVE_mciNotify(lpOpenParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
|
1998-12-01 09:27:22 +01:00
|
|
|
} else {
|
|
|
|
wmw->nUseCount--;
|
|
|
|
if (wmw->hFile != 0)
|
1999-02-26 12:11:13 +01:00
|
|
|
mmioClose(wmw->hFile, 0);
|
1998-12-01 09:27:22 +01:00
|
|
|
wmw->hFile = 0;
|
|
|
|
}
|
1999-03-15 16:16:13 +01:00
|
|
|
return dwRet;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciCue [internal]
|
|
|
|
*/
|
2009-10-19 18:31:57 +02:00
|
|
|
static DWORD WAVE_mciCue(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-19 18:31:57 +02:00
|
|
|
TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
|
|
|
|
|
|
|
/* Tests on systems without sound drivers show that Cue, like
|
|
|
|
* Record and Play, opens winmm, returning MCIERR_WAVE_xyPUTSUNSUITABLE.
|
|
|
|
* The first Cue Notify does not immediately return the
|
|
|
|
* notification, as if a player or recorder thread is started.
|
|
|
|
* PAUSE mode is reported when successful, but this mode is
|
|
|
|
* different from the normal Pause, because a) Pause then returns
|
|
|
|
* NONAPPLICABLE_FUNCTION instead of 0 and b) Set Channels etc. is
|
|
|
|
* still accepted, returning the original notification as ABORTED.
|
|
|
|
* I.e. Cue allows subsequent format changes, unlike Record or
|
|
|
|
* Open file, closes winmm if the format changes and stops this
|
|
|
|
* thread.
|
|
|
|
* Wine creates one player or recorder thread per async. Play or
|
|
|
|
* Record command. Notification behaviour suggests that MS-W*
|
|
|
|
* reuses a single thread to improve response times. Having Cue
|
|
|
|
* start this thread early helps to improve Play/Record's initial
|
|
|
|
* response time. In effect, Cue is a performance hint, which
|
|
|
|
* justifies our almost no-op implementation.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-19 18:31:57 +02:00
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
|
|
|
if (wmw->dwStatus != MCI_MODE_STOP) return MCIERR_NONAPPLICABLE_FUNCTION;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-19 18:31:57 +02:00
|
|
|
if ((dwFlags & MCI_NOTIFY) && lpParms)
|
|
|
|
WAVE_mciNotify(lpParms->dwCallback,wmw,MCI_NOTIFY_SUCCESSFUL);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-19 18:31:57 +02:00
|
|
|
return MMSYSERR_NOERROR;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciStop [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static DWORD WAVE_mciStop(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
1999-12-12 22:26:09 +01:00
|
|
|
DWORD dwRet = 0;
|
1998-11-24 17:36:18 +01:00
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-11-10 08:40:55 +01:00
|
|
|
if (wmw->dwStatus != MCI_MODE_STOP) {
|
|
|
|
HANDLE old = InterlockedExchangePointer(&wmw->hCallback, NULL);
|
|
|
|
if (old) mciDriverNotify(old, wDevID, MCI_NOTIFY_ABORTED);
|
|
|
|
}
|
|
|
|
|
1999-12-12 22:26:09 +01:00
|
|
|
/* wait for playback thread (if any) to exit before processing further */
|
|
|
|
switch (wmw->dwStatus) {
|
|
|
|
case MCI_MODE_PAUSE:
|
|
|
|
case MCI_MODE_PLAY:
|
|
|
|
case MCI_MODE_RECORD:
|
|
|
|
{
|
|
|
|
int oldStat = wmw->dwStatus;
|
|
|
|
wmw->dwStatus = MCI_MODE_NOT_READY;
|
|
|
|
if (oldStat == MCI_MODE_PAUSE)
|
|
|
|
dwRet = (wmw->fInput) ? waveInReset(wmw->hWave) : waveOutReset(wmw->hWave);
|
|
|
|
}
|
2000-01-09 03:38:24 +01:00
|
|
|
while (wmw->dwStatus != MCI_MODE_STOP)
|
1999-12-12 22:26:09 +01:00
|
|
|
Sleep(10);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sanity resets */
|
|
|
|
wmw->dwStatus = MCI_MODE_STOP;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-11-10 08:40:55 +01:00
|
|
|
if ((dwFlags & MCI_NOTIFY) && lpParms && MMSYSERR_NOERROR==dwRet)
|
|
|
|
WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-12-12 22:26:09 +01:00
|
|
|
return dwRet;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciClose [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static DWORD WAVE_mciClose(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
1999-02-14 12:26:34 +01:00
|
|
|
DWORD dwRet = 0;
|
1998-11-24 17:36:18 +01:00
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-14 12:26:34 +01:00
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (wmw->dwStatus != MCI_MODE_STOP) {
|
2009-11-10 08:40:55 +01:00
|
|
|
/* mciStop handles MCI_NOTIFY_ABORTED */
|
1999-02-14 12:26:34 +01:00
|
|
|
dwRet = WAVE_mciStop(wDevID, MCI_WAIT, lpParms);
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
wmw->nUseCount--;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (wmw->nUseCount == 0) {
|
|
|
|
if (wmw->hFile != 0) {
|
1999-02-26 12:11:13 +01:00
|
|
|
mmioClose(wmw->hFile, 0);
|
1998-11-24 17:36:18 +01:00
|
|
|
wmw->hFile = 0;
|
|
|
|
}
|
|
|
|
}
|
2000-10-20 00:36:54 +02:00
|
|
|
|
2009-10-18 19:04:14 +02:00
|
|
|
if (wmw->lpWaveFormat != &wmw->wfxRef)
|
|
|
|
HeapFree(GetProcessHeap(), 0, wmw->lpWaveFormat);
|
|
|
|
wmw->lpWaveFormat = &wmw->wfxRef;
|
2009-11-05 23:10:06 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName);
|
|
|
|
wmw->lpFileName = NULL;
|
1999-12-05 03:18:35 +01:00
|
|
|
|
1999-03-15 16:16:13 +01:00
|
|
|
if ((dwFlags & MCI_NOTIFY) && lpParms) {
|
2009-11-10 08:40:55 +01:00
|
|
|
WAVE_mciNotify(lpParms->dwCallback, wmw,
|
|
|
|
(dwRet == 0) ? MCI_NOTIFY_SUCCESSFUL : MCI_NOTIFY_FAILURE);
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
1999-12-12 22:26:09 +01:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-12-12 22:26:09 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciPlayCallback [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static void CALLBACK WAVE_mciPlayCallback(HWAVEOUT hwo, UINT uMsg,
|
2005-11-28 20:53:22 +01:00
|
|
|
DWORD_PTR dwInstance,
|
|
|
|
LPARAM dwParam1, LPARAM dwParam2)
|
1999-12-12 22:26:09 +01:00
|
|
|
{
|
|
|
|
WINE_MCIWAVE* wmw = (WINE_MCIWAVE*)dwInstance;
|
|
|
|
|
|
|
|
switch (uMsg) {
|
|
|
|
case WOM_OPEN:
|
|
|
|
case WOM_CLOSE:
|
|
|
|
break;
|
|
|
|
case WOM_DONE:
|
|
|
|
InterlockedIncrement(&wmw->dwEventCount);
|
|
|
|
TRACE("Returning waveHdr=%lx\n", dwParam1);
|
|
|
|
SetEvent(wmw->hEvent);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown uMsg=%d\n", uMsg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-11 23:47:21 +01:00
|
|
|
/******************************************************************
|
2009-10-31 09:11:55 +01:00
|
|
|
* WAVE_mciPlayWaitDone [internal]
|
2003-01-11 23:47:21 +01:00
|
|
|
*/
|
1999-12-12 22:26:09 +01:00
|
|
|
static void WAVE_mciPlayWaitDone(WINE_MCIWAVE* wmw)
|
|
|
|
{
|
|
|
|
for (;;) {
|
|
|
|
ResetEvent(wmw->hEvent);
|
|
|
|
if (InterlockedDecrement(&wmw->dwEventCount) >= 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
InterlockedIncrement(&wmw->dwEventCount);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-12-12 22:26:09 +01:00
|
|
|
WaitForSingleObject(wmw->hEvent, INFINITE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciPlay [internal]
|
|
|
|
*/
|
2009-10-17 10:08:43 +02:00
|
|
|
static DWORD WAVE_mciPlay(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt, HANDLE hEvent)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
2009-10-17 10:08:37 +02:00
|
|
|
LPMCI_PLAY_PARMS lpParms = (void*)pmt;
|
1998-11-24 17:36:18 +01:00
|
|
|
DWORD end;
|
1999-12-05 03:18:35 +01:00
|
|
|
LONG bufsize, count, left;
|
2009-10-18 14:10:31 +02:00
|
|
|
DWORD dwRet;
|
1999-12-12 22:26:09 +01:00
|
|
|
LPWAVEHDR waveHdr = NULL;
|
1998-11-24 17:36:18 +01:00
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2009-11-10 08:40:55 +01:00
|
|
|
HANDLE oldcb;
|
1999-12-05 03:18:35 +01:00
|
|
|
int whidx;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-17 10:08:37 +02:00
|
|
|
TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-14 12:26:34 +01:00
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
2000-10-20 00:36:54 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (wmw->hFile == 0) {
|
2009-11-05 23:10:06 +01:00
|
|
|
WARN("Can't play: no file=%s!\n", debugstr_w(wmw->lpFileName));
|
1998-11-24 17:36:18 +01:00
|
|
|
return MCIERR_FILE_NOT_FOUND;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-17 16:40:28 +02:00
|
|
|
if (wmw->dwStatus == MCI_MODE_PAUSE && !wmw->fInput) {
|
2000-10-20 00:36:54 +02:00
|
|
|
/* FIXME: parameters (start/end) in lpParams may not be used */
|
|
|
|
return WAVE_mciResume(wDevID, dwFlags, (LPMCI_GENERIC_PARMS)lpParms);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-01-09 03:38:24 +01:00
|
|
|
/** This function will be called again by a thread when async is used.
|
|
|
|
* We have to set MCI_MODE_PLAY before we do this so that the app can spin
|
|
|
|
* on MCI_STATUS, so we have to allow it here if we're not going to start this thread.
|
|
|
|
*/
|
|
|
|
if ((wmw->dwStatus != MCI_MODE_STOP) && ((wmw->dwStatus != MCI_MODE_PLAY) && (dwFlags & MCI_WAIT))) {
|
1999-05-24 10:18:53 +02:00
|
|
|
return MCIERR_INTERNAL;
|
|
|
|
}
|
|
|
|
|
2009-10-18 14:10:31 +02:00
|
|
|
if (wmw->lpWaveFormat->wFormatTag == WAVE_FORMAT_PCM) {
|
|
|
|
if (wmw->lpWaveFormat->nBlockAlign !=
|
|
|
|
wmw->lpWaveFormat->nChannels * wmw->lpWaveFormat->wBitsPerSample/8) {
|
|
|
|
WARN("Incorrect nBlockAlign (%d), setting it to %d\n",
|
|
|
|
wmw->lpWaveFormat->nBlockAlign,
|
|
|
|
wmw->lpWaveFormat->nChannels *
|
|
|
|
wmw->lpWaveFormat->wBitsPerSample/8);
|
|
|
|
wmw->lpWaveFormat->nBlockAlign =
|
|
|
|
wmw->lpWaveFormat->nChannels *
|
|
|
|
wmw->lpWaveFormat->wBitsPerSample/8;
|
|
|
|
}
|
|
|
|
if (wmw->lpWaveFormat->nAvgBytesPerSec !=
|
|
|
|
wmw->lpWaveFormat->nSamplesPerSec * wmw->lpWaveFormat->nBlockAlign) {
|
|
|
|
WARN("Incorrect nAvgBytesPerSec (%d), setting it to %d\n",
|
|
|
|
wmw->lpWaveFormat->nAvgBytesPerSec,
|
|
|
|
wmw->lpWaveFormat->nSamplesPerSec *
|
|
|
|
wmw->lpWaveFormat->nBlockAlign);
|
|
|
|
wmw->lpWaveFormat->nAvgBytesPerSec =
|
|
|
|
wmw->lpWaveFormat->nSamplesPerSec *
|
|
|
|
wmw->lpWaveFormat->nBlockAlign;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-21 17:44:58 +02:00
|
|
|
end = wmw->ckWaveData.cksize;
|
|
|
|
if (lpParms && (dwFlags & MCI_TO)) {
|
|
|
|
DWORD position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo);
|
|
|
|
if (position > end) return MCIERR_OUTOFRANGE;
|
|
|
|
end = position;
|
|
|
|
}
|
1998-11-24 17:36:18 +01:00
|
|
|
if (lpParms && (dwFlags & MCI_FROM)) {
|
2009-10-21 17:44:58 +02:00
|
|
|
DWORD position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwFrom);
|
|
|
|
if (position > end) return MCIERR_OUTOFRANGE;
|
|
|
|
/* Seek rounds down, so do we. */
|
|
|
|
position /= wmw->lpWaveFormat->nBlockAlign;
|
|
|
|
position *= wmw->lpWaveFormat->nBlockAlign;
|
|
|
|
wmw->dwPosition = position;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
2009-10-21 17:44:58 +02:00
|
|
|
if (end < wmw->dwPosition) return MCIERR_OUTOFRANGE;
|
|
|
|
left = end - wmw->dwPosition;
|
|
|
|
if (0==left) return MMSYSERR_NOERROR; /* FIXME: NOTIFY */
|
|
|
|
|
|
|
|
wmw->fInput = FALSE; /* FIXME: waveInOpen may have been called. */
|
|
|
|
wmw->dwStatus = MCI_MODE_PLAY;
|
|
|
|
|
|
|
|
if (!(dwFlags & MCI_WAIT)) {
|
2009-11-05 20:21:07 +01:00
|
|
|
return MCI_SendCommandAsync(wDevID, WAVE_mciPlay, dwFlags,
|
2009-10-21 17:44:58 +02:00
|
|
|
(DWORD_PTR)lpParms, sizeof(MCI_PLAY_PARMS));
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("Playing from byte=%u to byte=%u\n", wmw->dwPosition, end);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-11-10 08:40:55 +01:00
|
|
|
oldcb = InterlockedExchangePointer(&wmw->hCallback,
|
|
|
|
(dwFlags & MCI_NOTIFY) ? HWND_32(LOWORD(lpParms->dwCallback)) : NULL);
|
|
|
|
if (oldcb) mciDriverNotify(oldcb, wDevID, MCI_NOTIFY_ABORTED);
|
|
|
|
oldcb = NULL;
|
|
|
|
|
1999-12-05 03:18:35 +01:00
|
|
|
#define WAVE_ALIGN_ON_BLOCK(wmw,v) \
|
|
|
|
((((v) + (wmw)->lpWaveFormat->nBlockAlign - 1) / (wmw)->lpWaveFormat->nBlockAlign) * (wmw)->lpWaveFormat->nBlockAlign)
|
|
|
|
|
2001-10-22 21:04:32 +02:00
|
|
|
/* go back to beginning of chunk plus the requested position */
|
2002-06-01 01:06:46 +02:00
|
|
|
/* FIXME: I'm not sure this is correct, notably because some data linked to
|
2008-04-04 21:23:01 +02:00
|
|
|
* the decompression state machine will not be correctly initialized.
|
1999-12-05 03:18:35 +01:00
|
|
|
* try it this way (other way would be to decompress from 0 up to dwPosition
|
|
|
|
* and to start sending to hWave when dwPosition is reached)
|
|
|
|
*/
|
2000-10-20 00:36:54 +02:00
|
|
|
mmioSeek(wmw->hFile, wmw->ckWaveData.dwDataOffset + wmw->dwPosition, SEEK_SET); /* >= 0 */
|
1999-12-12 22:26:09 +01:00
|
|
|
|
1999-12-05 03:18:35 +01:00
|
|
|
/* FIXME: how to choose between several output channels ? here mapper is forced */
|
2002-10-19 19:20:02 +02:00
|
|
|
dwRet = waveOutOpen((HWAVEOUT *)&wmw->hWave, WAVE_MAPPER, wmw->lpWaveFormat,
|
2007-05-31 16:01:28 +02:00
|
|
|
(DWORD_PTR)WAVE_mciPlayCallback, (DWORD_PTR)wmw, CALLBACK_FUNCTION);
|
1999-12-12 22:26:09 +01:00
|
|
|
|
1999-03-15 16:16:13 +01:00
|
|
|
if (dwRet != 0) {
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("Can't open low level audio device %d\n", dwRet);
|
1999-12-12 22:26:09 +01:00
|
|
|
dwRet = MCIERR_DEVICE_OPEN;
|
|
|
|
wmw->hWave = 0;
|
|
|
|
goto cleanUp;
|
1999-03-15 16:16:13 +01:00
|
|
|
}
|
1998-11-24 17:36:18 +01:00
|
|
|
|
1999-12-05 03:18:35 +01:00
|
|
|
/* make it so that 3 buffers per second are needed */
|
|
|
|
bufsize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->lpWaveFormat->nAvgBytesPerSec / 3);
|
|
|
|
|
|
|
|
waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize);
|
|
|
|
waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
|
|
|
|
waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize;
|
1999-12-12 22:26:09 +01:00
|
|
|
waveHdr[0].dwUser = waveHdr[1].dwUser = 0L;
|
|
|
|
waveHdr[0].dwLoops = waveHdr[1].dwLoops = 0L;
|
|
|
|
waveHdr[0].dwFlags = waveHdr[1].dwFlags = 0L;
|
|
|
|
waveHdr[0].dwBufferLength = waveHdr[1].dwBufferLength = bufsize;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (waveOutPrepareHeader(wmw->hWave, &waveHdr[0], sizeof(WAVEHDR)) ||
|
1999-12-12 22:26:09 +01:00
|
|
|
waveOutPrepareHeader(wmw->hWave, &waveHdr[1], sizeof(WAVEHDR))) {
|
|
|
|
dwRet = MCIERR_INTERNAL;
|
|
|
|
goto cleanUp;
|
|
|
|
}
|
1999-12-05 03:18:35 +01:00
|
|
|
|
|
|
|
whidx = 0;
|
2005-01-07 16:40:09 +01:00
|
|
|
wmw->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
|
1999-12-12 22:26:09 +01:00
|
|
|
wmw->dwEventCount = 1L; /* for first buffer */
|
1999-12-05 03:18:35 +01:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("Playing (normalized) from byte=%u for %u bytes\n", wmw->dwPosition, left);
|
2009-10-17 10:08:43 +02:00
|
|
|
if (hEvent) SetEvent(hEvent);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
/* FIXME: this doesn't work if wmw->dwPosition != 0 */
|
1999-12-12 22:26:09 +01:00
|
|
|
while (left > 0 && wmw->dwStatus != MCI_MODE_STOP && wmw->dwStatus != MCI_MODE_NOT_READY) {
|
2000-03-25 22:44:35 +01:00
|
|
|
count = mmioRead(wmw->hFile, waveHdr[whidx].lpData, min(bufsize, left));
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("mmioRead bufsize=%d count=%d\n", bufsize, count);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (count < 1)
|
1999-03-15 16:16:13 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
/* count is always <= bufsize, so this is correct regarding the
|
|
|
|
* waveOutPrepareHeader function
|
1999-12-12 22:26:09 +01:00
|
|
|
*/
|
1999-12-05 03:18:35 +01:00
|
|
|
waveHdr[whidx].dwBufferLength = count;
|
1999-12-12 22:26:09 +01:00
|
|
|
waveHdr[whidx].dwFlags &= ~WHDR_DONE;
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("before WODM_WRITE lpWaveHdr=%p dwBufferLength=%u dwBytesRecorded=%u\n",
|
2002-06-01 01:06:46 +02:00
|
|
|
&waveHdr[whidx], waveHdr[whidx].dwBufferLength,
|
1999-12-05 03:18:35 +01:00
|
|
|
waveHdr[whidx].dwBytesRecorded);
|
|
|
|
dwRet = waveOutWrite(wmw->hWave, &waveHdr[whidx], sizeof(WAVEHDR));
|
1999-12-12 22:26:09 +01:00
|
|
|
left -= count;
|
1998-11-24 17:36:18 +01:00
|
|
|
wmw->dwPosition += count;
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("after WODM_WRITE dwPosition=%u\n", wmw->dwPosition);
|
1999-12-05 03:18:35 +01:00
|
|
|
|
1999-12-12 22:26:09 +01:00
|
|
|
WAVE_mciPlayWaitDone(wmw);
|
1999-12-05 03:18:35 +01:00
|
|
|
whidx ^= 1;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
1999-03-15 16:16:13 +01:00
|
|
|
|
1999-12-12 22:26:09 +01:00
|
|
|
WAVE_mciPlayWaitDone(wmw); /* to balance first buffer */
|
|
|
|
|
|
|
|
/* just to get rid of some race conditions between play, stop and pause */
|
1999-09-05 18:31:37 +02:00
|
|
|
waveOutReset(wmw->hWave);
|
1999-03-15 16:16:13 +01:00
|
|
|
|
1999-12-12 22:26:09 +01:00
|
|
|
waveOutUnprepareHeader(wmw->hWave, &waveHdr[0], sizeof(WAVEHDR));
|
|
|
|
waveOutUnprepareHeader(wmw->hWave, &waveHdr[1], sizeof(WAVEHDR));
|
|
|
|
|
|
|
|
dwRet = 0;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
cleanUp:
|
2009-11-10 08:40:55 +01:00
|
|
|
if (dwFlags & MCI_NOTIFY)
|
|
|
|
oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL);
|
|
|
|
|
1999-12-12 22:26:09 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, waveHdr);
|
|
|
|
|
|
|
|
if (wmw->hWave) {
|
|
|
|
waveOutClose(wmw->hWave);
|
|
|
|
wmw->hWave = 0;
|
|
|
|
}
|
|
|
|
CloseHandle(wmw->hEvent);
|
|
|
|
|
2009-10-17 16:41:10 +02:00
|
|
|
wmw->dwStatus = MCI_MODE_STOP;
|
|
|
|
|
2009-11-10 08:40:55 +01:00
|
|
|
/* Let the potentically asynchronous commands support FAILURE notification. */
|
|
|
|
if (oldcb) mciDriverNotify(oldcb, wDevID,
|
|
|
|
dwRet ? MCI_NOTIFY_FAILURE : MCI_NOTIFY_SUCCESSFUL);
|
1999-12-12 22:26:09 +01:00
|
|
|
|
|
|
|
return dwRet;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
/**************************************************************************
|
2009-10-31 09:11:55 +01:00
|
|
|
* WAVE_mciRecordCallback [internal]
|
2000-10-20 00:36:54 +02:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static void CALLBACK WAVE_mciRecordCallback(HWAVEOUT hwo, UINT uMsg,
|
2005-11-28 20:53:22 +01:00
|
|
|
DWORD_PTR dwInstance,
|
|
|
|
LPARAM dwParam1, LPARAM dwParam2)
|
2000-10-20 00:36:54 +02:00
|
|
|
{
|
|
|
|
WINE_MCIWAVE* wmw = (WINE_MCIWAVE*)dwInstance;
|
2003-01-11 23:47:21 +01:00
|
|
|
LPWAVEHDR lpWaveHdr;
|
2002-06-01 01:06:46 +02:00
|
|
|
LONG count = 0;
|
2003-01-11 23:47:21 +01:00
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
switch (uMsg) {
|
|
|
|
case WIM_OPEN:
|
|
|
|
case WIM_CLOSE:
|
|
|
|
break;
|
|
|
|
case WIM_DATA:
|
|
|
|
lpWaveHdr = (LPWAVEHDR) dwParam1;
|
|
|
|
|
|
|
|
InterlockedIncrement(&wmw->dwEventCount);
|
|
|
|
|
|
|
|
count = mmioWrite(wmw->hFile, lpWaveHdr->lpData, lpWaveHdr->dwBytesRecorded);
|
|
|
|
|
|
|
|
lpWaveHdr->dwFlags &= ~WHDR_DONE;
|
2003-01-11 23:47:21 +01:00
|
|
|
if (count > 0)
|
|
|
|
wmw->dwPosition += count;
|
|
|
|
/* else error reporting ?? */
|
2001-03-24 00:39:28 +01:00
|
|
|
if (wmw->dwStatus == MCI_MODE_RECORD)
|
|
|
|
{
|
|
|
|
/* Only queue up another buffer if we are recording. We could receive this
|
|
|
|
message also when waveInReset() is called, since it notifies on all wave
|
|
|
|
buffers that are outstanding. Queueing up more sometimes causes waveInClose
|
2002-06-01 01:06:46 +02:00
|
|
|
to fail. */
|
2001-03-24 00:39:28 +01:00
|
|
|
waveInAddBuffer(wmw->hWave, lpWaveHdr, sizeof(*lpWaveHdr));
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("after mmioWrite dwPosition=%u\n", wmw->dwPosition);
|
2001-03-24 00:39:28 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
SetEvent(wmw->hEvent);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown uMsg=%d\n", uMsg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-11 23:47:21 +01:00
|
|
|
/******************************************************************
|
2009-10-31 09:11:55 +01:00
|
|
|
* WAVE_mciRecordWaitDone [internal]
|
2003-01-11 23:47:21 +01:00
|
|
|
*/
|
2000-10-20 00:36:54 +02:00
|
|
|
static void WAVE_mciRecordWaitDone(WINE_MCIWAVE* wmw)
|
|
|
|
{
|
|
|
|
for (;;) {
|
|
|
|
ResetEvent(wmw->hEvent);
|
|
|
|
if (InterlockedDecrement(&wmw->dwEventCount) >= 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
InterlockedIncrement(&wmw->dwEventCount);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
WaitForSingleObject(wmw->hEvent, INFINITE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciRecord [internal]
|
|
|
|
*/
|
2009-10-17 10:08:43 +02:00
|
|
|
static DWORD WAVE_mciRecord(MCIDEVICEID wDevID, DWORD_PTR dwFlags, DWORD_PTR pmt, HANDLE hEvent)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
2009-10-17 10:08:37 +02:00
|
|
|
LPMCI_RECORD_PARMS lpParms = (void*)pmt;
|
2000-10-20 00:36:54 +02:00
|
|
|
DWORD end;
|
2003-01-11 23:47:21 +01:00
|
|
|
DWORD dwRet = MMSYSERR_NOERROR;
|
2002-06-01 01:06:46 +02:00
|
|
|
LONG bufsize;
|
2000-10-20 00:36:54 +02:00
|
|
|
LPWAVEHDR waveHdr = NULL;
|
1998-11-24 17:36:18 +01:00
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2009-11-10 08:40:55 +01:00
|
|
|
HANDLE oldcb;
|
2000-10-20 00:36:54 +02:00
|
|
|
|
2009-10-17 10:08:37 +02:00
|
|
|
TRACE("(%u, %08lX, %p);\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-14 12:26:34 +01:00
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-17 16:40:28 +02:00
|
|
|
if (wmw->dwStatus == MCI_MODE_PAUSE && wmw->fInput) {
|
|
|
|
/* FIXME: parameters (start/end) in lpParams may not be used */
|
|
|
|
return WAVE_mciResume(wDevID, dwFlags, (LPMCI_GENERIC_PARMS)lpParms);
|
|
|
|
}
|
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
/** This function will be called again by a thread when async is used.
|
2009-10-31 09:11:55 +01:00
|
|
|
* We have to set MCI_MODE_RECORD before we do this so that the app can spin
|
2000-10-20 00:36:54 +02:00
|
|
|
* on MCI_STATUS, so we have to allow it here if we're not going to start this thread.
|
|
|
|
*/
|
|
|
|
if ((wmw->dwStatus != MCI_MODE_STOP) && ((wmw->dwStatus != MCI_MODE_RECORD) && (dwFlags & MCI_WAIT))) {
|
|
|
|
return MCIERR_INTERNAL;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
1999-12-05 03:18:35 +01:00
|
|
|
|
2009-10-21 17:44:58 +02:00
|
|
|
wmw->fInput = TRUE; /* FIXME: waveOutOpen may have been called. */
|
2000-10-20 00:36:54 +02:00
|
|
|
wmw->dwStatus = MCI_MODE_RECORD;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
if (!(dwFlags & MCI_WAIT)) {
|
2009-11-05 20:21:07 +01:00
|
|
|
return MCI_SendCommandAsync(wDevID, WAVE_mciRecord, dwFlags,
|
2007-05-31 16:01:28 +02:00
|
|
|
(DWORD_PTR)lpParms, sizeof(MCI_RECORD_PARMS));
|
2000-10-20 00:36:54 +02:00
|
|
|
}
|
|
|
|
|
2005-12-06 21:21:48 +01:00
|
|
|
/* FIXME: we only re-create the RIFF structure from an existing file (if any)
|
|
|
|
* we don't modify the wave part of an existing file (ie. we always erase an
|
|
|
|
* existing content, we don't overwrite)
|
|
|
|
*/
|
2009-11-05 23:10:06 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, (void*)wmw->lpFileName);
|
|
|
|
dwRet = create_tmp_file(&wmw->hFile, (WCHAR**)&wmw->lpFileName);
|
2005-12-06 21:21:48 +01:00
|
|
|
if (dwRet != 0) return dwRet;
|
|
|
|
|
2009-10-21 17:44:58 +02:00
|
|
|
/* new RIFF file, lpWaveFormat now valid */
|
2005-12-06 21:21:48 +01:00
|
|
|
dwRet = WAVE_mciCreateRIFFSkeleton(wmw);
|
2009-10-18 19:04:14 +02:00
|
|
|
if (dwRet != 0) return dwRet;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
if (lpParms && (dwFlags & MCI_TO)) {
|
|
|
|
end = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo);
|
2009-10-21 17:44:58 +02:00
|
|
|
} else end = 0xFFFFFFFF;
|
|
|
|
if (lpParms && (dwFlags & MCI_FROM)) {
|
|
|
|
DWORD position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwFrom);
|
|
|
|
if (wmw->ckWaveData.cksize < position) return MCIERR_OUTOFRANGE;
|
|
|
|
/* Seek rounds down, so do we. */
|
|
|
|
position /= wmw->lpWaveFormat->nBlockAlign;
|
|
|
|
position *= wmw->lpWaveFormat->nBlockAlign;
|
|
|
|
wmw->dwPosition = position;
|
2000-10-20 00:36:54 +02:00
|
|
|
}
|
2009-10-21 17:44:58 +02:00
|
|
|
if (end==wmw->dwPosition) return MMSYSERR_NOERROR; /* FIXME: NOTIFY */
|
2000-10-20 00:36:54 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("Recording from byte=%u to byte=%u\n", wmw->dwPosition, end);
|
2000-10-20 00:36:54 +02:00
|
|
|
|
2009-11-10 08:40:55 +01:00
|
|
|
oldcb = InterlockedExchangePointer(&wmw->hCallback,
|
|
|
|
(dwFlags & MCI_NOTIFY) ? HWND_32(LOWORD(lpParms->dwCallback)) : NULL);
|
|
|
|
if (oldcb) mciDriverNotify(oldcb, wDevID, MCI_NOTIFY_ABORTED);
|
|
|
|
oldcb = NULL;
|
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
#define WAVE_ALIGN_ON_BLOCK(wmw,v) \
|
|
|
|
((((v) + (wmw)->lpWaveFormat->nBlockAlign - 1) / (wmw)->lpWaveFormat->nBlockAlign) * (wmw)->lpWaveFormat->nBlockAlign)
|
|
|
|
|
|
|
|
wmw->ckWaveData.cksize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->ckWaveData.cksize);
|
|
|
|
|
2008-04-21 07:17:27 +02:00
|
|
|
/* Go back to the beginning of the chunk plus the requested position */
|
2002-06-01 01:06:46 +02:00
|
|
|
/* FIXME: I'm not sure this is correct, notably because some data linked to
|
2008-04-21 07:17:27 +02:00
|
|
|
* the decompression state machine will not be correctly initialized.
|
|
|
|
* Try it this way (other way would be to decompress from 0 up to dwPosition
|
|
|
|
* and to start sending to hWave when dwPosition is reached).
|
2000-10-20 00:36:54 +02:00
|
|
|
*/
|
|
|
|
mmioSeek(wmw->hFile, wmw->ckWaveData.dwDataOffset + wmw->dwPosition, SEEK_SET); /* >= 0 */
|
|
|
|
|
|
|
|
/* By default the device will be opened for output, the MCI_CUE function is there to
|
|
|
|
* change from output to input and back
|
|
|
|
*/
|
|
|
|
/* FIXME: how to choose between several output channels ? here mapper is forced */
|
2002-10-19 19:20:02 +02:00
|
|
|
dwRet = waveInOpen((HWAVEIN*)&wmw->hWave, WAVE_MAPPER, wmw->lpWaveFormat,
|
2007-05-31 16:01:28 +02:00
|
|
|
(DWORD_PTR)WAVE_mciRecordCallback, (DWORD_PTR)wmw, CALLBACK_FUNCTION);
|
2000-10-20 00:36:54 +02:00
|
|
|
|
2003-01-11 23:47:21 +01:00
|
|
|
if (dwRet != MMSYSERR_NOERROR) {
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("Can't open low level audio device %d\n", dwRet);
|
2000-10-20 00:36:54 +02:00
|
|
|
dwRet = MCIERR_DEVICE_OPEN;
|
|
|
|
wmw->hWave = 0;
|
|
|
|
goto cleanUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make it so that 3 buffers per second are needed */
|
|
|
|
bufsize = WAVE_ALIGN_ON_BLOCK(wmw, wmw->lpWaveFormat->nAvgBytesPerSec / 3);
|
|
|
|
|
|
|
|
waveHdr = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(WAVEHDR) + 2 * bufsize);
|
|
|
|
waveHdr[0].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR);
|
|
|
|
waveHdr[1].lpData = (char*)waveHdr + 2 * sizeof(WAVEHDR) + bufsize;
|
|
|
|
waveHdr[0].dwUser = waveHdr[1].dwUser = 0L;
|
|
|
|
waveHdr[0].dwLoops = waveHdr[1].dwLoops = 0L;
|
|
|
|
waveHdr[0].dwFlags = waveHdr[1].dwFlags = 0L;
|
|
|
|
waveHdr[0].dwBufferLength = waveHdr[1].dwBufferLength = bufsize;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (waveInPrepareHeader(wmw->hWave, &waveHdr[0], sizeof(WAVEHDR)) ||
|
2000-10-20 00:36:54 +02:00
|
|
|
waveInPrepareHeader(wmw->hWave, &waveHdr[1], sizeof(WAVEHDR))) {
|
|
|
|
dwRet = MCIERR_INTERNAL;
|
|
|
|
goto cleanUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (waveInAddBuffer(wmw->hWave, &waveHdr[0], sizeof(WAVEHDR)) ||
|
|
|
|
waveInAddBuffer(wmw->hWave, &waveHdr[1], sizeof(WAVEHDR))) {
|
|
|
|
dwRet = MCIERR_INTERNAL;
|
|
|
|
goto cleanUp;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-01-07 16:40:09 +01:00
|
|
|
wmw->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
|
2000-10-20 00:36:54 +02:00
|
|
|
wmw->dwEventCount = 1L; /* for first buffer */
|
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("Recording (normalized) from byte=%u for %u bytes\n", wmw->dwPosition, end - wmw->dwPosition);
|
2000-10-20 00:36:54 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
dwRet = waveInStart(wmw->hWave);
|
|
|
|
|
2009-10-17 10:08:43 +02:00
|
|
|
if (hEvent) SetEvent(hEvent);
|
|
|
|
|
2003-01-11 23:47:21 +01:00
|
|
|
while (wmw->dwPosition < end && wmw->dwStatus != MCI_MODE_STOP && wmw->dwStatus != MCI_MODE_NOT_READY) {
|
2002-06-01 01:06:46 +02:00
|
|
|
WAVE_mciRecordWaitDone(wmw);
|
2000-10-20 00:36:54 +02:00
|
|
|
}
|
2009-11-10 08:40:55 +01:00
|
|
|
/* Grab callback before another thread kicks in after we change dwStatus. */
|
|
|
|
if (dwFlags & MCI_NOTIFY) {
|
|
|
|
oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL);
|
|
|
|
dwFlags &= ~MCI_NOTIFY;
|
|
|
|
}
|
2001-04-14 00:27:11 +02:00
|
|
|
/* needed so that the callback above won't add again the buffers returned by the reset */
|
|
|
|
wmw->dwStatus = MCI_MODE_STOP;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
waveInReset(wmw->hWave);
|
2001-04-14 00:27:11 +02:00
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
waveInUnprepareHeader(wmw->hWave, &waveHdr[0], sizeof(WAVEHDR));
|
|
|
|
waveInUnprepareHeader(wmw->hWave, &waveHdr[1], sizeof(WAVEHDR));
|
|
|
|
|
|
|
|
dwRet = 0;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
cleanUp:
|
2009-11-10 08:40:55 +01:00
|
|
|
if (dwFlags & MCI_NOTIFY)
|
|
|
|
oldcb = InterlockedExchangePointer(&wmw->hCallback, NULL);
|
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, waveHdr);
|
|
|
|
|
|
|
|
if (wmw->hWave) {
|
|
|
|
waveInClose(wmw->hWave);
|
|
|
|
wmw->hWave = 0;
|
|
|
|
}
|
|
|
|
CloseHandle(wmw->hEvent);
|
|
|
|
|
2009-10-17 16:41:10 +02:00
|
|
|
wmw->dwStatus = MCI_MODE_STOP;
|
|
|
|
|
2009-11-10 08:40:55 +01:00
|
|
|
if (oldcb) mciDriverNotify(oldcb, wDevID,
|
|
|
|
dwRet ? MCI_NOTIFY_FAILURE : MCI_NOTIFY_SUCCESSFUL);
|
2000-10-20 00:36:54 +02:00
|
|
|
|
|
|
|
return dwRet;
|
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciPause [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static DWORD WAVE_mciPause(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
|
|
|
DWORD dwRet;
|
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-17 16:37:40 +02:00
|
|
|
switch (wmw->dwStatus) {
|
|
|
|
case MCI_MODE_PLAY:
|
|
|
|
dwRet = waveOutPause(wmw->hWave);
|
2009-10-17 21:30:33 +02:00
|
|
|
if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_PAUSE;
|
|
|
|
else { /* When playthread was not started yet, winmm not opened, error 5 MMSYSERR_INVALHANDLE */
|
|
|
|
ERR("waveOutPause error %d\n",dwRet);
|
|
|
|
dwRet = MCIERR_INTERNAL;
|
|
|
|
}
|
2009-10-17 16:37:40 +02:00
|
|
|
break;
|
|
|
|
case MCI_MODE_RECORD:
|
|
|
|
dwRet = waveInStop(wmw->hWave);
|
2009-10-17 21:30:33 +02:00
|
|
|
if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_PAUSE;
|
|
|
|
else {
|
|
|
|
ERR("waveInStop error %d\n",dwRet);
|
|
|
|
dwRet = MCIERR_INTERNAL;
|
|
|
|
}
|
2009-10-17 16:37:40 +02:00
|
|
|
break;
|
|
|
|
case MCI_MODE_PAUSE:
|
|
|
|
dwRet = MMSYSERR_NOERROR;
|
|
|
|
break;
|
|
|
|
default:
|
2009-10-17 21:30:33 +02:00
|
|
|
dwRet = MCIERR_NONAPPLICABLE_FUNCTION;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2009-11-10 08:40:55 +01:00
|
|
|
if (MMSYSERR_NOERROR==dwRet && (dwFlags & MCI_NOTIFY) && lpParms)
|
|
|
|
WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
|
2009-10-17 21:30:33 +02:00
|
|
|
return dwRet;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciResume [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static DWORD WAVE_mciResume(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2009-10-17 16:37:40 +02:00
|
|
|
DWORD dwRet;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-17 16:37:40 +02:00
|
|
|
switch (wmw->dwStatus) {
|
|
|
|
case MCI_MODE_PAUSE:
|
2009-10-17 21:30:33 +02:00
|
|
|
/* Only update dwStatus if wave* succeeds and will exchange buffers buffers. */
|
2009-10-17 16:37:40 +02:00
|
|
|
if (wmw->fInput) {
|
|
|
|
dwRet = waveInStart(wmw->hWave);
|
2009-10-17 21:30:33 +02:00
|
|
|
if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_RECORD;
|
|
|
|
else {
|
|
|
|
ERR("waveInStart error %d\n",dwRet);
|
|
|
|
dwRet = MCIERR_INTERNAL;
|
|
|
|
}
|
2009-10-17 16:37:40 +02:00
|
|
|
} else {
|
|
|
|
dwRet = waveOutRestart(wmw->hWave);
|
2009-10-17 21:30:33 +02:00
|
|
|
if (dwRet==MMSYSERR_NOERROR) wmw->dwStatus = MCI_MODE_PLAY;
|
|
|
|
else {
|
|
|
|
ERR("waveOutRestart error %d\n",dwRet);
|
|
|
|
dwRet = MCIERR_INTERNAL;
|
|
|
|
}
|
2009-10-17 16:37:40 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MCI_MODE_PLAY:
|
|
|
|
case MCI_MODE_RECORD:
|
|
|
|
dwRet = MMSYSERR_NOERROR;
|
|
|
|
break;
|
|
|
|
default:
|
2009-10-17 21:30:33 +02:00
|
|
|
dwRet = MCIERR_NONAPPLICABLE_FUNCTION;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2009-11-10 08:40:55 +01:00
|
|
|
if (MMSYSERR_NOERROR==dwRet && (dwFlags & MCI_NOTIFY) && lpParms)
|
|
|
|
WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
|
2009-10-17 21:30:33 +02:00
|
|
|
return dwRet;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciSeek [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static DWORD WAVE_mciSeek(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2009-10-21 16:54:33 +02:00
|
|
|
DWORD position, dwRet;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("(%04X, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-11-07 08:34:16 +01:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
|
|
|
|
2009-10-21 16:54:33 +02:00
|
|
|
position = dwFlags & (MCI_SEEK_TO_START|MCI_SEEK_TO_END|MCI_TO);
|
|
|
|
if (!position) return MCIERR_MISSING_PARAMETER;
|
|
|
|
if (position&(position-1)) return MCIERR_FLAGS_NOT_COMPATIBLE;
|
2009-11-07 08:34:16 +01:00
|
|
|
|
2009-10-21 16:54:33 +02:00
|
|
|
/* Stop sends MCI_NOTIFY_ABORTED when needed */
|
|
|
|
dwRet = WAVE_mciStop(wDevID, MCI_WAIT, 0);
|
|
|
|
if (dwRet != MMSYSERR_NOERROR) return dwRet;
|
|
|
|
|
|
|
|
if (dwFlags & MCI_TO) {
|
|
|
|
position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo);
|
|
|
|
if (position > wmw->ckWaveData.cksize)
|
|
|
|
return MCIERR_OUTOFRANGE;
|
|
|
|
} else if (dwFlags & MCI_SEEK_TO_START) {
|
|
|
|
position = 0;
|
1998-11-24 17:36:18 +01:00
|
|
|
} else {
|
2009-10-21 16:54:33 +02:00
|
|
|
position = wmw->ckWaveData.cksize;
|
2009-11-07 08:34:16 +01:00
|
|
|
}
|
2009-10-21 16:54:33 +02:00
|
|
|
/* Seek rounds down, unless at end */
|
|
|
|
if (position != wmw->ckWaveData.cksize) {
|
|
|
|
position /= wmw->lpWaveFormat->nBlockAlign;
|
|
|
|
position *= wmw->lpWaveFormat->nBlockAlign;
|
|
|
|
}
|
|
|
|
wmw->dwPosition = position;
|
|
|
|
TRACE("Seeking to position=%u bytes\n", position);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-11-10 08:40:55 +01:00
|
|
|
if (dwFlags & MCI_NOTIFY)
|
|
|
|
WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
|
|
|
|
|
2009-11-07 08:34:16 +01:00
|
|
|
return MMSYSERR_NOERROR;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1998-11-24 17:36:18 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciSet [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static DWORD WAVE_mciSet(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-01 09:27:22 +01:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
1998-11-24 17:36:18 +01:00
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (dwFlags & MCI_SET_TIME_FORMAT) {
|
|
|
|
switch (lpParms->dwTimeFormat) {
|
|
|
|
case MCI_FORMAT_MILLISECONDS:
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_FORMAT_MILLISECONDS !\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
wmw->dwMciTimeFormat = MCI_FORMAT_MILLISECONDS;
|
|
|
|
break;
|
|
|
|
case MCI_FORMAT_BYTES:
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_FORMAT_BYTES !\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
wmw->dwMciTimeFormat = MCI_FORMAT_BYTES;
|
|
|
|
break;
|
|
|
|
case MCI_FORMAT_SAMPLES:
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_FORMAT_SAMPLES !\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
wmw->dwMciTimeFormat = MCI_FORMAT_SAMPLES;
|
|
|
|
break;
|
|
|
|
default:
|
2006-10-12 21:34:28 +02:00
|
|
|
WARN("Bad time format %u!\n", lpParms->dwTimeFormat);
|
1998-11-24 17:36:18 +01:00
|
|
|
return MCIERR_BAD_TIME_FORMAT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dwFlags & MCI_SET_VIDEO) {
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("No support for video !\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
return MCIERR_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
if (dwFlags & MCI_SET_DOOR_OPEN) {
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("No support for door open !\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
return MCIERR_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
if (dwFlags & MCI_SET_DOOR_CLOSED) {
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("No support for door close !\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
return MCIERR_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
|
|
|
if (dwFlags & MCI_SET_AUDIO) {
|
|
|
|
if (dwFlags & MCI_SET_ON) {
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_SET_ON audio !\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
} else if (dwFlags & MCI_SET_OFF) {
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_SET_OFF audio !\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
} else {
|
1999-05-24 10:18:53 +02:00
|
|
|
WARN("MCI_SET_AUDIO without SET_ON or SET_OFF\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
return MCIERR_BAD_INTEGER;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-02-09 23:26:25 +01:00
|
|
|
switch (lpParms->dwAudio)
|
|
|
|
{
|
|
|
|
case MCI_SET_AUDIO_ALL: TRACE("MCI_SET_AUDIO_ALL !\n"); break;
|
|
|
|
case MCI_SET_AUDIO_LEFT: TRACE("MCI_SET_AUDIO_LEFT !\n"); break;
|
|
|
|
case MCI_SET_AUDIO_RIGHT: TRACE("MCI_SET_AUDIO_RIGHT !\n"); break;
|
2006-10-12 21:34:28 +02:00
|
|
|
default: WARN("Unknown audio channel %u\n", lpParms->dwAudio); break;
|
2005-02-09 23:26:25 +01:00
|
|
|
}
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if (dwFlags & MCI_WAVE_INPUT)
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_WAVE_INPUT !\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
if (dwFlags & MCI_WAVE_OUTPUT)
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_WAVE_OUTPUT !\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
if (dwFlags & MCI_WAVE_SET_ANYINPUT)
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_WAVE_SET_ANYINPUT !\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
if (dwFlags & MCI_WAVE_SET_ANYOUTPUT)
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_WAVE_SET_ANYOUTPUT !\n");
|
2009-10-18 19:04:14 +02:00
|
|
|
/* Set wave format parameters is refused after Open or Record.*/
|
2009-10-18 18:31:15 +02:00
|
|
|
if (dwFlags & MCI_WAVE_SET_FORMATTAG) {
|
|
|
|
TRACE("MCI_WAVE_SET_FORMATTAG = %d\n", ((LPMCI_WAVE_SET_PARMS)lpParms)->wFormatTag);
|
2009-10-18 19:04:14 +02:00
|
|
|
if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION;
|
2009-10-18 18:31:15 +02:00
|
|
|
if (((LPMCI_WAVE_SET_PARMS)lpParms)->wFormatTag != WAVE_FORMAT_PCM)
|
|
|
|
return MCIERR_OUTOFRANGE;
|
|
|
|
}
|
2001-04-14 00:27:11 +02:00
|
|
|
if (dwFlags & MCI_WAVE_SET_AVGBYTESPERSEC) {
|
2009-10-18 19:04:14 +02:00
|
|
|
if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION;
|
2001-04-14 00:27:11 +02:00
|
|
|
wmw->wfxRef.nAvgBytesPerSec = ((LPMCI_WAVE_SET_PARMS)lpParms)->nAvgBytesPerSec;
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("MCI_WAVE_SET_AVGBYTESPERSEC = %d\n", wmw->wfxRef.nAvgBytesPerSec);
|
2001-04-14 00:27:11 +02:00
|
|
|
}
|
|
|
|
if (dwFlags & MCI_WAVE_SET_BITSPERSAMPLE) {
|
2009-10-18 19:04:14 +02:00
|
|
|
if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION;
|
2001-04-14 00:27:11 +02:00
|
|
|
wmw->wfxRef.wBitsPerSample = ((LPMCI_WAVE_SET_PARMS)lpParms)->wBitsPerSample;
|
|
|
|
TRACE("MCI_WAVE_SET_BITSPERSAMPLE = %d\n", wmw->wfxRef.wBitsPerSample);
|
|
|
|
}
|
|
|
|
if (dwFlags & MCI_WAVE_SET_BLOCKALIGN) {
|
2009-10-18 19:04:14 +02:00
|
|
|
if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION;
|
2001-04-14 00:27:11 +02:00
|
|
|
wmw->wfxRef.nBlockAlign = ((LPMCI_WAVE_SET_PARMS)lpParms)->nBlockAlign;
|
|
|
|
TRACE("MCI_WAVE_SET_BLOCKALIGN = %d\n", wmw->wfxRef.nBlockAlign);
|
|
|
|
}
|
|
|
|
if (dwFlags & MCI_WAVE_SET_CHANNELS) {
|
2009-10-18 19:04:14 +02:00
|
|
|
if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION;
|
2001-04-14 00:27:11 +02:00
|
|
|
wmw->wfxRef.nChannels = ((LPMCI_WAVE_SET_PARMS)lpParms)->nChannels;
|
|
|
|
TRACE("MCI_WAVE_SET_CHANNELS = %d\n", wmw->wfxRef.nChannels);
|
|
|
|
}
|
|
|
|
if (dwFlags & MCI_WAVE_SET_SAMPLESPERSEC) {
|
2009-10-18 19:04:14 +02:00
|
|
|
if (wmw->lpWaveFormat != &wmw->wfxRef) return MCIERR_NONAPPLICABLE_FUNCTION;
|
2001-04-14 00:27:11 +02:00
|
|
|
wmw->wfxRef.nSamplesPerSec = ((LPMCI_WAVE_SET_PARMS)lpParms)->nSamplesPerSec;
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("MCI_WAVE_SET_SAMPLESPERSEC = %d\n", wmw->wfxRef.nSamplesPerSec);
|
2001-04-14 00:27:11 +02:00
|
|
|
}
|
2009-11-10 08:40:55 +01:00
|
|
|
if (dwFlags & MCI_NOTIFY)
|
|
|
|
WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
|
1998-11-24 17:36:18 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciSave [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static DWORD WAVE_mciSave(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SAVE_PARMSW lpParms)
|
2000-10-20 00:36:54 +02:00
|
|
|
{
|
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2002-06-01 01:06:46 +02:00
|
|
|
DWORD ret = MCIERR_FILE_NOT_SAVED, tmpRet;
|
2000-10-20 00:36:54 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("%d, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
2000-10-20 00:36:54 +02:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
|
|
|
|
|
|
|
if (dwFlags & MCI_WAIT)
|
|
|
|
{
|
|
|
|
FIXME("MCI_WAIT not implemented\n");
|
|
|
|
}
|
2005-12-06 21:21:48 +01:00
|
|
|
WAVE_mciStop(wDevID, 0, NULL);
|
2000-10-20 00:36:54 +02:00
|
|
|
|
|
|
|
ret = mmioAscend(wmw->hFile, &wmw->ckWaveData, 0);
|
|
|
|
ret = mmioAscend(wmw->hFile, &wmw->ckMainRIFF, 0);
|
|
|
|
|
|
|
|
ret = mmioClose(wmw->hFile, 0);
|
2005-12-06 21:21:48 +01:00
|
|
|
wmw->hFile = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-03-24 00:39:28 +01:00
|
|
|
/*
|
|
|
|
If the destination file already exists, it has to be overwritten. (Behaviour
|
|
|
|
verified in Windows (2000)). If it doesn't overwrite, it is breaking one of
|
|
|
|
my applications. We are making use of mmioRename, which WILL NOT overwrite
|
|
|
|
the destination file (which is what Windows does, also verified in Win2K)
|
|
|
|
So, lets delete the destination file before calling mmioRename. If the
|
|
|
|
destination file DOESN'T exist, the delete will fail silently. Let's also be
|
|
|
|
careful not to lose our previous error code.
|
|
|
|
*/
|
|
|
|
tmpRet = GetLastError();
|
2005-02-09 23:26:25 +01:00
|
|
|
DeleteFileW (lpParms->lpfilename);
|
2001-03-24 00:39:28 +01:00
|
|
|
SetLastError(tmpRet);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-20 07:34:57 +02:00
|
|
|
/* FIXME: Open file.wav; Save; must not rename the original file.
|
|
|
|
* Nor must Save a.wav; Save b.wav rename a. */
|
2009-11-05 23:10:06 +01:00
|
|
|
if (0 == mmioRenameW(wmw->lpFileName, lpParms->lpfilename, 0, 0 )) {
|
2005-12-06 21:21:48 +01:00
|
|
|
ret = MMSYSERR_NOERROR;
|
2000-10-20 00:36:54 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-11-10 08:40:55 +01:00
|
|
|
if (MMSYSERR_NOERROR==ret && (dwFlags & MCI_NOTIFY))
|
|
|
|
WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
|
2000-10-20 00:36:54 +02:00
|
|
|
|
2005-12-06 21:21:48 +01:00
|
|
|
if (ret == MMSYSERR_NOERROR)
|
|
|
|
ret = WAVE_mciOpenFile(wmw, lpParms->lpfilename);
|
|
|
|
|
2000-10-20 00:36:54 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciStatus [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static DWORD WAVE_mciStatus(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
1999-12-05 03:18:35 +01:00
|
|
|
DWORD ret = 0;
|
1999-07-24 12:45:24 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
1998-12-01 09:27:22 +01:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
1998-11-24 17:36:18 +01:00
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (dwFlags & MCI_STATUS_ITEM) {
|
1999-09-05 18:31:37 +02:00
|
|
|
switch (lpParms->dwItem) {
|
1998-11-24 17:36:18 +01:00
|
|
|
case MCI_STATUS_CURRENT_TRACK:
|
|
|
|
lpParms->dwReturn = 1;
|
2009-01-09 17:46:46 +01:00
|
|
|
TRACE("MCI_STATUS_CURRENT_TRACK => %lu\n", lpParms->dwReturn);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_STATUS_LENGTH:
|
1999-12-05 03:18:35 +01:00
|
|
|
if (!wmw->hFile) {
|
|
|
|
lpParms->dwReturn = 0;
|
|
|
|
return MCIERR_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
1998-11-24 17:36:18 +01:00
|
|
|
/* only one track in file is currently handled, so don't take care of MCI_TRACK flag */
|
2000-10-20 00:36:54 +02:00
|
|
|
lpParms->dwReturn = WAVE_ConvertByteToTimeFormat(wmw, wmw->ckWaveData.cksize, &ret);
|
2009-01-09 17:46:46 +01:00
|
|
|
TRACE("MCI_STATUS_LENGTH => %lu\n", lpParms->dwReturn);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_STATUS_MODE:
|
1999-07-24 12:45:24 +02:00
|
|
|
TRACE("MCI_STATUS_MODE => %u\n", wmw->dwStatus);
|
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(wmw->dwStatus, wmw->dwStatus);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_STATUS_MEDIA_PRESENT:
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_STATUS_MEDIA_PRESENT => TRUE!\n");
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_STATUS_NUMBER_OF_TRACKS:
|
|
|
|
/* only one track in file is currently handled, so don't take care of MCI_TRACK flag */
|
|
|
|
lpParms->dwReturn = 1;
|
2009-01-09 17:46:46 +01:00
|
|
|
TRACE("MCI_STATUS_NUMBER_OF_TRACKS => %lu\n", lpParms->dwReturn);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_STATUS_POSITION:
|
1999-12-05 03:18:35 +01:00
|
|
|
if (!wmw->hFile) {
|
|
|
|
lpParms->dwReturn = 0;
|
|
|
|
return MCIERR_UNSUPPORTED_FUNCTION;
|
|
|
|
}
|
1998-11-24 17:36:18 +01:00
|
|
|
/* only one track in file is currently handled, so don't take care of MCI_TRACK flag */
|
2002-06-01 01:06:46 +02:00
|
|
|
lpParms->dwReturn = WAVE_ConvertByteToTimeFormat(wmw,
|
1999-07-24 12:45:24 +02:00
|
|
|
(dwFlags & MCI_STATUS_START) ? 0 : wmw->dwPosition,
|
|
|
|
&ret);
|
2009-01-09 17:46:46 +01:00
|
|
|
TRACE("MCI_STATUS_POSITION %s => %lu\n",
|
1998-11-24 17:36:18 +01:00
|
|
|
(dwFlags & MCI_STATUS_START) ? "start" : "current", lpParms->dwReturn);
|
|
|
|
break;
|
|
|
|
case MCI_STATUS_READY:
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = (wmw->dwStatus == MCI_MODE_NOT_READY) ?
|
|
|
|
MAKEMCIRESOURCE(FALSE, MCI_FALSE) : MAKEMCIRESOURCE(TRUE, MCI_TRUE);
|
|
|
|
TRACE("MCI_STATUS_READY => %u!\n", LOWORD(lpParms->dwReturn));
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_STATUS_TIME_FORMAT:
|
2004-01-08 01:42:02 +01:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(wmw->dwMciTimeFormat, MCI_FORMAT_RETURN_BASE + wmw->dwMciTimeFormat);
|
2009-01-09 17:46:46 +01:00
|
|
|
TRACE("MCI_STATUS_TIME_FORMAT => %lu\n", lpParms->dwReturn);
|
1999-07-24 12:45:24 +02:00
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_WAVE_INPUT:
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_WAVE_INPUT !\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
lpParms->dwReturn = 0;
|
1999-12-05 03:18:35 +01:00
|
|
|
ret = MCIERR_WAVE_INPUTUNSPECIFIED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_WAVE_OUTPUT:
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_WAVE_OUTPUT !\n");
|
1999-12-05 03:18:35 +01:00
|
|
|
{
|
|
|
|
UINT id;
|
|
|
|
if (waveOutGetID(wmw->hWave, &id) == MMSYSERR_NOERROR) {
|
|
|
|
lpParms->dwReturn = id;
|
|
|
|
} else {
|
|
|
|
lpParms->dwReturn = 0;
|
2009-11-03 00:32:30 +01:00
|
|
|
ret = MCIERR_WAVE_OUTPUTUNSPECIFIED;
|
1999-12-05 03:18:35 +01:00
|
|
|
}
|
|
|
|
}
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
2009-10-18 19:04:14 +02:00
|
|
|
/* It is always ok to query wave format parameters,
|
|
|
|
* except on auto-open yield MCIERR_UNSUPPORTED_FUNCTION. */
|
1998-11-24 17:36:18 +01:00
|
|
|
case MCI_WAVE_STATUS_AVGBYTESPERSEC:
|
1999-12-05 03:18:35 +01:00
|
|
|
lpParms->dwReturn = wmw->lpWaveFormat->nAvgBytesPerSec;
|
2009-10-18 19:04:14 +02:00
|
|
|
TRACE("MCI_WAVE_STATUS_AVGBYTESPERSEC => %lu\n", lpParms->dwReturn);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_WAVE_STATUS_BITSPERSAMPLE:
|
1999-12-05 03:18:35 +01:00
|
|
|
lpParms->dwReturn = wmw->lpWaveFormat->wBitsPerSample;
|
2009-10-18 19:04:14 +02:00
|
|
|
TRACE("MCI_WAVE_STATUS_BITSPERSAMPLE => %lu\n", lpParms->dwReturn);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_WAVE_STATUS_BLOCKALIGN:
|
1999-12-05 03:18:35 +01:00
|
|
|
lpParms->dwReturn = wmw->lpWaveFormat->nBlockAlign;
|
2009-10-18 19:04:14 +02:00
|
|
|
TRACE("MCI_WAVE_STATUS_BLOCKALIGN => %lu\n", lpParms->dwReturn);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_WAVE_STATUS_CHANNELS:
|
1999-12-05 03:18:35 +01:00
|
|
|
lpParms->dwReturn = wmw->lpWaveFormat->nChannels;
|
2009-10-18 19:04:14 +02:00
|
|
|
TRACE("MCI_WAVE_STATUS_CHANNELS => %lu\n", lpParms->dwReturn);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_WAVE_STATUS_FORMATTAG:
|
1999-12-05 03:18:35 +01:00
|
|
|
lpParms->dwReturn = wmw->lpWaveFormat->wFormatTag;
|
2009-10-18 19:04:14 +02:00
|
|
|
TRACE("MCI_WAVE_FORMATTAG => %lu\n", lpParms->dwReturn);
|
|
|
|
break;
|
|
|
|
case MCI_WAVE_STATUS_SAMPLESPERSEC:
|
|
|
|
lpParms->dwReturn = wmw->lpWaveFormat->nSamplesPerSec;
|
|
|
|
TRACE("MCI_WAVE_STATUS_SAMPLESPERSEC => %lu\n", lpParms->dwReturn);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_WAVE_STATUS_LEVEL:
|
1999-05-24 10:18:53 +02:00
|
|
|
TRACE("MCI_WAVE_STATUS_LEVEL !\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
lpParms->dwReturn = 0xAAAA5555;
|
|
|
|
break;
|
|
|
|
default:
|
2006-10-12 21:34:28 +02:00
|
|
|
WARN("unknown command %08X !\n", lpParms->dwItem);
|
1998-11-24 17:36:18 +01:00
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
|
|
|
}
|
|
|
|
}
|
2009-11-10 08:40:55 +01:00
|
|
|
if ((dwFlags & MCI_NOTIFY) && HRESULT_CODE(ret)==0)
|
|
|
|
WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
|
1999-07-24 12:45:24 +02:00
|
|
|
return ret;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciGetDevCaps [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static DWORD WAVE_mciGetDevCaps(MCIDEVICEID wDevID, DWORD dwFlags,
|
1998-11-24 17:36:18 +01:00
|
|
|
LPMCI_GETDEVCAPS_PARMS lpParms)
|
|
|
|
{
|
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
1999-07-24 12:45:24 +02:00
|
|
|
DWORD ret = 0;
|
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-01 09:27:22 +01:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
1998-11-24 17:36:18 +01:00
|
|
|
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-11-24 17:36:18 +01:00
|
|
|
if (dwFlags & MCI_GETDEVCAPS_ITEM) {
|
|
|
|
switch(lpParms->dwItem) {
|
|
|
|
case MCI_GETDEVCAPS_DEVICE_TYPE:
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(MCI_DEVTYPE_WAVEFORM_AUDIO, MCI_DEVTYPE_WAVEFORM_AUDIO);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_GETDEVCAPS_HAS_AUDIO:
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_GETDEVCAPS_HAS_VIDEO:
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_GETDEVCAPS_USES_FILES:
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_GETDEVCAPS_COMPOUND_DEVICE:
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_GETDEVCAPS_CAN_RECORD:
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_GETDEVCAPS_CAN_EJECT:
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(FALSE, MCI_FALSE);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_GETDEVCAPS_CAN_PLAY:
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_GETDEVCAPS_CAN_SAVE:
|
1999-07-24 12:45:24 +02:00
|
|
|
lpParms->dwReturn = MAKEMCIRESOURCE(TRUE, MCI_TRUE);
|
|
|
|
ret = MCI_RESOURCE_RETURNED;
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
case MCI_WAVE_GETDEVCAPS_INPUTS:
|
|
|
|
lpParms->dwReturn = 1;
|
|
|
|
break;
|
|
|
|
case MCI_WAVE_GETDEVCAPS_OUTPUTS:
|
|
|
|
lpParms->dwReturn = 1;
|
|
|
|
break;
|
|
|
|
default:
|
2006-10-12 21:34:28 +02:00
|
|
|
FIXME("Unknown capability (%08x) !\n", lpParms->dwItem);
|
1998-11-24 17:36:18 +01:00
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
|
|
|
}
|
1999-07-24 12:45:24 +02:00
|
|
|
} else {
|
|
|
|
WARN("No GetDevCaps-Item !\n");
|
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
2009-11-10 08:40:55 +01:00
|
|
|
if ((dwFlags & MCI_NOTIFY) && HRESULT_CODE(ret)==0)
|
|
|
|
WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
|
1999-07-24 12:45:24 +02:00
|
|
|
return ret;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* WAVE_mciInfo [internal]
|
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
static DWORD WAVE_mciInfo(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_INFO_PARMSW lpParms)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
|
|
|
DWORD ret = 0;
|
2005-02-09 23:26:25 +01:00
|
|
|
LPCWSTR str = 0;
|
1998-11-24 17:36:18 +01:00
|
|
|
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("(%u, %08X, %p);\n", wDevID, dwFlags, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-10-17 17:44:21 +02:00
|
|
|
if (!lpParms || !lpParms->lpstrReturn)
|
|
|
|
return MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
|
|
|
|
if (wmw == NULL) {
|
1998-11-24 17:36:18 +01:00
|
|
|
ret = MCIERR_INVALID_DEVICE_ID;
|
|
|
|
} else {
|
2005-02-09 23:26:25 +01:00
|
|
|
static const WCHAR wszAudio [] = {'W','i','n','e','\'','s',' ','a','u','d','i','o',' ','p','l','a','y','e','r',0};
|
|
|
|
static const WCHAR wszWaveIn [] = {'W','i','n','e',' ','W','a','v','e',' ','I','n',0};
|
|
|
|
static const WCHAR wszWaveOut[] = {'W','i','n','e',' ','W','a','v','e',' ','O','u','t',0};
|
|
|
|
|
2006-10-12 21:34:28 +02:00
|
|
|
TRACE("buf=%p, len=%u\n", lpParms->lpstrReturn, lpParms->dwRetSize);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-12-06 00:09:49 +01:00
|
|
|
switch (dwFlags & ~(MCI_WAIT|MCI_NOTIFY)) {
|
2005-02-09 23:26:25 +01:00
|
|
|
case MCI_INFO_PRODUCT: str = wszAudio; break;
|
2009-11-05 23:10:06 +01:00
|
|
|
case MCI_INFO_FILE: str = wmw->lpFileName; break;
|
2005-02-09 23:26:25 +01:00
|
|
|
case MCI_WAVE_INPUT: str = wszWaveIn; break;
|
|
|
|
case MCI_WAVE_OUTPUT: str = wszWaveOut; break;
|
1998-11-24 17:36:18 +01:00
|
|
|
default:
|
2006-10-12 21:34:28 +02:00
|
|
|
WARN("Don't know this info command (%u)\n", dwFlags);
|
1999-02-13 13:38:09 +01:00
|
|
|
ret = MCIERR_UNRECOGNIZED_COMMAND;
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (str) {
|
2005-02-09 23:26:25 +01:00
|
|
|
if (strlenW(str) + 1 > lpParms->dwRetSize) {
|
1998-11-24 17:36:18 +01:00
|
|
|
ret = MCIERR_PARAM_OVERFLOW;
|
|
|
|
} else {
|
2005-02-09 23:26:25 +01:00
|
|
|
lstrcpynW(lpParms->lpstrReturn, str, lpParms->dwRetSize);
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lpParms->lpstrReturn[0] = 0;
|
|
|
|
}
|
2009-11-10 08:40:55 +01:00
|
|
|
if (MMSYSERR_NOERROR==ret && (dwFlags & MCI_NOTIFY))
|
|
|
|
WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
|
1998-11-24 17:36:18 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2001-07-11 20:56:41 +02:00
|
|
|
* DriverProc (MCIWAVE.@)
|
1998-11-24 17:36:18 +01:00
|
|
|
*/
|
2005-11-28 20:53:22 +01:00
|
|
|
LRESULT CALLBACK MCIWAVE_DriverProc(DWORD_PTR dwDevID, HDRVR hDriv, UINT wMsg,
|
|
|
|
LPARAM dwParam1, LPARAM dwParam2)
|
1998-11-24 17:36:18 +01:00
|
|
|
{
|
2005-11-28 20:53:22 +01:00
|
|
|
TRACE("(%08lX, %p, %08X, %08lX, %08lX)\n",
|
1998-11-24 17:36:18 +01:00
|
|
|
dwDevID, hDriv, wMsg, dwParam1, dwParam2);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-05-12 01:02:55 +02:00
|
|
|
switch (wMsg) {
|
1998-11-24 17:36:18 +01:00
|
|
|
case DRV_LOAD: return 1;
|
|
|
|
case DRV_FREE: return 1;
|
2005-02-09 23:26:25 +01:00
|
|
|
case DRV_OPEN: return WAVE_drvOpen((LPCWSTR)dwParam1, (LPMCI_OPEN_DRIVER_PARMSW)dwParam2);
|
1999-05-02 12:21:49 +02:00
|
|
|
case DRV_CLOSE: return WAVE_drvClose(dwDevID);
|
1998-11-24 17:36:18 +01:00
|
|
|
case DRV_ENABLE: return 1;
|
|
|
|
case DRV_DISABLE: return 1;
|
|
|
|
case DRV_QUERYCONFIGURE: return 1;
|
2009-10-31 09:11:55 +01:00
|
|
|
case DRV_CONFIGURE: MessageBoxA(0, "MCI waveaudio Driver !", "Wine Driver", MB_OK); return 1;
|
1998-11-24 17:36:18 +01:00
|
|
|
case DRV_INSTALL: return DRVCNF_RESTART;
|
|
|
|
case DRV_REMOVE: return DRVCNF_RESTART;
|
2002-05-12 01:02:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dwDevID == 0xFFFFFFFF) return MCIERR_UNSUPPORTED_FUNCTION;
|
|
|
|
|
|
|
|
switch (wMsg) {
|
2005-02-09 23:26:25 +01:00
|
|
|
case MCI_OPEN_DRIVER: return WAVE_mciOpen (dwDevID, dwParam1, (LPMCI_WAVE_OPEN_PARMSW) dwParam2);
|
1998-11-24 17:36:18 +01:00
|
|
|
case MCI_CLOSE_DRIVER: return WAVE_mciClose (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
|
|
|
|
case MCI_CUE: return WAVE_mciCue (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
|
2009-10-17 10:08:43 +02:00
|
|
|
case MCI_PLAY: return WAVE_mciPlay (dwDevID, dwParam1, dwParam2, NULL);
|
|
|
|
case MCI_RECORD: return WAVE_mciRecord (dwDevID, dwParam1, dwParam2, NULL);
|
1998-11-24 17:36:18 +01:00
|
|
|
case MCI_STOP: return WAVE_mciStop (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
|
|
|
|
case MCI_SET: return WAVE_mciSet (dwDevID, dwParam1, (LPMCI_SET_PARMS) dwParam2);
|
|
|
|
case MCI_PAUSE: return WAVE_mciPause (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
|
|
|
|
case MCI_RESUME: return WAVE_mciResume (dwDevID, dwParam1, (LPMCI_GENERIC_PARMS) dwParam2);
|
|
|
|
case MCI_STATUS: return WAVE_mciStatus (dwDevID, dwParam1, (LPMCI_STATUS_PARMS) dwParam2);
|
|
|
|
case MCI_GETDEVCAPS: return WAVE_mciGetDevCaps(dwDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS) dwParam2);
|
2005-02-09 23:26:25 +01:00
|
|
|
case MCI_INFO: return WAVE_mciInfo (dwDevID, dwParam1, (LPMCI_INFO_PARMSW) dwParam2);
|
2002-06-01 01:06:46 +02:00
|
|
|
case MCI_SEEK: return WAVE_mciSeek (dwDevID, dwParam1, (LPMCI_SEEK_PARMS) dwParam2);
|
2005-02-09 23:26:25 +01:00
|
|
|
case MCI_SAVE: return WAVE_mciSave (dwDevID, dwParam1, (LPMCI_SAVE_PARMSW) dwParam2);
|
1999-07-24 12:45:24 +02:00
|
|
|
/* commands that should be supported */
|
2002-06-01 01:06:46 +02:00
|
|
|
case MCI_LOAD:
|
|
|
|
case MCI_FREEZE:
|
|
|
|
case MCI_PUT:
|
|
|
|
case MCI_REALIZE:
|
|
|
|
case MCI_UNFREEZE:
|
|
|
|
case MCI_UPDATE:
|
|
|
|
case MCI_WHERE:
|
|
|
|
case MCI_STEP:
|
|
|
|
case MCI_SPIN:
|
|
|
|
case MCI_ESCAPE:
|
|
|
|
case MCI_COPY:
|
|
|
|
case MCI_CUT:
|
|
|
|
case MCI_DELETE:
|
|
|
|
case MCI_PASTE:
|
2005-11-28 20:53:22 +01:00
|
|
|
FIXME("Unsupported yet command [%u]\n", wMsg);
|
1999-07-24 12:45:24 +02:00
|
|
|
break;
|
1999-12-05 03:18:35 +01:00
|
|
|
case MCI_WINDOW:
|
2005-11-28 20:53:22 +01:00
|
|
|
TRACE("Unsupported command [%u]\n", wMsg);
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
2001-01-03 22:36:56 +01:00
|
|
|
/* option which can be silenced */
|
|
|
|
case MCI_CONFIGURE:
|
|
|
|
return 0;
|
1998-11-24 17:36:18 +01:00
|
|
|
case MCI_OPEN:
|
|
|
|
case MCI_CLOSE:
|
1999-07-24 12:45:24 +02:00
|
|
|
ERR("Shouldn't receive a MCI_OPEN or CLOSE message\n");
|
1998-11-24 17:36:18 +01:00
|
|
|
break;
|
|
|
|
default:
|
2005-11-28 20:53:22 +01:00
|
|
|
FIXME("is probably wrong msg [%u]\n", wMsg);
|
1999-02-26 12:11:13 +01:00
|
|
|
return DefDriverProc(dwDevID, hDriv, wMsg, dwParam1, dwParam2);
|
1998-11-24 17:36:18 +01:00
|
|
|
}
|
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
|
|
|
}
|