diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c index f8b7aeb8bb4..7eb882de4aa 100644 --- a/dlls/dsound/tests/dsound.c +++ b/dlls/dsound/tests/dsound.c @@ -1039,6 +1039,191 @@ EXIT: return rc; } +static HRESULT test_notify(LPDIRECTSOUNDBUFFER dsb, + DWORD count, LPHANDLE event, + DWORD expected) +{ + HRESULT rc; + DWORD ret; + + rc=IDirectSoundBuffer_SetCurrentPosition(dsb,0); + ok(rc==DS_OK, + "IDirectSoundBuffer_SetCurrentPosition failed %08x\n",rc); + if(rc!=DS_OK) + return rc; + + rc=IDirectSoundBuffer_Play(dsb,0,0,0); + ok(rc==DS_OK,"IDirectSoundBuffer_Play failed %08x\n",rc); + if(rc!=DS_OK) + return rc; + + rc=IDirectSoundBuffer_Stop(dsb); + ok(rc==DS_OK,"IDirectSoundBuffer_Stop failed %08x\n",rc); + if(rc!=DS_OK) + return rc; + + ret=WaitForMultipleObjects(count,event,FALSE,0); + if (expected != WAIT_OBJECT_0+1) { + todo_wine + ok(ret==expected,"expected %d. got %d\n",expected,ret); + } + else + ok(ret==expected,"expected %d. got %d\n",expected,ret); + return rc; +} + +static HRESULT test_duplicate(LPGUID lpGuid) +{ + HRESULT rc; + LPDIRECTSOUND dso=NULL; + LPDIRECTSOUNDBUFFER primary=NULL; + DSBUFFERDESC bufdesc; + int ref; + + /* Create the DirectSound object */ + rc=pDirectSoundCreate(lpGuid,&dso,NULL); + ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, + "DirectSoundCreate() failed: %08x\n",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() failed: %08x\n", rc); + if (rc!=DS_OK) + goto EXIT; + + ZeroMemory(&bufdesc, sizeof(bufdesc)); + bufdesc.dwSize=sizeof(bufdesc); + bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER; + rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL); + ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed " + "to create a primary buffer %08x\n",rc); + + if (rc==DS_OK && primary!=NULL) { + LPDIRECTSOUNDBUFFER original=NULL; + WAVEFORMATEX wfx; + + init_format(&wfx,WAVE_FORMAT_PCM,22050,16,1); + ZeroMemory(&bufdesc, sizeof(bufdesc)); + bufdesc.dwSize=sizeof(bufdesc); + bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLPOSITIONNOTIFY; + bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec/100; /* very short buffer */ + bufdesc.lpwfxFormat=&wfx; + rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&original,NULL); + ok(rc==DS_OK && original!=NULL, + "IDirectSound_CreateSoundBuffer() failed to create a original " + "buffer %08x\n",rc); + if (rc==DS_OK && original!=NULL) { + LPDIRECTSOUNDBUFFER duplicated=NULL; + LPDIRECTSOUNDNOTIFY notify=NULL; + HANDLE event[2]; + LPVOID buf=NULL; + DWORD bufsize; + int i; + + /* Prepare notify events */ + for (i=0;i