ReactOS  0.4.13-dev-544-gede3fdd
dsound_test.h File Reference
#include <math.h>
#include <wine/test.h>
#include <wingdi.h>
#include <mmreg.h>
#include <mmsystem.h>
#include <dsound.h>
#include <dsconf.h>
#include <ks.h>
#include <ksmedia.h>
Include dependency graph for dsound_test.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define COBJMACROS
 
#define NB_FORMATS   (sizeof(formats)/sizeof(*formats))
 
#define NB_TAGS   (sizeof(format_tags)/sizeof(*format_tags))
 
#define TIME_SLICE   31
 
#define BUFFER_LEN   400
 

Functions

charwave_generate_la (WAVEFORMATEX *, double, DWORD *, BOOL)
 
HWND get_hwnd (void)
 
void init_format (WAVEFORMATEX *, int, int, int, int)
 
void test_buffer (LPDIRECTSOUND, LPDIRECTSOUNDBUFFER *, BOOL, BOOL, LONG, BOOL, LONG, BOOL, double, BOOL, LPDIRECTSOUND3DLISTENER, BOOL, BOOL, BOOL, DWORD)
 
void test_buffer8 (LPDIRECTSOUND8, LPDIRECTSOUNDBUFFER *, BOOL, BOOL, LONG, BOOL, LONG, BOOL, double, BOOL, LPDIRECTSOUND3DLISTENER, BOOL, BOOL)
 
const chargetDSBCAPS (DWORD xmask)
 
int align (int length, int align)
 
const charformat_string (const WAVEFORMATEX *wfx)
 

Variables

static const unsigned int formats [][4]
 
static const unsigned int format_tags [] = {WAVE_FORMAT_PCM, WAVE_FORMAT_IEEE_FLOAT}
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 27 of file dsound_test.h.

◆ BUFFER_LEN

#define BUFFER_LEN   400

Definition at line 98 of file dsound_test.h.

◆ COBJMACROS

#define COBJMACROS

Definition at line 29 of file dsound_test.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 28 of file dsound_test.h.

◆ NB_FORMATS

#define NB_FORMATS   (sizeof(formats)/sizeof(*formats))

Definition at line 91 of file dsound_test.h.

◆ NB_TAGS

Definition at line 94 of file dsound_test.h.

◆ TIME_SLICE

#define TIME_SLICE   31

Definition at line 97 of file dsound_test.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 26 of file dsound_test.h.

Function Documentation

◆ align()

int align ( int  length,
int  align 
)

Definition at line 36 of file dsound8.c.

37 {
38  return (length / align) * align;
39 }
int align(int length, int align)
Definition: dsound8.c:36
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579

Referenced by _test_img_align(), align(), align_length(), align_output(), align_pointer(), align_pointer_clear(), align_pointer_offset(), align_pointer_offset_clear(), clamp_align(), d3d8_device_DrawIndexedPrimitiveUP(), d3d8_device_DrawPrimitiveUP(), d3d9_device_DrawIndexedPrimitiveUP(), d3d9_device_DrawPrimitiveUP(), d3d_device7_DrawIndexedPrimitive(), d3d_device7_DrawIndexedPrimitiveStrided(), d3d_device7_DrawPrimitive(), d3d_device7_DrawPrimitiveStrided(), DrawStatusTextW(), EMFDRV_SetTextAlign(), field_memsize(), fields_memsize(), GdipGetStringFormatAlign(), GdipGetStringFormatLineAlign(), GdipSetStringFormatAlign(), GdipSetStringFormatLineAlign(), get_padding(), get_required_buffer_size_type(), ME_DebugWrite(), ME_DrawParagraph(), ME_InsertRowStart(), MFDRV_SetTextAlign(), psh_hint_align(), query_align_status(), test_constructor(), test_dsound(), test_dsound8(), test_frequency(), test_getgenericdefault(), test_getgenerictypographic(), test_primary_secondary(), test_primary_secondary8(), test_secondary(), test_secondary8(), test_SysAllocString(), test_TabbedText(), ThemeDrawCaptionText(), TLB_get_size_from_hreftype(), TLB_size_instance(), TREEVIEW_DrawItem(), type_buffer_alignment(), type_memsize(), type_memsize_and_alignment(), UDFFindMinSuitableExtent(), union_memsize(), VARIANT_UserMarshal(), VARIANT_UserSize(), VARIANT_UserUnmarshal(), wined3d_resource_allocate_sysmem(), write_array_tfs(), write_fixed_array_pointer_descriptions(), write_func_param_struct(), write_no_repeat_pointer_descriptions(), write_pointer_description_offsets(), write_struct_members(), write_struct_tfs(), write_union_tfs(), write_varying_array_pointer_descriptions(), XXH_readLE32_align(), and XXH_readLE64_align().

◆ 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_hwnd()

HWND get_hwnd ( void  )

Definition at line 146 of file ds3d.c.

147 {
149  if (!hwnd)
151  return hwnd;
152 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:622
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392

Referenced by test_buffer(), test_primary(), test_primary_3d(), test_primary_3d_with_listener(), and test_secondary().

◆ getDSBCAPS()

const char* getDSBCAPS ( DWORD  xmask)

Definition at line 106 of file ds3d.c.

106  {
107  static struct {
108  DWORD mask;
109  const char *name;
110  } flags[] = {
111 #define FE(x) { x, #x },
125 #undef FE
126  };
127  static char buffer[512];
128  unsigned int i;
129  BOOL first = TRUE;
130 
131  buffer[0] = 0;
132 
133  for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++) {
134  if ((flags[i].mask & xmask) == flags[i].mask) {
135  if (first)
136  first = FALSE;
137  else
138  strcat(buffer, "|");
139  strcat(buffer, flags[i].name);
140  }
141  }
142 
143  return buffer;
144 }
#define TRUE
Definition: types.h:120
#define DSBCAPS_CTRLVOLUME
Definition: dsound.h:213
#define DSBCAPS_GETCURRENTPOSITION2
Definition: dsound.h:220
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define DSBCAPS_LOCSOFTWARE
Definition: dsound.h:209
const GLint * first
Definition: glext.h:5794
GLuint buffer
Definition: glext.h:5915
#define DSBCAPS_CTRLPAN
Definition: dsound.h:212
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
GLenum GLint GLuint mask
Definition: glext.h:6028
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FE(x)
#define DSBCAPS_STICKYFOCUS
Definition: dsound.h:218
#define DSBCAPS_GLOBALFOCUS
Definition: dsound.h:219
#define DSBCAPS_CTRLPOSITIONNOTIFY
Definition: dsound.h:215
#define DSBCAPS_PRIMARYBUFFER
Definition: dsound.h:206
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define DSBCAPS_STATIC
Definition: dsound.h:207
#define DSBCAPS_CTRL3D
Definition: dsound.h:210
#define DSBCAPS_CTRLFREQUENCY
Definition: dsound.h:211
Definition: name.c:36
#define DSBCAPS_MUTE3DATMAXDISTANCE
Definition: dsound.h:221
#define DSBCAPS_LOCHARDWARE
Definition: dsound.h:208
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by test_secondary(), and test_secondary8().

◆ init_format()

void init_format ( WAVEFORMATEX ,
int  ,
int  ,
int  ,
int   
)

Definition at line 154 of file ds3d.c.

156 {
157  wfx->wFormatTag=format;
158  wfx->nChannels=channels;
159  wfx->wBitsPerSample=depth;
160  wfx->nSamplesPerSec=rate;
161  wfx->nBlockAlign=wfx->nChannels*wfx->wBitsPerSample/8;
162  /* FIXME: Shouldn't this test be if (format!=WAVE_FORMAT_PCM) */
163  if (wfx->nBlockAlign==0)
164  {
165  /* align compressed formats to byte boundary */
166  wfx->nBlockAlign=1;
167  }
168  wfx->nAvgBytesPerSec=wfx->nSamplesPerSec*wfx->nBlockAlign;
169  wfx->cbSize=0;
170 }
int This channels
Definition: rdpsnd_libao.c:37
int rate
Definition: pcmconverter.c:98
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546

Referenced by dscenum_callback(), test_block_align(), test_buffer(), test_buffer8(), test_COM(), test_dsound(), test_dsound8(), test_duplicate(), test_frequency(), test_primary(), test_primary8(), test_primary_secondary(), test_primary_secondary8(), test_secondary(), and test_secondary8().

◆ test_buffer()

void test_buffer ( LPDIRECTSOUND  ,
LPDIRECTSOUNDBUFFER ,
BOOL  ,
BOOL  ,
LONG  ,
BOOL  ,
LONG  ,
BOOL  ,
double  ,
BOOL  ,
LPDIRECTSOUND3DLISTENER  ,
BOOL  ,
BOOL  ,
BOOL  ,
DWORD   
)

Definition at line 315 of file ds3d.c.

321 {
322  HRESULT rc;
323  DSBCAPS dsbcaps;
324  WAVEFORMATEX wfx,wfx2;
325  DWORD size,status,freq;
326  BOOL ieee = FALSE;
327  int ref;
328 
329  if (set_frequency) {
331  ok(rc==DS_OK||rc==DSERR_CONTROLUNAVAIL,
332  "IDirectSoundBuffer_SetFrequency() failed to set frequency %08x\n",rc);
333  if (rc!=DS_OK)
334  return;
335  }
336 
337  /* DSOUND: Error: Invalid caps pointer */
338  rc=IDirectSoundBuffer_GetCaps(*dsbo,0);
339  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
340  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
341 
342  ZeroMemory(&dsbcaps, sizeof(dsbcaps));
343 
344  /* DSOUND: Error: Invalid caps pointer */
345  rc=IDirectSoundBuffer_GetCaps(*dsbo,&dsbcaps);
346  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
347  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
348 
349  dsbcaps.dwSize=sizeof(dsbcaps);
350  rc=IDirectSoundBuffer_GetCaps(*dsbo,&dsbcaps);
351  ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() failed: %08x\n", rc);
352  if (rc==DS_OK && winetest_debug > 1) {
353  trace(" Caps: flags=0x%08x size=%d\n",dsbcaps.dwFlags,
354  dsbcaps.dwBufferBytes);
355  }
356 
357  /* Query the format size. */
358  size=0;
360  ok(rc==DS_OK && size!=0,"IDirectSoundBuffer_GetFormat() should have "
361  "returned the needed size: rc=%08x size=%d\n",rc,size);
362 
363  ok(size == sizeof(WAVEFORMATEX) || size == sizeof(WAVEFORMATEXTENSIBLE),
364  "Expected a correct structure size, got %d\n", size);
365 
366  if (size == sizeof(WAVEFORMATEX)) {
367  rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,size,NULL);
368  ieee = (wfx.wFormatTag == WAVE_FORMAT_IEEE_FLOAT);
369  }
370  else if (size == sizeof(WAVEFORMATEXTENSIBLE)) {
373  wfx = wfxe.Format;
375  } else
376  return;
377 
378  ok(rc==DS_OK,
379  "IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
380  if (rc==DS_OK && winetest_debug > 1) {
381  trace(" Format: %s tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
382  is_primary ? "Primary" : "Secondary",
385  }
386 
387  /* DSOUND: Error: Invalid frequency buffer */
389  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetFrequency() should have "
390  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
391 
392  /* DSOUND: Error: Primary buffers don't support CTRLFREQUENCY */
393  rc=IDirectSoundBuffer_GetFrequency(*dsbo,&freq);
394  ok((rc==DS_OK && !is_primary) || (rc==DSERR_CONTROLUNAVAIL&&is_primary) ||
396  "IDirectSoundBuffer_GetFrequency() failed: %08x\n",rc);
397  if (rc==DS_OK) {
398  DWORD f = set_frequency?frequency:wfx.nSamplesPerSec;
399  ok(freq==f,"The frequency returned by GetFrequency "
400  "%d does not match the format %d\n",freq,f);
401  }
402 
403  /* DSOUND: Error: Invalid status pointer */
404  rc=IDirectSoundBuffer_GetStatus(*dsbo,0);
405  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetStatus() should have "
406  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
407 
409  ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %08x\n", rc);
410  ok(status==0,"status=0x%x instead of 0\n",status);
411 
412  if (is_primary) {
413  DSBCAPS new_dsbcaps;
414  /* We must call SetCooperativeLevel to be allowed to call SetFormat */
415  /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
417  ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: %08x\n",rc);
418  if (rc!=DS_OK)
419  return;
420 
421  /* DSOUND: Error: Invalid format pointer */
422  rc=IDirectSoundBuffer_SetFormat(*dsbo,0);
423  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_SetFormat() should have "
424  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
425 
426  init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
427  rc=IDirectSoundBuffer_SetFormat(*dsbo,&wfx2);
428  ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat(%s) failed: %08x\n",
429  format_string(&wfx2), rc);
430 
431  /* There is no guarantee that SetFormat will actually change the
432  * format to what we asked for. It depends on what the soundcard
433  * supports. So we must re-query the format.
434  */
435  rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,sizeof(wfx),NULL);
436  ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
437  if (rc==DS_OK &&
438  (wfx.wFormatTag!=wfx2.wFormatTag ||
439  wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
440  wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
441  wfx.nChannels!=wfx2.nChannels)) {
442  trace("Requested format tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
444  wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
445  trace("Got tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
448  }
449 
450  ZeroMemory(&new_dsbcaps, sizeof(new_dsbcaps));
451  new_dsbcaps.dwSize = sizeof(new_dsbcaps);
452  rc=IDirectSoundBuffer_GetCaps(*dsbo,&new_dsbcaps);
453  ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() failed: %08x\n", rc);
454  if (rc==DS_OK && winetest_debug > 1) {
455  trace(" new Caps: flags=0x%08x size=%d\n",new_dsbcaps.dwFlags,
456  new_dsbcaps.dwBufferBytes);
457  }
458 
459  /* Check for primary buffer size change */
460  ok(new_dsbcaps.dwBufferBytes == dsbcaps.dwBufferBytes,
461  " buffer size changed after SetFormat() - "
462  "previous size was %u, current size is %u\n",
463  dsbcaps.dwBufferBytes, new_dsbcaps.dwBufferBytes);
464  dsbcaps.dwBufferBytes = new_dsbcaps.dwBufferBytes;
465 
466  /* Check for primary buffer flags change */
467  ok(new_dsbcaps.dwFlags == dsbcaps.dwFlags,
468  " flags changed after SetFormat() - "
469  "previous flags were %08x, current flags are %08x\n",
470  dsbcaps.dwFlags, new_dsbcaps.dwFlags);
471 
472  /* Set the CooperativeLevel back to normal */
473  /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
475  ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) failed: %08x\n",rc);
476  }
477 
478  if (play) {
480  DS3DLISTENER listener_param;
482  DS3DBUFFER buffer_param;
483  DWORD start_time,now;
484  LPVOID buffer1;
485  DWORD length1;
486 
487  if (winetest_interactive) {
488  if (set_frequency)
489  trace(" Playing %g second 440Hz tone at %dx%dx%d with a "
490  "frequency of %d (%dHz)\n", duration,
492  frequency, (440 * frequency) / wfx.nSamplesPerSec);
493  else
494  trace(" Playing %g second 440Hz tone at %dx%dx%d\n", duration,
495  wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nChannels);
496  }
497 
498  if (is_primary) {
499  /* We must call SetCooperativeLevel to be allowed to call Lock */
500  /* DSOUND: Setting DirectSound cooperative level to
501  * DSSCL_WRITEPRIMARY */
504  ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_WRITEPRIMARY) "
505  "failed: %08x\n",rc);
506  if (rc!=DS_OK)
507  return;
508  }
509  if (buffer3d) {
510  LPDIRECTSOUNDBUFFER temp_buffer;
511 
512  rc=IDirectSoundBuffer_QueryInterface(*dsbo,&IID_IDirectSound3DBuffer,
513  (LPVOID *)&buffer);
514  ok(rc==DS_OK,"IDirectSoundBuffer_QueryInterface() failed: %08x\n", rc);
515  if (rc!=DS_OK)
516  return;
517 
518  /* check the COM interface */
519  rc=IDirectSoundBuffer_QueryInterface(*dsbo, &IID_IDirectSoundBuffer,
520  (LPVOID *)&temp_buffer);
521  ok(rc==DS_OK && temp_buffer!=NULL,
522  "IDirectSoundBuffer_QueryInterface() failed: %08x\n", rc);
523  ok(temp_buffer==*dsbo,"COM interface broken: %p != %p\n",
524  temp_buffer,*dsbo);
525  ref=IDirectSoundBuffer_Release(temp_buffer);
526  ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
527  "should have 1\n",ref);
528 
529  temp_buffer=NULL;
531  &IID_IDirectSoundBuffer,
532  (LPVOID *)&temp_buffer);
533  ok(rc==DS_OK && temp_buffer!=NULL,
534  "IDirectSound3DBuffer_QueryInterface() failed: %08x\n", rc);
535  ok(temp_buffer==*dsbo,"COM interface broken: %p != %p\n",
536  temp_buffer,*dsbo);
537  ref=IDirectSoundBuffer_Release(temp_buffer);
538  ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
539  "should have 1\n",ref);
540 
542  ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
543  "should have 0\n",ref);
544 
546  &IID_IDirectSoundBuffer,
547  (LPVOID *)dsbo);
548  ok(rc==DS_OK && *dsbo!=NULL,"IDirectSound3DBuffer_QueryInterface() "
549  "failed: %08x\n",rc);
550 
551  /* DSOUND: Error: Invalid buffer */
553  ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
554  "failed: %08x\n",rc);
555 
556  ZeroMemory(&buffer_param, sizeof(buffer_param));
557 
558  /* DSOUND: Error: Invalid buffer */
560  ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
561  "failed: %08x\n",rc);
562 
563  buffer_param.dwSize=sizeof(buffer_param);
565  ok(rc==DS_OK,"IDirectSound3DBuffer_GetAllParameters() failed: %08x\n", rc);
566  }
567  if (set_volume) {
568  if (dsbcaps.dwFlags & DSBCAPS_CTRLVOLUME) {
569  LONG val;
571  ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %08x\n", rc);
572 
574  ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume() failed: %08x\n", rc);
575  } else {
576  /* DSOUND: Error: Buffer does not have CTRLVOLUME */
578  ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetVolume() "
579  "should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc);
580  }
581  }
582 
583  if (set_pan) {
584  if (dsbcaps.dwFlags & DSBCAPS_CTRLPAN) {
585  LONG val;
586  rc=IDirectSoundBuffer_GetPan(*dsbo,&val);
587  ok(rc==DS_OK,"IDirectSoundBuffer_GetPan() failed: %08x\n", rc);
588 
589  rc=IDirectSoundBuffer_SetPan(*dsbo,pan);
590  ok(rc==DS_OK,"IDirectSoundBuffer_SetPan() failed: %08x\n", rc);
591  } else {
592  /* DSOUND: Error: Buffer does not have CTRLPAN */
593  rc=IDirectSoundBuffer_GetPan(*dsbo,&pan);
594  ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetPan() "
595  "should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc);
596  }
597  }
598 
599  /* try an offset past the end of the buffer */
600  rc = IDirectSoundBuffer_Lock(*dsbo, dsbcaps.dwBufferBytes, 0, &buffer1,
601  &length1, NULL, NULL,
603  ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
604  "returned DSERR_INVALIDPARAM, returned %08x\n", rc);
605 
606  /* try a size larger than the buffer */
607  rc = IDirectSoundBuffer_Lock(*dsbo, 0, dsbcaps.dwBufferBytes + 1,
608  &buffer1, &length1, NULL, NULL,
610  ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
611  "returned DSERR_INVALIDPARAM, returned %08x\n", rc);
612 
613  if (set_frequency)
614  state.wave=wave_generate_la(&wfx,(duration*frequency)/wfx.nSamplesPerSec,&state.wave_len,ieee);
615  else
616  state.wave=wave_generate_la(&wfx,duration,&state.wave_len,ieee);
617 
618  state.dsbo=*dsbo;
619  state.wfx=&wfx;
620  state.buffer_size=dsbcaps.dwBufferBytes;
621  state.played=state.written=state.offset=0;
622  buffer_refill(&state,state.buffer_size);
623 
625  ok(rc==DS_OK,"IDirectSoundBuffer_Play() failed: %08x\n", rc);
626 
628  ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %08x\n", rc);
630  "GetStatus: bad status: %x\n",status);
631 
632  if (listener) {
633  ZeroMemory(&listener_param,sizeof(listener_param));
634  listener_param.dwSize=sizeof(listener_param);
636  &listener_param);
637  ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
638  "failed: %08x\n",rc);
639  if (move_listener) {
640  listener_param.vPosition.x = -5.0f;
641  listener_param.vVelocity.x = (float)(10.0/duration);
642  }
644  &listener_param,
646  ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: %08x\n", rc);
647  }
648  if (buffer3d) {
649  if (move_sound) {
650  buffer_param.vPosition.x = 100.0f;
651  buffer_param.vVelocity.x = (float)(-200.0/duration);
652  }
653  buffer_param.flMinDistance = 10;
656  ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %08x\n", rc);
657  }
658 
659  start_time=GetTickCount();
660  while (buffer_service(&state)) {
662  now=GetTickCount();
663  if (listener && move_listener) {
664  listener_param.vPosition.x = (float)(-5.0+10.0*(now-start_time)/1000/duration);
665  if (winetest_debug>2)
666  trace("listener position=%g\n",listener_param.vPosition.x);
668  listener_param.vPosition.x,listener_param.vPosition.y,
669  listener_param.vPosition.z,DS3D_IMMEDIATE);
670  ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: %08x\n",rc);
671  }
672  if (buffer3d && move_sound) {
673  buffer_param.vPosition.x = (float)(100-200.0*(now-start_time)/1000/duration);
674  if (winetest_debug>2)
675  trace("sound position=%g\n",buffer_param.vPosition.x);
677  buffer_param.vPosition.x,buffer_param.vPosition.y,
678  buffer_param.vPosition.z,DS3D_IMMEDIATE);
679  ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %08x\n", rc);
680  }
681  }
682  /* Check the sound duration was within 10% of the expected value */
683  now=GetTickCount();
684  ok(fabs(1000*duration-now+start_time)<=100*duration,
685  "The sound played for %d ms instead of %g ms\n",
686  now-start_time,1000*duration);
687 
688  HeapFree(GetProcessHeap(), 0, state.wave);
689  if (is_primary) {
690  /* Set the CooperativeLevel back to normal */
691  /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
693  ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) "
694  "failed: %08x\n",rc);
695  }
696  if (buffer3d) {
698  ok(ref==0,"IDirectSound3DBuffer_Release() has %d references, "
699  "should have 0\n",ref);
700  }
701  }
702 }
#define IDirectSoundBuffer_Lock(p, a, b, c, d, e, f, g)
Definition: dsound.h:584
#define trace(...)
Definition: kmt_test.h:217
#define DSBCAPS_CTRLVOLUME
Definition: dsound.h:213
#define IDirectSoundBuffer_GetFormat(p, a, b, c)
Definition: dsound.h:578
DWORD dwSize
Definition: dsound.h:239
#define IDirectSound3DBuffer_QueryInterface(p, a, b)
Definition: dsound.h:1071
#define IDirectSoundBuffer_Release(p)
Definition: dsound.h:574
#define TIME_SLICE
Definition: dsound_test.h:97
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define ZeroMemory
Definition: winbase.h:1635
GLuint buffer
Definition: glext.h:5915
#define DS3D_IMMEDIATE
Definition: dsound.h:914
#define DSBCAPS_CTRLPAN
Definition: dsound.h:212
#define IDirectSound3DBuffer_SetPosition(p, a, b, c, d)
Definition: dsound.h:1091
int winetest_interactive
GUID KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
D3DVECTOR vVelocity
Definition: dsound.h:1028
int winetest_debug
Definition: send.c:47
char * wave_generate_la(WAVEFORMATEX *wfx, double duration, DWORD *size, BOOL ieee)
Definition: ds3d.c:35
#define DSSCL_NORMAL
Definition: dsound.h:247
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAVE_FORMAT_PCM
Definition: constants.h:425
static int buffer_service(play_state_t *state)
Definition: ds3d.c:246
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define IDirectSoundBuffer_QueryInterface(p, a, b)
Definition: dsound.h:572
time_t now
Definition: finger.c:65
#define IDirectSoundBuffer_GetVolume(p, a)
Definition: dsound.h:579
GLenum GLint ref
Definition: glext.h:6028
WORD wBitsPerSample
Definition: audioclient.idl:45
#define IDirectSoundBuffer_GetCaps(p, a)
Definition: dsound.h:576
#define ok(value,...)
D3DVECTOR vVelocity
Definition: dsound.h:941
#define IDirectSoundBuffer_SetVolume(p, a)
Definition: dsound.h:588
smooth NULL
Definition: ftsmooth.c:416
DWORD nSamplesPerSec
Definition: audioclient.idl:42
GLuint GLfloat * val
Definition: glext.h:7180
GLfloat f
Definition: glext.h:7540
#define DS_OK
Definition: dsound.h:116
#define DSBSTATUS_LOOPING
Definition: dsound.h:198
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
void init_format(WAVEFORMATEX *wfx, int format, int rate, int depth, int channels)
Definition: ds3d.c:154
#define DSBLOCK_FROMWRITECURSOR
Definition: dsound.h:203
#define DSBPLAY_LOOPING
Definition: dsound.h:189
WAVEFORMATEX Format
Definition: ksmedia.h:538
#define IDirectSound3DListener_SetPosition(p, a, b, c, d)
Definition: dsound.h:994
LONG HRESULT
Definition: typedefs.h:77
DWORD dwFlags
Definition: dsound.h:240
#define IDirectSound3DBuffer_GetAllParameters(p, a)
Definition: dsound.h:1075
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
#define DSERR_CONTROLUNAVAIL
Definition: dsound.h:120
DWORD dwBufferBytes
Definition: dsound.h:241
#define IDirectSoundBuffer_GetStatus(p, a)
Definition: dsound.h:582
#define IDirectSound3DListener_SetAllParameters(p, a, b)
Definition: dsound.h:990
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND get_hwnd(void)
Definition: ds3d.c:146
const char * format_string(const WAVEFORMATEX *wfx)
Definition: capture.c:84
#define DSBSTATUS_PLAYING
Definition: dsound.h:196
static int state
Definition: maze.c:121
#define IDirectSoundBuffer_SetFrequency(p, a)
Definition: dsound.h:590
#define IDirectSound3DBuffer_Release(p)
Definition: dsound.h:1073
#define IDirectSound3DListener_GetAllParameters(p, a)
Definition: dsound.h:983
#define IDirectSoundBuffer_SetPan(p, a)
Definition: dsound.h:589
#define IDirectSound_SetCooperativeLevel(p, a, b)
Definition: dsound.h:458
struct IDirectSoundBuffer * LPDIRECTSOUNDBUFFER
Definition: dsound.h:76
static LARGE_INTEGER * frequency
Definition: time.c:106
#define IDirectSoundBuffer_GetFrequency(p, a)
Definition: dsound.h:581
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
D3DVALUE flMinDistance
Definition: dsound.h:1033
DWORD dwSize
Definition: dsound.h:939
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
#define DSBCAPS_CTRLFREQUENCY
Definition: dsound.h:211
#define DSSCL_WRITEPRIMARY
Definition: dsound.h:250
struct IDirectSound3DBuffer * LPDIRECTSOUND3DBUFFER
Definition: dsound.h:89
D3DVECTOR vPosition
Definition: dsound.h:940
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
#define IDirectSoundBuffer_SetFormat(p, a)
Definition: dsound.h:587
#define IDirectSound3DBuffer_SetAllParameters(p, a, b)
Definition: dsound.h:1084
static int buffer_refill(play_state_t *state, DWORD size)
Definition: ds3d.c:184
#define IDirectSoundBuffer_GetPan(p, a)
Definition: dsound.h:580
DWORD dwSize
Definition: dsound.h:1026
#define IDirectSoundBuffer_Play(p, a, b, c)
Definition: dsound.h:585
#define DSSCL_PRIORITY
Definition: dsound.h:248
static SERVICE_STATUS status
Definition: service.c:31
#define DSBLOCK_ENTIREBUFFER
Definition: dsound.h:204
#define HeapFree(x, y, z)
Definition: compat.h:394
#define WAVE_FORMAT_IEEE_FLOAT
Definition: mmreg.h:97
D3DVECTOR vPosition
Definition: dsound.h:1027
Definition: ps.c:97

Referenced by test_primary(), test_primary_3d(), test_primary_3d_with_listener(), and test_secondary().

◆ test_buffer8()

void test_buffer8 ( LPDIRECTSOUND8  ,
LPDIRECTSOUNDBUFFER ,
BOOL  ,
BOOL  ,
LONG  ,
BOOL  ,
LONG  ,
BOOL  ,
double  ,
BOOL  ,
LPDIRECTSOUND3DLISTENER  ,
BOOL  ,
BOOL   
)

Definition at line 167 of file ds3d8.c.

172 {
173  HRESULT rc;
174  DSBCAPS dsbcaps;
175  WAVEFORMATEX wfx,wfx2;
176  DWORD size,status,freq;
177  BOOL ieee = FALSE;
178  int ref;
179 
180  /* DSOUND: Error: Invalid caps pointer */
181  rc=IDirectSoundBuffer_GetCaps(*dsbo,0);
182  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
183  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
184 
185  ZeroMemory(&dsbcaps, sizeof(dsbcaps));
186 
187  /* DSOUND: Error: Invalid caps pointer */
188  rc=IDirectSoundBuffer_GetCaps(*dsbo,&dsbcaps);
189  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
190  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
191 
192  dsbcaps.dwSize=sizeof(dsbcaps);
193  rc=IDirectSoundBuffer_GetCaps(*dsbo,&dsbcaps);
194  ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() failed: %08x\n", rc);
195  if (rc==DS_OK && winetest_debug > 1) {
196  trace(" Caps: flags=0x%08x size=%d\n",dsbcaps.dwFlags,
197  dsbcaps.dwBufferBytes);
198  }
199 
200  /* Query the format size. */
201  size=0;
203  ok(rc==DS_OK && size!=0,"IDirectSoundBuffer_GetFormat() should have "
204  "returned the needed size: rc=%08x size=%d\n",rc,size);
205 
206  ok(size == sizeof(WAVEFORMATEX) || size == sizeof(WAVEFORMATEXTENSIBLE),
207  "Expected a correct structure size, got %d\n", size);
208 
209  if (size == sizeof(WAVEFORMATEX)) {
210  rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,size,NULL);
211  ieee = (wfx.wFormatTag == WAVE_FORMAT_IEEE_FLOAT);
212  } else if (size == sizeof(WAVEFORMATEXTENSIBLE)) {
215  wfx = wfxe.Format;
217  } else
218  return;
219 
220  ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
221  if (rc==DS_OK && winetest_debug > 1) {
222  trace(" Format: %s tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
223  is_primary ? "Primary" : "Secondary",
226  }
227 
228  /* DSOUND: Error: Invalid frequency buffer */
230  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetFrequency() should have "
231  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
232 
233  /* DSOUND: Error: Primary buffers don't support CTRLFREQUENCY */
234  rc=IDirectSoundBuffer_GetFrequency(*dsbo,&freq);
235  ok((rc==DS_OK && !is_primary) || (rc==DSERR_CONTROLUNAVAIL&&is_primary) ||
237  "IDirectSoundBuffer_GetFrequency() failed: %08x\n",rc);
238  if (rc==DS_OK) {
239  ok(freq==wfx.nSamplesPerSec,"The frequency returned by GetFrequency "
240  "%d does not match the format %d\n",freq,wfx.nSamplesPerSec);
241  }
242 
243  /* DSOUND: Error: Invalid status pointer */
244  rc=IDirectSoundBuffer_GetStatus(*dsbo,0);
245  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetStatus() should have "
246  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
247 
249  ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %08x\n", rc);
250  ok(status==0,"status=0x%x instead of 0\n",status);
251 
252  if (is_primary) {
253  DSBCAPS new_dsbcaps;
254  /* We must call SetCooperativeLevel to be allowed to call SetFormat */
255  /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
257  ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_PRIORITY) "
258  "failed: %08x\n",rc);
259  if (rc!=DS_OK)
260  return;
261 
262  /* DSOUND: Error: Invalid format pointer */
263  rc=IDirectSoundBuffer_SetFormat(*dsbo,0);
264  ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_SetFormat() should have "
265  "returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
266 
267  init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
268  rc=IDirectSoundBuffer_SetFormat(*dsbo,&wfx2);
269  ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat(%s) failed: %08x\n",
270  format_string(&wfx2), rc);
271 
272  /* There is no guarantee that SetFormat will actually change the
273  * format to what we asked for. It depends on what the soundcard
274  * supports. So we must re-query the format.
275  */
276  rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,sizeof(wfx),NULL);
277  ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
278  if (rc==DS_OK &&
279  (wfx.wFormatTag!=wfx2.wFormatTag ||
280  wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
281  wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
282  wfx.nChannels!=wfx2.nChannels)) {
283  trace("Requested format tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
285  wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
286  trace("Got tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
289  }
290 
291  ZeroMemory(&new_dsbcaps, sizeof(new_dsbcaps));
292  new_dsbcaps.dwSize = sizeof(new_dsbcaps);
293  rc=IDirectSoundBuffer_GetCaps(*dsbo,&new_dsbcaps);
294  ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() failed: %08x\n", rc);
295  if (rc==DS_OK && winetest_debug > 1) {
296  trace(" new Caps: flags=0x%08x size=%d\n",new_dsbcaps.dwFlags,
297  new_dsbcaps.dwBufferBytes);
298  }
299 
300  /* Check for primary buffer size change */
301  ok(new_dsbcaps.dwBufferBytes == dsbcaps.dwBufferBytes,
302  " buffer size changed after SetFormat() - "
303  "previous size was %u, current size is %u\n",
304  dsbcaps.dwBufferBytes, new_dsbcaps.dwBufferBytes);
305  dsbcaps.dwBufferBytes = new_dsbcaps.dwBufferBytes;
306 
307  /* Check for primary buffer flags change */
308  ok(new_dsbcaps.dwFlags == dsbcaps.dwFlags,
309  " flags changed after SetFormat() - "
310  "previous flags were %08x, current flags are %08x\n",
311  dsbcaps.dwFlags, new_dsbcaps.dwFlags);
312 
313  /* Set the CooperativeLevel back to normal */
314  /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
316  ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) "
317  "failed: %08x\n",rc);
318  }
319 
320  if (play) {
322  DS3DLISTENER listener_param;
324  DS3DBUFFER buffer_param;
325  DWORD start_time,now;
326  LPVOID buffer1;
327  DWORD length1;
328 
329  if (winetest_interactive) {
330  trace(" Playing %g second 440Hz tone at %dx%dx%d\n", duration,
332  }
333 
334  if (is_primary) {
335  /* We must call SetCooperativeLevel to be allowed to call Lock */
336  /* DSOUND: Setting DirectSound cooperative level to
337  * DSSCL_WRITEPRIMARY */
340  ok(rc==DS_OK,
341  "IDirectSound8_SetCooperativeLevel(DSSCL_WRITEPRIMARY) failed: %08x\n",rc);
342  if (rc!=DS_OK)
343  return;
344  }
345  if (buffer3d) {
346  LPDIRECTSOUNDBUFFER temp_buffer;
347 
348  rc=IDirectSoundBuffer_QueryInterface(*dsbo,&IID_IDirectSound3DBuffer,
349  (LPVOID *)&buffer);
350  ok(rc==DS_OK,"IDirectSoundBuffer_QueryInterface() failed: %08x\n", rc);
351  if (rc!=DS_OK)
352  return;
353 
354  /* check the COM interface */
355  rc=IDirectSoundBuffer_QueryInterface(*dsbo, &IID_IDirectSoundBuffer,
356  (LPVOID *)&temp_buffer);
357  ok(rc==DS_OK && temp_buffer!=NULL,
358  "IDirectSoundBuffer_QueryInterface() failed: %08x\n", rc);
359  ok(temp_buffer==*dsbo,"COM interface broken: %p != %p\n",
360  temp_buffer,*dsbo);
361  ref=IDirectSoundBuffer_Release(temp_buffer);
362  ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
363  "should have 1\n",ref);
364 
365  temp_buffer=NULL;
366  rc=IDirectSound3DBuffer_QueryInterface(*dsbo, &IID_IDirectSoundBuffer,
367  (LPVOID *)&temp_buffer);
368  ok(rc==DS_OK && temp_buffer!=NULL,
369  "IDirectSound3DBuffer_QueryInterface() failed: %08x\n", rc);
370  ok(temp_buffer==*dsbo,"COM interface broken: %p != %p\n",
371  temp_buffer,*dsbo);
372  ref=IDirectSoundBuffer_Release(temp_buffer);
373  ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
374  "should have 1\n",ref);
375 
377  ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
378  "should have 0\n",ref);
379 
381  &IID_IDirectSoundBuffer,
382  (LPVOID *)dsbo);
383  ok(rc==DS_OK && *dsbo!=NULL,"IDirectSound3DBuffer_QueryInterface() "
384  "failed: %08x\n",rc);
385 
386  /* DSOUND: Error: Invalid buffer */
388  ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
389  "failed: %08x\n",rc);
390 
391  ZeroMemory(&buffer_param, sizeof(buffer_param));
392 
393  /* DSOUND: Error: Invalid buffer */
395  ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
396  "failed: %08x\n",rc);
397 
398  buffer_param.dwSize=sizeof(buffer_param);
400  ok(rc==DS_OK,"IDirectSound3DBuffer_GetAllParameters() failed: %08x\n", rc);
401  }
402  if (set_volume) {
403  if (dsbcaps.dwFlags & DSBCAPS_CTRLVOLUME) {
404  LONG val;
406  ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %08x\n", rc);
407 
409  ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume() failed: %08x\n", rc);
410  } else {
411  /* DSOUND: Error: Buffer does not have CTRLVOLUME */
413  ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetVolume() "
414  "should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc);
415  }
416  }
417 
418  if (set_pan) {
419  if (dsbcaps.dwFlags & DSBCAPS_CTRLPAN) {
420  LONG val;
421  rc=IDirectSoundBuffer_GetPan(*dsbo,&val);
422  ok(rc==DS_OK,"IDirectSoundBuffer_GetPan() failed: %08x\n", rc);
423 
424  rc=IDirectSoundBuffer_SetPan(*dsbo,pan);
425  ok(rc==DS_OK,"IDirectSoundBuffer_SetPan() failed: %08x\n", rc);
426  } else {
427  /* DSOUND: Error: Buffer does not have CTRLPAN */
428  rc=IDirectSoundBuffer_GetPan(*dsbo,&pan);
429  ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetPan() "
430  "should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc);
431  }
432  }
433 
434  /* try an offset past the end of the buffer */
435  rc = IDirectSoundBuffer_Lock(*dsbo, dsbcaps.dwBufferBytes, 0, &buffer1,
436  &length1, NULL, NULL,
438  ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
439  "returned DSERR_INVALIDPARAM, returned %08x\n", rc);
440 
441  /* try a size larger than the buffer */
442  rc = IDirectSoundBuffer_Lock(*dsbo, 0, dsbcaps.dwBufferBytes + 1,
443  &buffer1, &length1, NULL, NULL,
445  ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
446  "returned DSERR_INVALIDPARAM, returned %08x\n", rc);
447 
448  state.wave=wave_generate_la(&wfx,duration,&state.wave_len,ieee);
449 
450  state.dsbo=*dsbo;
451  state.wfx=&wfx;
452  state.buffer_size=dsbcaps.dwBufferBytes;
453  state.played=state.written=state.offset=0;
454  buffer_refill8(&state,state.buffer_size);
455 
457  ok(rc==DS_OK,"IDirectSoundBuffer_Play() failed: %08x\n", rc);
458 
460  ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %08x\n", rc);
462  "GetStatus: bad status: %x\n",status);
463 
464  if (listener) {
465  ZeroMemory(&listener_param,sizeof(listener_param));
466  listener_param.dwSize=sizeof(listener_param);
467  rc=IDirectSound3DListener_GetAllParameters(listener,&listener_param);
468  ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
469  "failed: %08x\n",rc);
470  if (move_listener) {
471  listener_param.vPosition.x = -5.0f;
472  listener_param.vVelocity.x = (float)(10.0/duration);
473  }
475  &listener_param,
477  ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: %08x\n", rc);
478  }
479  if (buffer3d) {
480  if (move_sound) {
481  buffer_param.vPosition.x = 100.0f;
482  buffer_param.vVelocity.x = (float)(-200.0/duration);
483  }
484  buffer_param.flMinDistance = 10;
487  ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %08x\n", rc);
488  }
489 
490  start_time=GetTickCount();
491  while (buffer_service8(&state)) {
493  now=GetTickCount();
494  if (listener && move_listener) {
495  listener_param.vPosition.x = (float)(-5.0+10.0*(now-start_time)/1000/duration);
496  if (winetest_debug>2)
497  trace("listener position=%g\n",listener_param.vPosition.x);
499  listener_param.vPosition.x,listener_param.vPosition.y,
500  listener_param.vPosition.z,DS3D_IMMEDIATE);
501  ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: %08x\n",rc);
502  }
503  if (buffer3d && move_sound) {
504  buffer_param.vPosition.x = (float)(100-200.0*(now-start_time)/1000/duration);
505  if (winetest_debug>2)
506  trace("sound position=%g\n",buffer_param.vPosition.x);
508  buffer_param.vPosition.x,buffer_param.vPosition.y,
509  buffer_param.vPosition.z,DS3D_IMMEDIATE);
510  ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %08x\n", rc);
511  }
512  }
513  /* Check the sound duration was within 10% of the expected value */
514  now=GetTickCount();
515  ok(fabs(1000*duration-now+start_time)<=100*duration,
516  "The sound played for %d ms instead of %g ms\n",
517  now-start_time,1000*duration);
518 
519  HeapFree(GetProcessHeap(), 0, state.wave);
520  if (is_primary) {
521  /* Set the CooperativeLevel back to normal */
522  /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
524  ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel(DSSCL_NORMAL) "
525  "failed: %08x\n",rc);
526  }
527  if (buffer3d) {
529  ok(ref==0,"IDirectSound3DBuffer_Release() has %d references, "
530  "should have 0\n",ref);
531  }
532  }
533 }
#define IDirectSoundBuffer_Lock(p, a, b, c, d, e, f, g)
Definition: dsound.h:584
#define trace(...)
Definition: kmt_test.h:217
#define IDirectSound8_SetCooperativeLevel(p, a, b)
Definition: dsound.h:512
#define DSBCAPS_CTRLVOLUME
Definition: dsound.h:213
#define IDirectSoundBuffer_GetFormat(p, a, b, c)
Definition: dsound.h:578
DWORD dwSize
Definition: dsound.h:239
#define IDirectSound3DBuffer_QueryInterface(p, a, b)
Definition: dsound.h:1071
#define IDirectSoundBuffer_Release(p)
Definition: dsound.h:574
#define TIME_SLICE
Definition: dsound_test.h:97
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
#define ZeroMemory
Definition: winbase.h:1635
GLuint buffer
Definition: glext.h:5915
#define DS3D_IMMEDIATE
Definition: dsound.h:914
#define DSBCAPS_CTRLPAN
Definition: dsound.h:212
#define IDirectSound3DBuffer_SetPosition(p, a, b, c, d)
Definition: dsound.h:1091
int winetest_interactive
GUID KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
D3DVECTOR vVelocity
Definition: dsound.h:1028
int winetest_debug
Definition: send.c:47
char * wave_generate_la(WAVEFORMATEX *wfx, double duration, DWORD *size, BOOL ieee)
Definition: ds3d.c:35
#define DSSCL_NORMAL
Definition: dsound.h:247
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAVE_FORMAT_PCM
Definition: constants.h:425
#define DSERR_INVALIDPARAM
Definition: dsound.h:121
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define IDirectSoundBuffer_QueryInterface(p, a, b)
Definition: dsound.h:572
time_t now
Definition: finger.c:65
#define IDirectSoundBuffer_GetVolume(p, a)
Definition: dsound.h:579
GLenum GLint ref
Definition: glext.h:6028
WORD wBitsPerSample
Definition: audioclient.idl:45
#define IDirectSoundBuffer_GetCaps(p, a)
Definition: dsound.h:576
#define ok(value,...)
D3DVECTOR vVelocity
Definition: dsound.h:941
#define IDirectSoundBuffer_SetVolume(p, a)
Definition: dsound.h:588
smooth NULL
Definition: ftsmooth.c:416
static int buffer_service8(play_state_t *state)
Definition: ds3d8.c:98
DWORD nSamplesPerSec
Definition: audioclient.idl:42
GLuint GLfloat * val
Definition: glext.h:7180
#define DS_OK
Definition: dsound.h:116
#define DSBSTATUS_LOOPING
Definition: dsound.h:198
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
void init_format(WAVEFORMATEX *wfx, int format, int rate, int depth, int channels)
Definition: ds3d.c:154
#define DSBLOCK_FROMWRITECURSOR
Definition: dsound.h:203
#define DSBPLAY_LOOPING
Definition: dsound.h:189
WAVEFORMATEX Format
Definition: ksmedia.h:538
#define IDirectSound3DListener_SetPosition(p, a, b, c, d)
Definition: dsound.h:994
LONG HRESULT
Definition: typedefs.h:77
DWORD dwFlags
Definition: dsound.h:240
#define IDirectSound3DBuffer_GetAllParameters(p, a)
Definition: dsound.h:1075
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
#define DSERR_CONTROLUNAVAIL
Definition: dsound.h:120
DWORD dwBufferBytes
Definition: dsound.h:241
#define IDirectSoundBuffer_GetStatus(p, a)
Definition: dsound.h:582
#define IDirectSound3DListener_SetAllParameters(p, a, b)
Definition: dsound.h:990
unsigned long DWORD
Definition: ntddk_ex.h:95
static int buffer_refill8(play_state_t *state, DWORD size)
Definition: ds3d8.c:43
const char * format_string(const WAVEFORMATEX *wfx)
Definition: capture.c:84
#define DSBSTATUS_PLAYING
Definition: dsound.h:196
static int state
Definition: maze.c:121
#define IDirectSound3DBuffer_Release(p)
Definition: dsound.h:1073
#define IDirectSound3DListener_GetAllParameters(p, a)
Definition: dsound.h:983
#define IDirectSoundBuffer_SetPan(p, a)
Definition: dsound.h:589
static HWND get_hwnd(void)
Definition: joystick.c:67
struct IDirectSoundBuffer * LPDIRECTSOUNDBUFFER
Definition: dsound.h:76
#define IDirectSoundBuffer_GetFrequency(p, a)
Definition: dsound.h:581
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
D3DVALUE flMinDistance
Definition: dsound.h:1033
DWORD dwSize
Definition: dsound.h:939
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
#define DSBCAPS_CTRLFREQUENCY
Definition: dsound.h:211
#define DSSCL_WRITEPRIMARY
Definition: dsound.h:250
struct IDirectSound3DBuffer * LPDIRECTSOUND3DBUFFER
Definition: dsound.h:89
D3DVECTOR vPosition
Definition: dsound.h:940
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
#define IDirectSoundBuffer_SetFormat(p, a)
Definition: dsound.h:587
#define IDirectSound3DBuffer_SetAllParameters(p, a, b)
Definition: dsound.h:1084
#define IDirectSoundBuffer_GetPan(p, a)
Definition: dsound.h:580
DWORD dwSize
Definition: dsound.h:1026
#define IDirectSoundBuffer_Play(p, a, b, c)
Definition: dsound.h:585
#define DSSCL_PRIORITY
Definition: dsound.h:248
static SERVICE_STATUS status
Definition: service.c:31
#define DSBLOCK_ENTIREBUFFER
Definition: dsound.h:204
#define HeapFree(x, y, z)
Definition: compat.h:394
#define WAVE_FORMAT_IEEE_FLOAT
Definition: mmreg.h:97
D3DVECTOR vPosition
Definition: dsound.h:1027
Definition: ps.c:97

Referenced by test_primary8(), test_primary_3d8(), test_primary_3d_with_listener8(), test_primary_secondary8(), and test_secondary8().

◆ wave_generate_la()

char* wave_generate_la ( WAVEFORMATEX ,
double  ,
DWORD ,
BOOL   
)

Definition at line 35 of file ds3d.c.

36 {
37  int i;
38  int nb_samples;
39  char* buf;
40  char* b;
41 
42  nb_samples=(int)(duration*wfx->nSamplesPerSec);
43  *size=nb_samples*wfx->nBlockAlign;
45  for (i=0;i<nb_samples;i++) {
46  double y=sin(440.0*2*PI*i/wfx->nSamplesPerSec);
47  if (wfx->wBitsPerSample==8) {
48  unsigned char sample=127.5*(y+1.0);
49  *b++=sample;
50  if (wfx->nChannels==2)
51  *b++=sample;
52  } else if (wfx->wBitsPerSample == 16) {
53  signed short sample=32767.5*y-0.5;
54  b[0]=sample & 0xff;
55  b[1]=sample >> 8;
56  b+=2;
57  if (wfx->nChannels==2) {
58  b[0]=sample & 0xff;
59  b[1]=sample >> 8;
60  b+=2;
61  }
62  } else if (wfx->wBitsPerSample == 24) {
63  signed int sample=8388607.5*y-0.5;
64  b[0]=sample & 0xff;
65  b[1]=(sample >> 8)&0xff;
66  b[2]=sample >> 16;
67  b+=3;
68  if (wfx->nChannels==2) {
69  b[0]=sample & 0xff;
70  b[1]=(sample >> 8)&0xff;
71  b[2]=sample >> 16;
72  b+=3;
73  }
74  } else if (wfx->wBitsPerSample == 32) {
75  if (ieee) {
76  float *ptr = (float *) b;
77  *ptr = y;
78 
79  ptr++;
80  b+=4;
81 
82  if (wfx->nChannels==2) {
83  *ptr = y;
84  b+=4;
85  }
86  } else {
87  signed int sample=2147483647.5*y-0.5;
88  b[0]=sample & 0xff;
89  b[1]=(sample >> 8)&0xff;
90  b[2]=(sample >> 16)&0xff;
91  b[3]=sample >> 24;
92  b+=4;
93  if (wfx->nChannels==2) {
94  b[0]=sample & 0xff;
95  b[1]=(sample >> 8)&0xff;
96  b[2]=(sample >> 16)&0xff;
97  b[3]=sample >> 24;
98  b+=4;
99  }
100  }
101  }
102  }
103  return buf;
104 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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
static PVOID ptr
Definition: dispmode.c:27
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define PI
Definition: ds3d.c:28
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by test_buffer(), and test_buffer8().

Variable Documentation

◆ format_tags

const unsigned int format_tags[] = {WAVE_FORMAT_PCM, WAVE_FORMAT_IEEE_FLOAT}
static

◆ formats

const unsigned int formats[][4]
static

Definition at line 41 of file dsound_test.h.