ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

dsound.c
Go to the documentation of this file.
00001 /*
00002  * Tests basic sound playback in DirectSound.
00003  * In particular we test each standard Windows sound format to make sure
00004  * we handle the sound card/driver quirks correctly.
00005  *
00006  * Part of this test involves playing test tones. But this only makes
00007  * sense if someone is going to carefully listen to it, and would only
00008  * bother everyone else.
00009  * So this is only done if the test is being run in interactive mode.
00010  *
00011  * Copyright (c) 2002-2004 Francois Gouget
00012  *
00013  * This library is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU Lesser General Public
00015  * License as published by the Free Software Foundation; either
00016  * version 2.1 of the License, or (at your option) any later version.
00017  *
00018  * This library is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  * Lesser General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public
00024  * License along with this library; if not, write to the Free Software
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  */
00027 
00028 #define NONAMELESSSTRUCT
00029 #define NONAMELESSUNION
00030 #include <windows.h>
00031 
00032 #include "wine/test.h"
00033 #include "dsound.h"
00034 #include "dxerr8.h"
00035 #include "dsconf.h"
00036 
00037 #include "dsound_test.h"
00038 
00039 static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized,
00040                               LPCGUID lpGuid)
00041 {
00042     HRESULT rc;
00043     DSCAPS dscaps;
00044     int ref;
00045     IUnknown * unknown;
00046     IDirectSound * ds;
00047     IDirectSound8 * ds8;
00048     DWORD speaker_config, new_speaker_config;
00049 
00050     /* Try to Query for objects */
00051     rc=IDirectSound_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown);
00052     ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IUnknown) failed: %s\n",
00053        DXGetErrorString8(rc));
00054     if (rc==DS_OK)
00055         IDirectSound_Release(unknown);
00056 
00057     rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds);
00058     ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IDirectSound) failed: %s\n",
00059        DXGetErrorString8(rc));
00060     if (rc==DS_OK)
00061         IDirectSound_Release(ds);
00062 
00063     rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
00064     ok(rc==E_NOINTERFACE,"IDirectSound_QueryInterface(IID_IDirectSound8) "
00065        "should have failed: %s\n",DXGetErrorString8(rc));
00066     if (rc==DS_OK)
00067         IDirectSound8_Release(ds8);
00068 
00069     if (initialized == FALSE) {
00070         /* try unitialized object */
00071         rc=IDirectSound_GetCaps(dso,0);
00072         ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetCaps(NULL) "
00073            "should have returned DSERR_UNINITIALIZED, returned: %s\n",
00074            DXGetErrorString8(rc));
00075 
00076         rc=IDirectSound_GetCaps(dso,&dscaps);
00077         ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetCaps() "
00078            "should have returned DSERR_UNINITIALIZED, returned: %s\n",
00079            DXGetErrorString8(rc));
00080 
00081         rc=IDirectSound_Compact(dso);
00082         ok(rc==DSERR_UNINITIALIZED,"IDirectSound_Compact() "
00083            "should have returned DSERR_UNINITIALIZED, returned: %s\n",
00084            DXGetErrorString8(rc));
00085 
00086         rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config);
00087         ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetSpeakerConfig() "
00088            "should have returned DSERR_UNINITIALIZED, returned: %s\n",
00089            DXGetErrorString8(rc));
00090 
00091         rc=IDirectSound_Initialize(dso,lpGuid);
00092         ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
00093            "IDirectSound_Initialize() failed: %s\n",DXGetErrorString8(rc));
00094         if (rc==DSERR_NODRIVER) {
00095             trace("  No Driver\n");
00096             goto EXIT;
00097         } else if (rc==E_FAIL) {
00098             trace("  No Device\n");
00099             goto EXIT;
00100         } else if (rc==DSERR_ALLOCATED) {
00101             trace("  Already In Use\n");
00102             goto EXIT;
00103         }
00104     }
00105 
00106     rc=IDirectSound_Initialize(dso,lpGuid);
00107     ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSound_Initialize() "
00108        "should have returned DSERR_ALREADYINITIALIZED: %s\n",
00109        DXGetErrorString8(rc));
00110 
00111     /* DSOUND: Error: Invalid caps buffer */
00112     rc=IDirectSound_GetCaps(dso,0);
00113     ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetCaps(NULL) "
00114        "should have returned DSERR_INVALIDPARAM, returned: %s\n",
00115        DXGetErrorString8(rc));
00116 
00117     ZeroMemory(&dscaps, sizeof(dscaps));
00118 
00119     /* DSOUND: Error: Invalid caps buffer */
00120     rc=IDirectSound_GetCaps(dso,&dscaps);
00121     ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetCaps() "
00122        "should have returned DSERR_INVALIDPARAM, returned: %s\n",
00123        DXGetErrorString8(rc));
00124 
00125     dscaps.dwSize=sizeof(dscaps);
00126 
00127     /* DSOUND: Running on a certified driver */
00128     rc=IDirectSound_GetCaps(dso,&dscaps);
00129     ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
00130 
00131     rc=IDirectSound_Compact(dso);
00132     ok(rc==DSERR_PRIOLEVELNEEDED,"IDirectSound_Compact() failed: %s\n",
00133        DXGetErrorString8(rc));
00134 
00135     rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
00136     ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00137        DXGetErrorString8(rc));
00138 
00139     rc=IDirectSound_Compact(dso);
00140     ok(rc==DS_OK,"IDirectSound_Compact() failed: %s\n",DXGetErrorString8(rc));
00141 
00142     rc=IDirectSound_GetSpeakerConfig(dso,0);
00143     ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetSpeakerConfig(NULL) "
00144        "should have returned DSERR_INVALIDPARAM, returned: %s\n",
00145        DXGetErrorString8(rc));
00146 
00147     rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config);
00148     ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %s\n",
00149        DXGetErrorString8(rc));
00150 
00151     speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO,
00152                                         DSSPEAKER_GEOMETRY_WIDE);
00153     rc=IDirectSound_SetSpeakerConfig(dso,speaker_config);
00154     ok(rc==DS_OK,"IDirectSound_SetSpeakerConfig() failed: %s\n",
00155        DXGetErrorString8(rc));
00156     if (rc==DS_OK) {
00157         rc=IDirectSound_GetSpeakerConfig(dso,&new_speaker_config);
00158         ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %s\n",
00159            DXGetErrorString8(rc));
00160         if (rc==DS_OK && speaker_config!=new_speaker_config)
00161                trace("IDirectSound_GetSpeakerConfig() failed to set speaker "
00162                "config: expected 0x%08lx, got 0x%08lx\n",
00163                speaker_config,new_speaker_config);
00164     }
00165 
00166 EXIT:
00167     ref=IDirectSound_Release(dso);
00168     ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
00169 }
00170 
00171 static void IDirectSound_tests(void)
00172 {
00173     HRESULT rc;
00174     LPDIRECTSOUND dso=NULL;
00175 
00176     trace("Testing IDirectSound\n");
00177 
00178     /* try the COM class factory method of creation with no device specified */
00179     rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
00180                         &IID_IDirectSound, (void**)&dso);
00181     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
00182        DXGetErrorString8(rc));
00183     if (dso)
00184         IDirectSound_test(dso, FALSE, NULL);
00185 
00186     /* try the COM class factory method of creation with default playback
00187      * device specified */
00188     rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
00189                         &IID_IDirectSound, (void**)&dso);
00190     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
00191        DXGetErrorString8(rc));
00192     if (dso)
00193         IDirectSound_test(dso, FALSE, &DSDEVID_DefaultPlayback);
00194 
00195     /* try the COM class factory method of creation with default voice
00196      * playback device specified */
00197     rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
00198                         &IID_IDirectSound, (void**)&dso);
00199     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
00200        DXGetErrorString8(rc));
00201     if (dso)
00202         IDirectSound_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback);
00203 
00204     /* try the COM class factory method of creation with a bad
00205      * IID specified */
00206     rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
00207                         &CLSID_DirectSoundPrivate, (void**)&dso);
00208     ok(rc==E_NOINTERFACE,
00209        "CoCreateInstance(CLSID_DirectSound,CLSID_DirectSoundPrivate) "
00210        "should have failed: %s\n",DXGetErrorString8(rc));
00211 
00212     /* try the COM class factory method of creation with a bad
00213      * GUID and IID specified */
00214     rc=CoCreateInstance(&CLSID_DirectSoundPrivate, NULL, CLSCTX_INPROC_SERVER,
00215                         &IID_IDirectSound, (void**)&dso);
00216     ok(rc==REGDB_E_CLASSNOTREG,
00217        "CoCreateInstance(CLSID_DirectSoundPrivate,IID_IDirectSound) "
00218        "should have failed: %s\n",DXGetErrorString8(rc));
00219 
00220     /* try with no device specified */
00221     rc=DirectSoundCreate(NULL,&dso,NULL);
00222     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
00223        "DirectSoundCreate(NULL) failed: %s\n",DXGetErrorString8(rc));
00224     if (rc==S_OK && dso)
00225         IDirectSound_test(dso, TRUE, NULL);
00226 
00227     /* try with default playback device specified */
00228     rc=DirectSoundCreate(&DSDEVID_DefaultPlayback,&dso,NULL);
00229     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
00230        "DirectSoundCreate(DSDEVID_DefaultPlayback) failed: %s\n",
00231        DXGetErrorString8(rc));
00232     if (rc==DS_OK && dso)
00233         IDirectSound_test(dso, TRUE, NULL);
00234 
00235     /* try with default voice playback device specified */
00236     rc=DirectSoundCreate(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
00237     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
00238        "DirectSoundCreate(DSDEVID_DefaultVoicePlayback) failed: %s\n",
00239        DXGetErrorString8(rc));
00240     if (rc==DS_OK && dso)
00241         IDirectSound_test(dso, TRUE, NULL);
00242 
00243     /* try with a bad device specified */
00244     rc=DirectSoundCreate(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
00245     ok(rc==DSERR_NODRIVER,"DirectSoundCreate(DSDEVID_DefaultVoiceCapture) "
00246        "should have failed: %s\n",DXGetErrorString8(rc));
00247     if (rc==DS_OK && dso)
00248         IDirectSound_Release(dso);
00249 }
00250 
00251 static HRESULT test_dsound(LPGUID lpGuid)
00252 {
00253     HRESULT rc;
00254     LPDIRECTSOUND dso=NULL;
00255     int ref;
00256 
00257     /* DSOUND: Error: Invalid interface buffer */
00258     rc=DirectSoundCreate(lpGuid,0,NULL);
00259     ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate() should have returned "
00260        "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
00261 
00262     /* Create the DirectSound object */
00263     rc=DirectSoundCreate(lpGuid,&dso,NULL);
00264     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
00265        "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
00266     if (rc!=DS_OK)
00267         return rc;
00268 
00269     /* Try the enumerated device */
00270     IDirectSound_test(dso, TRUE, lpGuid);
00271 
00272     /* Try the COM class factory method of creation with enumerated device */
00273     rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
00274                         &IID_IDirectSound, (void**)&dso);
00275     ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %s\n",
00276        DXGetErrorString8(rc));
00277     if (dso)
00278         IDirectSound_test(dso, FALSE, lpGuid);
00279 
00280     /* Create a DirectSound object */
00281     rc=DirectSoundCreate(lpGuid,&dso,NULL);
00282     ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
00283     if (rc==DS_OK) {
00284         LPDIRECTSOUND dso1=NULL;
00285 
00286         /* Create a second DirectSound object */
00287         rc=DirectSoundCreate(lpGuid,&dso1,NULL);
00288         ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
00289         if (rc==DS_OK) {
00290             /* Release the second DirectSound object */
00291             ref=IDirectSound_Release(dso1);
00292             ok(ref==0,"IDirectSound_Release() has %d references, should have "
00293                "0\n",ref);
00294             ok(dso!=dso1,"DirectSound objects should be unique: dso=%p,dso1=%p\n",dso,dso1);
00295         }
00296 
00297         /* Release the first DirectSound object */
00298         ref=IDirectSound_Release(dso);
00299         ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
00300            ref);
00301         if (ref!=0)
00302             return DSERR_GENERIC;
00303     } else
00304         return rc;
00305 
00306     /* Create a DirectSound object */
00307     rc=DirectSoundCreate(lpGuid,&dso,NULL);
00308     ok(rc==DS_OK,"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
00309     if (rc==DS_OK) {
00310         LPDIRECTSOUNDBUFFER secondary;
00311         DSBUFFERDESC bufdesc;
00312         WAVEFORMATEX wfx;
00313 
00314         init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
00315         ZeroMemory(&bufdesc, sizeof(bufdesc));
00316         bufdesc.dwSize=sizeof(bufdesc);
00317         bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D;
00318         bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
00319                                     wfx.nBlockAlign);
00320         bufdesc.lpwfxFormat=&wfx;
00321         rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
00322         ok(rc==DS_OK && secondary!=NULL,
00323            "IDirectSound_CreateSoundBuffer() failed to create a secondary "
00324            "buffer %s\n",DXGetErrorString8(rc));
00325         if (rc==DS_OK && secondary!=NULL) {
00326             LPDIRECTSOUND3DBUFFER buffer3d;
00327             rc=IDirectSound_QueryInterface(secondary, &IID_IDirectSound3DBuffer,
00328                                            (void **)&buffer3d);
00329             ok(rc==DS_OK && buffer3d!=NULL,"IDirectSound_QueryInterface() "
00330                "failed:  %s\n",DXGetErrorString8(rc));
00331             if (rc==DS_OK && buffer3d!=NULL) {
00332                 ref=IDirectSound3DBuffer_AddRef(buffer3d);
00333                 ok(ref==2,"IDirectSound3DBuffer_AddRef() has %d references, "
00334                    "should have 2\n",ref);
00335             }
00336             ref=IDirectSoundBuffer_AddRef(secondary);
00337             ok(ref==2,"IDirectSoundBuffer_AddRef() has %d references, "
00338                "should have 2\n",ref);
00339         }
00340         /* release with buffer */
00341         ref=IDirectSound_Release(dso);
00342         ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
00343            ref);
00344         if (ref!=0)
00345             return DSERR_GENERIC;
00346     } else
00347         return rc;
00348 
00349     return DS_OK;
00350 }
00351 
00352 static HRESULT test_primary(LPGUID lpGuid)
00353 {
00354     HRESULT rc;
00355     LPDIRECTSOUND dso=NULL;
00356     LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL;
00357     DSBUFFERDESC bufdesc;
00358     DSCAPS dscaps;
00359     WAVEFORMATEX wfx;
00360     int ref;
00361 
00362     /* Create the DirectSound object */
00363     rc=DirectSoundCreate(lpGuid,&dso,NULL);
00364     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
00365        "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
00366     if (rc!=DS_OK)
00367         return rc;
00368 
00369     /* Get the device capabilities */
00370     ZeroMemory(&dscaps, sizeof(dscaps));
00371     dscaps.dwSize=sizeof(dscaps);
00372     rc=IDirectSound_GetCaps(dso,&dscaps);
00373     ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
00374     if (rc!=DS_OK)
00375         goto EXIT;
00376 
00377     /* DSOUND: Error: Invalid buffer description pointer */
00378     rc=IDirectSound_CreateSoundBuffer(dso,0,0,NULL);
00379     ok(rc==DSERR_INVALIDPARAM,
00380        "IDirectSound_CreateSoundBuffer() should have failed: %s\n",
00381        DXGetErrorString8(rc));
00382 
00383     /* DSOUND: Error: Invalid buffer description pointer */
00384     rc=IDirectSound_CreateSoundBuffer(dso,0,&primary,NULL);
00385     ok(rc==DSERR_INVALIDPARAM && primary==0,
00386        "IDirectSound_CreateSoundBuffer() should have failed: rc=%s,"
00387        "dsbo=%p\n",DXGetErrorString8(rc),primary);
00388 
00389     /* DSOUND: Error: Invalid buffer description pointer */
00390     rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,0,NULL);
00391     ok(rc==DSERR_INVALIDPARAM && primary==0,
00392        "IDirectSound_CreateSoundBuffer() should have failed: rc=%s,"
00393        "dsbo=0x%p\n",DXGetErrorString8(rc),primary);
00394 
00395     ZeroMemory(&bufdesc, sizeof(bufdesc));
00396 
00397     /* DSOUND: Error: Invalid size */
00398     /* DSOUND: Error: Invalid buffer description */
00399     rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
00400     ok(rc==DSERR_INVALIDPARAM && primary==0,
00401        "IDirectSound_CreateSoundBuffer() should have failed: rc=%s,"
00402        "primary=%p\n",DXGetErrorString8(rc),primary);
00403 
00404     /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
00405     /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
00406     rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
00407     ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00408        DXGetErrorString8(rc));
00409     if (rc!=DS_OK)
00410         goto EXIT;
00411 
00412     /* Testing the primary buffer */
00413     primary=NULL;
00414     ZeroMemory(&bufdesc, sizeof(bufdesc));
00415     bufdesc.dwSize=sizeof(bufdesc);
00416     bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
00417     bufdesc.lpwfxFormat = &wfx;
00418     init_format(&wfx,WAVE_FORMAT_PCM,11025,8,2);
00419     rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
00420     ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() should have "
00421        "returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc));
00422     if (rc==DS_OK && primary!=NULL)
00423         IDirectSoundBuffer_Release(primary);
00424 
00425     primary=NULL;
00426     ZeroMemory(&bufdesc, sizeof(bufdesc));
00427     bufdesc.dwSize=sizeof(bufdesc);
00428     bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
00429     rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
00430     ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),
00431        "IDirectSound_CreateSoundBuffer() failed to create a primary buffer: "
00432        "%s\n",DXGetErrorString8(rc));
00433     if (rc==DSERR_CONTROLUNAVAIL)
00434         trace("  No Primary\n");
00435     else if (rc==DS_OK && primary!=NULL) {
00436         LONG vol;
00437 
00438         /* Try to create a second primary buffer */
00439         /* DSOUND: Error: The primary buffer already exists.
00440          * Any changes made to the buffer description will be ignored. */
00441         rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&second,NULL);
00442         ok(rc==DS_OK && second==primary,
00443            "IDirectSound_CreateSoundBuffer() should have returned original "
00444            "primary buffer: %s\n",DXGetErrorString8(rc));
00445         ref=IDirectSoundBuffer_Release(second);
00446         ok(ref==1,"IDirectSoundBuffer_Release() primary has %d references, "
00447            "should have 1\n",ref);
00448 
00449         /* Try to duplicate a primary buffer */
00450         /* DSOUND: Error: Can't duplicate primary buffers */
00451         rc=IDirectSound_DuplicateSoundBuffer(dso,primary,&third);
00452         /* rc=0x88780032 */
00453         ok(rc!=DS_OK,"IDirectSound_DuplicateSoundBuffer() primary buffer "
00454            "should have failed %s\n",DXGetErrorString8(rc));
00455 
00456         rc=IDirectSoundBuffer_GetVolume(primary,&vol);
00457         ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %s\n",
00458            DXGetErrorString8(rc));
00459 
00460         if (winetest_interactive) {
00461             trace("Playing a 5 seconds reference tone at the current "
00462                   "volume.\n");
00463             if (rc==DS_OK)
00464                 trace("(the current volume is %ld according to DirectSound)\n",
00465                       vol);
00466             trace("All subsequent tones should be identical to this one.\n");
00467             trace("Listen for stutter, changes in pitch, volume, etc.\n");
00468         }
00469         test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive &&
00470                     !(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0,FALSE,0);
00471 
00472         ref=IDirectSoundBuffer_Release(primary);
00473         ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
00474            "should have 0\n",ref);
00475     }
00476 
00477     /* Set the CooperativeLevel back to normal */
00478     /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
00479     rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
00480     ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00481        DXGetErrorString8(rc));
00482 
00483 EXIT:
00484     ref=IDirectSound_Release(dso);
00485     ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
00486     if (ref!=0)
00487         return DSERR_GENERIC;
00488 
00489     return rc;
00490 }
00491 
00492 /*
00493  * Test the primary buffer at different formats while keeping the
00494  * secondary buffer at a constant format.
00495  */
00496 static HRESULT test_primary_secondary(LPGUID lpGuid)
00497 {
00498     HRESULT rc;
00499     LPDIRECTSOUND dso=NULL;
00500     LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
00501     DSBUFFERDESC bufdesc;
00502     DSCAPS dscaps;
00503     WAVEFORMATEX wfx, wfx2;
00504     int f,ref;
00505 
00506     /* Create the DirectSound object */
00507     rc=DirectSoundCreate(lpGuid,&dso,NULL);
00508     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
00509        "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
00510     if (rc!=DS_OK)
00511         return rc;
00512 
00513     /* Get the device capabilities */
00514     ZeroMemory(&dscaps, sizeof(dscaps));
00515     dscaps.dwSize=sizeof(dscaps);
00516     rc=IDirectSound_GetCaps(dso,&dscaps);
00517     ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
00518     if (rc!=DS_OK)
00519         goto EXIT;
00520 
00521     /* We must call SetCooperativeLevel before creating primary buffer */
00522     /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
00523     rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
00524     ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00525        DXGetErrorString8(rc));
00526     if (rc!=DS_OK)
00527         goto EXIT;
00528 
00529     ZeroMemory(&bufdesc, sizeof(bufdesc));
00530     bufdesc.dwSize=sizeof(bufdesc);
00531     bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
00532     rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
00533     ok(rc==DS_OK && primary!=NULL,
00534        "IDirectSound_CreateSoundBuffer() failed to create a primary buffer "
00535        "%s\n",DXGetErrorString8(rc));
00536 
00537     if (rc==DS_OK && primary!=NULL) {
00538         for (f=0;f<NB_FORMATS;f++) {
00539             /* We must call SetCooperativeLevel to be allowed to call
00540              * SetFormat */
00541             /* DSOUND: Setting DirectSound cooperative level to
00542              * DSSCL_PRIORITY */
00543             rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
00544             ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00545                DXGetErrorString8(rc));
00546             if (rc!=DS_OK)
00547                 goto EXIT;
00548 
00549             init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
00550                         formats[f][2]);
00551             wfx2=wfx;
00552             rc=IDirectSoundBuffer_SetFormat(primary,&wfx);
00553             ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat() failed: %s\n",
00554                DXGetErrorString8(rc));
00555 
00556             /* There is no garantee that SetFormat will actually change the
00557              * format to what we asked for. It depends on what the soundcard
00558              * supports. So we must re-query the format.
00559              */
00560             rc=IDirectSoundBuffer_GetFormat(primary,&wfx,sizeof(wfx),NULL);
00561             ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %s\n",
00562                DXGetErrorString8(rc));
00563             if (rc==DS_OK &&
00564                 (wfx.wFormatTag!=wfx2.wFormatTag ||
00565                  wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
00566                  wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
00567                  wfx.nChannels!=wfx2.nChannels)) {
00568                 trace("Requested primary format tag=0x%04x %ldx%dx%d "
00569                       "avg.B/s=%ld align=%d\n",
00570                       wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
00571                       wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
00572                 trace("Got tag=0x%04x %ldx%dx%d avg.B/s=%ld align=%d\n",
00573                       wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
00574                       wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
00575             }
00576 
00577             /* Set the CooperativeLevel back to normal */
00578             /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
00579             rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
00580             ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00581                DXGetErrorString8(rc));
00582 
00583             init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
00584 
00585             secondary=NULL;
00586             ZeroMemory(&bufdesc, sizeof(bufdesc));
00587             bufdesc.dwSize=sizeof(bufdesc);
00588             bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
00589             bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
00590                                         wfx.nBlockAlign);
00591             bufdesc.lpwfxFormat=&wfx2;
00592             if (winetest_interactive) {
00593                 trace("  Testing a primary buffer at %ldx%dx%d with a "
00594                       "secondary buffer at %ldx%dx%d\n",
00595                       wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
00596                       wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels);
00597             }
00598             rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
00599             ok(rc==DS_OK && secondary!=NULL,
00600                "IDirectSound_CreateSoundBuffer() failed to create a secondary "
00601                "buffer %s\n",DXGetErrorString8(rc));
00602 
00603             if (rc==DS_OK && secondary!=NULL) {
00604                 test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
00605                             winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
00606 
00607                 ref=IDirectSoundBuffer_Release(secondary);
00608                 ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
00609                    "should have 0\n",ref);
00610             }
00611         }
00612 
00613         ref=IDirectSoundBuffer_Release(primary);
00614         ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
00615            "should have 0\n",ref);
00616     }
00617 
00618     /* Set the CooperativeLevel back to normal */
00619     /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
00620     rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
00621     ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00622        DXGetErrorString8(rc));
00623 
00624 EXIT:
00625     ref=IDirectSound_Release(dso);
00626     ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
00627     if (ref!=0)
00628         return DSERR_GENERIC;
00629 
00630     return rc;
00631 }
00632 
00633 static HRESULT test_secondary(LPGUID lpGuid)
00634 {
00635     HRESULT rc;
00636     LPDIRECTSOUND dso=NULL;
00637     LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
00638     DSBUFFERDESC bufdesc;
00639     DSCAPS dscaps;
00640     WAVEFORMATEX wfx, wfx1;
00641     DWORD f;
00642     int ref;
00643 
00644     /* Create the DirectSound object */
00645     rc=DirectSoundCreate(lpGuid,&dso,NULL);
00646     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
00647        "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
00648     if (rc!=DS_OK)
00649         return rc;
00650 
00651     /* Get the device capabilities */
00652     ZeroMemory(&dscaps, sizeof(dscaps));
00653     dscaps.dwSize=sizeof(dscaps);
00654     rc=IDirectSound_GetCaps(dso,&dscaps);
00655     ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
00656     if (rc!=DS_OK)
00657         goto EXIT;
00658 
00659     /* We must call SetCooperativeLevel before creating primary buffer */
00660     /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
00661     rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
00662     ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00663        DXGetErrorString8(rc));
00664     if (rc!=DS_OK)
00665         goto EXIT;
00666 
00667     ZeroMemory(&bufdesc, sizeof(bufdesc));
00668     bufdesc.dwSize=sizeof(bufdesc);
00669     bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
00670     rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
00671     ok(rc==DS_OK && primary!=NULL,
00672        "IDirectSound_CreateSoundBuffer() failed to create a primary buffer "
00673        "%s\n",DXGetErrorString8(rc));
00674 
00675     if (rc==DS_OK && primary!=NULL) {
00676         rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
00677         ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
00678            DXGetErrorString8(rc));
00679         if (rc!=DS_OK)
00680             goto EXIT1;
00681 
00682         for (f=0;f<NB_FORMATS;f++) {
00683             init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
00684                         formats[f][2]);
00685             secondary=NULL;
00686             ZeroMemory(&bufdesc, sizeof(bufdesc));
00687             bufdesc.dwSize=sizeof(bufdesc);
00688             bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
00689             bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
00690                                         wfx.nBlockAlign);
00691             rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
00692             ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() "
00693                "should have returned DSERR_INVALIDPARAM, returned: %s\n",
00694                DXGetErrorString8(rc));
00695             if (rc==DS_OK && secondary!=NULL)
00696                 IDirectSoundBuffer_Release(secondary);
00697 
00698             secondary=NULL;
00699             ZeroMemory(&bufdesc, sizeof(bufdesc));
00700             bufdesc.dwSize=sizeof(bufdesc);
00701             bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
00702             bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
00703                                         wfx.nBlockAlign);
00704             bufdesc.lpwfxFormat=&wfx;
00705             if (winetest_interactive) {
00706                 trace("  Testing a secondary buffer at %ldx%dx%d "
00707                       "with a primary buffer at %ldx%dx%d\n",
00708                       wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
00709                       wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
00710             }
00711             rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
00712             ok(rc==DS_OK && secondary!=NULL,
00713                "IDirectSound_CreateSoundBuffer() failed to create a secondary "
00714                "buffer %s\n",DXGetErrorString8(rc));
00715 
00716             if (rc==DS_OK && secondary!=NULL) {
00717                 test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
00718                             winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
00719 
00720                 ref=IDirectSoundBuffer_Release(secondary);
00721                 ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
00722                    "should have 0\n",ref);
00723             }
00724         }
00725 EXIT1:
00726         ref=IDirectSoundBuffer_Release(primary);
00727         ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
00728            "should have 0\n",ref);
00729     }
00730 
00731     /* Set the CooperativeLevel back to normal */
00732     /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
00733     rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
00734     ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00735        DXGetErrorString8(rc));
00736 
00737 EXIT:
00738     ref=IDirectSound_Release(dso);
00739     ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
00740     if (ref!=0)
00741         return DSERR_GENERIC;
00742 
00743     return rc;
00744 }
00745 
00746 static HRESULT test_block_align(LPGUID lpGuid)
00747 {
00748     HRESULT rc;
00749     LPDIRECTSOUND dso=NULL;
00750     LPDIRECTSOUNDBUFFER secondary=NULL;
00751     DSBUFFERDESC bufdesc;
00752     DSBCAPS dsbcaps;
00753     WAVEFORMATEX wfx;
00754     int ref;
00755 
00756     /* Create the DirectSound object */
00757     rc=DirectSoundCreate(lpGuid,&dso,NULL);
00758     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
00759        "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
00760     if (rc!=DS_OK)
00761         return rc;
00762 
00763     init_format(&wfx,WAVE_FORMAT_PCM,11025,16,2);
00764     ZeroMemory(&bufdesc, sizeof(bufdesc));
00765     bufdesc.dwSize=sizeof(bufdesc);
00766     bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
00767     bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec + 1;
00768     bufdesc.lpwfxFormat=&wfx;
00769     rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
00770     ok(rc==DS_OK,"IDirectSound_CreateSoundBuffer() "
00771        "should have returned DS_OK, returned: %s\n",
00772        DXGetErrorString8(rc));
00773 
00774     if (rc==DS_OK && secondary!=NULL) {
00775         ZeroMemory(&dsbcaps, sizeof(dsbcaps));
00776         dsbcaps.dwSize = sizeof(dsbcaps);
00777         rc=IDirectSoundBuffer_GetCaps(secondary,&dsbcaps);
00778         ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() should have returned DS_OK, "
00779            "returned: %s\n", DXGetErrorString8(rc));
00780         if (rc==DS_OK)
00781             ok(dsbcaps.dwBufferBytes==(wfx.nAvgBytesPerSec + wfx.nBlockAlign),
00782                "Buffer size not a multiple of nBlockAlign: requested %ld, "
00783                "got %ld, should be %ld\n", bufdesc.dwBufferBytes,
00784                dsbcaps.dwBufferBytes, wfx.nAvgBytesPerSec + wfx.nBlockAlign);
00785         ref=IDirectSoundBuffer_Release(secondary);
00786         ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d references, "
00787            "should have 0\n",ref);
00788     }
00789 
00790     ref=IDirectSound_Release(dso);
00791     ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
00792     if (ref!=0)
00793         return DSERR_GENERIC;
00794 
00795     return rc;
00796 }
00797 
00798 static struct fmt {
00799     int bits;
00800     int channels;
00801 } fmts[] = { { 8, 1 }, { 8, 2 }, { 16, 1 }, {16, 2 } };
00802 
00803 static HRESULT test_frequency(LPGUID lpGuid)
00804 {
00805     HRESULT rc;
00806     LPDIRECTSOUND dso=NULL;
00807     LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
00808     DSBUFFERDESC bufdesc;
00809     DSCAPS dscaps;
00810     WAVEFORMATEX wfx, wfx1;
00811     DWORD f, r;
00812     int ref;
00813     int rates[] = { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100,
00814                     48000, 96000 };
00815 
00816     /* Create the DirectSound object */
00817     rc=DirectSoundCreate(lpGuid,&dso,NULL);
00818     ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
00819        "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
00820     if (rc!=DS_OK)
00821         return rc;
00822 
00823     /* Get the device capabilities */
00824     ZeroMemory(&dscaps, sizeof(dscaps));
00825     dscaps.dwSize=sizeof(dscaps);
00826     rc=IDirectSound_GetCaps(dso,&dscaps);
00827     ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
00828     if (rc!=DS_OK)
00829         goto EXIT;
00830 
00831     /* We must call SetCooperativeLevel before creating primary buffer */
00832     /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
00833     rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
00834     ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00835        DXGetErrorString8(rc));
00836     if (rc!=DS_OK)
00837         goto EXIT;
00838 
00839     ZeroMemory(&bufdesc, sizeof(bufdesc));
00840     bufdesc.dwSize=sizeof(bufdesc);
00841     bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
00842     rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
00843     ok(rc==DS_OK && primary!=NULL,
00844        "IDirectSound_CreateSoundBuffer() failed to create a primary buffer "
00845        "%s\n",DXGetErrorString8(rc));
00846 
00847     if (rc==DS_OK && primary!=NULL) {
00848         rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
00849         ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
00850            DXGetErrorString8(rc));
00851         if (rc!=DS_OK)
00852             goto EXIT1;
00853 
00854         for (f=0;f<sizeof(fmts)/sizeof(fmts[0]);f++) {
00855         for (r=0;r<sizeof(rates)/sizeof(rates[0]);r++) {
00856             init_format(&wfx,WAVE_FORMAT_PCM,11025,fmts[f].bits,
00857                         fmts[f].channels);
00858             secondary=NULL;
00859             ZeroMemory(&bufdesc, sizeof(bufdesc));
00860             bufdesc.dwSize=sizeof(bufdesc);
00861             bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLFREQUENCY;
00862             bufdesc.dwBufferBytes=align((wfx.nAvgBytesPerSec*rates[r]/11025)*
00863                                         BUFFER_LEN/1000,wfx.nBlockAlign);
00864             bufdesc.lpwfxFormat=&wfx;
00865             if (winetest_interactive) {
00866                 trace("  Testing a secondary buffer at %ldx%dx%d "
00867                       "with a primary buffer at %ldx%dx%d\n",
00868                       wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
00869                       wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
00870             }
00871             rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
00872             ok(rc==DS_OK && secondary!=NULL,
00873                "IDirectSound_CreateSoundBuffer() failed to create a secondary "
00874                "buffer %s\n",DXGetErrorString8(rc));
00875 
00876             if (rc==DS_OK && secondary!=NULL) {
00877                 test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
00878                             winetest_interactive,1.0,0,NULL,0,0,TRUE,rates[r]);
00879 
00880                 ref=IDirectSoundBuffer_Release(secondary);
00881                 ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
00882                    "should have 0\n",ref);
00883             }
00884         }
00885         }
00886 EXIT1:
00887         ref=IDirectSoundBuffer_Release(primary);
00888         ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
00889            "should have 0\n",ref);
00890     }
00891 
00892     /* Set the CooperativeLevel back to normal */
00893     /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
00894     rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
00895     ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
00896        DXGetErrorString8(rc));
00897 
00898 EXIT:
00899     ref=IDirectSound_Release(dso);
00900     ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
00901     if (ref!=0)
00902         return DSERR_GENERIC;
00903 
00904     return rc;
00905 }
00906 
00907 static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
00908                                    LPCSTR lpcstrModule, LPVOID lpContext)
00909 {
00910     HRESULT rc;
00911     trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
00912     rc = test_dsound(lpGuid);
00913     if (rc == DSERR_NODRIVER)
00914         trace("  No Driver\n");
00915     else if (rc == DSERR_ALLOCATED)
00916         trace("  Already In Use\n");
00917     else if (rc == E_FAIL)
00918         trace("  No Device\n");
00919     else {
00920         test_block_align(lpGuid);
00921         test_primary(lpGuid);
00922         test_primary_secondary(lpGuid);
00923         test_secondary(lpGuid);
00924         test_frequency(lpGuid);
00925     }
00926 
00927     return 1;
00928 }
00929 
00930 static void dsound_tests(void)
00931 {
00932     HRESULT rc;
00933     rc=DirectSoundEnumerateA(&dsenum_callback,NULL);
00934     ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %s\n",DXGetErrorString8(rc));
00935 }
00936 
00937 START_TEST(dsound)
00938 {
00939     CoInitialize(NULL);
00940 
00941     trace("DLL Version: %s\n", get_file_version("dsound.dll"));
00942 
00943     IDirectSound_tests();
00944     dsound_tests();
00945 
00946     CoUninitialize();
00947 }

Generated on Sat May 26 2012 04:20:12 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.