Allow MCI_SET to change waveFormat for recording.

Fixed buffer handling on recording end.
Fixed size of recorded data in mmio file.
This commit is contained in:
Eric Pouech 2001-04-13 22:27:11 +00:00 committed by Alexandre Julliard
parent 7a3ec5d705
commit b24ed627eb
1 changed files with 54 additions and 23 deletions

View File

@ -3,7 +3,7 @@
* Sample Wine Driver for MCI wave forms * Sample Wine Driver for MCI wave forms
* *
* Copyright 1994 Martin Ayotte * Copyright 1994 Martin Ayotte
* 1999 Eric Pouech * 1999,2000 Eric Pouech
* 2000 Francois Jacques * 2000 Francois Jacques
*/ */
@ -26,6 +26,7 @@ typedef struct {
BOOL fShareable; /* TRUE if first open was shareable */ BOOL fShareable; /* TRUE if first open was shareable */
HMMIO hFile; /* mmio file handle open as Element */ HMMIO hFile; /* mmio file handle open as Element */
MCI_WAVE_OPEN_PARMSA openParms; MCI_WAVE_OPEN_PARMSA openParms;
WAVEFORMATEX wfxRef;
LPWAVEFORMATEX lpWaveFormat; LPWAVEFORMATEX lpWaveFormat;
BOOL fInput; /* FALSE = Output, TRUE = Input */ BOOL fInput; /* FALSE = Output, TRUE = Input */
volatile WORD dwStatus; /* one from MCI_MODE_xxxx */ volatile WORD dwStatus; /* one from MCI_MODE_xxxx */
@ -127,6 +128,15 @@ static DWORD WAVE_drvOpen(LPSTR str, LPMCI_OPEN_DRIVER_PARMSA modp)
mciSetDriverData(wmw->wDevID, (DWORD)wmw); mciSetDriverData(wmw->wDevID, (DWORD)wmw);
modp->wCustomCommandTable = MCI_NO_COMMAND_TABLE; modp->wCustomCommandTable = MCI_NO_COMMAND_TABLE;
modp->wType = MCI_DEVTYPE_WAVEFORM_AUDIO; modp->wType = MCI_DEVTYPE_WAVEFORM_AUDIO;
wmw->wfxRef.wFormatTag = WAVE_FORMAT_PCM;
wmw->wfxRef.nChannels = 1; /* MONO */
wmw->wfxRef.nSamplesPerSec = 11025;
wmw->wfxRef.nAvgBytesPerSec = 11025;
wmw->wfxRef.nBlockAlign = 1;
wmw->wfxRef.wBitsPerSample = 8;
wmw->wfxRef.cbSize = 0; /* don't care */
return modp->wDeviceID; return modp->wDeviceID;
} }
@ -277,23 +287,20 @@ static DWORD WAVE_mciCreateRIFFSkeleton(WINE_MCIWAVE* wmw)
if (!lpWaveFormat) if (!lpWaveFormat)
{ {
TRACE("allocating waveformat with default waveformat 11khz/8bit/mono \n"); /* FIXME: for non PCM formats, the size of the waveFormat has to be
* gotten
*/
lpWaveFormat = wmw->lpWaveFormat = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*lpWaveFormat)); lpWaveFormat = wmw->lpWaveFormat = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*lpWaveFormat));
lpWaveFormat->wFormatTag = WAVE_FORMAT_PCM; memcpy(lpWaveFormat, &wmw->wfxRef, sizeof(wmw->wfxRef));
lpWaveFormat->nChannels = 1; /* MONO */
lpWaveFormat->nSamplesPerSec = 11025;
lpWaveFormat->nAvgBytesPerSec = 11025;
lpWaveFormat->nBlockAlign = 1;
lpWaveFormat->wBitsPerSample = 8;
lpWaveFormat->cbSize = 0; /* don't care */
} }
if (MMSYSERR_NOERROR != mmioCreateChunk(hmmio, &ckWaveFormat, 0)) if (MMSYSERR_NOERROR != mmioCreateChunk(hmmio, &ckWaveFormat, 0))
goto err; goto err;
/* only the first 16 bytes are serialized */ /* only the first 16 bytes are serialized */
/* wrong... for non PCM, the whole waveFormat is stored
*/
if (-1 == mmioWrite(hmmio, (HPCSTR) lpWaveFormat, 16)) if (-1 == mmioWrite(hmmio, (HPCSTR) lpWaveFormat, 16))
goto err; goto err;
@ -942,6 +949,9 @@ static DWORD WAVE_mciRecord(UINT wDevID, DWORD dwFlags, LPMCI_RECORD_PARMS lpPar
{ {
/* new RIFF file */ /* new RIFF file */
dwRet = WAVE_mciCreateRIFFSkeleton(wmw); dwRet = WAVE_mciCreateRIFFSkeleton(wmw);
} else
{
FIXME("Should descend into data chunk. Please report.\n");
} }
end = 0xFFFFFFFF; end = 0xFFFFFFFF;
@ -1024,7 +1034,11 @@ static DWORD WAVE_mciRecord(UINT wDevID, DWORD dwFlags, LPMCI_RECORD_PARMS lpPar
WAVE_mciRecordWaitDone(wmw); WAVE_mciRecordWaitDone(wmw);
} }
/* needed so that the callback above won't add again the buffers returned by the reset */
wmw->dwStatus = MCI_MODE_STOP;
waveInReset(wmw->hWave); waveInReset(wmw->hWave);
waveInUnprepareHeader(wmw->hWave, &waveHdr[0], sizeof(WAVEHDR)); waveInUnprepareHeader(wmw->hWave, &waveHdr[0], sizeof(WAVEHDR));
waveInUnprepareHeader(wmw->hWave, &waveHdr[1], sizeof(WAVEHDR)); waveInUnprepareHeader(wmw->hWave, &waveHdr[1], sizeof(WAVEHDR));
@ -1039,6 +1053,11 @@ cleanUp:
} }
CloseHandle(wmw->hEvent); CloseHandle(wmw->hEvent);
/* need to update the size of the data chunk */
if (mmioAscend(wmw->hFile, &wmw->ckWaveData, 0) != MMSYSERR_NOERROR) {
TRACE("failed on ascend\n");
}
if (lpParms && (dwFlags & MCI_NOTIFY)) { if (lpParms && (dwFlags & MCI_NOTIFY)) {
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
wmw->openParms.wDeviceID, wmw->openParms.wDeviceID,
@ -1201,18 +1220,30 @@ static DWORD WAVE_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
TRACE("MCI_WAVE_SET_ANYINPUT !\n"); TRACE("MCI_WAVE_SET_ANYINPUT !\n");
if (dwFlags & MCI_WAVE_SET_ANYOUTPUT) if (dwFlags & MCI_WAVE_SET_ANYOUTPUT)
TRACE("MCI_WAVE_SET_ANYOUTPUT !\n"); TRACE("MCI_WAVE_SET_ANYOUTPUT !\n");
if (dwFlags & MCI_WAVE_SET_AVGBYTESPERSEC) if (dwFlags & MCI_WAVE_SET_AVGBYTESPERSEC) {
TRACE("MCI_WAVE_SET_AVGBYTESPERSEC !\n"); wmw->wfxRef.nAvgBytesPerSec = ((LPMCI_WAVE_SET_PARMS)lpParms)->nAvgBytesPerSec;
if (dwFlags & MCI_WAVE_SET_BITSPERSAMPLE) TRACE("MCI_WAVE_SET_AVGBYTESPERSEC = %ld\n", wmw->wfxRef.nAvgBytesPerSec);
TRACE("MCI_WAVE_SET_BITSPERSAMPLE !\n"); }
if (dwFlags & MCI_WAVE_SET_BLOCKALIGN) if (dwFlags & MCI_WAVE_SET_BITSPERSAMPLE) {
TRACE("MCI_WAVE_SET_BLOCKALIGN !\n"); wmw->wfxRef.wBitsPerSample = ((LPMCI_WAVE_SET_PARMS)lpParms)->wBitsPerSample;
if (dwFlags & MCI_WAVE_SET_CHANNELS) TRACE("MCI_WAVE_SET_BITSPERSAMPLE = %d\n", wmw->wfxRef.wBitsPerSample);
TRACE("MCI_WAVE_SET_CHANNELS !\n"); }
if (dwFlags & MCI_WAVE_SET_FORMATTAG) if (dwFlags & MCI_WAVE_SET_BLOCKALIGN) {
TRACE("MCI_WAVE_SET_FORMATTAG !\n"); wmw->wfxRef.nBlockAlign = ((LPMCI_WAVE_SET_PARMS)lpParms)->nBlockAlign;
if (dwFlags & MCI_WAVE_SET_SAMPLESPERSEC) TRACE("MCI_WAVE_SET_BLOCKALIGN = %d\n", wmw->wfxRef.nBlockAlign);
TRACE("MCI_WAVE_SET_SAMPLESPERSEC !\n"); }
if (dwFlags & MCI_WAVE_SET_CHANNELS) {
wmw->wfxRef.nChannels = ((LPMCI_WAVE_SET_PARMS)lpParms)->nChannels;
TRACE("MCI_WAVE_SET_CHANNELS = %d\n", wmw->wfxRef.nChannels);
}
if (dwFlags & MCI_WAVE_SET_FORMATTAG) {
wmw->wfxRef.wFormatTag = ((LPMCI_WAVE_SET_PARMS)lpParms)->wFormatTag;
TRACE("MCI_WAVE_SET_FORMATTAG = %d\n", wmw->wfxRef.wFormatTag);
}
if (dwFlags & MCI_WAVE_SET_SAMPLESPERSEC) {
wmw->wfxRef.nSamplesPerSec = ((LPMCI_WAVE_SET_PARMS)lpParms)->nSamplesPerSec;
TRACE("MCI_WAVE_SET_SAMPLESPERSEC = %ld\n", wmw->wfxRef.nSamplesPerSec);
}
return 0; return 0;
} }