Lines Matching refs:device
58 static void DSOUND_RecalcPrimary(DirectSoundDevice *device) in DSOUND_RecalcPrimary() argument
60 TRACE("(%p)\n", device); in DSOUND_RecalcPrimary()
62 device->fraglen = DSOUND_fraglen(device->pwfx->nSamplesPerSec, device->pwfx->nBlockAlign); in DSOUND_RecalcPrimary()
63 device->helfrags = device->buflen / device->fraglen; in DSOUND_RecalcPrimary()
64 TRACE("fraglen=%d helfrags=%d\n", device->fraglen, device->helfrags); in DSOUND_RecalcPrimary()
66 if (device->hwbuf && device->drvdesc.dwFlags & DSDDESC_DONTNEEDWRITELEAD) in DSOUND_RecalcPrimary()
67 device->writelead = 0; in DSOUND_RecalcPrimary()
70 device->writelead = (device->pwfx->nSamplesPerSec / 100) * device->pwfx->nBlockAlign; in DSOUND_RecalcPrimary()
73 HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) in DSOUND_ReopenDevice() argument
76 TRACE("(%p, %d)\n", device, forcewave); in DSOUND_ReopenDevice()
78 if (device->driver) in DSOUND_ReopenDevice()
80 IDsDriver_Close(device->driver); in DSOUND_ReopenDevice()
81 if (device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN) in DSOUND_ReopenDevice()
82 waveOutClose(device->hwo); in DSOUND_ReopenDevice()
83 IDsDriver_Release(device->driver); in DSOUND_ReopenDevice()
84 device->driver = NULL; in DSOUND_ReopenDevice()
85 device->buffer = NULL; in DSOUND_ReopenDevice()
86 device->hwo = 0; in DSOUND_ReopenDevice()
88 else if (device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN) in DSOUND_ReopenDevice()
89 waveOutClose(device->hwo); in DSOUND_ReopenDevice()
93 …waveOutMessage((HWAVEOUT)(DWORD_PTR)device->drvdesc.dnDevNode, DRV_QUERYDSOUNDIFACE, (DWORD_PTR)&d… in DSOUND_ReopenDevice()
96 if (device->driver) { in DSOUND_ReopenDevice()
97 DWORD wod = device->drvdesc.dnDevNode; in DSOUND_ReopenDevice()
98 hres = IDsDriver_GetDriverDesc(device->driver,&(device->drvdesc)); in DSOUND_ReopenDevice()
99 device->drvdesc.dnDevNode = wod; in DSOUND_ReopenDevice()
102 IDsDriver_Release(device->driver); in DSOUND_ReopenDevice()
103 device->driver = NULL; in DSOUND_ReopenDevice()
108 if (!device->driver) in DSOUND_ReopenDevice()
109 device->drvdesc.dwFlags = DSDDESC_DOMMSYSTEMOPEN | DSDDESC_DOMMSYSTEMSETFORMAT; in DSOUND_ReopenDevice()
111 if (device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMOPEN) in DSOUND_ReopenDevice()
115 if (device->driver) in DSOUND_ReopenDevice()
118 …res = mmErr(waveOutOpen(&(device->hwo), device->drvdesc.dnDevNode, device->pwfx, (DWORD_PTR)DSOUND… in DSOUND_ReopenDevice()
121 if (device->driver) in DSOUND_ReopenDevice()
123 IDsDriver_Release(device->driver); in DSOUND_ReopenDevice()
124 device->driver = NULL; in DSOUND_ReopenDevice()
130 if (device->driver) in DSOUND_ReopenDevice()
131 hres = IDsDriver_Open(device->driver); in DSOUND_ReopenDevice()
136 static HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device) in DSOUND_PrimaryOpen() argument
140 TRACE("(%p)\n", device); in DSOUND_PrimaryOpen()
144 if (!device->buflen) in DSOUND_PrimaryOpen()
145 device->buflen = ds_hel_buflen; in DSOUND_PrimaryOpen()
146 buflen = device->buflen; in DSOUND_PrimaryOpen()
147 buflen -= buflen % device->pwfx->nBlockAlign; in DSOUND_PrimaryOpen()
148 device->buflen = buflen; in DSOUND_PrimaryOpen()
150 if (device->driver) in DSOUND_PrimaryOpen()
152 err = IDsDriver_CreateSoundBuffer(device->driver,device->pwfx, in DSOUND_PrimaryOpen()
154 &(device->buflen),&(device->buffer), in DSOUND_PrimaryOpen()
155 (LPVOID*)&(device->hwbuf)); in DSOUND_PrimaryOpen()
159 err = DSOUND_ReopenDevice(device, TRUE); in DSOUND_PrimaryOpen()
166 if (device->hwbuf) in DSOUND_PrimaryOpen()
167 IDsDriverBuffer_SetVolumePan(device->hwbuf, &device->volpan); in DSOUND_PrimaryOpen()
169 DSOUND_RecalcPrimary(device); in DSOUND_PrimaryOpen()
170 device->prebuf = ds_snd_queue_max; in DSOUND_PrimaryOpen()
171 if (device->helfrags < ds_snd_queue_min) in DSOUND_PrimaryOpen()
173 …fer to be effective (%d/%d) falling back to waveout\n", device->buflen, ds_snd_queue_min * device-… in DSOUND_PrimaryOpen()
174 device->buflen = buflen; in DSOUND_PrimaryOpen()
175 IDsDriverBuffer_Release(device->hwbuf); in DSOUND_PrimaryOpen()
176 device->hwbuf = NULL; in DSOUND_PrimaryOpen()
177 err = DSOUND_ReopenDevice(device, TRUE); in DSOUND_PrimaryOpen()
184 else if (device->helfrags < ds_snd_queue_max) in DSOUND_PrimaryOpen()
185 device->prebuf = device->helfrags; in DSOUND_PrimaryOpen()
188 device->mix_buffer_len = DSOUND_bufpos_to_mixpos(device, device->buflen); in DSOUND_PrimaryOpen()
189 device->mix_buffer = HeapAlloc(GetProcessHeap(), 0, device->mix_buffer_len); in DSOUND_PrimaryOpen()
190 if (!device->mix_buffer) in DSOUND_PrimaryOpen()
192 if (device->hwbuf) in DSOUND_PrimaryOpen()
193 IDsDriverBuffer_Release(device->hwbuf); in DSOUND_PrimaryOpen()
194 device->hwbuf = NULL; in DSOUND_PrimaryOpen()
198 if (device->state == STATE_PLAYING) device->state = STATE_STARTING; in DSOUND_PrimaryOpen()
199 else if (device->state == STATE_STOPPING) device->state = STATE_STOPPED; in DSOUND_PrimaryOpen()
202 if (!device->driver) { in DSOUND_PrimaryOpen()
209 waveOutPause(device->hwo); in DSOUND_PrimaryOpen()
211 TRACE("desired buflen=%d, old buffer=%p\n", buflen, device->buffer); in DSOUND_PrimaryOpen()
214 if (device->buffer) in DSOUND_PrimaryOpen()
215 newbuf = HeapReAlloc(GetProcessHeap(),0,device->buffer, buflen); in DSOUND_PrimaryOpen()
225 DSOUND_RecalcPrimary(device); in DSOUND_PrimaryOpen()
226 if (device->pwave) in DSOUND_PrimaryOpen()
227 headers = HeapReAlloc(GetProcessHeap(),0,device->pwave, device->helfrags * sizeof(WAVEHDR)); in DSOUND_PrimaryOpen()
229 headers = HeapAlloc(GetProcessHeap(),0,device->helfrags * sizeof(WAVEHDR)); in DSOUND_PrimaryOpen()
234 DSOUND_RecalcPrimary(device); in DSOUND_PrimaryOpen()
238 device->buffer = newbuf; in DSOUND_PrimaryOpen()
239 device->pwave = headers; in DSOUND_PrimaryOpen()
242 for (c=0; c<device->helfrags; c++) { in DSOUND_PrimaryOpen()
243 device->pwave[c].lpData = (char*)device->buffer + c*device->fraglen; in DSOUND_PrimaryOpen()
244 device->pwave[c].dwBufferLength = device->fraglen; in DSOUND_PrimaryOpen()
245 device->pwave[c].dwUser = (DWORD_PTR)device; in DSOUND_PrimaryOpen()
246 device->pwave[c].dwFlags = 0; in DSOUND_PrimaryOpen()
247 device->pwave[c].dwLoops = 0; in DSOUND_PrimaryOpen()
248 err = mmErr(waveOutPrepareHeader(device->hwo,&device->pwave[c],sizeof(WAVEHDR))); in DSOUND_PrimaryOpen()
251 waveOutUnprepareHeader(device->hwo,&device->pwave[c],sizeof(WAVEHDR)); in DSOUND_PrimaryOpen()
256 overshot = device->buflen % device->fraglen; in DSOUND_PrimaryOpen()
260 overshot -= overshot % device->pwfx->nBlockAlign; in DSOUND_PrimaryOpen()
261 device->pwave[device->helfrags - 1].dwBufferLength += overshot; in DSOUND_PrimaryOpen()
264 TRACE("fraglen=%d, overshot=%d\n", device->fraglen, overshot); in DSOUND_PrimaryOpen()
266 device->mixfunction = mixfunctions[device->pwfx->wBitsPerSample/8 - 1]; in DSOUND_PrimaryOpen()
267 device->normfunction = normfunctions[device->pwfx->wBitsPerSample/8 - 1]; in DSOUND_PrimaryOpen()
268 FillMemory(device->buffer, device->buflen, (device->pwfx->wBitsPerSample == 8) ? 128 : 0); in DSOUND_PrimaryOpen()
269 FillMemory(device->mix_buffer, device->mix_buffer_len, 0); in DSOUND_PrimaryOpen()
270 device->pwplay = device->pwqueue = device->playpos = device->mixpos = 0; in DSOUND_PrimaryOpen()
275 static void DSOUND_PrimaryClose(DirectSoundDevice *device) in DSOUND_PrimaryClose() argument
277 TRACE("(%p)\n", device); in DSOUND_PrimaryClose()
280 if (!device->hwbuf) { in DSOUND_PrimaryClose()
284 LeaveCriticalSection(&(device->mixlock)); in DSOUND_PrimaryClose()
286 device->pwqueue = (DWORD)-1; /* resetting queues */ in DSOUND_PrimaryClose()
287 waveOutReset(device->hwo); in DSOUND_PrimaryClose()
288 for (c=0; c<device->helfrags; c++) in DSOUND_PrimaryClose()
289 waveOutUnprepareHeader(device->hwo, &device->pwave[c], sizeof(WAVEHDR)); in DSOUND_PrimaryClose()
291 EnterCriticalSection(&(device->mixlock)); in DSOUND_PrimaryClose()
294 device->pwqueue = 0; in DSOUND_PrimaryClose()
296 ULONG ref = IDsDriverBuffer_Release(device->hwbuf); in DSOUND_PrimaryClose()
298 device->hwbuf = 0; in DSOUND_PrimaryClose()
304 HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device) in DSOUND_PrimaryCreate() argument
307 TRACE("(%p)\n", device); in DSOUND_PrimaryCreate()
309 device->buflen = ds_hel_buflen; in DSOUND_PrimaryCreate()
310 err = DSOUND_PrimaryOpen(device); in DSOUND_PrimaryCreate()
317 device->state = STATE_STOPPED; in DSOUND_PrimaryCreate()
321 HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device) in DSOUND_PrimaryDestroy() argument
323 TRACE("(%p)\n", device); in DSOUND_PrimaryDestroy()
326 EnterCriticalSection(&(device->mixlock)); in DSOUND_PrimaryDestroy()
328 DSOUND_PrimaryClose(device); in DSOUND_PrimaryDestroy()
329 if (device->driver) { in DSOUND_PrimaryDestroy()
330 if (device->hwbuf) { in DSOUND_PrimaryDestroy()
331 if (IDsDriverBuffer_Release(device->hwbuf) == 0) in DSOUND_PrimaryDestroy()
332 device->hwbuf = 0; in DSOUND_PrimaryDestroy()
335 HeapFree(GetProcessHeap(),0,device->pwave); in DSOUND_PrimaryDestroy()
336 HeapFree(GetProcessHeap(),0,device->pwfx); in DSOUND_PrimaryDestroy()
337 device->pwfx=NULL; in DSOUND_PrimaryDestroy()
339 LeaveCriticalSection(&(device->mixlock)); in DSOUND_PrimaryDestroy()
345 HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) in DSOUND_PrimaryPlay() argument
348 TRACE("(%p)\n", device); in DSOUND_PrimaryPlay()
350 if (device->hwbuf) { in DSOUND_PrimaryPlay()
351 err = IDsDriverBuffer_Play(device->hwbuf, 0, 0, DSBPLAY_LOOPING); in DSOUND_PrimaryPlay()
355 err = mmErr(waveOutRestart(device->hwo)); in DSOUND_PrimaryPlay()
363 HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device) in DSOUND_PrimaryStop() argument
366 TRACE("(%p)\n", device); in DSOUND_PrimaryStop()
368 if (device->hwbuf) { in DSOUND_PrimaryStop()
369 err = IDsDriverBuffer_Stop(device->hwbuf); in DSOUND_PrimaryStop()
371 DSOUND_PrimaryClose(device); in DSOUND_PrimaryStop()
372 err = DSOUND_ReopenDevice(device, FALSE); in DSOUND_PrimaryStop()
377 err = DSOUND_PrimaryOpen(device); in DSOUND_PrimaryStop()
387 LeaveCriticalSection(&(device->mixlock)); in DSOUND_PrimaryStop()
390 err = mmErr(waveOutPause(device->hwo)); in DSOUND_PrimaryStop()
393 EnterCriticalSection(&(device->mixlock)); in DSOUND_PrimaryStop()
402 HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos) in DSOUND_PrimaryGetPosition() argument
404 TRACE("(%p,%p,%p)\n", device, playpos, writepos); in DSOUND_PrimaryGetPosition()
406 if (device->hwbuf) { in DSOUND_PrimaryGetPosition()
407 HRESULT err=IDsDriverBuffer_GetPosition(device->hwbuf,playpos,writepos); in DSOUND_PrimaryGetPosition()
413 TRACE("pwplay=%i, pwqueue=%i\n", device->pwplay, device->pwqueue); in DSOUND_PrimaryGetPosition()
418 *playpos = device->pwplay * device->fraglen; in DSOUND_PrimaryGetPosition()
423 *writepos = ((device->pwplay + device->pwqueue) % device->helfrags) * device->fraglen; in DSOUND_PrimaryGetPosition()
425 …ritepos = %d (%p, time=%d)\n", playpos?*playpos:-1, writepos?*writepos:-1, device, GetTickCount()); in DSOUND_PrimaryGetPosition()
460 HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex) in primarybuffer_SetFormat() argument
466 BOOL forced = device->priolevel == DSSCL_WRITEPRIMARY; in primarybuffer_SetFormat()
468 TRACE("(%p,%p)\n", device, wfex); in primarybuffer_SetFormat()
470 if (device->priolevel == DSSCL_NORMAL) { in primarybuffer_SetFormat()
487 RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE); in primarybuffer_SetFormat()
488 EnterCriticalSection(&(device->mixlock)); in primarybuffer_SetFormat()
490 nSamplesPerSec = device->pwfx->nSamplesPerSec; in primarybuffer_SetFormat()
491 bpp = device->pwfx->wBitsPerSample; in primarybuffer_SetFormat()
492 chans = device->pwfx->nChannels; in primarybuffer_SetFormat()
494 oldpwfx = device->pwfx; in primarybuffer_SetFormat()
495 device->pwfx = DSOUND_CopyFormat(wfex); in primarybuffer_SetFormat()
496 if (device->pwfx == NULL) { in primarybuffer_SetFormat()
497 device->pwfx = oldpwfx; in primarybuffer_SetFormat()
503 if (!(device->drvdesc.dwFlags & DSDDESC_DOMMSYSTEMSETFORMAT) && device->hwbuf) { in primarybuffer_SetFormat()
504 err = IDsDriverBuffer_SetFormat(device->hwbuf, device->pwfx); in primarybuffer_SetFormat()
507 …if (forced && (device->pwfx->nSamplesPerSec/100 != wfex->nSamplesPerSec/100 || err == DSERR_BADFOR… in primarybuffer_SetFormat()
512 CopyMemory(device->pwfx, wfex, cp_size); in primarybuffer_SetFormat()
519 CopyMemory(device->pwfx, oldpwfx, size); in primarybuffer_SetFormat()
532 …IDsDriverBuffer_Lock(device->hwbuf, (LPVOID *)&device->buffer, &device->buflen, NULL, NULL, 0, 0, … in primarybuffer_SetFormat()
533 IDsDriverBuffer_Unlock(device->hwbuf, device->buffer, 0, NULL, 0); in primarybuffer_SetFormat()
535 if (device->state == STATE_PLAYING) device->state = STATE_STARTING; in primarybuffer_SetFormat()
536 else if (device->state == STATE_STOPPING) device->state = STATE_STOPPED; in primarybuffer_SetFormat()
537 device->pwplay = device->pwqueue = device->playpos = device->mixpos = 0; in primarybuffer_SetFormat()
540 DSOUND_RecalcPrimary(device); in primarybuffer_SetFormat()
545 DSOUND_PrimaryClose(device); in primarybuffer_SetFormat()
547 err = DSOUND_ReopenDevice(device, FALSE); in primarybuffer_SetFormat()
553 err = DSOUND_PrimaryOpen(device); in primarybuffer_SetFormat()
559 if (wfex->nSamplesPerSec/100 != device->pwfx->nSamplesPerSec/100 && forced && device->buffer) in primarybuffer_SetFormat()
561 DSOUND_PrimaryClose(device); in primarybuffer_SetFormat()
562 device->pwfx->nSamplesPerSec = wfex->nSamplesPerSec; in primarybuffer_SetFormat()
563 err = DSOUND_ReopenDevice(device, TRUE); in primarybuffer_SetFormat()
566 else if (FAILED((err = DSOUND_PrimaryOpen(device)))) in primarybuffer_SetFormat()
571 device->mix_buffer_len = DSOUND_bufpos_to_mixpos(device, device->buflen); in primarybuffer_SetFormat()
572 device->mix_buffer = HeapReAlloc(GetProcessHeap(), 0, device->mix_buffer, device->mix_buffer_len); in primarybuffer_SetFormat()
573 FillMemory(device->mix_buffer, device->mix_buffer_len, 0); in primarybuffer_SetFormat()
574 device->mixfunction = mixfunctions[device->pwfx->wBitsPerSample/8 - 1]; in primarybuffer_SetFormat()
575 device->normfunction = normfunctions[device->pwfx->wBitsPerSample/8 - 1]; in primarybuffer_SetFormat()
577 …if (nSamplesPerSec != device->pwfx->nSamplesPerSec || bpp != device->pwfx->wBitsPerSample || chans… in primarybuffer_SetFormat()
578 IDirectSoundBufferImpl** dsb = device->buffers; in primarybuffer_SetFormat()
579 for (i = 0; i < device->nrofbuffers; i++, dsb++) { in primarybuffer_SetFormat()
583 (*dsb)->freqAdjust = ((DWORD64)(*dsb)->freq << DSOUND_FREQSHIFT) / device->pwfx->nSamplesPerSec; in primarybuffer_SetFormat()
594 LeaveCriticalSection(&(device->mixlock)); in primarybuffer_SetFormat()
595 RtlReleaseResource(&(device->buffer_list_lock)); in primarybuffer_SetFormat()
619 return primarybuffer_SetFormat(This->device, wfex); in PrimaryBufferImpl_SetFormat()
626 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_SetVolume() local
642 EnterCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_SetVolume()
644 waveOutGetVolume(device->hwo, &factors); in PrimaryBufferImpl_SetVolume()
645 device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff; in PrimaryBufferImpl_SetVolume()
646 device->volpan.dwTotalRightAmpFactor=ampfactors >> 16; in PrimaryBufferImpl_SetVolume()
647 DSOUND_AmpFactorToVolPan(&device->volpan); in PrimaryBufferImpl_SetVolume()
648 if (vol != device->volpan.lVolume) { in PrimaryBufferImpl_SetVolume()
649 device->volpan.lVolume=vol; in PrimaryBufferImpl_SetVolume()
650 DSOUND_RecalcVolPan(&device->volpan); in PrimaryBufferImpl_SetVolume()
651 if (device->hwbuf) { in PrimaryBufferImpl_SetVolume()
652 hres = IDsDriverBuffer_SetVolumePan(device->hwbuf, &device->volpan); in PrimaryBufferImpl_SetVolume()
656 …ampfactors = (device->volpan.dwTotalLeftAmpFactor & 0xffff) | (device->volpan.dwTotalRightAmpFacto… in PrimaryBufferImpl_SetVolume()
657 waveOutSetVolume(device->hwo, ampfactors); in PrimaryBufferImpl_SetVolume()
661 LeaveCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_SetVolume()
671 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_GetVolume() local
685 if (!device->hwbuf) in PrimaryBufferImpl_GetVolume()
687 waveOutGetVolume(device->hwo, &factors); in PrimaryBufferImpl_GetVolume()
688 device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff; in PrimaryBufferImpl_GetVolume()
689 device->volpan.dwTotalRightAmpFactor=ampfactors >> 16; in PrimaryBufferImpl_GetVolume()
690 DSOUND_AmpFactorToVolPan(&device->volpan); in PrimaryBufferImpl_GetVolume()
692 *vol = device->volpan.lVolume; in PrimaryBufferImpl_GetVolume()
711 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_Play() local
720 EnterCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_Play()
722 if (device->state == STATE_STOPPED) in PrimaryBufferImpl_Play()
723 device->state = STATE_STARTING; in PrimaryBufferImpl_Play()
724 else if (device->state == STATE_STOPPING) in PrimaryBufferImpl_Play()
725 device->state = STATE_PLAYING; in PrimaryBufferImpl_Play()
727 LeaveCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_Play()
736 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_Stop() local
740 EnterCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_Stop()
742 if (device->state == STATE_PLAYING) in PrimaryBufferImpl_Stop()
743 device->state = STATE_STOPPING; in PrimaryBufferImpl_Stop()
744 else if (device->state == STATE_STARTING) in PrimaryBufferImpl_Stop()
745 device->state = STATE_STOPPED; in PrimaryBufferImpl_Stop()
747 LeaveCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_Stop()
765 This->device->primary = NULL; in primarybuffer_destroy()
786 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_GetCurrentPosition() local
790 EnterCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_GetCurrentPosition()
792 hres = DSOUND_PrimaryGetPosition(device, playpos, writepos); in PrimaryBufferImpl_GetCurrentPosition()
795 LeaveCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_GetCurrentPosition()
799 if (device->state != STATE_STOPPED) in PrimaryBufferImpl_GetCurrentPosition()
801 *writepos += device->writelead; in PrimaryBufferImpl_GetCurrentPosition()
802 while (*writepos >= device->buflen) *writepos -= device->buflen; in PrimaryBufferImpl_GetCurrentPosition()
805 LeaveCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_GetCurrentPosition()
808 … writepos = %d (%p, time=%d)\n", playpos?*playpos:0, writepos?*writepos:0, device, GetTickCount()); in PrimaryBufferImpl_GetCurrentPosition()
816 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_GetStatus() local
825 if ((device->state == STATE_STARTING) || in PrimaryBufferImpl_GetStatus()
826 (device->state == STATE_PLAYING)) in PrimaryBufferImpl_GetStatus()
842 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_GetFormat() local
845 size = sizeof(WAVEFORMATEX) + device->pwfx->cbSize; in PrimaryBufferImpl_GetFormat()
849 CopyMemory(lpwf,device->pwfx,size); in PrimaryBufferImpl_GetFormat()
860 *wfwritten = sizeof(WAVEFORMATEX) + device->pwfx->cbSize; in PrimaryBufferImpl_GetFormat()
875 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_Lock() local
891 if (device->priolevel != DSSCL_WRITEPRIMARY) { in PrimaryBufferImpl_Lock()
908 writebytes = device->buflen; in PrimaryBufferImpl_Lock()
910 if (writecursor >= device->buflen) { in PrimaryBufferImpl_Lock()
912 writecursor, device->buflen); in PrimaryBufferImpl_Lock()
916 if (writebytes > device->buflen) { in PrimaryBufferImpl_Lock()
918 writebytes, device->buflen); in PrimaryBufferImpl_Lock()
922 if (!(device->drvdesc.dwFlags & DSDDESC_DONTNEEDPRIMARYLOCK) && device->hwbuf) { in PrimaryBufferImpl_Lock()
923 hres = IDsDriverBuffer_Lock(device->hwbuf, in PrimaryBufferImpl_Lock()
933 if (writecursor+writebytes <= device->buflen) { in PrimaryBufferImpl_Lock()
934 *(LPBYTE*)lplpaudioptr1 = device->buffer+writecursor; in PrimaryBufferImpl_Lock()
942 *(LPBYTE*)lplpaudioptr1 = device->buffer+writecursor; in PrimaryBufferImpl_Lock()
943 *audiobytes1 = device->buflen-writecursor; in PrimaryBufferImpl_Lock()
945 *(LPBYTE*)lplpaudioptr2 = device->buffer; in PrimaryBufferImpl_Lock()
947 *audiobytes2 = writebytes-(device->buflen-writecursor); in PrimaryBufferImpl_Lock()
969 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_SetPan() local
985 EnterCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_SetPan()
987 if (!device->hwbuf) in PrimaryBufferImpl_SetPan()
989 waveOutGetVolume(device->hwo, &factors); in PrimaryBufferImpl_SetPan()
990 device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff; in PrimaryBufferImpl_SetPan()
991 device->volpan.dwTotalRightAmpFactor=ampfactors >> 16; in PrimaryBufferImpl_SetPan()
992 DSOUND_AmpFactorToVolPan(&device->volpan); in PrimaryBufferImpl_SetPan()
994 if (pan != device->volpan.lPan) { in PrimaryBufferImpl_SetPan()
995 device->volpan.lPan=pan; in PrimaryBufferImpl_SetPan()
996 DSOUND_RecalcVolPan(&device->volpan); in PrimaryBufferImpl_SetPan()
997 if (device->hwbuf) { in PrimaryBufferImpl_SetPan()
998 hres = IDsDriverBuffer_SetVolumePan(device->hwbuf, &device->volpan); in PrimaryBufferImpl_SetPan()
1002 …ampfactors = (device->volpan.dwTotalLeftAmpFactor & 0xffff) | (device->volpan.dwTotalRightAmpFacto… in PrimaryBufferImpl_SetPan()
1003 waveOutSetVolume(device->hwo, ampfactors); in PrimaryBufferImpl_SetPan()
1007 LeaveCriticalSection(&(device->mixlock)); in PrimaryBufferImpl_SetPan()
1017 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_GetPan() local
1031 if (!device->hwbuf) in PrimaryBufferImpl_GetPan()
1033 waveOutGetVolume(device->hwo, &factors); in PrimaryBufferImpl_GetPan()
1034 device->volpan.dwTotalLeftAmpFactor=ampfactors & 0xffff; in PrimaryBufferImpl_GetPan()
1035 device->volpan.dwTotalRightAmpFactor=ampfactors >> 16; in PrimaryBufferImpl_GetPan()
1036 DSOUND_AmpFactorToVolPan(&device->volpan); in PrimaryBufferImpl_GetPan()
1038 *pan = device->volpan.lPan; in PrimaryBufferImpl_GetPan()
1046 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_Unlock() local
1049 if (device->priolevel != DSSCL_WRITEPRIMARY) { in PrimaryBufferImpl_Unlock()
1054 if (!(device->drvdesc.dwFlags & DSDDESC_DONTNEEDPRIMARYLOCK) && device->hwbuf) { in PrimaryBufferImpl_Unlock()
1057 if ((char *)p1 - (char *)device->buffer + x1 > device->buflen) in PrimaryBufferImpl_Unlock()
1060 hres = IDsDriverBuffer_Unlock(device->hwbuf, p1, x1, p2, x2); in PrimaryBufferImpl_Unlock()
1083 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_GetFrequency() local
1096 *freq = device->pwfx->nSamplesPerSec; in PrimaryBufferImpl_GetFrequency()
1114 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_GetCaps() local
1128 caps->dwBufferBytes = device->buflen; in PrimaryBufferImpl_GetCaps()
1141 DirectSoundDevice *device = This->device; in PrimaryBufferImpl_QueryInterface() local
1177 if (!device->listener) in PrimaryBufferImpl_QueryInterface()
1178 IDirectSound3DListenerImpl_Create(device, &device->listener); in PrimaryBufferImpl_QueryInterface()
1179 if (device->listener) { in PrimaryBufferImpl_QueryInterface()
1180 *ppobj = device->listener; in PrimaryBufferImpl_QueryInterface()
1223 HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb, in primarybuffer_create() argument
1227 TRACE("%p,%p,%p)\n",device,ppdsb,dsbd); in primarybuffer_create()
1245 dsb->device = device; in primarybuffer_create()
1252 device->pwfx->wFormatTag, device->pwfx->nChannels, in primarybuffer_create()
1253 device->pwfx->nSamplesPerSec, device->pwfx->nAvgBytesPerSec, in primarybuffer_create()
1254 device->pwfx->nBlockAlign, device->pwfx->wBitsPerSample, in primarybuffer_create()
1255 device->pwfx->cbSize); in primarybuffer_create()