void RemoveSound(void) { int iRes; if(iDoRecord) RecordStop(); if(lpDSBSECONDARY1!=NULL) { IDirectSoundBuffer_Stop(lpDSBSECONDARY1); iRes=IDirectSoundBuffer_Release(lpDSBSECONDARY1); // FF says such a loop is bad... Demo says it's good... Pete doesn't care while(iRes!=0) iRes=IDirectSoundBuffer_Release(lpDSBSECONDARY1); lpDSBSECONDARY1=NULL; } if(lpDSBPRIMARY!=NULL) { IDirectSoundBuffer_Stop(lpDSBPRIMARY); iRes=IDirectSoundBuffer_Release(lpDSBPRIMARY); // FF says such a loop is bad... Demo says it's good... Pete doesn't care while(iRes!=0) iRes=IDirectSoundBuffer_Release(lpDSBPRIMARY); lpDSBPRIMARY=NULL; } if(lpDS!=NULL) { iRes=IDirectSound_Release(lpDS); // FF says such a loop is bad... Demo says it's good... Pete doesn't care while(iRes!=0) iRes=IDirectSound_Release(lpDS); lpDS=NULL; } }
static void FreeSound (void) { if (pDSBuf) { IDirectSoundBuffer_Stop (pDSBuf); IDirectSound_Release (pDSBuf); } // release primary buffer only if it's not also the mixing buffer we just released if (pDSPBuf && (pDSBuf != pDSPBuf)) { IDirectSound_Release (pDSPBuf); } if (pDS) { IDirectSound_SetCooperativeLevel (pDS, mainwindow, DSSCL_NORMAL); IDirectSound_Release (pDS); } pDS = NULL; pDSBuf = NULL; pDSPBuf = NULL; hWaveOut = 0; hData = 0; hWaveHdr = 0; lpData = NULL; lpWaveHdr = NULL; }
/* FreeSound */ void FreeSound (void) { int i; if (pDSBuf) { IDirectSoundBuffer_Stop (pDSBuf); IDirectSound_Release (pDSBuf); } // only release primary buffer if it's not also the mixing buffer we just released if (pDSPBuf && (pDSBuf != pDSPBuf)) { IDirectSound_Release (pDSPBuf); } if (pDS) { IDirectSound_SetCooperativeLevel (pDS, mainwindow, DSSCL_NORMAL); IDirectSound_Release (pDS); } if (hWaveOut) { waveOutReset (hWaveOut); if (lpWaveHdr) { for (i = 0; i < WAV_BUFFERS; i++) waveOutUnprepareHeader (hWaveOut, lpWaveHdr + i, sizeof (WAVEHDR)); } waveOutClose (hWaveOut); if (hWaveHdr) { GlobalUnlock (hWaveHdr); GlobalFree (hWaveHdr); } if (hData) { GlobalUnlock (hData); GlobalFree (hData); } } pDS = NULL; pDSBuf = NULL; pDSPBuf = NULL; hWaveOut = 0; hData = 0; hWaveHdr = 0; lpData = NULL; lpWaveHdr = NULL; dsound_init = false; wav_init = false; }
static void dsound_free(void *data) { dsound_t *ds = (dsound_t*)data; if (!ds) return; if (ds->thread) { ds->thread_alive = false; sthread_join(ds->thread); } DeleteCriticalSection(&ds->crit); if (ds->dsb) { IDirectSoundBuffer_Stop(ds->dsb); IDirectSoundBuffer_Release(ds->dsb); } if (ds->ds) IDirectSound_Release(ds->ds); if (ds->event) CloseHandle(ds->event); if (ds->buffer) fifo_free(ds->buffer); free(ds); }
void sound_direct_sound::dsound_kill() { // release the object if (dsound != NULL) IDirectSound_Release(dsound); dsound = NULL; }
/** * Closes the audio device. */ static HRESULT Stop( aout_stream_sys_t *p_sys ) { vlc_mutex_lock( &p_sys->lock ); p_sys->b_playing = true; vlc_cond_signal( &p_sys->cond ); vlc_mutex_unlock( &p_sys->lock ); vlc_cancel( p_sys->eraser_thread ); vlc_join( p_sys->eraser_thread, NULL ); vlc_cond_destroy( &p_sys->cond ); vlc_mutex_destroy( &p_sys->lock ); if( p_sys->p_notify != NULL ) { IDirectSoundNotify_Release(p_sys->p_notify ); p_sys->p_notify = NULL; } if( p_sys->p_dsbuffer != NULL ) { IDirectSoundBuffer_Stop( p_sys->p_dsbuffer ); IDirectSoundBuffer_Release( p_sys->p_dsbuffer ); p_sys->p_dsbuffer = NULL; } if( p_sys->p_dsobject != NULL ) { IDirectSound_Release( p_sys->p_dsobject ); p_sys->p_dsobject = NULL; } return DS_OK; }
void m1sdr_Exit(void) { if (!s32SoundEnable) { return; } if (lpSecB) { IDirectSoundBuffer_Stop(lpSecB); IDirectSoundBuffer_Release(lpSecB); lpSecB = NULL; } if (lpPDSB) { IDirectSoundBuffer_Stop(lpPDSB); IDirectSoundBuffer_Release(lpPDSB); lpPDSB = NULL; } if (lpDS) { IDirectSound_Release(lpDS); lpDS = NULL; } if (samples) { free(samples); } }
void digi_close(void) { if(digi_initialised){ digi_reset_digi_sounds(); IDirectSound_Release(lpds); } digi_initialised = 0; }
static void dsound_kill(void) { // release the object if (dsound) IDirectSound_Release(dsound); dsound = NULL; }
void DSW_Term( DSoundWrapper *dsw ) { // Cleanup the sound buffers if (dsw->dsw_OutputBuffer) { IDirectSoundBuffer_Stop( dsw->dsw_OutputBuffer ); IDirectSoundBuffer_Release( dsw->dsw_OutputBuffer ); dsw->dsw_OutputBuffer = NULL; } if (dsw->dsw_InputBuffer) { IDirectSoundCaptureBuffer_Stop( dsw->dsw_InputBuffer ); IDirectSoundCaptureBuffer_Release( dsw->dsw_InputBuffer ); dsw->dsw_InputBuffer = NULL; } if (dsw->dsw_pDirectSoundCapture) { IDirectSoundCapture_Release( dsw->dsw_pDirectSoundCapture ); dsw->dsw_pDirectSoundCapture = NULL; } if (dsw->dsw_pDirectSound) { IDirectSound_Release( dsw->dsw_pDirectSound ); dsw->dsw_pDirectSound = NULL; } }
void DSW_Term( DSoundWrapper *dsw ) { // Cleanup the sound buffers if (dsw->dsw_OutputBuffer) { IDirectSoundBuffer_Stop( dsw->dsw_OutputBuffer ); IDirectSoundBuffer_Release( dsw->dsw_OutputBuffer ); dsw->dsw_OutputBuffer = NULL; } #if SUPPORT_AUDIO_CAPTURE if (dsw->dsw_InputBuffer) { IDirectSoundCaptureBuffer_Stop( dsw->dsw_InputBuffer ); IDirectSoundCaptureBuffer_Release( dsw->dsw_InputBuffer ); dsw->dsw_InputBuffer = NULL; } if (dsw->dsw_pDirectSoundCapture) { IDirectSoundCapture_Release( dsw->dsw_pDirectSoundCapture ); dsw->dsw_pDirectSoundCapture = NULL; } #endif /* SUPPORT_AUDIO_CAPTURE */ if (dsw->dsw_pDirectSound) { IDirectSound_Release( dsw->dsw_pDirectSound ); dsw->dsw_pDirectSound = NULL; } }
static void dsound_free(void *data) { dsound_t *ds = (dsound_t*)data; if (ds) { if (ds->thread) { ds->thread_alive = false; WaitForSingleObject(ds->thread, INFINITE); CloseHandle(ds->thread); } DeleteCriticalSection(&ds->crit); if (ds->dsb) { IDirectSoundBuffer_Stop(ds->dsb); IDirectSoundBuffer_Release(ds->dsb); } if (ds->ds) IDirectSound_Release(ds->ds); if (ds->event) CloseHandle(ds->event); if (ds->buffer) fifo_free(ds->buffer); free(ds); } }
static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName) { DSoundData *pData = NULL; LPGUID guid = NULL; HRESULT hr; if(!DSoundLoad()) return ALC_FALSE; if(!deviceName) deviceName = dsDevice; else if(strcmp(deviceName, dsDevice) != 0) { ALuint i; if(!DeviceList) { hr = pDirectSoundEnumerateA(DSoundEnumDevices, NULL); if(FAILED(hr)) AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr); } for(i = 0; i < NumDevices; i++) { if(strcmp(deviceName, DeviceList[i].name) == 0) { if(i > 0) guid = &DeviceList[i].guid; break; } } if(i == NumDevices) return ALC_FALSE; } //Initialise requested device pData = calloc(1, sizeof(DSoundData)); if(!pData) { alcSetError(device, ALC_OUT_OF_MEMORY); return ALC_FALSE; } //DirectSound Init code hr = pDirectSoundCreate(guid, &pData->lpDS, NULL); if(SUCCEEDED(hr)) hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY); if(FAILED(hr)) { if(pData->lpDS) IDirectSound_Release(pData->lpDS); free(pData); AL_PRINT("Device init failed: 0x%08lx\n", hr); return ALC_FALSE; } device->szDeviceName = strdup(deviceName); device->ExtraData = pData; return ALC_TRUE; }
/* destructor */ static tsk_object_t* tdav_consumer_dsound_dtor(tsk_object_t * self) { tdav_consumer_dsound_t *dsound = self; if(dsound){ tsk_size_t i; /* stop */ if(dsound->started){ tdav_consumer_dsound_stop(self); } /* deinit base */ tdav_consumer_audio_deinit(TDAV_CONSUMER_AUDIO(dsound)); /* deinit self */ // Delete secondary buffer if(dsound->primaryBuffer){ IDirectSoundBuffer_Release(dsound->primaryBuffer); } if(dsound->secondaryBuffer){ IDirectSoundBuffer_Release(dsound->secondaryBuffer); } if(dsound->device){ IDirectSound_Release(dsound->device); } for(i = 0; i<sizeof(dsound->notifEvents)/sizeof(HANDLE); i++){ if(dsound->notifEvents[i]){ CloseHandle(dsound->notifEvents[i]); } } } return self; }
void delete_fluid_dsound_audio_driver(fluid_audio_driver_t* d) { fluid_dsound_audio_driver_t* dev = (fluid_dsound_audio_driver_t*) d; fluid_return_if_fail(dev != NULL); /* tell the audio thread to stop its loop */ dev->cont = 0; /* wait till the audio thread exits */ if (dev->thread != 0) { if (WaitForSingleObject(dev->thread, 2000) != WAIT_OBJECT_0) { /* on error kill the thread mercilessly */ FLUID_LOG(FLUID_DBG, "Couldn't join the audio thread. killing it."); TerminateThread(dev->thread, 0); } } /* release all the allocated ressources */ FLUID_FREE(dev->format); if (dev->sec_buffer != NULL) { IDirectSoundBuffer_Stop(dev->sec_buffer); IDirectSoundBuffer_Release(dev->sec_buffer); } if (dev->prim_buffer != NULL) { IDirectSoundBuffer_Release(dev->prim_buffer); } if (dev->direct_sound != NULL) { IDirectSound_Release(dev->direct_sound); } FLUID_FREE(dev); }
void SSDestroy() { int i; int j = 0; if (!SSMixer.lpds) return; // Free sound buffers currently allocated. for (i=0; i<SSMixer.ch_num; i++) if (SSMixer.ch_list[i].obj) { j++; IDirectSoundBuffer_Release(SSMixer.ch_list[i].obj); } if (j) mprintf((1, "SS: Releasing %d sound buffers!\n", j)); free(SSMixer.ch_list); // Restore old WAV volume waveOutSetVolume((HWAVEOUT)WAVE_MAPPER, SSMixer.old_master_vol); // Turn off DirectSound if (SSMixer.lpds) IDirectSound_Release(SSMixer.lpds); memset(&SSMixer, 0, sizeof(SSMixer)); }
static ULONG WINAPI DSoundRender_Release(IBaseFilter * iface) { DSoundRenderImpl *This = impl_from_IBaseFilter(iface); ULONG refCount = BaseRendererImpl_Release(iface); TRACE("(%p)->() Release from %d\n", This, refCount + 1); if (!refCount) { if (This->threadid) { PostThreadMessageW(This->threadid, WM_APP, 0, 0); WaitForSingleObject(This->advisethread, INFINITE); CloseHandle(This->advisethread); } if (This->dsbuffer) IDirectSoundBuffer_Release(This->dsbuffer); This->dsbuffer = NULL; if (This->dsound) IDirectSound_Release(This->dsound); This->dsound = NULL; BasicAudio_Destroy(&This->basicAudio); CloseHandle(This->blocked); TRACE("Destroying Audio Renderer\n"); CoTaskMemFree(This); return 0; } else return refCount; }
/************************************************************************** * MCICDA_Stop [internal] */ static DWORD MCICDA_Stop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms) { WINE_MCICDAUDIO* wmcda = MCICDA_GetOpenDrv(wDevID); HANDLE oldcb; DWORD br; TRACE("(%04X, %08X, %p);\n", wDevID, dwFlags, lpParms); if (wmcda == NULL) return MCIERR_INVALID_DEVICE_ID; oldcb = InterlockedExchangePointer(&wmcda->hCallback, NULL); if (oldcb) mciDriverNotify(oldcb, wmcda->wNotifyDeviceID, MCI_NOTIFY_ABORTED); if (wmcda->hThread != 0) { SetEvent(wmcda->stopEvent); WaitForSingleObject(wmcda->hThread, INFINITE); CloseHandle(wmcda->hThread); wmcda->hThread = 0; CloseHandle(wmcda->stopEvent); wmcda->stopEvent = 0; IDirectSoundBuffer_Release(wmcda->dsBuf); wmcda->dsBuf = NULL; IDirectSound_Release(wmcda->dsObj); wmcda->dsObj = NULL; } else if (!DeviceIoControl(wmcda->handle, IOCTL_CDROM_STOP_AUDIO, NULL, 0, NULL, 0, &br, NULL)) return MCIERR_HARDWARE; if ((dwFlags & MCI_NOTIFY) && lpParms) MCICDA_Notify(lpParms->dwCallback, wmcda, MCI_NOTIFY_SUCCESSFUL); return 0; }
static void ClearDupBuffers( Channel* channel ) { Channel* dupChannel, *prevChannel; if( channel == NULL) return; dupChannel = channel->nextDup; prevChannel = channel; while( dupChannel ) { if( !ChannelPlaying( dupChannel ) ) { prevChannel->nextDup = dupChannel->nextDup; IDirectSound_Release(dupChannel->buffer); // free( dupChannel ); geRam_Free(dupChannel); dupChannel = prevChannel->nextDup; } else { prevChannel = dupChannel; dupChannel = dupChannel->nextDup; } } }
static void DSoundClosePlayback(ALCdevice *device) { DSoundData *pData = device->ExtraData; IDirectSound_Release(pData->lpDS); free(pData); device->ExtraData = NULL; }
/* IDirectMusicPerformance8 Interface part follow: */ static HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusic** ppDirectMusic, IDirectSound** ppDirectSound, HWND hWnd, DWORD dwDefaultPathType, DWORD dwPChannelCount, DWORD dwFlags, DMUS_AUDIOPARAMS* pParams) { IDirectSound* dsound = NULL; HRESULT hr = S_OK; IDirectMusicPerformance8Impl *This = (IDirectMusicPerformance8Impl *)iface; FIXME("(%p, %p, %p, %p, %x, %u, %x, %p): to check\n", This, ppDirectMusic, ppDirectSound, hWnd, dwDefaultPathType, dwPChannelCount, dwFlags, pParams); if (This->pDirectMusic || This->pDirectSound) return DMUS_E_ALREADY_INITED; if (NULL != ppDirectSound && NULL != *ppDirectSound) { dsound = *ppDirectSound; } else { hr = DirectSoundCreate8 (NULL, (LPDIRECTSOUND8*) &dsound, NULL); FIXME("return dsound(%p,%d)\n", dsound, hr); if (FAILED(hr) || !dsound) return DSERR_NODRIVER; if (ppDirectSound) *ppDirectSound = dsound; } IDirectMusicPerformance8Impl_Init(iface, ppDirectMusic, dsound, hWnd); /* Init increases the ref count of the dsound object. Decrement it if the app doesn't want a pointer to the object. */ if (NULL == ppDirectSound) { IDirectSound_Release(This->pDirectSound); } /* as seen in msdn we need params init before audio path creation */ if (NULL != pParams) { This->pParams = *pParams; } else { /* TODO, how can i fill the struct as seen on msdn */ memset(&This->pParams, 0, sizeof(DMUS_AUDIOPARAMS)); This->pParams.dwSize = sizeof(DMUS_AUDIOPARAMS); This->pParams.fInitNow = FALSE; This->pParams.dwValidData = DMUS_AUDIOPARAMS_FEATURES | DMUS_AUDIOPARAMS_VOICES | DMUS_AUDIOPARAMS_SAMPLERATE | DMUS_AUDIOPARAMS_DEFAULTSYNTH; This->pParams.dwVoices = 64; This->pParams.dwSampleRate = (DWORD) 22.050; This->pParams.dwFeatures = dwFlags; This->pParams.clsidDefaultSynth = CLSID_DirectMusicSynthSink; } hr = IDirectMusicPerformance8_CreateStandardAudioPath(iface, dwDefaultPathType, dwPChannelCount, FALSE, &This->pDefaultPath); PostMessageToProcessMsgThread(This, PROCESSMSG_START); return hr; }
void pest_internal_close(){ done = TRUE; while(!ready_to_quit){ Sleep(100); } if(primary!=NULL) IDirectSoundBuffer_Release( primary ); if(secondary!=NULL) IDirectSoundBuffer_Release( secondary ); if(dsound!=NULL) IDirectSound_Release( dsound ); }
static BOOL DS_IsPresent(void) { if(DirectSoundCreate(NULL,&pSoundCard,NULL)!=DS_OK) return 0; if (pSoundCard) { IDirectSound_Release(pSoundCard); pSoundCard = NULL; } return 1; }
static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName) { DSoundData *pData = NULL; LPGUID guid = NULL; HRESULT hr; if(!deviceName) deviceName = dsDevice; else if(strcmp(deviceName, dsDevice) != 0) { ALuint i; for(i = 0;i < NumDevices;i++) { if(strcmp(deviceName, DeviceList[i].name) == 0) { guid = &DeviceList[i].guid; break; } } if(i == NumDevices) return ALC_FALSE; } DSoundLoad(); if(ds_handle == NULL) return ALC_FALSE; //Initialise requested device pData = calloc(1, sizeof(DSoundData)); if(!pData) { alcSetError(ALC_OUT_OF_MEMORY); DSoundUnload(); return ALC_FALSE; } //DirectSound Init code hr = pDirectSoundCreate(guid, &pData->lpDS, NULL); if(SUCCEEDED(hr)) hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY); if(FAILED(hr)) { if(pData->lpDS) IDirectSound_Release(pData->lpDS); free(pData); DSoundUnload(); return ALC_FALSE; } device->szDeviceName = strdup(deviceName); device->ExtraData = pData; return ALC_TRUE; }
SoundDevice::~SoundDevice() { if (dsBuffer) { // TODO: Free soundbuffer somehow? } if (dsObject) { IDirectSound_Release(dsObject); } }
/* * DirectSoundの使用を終了する */ VOID DSCleanup() { int i; /* イベントスレッドの終了を待つ */ if(hQuitEvent != NULL) { /* 終了を通知する*/ SetEvent(hQuitEvent); // スレッドの終了を待つ if(hEventThread != NULL) WaitForSingleObject(hEventThread, 1000*30); CloseHandle(hQuitEvent); /* * _beginthread()で作成したスレッドのハンドルhEventThreadは、 * CloseHandle()で閉じては*いけない*。 */ } /* クリティカルセクションを削除する */ DeleteCriticalSection(&StreamCritical); /* セカンダリバッファと通知イベントを解放する */ for(i=0; i<MIXER_STREAMS; i++) { if(pDSNotify[i] != NULL) { IDirectSoundNotify_Release(pDSNotify[i]); pDSNotify[i] = NULL; } if(pDSBuffer[i] != NULL) { IDirectSoundBuffer_Release(pDSBuffer[i]); pDSBuffer[i] = NULL; } if(hNotifyEvent[i] != NULL) { CloseHandle(hNotifyEvent[i]); hNotifyEvent[i] = NULL; } } /* DirectSoundオブジェクトを解放する */ if(pDS != NULL) { IDirectSound_Release(pDS); pDS = NULL; } }
static ULONG WINAPI IDirectSoundFullDuplex_IDirectSound8_Release( LPDIRECTSOUND8 iface) { IDirectSoundFullDuplex_IDirectSound8 *This = (IDirectSoundFullDuplex_IDirectSound8 *)iface; ULONG ref = InterlockedDecrement(&(This->ref)); TRACE("(%p) ref was %ld\n", This, ref + 1); if (!ref) { IDirectSound_Release(This->pdsfd->pDS8); HeapFree(GetProcessHeap(), 0, This); TRACE("(%p) released\n", This); } return ref; }
static ULONG WINAPI IDirectSoundFullDuplex_IUnknown_Release( LPUNKNOWN iface) { IDirectSoundFullDuplex_IUnknown *This = (IDirectSoundFullDuplex_IUnknown *)iface; ULONG ref = InterlockedDecrement(&(This->ref)); TRACE("(%p) ref was %ld\n", This, ref + 1); if (!ref) { IDirectSound_Release(This->pdsfd->pUnknown); HeapFree(GetProcessHeap(), 0, This); TRACE("(%p) released\n", This); } return ref; }
/* * DSOUND_Shutdown * Shuts down DirectSound and it's associates. */ int DSOUND_Shutdown(void) { int i; if (DSOUND_Installed) printOSD("Uninitializing DirectSound...\n"); DSOUND_Installed = FALSE; DSOUND_StopPlayback(); if (lpDSNotify) { IDirectSoundNotify_Release(lpDSNotify); lpDSNotify = NULL; } if (hPosNotify) { for (i=0; i<_DSOUND_NumBuffers; i++) { if (hPosNotify[i]) CloseHandle(hPosNotify[i]); } free(hPosNotify); hPosNotify = NULL; } if (lpDSBSecondary) { printOSD(" - Releasing secondary buffer\n"); IDirectSoundBuffer_Stop(lpDSBSecondary); IDirectSoundBuffer_Release(lpDSBSecondary); lpDSBSecondary = NULL; } if (lpDSBPrimary) { printOSD(" - Releasing primary buffer\n"); IDirectSoundBuffer_Release(lpDSBPrimary); lpDSBPrimary = NULL; } if (lpDS) { printOSD(" - Releasing DirectSound object\n"); IDirectSound_Release(lpDS); lpDS = NULL; } if (hDSoundDLL) { printOSD(" - Unloading DSOUND.DLL\n"); FreeLibrary(hDSoundDLL); hDSoundDLL = NULL; } DSOUND_SetErrorCode(DSOUND_Ok); return DSOUND_Ok; }
static HRESULT test_block_align(LPGUID lpGuid) { HRESULT rc; LPDIRECTSOUND dso=NULL; LPDIRECTSOUNDBUFFER secondary=NULL; DSBUFFERDESC bufdesc; DSBCAPS dsbcaps; WAVEFORMATEX wfx; int ref; /* Create the DirectSound object */ rc=DirectSoundCreate(lpGuid,&dso,NULL); ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED, "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc)); if (rc!=DS_OK) return rc; init_format(&wfx,WAVE_FORMAT_PCM,11025,16,2); ZeroMemory(&bufdesc, sizeof(bufdesc)); bufdesc.dwSize=sizeof(bufdesc); bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2; bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec + 1; bufdesc.lpwfxFormat=&wfx; rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL); ok(rc==DS_OK,"IDirectSound_CreateSoundBuffer() " "should have returned DS_OK, returned: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK && secondary!=NULL) { ZeroMemory(&dsbcaps, sizeof(dsbcaps)); dsbcaps.dwSize = sizeof(dsbcaps); rc=IDirectSoundBuffer_GetCaps(secondary,&dsbcaps); ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() should have returned DS_OK, " "returned: %s\n", DXGetErrorString8(rc)); if (rc==DS_OK) ok(dsbcaps.dwBufferBytes==(wfx.nAvgBytesPerSec + wfx.nBlockAlign), "Buffer size not a multiple of nBlockAlign: requested %ld, " "got %ld, should be %ld\n", bufdesc.dwBufferBytes, dsbcaps.dwBufferBytes, wfx.nAvgBytesPerSec + wfx.nBlockAlign); ref=IDirectSoundBuffer_Release(secondary); ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d references, " "should have 0\n",ref); } 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; }