ReactOS  0.4.14-dev-358-gbef841c
capture.c File Reference
#include "dsound_test.h"
#include <stdio.h>
Include dependency graph for capture.c:

Go to the source code of this file.

Classes

struct  capture_state_t
 

Macros

#define NOTIFICATIONS   5
 
#define WAVE_FORMAT(f)   case f: return #f
 

Functions

static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID
 
static const charget_format_str (WORD format)
 
const charformat_string (const WAVEFORMATEX *wfx)
 
static void IDirectSoundCapture_test (LPDIRECTSOUNDCAPTURE dsco, BOOL initialized, LPCGUID lpGuid)
 
static void test_capture (void)
 
static int capture_buffer_service (capture_state_t *state)
 
static void test_capture_buffer (LPDIRECTSOUNDCAPTURE dsco, LPDIRECTSOUNDCAPTUREBUFFER dscbo, int record)
 
static BOOL WINAPI dscenum_callback (LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
 
static void test_enumerate (void)
 
static void test_COM (void)
 
 START_TEST (capture)
 

Variables

static LPDIRECTSOUNDCAPTURE LPUNKNOWN =NULL
 
static LPVOID =NULL
 

Macro Definition Documentation

◆ NOTIFICATIONS

#define NOTIFICATIONS   5

Definition at line 26 of file capture.c.

◆ WAVE_FORMAT

#define WAVE_FORMAT (   f)    case f: return #f

Function Documentation

◆ capture_buffer_service()

static int capture_buffer_service ( capture_state_t state)
static

Definition at line 275 of file capture.c.

276 {
277  HRESULT rc;
278  LPVOID ptr1,ptr2;
279  DWORD len1,len2;
280  DWORD capture_pos,read_pos;
281 
283  &read_pos);
284  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetCurrentPosition() failed: %08x\n", rc);
285  if (rc!=DS_OK)
286  return 0;
287 
288  rc=IDirectSoundCaptureBuffer_Lock(state->dscbo,state->offset,state->size,
289  &ptr1,&len1,&ptr2,&len2,0);
290  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Lock() failed: %08x\n", rc);
291  if (rc!=DS_OK)
292  return 0;
293 
294  rc=IDirectSoundCaptureBuffer_Unlock(state->dscbo,ptr1,len1,ptr2,len2);
295  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Unlock() failed: %08x\n", rc);
296  if (rc!=DS_OK)
297  return 0;
298 
299  state->offset = (state->offset + state->size) % state->buffer_size;
300 
301  return 1;
302 }
#define DS_OK
Definition: dsound.h:116
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static int state
Definition: maze.c:121
#define IDirectSoundCaptureBuffer_GetCurrentPosition(p, a, b)
Definition: dsound.h:782
#define IDirectSoundCaptureBuffer_Lock(p, a, b, c, d, e, f, g)
Definition: dsound.h:786
#define IDirectSoundCaptureBuffer_Unlock(p, a, b, c, d)
Definition: dsound.h:789
#define ok(value,...)
Definition: atltest.h:57

Referenced by test_capture_buffer().

◆ dscenum_callback()

static BOOL WINAPI dscenum_callback ( LPGUID  lpGuid,
LPCSTR  lpcstrDescription,
LPCSTR  lpcstrModule,
LPVOID  lpContext 
)
static

Definition at line 424 of file capture.c.

426 {
427  HRESULT rc;
430  DSCBUFFERDESC bufdesc;
431  WAVEFORMATEX wfx;
432  DSCCAPS dsccaps;
433  DWORD f;
434  int ref;
435 
436  /* Private dsound.dll: Error: Invalid interface buffer */
437  trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
438  rc=pDirectSoundCaptureCreate(lpGuid,NULL,NULL);
439  ok(rc==DSERR_INVALIDPARAM,"DirectSoundCaptureCreate() should have "
440  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
441 
442  rc=pDirectSoundCaptureCreate(lpGuid,&dsco,NULL);
443  ok((rc==DS_OK)||(rc==DSERR_NODRIVER)||(rc==E_FAIL)||(rc==DSERR_ALLOCATED),
444  "DirectSoundCaptureCreate() failed: %08x\n",rc);
445  if (rc!=DS_OK) {
446  if (rc==DSERR_NODRIVER)
447  trace(" No Driver\n");
448  else if (rc==E_FAIL)
449  trace(" No Device\n");
450  else if (rc==DSERR_ALLOCATED)
451  trace(" Already In Use\n");
452  goto EXIT;
453  }
454 
455  /* Private dsound.dll: Error: Invalid caps buffer */
457  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_GetCaps() should have "
458  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
459 
460  /* Private dsound.dll: Error: Invalid caps buffer */
461  dsccaps.dwSize=0;
462  rc=IDirectSoundCapture_GetCaps(dsco,&dsccaps);
463  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_GetCaps() should have "
464  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
465 
466  dsccaps.dwSize=sizeof(dsccaps);
467  rc=IDirectSoundCapture_GetCaps(dsco,&dsccaps);
468  ok(rc==DS_OK,"IDirectSoundCapture_GetCaps() failed: %08x\n", rc);
469  if (rc==DS_OK && winetest_debug > 1) {
470  trace(" Caps: size=%d flags=0x%08x formats=%05x channels=%d\n",
471  dsccaps.dwSize,dsccaps.dwFlags,dsccaps.dwFormats,
472  dsccaps.dwChannels);
473  }
474 
475  /* Private dsound.dll: Error: Invalid size */
476  /* Private dsound.dll: Error: Invalid capture buffer description */
477  ZeroMemory(&bufdesc, sizeof(bufdesc));
478  bufdesc.dwSize=0;
479  bufdesc.dwFlags=0;
480  bufdesc.dwBufferBytes=0;
481  bufdesc.dwReserved=0;
482  bufdesc.lpwfxFormat=NULL;
483  rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
484  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
485  "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
486  if (rc==DS_OK) {
488  ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
489  "should have 0\n",ref);
490  }
491 
492  /* Private dsound.dll: Error: Invalid buffer size */
493  /* Private dsound.dll: Error: Invalid capture buffer description */
494  ZeroMemory(&bufdesc, sizeof(bufdesc));
495  bufdesc.dwSize=sizeof(bufdesc);
496  bufdesc.dwFlags=0;
497  bufdesc.dwBufferBytes=0;
498  bufdesc.dwReserved=0;
499  bufdesc.lpwfxFormat=NULL;
500  rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
501  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
502  "should have returned DSERR_INVALIDPARAM, returned %08x\n", rc);
503  if (rc==DS_OK) {
505  ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
506  "should have 0\n",ref);
507  }
508 
509  /* Private dsound.dll: Error: Invalid buffer size */
510  /* Private dsound.dll: Error: Invalid capture buffer description */
511  ZeroMemory(&bufdesc, sizeof(bufdesc));
512  ZeroMemory(&wfx, sizeof(wfx));
513  bufdesc.dwSize=sizeof(bufdesc);
514  bufdesc.dwFlags=0;
515  bufdesc.dwBufferBytes=0;
516  bufdesc.dwReserved=0;
517  bufdesc.lpwfxFormat=&wfx;
518  rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
519  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
520  "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
521  if (rc==DS_OK) {
523  ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
524  "should have 0\n",ref);
525  }
526 
527  /* Private dsound.dll: Error: Invalid buffer size */
528  /* Private dsound.dll: Error: Invalid capture buffer description */
529  init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
530  ZeroMemory(&bufdesc, sizeof(bufdesc));
531  bufdesc.dwSize=sizeof(bufdesc);
532  bufdesc.dwFlags=0;
533  bufdesc.dwBufferBytes=0;
534  bufdesc.dwReserved=0;
535  bufdesc.lpwfxFormat=&wfx;
536  rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
537  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
538  "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
539  if (rc==DS_OK) {
541  ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
542  "should have 0\n",ref);
543  }
544 
545  for (f=0;f<NB_FORMATS;f++) {
546  dscbo=NULL;
548  formats[f][2]);
549  ZeroMemory(&bufdesc, sizeof(bufdesc));
550  bufdesc.dwSize=sizeof(bufdesc);
551  bufdesc.dwFlags=0;
552  bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
553  bufdesc.dwReserved=0;
554  bufdesc.lpwfxFormat=&wfx;
556  trace(" Testing the capture buffer at %s\n", format_string(&wfx));
557  rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
558  ok(((rc==DS_OK)&&(dscbo!=NULL))
560  || rc==DSERR_ALLOCATED || rc==E_INVALIDARG || rc==E_FAIL,
561  "IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
562  "%s capture buffer: %08x\n",format_string(&wfx),rc);
563  if (rc==DS_OK) {
566  ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
567  "should have 0\n",ref);
568  } else if (rc==DSERR_BADFORMAT) {
569  ok(!(dsccaps.dwFormats & formats[f][3]),
570  "IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
571  "capture buffer: format listed as supported but using it failed\n");
572  if (!(dsccaps.dwFormats & formats[f][3]))
573  trace(" Format not supported: %s\n", format_string(&wfx));
574  } else if (rc==DSERR_NODRIVER) {
575  trace(" No Driver\n");
576  } else if (rc==DSERR_ALLOCATED) {
577  trace(" Already In Use\n");
578  } else if (rc==E_INVALIDARG) { /* try the old version struct */
579  DSCBUFFERDESC1 bufdesc1;
580  ZeroMemory(&bufdesc1, sizeof(bufdesc1));
581  bufdesc1.dwSize=sizeof(bufdesc1);
582  bufdesc1.dwFlags=0;
583  bufdesc1.dwBufferBytes=wfx.nAvgBytesPerSec;
584  bufdesc1.dwReserved=0;
585  bufdesc1.lpwfxFormat=&wfx;
587  (DSCBUFFERDESC*)&bufdesc1,&dscbo,NULL);
588  ok(rc==DS_OK || broken(rc==DSERR_INVALIDPARAM),
589  "IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
590  "%s capture buffer: %08x\n",format_string(&wfx), rc);
591  if (rc==DSERR_INVALIDPARAM) {
592  skip("broken driver\n");
593  goto EXIT;
594  }
595  if (rc==DS_OK) {
598  ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d "
599  "references, should have 0\n",ref);
600  }
601  } else if (rc==E_FAIL) {
602  /* WAVE_FORMAT_PCM only allows 8 and 16 bits per sample, so only
603  * report a failure if the bits per sample is 8 or 16
604  */
605  if (wfx.wBitsPerSample == 8 || wfx.wBitsPerSample == 16)
606  ok(FALSE,"Should not fail for 8 or 16 bits per sample\n");
607  }
608  }
609 
610  /* try a non PCM format */
611  if (0)
612  {
613  /* FIXME: Why is this commented out? */
614  init_format(&wfx,WAVE_FORMAT_MULAW,8000,8,1);
615  ZeroMemory(&bufdesc, sizeof(bufdesc));
616  bufdesc.dwSize=sizeof(bufdesc);
618  bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
619  bufdesc.dwReserved=0;
620  bufdesc.lpwfxFormat=&wfx;
622  trace(" Testing the capture buffer at %s\n", format_string(&wfx));
623  rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
624  ok((rc==DS_OK)&&(dscbo!=NULL),"IDirectSoundCapture_CreateCaptureBuffer() "
625  "failed to create a capture buffer: %08x\n",rc);
626  if ((rc==DS_OK)&&(dscbo!=NULL)) {
629  ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
630  "should have 0\n",ref);
631  }
632  }
633 
634  /* Try an invalid format to test error handling */
635  if (0)
636  {
637  /* FIXME: Remove this test altogether? */
638  init_format(&wfx,WAVE_FORMAT_PCM,2000000,16,2);
639  ZeroMemory(&bufdesc, sizeof(bufdesc));
640  bufdesc.dwSize=sizeof(bufdesc);
642  bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
643  bufdesc.dwReserved=0;
644  bufdesc.lpwfxFormat=&wfx;
646  trace(" Testing the capture buffer at %s\n", format_string(&wfx));
647  rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
648  ok(rc!=DS_OK,"IDirectSoundCapture_CreateCaptureBuffer() should have failed "
649  "at 2 MHz %08x\n",rc);
650  }
651 
652 EXIT:
653  if (dsco!=NULL) {
655  ok(ref==0,"IDirectSoundCapture_Release() has %d references, should "
656  "have 0\n",ref);
657  }
658 
659  return TRUE;
660 }
LPWAVEFORMATEX lpwfxFormat
Definition: dsound.h:361
DWORD dwSize
Definition: dsound.h:357
LPWAVEFORMATEX lpwfxFormat
Definition: dsound.h:352
#define TRUE
Definition: types.h:120
#define DSCBCAPS_WAVEMAPPED
Definition: dsound.h:389
#define DSERR_INVALIDCALL
Definition: dsound.h:122
DWORD dwFlags
Definition: dsound.h:358
#define IDirectSoundCapture_Release(p)
Definition: dsound.h:736
DWORD dwReserved
Definition: dsound.h:351
static const struct pixel_format_desc formats[]
Definition: util.c:57
#define IDirectSoundCaptureBuffer_Release(p)
Definition: dsound.h:779
#define ZeroMemory
Definition: winbase.h:1642
DWORD dwBufferBytes
Definition: dsound.h:359
#define IDirectSoundCapture_GetCaps(p, a)
Definition: dsound.h:739
int winetest_interactive
#define E_FAIL
Definition: ddrawi.h:102
int winetest_debug
Definition: send.c:47
#define NB_FORMATS
Definition: dsound_test.h:91
DWORD dwReserved
Definition: dsound.h:360
#define WAVE_FORMAT_PCM
Definition: constants.h:425
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
#define WAVE_FORMAT_MULAW
Definition: constants.h:428
GLenum GLint ref
Definition: glext.h:6028
WORD wBitsPerSample
Definition: audioclient.idl:45
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define DSERR_NODRIVER
Definition: dsound.h:128
DWORD dwFlags
Definition: dsound.h:349
GLfloat f
Definition: glext.h:7540
#define DS_OK
Definition: dsound.h:116
void init_format(WAVEFORMATEX *wfx, int format, int rate, int depth, int channels)
Definition: ds3d.c:154
#define trace
Definition: atltest.h:70
DWORD dwFormats
Definition: dsound.h:371
LONG HRESULT
Definition: typedefs.h:77
static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco, LPDIRECTSOUNDCAPTUREBUFFER dscbo, int record)
Definition: capture.c:304
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwSize
Definition: dsound.h:348
const char * format_string(const WAVEFORMATEX *wfx)
Definition: capture.c:84
#define DSERR_BADFORMAT
Definition: dsound.h:126
#define IDirectSoundCapture_CreateCaptureBuffer(p, a, b, c)
Definition: dsound.h:738
struct IDirectSoundCapture * LPDIRECTSOUNDCAPTURE
Definition: dsound.h:92
#define broken(x)
Definition: _sntprintf.h:21
DWORD dwFlags
Definition: dsound.h:370
struct IDirectSoundCaptureBuffer * LPDIRECTSOUNDCAPTUREBUFFER
Definition: dsound.h:97
#define f
Definition: ke_i.h:83
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
#define ok(value,...)
Definition: atltest.h:57
DWORD dwChannels
Definition: dsound.h:372
#define skip(...)
Definition: atltest.h:64
#define DSERR_ALLOCATED
Definition: dsound.h:119
DWORD dwBufferBytes
Definition: dsound.h:350
DWORD dwSize
Definition: dsound.h:369

Referenced by test_enumerate().

◆ format_string()

const char* format_string ( const WAVEFORMATEX wfx)

Definition at line 84 of file capture.c.

85 {
86  static char str[64];
87 
88  sprintf(str, "%5dx%2dx%d %s",
89  wfx->nSamplesPerSec, wfx->wBitsPerSample, wfx->nChannels,
91 
92  return str;
93 }
#define sprintf(buf, format,...)
Definition: sprintf.c:55
WORD wBitsPerSample
Definition: audioclient.idl:45
const WCHAR * str
DWORD nSamplesPerSec
Definition: audioclient.idl:42
static const char * get_format_str(WORD format)
Definition: capture.c:31

Referenced by acpi_extract_package(), dscenum_callback(), test_buffer(), test_buffer8(), test_primary_secondary(), and test_primary_secondary8().

◆ get_format_str()

static const char* get_format_str ( WORD  format)
static

Definition at line 31 of file capture.c.

32 {
33  static char msg[32];
34 #define WAVE_FORMAT(f) case f: return #f
35  switch (format) {
78  }
79 #undef WAVE_FORMAT
80  sprintf(msg, "Unknown(0x%04x)", format);
81  return msg;
82 }
#define WAVE_FORMAT_IBM_CVSD
Definition: mmreg.h:98
#define WAVE_FORMAT_SIERRA_ADPCM
Definition: mmreg.h:105
#define WAVE_FORMAT_DSPGROUP_TRUESPEECH
Definition: mmreg.h:112
#define WAVE_FORMAT_APTX
Definition: mmreg.h:115
#define WAVE_FORMAT_DIGISTD
Definition: mmreg.h:107
#define WAVE_FORMAT_AUDIOFILE_AF36
Definition: mmreg.h:114
#define WAVE_FORMAT_SONARC
Definition: mmreg.h:111
#define WAVE_FORMAT_CONTROL_RES_CR10
Definition: mmreg.h:123
#define WAVE_FORMAT_OLICELP
Definition: mmreg.h:136
#define WAVE_FORMAT_OKI_ADPCM
Definition: mmreg.h:101
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define WAVE_FORMAT_MEDIASPACE_ADPCM
Definition: mmreg.h:104
#define WAVE_FORMAT_MPEG
Definition: mmreg.h:126
#define WAVE_FORMAT_CREATIVE_ADPCM
Definition: mmreg.h:130
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define WAVE_FORMAT_PCM
Definition: constants.h:425
#define WAVE_FORMAT_DIGIFIX
Definition: mmreg.h:108
#define WAVE_FORMAT_AUDIOFILE_AF10
Definition: mmreg.h:116
#define WAVE_FORMAT_MULAW
Definition: constants.h:428
#define WAVE_FORMAT_G723_ADPCM
Definition: mmreg.h:106
#define WAVE_FORMAT_CREATIVE_FASTSPEECH10
Definition: mmreg.h:132
#define WAVE_FORMAT_DIGIREAL
Definition: mmreg.h:121
#define WAVE_FORMAT_NMS_VBXADPCM
Definition: mmreg.h:124
#define WAVE_FORMAT_IMA_ADPCM
Definition: mmreg.h:103
#define WAVE_FORMAT_CONTROL_RES_VQLPC
Definition: mmreg.h:120
#define WAVE_FORMAT_OLIADPCM
Definition: mmreg.h:135
#define WAVE_FORMAT(f)
#define WAVE_FORMAT_OLISBC
Definition: mmreg.h:137
#define WAVE_FORMAT_DEVELOPMENT
Definition: mmreg.h:160
#define WAVE_FORMAT_YAMAHA_ADPCM
Definition: mmreg.h:110
#define WAVE_FORMAT_MPEGLAYER3
Definition: mmreg.h:127
#define WAVE_FORMAT_ADPCM
Definition: constants.h:426
#define WAVE_FORMAT_FM_TOWNS_SND
Definition: mmreg.h:133
#define WAVE_FORMAT_OLIOPR
Definition: mmreg.h:138
#define WAVE_FORMAT_DIALOGIC_OKI_ADPCM
Definition: mmreg.h:109
#define WAVE_FORMAT_ALAW
Definition: constants.h:427
#define msg(x)
Definition: auth_time.c:54
#define WAVE_FORMAT_DIGIADPCM
Definition: mmreg.h:122
#define WAVE_FORMAT_DOLBY_AC2
Definition: mmreg.h:117
#define WAVE_FORMAT_GSM610
Definition: mmreg.h:118
#define WAVE_FORMAT_ECHOSC1
Definition: mmreg.h:113
#define WAVE_FORMAT_CREATIVE_FASTSPEECH8
Definition: mmreg.h:131
#define WAVE_FORMAT_OLIGSM
Definition: mmreg.h:134
#define WAVE_FORMAT_G721_ADPCM
Definition: mmreg.h:125
#define WAVE_FORMAT_EXTENSIBLE
Definition: ksmedia.h:551
#define WAVE_FORMAT_ANTEX_ADPCME
Definition: mmreg.h:119

Referenced by format_string(), and wave_in_test_deviceIn().

◆ HRESULT()

static HRESULT ( WINAPI pDirectSoundCaptureCreate)
static

◆ IDirectSoundCapture_test()

static void IDirectSoundCapture_test ( LPDIRECTSOUNDCAPTURE  dsco,
BOOL  initialized,
LPCGUID  lpGuid 
)
static

Definition at line 95 of file capture.c.

97 {
98  HRESULT rc;
99  DSCCAPS dsccaps;
100  int ref;
101  IUnknown * unknown;
102  IDirectSoundCapture * dsc;
103 
104  /* Try to Query for objects */
106  (LPVOID*)&unknown);
107  ok(rc==DS_OK, "IDirectSoundCapture_QueryInterface(IID_IUnknown) "
108  "failed: %08x\n", rc);
109  if (rc==DS_OK)
111 
112  rc=IDirectSoundCapture_QueryInterface(dsco, &IID_IDirectSoundCapture,
113  (LPVOID*)&dsc);
114  ok(rc==DS_OK, "IDirectSoundCapture_QueryInterface(IID_IDirectSoundCapture) "
115  "failed: %08x\n", rc);
116  if (rc==DS_OK)
118 
119  if (initialized == FALSE) {
120  /* try uninitialized object */
121  rc=IDirectSoundCapture_GetCaps(dsco,0);
123  "IDirectSoundCapture_GetCaps(NULL) should have returned "
124  "DSERR_UNINITIALIZED or E_INVALIDARG, returned: %08x\n", rc);
125 
126  rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
127  ok(rc==DSERR_UNINITIALIZED,"IDirectSoundCapture_GetCaps() "
128  "should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
129 
130  rc=IDirectSoundCapture_Initialize(dsco, lpGuid);
131  ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||
132  rc==E_FAIL||rc==E_INVALIDARG,
133  "IDirectSoundCapture_Initialize() failed: %08x\n", rc);
134  if (rc==DSERR_NODRIVER||rc==E_INVALIDARG) {
135  trace(" No Driver\n");
136  goto EXIT;
137  } else if (rc==E_FAIL) {
138  trace(" No Device\n");
139  goto EXIT;
140  } else if (rc==DSERR_ALLOCATED) {
141  trace(" Already In Use\n");
142  goto EXIT;
143  }
144  }
145 
146  rc=IDirectSoundCapture_Initialize(dsco, lpGuid);
147  ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSoundCapture_Initialize() "
148  "should have returned DSERR_ALREADYINITIALIZED: %08x\n", rc);
149 
150  /* DSOUND: Error: Invalid caps buffer */
151  rc=IDirectSoundCapture_GetCaps(dsco, 0);
152  ok(rc==DSERR_INVALIDPARAM, "IDirectSoundCapture_GetCaps(NULL) "
153  "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
154 
155  ZeroMemory(&dsccaps, sizeof(dsccaps));
156 
157  /* DSOUND: Error: Invalid caps buffer */
158  rc=IDirectSound_GetCaps(dsco, &dsccaps);
159  ok(rc==DSERR_INVALIDPARAM, "IDirectSound_GetCaps() "
160  "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
161 
162  dsccaps.dwSize=sizeof(dsccaps);
163 
164  /* DSOUND: Running on a certified driver */
165  rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
166  ok(rc==DS_OK, "IDirectSoundCapture_GetCaps() failed: %08x\n", rc);
167 
168 EXIT:
170  ok(ref==0, "IDirectSoundCapture_Release() has %d references, "
171  "should have 0\n", ref);
172 }
#define IDirectSoundCapture_Release(p)
Definition: dsound.h:736
#define DSERR_UNINITIALIZED
Definition: dsound.h:133
#define DSERR_ALREADYINITIALIZED
Definition: dsound.h:129
#define ZeroMemory
Definition: winbase.h:1642
#define IDirectSoundCapture_GetCaps(p, a)
Definition: dsound.h:739
#define IDirectSound_GetCaps(p, a)
Definition: dsound.h:456
#define E_FAIL
Definition: ddrawi.h:102
Definition: send.c:47
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
GLenum GLint ref
Definition: glext.h:6028
#define E_INVALIDARG
Definition: ddrawi.h:101
#define DSERR_NODRIVER
Definition: dsound.h:128
#define DS_OK
Definition: dsound.h:116
#define trace
Definition: atltest.h:70
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
static BOOL initialized
Definition: syslog.c:39
#define IDirectSoundCapture_Initialize(p, a)
Definition: dsound.h:740
Definition: id3.c:18
#define ok(value,...)
Definition: atltest.h:57
#define DSERR_ALLOCATED
Definition: dsound.h:119
#define IDirectSoundCapture_QueryInterface(p, a, b)
Definition: dsound.h:734
DWORD dwSize
Definition: dsound.h:369

Referenced by test_capture().

◆ START_TEST()

START_TEST ( capture  )

Definition at line 749 of file capture.c.

750 {
751  HMODULE hDsound;
752 
754 
755  hDsound = LoadLibrary("dsound.dll");
756  if (!hDsound) {
757  skip("dsound.dll not found - skipping all tests\n");
758  return;
759  }
760 
761  pDirectSoundCaptureCreate = (void*)GetProcAddress(hDsound, "DirectSoundCaptureCreate");
762  pDirectSoundCaptureEnumerateA = (void*)GetProcAddress(hDsound, "DirectSoundCaptureEnumerateA");
763  if (!pDirectSoundCaptureCreate || !pDirectSoundCaptureEnumerateA) {
764  skip("DirectSoundCapture{Create,Enumerate} missing - skipping all tests\n");
765  return;
766  }
767 
768  test_COM();
769  test_capture();
770  test_enumerate();
771 
772  FreeLibrary(hDsound);
773  CoUninitialize();
774 }
#define LoadLibrary
Definition: winbase.h:3686
static void test_COM(void)
Definition: capture.c:669
smooth NULL
Definition: ftsmooth.c:416
#define FreeLibrary(x)
Definition: compat.h:413
static void test_capture(void)
Definition: capture.c:174
static void test_enumerate(void)
Definition: capture.c:662
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define skip(...)
Definition: atltest.h:64
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
#define GetProcAddress(x, y)
Definition: compat.h:418

◆ test_capture()

static void test_capture ( void  )
static

Definition at line 174 of file capture.c.

175 {
176  HRESULT rc;
178  LPCLASSFACTORY cf=NULL;
179 
180  trace("Testing IDirectSoundCapture\n");
181 
182  rc=CoGetClassObject(&CLSID_DirectSoundCapture, CLSCTX_INPROC_SERVER, NULL,
183  &IID_IClassFactory, (void**)&cf);
184  ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
185  "failed: %08x\n", rc);
186 
187  rc=CoGetClassObject(&CLSID_DirectSoundCapture, CLSCTX_INPROC_SERVER, NULL,
188  &IID_IUnknown, (void**)&cf);
189  ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSoundCapture, IID_IUnknown) "
190  "failed: %08x\n", rc);
191 
192  /* try the COM class factory method of creation with no device specified */
193  rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
194  &IID_IDirectSoundCapture, (void**)&dsco);
195  ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %08x\n", rc);
196  if (rc==REGDB_E_CLASSNOTREG) {
197  trace(" Class Not Registered\n");
198  return;
199  }
200  if (dsco)
202 
203  /* try the COM class factory method of creation with default capture
204  * device specified */
205  rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
206  &IID_IDirectSoundCapture, (void**)&dsco);
207  ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %08x\n", rc);
208  if (dsco)
209  IDirectSoundCapture_test(dsco, FALSE, &DSDEVID_DefaultCapture);
210 
211  /* try the COM class factory method of creation with default voice
212  * capture device specified */
213  rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
214  &IID_IDirectSoundCapture, (void**)&dsco);
215  ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %08x\n", rc);
216  if (dsco)
217  IDirectSoundCapture_test(dsco, FALSE, &DSDEVID_DefaultVoiceCapture);
218 
219  /* try the COM class factory method of creation with a bad
220  * IID specified */
221  rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
222  &CLSID_DirectSoundPrivate, (void**)&dsco);
223  ok(rc==E_NOINTERFACE,
224  "CoCreateInstance(CLSID_DirectSoundCapture,CLSID_DirectSoundPrivate) "
225  "should have failed: %08x\n",rc);
226 
227  /* try with no device specified */
228  rc=pDirectSoundCaptureCreate(NULL,&dsco,NULL);
229  ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
230  "DirectSoundCaptureCreate(NULL) failed: %08x\n",rc);
231  if (rc==S_OK && dsco)
233 
234  /* try with default capture device specified */
235  rc=pDirectSoundCaptureCreate(&DSDEVID_DefaultCapture,&dsco,NULL);
236  ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
237  "DirectSoundCaptureCreate(DSDEVID_DefaultCapture) failed: %08x\n", rc);
238  if (rc==DS_OK && dsco)
240 
241  /* try with default voice capture device specified */
242  rc=pDirectSoundCaptureCreate(&DSDEVID_DefaultVoiceCapture,&dsco,NULL);
243  ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
244  "DirectSoundCaptureCreate(DSDEVID_DefaultVoiceCapture) failed: %08x\n", rc);
245  if (rc==DS_OK && dsco)
247 
248  /* try with a bad device specified */
249  rc=pDirectSoundCaptureCreate(&DSDEVID_DefaultVoicePlayback,&dsco,NULL);
250  ok(rc==DSERR_NODRIVER,
251  "DirectSoundCaptureCreate(DSDEVID_DefaultVoicePlatback) "
252  "should have failed: %08x\n",rc);
253  if (rc==DS_OK && dsco)
255 }
#define TRUE
Definition: types.h:120
#define E_NOINTERFACE
Definition: winerror.h:2364
#define IDirectSoundCapture_Release(p)
Definition: dsound.h:736
#define E_FAIL
Definition: ddrawi.h:102
static void IDirectSoundCapture_test(LPDIRECTSOUNDCAPTURE dsco, BOOL initialized, LPCGUID lpGuid)
Definition: capture.c:95
smooth NULL
Definition: ftsmooth.c:416
#define DSERR_NODRIVER
Definition: dsound.h:128
HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3103
#define DS_OK
Definition: dsound.h:116
#define trace
Definition: atltest.h:70
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
struct IDirectSoundCapture * LPDIRECTSOUNDCAPTURE
Definition: dsound.h:92
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:59
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696
#define ok(value,...)
Definition: atltest.h:57
#define DSERR_ALLOCATED
Definition: dsound.h:119
const GUID IID_IClassFactory

Referenced by START_TEST().

◆ test_capture_buffer()

static void test_capture_buffer ( LPDIRECTSOUNDCAPTURE  dsco,
LPDIRECTSOUNDCAPTUREBUFFER  dscbo,
int  record 
)
static

Definition at line 304 of file capture.c.

306 {
307  HRESULT rc;
308  DSCBCAPS dscbcaps;
309  WAVEFORMATEX wfx;
310  DWORD size,status;
312  int i, ref;
313 
314  /* Private dsound.dll: Error: Invalid caps pointer */
316  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetCaps() should "
317  "have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
318 
319  /* Private dsound.dll: Error: Invalid caps pointer */
320  dscbcaps.dwSize=0;
321  rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps);
322  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetCaps() should "
323  "have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
324 
325  dscbcaps.dwSize=sizeof(dscbcaps);
326  rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps);
327  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetCaps() failed: %08x\n", rc);
328  if (rc==DS_OK && winetest_debug > 1) {
329  trace(" Caps: size = %d flags=0x%08x buffer size=%d\n",
330  dscbcaps.dwSize,dscbcaps.dwFlags,dscbcaps.dwBufferBytes);
331  }
332 
333  /* Query the format size. Note that it may not match sizeof(wfx) */
334  /* Private dsound.dll: Error: Either pwfxFormat or pdwSizeWritten must
335  * be non-NULL */
337  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetFormat() should "
338  "have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
339 
340  size=0;
342  ok(rc==DS_OK && size!=0,"IDirectSoundCaptureBuffer_GetFormat() should "
343  "have returned the needed size: rc=%08x, size=%d\n", rc,size);
344 
345  rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,&wfx,sizeof(wfx),NULL);
346  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetFormat() failed: %08x\n", rc);
347  if (rc==DS_OK && winetest_debug > 1) {
348  trace(" Format: tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
351  }
352 
353  /* Private dsound.dll: Error: Invalid status pointer */
355  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetStatus() should "
356  "have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
357 
359  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc);
360  if (rc==DS_OK && winetest_debug > 1) {
361  trace(" Status=0x%04x\n",status);
362  }
363 
364  ZeroMemory(&state, sizeof(state));
365  state.dscbo=dscbo;
366  state.wfx=&wfx;
367  state.buffer_size = dscbcaps.dwBufferBytes;
368  for (i = 0; i < NOTIFICATIONS; i++)
369  state.event[i] = CreateEvent( NULL, FALSE, FALSE, NULL );
370  state.size = dscbcaps.dwBufferBytes / NOTIFICATIONS;
371 
372  rc=IDirectSoundCaptureBuffer_QueryInterface(dscbo,&IID_IDirectSoundNotify,
373  (void **)&(state.notify));
374  ok((rc==DS_OK)&&(state.notify!=NULL),
375  "IDirectSoundCaptureBuffer_QueryInterface() failed: %08x\n", rc);
376 
377  for (i = 0; i < NOTIFICATIONS; i++) {
378  state.posnotify[i].dwOffset = (i * state.size) + state.size - 1;
379  state.posnotify[i].hEventNotify = state.event[i];
380  }
381 
383  state.posnotify);
384  ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions() failed: %08x\n", rc);
385 
387  ok(ref==0,"IDirectSoundNotify_Release(): has %d references, should have "
388  "0\n",ref);
389 
391  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc);
392 
394  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc);
395 
397  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc);
399  "GetStatus: bad status: %x\n",status);
400 
401  if (record) {
402  /* wait for the notifications */
403  for (i = 0; i < (NOTIFICATIONS * 2); i++) {
406  "WaitForMultipleObjects failed: 0x%x\n",rc);
407  if (rc!=(WAIT_OBJECT_0+(i%NOTIFICATIONS))) {
408  ok((rc==WAIT_TIMEOUT)||(rc==WAIT_FAILED),
409  "Wrong notification: should be %d, got %d\n",
411  }
413  break;
414  }
415 
416  }
418  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
419 
421  ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
422 }
#define CreateEvent
Definition: winbase.h:3572
#define IDirectSoundCaptureBuffer_Start(p, a)
Definition: dsound.h:787
#define IDirectSoundCaptureBuffer_Stop(p)
Definition: dsound.h:788
#define ZeroMemory
Definition: winbase.h:1642
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
int winetest_debug
Definition: send.c:47
DWORD dwBufferBytes
Definition: dsound.h:380
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
GLenum GLint ref
Definition: glext.h:6028
DWORD dwSize
Definition: dsound.h:378
DWORD dwFlags
Definition: dsound.h:379
WORD wBitsPerSample
Definition: audioclient.idl:45
smooth NULL
Definition: ftsmooth.c:416
static int capture_buffer_service(capture_state_t *state)
Definition: capture.c:275
DWORD nSamplesPerSec
Definition: audioclient.idl:42
#define DS_OK
Definition: dsound.h:116
#define WAIT_OBJECT_0
Definition: winbase.h:387
GLsizeiptr size
Definition: glext.h:5919
#define trace
Definition: atltest.h:70
LONG HRESULT
Definition: typedefs.h:77
#define DSCBSTATUS_CAPTURING
Definition: dsound.h:396
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WAIT_FAILED
Definition: winbase.h:394
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define IDirectSoundCaptureBuffer_GetStatus(p, a)
Definition: dsound.h:784
#define DSCBSTART_LOOPING
Definition: dsound.h:393
static int state
Definition: maze.c:121
#define broken(x)
Definition: _sntprintf.h:21
#define IDirectSoundNotify_SetNotificationPositions(p, a, b)
Definition: dsound.h:896
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
#define ok(value,...)
Definition: atltest.h:57
#define IDirectSoundCaptureBuffer_GetFormat(p, a, b, c)
Definition: dsound.h:783
#define IDirectSoundCaptureBuffer_GetCaps(p, a)
Definition: dsound.h:781
#define NOTIFICATIONS
Definition: capture.c:26
#define IDirectSoundNotify_Release(p)
Definition: dsound.h:894
#define IDirectSoundCaptureBuffer_QueryInterface(p, a, b)
Definition: dsound.h:777
#define DSCBSTATUS_LOOPING
Definition: dsound.h:397
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by dscenum_callback().

◆ test_COM()

static void test_COM ( void  )
static

Definition at line 669 of file capture.c.

670 {
671  IDirectSoundCapture *dsc = (IDirectSoundCapture*)0xdeadbeef;
672  IDirectSoundCaptureBuffer *buffer = (IDirectSoundCaptureBuffer*)0xdeadbeef;
673  IDirectSoundNotify *notify;
674  IUnknown *unk;
675  DSCBUFFERDESC bufdesc;
676  WAVEFORMATEX wfx;
677  HRESULT hr;
678  ULONG refcount;
679 
680  hr = pDirectSoundCaptureCreate(NULL, &dsc, (IUnknown*)0xdeadbeef);
682  "DirectSoundCaptureCreate failed: %08x, expected DSERR_NOAGGREGATION\n", hr);
683  ok(dsc == (IDirectSoundCapture*)0xdeadbeef, "dsc = %p\n", dsc);
684 
685  hr = pDirectSoundCaptureCreate(NULL, &dsc, NULL);
686  if (hr == DSERR_NODRIVER) {
687  skip("No driver\n");
688  return;
689  }
690  ok(hr == DS_OK, "DirectSoundCaptureCreate failed: %08x, expected DS_OK\n", hr);
691 
692  /* Different refcount for IDirectSoundCapture and for IUnknown */
693  refcount = IDirectSoundCapture_AddRef(dsc);
694  ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
695  hr = IDirectSoundCapture_QueryInterface(dsc, &IID_IUnknown, (void**)&unk);
696  ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
697  refcount = IUnknown_AddRef(unk);
698  ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
699  IUnknown_Release(unk);
700  IUnknown_Release(unk);
702 
703  init_format(&wfx, WAVE_FORMAT_PCM, 44100, 16, 1);
704  ZeroMemory(&bufdesc, sizeof(bufdesc));
705  bufdesc.dwSize = sizeof(bufdesc);
706  bufdesc.dwBufferBytes = wfx.nAvgBytesPerSec;
707  bufdesc.lpwfxFormat = &wfx;
708 
709  hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer, (IUnknown*)0xdeadbeef);
710  if (hr == E_INVALIDARG) {
711  /* Old DirectX has only the 1st version of the DSCBUFFERDESC struct */
712  bufdesc.dwSize = sizeof(DSCBUFFERDESC1);
713  hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer, (IUnknown*)0xdeadbeef);
714  }
716  "IDirectSoundCapture_CreateCaptureBuffer failed: %08x, expected DSERR_NOAGGREGATION\n", hr);
717  ok(buffer == (IDirectSoundCaptureBuffer*)0xdeadbeef || !buffer /* Win2k without DirectX9 */,
718  "buffer = %p\n", buffer);
719 
721  ok(hr == DS_OK, "IDirectSoundCapture_CreateCaptureBuffer failed: %08x, expected DS_OK\n", hr);
722 
723  /* IDirectSoundCaptureBuffer and IDirectSoundNotify have separate refcounts */
726  ok(refcount == 3, "IDirectSoundCaptureBuffer refcount is %u, expected 3\n", refcount);
727  hr = IDirectSoundCaptureBuffer_QueryInterface(buffer, &IID_IDirectSoundNotify, (void**)&notify);
728  ok(hr == DS_OK, "IDirectSoundCapture_QueryInterface failed: %08x, expected DS_OK\n", hr);
729  refcount = IDirectSoundNotify_AddRef(notify);
730  ok(refcount == 2, "IDirectSoundNotify refcount is %u, expected 2\n", refcount);
733  ok(refcount == 3, "IDirectSoundCaptureBuffer refcount is %u, expected 3\n", refcount);
734 
735  /* Release IDirectSoundCaptureBuffer while keeping IDirectSoundNotify alive */
737  refcount = IDirectSoundNotify_AddRef(notify);
738  ok(refcount == 3, "IDirectSoundNotify refcount is %u, expected 3\n", refcount);
740  ok(refcount == 1, "IDirectSoundCaptureBuffer refcount is %u, expected 1\n", refcount);
741 
742  while (IDirectSoundNotify_Release(notify) > 0);
744  ok(refcount == 0, "IDirectSoundCaptureBuffer refcount is %u, expected 0\n", refcount);
745  refcount = IDirectSoundCapture_Release(dsc);
746  ok(refcount == 0, "IDirectSoundCapture refcount is %u, expected 0\n", refcount);
747 }
#define IDirectSoundCaptureBuffer_AddRef(p)
Definition: dsound.h:778
LPWAVEFORMATEX lpwfxFormat
Definition: dsound.h:361
DWORD dwSize
Definition: dsound.h:357
struct _DSCBUFFERDESC1 DSCBUFFERDESC1
HRESULT hr
Definition: shlfolder.c:183
#define IDirectSoundCapture_Release(p)
Definition: dsound.h:736
int notify
Definition: msacm.c:1365
#define IDirectSoundCaptureBuffer_Release(p)
Definition: dsound.h:779
#define ZeroMemory
Definition: winbase.h:1642
DWORD dwBufferBytes
Definition: dsound.h:359
GLuint buffer
Definition: glext.h:5915
#define WAVE_FORMAT_PCM
Definition: constants.h:425
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define DSERR_NODRIVER
Definition: dsound.h:128
#define IDirectSoundNotify_AddRef(p)
Definition: dsound.h:893
#define DS_OK
Definition: dsound.h:116
void init_format(WAVEFORMATEX *wfx, int format, int rate, int depth, int channels)
Definition: ds3d.c:154
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define IDirectSoundCapture_CreateCaptureBuffer(p, a, b, c)
Definition: dsound.h:738
#define S_OK
Definition: intsafe.h:59
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
#define ok(value,...)
Definition: atltest.h:57
#define DSERR_NOAGGREGATION
Definition: dsound.h:130
#define skip(...)
Definition: atltest.h:64
#define IDirectSoundCapture_AddRef(p)
Definition: dsound.h:735
unsigned int ULONG
Definition: retypes.h:1
#define IDirectSoundNotify_Release(p)
Definition: dsound.h:894
#define IDirectSoundCaptureBuffer_QueryInterface(p, a, b)
Definition: dsound.h:777
#define IDirectSoundCapture_QueryInterface(p, a, b)
Definition: dsound.h:734

Referenced by START_TEST().

◆ test_enumerate()

static void test_enumerate ( void  )
static

Definition at line 662 of file capture.c.

663 {
664  HRESULT rc;
665  rc=pDirectSoundCaptureEnumerateA(&dscenum_callback,NULL);
666  ok(rc==DS_OK,"DirectSoundCaptureEnumerateA() failed: %08x\n", rc);
667 }
smooth NULL
Definition: ftsmooth.c:416
#define DS_OK
Definition: dsound.h:116
LONG HRESULT
Definition: typedefs.h:77
static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
Definition: capture.c:424
#define ok(value,...)
Definition: atltest.h:57

Referenced by START_TEST().

Variable Documentation

◆ LPUNKNOWN

Definition at line 28 of file capture.c.

◆ LPVOID

Definition at line 29 of file capture.c.

Referenced by CDirectSoundCapture_fnQueryInterface(), and NewDirectSoundCapture().