⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ds3d.c

📁 一个类似windows
💻 C
📖 第 1 页 / 共 4 页
字号:
           now-start_time,1000*duration);        free(state.wave);        if (is_primary) {            /* Set the CooperativeLevel back to normal */            /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */            rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);            ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) "               "failed: %s\n",DXGetErrorString8(rc));        }        if (buffer3d) {            ref=IDirectSound3DBuffer_Release(buffer);            ok(ref==0,"IDirectSound3DBuffer_Release() has %d references, "               "should have 0\n",ref);        }    }}static HRESULT test_secondary(LPGUID lpGuid, int play,                              int has_3d, int has_3dbuffer,                              int has_listener, int has_duplicate,                              int move_listener, int move_sound){    HRESULT rc;    LPDIRECTSOUND dso=NULL;    LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;    LPDIRECTSOUND3DLISTENER listener=NULL;    DSBUFFERDESC bufdesc;    WAVEFORMATEX wfx, wfx1;    int ref;    /* Create the DirectSound object */    rc=DirectSoundCreate(lpGuid,&dso,NULL);    ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %s\n",       DXGetErrorString8(rc));    if (rc!=DS_OK)        return rc;    /* We must call SetCooperativeLevel before creating primary buffer */    /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */    rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);    ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: "       "%s\n",DXGetErrorString8(rc));    if (rc!=DS_OK)        goto EXIT;    ZeroMemory(&bufdesc, sizeof(bufdesc));    bufdesc.dwSize=sizeof(bufdesc);    bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;    if (has_3d)        bufdesc.dwFlags|=DSBCAPS_CTRL3D;    else        bufdesc.dwFlags|=(DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);    rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);    ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),       "IDirectSound_CreateSoundBuffer() failed to create a %sprimary buffer: "       "%s\n",has_3d?"3D ":"", DXGetErrorString8(rc));    if (rc==DSERR_CONTROLUNAVAIL)        trace("  No Primary\n");    else if (rc==DS_OK && primary!=NULL) {        rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);        ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",           DXGetErrorString8(rc));        if (rc!=DS_OK)            goto EXIT1;        if (has_listener) {            rc=IDirectSoundBuffer_QueryInterface(primary,                                                 &IID_IDirectSound3DListener,                                                 (void **)&listener);            ok(rc==DS_OK && listener!=NULL,               "IDirectSoundBuffer_QueryInterface() failed to get a 3D "               "listener: %s\n",DXGetErrorString8(rc));            ref=IDirectSoundBuffer_Release(primary);            ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "               "should have 0\n",ref);            if (rc==DS_OK && listener!=NULL) {                DS3DLISTENER listener_param;                ZeroMemory(&listener_param,sizeof(listener_param));                /* DSOUND: Error: Invalid buffer */                rc=IDirectSound3DListener_GetAllParameters(listener,0);                ok(rc==DSERR_INVALIDPARAM,                   "IDirectSound3dListener_GetAllParameters() should have "                   "returned DSERR_INVALIDPARAM, returned: %s\n",                   DXGetErrorString8(rc));                /* DSOUND: Error: Invalid buffer */                rc=IDirectSound3DListener_GetAllParameters(listener,                                                           &listener_param);                ok(rc==DSERR_INVALIDPARAM,                   "IDirectSound3dListener_GetAllParameters() should have "                   "returned DSERR_INVALIDPARAM, returned: %s\n",                   DXGetErrorString8(rc));                listener_param.dwSize=sizeof(listener_param);                rc=IDirectSound3DListener_GetAllParameters(listener,                                                           &listener_param);                ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "                   "failed: %s\n",DXGetErrorString8(rc));            }            else                goto EXIT;        }        init_format(&wfx,WAVE_FORMAT_PCM,22050,16,2);        secondary=NULL;        ZeroMemory(&bufdesc, sizeof(bufdesc));        bufdesc.dwSize=sizeof(bufdesc);        bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;        if (has_3d)            bufdesc.dwFlags|=DSBCAPS_CTRL3D;        else            bufdesc.dwFlags|=                (DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);        bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,                                    wfx.nBlockAlign);        bufdesc.lpwfxFormat=&wfx;        if (winetest_interactive) {            trace("  Testing a %s%ssecondary buffer %s%s%s%sat %ldx%dx%d "                  "with a primary buffer at %ldx%dx%d\n",                  has_3dbuffer?"3D ":"",                  has_duplicate?"duplicated ":"",                  listener!=NULL||move_sound?"with ":"",                  move_listener?"moving ":"",                  listener!=NULL?"listener ":"",                  listener&&move_sound?"and moving sound ":move_sound?                  "moving sound ":"",                  wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,                  wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);        }        rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);        ok(rc==DS_OK && secondary!=NULL,"IDirectSound_CreateSoundBuffer() "           "failed to create a %s%ssecondary buffer %s%s%s%sat %ldx%dx%d (%s): %s\n",           has_3dbuffer?"3D ":"", has_duplicate?"duplicated ":"",           listener!=NULL||move_sound?"with ":"", move_listener?"moving ":"",           listener!=NULL?"listener ":"",           listener&&move_sound?"and moving sound ":move_sound?           "moving sound ":"",           wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,           getDSBCAPS(bufdesc.dwFlags),DXGetErrorString8(rc));        if (rc==DS_OK && secondary!=NULL) {            if (!has_3d) {                LONG refvol,vol,refpan,pan;                /* Check the initial secondary buffer's volume and pan */                rc=IDirectSoundBuffer_GetVolume(secondary,&vol);                ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(secondary) failed: "                   "%s\n",DXGetErrorString8(rc));                ok(vol==0,"wrong volume for a new secondary buffer: %ld\n",vol);                rc=IDirectSoundBuffer_GetPan(secondary,&pan);                ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(secondary) failed: "                   "%s\n",DXGetErrorString8(rc));                ok(pan==0,"wrong pan for a new secondary buffer: %ld\n",pan);                /* Check that changing the secondary buffer's volume and pan                 * does not impact the primary buffer's volume and pan                 */                rc=IDirectSoundBuffer_GetVolume(primary,&refvol);                ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(primary) failed: "                   "%s\n",DXGetErrorString8(rc));                rc=IDirectSoundBuffer_GetPan(primary,&refpan);                ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: %s\n",                   DXGetErrorString8(rc));                rc=IDirectSoundBuffer_SetVolume(secondary,-1000);                ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "                   "%s\n",DXGetErrorString8(rc));                rc=IDirectSoundBuffer_GetVolume(secondary,&vol);                ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "                   "%s\n",DXGetErrorString8(rc));                ok(vol==-1000,"secondary: wrong volume %ld instead of -1000\n",                   vol);                rc=IDirectSoundBuffer_SetPan(secondary,-1000);                ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "                   "%s\n",DXGetErrorString8(rc));                rc=IDirectSoundBuffer_GetPan(secondary,&pan);                ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "                   "%s\n",DXGetErrorString8(rc));                ok(pan==-1000,"secondary: wrong pan %ld instead of -1000\n",                   pan);                rc=IDirectSoundBuffer_GetVolume(primary,&vol);                ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(primary) failed: "                   "%s\n",DXGetErrorString8(rc));                ok(vol==refvol,"The primary volume changed from %ld to %ld\n",                   refvol,vol);                rc=IDirectSoundBuffer_GetPan(primary,&pan);                ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: %s\n",                   DXGetErrorString8(rc));                ok(pan==refpan,"The primary pan changed from %ld to %ld\n",                   refpan,pan);                rc=IDirectSoundBuffer_SetVolume(secondary,0);                ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: "                   "%s\n",DXGetErrorString8(rc));                rc=IDirectSoundBuffer_SetPan(secondary,0);                ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: "                   "%s\n",DXGetErrorString8(rc));            }            if (has_duplicate) {                LPDIRECTSOUNDBUFFER duplicated=NULL;                /* DSOUND: Error: Invalid source buffer */                rc=IDirectSound_DuplicateSoundBuffer(dso,0,0);                ok(rc==DSERR_INVALIDPARAM,                   "IDirectSound_DuplicateSoundBuffer() should have returned "                   "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));                /* DSOUND: Error: Invalid dest buffer */                rc=IDirectSound_DuplicateSoundBuffer(dso,secondary,0);                ok(rc==DSERR_INVALIDPARAM,                   "IDirectSound_DuplicateSoundBuffer() should have returned "                   "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));                /* DSOUND: Error: Invalid source buffer */                rc=IDirectSound_DuplicateSoundBuffer(dso,0,&duplicated);                ok(rc==DSERR_INVALIDPARAM,                  "IDirectSound_DuplicateSoundBuffer() should have returned "                  "DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));                duplicated=NULL;                rc=IDirectSound_DuplicateSoundBuffer(dso,secondary,                                                     &duplicated);                ok(rc==DS_OK && duplicated!=NULL,                   "IDirectSound_DuplicateSoundBuffer() failed to duplicate "                   "a secondary buffer: %s\n",DXGetErrorString8(rc));                if (rc==DS_OK && duplicated!=NULL) {                    ref=IDirectSoundBuffer_Release(secondary);                    ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "                      "references, should have 0\n",ref);                    secondary=duplicated;                }            }            if (rc==DS_OK && secondary!=NULL) {                double duration;                duration=(move_listener || move_sound?4.0:1.0);                test_buffer(dso,secondary,0,FALSE,0,FALSE,0,                            winetest_interactive,duration,has_3dbuffer,                            listener,move_listener,move_sound,FALSE,0);                ref=IDirectSoundBuffer_Release(secondary);                ok(ref==0,"IDirectSoundBuffer_Release() %s has %d references, "                   "should have 0\n",has_duplicate?"duplicated":"secondary",                   ref);            }        }    }EXIT1:    if (has_listener) {        ref=IDirectSound3DListener_Release(listener);        ok(ref==0,"IDirectSound3dListener_Release() listener has %d "           "references, should have 0\n",ref);    } else {        ref=IDirectSoundBuffer_Release(primary);        ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "           "should have 0\n",ref);    }    /* Set the CooperativeLevel back to normal */    /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */    rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);    ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) failed: %s\n",       DXGetErrorString8(rc));EXIT:    ref=IDirectSound_Release(dso);    ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);    if (ref!=0)        return DSERR_GENERIC;    return rc;}static HRESULT test_for_driver(LPGUID lpGuid){    HRESULT rc;    LPDIRECTSOUND dso=NULL;    int ref;    /* Create the DirectSound object */    rc=DirectSoundCreate(lpGuid,&dso,NULL);    ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,       "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));    if (rc!=DS_OK)        return rc;    ref=IDirectSound_Release(dso);    ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);    if (ref!=0)        return DSERR_GENERIC;    return rc;}static HRESULT test_primary(LPGUID lpGuid){    HRESULT rc;    LPDIRECTSOUND dso=NULL;    LPDIRECTSOUNDBUFFER primary=NULL;    DSBUFFERDESC bufdesc;    DSCAPS dscaps;    int ref, i;    /* Create the DirectSound object */    rc=DirectSoundCreate(lpGuid,&dso,NULL);    ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %s\n",       DXGetErrorString8(rc));    if (rc!=DS_OK)        return rc;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -