2003-09-27 04:21:12 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for capture functions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002 Francois Gouget
|
|
|
|
* Copyright (c) 2003 Robert Reif
|
|
|
|
*
|
|
|
|
* 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
|
2003-09-27 04:21:12 +02:00
|
|
|
*/
|
|
|
|
|
2012-08-16 01:22:58 +02:00
|
|
|
#define COBJMACROS
|
2003-10-09 00:35:26 +02:00
|
|
|
#include <stdio.h>
|
2008-07-08 16:17:17 +02:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "windows.h"
|
2003-09-27 04:21:12 +02:00
|
|
|
#include "wine/test.h"
|
2013-10-14 23:19:31 +02:00
|
|
|
#include "mmsystem.h"
|
2003-09-27 04:21:12 +02:00
|
|
|
#include "dsound.h"
|
2005-06-05 19:44:30 +02:00
|
|
|
#include "dsconf.h"
|
2003-09-27 04:21:12 +02:00
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
#include "dsound_test.h"
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
#define NOTIFICATIONS 5
|
|
|
|
|
2006-12-10 16:51:26 +01:00
|
|
|
static const char * get_format_str(WORD format)
|
2004-08-23 19:50:31 +02:00
|
|
|
{
|
|
|
|
static char msg[32];
|
|
|
|
#define WAVE_FORMAT(f) case f: return #f
|
|
|
|
switch (format) {
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_PCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_IBM_CVSD);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_ALAW);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_MULAW);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OKI_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_IMA_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_MEDIASPACE_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_SIERRA_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_G723_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DIGISTD);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DIGIFIX);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DIALOGIC_OKI_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_YAMAHA_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_SONARC);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DSPGROUP_TRUESPEECH);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_ECHOSC1);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF36);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_APTX);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF10);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DOLBY_AC2);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_GSM610);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_ANTEX_ADPCME);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_VQLPC);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DIGIREAL);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DIGIADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_CR10);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_NMS_VBXADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_G721_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_MPEG);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_MPEGLAYER3);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_ADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH8);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH10);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_FM_TOWNS_SND);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OLIGSM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OLIADPCM);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OLICELP);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OLISBC);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_OLIOPR);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_DEVELOPMENT);
|
|
|
|
WAVE_FORMAT(WAVE_FORMAT_EXTENSIBLE);
|
|
|
|
}
|
|
|
|
#undef WAVE_FORMAT
|
|
|
|
sprintf(msg, "Unknown(0x%04x)", format);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2005-11-18 13:04:36 +01:00
|
|
|
const char * format_string(const WAVEFORMATEX* wfx)
|
2003-10-09 00:35:26 +02:00
|
|
|
{
|
|
|
|
static char str[64];
|
|
|
|
|
2006-10-10 01:07:36 +02:00
|
|
|
sprintf(str, "%5dx%2dx%d %s",
|
2003-10-09 00:35:26 +02:00
|
|
|
wfx->nSamplesPerSec, wfx->wBitsPerSample, wfx->nChannels,
|
2004-08-23 19:50:31 +02:00
|
|
|
get_format_str(wfx->wFormatTag));
|
2003-10-09 00:35:26 +02:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2005-06-05 19:44:30 +02:00
|
|
|
static void IDirectSoundCapture_test(LPDIRECTSOUNDCAPTURE dsco,
|
|
|
|
BOOL initialized, LPCGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
DSCCAPS dsccaps;
|
|
|
|
int ref;
|
|
|
|
IUnknown * unknown;
|
|
|
|
IDirectSoundCapture * dsc;
|
|
|
|
|
|
|
|
/* Try to Query for objects */
|
|
|
|
rc=IDirectSoundCapture_QueryInterface(dsco, &IID_IUnknown,
|
|
|
|
(LPVOID*)&unknown);
|
|
|
|
ok(rc==DS_OK, "IDirectSoundCapture_QueryInterface(IID_IUnknown) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
if (rc==DS_OK)
|
2018-03-30 07:05:28 +02:00
|
|
|
IUnknown_Release(unknown);
|
2005-06-05 19:44:30 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundCapture_QueryInterface(dsco, &IID_IDirectSoundCapture,
|
|
|
|
(LPVOID*)&dsc);
|
|
|
|
ok(rc==DS_OK, "IDirectSoundCapture_QueryInterface(IID_IDirectSoundCapture) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
if (rc==DS_OK)
|
|
|
|
IDirectSoundCapture_Release(dsc);
|
|
|
|
|
|
|
|
if (initialized == FALSE) {
|
2006-11-12 19:51:37 +01:00
|
|
|
/* try uninitialized object */
|
2005-06-05 19:44:30 +02:00
|
|
|
rc=IDirectSoundCapture_GetCaps(dsco,0);
|
2005-11-18 13:04:36 +01:00
|
|
|
ok(rc==DSERR_UNINITIALIZED||rc==E_INVALIDARG,
|
|
|
|
"IDirectSoundCapture_GetCaps(NULL) should have returned "
|
2008-07-08 17:49:20 +02:00
|
|
|
"DSERR_UNINITIALIZED or E_INVALIDARG, returned: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
|
|
|
|
ok(rc==DSERR_UNINITIALIZED,"IDirectSoundCapture_GetCaps() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundCapture_Initialize(dsco, lpGuid);
|
2005-11-18 13:04:36 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||
|
|
|
|
rc==E_FAIL||rc==E_INVALIDARG,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSoundCapture_Initialize() failed: %08x\n", rc);
|
2005-11-18 13:04:36 +01:00
|
|
|
if (rc==DSERR_NODRIVER||rc==E_INVALIDARG) {
|
2005-06-05 19:44:30 +02:00
|
|
|
trace(" No Driver\n");
|
|
|
|
goto EXIT;
|
|
|
|
} else if (rc==E_FAIL) {
|
|
|
|
trace(" No Device\n");
|
|
|
|
goto EXIT;
|
|
|
|
} else if (rc==DSERR_ALLOCATED) {
|
|
|
|
trace(" Already In Use\n");
|
|
|
|
goto EXIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rc=IDirectSoundCapture_Initialize(dsco, lpGuid);
|
|
|
|
ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSoundCapture_Initialize() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_ALREADYINITIALIZED: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid caps buffer */
|
|
|
|
rc=IDirectSoundCapture_GetCaps(dsco, 0);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM, "IDirectSoundCapture_GetCaps(NULL) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
|
|
|
|
ZeroMemory(&dsccaps, sizeof(dsccaps));
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid caps buffer */
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
|
2005-06-05 19:44:30 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM, "IDirectSound_GetCaps() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
|
|
|
|
dsccaps.dwSize=sizeof(dsccaps);
|
|
|
|
|
|
|
|
/* DSOUND: Running on a certified driver */
|
|
|
|
rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK, "IDirectSoundCapture_GetCaps() failed: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSoundCapture_Release(dsco);
|
|
|
|
ok(ref==0, "IDirectSoundCapture_Release() has %d references, "
|
|
|
|
"should have 0\n", ref);
|
|
|
|
}
|
|
|
|
|
2012-01-12 00:36:08 +01:00
|
|
|
static void test_capture(void)
|
2005-06-05 19:44:30 +02:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUNDCAPTURE dsco=NULL;
|
2006-08-18 07:14:12 +02:00
|
|
|
LPCLASSFACTORY cf=NULL;
|
2005-06-05 19:44:30 +02:00
|
|
|
|
|
|
|
trace("Testing IDirectSoundCapture\n");
|
|
|
|
|
2006-08-18 07:14:12 +02:00
|
|
|
rc=CoGetClassObject(&CLSID_DirectSoundCapture, CLSCTX_INPROC_SERVER, NULL,
|
|
|
|
&IID_IClassFactory, (void**)&cf);
|
|
|
|
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n", rc);
|
2006-08-18 07:14:12 +02:00
|
|
|
|
|
|
|
rc=CoGetClassObject(&CLSID_DirectSoundCapture, CLSCTX_INPROC_SERVER, NULL,
|
|
|
|
&IID_IUnknown, (void**)&cf);
|
|
|
|
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSoundCapture, IID_IUnknown) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n", rc);
|
2006-08-18 07:14:12 +02:00
|
|
|
|
2005-06-05 19:44:30 +02:00
|
|
|
/* try the COM class factory method of creation with no device specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSoundCapture, (void**)&dsco);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %08x\n", rc);
|
2005-09-23 12:05:40 +02:00
|
|
|
if (rc==REGDB_E_CLASSNOTREG) {
|
|
|
|
trace(" Class Not Registered\n");
|
|
|
|
return;
|
|
|
|
}
|
2005-06-05 19:44:30 +02:00
|
|
|
if (dsco)
|
|
|
|
IDirectSoundCapture_test(dsco, FALSE, NULL);
|
|
|
|
|
|
|
|
/* try the COM class factory method of creation with default capture
|
|
|
|
* device specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSoundCapture, (void**)&dsco);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
if (dsco)
|
|
|
|
IDirectSoundCapture_test(dsco, FALSE, &DSDEVID_DefaultCapture);
|
|
|
|
|
|
|
|
/* try the COM class factory method of creation with default voice
|
|
|
|
* capture device specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSoundCapture, (void**)&dsco);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
if (dsco)
|
|
|
|
IDirectSoundCapture_test(dsco, FALSE, &DSDEVID_DefaultVoiceCapture);
|
|
|
|
|
|
|
|
/* try the COM class factory method of creation with a bad
|
|
|
|
* IID specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&CLSID_DirectSoundPrivate, (void**)&dsco);
|
|
|
|
ok(rc==E_NOINTERFACE,
|
|
|
|
"CoCreateInstance(CLSID_DirectSoundCapture,CLSID_DirectSoundPrivate) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have failed: %08x\n",rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
|
|
|
|
/* try with no device specified */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCaptureCreate(NULL, &dsco, NULL);
|
2005-06-05 19:44:30 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCaptureCreate(NULL) failed: %08x\n",rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
if (rc==S_OK && dsco)
|
|
|
|
IDirectSoundCapture_test(dsco, TRUE, NULL);
|
|
|
|
|
|
|
|
/* try with default capture device specified */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCaptureCreate(&DSDEVID_DefaultCapture, &dsco, NULL);
|
2005-06-05 19:44:30 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCaptureCreate(DSDEVID_DefaultCapture) failed: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
if (rc==DS_OK && dsco)
|
|
|
|
IDirectSoundCapture_test(dsco, TRUE, NULL);
|
|
|
|
|
|
|
|
/* try with default voice capture device specified */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCaptureCreate(&DSDEVID_DefaultVoiceCapture, &dsco, NULL);
|
2005-06-05 19:44:30 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCaptureCreate(DSDEVID_DefaultVoiceCapture) failed: %08x\n", rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
if (rc==DS_OK && dsco)
|
|
|
|
IDirectSoundCapture_test(dsco, TRUE, NULL);
|
|
|
|
|
|
|
|
/* try with a bad device specified */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCaptureCreate(&DSDEVID_DefaultVoicePlayback, &dsco, NULL);
|
2005-06-05 19:44:30 +02:00
|
|
|
ok(rc==DSERR_NODRIVER,
|
|
|
|
"DirectSoundCaptureCreate(DSDEVID_DefaultVoicePlatback) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have failed: %08x\n",rc);
|
2005-06-05 19:44:30 +02:00
|
|
|
if (rc==DS_OK && dsco)
|
|
|
|
IDirectSoundCapture_Release(dsco);
|
|
|
|
}
|
|
|
|
|
2003-09-27 04:21:12 +02:00
|
|
|
typedef struct {
|
|
|
|
char* wave;
|
|
|
|
DWORD wave_len;
|
|
|
|
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER dscbo;
|
|
|
|
LPWAVEFORMATEX wfx;
|
|
|
|
DSBPOSITIONNOTIFY posnotify[NOTIFICATIONS];
|
|
|
|
HANDLE event[NOTIFICATIONS];
|
|
|
|
LPDIRECTSOUNDNOTIFY notify;
|
|
|
|
|
|
|
|
DWORD buffer_size;
|
|
|
|
DWORD read;
|
|
|
|
DWORD offset;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
DWORD last_pos;
|
|
|
|
} capture_state_t;
|
|
|
|
|
2013-11-12 22:11:12 +01:00
|
|
|
static BOOL capture_buffer_service(capture_state_t* state)
|
2003-09-27 04:21:12 +02:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPVOID ptr1,ptr2;
|
|
|
|
DWORD len1,len2;
|
|
|
|
DWORD capture_pos,read_pos;
|
|
|
|
|
2004-08-18 22:53:40 +02:00
|
|
|
rc=IDirectSoundCaptureBuffer_GetCurrentPosition(state->dscbo,&capture_pos,
|
|
|
|
&read_pos);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetCurrentPosition() failed: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
if (rc!=DS_OK)
|
2013-11-12 22:11:12 +01:00
|
|
|
return FALSE;
|
2003-09-27 04:21:12 +02:00
|
|
|
|
2004-08-18 22:53:40 +02:00
|
|
|
rc=IDirectSoundCaptureBuffer_Lock(state->dscbo,state->offset,state->size,
|
|
|
|
&ptr1,&len1,&ptr2,&len2,0);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Lock() failed: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
if (rc!=DS_OK)
|
2013-11-12 22:11:12 +01:00
|
|
|
return FALSE;
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundCaptureBuffer_Unlock(state->dscbo,ptr1,len1,ptr2,len2);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Unlock() failed: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
if (rc!=DS_OK)
|
2013-11-12 22:11:12 +01:00
|
|
|
return FALSE;
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
state->offset = (state->offset + state->size) % state->buffer_size;
|
|
|
|
|
2013-11-12 22:11:12 +01:00
|
|
|
return TRUE;
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
2004-08-23 19:50:31 +02:00
|
|
|
static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco,
|
2003-09-27 04:21:12 +02:00
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER dscbo, int record)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
DSCBCAPS dscbcaps;
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
DWORD size,status;
|
|
|
|
capture_state_t state;
|
2004-08-18 22:53:40 +02:00
|
|
|
int i, ref;
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
/* Private dsound.dll: Error: Invalid caps pointer */
|
|
|
|
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,0);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetCaps() should "
|
2008-07-08 17:49:20 +02:00
|
|
|
"have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
/* Private dsound.dll: Error: Invalid caps pointer */
|
|
|
|
dscbcaps.dwSize=0;
|
|
|
|
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetCaps() should "
|
2008-07-08 17:49:20 +02:00
|
|
|
"have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
dscbcaps.dwSize=sizeof(dscbcaps);
|
|
|
|
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetCaps() failed: %08x\n", rc);
|
2004-08-23 19:50:31 +02:00
|
|
|
if (rc==DS_OK && winetest_debug > 1) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" Caps: size = %d flags=0x%08x buffer size=%d\n",
|
2003-09-27 04:21:12 +02:00
|
|
|
dscbcaps.dwSize,dscbcaps.dwFlags,dscbcaps.dwBufferBytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Query the format size. Note that it may not match sizeof(wfx) */
|
2004-08-23 19:50:31 +02:00
|
|
|
/* Private dsound.dll: Error: Either pwfxFormat or pdwSizeWritten must
|
|
|
|
* be non-NULL */
|
2003-09-27 04:21:12 +02:00
|
|
|
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,NULL,0,NULL);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetFormat() should "
|
2008-07-08 17:49:20 +02:00
|
|
|
"have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
size=0;
|
|
|
|
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,NULL,0,&size);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DS_OK && size!=0,"IDirectSoundCaptureBuffer_GetFormat() should "
|
2008-07-08 17:49:20 +02:00
|
|
|
"have returned the needed size: rc=%08x, size=%d\n", rc,size);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,&wfx,sizeof(wfx),NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetFormat() failed: %08x\n", rc);
|
2004-08-23 19:50:31 +02:00
|
|
|
if (rc==DS_OK && winetest_debug > 1) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" Format: tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
|
2003-09-27 04:21:12 +02:00
|
|
|
wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
|
|
|
|
wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Private dsound.dll: Error: Invalid status pointer */
|
|
|
|
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,0);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetStatus() should "
|
2008-07-08 17:49:20 +02:00
|
|
|
"have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc);
|
2004-08-23 19:50:31 +02:00
|
|
|
if (rc==DS_OK && winetest_debug > 1) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" Status=0x%04x\n",status);
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ZeroMemory(&state, sizeof(state));
|
|
|
|
state.dscbo=dscbo;
|
|
|
|
state.wfx=&wfx;
|
|
|
|
state.buffer_size = dscbcaps.dwBufferBytes;
|
|
|
|
for (i = 0; i < NOTIFICATIONS; i++)
|
2013-10-14 23:19:31 +02:00
|
|
|
state.event[i] = CreateEventW(NULL, FALSE, FALSE, NULL);
|
2003-09-27 04:21:12 +02:00
|
|
|
state.size = dscbcaps.dwBufferBytes / NOTIFICATIONS;
|
|
|
|
|
2004-08-18 22:53:40 +02:00
|
|
|
rc=IDirectSoundCaptureBuffer_QueryInterface(dscbo,&IID_IDirectSoundNotify,
|
|
|
|
(void **)&(state.notify));
|
|
|
|
ok((rc==DS_OK)&&(state.notify!=NULL),
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSoundCaptureBuffer_QueryInterface() failed: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
for (i = 0; i < NOTIFICATIONS; i++) {
|
|
|
|
state.posnotify[i].dwOffset = (i * state.size) + state.size - 1;
|
|
|
|
state.posnotify[i].hEventNotify = state.event[i];
|
|
|
|
}
|
|
|
|
|
2004-08-18 22:53:40 +02:00
|
|
|
rc=IDirectSoundNotify_SetNotificationPositions(state.notify,NOTIFICATIONS,
|
|
|
|
state.posnotify);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions() failed: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
2004-08-18 22:53:40 +02:00
|
|
|
ref=IDirectSoundNotify_Release(state.notify);
|
|
|
|
ok(ref==0,"IDirectSoundNotify_Release(): has %d references, should have "
|
|
|
|
"0\n",ref);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
2012-10-16 14:06:26 +02:00
|
|
|
rc=IDirectSoundCaptureBuffer_Start(dscbo,DSCBSTART_LOOPING);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc);
|
|
|
|
|
|
|
|
rc=IDirectSoundCaptureBuffer_Start(dscbo,0);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
2012-10-16 14:06:26 +02:00
|
|
|
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc);
|
2013-04-23 00:01:40 +02:00
|
|
|
ok(status==(DSCBSTATUS_CAPTURING|DSCBSTATUS_LOOPING) || broken(status==DSCBSTATUS_CAPTURING),
|
2012-10-16 14:06:26 +02:00
|
|
|
"GetStatus: bad status: %x\n",status);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
2012-10-16 14:06:26 +02:00
|
|
|
if (record) {
|
2003-09-27 04:21:12 +02:00
|
|
|
/* wait for the notifications */
|
|
|
|
for (i = 0; i < (NOTIFICATIONS * 2); i++) {
|
2005-01-09 18:27:44 +01:00
|
|
|
rc=WaitForMultipleObjects(NOTIFICATIONS,state.event,FALSE,3000);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==(WAIT_OBJECT_0+(i%NOTIFICATIONS)),
|
2006-10-10 01:07:36 +02:00
|
|
|
"WaitForMultipleObjects failed: 0x%x\n",rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
if (rc!=(WAIT_OBJECT_0+(i%NOTIFICATIONS))) {
|
2004-08-18 22:53:40 +02:00
|
|
|
ok((rc==WAIT_TIMEOUT)||(rc==WAIT_FAILED),
|
2006-10-10 01:07:36 +02:00
|
|
|
"Wrong notification: should be %d, got %d\n",
|
2003-09-27 04:21:12 +02:00
|
|
|
i%NOTIFICATIONS,rc-WAIT_OBJECT_0);
|
2004-04-06 22:08:54 +02:00
|
|
|
}
|
2003-09-27 04:21:12 +02:00
|
|
|
if (!capture_buffer_service(&state))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-10-16 14:06:26 +02:00
|
|
|
rc=IDirectSoundCaptureBuffer_Stop(dscbo);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
|
|
|
|
|
|
|
|
rc=IDirectSoundCaptureBuffer_Stop(dscbo);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
|
|
|
|
LPCSTR lpcstrModule, LPVOID lpContext)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUNDCAPTURE dsco=NULL;
|
|
|
|
LPDIRECTSOUNDCAPTUREBUFFER dscbo=NULL;
|
|
|
|
DSCBUFFERDESC bufdesc;
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
DSCCAPS dsccaps;
|
2004-08-09 20:52:18 +02:00
|
|
|
DWORD f;
|
|
|
|
int ref;
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
/* Private dsound.dll: Error: Invalid interface buffer */
|
2004-08-23 19:50:31 +02:00
|
|
|
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCaptureCreate(lpGuid, NULL, NULL);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCaptureCreate() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCaptureCreate(lpGuid, &dsco, NULL);
|
2005-02-18 13:52:14 +01:00
|
|
|
ok((rc==DS_OK)||(rc==DSERR_NODRIVER)||(rc==E_FAIL)||(rc==DSERR_ALLOCATED),
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCaptureCreate() failed: %08x\n",rc);
|
2004-10-19 23:10:41 +02:00
|
|
|
if (rc!=DS_OK) {
|
|
|
|
if (rc==DSERR_NODRIVER)
|
|
|
|
trace(" No Driver\n");
|
2005-02-18 13:52:14 +01:00
|
|
|
else if (rc==E_FAIL)
|
2005-02-23 13:43:38 +01:00
|
|
|
trace(" No Device\n");
|
2005-02-18 13:52:14 +01:00
|
|
|
else if (rc==DSERR_ALLOCATED)
|
|
|
|
trace(" Already In Use\n");
|
2003-09-27 04:21:12 +02:00
|
|
|
goto EXIT;
|
2004-10-19 23:10:41 +02:00
|
|
|
}
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
/* Private dsound.dll: Error: Invalid caps buffer */
|
|
|
|
rc=IDirectSoundCapture_GetCaps(dsco,NULL);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_GetCaps() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
/* Private dsound.dll: Error: Invalid caps buffer */
|
|
|
|
dsccaps.dwSize=0;
|
|
|
|
rc=IDirectSoundCapture_GetCaps(dsco,&dsccaps);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_GetCaps() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
dsccaps.dwSize=sizeof(dsccaps);
|
|
|
|
rc=IDirectSoundCapture_GetCaps(dsco,&dsccaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundCapture_GetCaps() failed: %08x\n", rc);
|
2004-08-23 19:50:31 +02:00
|
|
|
if (rc==DS_OK && winetest_debug > 1) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" Caps: size=%d flags=0x%08x formats=%05x channels=%d\n",
|
2004-08-18 22:53:40 +02:00
|
|
|
dsccaps.dwSize,dsccaps.dwFlags,dsccaps.dwFormats,
|
|
|
|
dsccaps.dwChannels);
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Private dsound.dll: Error: Invalid size */
|
|
|
|
/* Private dsound.dll: Error: Invalid capture buffer description */
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=0;
|
|
|
|
bufdesc.dwFlags=0;
|
|
|
|
bufdesc.dwBufferBytes=0;
|
|
|
|
bufdesc.dwReserved=0;
|
|
|
|
bufdesc.lpwfxFormat=NULL;
|
|
|
|
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Private dsound.dll: Error: Invalid buffer size */
|
|
|
|
/* Private dsound.dll: Error: Invalid capture buffer description */
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=0;
|
|
|
|
bufdesc.dwBufferBytes=0;
|
|
|
|
bufdesc.dwReserved=0;
|
|
|
|
bufdesc.lpwfxFormat=NULL;
|
|
|
|
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Private dsound.dll: Error: Invalid buffer size */
|
|
|
|
/* Private dsound.dll: Error: Invalid capture buffer description */
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
ZeroMemory(&wfx, sizeof(wfx));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=0;
|
|
|
|
bufdesc.dwBufferBytes=0;
|
|
|
|
bufdesc.dwReserved=0;
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
|
|
|
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Private dsound.dll: Error: Invalid buffer size */
|
|
|
|
/* Private dsound.dll: Error: Invalid capture buffer description */
|
2003-10-09 00:35:26 +02:00
|
|
|
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
|
2003-09-27 04:21:12 +02:00
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=0;
|
|
|
|
bufdesc.dwBufferBytes=0;
|
|
|
|
bufdesc.dwReserved=0;
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
|
|
|
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
2018-06-13 20:30:23 +02:00
|
|
|
for (f = 0; f < ARRAY_SIZE(formats); f++) {
|
2003-09-27 04:21:12 +02:00
|
|
|
dscbo=NULL;
|
2004-08-18 22:53:40 +02:00
|
|
|
init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
|
|
|
|
formats[f][2]);
|
2003-09-27 04:21:12 +02:00
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=0;
|
|
|
|
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
|
|
|
|
bufdesc.dwReserved=0;
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
2004-08-23 19:50:31 +02:00
|
|
|
if (winetest_interactive)
|
|
|
|
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
|
2003-09-27 04:21:12 +02:00
|
|
|
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
2008-10-23 07:51:09 +02:00
|
|
|
ok(((rc==DS_OK)&&(dscbo!=NULL))
|
|
|
|
|| rc==DSERR_BADFORMAT || rc==DSERR_INVALIDCALL || rc==DSERR_NODRIVER
|
|
|
|
|| rc==DSERR_ALLOCATED || rc==E_INVALIDARG || rc==E_FAIL,
|
2004-08-18 22:53:40 +02:00
|
|
|
"IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
|
2008-07-08 17:49:20 +02:00
|
|
|
"%s capture buffer: %08x\n",format_string(&wfx),rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
test_capture_buffer(dsco, dscbo, winetest_interactive);
|
|
|
|
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2004-10-22 21:51:54 +02:00
|
|
|
} else if (rc==DSERR_BADFORMAT) {
|
|
|
|
ok(!(dsccaps.dwFormats & formats[f][3]),
|
|
|
|
"IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
|
2004-10-25 23:45:51 +02:00
|
|
|
"capture buffer: format listed as supported but using it failed\n");
|
|
|
|
if (!(dsccaps.dwFormats & formats[f][3]))
|
2004-10-22 21:51:54 +02:00
|
|
|
trace(" Format not supported: %s\n", format_string(&wfx));
|
2005-06-21 22:21:39 +02:00
|
|
|
} else if (rc==DSERR_NODRIVER) {
|
|
|
|
trace(" No Driver\n");
|
2005-02-24 18:02:42 +01:00
|
|
|
} else if (rc==DSERR_ALLOCATED) {
|
2004-10-22 21:51:54 +02:00
|
|
|
trace(" Already In Use\n");
|
2005-02-24 18:02:42 +01:00
|
|
|
} else if (rc==E_INVALIDARG) { /* try the old version struct */
|
|
|
|
DSCBUFFERDESC1 bufdesc1;
|
|
|
|
ZeroMemory(&bufdesc1, sizeof(bufdesc1));
|
|
|
|
bufdesc1.dwSize=sizeof(bufdesc1);
|
|
|
|
bufdesc1.dwFlags=0;
|
|
|
|
bufdesc1.dwBufferBytes=wfx.nAvgBytesPerSec;
|
|
|
|
bufdesc1.dwReserved=0;
|
|
|
|
bufdesc1.lpwfxFormat=&wfx;
|
|
|
|
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,
|
|
|
|
(DSCBUFFERDESC*)&bufdesc1,&dscbo,NULL);
|
2008-10-23 07:18:09 +02:00
|
|
|
ok(rc==DS_OK || broken(rc==DSERR_INVALIDPARAM),
|
2005-02-24 18:02:42 +01:00
|
|
|
"IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
|
2008-07-08 17:49:20 +02:00
|
|
|
"%s capture buffer: %08x\n",format_string(&wfx), rc);
|
2008-10-23 07:18:09 +02:00
|
|
|
if (rc==DSERR_INVALIDPARAM) {
|
|
|
|
skip("broken driver\n");
|
|
|
|
goto EXIT;
|
|
|
|
}
|
2005-02-24 18:02:42 +01:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
test_capture_buffer(dsco, dscbo, winetest_interactive);
|
|
|
|
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
|
|
|
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d "
|
|
|
|
"references, should have 0\n",ref);
|
|
|
|
}
|
2007-11-10 14:55:47 +01:00
|
|
|
} else if (rc==E_FAIL) {
|
|
|
|
/* WAVE_FORMAT_PCM only allows 8 and 16 bits per sample, so only
|
|
|
|
* report a failure if the bits per sample is 8 or 16
|
|
|
|
*/
|
|
|
|
if (wfx.wBitsPerSample == 8 || wfx.wBitsPerSample == 16)
|
|
|
|
ok(FALSE,"Should not fail for 8 or 16 bits per sample\n");
|
2005-02-24 18:02:42 +01:00
|
|
|
}
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
2003-10-09 00:35:26 +02:00
|
|
|
/* try a non PCM format */
|
2007-01-11 15:53:41 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* FIXME: Why is this commented out? */
|
2003-10-09 00:35:26 +02:00
|
|
|
init_format(&wfx,WAVE_FORMAT_MULAW,8000,8,1);
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSCBCAPS_WAVEMAPPED;
|
|
|
|
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
|
|
|
|
bufdesc.dwReserved=0;
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
2004-08-23 19:50:31 +02:00
|
|
|
if (winetest_interactive)
|
|
|
|
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
|
2003-10-09 00:35:26 +02:00
|
|
|
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok((rc==DS_OK)&&(dscbo!=NULL),"IDirectSoundCapture_CreateCaptureBuffer() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed to create a capture buffer: %08x\n",rc);
|
2003-10-09 00:35:26 +02:00
|
|
|
if ((rc==DS_OK)&&(dscbo!=NULL)) {
|
|
|
|
test_capture_buffer(dsco, dscbo, winetest_interactive);
|
|
|
|
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2003-10-09 00:35:26 +02:00
|
|
|
}
|
2007-01-11 15:53:41 +01:00
|
|
|
}
|
2003-10-09 00:35:26 +02:00
|
|
|
|
2003-09-27 04:21:12 +02:00
|
|
|
/* Try an invalid format to test error handling */
|
2007-01-11 15:53:41 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* FIXME: Remove this test altogether? */
|
2003-10-09 00:35:26 +02:00
|
|
|
init_format(&wfx,WAVE_FORMAT_PCM,2000000,16,2);
|
2003-09-27 04:21:12 +02:00
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSCBCAPS_WAVEMAPPED;
|
|
|
|
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
|
|
|
|
bufdesc.dwReserved=0;
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
2004-08-23 19:50:31 +02:00
|
|
|
if (winetest_interactive)
|
|
|
|
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
|
2003-09-27 04:21:12 +02:00
|
|
|
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(rc!=DS_OK,"IDirectSoundCapture_CreateCaptureBuffer() should have failed "
|
2008-07-08 17:49:20 +02:00
|
|
|
"at 2 MHz %08x\n",rc);
|
2007-01-11 15:53:41 +01:00
|
|
|
}
|
2003-09-27 04:21:12 +02:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
if (dsco!=NULL) {
|
|
|
|
ref=IDirectSoundCapture_Release(dsco);
|
2004-08-18 22:53:40 +02:00
|
|
|
ok(ref==0,"IDirectSoundCapture_Release() has %d references, should "
|
|
|
|
"have 0\n",ref);
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-01-12 00:36:08 +01:00
|
|
|
static void test_enumerate(void)
|
2003-09-27 04:21:12 +02:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCaptureEnumerateA(dscenum_callback, NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"DirectSoundCaptureEnumerateA() failed: %08x\n", rc);
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|
|
|
|
|
2012-01-12 00:40:31 +01:00
|
|
|
static void test_COM(void)
|
|
|
|
{
|
|
|
|
IDirectSoundCapture *dsc = (IDirectSoundCapture*)0xdeadbeef;
|
|
|
|
IDirectSoundCaptureBuffer *buffer = (IDirectSoundCaptureBuffer*)0xdeadbeef;
|
|
|
|
IDirectSoundNotify *notify;
|
2012-08-16 01:22:58 +02:00
|
|
|
IUnknown *unk;
|
2012-01-12 00:40:31 +01:00
|
|
|
DSCBUFFERDESC bufdesc;
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG refcount;
|
|
|
|
|
2020-07-23 18:46:59 +02:00
|
|
|
hr = DirectSoundCaptureCreate(NULL, &dsc, (IUnknown *)0xdeadbeef);
|
2012-01-12 00:40:31 +01:00
|
|
|
ok(hr == DSERR_NOAGGREGATION,
|
|
|
|
"DirectSoundCaptureCreate failed: %08x, expected DSERR_NOAGGREGATION\n", hr);
|
|
|
|
ok(dsc == (IDirectSoundCapture*)0xdeadbeef, "dsc = %p\n", dsc);
|
|
|
|
|
2020-07-23 18:46:59 +02:00
|
|
|
hr = DirectSoundCaptureCreate(NULL, &dsc, NULL);
|
2012-01-12 00:40:31 +01:00
|
|
|
if (hr == DSERR_NODRIVER) {
|
|
|
|
skip("No driver\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(hr == DS_OK, "DirectSoundCaptureCreate failed: %08x, expected DS_OK\n", hr);
|
|
|
|
|
2012-08-16 01:22:58 +02:00
|
|
|
/* Different refcount for IDirectSoundCapture and for IUnknown */
|
|
|
|
refcount = IDirectSoundCapture_AddRef(dsc);
|
|
|
|
ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
|
|
|
|
hr = IDirectSoundCapture_QueryInterface(dsc, &IID_IUnknown, (void**)&unk);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
|
|
|
|
refcount = IUnknown_AddRef(unk);
|
|
|
|
ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
IDirectSoundCapture_Release(dsc);
|
|
|
|
|
2012-01-12 00:40:31 +01:00
|
|
|
init_format(&wfx, WAVE_FORMAT_PCM, 44100, 16, 1);
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize = sizeof(bufdesc);
|
|
|
|
bufdesc.dwBufferBytes = wfx.nAvgBytesPerSec;
|
|
|
|
bufdesc.lpwfxFormat = &wfx;
|
|
|
|
|
|
|
|
hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer, (IUnknown*)0xdeadbeef);
|
2012-02-13 21:37:38 +01:00
|
|
|
if (hr == E_INVALIDARG) {
|
|
|
|
/* Old DirectX has only the 1st version of the DSCBUFFERDESC struct */
|
|
|
|
bufdesc.dwSize = sizeof(DSCBUFFERDESC1);
|
|
|
|
hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer, (IUnknown*)0xdeadbeef);
|
|
|
|
}
|
2012-01-12 00:40:31 +01:00
|
|
|
ok(hr == DSERR_NOAGGREGATION,
|
|
|
|
"IDirectSoundCapture_CreateCaptureBuffer failed: %08x, expected DSERR_NOAGGREGATION\n", hr);
|
2012-02-13 21:37:38 +01:00
|
|
|
ok(buffer == (IDirectSoundCaptureBuffer*)0xdeadbeef || !buffer /* Win2k without DirectX9 */,
|
|
|
|
"buffer = %p\n", buffer);
|
2012-01-12 00:40:31 +01:00
|
|
|
|
|
|
|
hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer, NULL);
|
|
|
|
ok(hr == DS_OK, "IDirectSoundCapture_CreateCaptureBuffer failed: %08x, expected DS_OK\n", hr);
|
|
|
|
|
|
|
|
/* IDirectSoundCaptureBuffer and IDirectSoundNotify have separate refcounts */
|
|
|
|
IDirectSoundCaptureBuffer_AddRef(buffer);
|
|
|
|
refcount = IDirectSoundCaptureBuffer_AddRef(buffer);
|
|
|
|
ok(refcount == 3, "IDirectSoundCaptureBuffer refcount is %u, expected 3\n", refcount);
|
|
|
|
hr = IDirectSoundCaptureBuffer_QueryInterface(buffer, &IID_IDirectSoundNotify, (void**)¬ify);
|
|
|
|
ok(hr == DS_OK, "IDirectSoundCapture_QueryInterface failed: %08x, expected DS_OK\n", hr);
|
|
|
|
refcount = IDirectSoundNotify_AddRef(notify);
|
|
|
|
ok(refcount == 2, "IDirectSoundNotify refcount is %u, expected 2\n", refcount);
|
|
|
|
IDirectSoundCaptureBuffer_AddRef(buffer);
|
|
|
|
refcount = IDirectSoundCaptureBuffer_Release(buffer);
|
|
|
|
ok(refcount == 3, "IDirectSoundCaptureBuffer refcount is %u, expected 3\n", refcount);
|
|
|
|
|
|
|
|
/* Release IDirectSoundCaptureBuffer while keeping IDirectSoundNotify alive */
|
|
|
|
while (IDirectSoundCaptureBuffer_Release(buffer) > 0);
|
|
|
|
refcount = IDirectSoundNotify_AddRef(notify);
|
|
|
|
ok(refcount == 3, "IDirectSoundNotify refcount is %u, expected 3\n", refcount);
|
|
|
|
refcount = IDirectSoundCaptureBuffer_AddRef(buffer);
|
|
|
|
ok(refcount == 1, "IDirectSoundCaptureBuffer refcount is %u, expected 1\n", refcount);
|
|
|
|
|
|
|
|
while (IDirectSoundNotify_Release(notify) > 0);
|
|
|
|
refcount = IDirectSoundCaptureBuffer_Release(buffer);
|
|
|
|
ok(refcount == 0, "IDirectSoundCaptureBuffer refcount is %u, expected 0\n", refcount);
|
|
|
|
refcount = IDirectSoundCapture_Release(dsc);
|
|
|
|
ok(refcount == 0, "IDirectSoundCapture refcount is %u, expected 0\n", refcount);
|
|
|
|
}
|
|
|
|
|
2003-09-27 04:21:12 +02:00
|
|
|
START_TEST(capture)
|
|
|
|
{
|
2005-01-09 17:34:00 +01:00
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2012-01-12 00:40:31 +01:00
|
|
|
test_COM();
|
2012-01-12 00:36:08 +01:00
|
|
|
test_capture();
|
|
|
|
test_enumerate();
|
|
|
|
|
2005-01-09 17:34:00 +01:00
|
|
|
CoUninitialize();
|
2003-09-27 04:21:12 +02:00
|
|
|
}
|