dsound8.c 36.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * Tests basic sound playback in DirectSound.
 * In particular we test each standard Windows sound format to make sure
 * we handle the sound card/driver quirks correctly.
 *
 * Part of this test involves playing test tones. But this only makes
 * sense if someone is going to carefully listen to it, and would only
 * bother everyone else.
 * So this is only done if the test is being run in interactive mode.
 *
 * Copyright (c) 2002-2004 Francois Gouget
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
25
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 27 28
 */

#include <windows.h>
29
#include <stdio.h>
30 31 32 33

#include "wine/test.h"
#include "dsound.h"
#include "dsconf.h"
34 35 36
#include "mmreg.h"
#include "ks.h"
#include "ksmedia.h"
37 38 39

#include "dsound_test.h"

40
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
41 42
static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,LPUNKNOWN)=NULL;

43 44 45 46 47
int align(int length, int align)
{
    return (length / align) * align;
}

48 49 50 51 52 53 54 55 56 57 58 59 60 61
static void IDirectSound8_test(LPDIRECTSOUND8 dso, BOOL initialized,
                               LPCGUID lpGuid)
{
    HRESULT rc;
    DSCAPS dscaps;
    int ref;
    IUnknown * unknown;
    IDirectSound * ds;
    IDirectSound8 * ds8;
    DWORD speaker_config, new_speaker_config;
    DWORD certified;

    /* Try to Query for objects */
    rc=IDirectSound8_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown);
62
    ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IUnknown) failed: %08x\n", rc);
63 64 65 66
    if (rc==DS_OK)
        IDirectSound8_Release(unknown);

    rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds);
67
    ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound) failed: %08x\n", rc);
68 69 70 71 72
    if (rc==DS_OK)
        IDirectSound_Release(ds);

    rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
    ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound8) "
73
       "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
74 75 76 77
    if (rc==DS_OK)
        IDirectSound8_Release(ds8);

    if (initialized == FALSE) {
78
        /* try uninitialized object */
79 80
        rc=IDirectSound8_GetCaps(dso,0);
        ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetCaps(NULL) "
81
           "should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
82 83 84

        rc=IDirectSound8_GetCaps(dso,&dscaps);
        ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetCaps() "
85
           "should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
86 87 88

        rc=IDirectSound8_Compact(dso);
        ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_Compact() "
89
           "should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
90 91 92

        rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config);
        ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetSpeakerConfig() "
93
           "should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
94 95 96

        rc=IDirectSound8_VerifyCertification(dso, &certified);
        ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_VerifyCertification() "
97
           "should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
98 99

        rc=IDirectSound8_Initialize(dso,lpGuid);
100
        ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
101
           "IDirectSound8_Initialize() failed: %08x\n",rc);
102 103
        if (rc==DSERR_NODRIVER) {
            trace("  No Driver\n");
104
            goto EXIT;
105 106
        } else if (rc==E_FAIL) {
            trace("  No Device\n");
107
            goto EXIT;
108
        } else if (rc==DSERR_ALLOCATED) {
109
            trace("  Already In Use\n");
110
            goto EXIT;
Jakob Eriksson's avatar
Jakob Eriksson committed
111
        }
112 113
    }

114 115
    rc=IDirectSound8_Initialize(dso,lpGuid);
    ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSound8_Initialize() "
116
       "should have returned DSERR_ALREADYINITIALIZED: %08x\n", rc);
117

118 119 120
    /* DSOUND: Error: Invalid caps buffer */
    rc=IDirectSound8_GetCaps(dso,0);
    ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetCaps() "
121
       "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
122 123 124 125 126 127

    ZeroMemory(&dscaps, sizeof(dscaps));

    /* DSOUND: Error: Invalid caps buffer */
    rc=IDirectSound8_GetCaps(dso,&dscaps);
    ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetCaps() "
128
       "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
129 130 131 132 133

    dscaps.dwSize=sizeof(dscaps);

    /* DSOUND: Running on a certified driver */
    rc=IDirectSound8_GetCaps(dso,&dscaps);
134
    ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
135 136

    rc=IDirectSound8_Compact(dso);
137
    ok(rc==DSERR_PRIOLEVELNEEDED,"IDirectSound8_Compact() failed: %08x\n", rc);
138 139

    rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
140
    ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
141 142

    rc=IDirectSound8_Compact(dso);
143
    ok(rc==DS_OK,"IDirectSound8_Compact() failed: %08x\n",rc);
144 145 146

    rc=IDirectSound8_GetSpeakerConfig(dso,0);
    ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetSpeakerConfig(NULL) "
147
       "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
148 149

    rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config);
150
    ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %08x\n", rc);
151 152 153 154

    speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO,
                                        DSSPEAKER_GEOMETRY_WIDE);
    rc=IDirectSound8_SetSpeakerConfig(dso,speaker_config);
155
    ok(rc==DS_OK,"IDirectSound8_SetSpeakerConfig() failed: %08x\n", rc);
156 157
    if (rc==DS_OK) {
        rc=IDirectSound8_GetSpeakerConfig(dso,&new_speaker_config);
158
        ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %08x\n", rc);
159 160
        if (rc==DS_OK && speaker_config!=new_speaker_config)
               trace("IDirectSound8_GetSpeakerConfig() failed to set speaker "
161
               "config: expected 0x%08x, got 0x%08x\n",
162 163 164 165
               speaker_config,new_speaker_config);
    }

    rc=IDirectSound8_VerifyCertification(dso, &certified);
166
    ok(rc==DS_OK||rc==E_NOTIMPL,"IDirectSound8_VerifyCertification() failed: %08x\n", rc);
167

168
EXIT:
169 170 171 172
    ref=IDirectSound8_Release(dso);
    ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
}

173
static void IDirectSound8_tests(void)
174 175 176
{
    HRESULT rc;
    LPDIRECTSOUND8 dso=NULL;
177
    LPCLASSFACTORY cf=NULL;
178 179 180

    trace("Testing IDirectSound8\n");

181 182 183
    rc=CoGetClassObject(&CLSID_DirectSound8, CLSCTX_INPROC_SERVER, NULL,
                        &IID_IClassFactory, (void**)&cf);
    ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
184
       "failed: %08x\n", rc);
185 186 187 188

    rc=CoGetClassObject(&CLSID_DirectSound8, CLSCTX_INPROC_SERVER, NULL,
                        &IID_IUnknown, (void**)&cf);
    ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound8, IID_IUnknown) "
189
       "failed: %08x\n", rc);
190

191 192 193
    /* try the COM class factory method of creation with no device specified */
    rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
                        &IID_IDirectSound8, (void**)&dso);
194
    ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG,"CoCreateInstance() failed: %08x\n", rc);
195 196 197 198
    if (rc==REGDB_E_CLASSNOTREG) {
        trace("  Class Not Registered\n");
        return;
    }
199 200 201 202 203 204 205
    if (dso)
        IDirectSound8_test(dso, FALSE, NULL);

    /* try the COM class factory method of creation with default playback
     *  device specified */
    rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
                        &IID_IDirectSound8, (void**)&dso);
206
    ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8) failed: %08x\n", rc);
207 208 209 210 211 212 213
    if (dso)
        IDirectSound8_test(dso, FALSE, &DSDEVID_DefaultPlayback);

    /* try the COM class factory method of creation with default voice
     * playback device specified */
    rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
                        &IID_IDirectSound8, (void**)&dso);
214
    ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8) failed: %08x\n", rc);
215 216 217 218 219 220 221 222 223
    if (dso)
        IDirectSound8_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback);

    /* try the COM class factory method of creation with a bad
     * IID specified */
    rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
                        &CLSID_DirectSoundPrivate, (void**)&dso);
    ok(rc==E_NOINTERFACE,
       "CoCreateInstance(CLSID_DirectSound8,CLSID_DirectSoundPrivate) "
224
       "should have failed: %08x\n",rc);
225 226 227 228 229 230 231

    /* try the COM class factory method of creation with a bad
     * GUID and IID specified */
    rc=CoCreateInstance(&CLSID_DirectSoundPrivate, NULL, CLSCTX_INPROC_SERVER,
                        &IID_IDirectSound8, (void**)&dso);
    ok(rc==REGDB_E_CLASSNOTREG,
       "CoCreateInstance(CLSID_DirectSoundPrivate,IID_IDirectSound8) "
232
       "should have failed: %08x\n",rc);
233 234

    /* try with no device specified */
235
    rc=pDirectSoundCreate8(NULL,&dso,NULL);
236
    ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
237
       "DirectSoundCreate8() failed: %08x\n",rc);
238
    if (rc==DS_OK && dso)
239 240 241
        IDirectSound8_test(dso, TRUE, NULL);

    /* try with default playback device specified */
242
    rc=pDirectSoundCreate8(&DSDEVID_DefaultPlayback,&dso,NULL);
243
    ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
244
       "DirectSoundCreate8() failed: %08x\n",rc);
245
    if (rc==DS_OK && dso)
246 247 248
        IDirectSound8_test(dso, TRUE, NULL);

    /* try with default voice playback device specified */
249
    rc=pDirectSoundCreate8(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
250
    ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
251
       "DirectSoundCreate8() failed: %08x\n",rc);
252
    if (rc==DS_OK && dso)
253 254 255
        IDirectSound8_test(dso, TRUE, NULL);

    /* try with a bad device specified */
256
    rc=pDirectSoundCreate8(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
257
    ok(rc==DSERR_NODRIVER,"DirectSoundCreate8(DSDEVID_DefaultVoiceCapture) "
258
       "should have failed: %08x\n",rc);
259 260 261 262 263 264 265 266 267
}

static HRESULT test_dsound8(LPGUID lpGuid)
{
    HRESULT rc;
    LPDIRECTSOUND8 dso=NULL;
    int ref;

    /* DSOUND: Error: Invalid interface buffer */
268
    rc=pDirectSoundCreate8(lpGuid,0,NULL);
269
    ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate8() should have returned "
270
       "DSERR_INVALIDPARAM, returned: %08x\n",rc);
271 272

    /* Create the DirectSound8 object */
273
    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
274
    ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
275
       "DirectSoundCreate8() failed: %08x\n",rc);
276 277 278 279 280 281 282 283 284
    if (rc!=DS_OK)
        return rc;

    /* Try the enumerated device */
    IDirectSound8_test(dso, TRUE, lpGuid);

    /* Try the COM class factory method of creation with enumerated device */
    rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
                        &IID_IDirectSound8, (void**)&dso);
285
    ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %08x\n", rc);
286 287 288 289
    if (dso)
        IDirectSound8_test(dso, FALSE, lpGuid);

    /* Create a DirectSound8 object */
290
    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
291
    ok(rc==DS_OK,"DirectSoundCreate8() failed: %08x\n",rc);
292 293 294 295
    if (rc==DS_OK) {
        LPDIRECTSOUND8 dso1=NULL;

        /* Create a second DirectSound8 object */
296
        rc=pDirectSoundCreate8(lpGuid,&dso1,NULL);
297
        ok(rc==DS_OK,"DirectSoundCreate8() failed: %08x\n",rc);
298 299 300
        if (rc==DS_OK) {
            /* Release the second DirectSound8 object */
            ref=IDirectSound8_Release(dso1);
301
            ok(ref==0,"IDirectSound8_Release() has %d references, "
302 303
               "should have 0\n",ref);
            ok(dso!=dso1,"DirectSound8 objects should be unique: "
304
               "dso=%p,dso1=%p\n",dso,dso1);
305 306 307 308
        }

        /* Release the first DirectSound8 object */
        ref=IDirectSound8_Release(dso);
309
        ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",
310 311 312 313 314 315 316
           ref);
        if (ref!=0)
            return DSERR_GENERIC;
    } else
        return rc;

    /* Create a DirectSound8 object */
317
    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
318
    ok(rc==DS_OK,"DirectSoundCreate8() failed: %08x\n",rc);
319 320 321 322 323 324 325 326 327
    if (rc==DS_OK) {
        LPDIRECTSOUNDBUFFER secondary;
        DSBUFFERDESC bufdesc;
        WAVEFORMATEX wfx;

        init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
        ZeroMemory(&bufdesc, sizeof(bufdesc));
        bufdesc.dwSize=sizeof(bufdesc);
        bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D;
328 329
        bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
                                    wfx.nBlockAlign);
330 331 332
        bufdesc.lpwfxFormat=&wfx;
        rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
        ok(rc==DS_OK && secondary!=NULL,
333
           "IDirectSound8_CreateSoundBuffer() failed to create a secondary "
334
           "buffer: %08x\n",rc);
335 336 337 338 339 340 341
        if (rc==DS_OK && secondary!=NULL) {
            LPDIRECTSOUND3DBUFFER buffer3d;
            LPDIRECTSOUNDBUFFER8 buffer8;
            rc=IDirectSound8_QueryInterface(secondary,
                                            &IID_IDirectSound3DBuffer,
                                            (void **)&buffer3d);
            ok(rc==DS_OK && buffer3d!=NULL,
342
               "IDirectSound8_QueryInterface() failed: %08x\n", rc);
343 344
            if (rc==DS_OK && buffer3d!=NULL) {
                ref=IDirectSound3DBuffer_AddRef(buffer3d);
345
                ok(ref==2,"IDirectSound3DBuffer_AddRef() has %d references, "
346 347 348 349 350 351 352
                   "should have 2\n",ref);
            }
            rc=IDirectSound8_QueryInterface(secondary,
                                            &IID_IDirectSoundBuffer8,
                                            (void **)&buffer8);
            if (rc==DS_OK && buffer8!=NULL) {
                ref=IDirectSoundBuffer8_AddRef(buffer8);
353
                ok(ref==3,"IDirectSoundBuffer8_AddRef() has %d references, "
354 355 356
                   "should have 3\n",ref);
            }
            ref=IDirectSoundBuffer_AddRef(secondary);
357
            ok(ref==4,"IDirectSoundBuffer_AddRef() has %d references, "
358 359 360 361
               "should have 4\n",ref);
        }
        /* release with buffer */
        ref=IDirectSound8_Release(dso);
362
        ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",
363 364 365 366 367 368 369 370 371 372 373 374 375 376
           ref);
        if (ref!=0)
            return DSERR_GENERIC;
    } else
        return rc;

    return DS_OK;
}

static HRESULT test_primary8(LPGUID lpGuid)
{
    HRESULT rc;
    LPDIRECTSOUND8 dso=NULL;
    LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL;
377
    LPDIRECTSOUNDBUFFER8 pb8 = NULL;
378 379
    DSBUFFERDESC bufdesc;
    DSCAPS dscaps;
380
    WAVEFORMATEX wfx;
381 382 383
    int ref;

    /* Create the DirectSound object */
384
    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
385
    ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
386
       "DirectSoundCreate8() failed: %08x\n",rc);
387 388 389 390 391 392 393
    if (rc!=DS_OK)
        return rc;

    /* Get the device capabilities */
    ZeroMemory(&dscaps, sizeof(dscaps));
    dscaps.dwSize=sizeof(dscaps);
    rc=IDirectSound8_GetCaps(dso,&dscaps);
394
    ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
395 396 397 398 399 400
    if (rc!=DS_OK)
        goto EXIT;

    /* DSOUND: Error: Invalid buffer description pointer */
    rc=IDirectSound8_CreateSoundBuffer(dso,0,0,NULL);
    ok(rc==DSERR_INVALIDPARAM,
401
       "IDirectSound8_CreateSoundBuffer should have returned "
402
       "DSERR_INVALIDPARAM, returned: %08x\n",rc);
403 404 405 406

    /* DSOUND: Error: Invalid buffer description pointer */
    rc=IDirectSound8_CreateSoundBuffer(dso,0,&primary,NULL);
    ok(rc==DSERR_INVALIDPARAM && primary==0,
407
       "IDirectSound8_CreateSoundBuffer() should have returned "
408 409
       "DSERR_INVALIDPARAM, returned: rc=%08x,dsbo=%p\n",
       rc,primary);
410

411 412 413 414
    ZeroMemory(&bufdesc, sizeof(bufdesc));
    bufdesc.dwSize = sizeof(DSBUFFERDESC);

    /* DSOUND: Error: Invalid dsound buffer interface pointer */
415 416
    rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,0,NULL);
    ok(rc==DSERR_INVALIDPARAM && primary==0,
417 418
       "IDirectSound8_CreateSoundBuffer() should have failed: rc=%08x,"
       "dsbo=%p\n",rc,primary);
419 420 421 422 423 424 425

    ZeroMemory(&bufdesc, sizeof(bufdesc));

    /* DSOUND: Error: Invalid size */
    /* DSOUND: Error: Invalid buffer description */
    rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
    ok(rc==DSERR_INVALIDPARAM && primary==0,
426 427
       "IDirectSound8_CreateSoundBuffer() should have failed: rc=%08x,"
       "primary=%p\n",rc,primary);
428 429 430 431

    /* We must call SetCooperativeLevel before calling CreateSoundBuffer */
    /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
    rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
432
    ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
433 434 435 436
    if (rc!=DS_OK)
        goto EXIT;

    /* Testing the primary buffer */
437 438 439 440 441 442 443 444
    primary=NULL;
    ZeroMemory(&bufdesc, sizeof(bufdesc));
    bufdesc.dwSize=sizeof(bufdesc);
    bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
    bufdesc.lpwfxFormat = &wfx;
    init_format(&wfx,WAVE_FORMAT_PCM,11025,8,2);
    rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
    ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() should have "
445
       "returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
446 447 448
    if (rc==DS_OK && primary!=NULL)
        IDirectSoundBuffer_Release(primary);

449 450 451 452 453
    primary=NULL;
    ZeroMemory(&bufdesc, sizeof(bufdesc));
    bufdesc.dwSize=sizeof(bufdesc);
    bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
    rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
454
    ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),
455
       "IDirectSound8_CreateSoundBuffer() failed to create a primary buffer: "
456
       "%08x\n",rc);
457 458 459
    if (rc==DSERR_CONTROLUNAVAIL)
        trace("  No Primary\n");
    else if (rc==DS_OK && primary!=NULL) {
460 461 462 463 464 465 466
        LONG vol;

        /* Try to create a second primary buffer */
        /* DSOUND: Error: The primary buffer already exists.
         * Any changes made to the buffer description will be ignored. */
        rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&second,NULL);
        ok(rc==DS_OK && second==primary,
467
           "IDirectSound8_CreateSoundBuffer() should have returned original "
468
           "primary buffer: %08x\n",rc);
469
        ref=IDirectSoundBuffer_Release(second);
470
        ok(ref==1,"IDirectSoundBuffer_Release() primary has %d references, "
471 472 473 474 475 476
           "should have 1\n",ref);

        /* Try to duplicate a primary buffer */
        /* DSOUND: Error: Can't duplicate primary buffers */
        rc=IDirectSound8_DuplicateSoundBuffer(dso,primary,&third);
        /* rc=0x88780032 */
477
        ok(rc!=DS_OK,"IDirectSound8_DuplicateSoundBuffer() primary buffer "
478
           "should have failed %08x\n",rc);
479

480 481
        /* Primary buffers don't have an IDirectSoundBuffer8 */
        rc = IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer8, (LPVOID*)&pb8);
482
        ok(FAILED(rc), "Primary buffer does have an IDirectSoundBuffer8: %08x\n", rc);
483

484
        rc=IDirectSoundBuffer_GetVolume(primary,&vol);
485
        ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %08x\n", rc);
486 487 488 489

        if (winetest_interactive) {
            trace("Playing a 5 seconds reference tone at the current volume.\n");
            if (rc==DS_OK)
490
                trace("(the current volume is %d according to DirectSound)\n",
491 492 493 494
                      vol);
            trace("All subsequent tones should be identical to this one.\n");
            trace("Listen for stutter, changes in pitch, volume, etc.\n");
        }
495
        test_buffer8(dso,&primary,1,FALSE,0,FALSE,0,winetest_interactive &&
496 497 498
                     !(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0);

        ref=IDirectSoundBuffer_Release(primary);
499
        ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
500 501 502 503 504 505
           "should have 0\n",ref);
    }

    /* Set the CooperativeLevel back to normal */
    /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
    rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
506
    ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
507 508 509

EXIT:
    ref=IDirectSound8_Release(dso);
510
    ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
511 512 513 514 515 516
    if (ref!=0)
        return DSERR_GENERIC;

    return rc;
}

517 518 519 520 521 522 523 524 525 526 527 528
/*
 * Test the primary buffer at different formats while keeping the
 * secondary buffer at a constant format.
 */
static HRESULT test_primary_secondary8(LPGUID lpGuid)
{
    HRESULT rc;
    LPDIRECTSOUND8 dso=NULL;
    LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
    DSBUFFERDESC bufdesc;
    DSCAPS dscaps;
    WAVEFORMATEX wfx, wfx2;
529 530
    int ref;
    unsigned int f;
531 532

    /* Create the DirectSound object */
533
    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
534
    ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
535
       "DirectSoundCreate8() failed: %08x\n",rc);
536 537 538 539 540 541 542
    if (rc!=DS_OK)
        return rc;

    /* Get the device capabilities */
    ZeroMemory(&dscaps, sizeof(dscaps));
    dscaps.dwSize=sizeof(dscaps);
    rc=IDirectSound8_GetCaps(dso,&dscaps);
543
    ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
544 545 546 547 548 549
    if (rc!=DS_OK)
        goto EXIT;

    /* We must call SetCooperativeLevel before creating primary buffer */
    /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
    rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
550
    ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
551 552 553 554 555 556 557 558
    if (rc!=DS_OK)
        goto EXIT;

    ZeroMemory(&bufdesc, sizeof(bufdesc));
    bufdesc.dwSize=sizeof(bufdesc);
    bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
    rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
    ok(rc==DS_OK && primary!=NULL,
559
       "IDirectSound8_CreateSoundBuffer() failed to create a primary buffer "
560
       "%08x\n",rc);
561 562 563

    if (rc==DS_OK && primary!=NULL) {
        for (f=0;f<NB_FORMATS;f++) {
564 565 566 567
            /* We must call SetCooperativeLevel to be allowed to call
             * SetFormat */
            /* DSOUND: Setting DirectSound cooperative level to
             * DSSCL_PRIORITY */
568
            rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
569
            ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
570 571 572 573 574 575 576
            if (rc!=DS_OK)
                goto EXIT;

            init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
                        formats[f][2]);
            wfx2=wfx;
            rc=IDirectSoundBuffer_SetFormat(primary,&wfx);
577 578 579
            ok(rc==DS_OK
               || rc==DSERR_INVALIDPARAM, /* 2003 */
               "IDirectSoundBuffer_SetFormat(%s) failed: %08x\n",
580
               format_string(&wfx), rc);
581

582
            /* There is no guarantee that SetFormat will actually change the
583 584 585 586
             * format to what we asked for. It depends on what the soundcard
             * supports. So we must re-query the format.
             */
            rc=IDirectSoundBuffer_GetFormat(primary,&wfx,sizeof(wfx),NULL);
587
            ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
588 589 590 591 592
            if (rc==DS_OK &&
                (wfx.wFormatTag!=wfx2.wFormatTag ||
                 wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
                 wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
                 wfx.nChannels!=wfx2.nChannels)) {
593 594
                trace("Requested primary format tag=0x%04x %dx%dx%d "
                      "avg.B/s=%d align=%d\n",
595 596
                      wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
                      wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
597
                trace("Got tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
598 599 600 601 602 603 604
                      wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
                      wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
            }

            /* Set the CooperativeLevel back to normal */
            /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
            rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
605
            ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
606 607 608 609 610 611 612

            init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);

            secondary=NULL;
            ZeroMemory(&bufdesc, sizeof(bufdesc));
            bufdesc.dwSize=sizeof(bufdesc);
            bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
613 614
            bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
                                        wfx.nBlockAlign);
615
            bufdesc.lpwfxFormat=&wfx2;
616
            if (winetest_interactive) {
617 618
                trace("  Testing a primary buffer at %dx%dx%d with a "
                      "secondary buffer at %dx%dx%d\n",
619 620 621
                      wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
                      wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels);
            }
622 623
            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
            ok(rc==DS_OK && secondary!=NULL,
624
               "IDirectSound_CreateSoundBuffer() failed to create a secondary "
625
               "buffer %08x\n",rc);
626 627

            if (rc==DS_OK && secondary!=NULL) {
628
                test_buffer8(dso,&secondary,0,FALSE,0,FALSE,0,
629 630 631
                             winetest_interactive,1.0,0,NULL,0,0);

                ref=IDirectSoundBuffer_Release(secondary);
632
                ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
633 634 635 636 637
                   "should have 0\n",ref);
            }
        }

        ref=IDirectSoundBuffer_Release(primary);
638
        ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
639 640 641 642 643 644
           "should have 0\n",ref);
    }

    /* Set the CooperativeLevel back to normal */
    /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
    rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
645
    ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
646 647 648

EXIT:
    ref=IDirectSound8_Release(dso);
649
    ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
650 651 652 653 654 655
    if (ref!=0)
        return DSERR_GENERIC;

    return rc;
}

656 657 658 659 660 661 662
static HRESULT test_secondary8(LPGUID lpGuid)
{
    HRESULT rc;
    LPDIRECTSOUND8 dso=NULL;
    LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
    DSBUFFERDESC bufdesc;
    DSCAPS dscaps;
663
    WAVEFORMATEX wfx, wfx1;
664 665
    DWORD f;
    int ref;
666 667

    /* Create the DirectSound object */
668
    rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
669
    ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
670
       "DirectSoundCreate8() failed: %08x\n",rc);
671 672 673 674 675 676 677
    if (rc!=DS_OK)
        return rc;

    /* Get the device capabilities */
    ZeroMemory(&dscaps, sizeof(dscaps));
    dscaps.dwSize=sizeof(dscaps);
    rc=IDirectSound8_GetCaps(dso,&dscaps);
678
    ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
679 680 681 682 683 684
    if (rc!=DS_OK)
        goto EXIT;

    /* We must call SetCooperativeLevel before creating primary buffer */
    /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
    rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
685
    ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
686 687 688 689 690 691 692 693
    if (rc!=DS_OK)
        goto EXIT;

    ZeroMemory(&bufdesc, sizeof(bufdesc));
    bufdesc.dwSize=sizeof(bufdesc);
    bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
    rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
    ok(rc==DS_OK && primary!=NULL,
694
       "IDirectSound8_CreateSoundBuffer() failed to create a primary buffer "
695
       "%08x\n",rc);
696 697

    if (rc==DS_OK && primary!=NULL) {
698
        rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
699
        ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %08x\n", rc);
700 701 702
        if (rc!=DS_OK)
            goto EXIT1;

703
        for (f=0;f<NB_FORMATS;f++) {
704
            WAVEFORMATEXTENSIBLE wfxe;
705 706 707 708 709 710
            init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
                        formats[f][2]);
            secondary=NULL;
            ZeroMemory(&bufdesc, sizeof(bufdesc));
            bufdesc.dwSize=sizeof(bufdesc);
            bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
711 712
            bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
                                        wfx.nBlockAlign);
713 714
            rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
            ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() "
715
               "should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
716 717 718 719 720 721 722
            if (rc==DS_OK && secondary!=NULL)
                IDirectSoundBuffer_Release(secondary);

            secondary=NULL;
            ZeroMemory(&bufdesc, sizeof(bufdesc));
            bufdesc.dwSize=sizeof(bufdesc);
            bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
723 724
            bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
                                        wfx.nBlockAlign);
725
            bufdesc.lpwfxFormat=&wfx;
726 727
            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
            if (wfx.wBitsPerSample != 8 && wfx.wBitsPerSample != 16)
728 729 730
                ok(((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL || rc == DSERR_INVALIDPARAM /* 2003 */) && !secondary)
                    || rc == DS_OK, /* driver dependent? */
                    "IDirectSound_CreateSoundBuffer() "
731 732
                    "should have returned (DSERR_CONTROLUNAVAIL or DSERR_INVALIDCALL) "
                    "and NULL, returned: %08x %p\n", rc, secondary);
733 734 735
            else
                ok(rc==DS_OK && secondary!=NULL,
                    "IDirectSound_CreateSoundBuffer() failed to create a secondary "
736
                    "buffer %08x\n",rc);
737 738 739 740 741 742 743 744 745 746 747 748 749 750
            if (secondary)
                IDirectSoundBuffer_Release(secondary);
            secondary = NULL;

            bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe;
            wfxe.Format = wfx;
            wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
            wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
            wfxe.Format.cbSize = 1;
            wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample;
            wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO : KSAUDIO_SPEAKER_STEREO);

            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
            ok(rc==DSERR_INVALIDPARAM && !secondary,
751 752
                "IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
                rc, secondary);
753
            if (secondary)
754
            {
755
                IDirectSoundBuffer_Release(secondary);
756 757
                secondary=NULL;
            }
758 759 760 761

            wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx) + 1;

            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
762 763
            ok(((rc==DSERR_CONTROLUNAVAIL || DSERR_INVALIDCALL /* 2003 */) && !secondary)
                || rc==DS_OK /* driver dependent? */,
764 765
                "IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
                rc, secondary);
766
            if (secondary)
767
            {
768
                IDirectSoundBuffer_Release(secondary);
769 770
                secondary=NULL;
            }
771 772 773 774

            wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx);
            wfxe.SubFormat = GUID_NULL;
            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
775
            ok((rc==DSERR_INVALIDPARAM || rc==DSERR_INVALIDCALL) && !secondary,
776 777
                "IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
                rc, secondary);
778
            if (secondary)
779
            {
780
                IDirectSoundBuffer_Release(secondary);
781 782
                secondary=NULL;
            }
783 784 785 786 787
            wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;

            ++wfxe.Samples.wValidBitsPerSample;
            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
            ok(rc==DSERR_INVALIDPARAM && !secondary,
788 789
                "IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
                rc, secondary);
790
            if (secondary)
791
            {
792
                IDirectSoundBuffer_Release(secondary);
793 794
                secondary=NULL;
            }
795 796 797 798 799
            --wfxe.Samples.wValidBitsPerSample;

            wfxe.Samples.wValidBitsPerSample = 0;
            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
            ok(rc==DS_OK && secondary,
800 801
                "IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
                rc, secondary);
802
            if (secondary)
803
            {
804
                IDirectSoundBuffer_Release(secondary);
805 806
                secondary=NULL;
            }
807 808 809
            wfxe.Samples.wValidBitsPerSample = wfxe.Format.wBitsPerSample;

            rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
810
            ok(rc==DS_OK && secondary!=NULL,
811
                "IDirectSound_CreateSoundBuffer() failed to create a secondary "
812
                "buffer %08x\n",rc);
813 814

            if (rc==DS_OK && secondary!=NULL) {
815 816 817 818 819 820
                if (winetest_interactive) {
                    trace("  Testing a secondary buffer at %dx%dx%d "
                        "with a primary buffer at %dx%dx%d\n",
                        wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
                        wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
                }
821
                test_buffer8(dso,&secondary,0,FALSE,0,FALSE,0,
822 823 824
                             winetest_interactive,1.0,0,NULL,0,0);

                ref=IDirectSoundBuffer_Release(secondary);
825
                ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
826 827 828
                   "should have 0\n",ref);
            }
        }
829
EXIT1:
830
        ref=IDirectSoundBuffer_Release(primary);
831
        ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
832 833 834 835 836 837
           "should have 0\n",ref);
    }

    /* Set the CooperativeLevel back to normal */
    /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
    rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
838
    ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
839 840 841

EXIT:
    ref=IDirectSound8_Release(dso);
842
    ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
843 844 845 846 847 848 849 850 851
    if (ref!=0)
        return DSERR_GENERIC;

    return rc;
}

static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
                                   LPCSTR lpcstrModule, LPVOID lpContext)
{
852
    HRESULT rc;
853
    trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
854 855 856
    rc = test_dsound8(lpGuid);
    if (rc == DSERR_NODRIVER)
        trace("  No Driver\n");
857 858
    else if (rc == DSERR_ALLOCATED)
        trace("  Already In Use\n");
859 860
    else if (rc == E_FAIL)
        trace("  No Device\n");
861 862 863 864 865
    else {
        test_primary8(lpGuid);
        test_primary_secondary8(lpGuid);
        test_secondary8(lpGuid);
    }
866 867 868 869

    return 1;
}

870
static void dsound8_tests(void)
871 872
{
    HRESULT rc;
873
    rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
874
    ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
875 876
}

877 878 879
const char * get_file_version(const char * file_name)
{
    static char version[32];
880
    static char backslash[] = "\\";
881 882 883 884 885 886 887 888 889 890
    DWORD size;
    DWORD handle;

    size = GetFileVersionInfoSizeA("dsound.dll", &handle);
    if (size) {
        char * data = HeapAlloc(GetProcessHeap(), 0, size);
        if (data) {
            if (GetFileVersionInfoA("dsound.dll", handle, size, data)) {
                VS_FIXEDFILEINFO *pFixedVersionInfo;
                UINT len;
891
                if (VerQueryValueA(data, backslash, (LPVOID *)&pFixedVersionInfo, &len)) {
892
                    sprintf(version, "%d.%d.%d.%d",
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910
                            pFixedVersionInfo->dwFileVersionMS >> 16,
                            pFixedVersionInfo->dwFileVersionMS & 0xffff,
                            pFixedVersionInfo->dwFileVersionLS >> 16,
                            pFixedVersionInfo->dwFileVersionLS & 0xffff);
                } else
                    sprintf(version, "not available");
            } else
                sprintf(version, "failed");

            HeapFree(GetProcessHeap(), 0, data);
        } else
            sprintf(version, "failed");
    } else
        sprintf(version, "not available");

    return version;
}

911 912 913 914 915 916
START_TEST(dsound8)
{
    HMODULE hDsound;

    CoInitialize(NULL);

917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932
    hDsound = LoadLibrary("dsound.dll");
    if (hDsound)
    {
        trace("DLL Version: %s\n", get_file_version("dsound.dll"));

        pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
            "DirectSoundEnumerateA");
        pDirectSoundCreate8 = (void*)GetProcAddress(hDsound,
            "DirectSoundCreate8");
        if (pDirectSoundCreate8)
        {
            IDirectSound8_tests();
            dsound8_tests();
        }
        else
            skip("dsound8 test skipped\n");
933

934
        FreeLibrary(hDsound);
935
    }
936 937
    else
        skip("dsound.dll not found!\n");
938 939

    CoUninitialize();
940
}