2 * Unit tests for capture functions
4 * Copyright (c) 2002 Francois Gouget
5 * Copyright (c) 2003 Robert Reif
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define NONAMELESSSTRUCT
23 #define NONAMELESSUNION
28 #include "wine/test.h"
33 #include "dsound_test.h"
35 #define NOTIFICATIONS 5
37 static HRESULT (WINAPI
*pDirectSoundCaptureCreate
)(LPCGUID
,LPDIRECTSOUNDCAPTURE
*,LPUNKNOWN
)=NULL
;
38 static HRESULT (WINAPI
*pDirectSoundCaptureEnumerateA
)(LPDSENUMCALLBACKA
,LPVOID
)=NULL
;
40 static const char * get_format_str(WORD format
)
43 #define WAVE_FORMAT(f) case f: return #f
45 WAVE_FORMAT(WAVE_FORMAT_PCM
);
46 WAVE_FORMAT(WAVE_FORMAT_ADPCM
);
47 WAVE_FORMAT(WAVE_FORMAT_IBM_CVSD
);
48 WAVE_FORMAT(WAVE_FORMAT_ALAW
);
49 WAVE_FORMAT(WAVE_FORMAT_MULAW
);
50 WAVE_FORMAT(WAVE_FORMAT_OKI_ADPCM
);
51 WAVE_FORMAT(WAVE_FORMAT_IMA_ADPCM
);
52 WAVE_FORMAT(WAVE_FORMAT_MEDIASPACE_ADPCM
);
53 WAVE_FORMAT(WAVE_FORMAT_SIERRA_ADPCM
);
54 WAVE_FORMAT(WAVE_FORMAT_G723_ADPCM
);
55 WAVE_FORMAT(WAVE_FORMAT_DIGISTD
);
56 WAVE_FORMAT(WAVE_FORMAT_DIGIFIX
);
57 WAVE_FORMAT(WAVE_FORMAT_DIALOGIC_OKI_ADPCM
);
58 WAVE_FORMAT(WAVE_FORMAT_YAMAHA_ADPCM
);
59 WAVE_FORMAT(WAVE_FORMAT_SONARC
);
60 WAVE_FORMAT(WAVE_FORMAT_DSPGROUP_TRUESPEECH
);
61 WAVE_FORMAT(WAVE_FORMAT_ECHOSC1
);
62 WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF36
);
63 WAVE_FORMAT(WAVE_FORMAT_APTX
);
64 WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF10
);
65 WAVE_FORMAT(WAVE_FORMAT_DOLBY_AC2
);
66 WAVE_FORMAT(WAVE_FORMAT_GSM610
);
67 WAVE_FORMAT(WAVE_FORMAT_ANTEX_ADPCME
);
68 WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_VQLPC
);
69 WAVE_FORMAT(WAVE_FORMAT_DIGIREAL
);
70 WAVE_FORMAT(WAVE_FORMAT_DIGIADPCM
);
71 WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_CR10
);
72 WAVE_FORMAT(WAVE_FORMAT_NMS_VBXADPCM
);
73 WAVE_FORMAT(WAVE_FORMAT_G721_ADPCM
);
74 WAVE_FORMAT(WAVE_FORMAT_MPEG
);
75 WAVE_FORMAT(WAVE_FORMAT_MPEGLAYER3
);
76 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_ADPCM
);
77 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH8
);
78 WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH10
);
79 WAVE_FORMAT(WAVE_FORMAT_FM_TOWNS_SND
);
80 WAVE_FORMAT(WAVE_FORMAT_OLIGSM
);
81 WAVE_FORMAT(WAVE_FORMAT_OLIADPCM
);
82 WAVE_FORMAT(WAVE_FORMAT_OLICELP
);
83 WAVE_FORMAT(WAVE_FORMAT_OLISBC
);
84 WAVE_FORMAT(WAVE_FORMAT_OLIOPR
);
85 WAVE_FORMAT(WAVE_FORMAT_DEVELOPMENT
);
86 WAVE_FORMAT(WAVE_FORMAT_EXTENSIBLE
);
89 sprintf(msg
, "Unknown(0x%04x)", format
);
93 static char * format_string(WAVEFORMATEX
* wfx
)
97 sprintf(str
, "%5ldx%2dx%d %s",
98 wfx
->nSamplesPerSec
, wfx
->wBitsPerSample
, wfx
->nChannels
,
99 get_format_str(wfx
->wFormatTag
));
108 LPDIRECTSOUNDCAPTUREBUFFER dscbo
;
110 DSBPOSITIONNOTIFY posnotify
[NOTIFICATIONS
];
111 HANDLE event
[NOTIFICATIONS
];
112 LPDIRECTSOUNDNOTIFY notify
;
122 static int capture_buffer_service(capture_state_t
* state
)
127 DWORD capture_pos
,read_pos
;
129 rc
=IDirectSoundCaptureBuffer_GetCurrentPosition(state
->dscbo
,&capture_pos
,
131 ok(rc
==DS_OK
,"IDirectSoundCaptureBuffer_GetCurrentPosition() failed: %s\n",
132 DXGetErrorString8(rc
));
136 rc
=IDirectSoundCaptureBuffer_Lock(state
->dscbo
,state
->offset
,state
->size
,
137 &ptr1
,&len1
,&ptr2
,&len2
,0);
138 ok(rc
==DS_OK
,"IDirectSoundCaptureBuffer_Lock() failed: %s\n",
139 DXGetErrorString8(rc
));
143 rc
=IDirectSoundCaptureBuffer_Unlock(state
->dscbo
,ptr1
,len1
,ptr2
,len2
);
144 ok(rc
==DS_OK
,"IDirectSoundCaptureBuffer_Unlock() failed: %s\n",
145 DXGetErrorString8(rc
));
149 state
->offset
= (state
->offset
+ state
->size
) % state
->buffer_size
;
154 static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco
,
155 LPDIRECTSOUNDCAPTUREBUFFER dscbo
, int record
)
161 capture_state_t state
;
164 /* Private dsound.dll: Error: Invalid caps pointer */
165 rc
=IDirectSoundCaptureBuffer_GetCaps(dscbo
,0);
166 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundCaptureBuffer_GetCaps() should "
167 "have returned DSERR_INVALIDPARAM, returned: %s\n",
168 DXGetErrorString8(rc
));
170 /* Private dsound.dll: Error: Invalid caps pointer */
172 rc
=IDirectSoundCaptureBuffer_GetCaps(dscbo
,&dscbcaps
);
173 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundCaptureBuffer_GetCaps() should "
174 "have returned DSERR_INVALIDPARAM, returned: %s\n",
175 DXGetErrorString8(rc
));
177 dscbcaps
.dwSize
=sizeof(dscbcaps
);
178 rc
=IDirectSoundCaptureBuffer_GetCaps(dscbo
,&dscbcaps
);
179 ok(rc
==DS_OK
,"IDirectSoundCaptureBuffer_GetCaps() failed: %s\n",
180 DXGetErrorString8(rc
));
181 if (rc
==DS_OK
&& winetest_debug
> 1) {
182 trace(" Caps: size = %ld flags=0x%08lx buffer size=%ld\n",
183 dscbcaps
.dwSize
,dscbcaps
.dwFlags
,dscbcaps
.dwBufferBytes
);
186 /* Query the format size. Note that it may not match sizeof(wfx) */
187 /* Private dsound.dll: Error: Either pwfxFormat or pdwSizeWritten must
189 rc
=IDirectSoundCaptureBuffer_GetFormat(dscbo
,NULL
,0,NULL
);
190 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundCaptureBuffer_GetFormat() should "
191 "have returned DSERR_INVALIDPARAM, returned: %s\n",
192 DXGetErrorString8(rc
));
195 rc
=IDirectSoundCaptureBuffer_GetFormat(dscbo
,NULL
,0,&size
);
196 ok(rc
==DS_OK
&& size
!=0,"IDirectSoundCaptureBuffer_GetFormat() should "
197 "have returned the needed size: rc=%s, size=%ld\n",
198 DXGetErrorString8(rc
),size
);
200 rc
=IDirectSoundCaptureBuffer_GetFormat(dscbo
,&wfx
,sizeof(wfx
),NULL
);
201 ok(rc
==DS_OK
,"IDirectSoundCaptureBuffer_GetFormat() failed: %s\n",
202 DXGetErrorString8(rc
));
203 if (rc
==DS_OK
&& winetest_debug
> 1) {
204 trace(" Format: tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
205 wfx
.wFormatTag
,wfx
.nSamplesPerSec
,wfx
.wBitsPerSample
,
206 wfx
.nChannels
,wfx
.nAvgBytesPerSec
,wfx
.nBlockAlign
);
209 /* Private dsound.dll: Error: Invalid status pointer */
210 rc
=IDirectSoundCaptureBuffer_GetStatus(dscbo
,0);
211 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundCaptureBuffer_GetStatus() should "
212 "have returned DSERR_INVALIDPARAM, returned: %s\n",
213 DXGetErrorString8(rc
));
215 rc
=IDirectSoundCaptureBuffer_GetStatus(dscbo
,&status
);
216 ok(rc
==DS_OK
,"IDirectSoundCaptureBuffer_GetStatus() failed: %s\n",
217 DXGetErrorString8(rc
));
218 if (rc
==DS_OK
&& winetest_debug
> 1) {
219 trace(" Status=0x%04lx\n",status
);
222 ZeroMemory(&state
, sizeof(state
));
225 state
.buffer_size
= dscbcaps
.dwBufferBytes
;
226 for (i
= 0; i
< NOTIFICATIONS
; i
++)
227 state
.event
[i
] = CreateEvent( NULL
, FALSE
, FALSE
, NULL
);
228 state
.size
= dscbcaps
.dwBufferBytes
/ NOTIFICATIONS
;
230 rc
=IDirectSoundCaptureBuffer_QueryInterface(dscbo
,&IID_IDirectSoundNotify
,
231 (void **)&(state
.notify
));
232 ok((rc
==DS_OK
)&&(state
.notify
!=NULL
),
233 "IDirectSoundCaptureBuffer_QueryInterface() failed: %s\n",
234 DXGetErrorString8(rc
));
238 for (i
= 0; i
< NOTIFICATIONS
; i
++) {
239 state
.posnotify
[i
].dwOffset
= (i
* state
.size
) + state
.size
- 1;
240 state
.posnotify
[i
].hEventNotify
= state
.event
[i
];
243 rc
=IDirectSoundNotify_SetNotificationPositions(state
.notify
,NOTIFICATIONS
,
245 ok(rc
==DS_OK
,"IDirectSoundNotify_SetNotificationPositions() failed: %s\n",
246 DXGetErrorString8(rc
));
250 ref
=IDirectSoundNotify_Release(state
.notify
);
251 ok(ref
==0,"IDirectSoundNotify_Release(): has %d references, should have "
257 rc
=IDirectSoundCaptureBuffer_Start(dscbo
,DSCBSTART_LOOPING
);
258 ok(rc
==DS_OK
,"IDirectSoundCaptureBuffer_Start() failed: %s\n",
259 DXGetErrorString8(rc
));
263 rc
=IDirectSoundCaptureBuffer_GetStatus(dscbo
,&status
);
264 ok(rc
==DS_OK
,"IDirectSoundCaptureBuffer_GetStatus() failed: %s\n",
265 DXGetErrorString8(rc
));
266 ok(status
==(DSCBSTATUS_CAPTURING
|DSCBSTATUS_LOOPING
),
267 "GetStatus: bad status: %lx\n",status
);
271 /* wait for the notifications */
272 for (i
= 0; i
< (NOTIFICATIONS
* 2); i
++) {
273 rc
=WaitForMultipleObjects(NOTIFICATIONS
,state
.event
,FALSE
,3000);
274 ok(rc
==(WAIT_OBJECT_0
+(i
%NOTIFICATIONS
)),
275 "WaitForMultipleObjects failed: 0x%lx\n",rc
);
276 if (rc
!=(WAIT_OBJECT_0
+(i
%NOTIFICATIONS
))) {
277 ok((rc
==WAIT_TIMEOUT
)||(rc
==WAIT_FAILED
),
278 "Wrong notification: should be %d, got %ld\n",
279 i
%NOTIFICATIONS
,rc
-WAIT_OBJECT_0
);
281 if (!capture_buffer_service(&state
))
285 rc
=IDirectSoundCaptureBuffer_Stop(dscbo
);
286 ok(rc
==DS_OK
,"IDirectSoundCaptureBuffer_Stop() failed: %s\n",
287 DXGetErrorString8(rc
));
293 static BOOL WINAPI
dscenum_callback(LPGUID lpGuid
, LPCSTR lpcstrDescription
,
294 LPCSTR lpcstrModule
, LPVOID lpContext
)
297 LPDIRECTSOUNDCAPTURE dsco
=NULL
;
298 LPDIRECTSOUNDCAPTUREBUFFER dscbo
=NULL
;
299 DSCBUFFERDESC bufdesc
;
305 /* Private dsound.dll: Error: Invalid interface buffer */
306 trace("*** Testing %s - %s ***\n",lpcstrDescription
,lpcstrModule
);
307 rc
=pDirectSoundCaptureCreate(lpGuid
,NULL
,NULL
);
308 ok(rc
==DSERR_INVALIDPARAM
,"DirectSoundCaptureCreate() should have "
309 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc
));
311 ref
=IDirectSoundCapture_Release(dsco
);
312 ok(ref
==0,"IDirectSoundCapture_Release() has %d references, should "
316 rc
=pDirectSoundCaptureCreate(lpGuid
,&dsco
,NULL
);
317 ok((rc
==DS_OK
)||(rc
==DSERR_NODRIVER
)||(rc
==E_FAIL
)||(rc
==DSERR_ALLOCATED
),
318 "DirectSoundCaptureCreate() failed: %s\n",DXGetErrorString8(rc
));
320 if (rc
==DSERR_NODRIVER
)
321 trace(" No Driver\n");
323 trace(" No Device\n");
324 else if (rc
==DSERR_ALLOCATED
)
325 trace(" Already In Use\n");
329 /* Private dsound.dll: Error: Invalid caps buffer */
330 rc
=IDirectSoundCapture_GetCaps(dsco
,NULL
);
331 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundCapture_GetCaps() should have "
332 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc
));
334 /* Private dsound.dll: Error: Invalid caps buffer */
336 rc
=IDirectSoundCapture_GetCaps(dsco
,&dsccaps
);
337 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundCapture_GetCaps() should have "
338 "returned DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc
));
340 dsccaps
.dwSize
=sizeof(dsccaps
);
341 rc
=IDirectSoundCapture_GetCaps(dsco
,&dsccaps
);
342 ok(rc
==DS_OK
,"IDirectSoundCapture_GetCaps() failed: %s\n",
343 DXGetErrorString8(rc
));
344 if (rc
==DS_OK
&& winetest_debug
> 1) {
345 trace(" Caps: size=%ld flags=0x%08lx formats=%05lx channels=%ld\n",
346 dsccaps
.dwSize
,dsccaps
.dwFlags
,dsccaps
.dwFormats
,
350 /* Private dsound.dll: Error: Invalid size */
351 /* Private dsound.dll: Error: Invalid capture buffer description */
352 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
355 bufdesc
.dwBufferBytes
=0;
356 bufdesc
.dwReserved
=0;
357 bufdesc
.lpwfxFormat
=NULL
;
358 rc
=IDirectSoundCapture_CreateCaptureBuffer(dsco
,&bufdesc
,&dscbo
,NULL
);
359 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundCapture_CreateCaptureBuffer() "
360 "should have returned DSERR_INVALIDPARAM, returned: %s\n",
361 DXGetErrorString8(rc
));
363 ref
=IDirectSoundCaptureBuffer_Release(dscbo
);
364 ok(ref
==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
365 "should have 0\n",ref
);
368 /* Private dsound.dll: Error: Invalid buffer size */
369 /* Private dsound.dll: Error: Invalid capture buffer description */
370 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
371 bufdesc
.dwSize
=sizeof(bufdesc
);
373 bufdesc
.dwBufferBytes
=0;
374 bufdesc
.dwReserved
=0;
375 bufdesc
.lpwfxFormat
=NULL
;
376 rc
=IDirectSoundCapture_CreateCaptureBuffer(dsco
,&bufdesc
,&dscbo
,NULL
);
377 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundCapture_CreateCaptureBuffer() "
378 "should have returned DSERR_INVALIDPARAM, returned %s\n",
379 DXGetErrorString8(rc
));
381 ref
=IDirectSoundCaptureBuffer_Release(dscbo
);
382 ok(ref
==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
383 "should have 0\n",ref
);
386 /* Private dsound.dll: Error: Invalid buffer size */
387 /* Private dsound.dll: Error: Invalid capture buffer description */
388 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
389 ZeroMemory(&wfx
, sizeof(wfx
));
390 bufdesc
.dwSize
=sizeof(bufdesc
);
392 bufdesc
.dwBufferBytes
=0;
393 bufdesc
.dwReserved
=0;
394 bufdesc
.lpwfxFormat
=&wfx
;
395 rc
=IDirectSoundCapture_CreateCaptureBuffer(dsco
,&bufdesc
,&dscbo
,NULL
);
396 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundCapture_CreateCaptureBuffer() "
397 "should have returned DSERR_INVALIDPARAM, returned :%s\n",
398 DXGetErrorString8(rc
));
400 ref
=IDirectSoundCaptureBuffer_Release(dscbo
);
401 ok(ref
==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
402 "should have 0\n",ref
);
405 /* Private dsound.dll: Error: Invalid buffer size */
406 /* Private dsound.dll: Error: Invalid capture buffer description */
407 init_format(&wfx
,WAVE_FORMAT_PCM
,11025,8,1);
408 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
409 bufdesc
.dwSize
=sizeof(bufdesc
);
411 bufdesc
.dwBufferBytes
=0;
412 bufdesc
.dwReserved
=0;
413 bufdesc
.lpwfxFormat
=&wfx
;
414 rc
=IDirectSoundCapture_CreateCaptureBuffer(dsco
,&bufdesc
,&dscbo
,NULL
);
415 ok(rc
==DSERR_INVALIDPARAM
,"IDirectSoundCapture_CreateCaptureBuffer() "
416 "should have returned DSERR_INVALIDPARAM, returned: %s\n",
417 DXGetErrorString8(rc
));
419 ref
=IDirectSoundCaptureBuffer_Release(dscbo
);
420 ok(ref
==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
421 "should have 0\n",ref
);
424 for (f
=0;f
<NB_FORMATS
;f
++) {
426 init_format(&wfx
,WAVE_FORMAT_PCM
,formats
[f
][0],formats
[f
][1],
428 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
429 bufdesc
.dwSize
=sizeof(bufdesc
);
431 bufdesc
.dwBufferBytes
=wfx
.nAvgBytesPerSec
;
432 bufdesc
.dwReserved
=0;
433 bufdesc
.lpwfxFormat
=&wfx
;
434 if (winetest_interactive
)
435 trace(" Testing the capture buffer at %s\n", format_string(&wfx
));
436 rc
=IDirectSoundCapture_CreateCaptureBuffer(dsco
,&bufdesc
,&dscbo
,NULL
);
437 ok(((rc
==DS_OK
)&&(dscbo
!=NULL
))||(rc
==DSERR_BADFORMAT
)||
438 (rc
==DSERR_ALLOCATED
)||(rc
==E_INVALIDARG
),
439 "IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
440 "%s capture buffer: %s\n",format_string(&wfx
),DXGetErrorString8(rc
));
442 test_capture_buffer(dsco
, dscbo
, winetest_interactive
);
443 ref
=IDirectSoundCaptureBuffer_Release(dscbo
);
444 ok(ref
==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
445 "should have 0\n",ref
);
446 } else if (rc
==DSERR_BADFORMAT
) {
447 ok(!(dsccaps
.dwFormats
& formats
[f
][3]),
448 "IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
449 "capture buffer: format listed as supported but using it failed\n");
450 if (!(dsccaps
.dwFormats
& formats
[f
][3]))
451 trace(" Format not supported: %s\n", format_string(&wfx
));
452 } else if (rc
==DSERR_ALLOCATED
) {
453 trace(" Already In Use\n");
454 } else if (rc
==E_INVALIDARG
) { /* try the old version struct */
455 DSCBUFFERDESC1 bufdesc1
;
456 ZeroMemory(&bufdesc1
, sizeof(bufdesc1
));
457 bufdesc1
.dwSize
=sizeof(bufdesc1
);
459 bufdesc1
.dwBufferBytes
=wfx
.nAvgBytesPerSec
;
460 bufdesc1
.dwReserved
=0;
461 bufdesc1
.lpwfxFormat
=&wfx
;
462 rc
=IDirectSoundCapture_CreateCaptureBuffer(dsco
,
463 (DSCBUFFERDESC
*)&bufdesc1
,&dscbo
,NULL
);
465 "IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
466 "%s capture buffer: %s\n",format_string(&wfx
),
467 DXGetErrorString8(rc
));
469 test_capture_buffer(dsco
, dscbo
, winetest_interactive
);
470 ref
=IDirectSoundCaptureBuffer_Release(dscbo
);
471 ok(ref
==0,"IDirectSoundCaptureBuffer_Release() has %d "
472 "references, should have 0\n",ref
);
477 /* try a non PCM format */
479 init_format(&wfx
,WAVE_FORMAT_MULAW
,8000,8,1);
480 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
481 bufdesc
.dwSize
=sizeof(bufdesc
);
482 bufdesc
.dwFlags
=DSCBCAPS_WAVEMAPPED
;
483 bufdesc
.dwBufferBytes
=wfx
.nAvgBytesPerSec
;
484 bufdesc
.dwReserved
=0;
485 bufdesc
.lpwfxFormat
=&wfx
;
486 if (winetest_interactive
)
487 trace(" Testing the capture buffer at %s\n", format_string(&wfx
));
488 rc
=IDirectSoundCapture_CreateCaptureBuffer(dsco
,&bufdesc
,&dscbo
,NULL
);
489 ok((rc
==DS_OK
)&&(dscbo
!=NULL
),"IDirectSoundCapture_CreateCaptureBuffer() "
490 "failed to create a capture buffer: %s\n",DXGetErrorString8(rc
));
491 if ((rc
==DS_OK
)&&(dscbo
!=NULL
)) {
492 test_capture_buffer(dsco
, dscbo
, winetest_interactive
);
493 ref
=IDirectSoundCaptureBuffer_Release(dscbo
);
494 ok(ref
==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
495 "should have 0\n",ref
);
499 /* Try an invalid format to test error handling */
501 init_format(&wfx
,WAVE_FORMAT_PCM
,2000000,16,2);
502 ZeroMemory(&bufdesc
, sizeof(bufdesc
));
503 bufdesc
.dwSize
=sizeof(bufdesc
);
504 bufdesc
.dwFlags
=DSCBCAPS_WAVEMAPPED
;
505 bufdesc
.dwBufferBytes
=wfx
.nAvgBytesPerSec
;
506 bufdesc
.dwReserved
=0;
507 bufdesc
.lpwfxFormat
=&wfx
;
508 if (winetest_interactive
)
509 trace(" Testing the capture buffer at %s\n", format_string(&wfx
));
510 rc
=IDirectSoundCapture_CreateCaptureBuffer(dsco
,&bufdesc
,&dscbo
,NULL
);
511 ok(rc
!=DS_OK
,"IDirectSoundCapture_CreateCaptureBuffer() should have failed "
512 "at 2 MHz %s\n",DXGetErrorString8(rc
));
517 ref
=IDirectSoundCapture_Release(dsco
);
518 ok(ref
==0,"IDirectSoundCapture_Release() has %d references, should "
525 static void capture_tests()
528 rc
=pDirectSoundCaptureEnumerateA(&dscenum_callback
,NULL
);
529 ok(rc
==DS_OK
,"DirectSoundCaptureEnumerateA() failed: %s\n",
530 DXGetErrorString8(rc
));
539 hDsound
= LoadLibraryA("dsound.dll");
541 trace("dsound.dll not found\n");
545 trace("DLL Version: %s\n", get_file_version("dsound.dll"));
547 pDirectSoundCaptureCreate
=(void*)GetProcAddress(hDsound
,"DirectSoundCaptureCreate");
548 pDirectSoundCaptureEnumerateA
=(void*)GetProcAddress(hDsound
,"DirectSoundCaptureEnumerateA");
549 if (!pDirectSoundCaptureCreate
|| !pDirectSoundCaptureEnumerateA
)
551 trace("capture test skipped\n");