Fixed a bug where a capture device was used after it failed to open

due to a missing driver.
Added tests to try all possible combinations of sample rate, sample
size and mono/stereo.
This commit is contained in:
Robert Reif 2003-03-07 20:36:47 +00:00 committed by Alexandre Julliard
parent 26b9bcaba3
commit 5a1439cf23
1 changed files with 68 additions and 98 deletions

View File

@ -28,6 +28,34 @@
#include "initguid.h" #include "initguid.h"
#include "dsound.h" #include "dsound.h"
static const unsigned int formats[][3]={
{ 8000, 8, 1},
{ 8000, 8, 2},
{ 8000, 16, 1},
{ 8000, 16, 2},
{11025, 8, 1},
{11025, 8, 2},
{11025, 16, 1},
{11025, 16, 2},
{22050, 8, 1},
{22050, 8, 2},
{22050, 16, 1},
{22050, 16, 2},
{44100, 8, 1},
{44100, 8, 2},
{44100, 16, 1},
{44100, 16, 2},
{48000, 8, 1},
{48000, 8, 2},
{48000, 16, 1},
{48000, 16, 2},
{96000, 8, 1},
{96000, 8, 2},
{96000, 16, 1},
{96000, 16, 2}
};
#define NB_FORMATS (sizeof(formats)/sizeof(*formats))
/* The time slice determines how often we will service the buffer and the /* The time slice determines how often we will service the buffer and the
* buffer will be four time slices long * buffer will be four time slices long
*/ */
@ -371,6 +399,7 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
DSBUFFERDESC bufdesc; DSBUFFERDESC bufdesc;
WAVEFORMATEX wfx; WAVEFORMATEX wfx;
DSCAPS dscaps; DSCAPS dscaps;
int f;
trace("Testing %s - %s : %s\n",lpcstrDescription,lpcstrModule,wine_dbgstr_guid(lpGuid)); trace("Testing %s - %s : %s\n",lpcstrDescription,lpcstrModule,wine_dbgstr_guid(lpGuid));
rc=DirectSoundCreate(lpGuid,&dso,NULL); rc=DirectSoundCreate(lpGuid,&dso,NULL);
@ -418,34 +447,21 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
goto EXIT; goto EXIT;
/* Testing secondary buffers */ /* Testing secondary buffers */
init_format(&wfx,11025,8,1); for (f=0;f<NB_FORMATS;f++) {
bufdesc.dwSize=sizeof(bufdesc); init_format(&wfx,formats[f][0],formats[f][1],formats[f][2]);
bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec*BUFFER_LEN/1000; bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwReserved=0; bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec*BUFFER_LEN/1000;
bufdesc.lpwfxFormat=&wfx; bufdesc.dwReserved=0;
trace(" Testing a secondary buffer at %ldx%dx%d\n", bufdesc.lpwfxFormat=&wfx;
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels); trace(" Testing a secondary buffer at %ldx%dx%d\n",
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&dsbo,NULL); wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
ok(rc==DS_OK,"CreateSoundBuffer failed to create a secondary buffer 0x%lx\n",rc); rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&dsbo,NULL);
if (rc==DS_OK) { ok(rc==DS_OK,"CreateSoundBuffer failed to create a secondary buffer 0x%lx\n",rc);
test_buffer(dso,dsbo,0,winetest_interactive); if (rc==DS_OK) {
IDirectSoundBuffer_Release(dsbo); test_buffer(dso,dsbo,0,winetest_interactive);
} IDirectSoundBuffer_Release(dsbo);
}
init_format(&wfx,48000,16,2);
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec*BUFFER_LEN/1000;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
trace(" Testing a secondary buffer at %ldx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&dsbo,NULL);
ok(rc==DS_OK,"CreateSoundBuffer failed to create a secondary buffer 0x%lx\n",rc);
if (rc==DS_OK) {
test_buffer(dso,dsbo,0,winetest_interactive);
IDirectSoundBuffer_Release(dsbo);
} }
EXIT: EXIT:
@ -628,6 +644,7 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
DSCBUFFERDESC bufdesc; DSCBUFFERDESC bufdesc;
WAVEFORMATEX wfx; WAVEFORMATEX wfx;
DSCCAPS dsccaps; DSCCAPS dsccaps;
int f;
/* Private dsound.dll: Error: Invalid interface buffer */ /* Private dsound.dll: Error: Invalid interface buffer */
trace("Testing %s - %s : %s\n",lpcstrDescription,lpcstrModule,wine_dbgstr_guid(lpGuid)); trace("Testing %s - %s : %s\n",lpcstrDescription,lpcstrModule,wine_dbgstr_guid(lpGuid));
@ -638,7 +655,7 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
rc=DirectSoundCaptureCreate(lpGuid,&dsco,NULL); rc=DirectSoundCaptureCreate(lpGuid,&dsco,NULL);
ok((rc==DS_OK)||(rc==DSERR_NODRIVER),"DirectSoundCaptureCreate failed: 0x%lx\n",rc); ok((rc==DS_OK)||(rc==DSERR_NODRIVER),"DirectSoundCaptureCreate failed: 0x%lx\n",rc);
if ((rc!=DS_OK)&&(rc!=DSERR_NODRIVER)) if (rc!=DS_OK)
goto EXIT; goto EXIT;
/* Private dsound.dll: Error: Invalid caps buffer */ /* Private dsound.dll: Error: Invalid caps buffer */
@ -716,23 +733,27 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
IDirectSoundCaptureBuffer_Release(dscbo); IDirectSoundCaptureBuffer_Release(dscbo);
} }
init_format(&wfx,11025,8,1); for (f=0;f<NB_FORMATS;f++) {
ZeroMemory(&bufdesc, sizeof(bufdesc)); init_format(&wfx,formats[f][0],formats[f][1],formats[f][2]);
bufdesc.dwSize=sizeof(bufdesc); ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwFlags=0; bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec; bufdesc.dwFlags=0;
bufdesc.dwReserved=0; bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
bufdesc.lpwfxFormat=&wfx; bufdesc.dwReserved=0;
trace(" Testing the capture buffer at %ldx%dx%d\n", bufdesc.lpwfxFormat=&wfx;
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels); trace(" Testing the capture buffer at %ldx%dx%d\n",
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL); wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
ok(rc==DS_OK,"CreateCaptureBuffer failed to create a capture buffer 0x%lx\n",rc); rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
if (rc==DS_OK) { ok(rc==DS_OK,"CreateCaptureBuffer failed to create a capture buffer 0x%lx\n",rc);
test_capture_buffer(dsco, dscbo); if (rc==DS_OK) {
IDirectSoundCaptureBuffer_Release(dscbo); test_capture_buffer(dsco, dscbo);
IDirectSoundCaptureBuffer_Release(dscbo);
}
} }
init_format(&wfx,11025,8,1); /* Try an invalid format to test error handling */
#if 0
init_format(&wfx,2000000,16,2);
ZeroMemory(&bufdesc, sizeof(bufdesc)); ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSCBCAPS_WAVEMAPPED; bufdesc.dwFlags=DSCBCAPS_WAVEMAPPED;
@ -740,61 +761,10 @@ static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
bufdesc.dwReserved=0; bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx; bufdesc.lpwfxFormat=&wfx;
trace(" Testing the capture buffer at %ldx%dx%d\n", trace(" Testing the capture buffer at %ldx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels); wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL); rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DS_OK,"CreateCaptureBuffer failed to create a capture buffer 0x%lx\n",rc); ok(rc!=DS_OK,"CreateCaptureBuffer should have failed at 2 MHz 0x%lx\n",rc);
if (rc==DS_OK) { #endif
test_capture_buffer(dsco, dscbo);
IDirectSoundCaptureBuffer_Release(dscbo);
}
init_format(&wfx,11025,16,2);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=0;
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
trace(" Testing the capture buffer at %ldx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DS_OK,"CreateCaptureBuffer failed to create a capture buffer 0x%lx\n",rc);
if (rc==DS_OK) {
test_capture_buffer(dsco, dscbo);
IDirectSoundCaptureBuffer_Release(dscbo);
}
init_format(&wfx,11025,16,2);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSCBCAPS_WAVEMAPPED;
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
trace(" Testing the capture buffer at %ldx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DS_OK,"CreateCaptureBuffer failed to create a capture buffer 0x%lx\n",rc);
if (rc==DS_OK) {
test_capture_buffer(dsco, dscbo);
IDirectSoundCaptureBuffer_Release(dscbo);
}
init_format(&wfx,44100,16,1);
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSCBCAPS_WAVEMAPPED;
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
bufdesc.dwReserved=0;
bufdesc.lpwfxFormat=&wfx;
trace(" Testing the capture buffer at %ldx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
ok(rc==DS_OK,"CreateCaptureBuffer failed to create a capture buffer 0x%lx\n",rc);
if (rc==DS_OK) {
test_capture_buffer(dsco, dscbo);
IDirectSoundCaptureBuffer_Release(dscbo);
}
EXIT: EXIT:
if (dsco!=NULL) if (dsco!=NULL)