oldFreq = This->freq;
This->freq = freq;
if (freq != oldFreq) {
- This->freqAdjust = (freq << DSOUND_FREQSHIFT) / This->dsound->device->pwfx->nSamplesPerSec;
+ This->freqAdjust = (freq << DSOUND_FREQSHIFT) / This->device->pwfx->nSamplesPerSec;
This->nAvgBytesPerSec = freq * This->pwfx->nBlockAlign;
DSOUND_RecalcFormat(This);
if (!This->hwbuf)
TRACE("(%p) ref was %ld\n", This, ref + 1);
if (!ref) {
- DSOUND_RemoveBuffer(This->dsound, This);
+ DSOUND_RemoveBuffer(This->device, This);
This->lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&(This->lock));
if (This->hwbuf) {
IDsDriverBuffer_Release(This->hwbuf);
- if (This->dsound->device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) {
+ if (This->device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) {
This->buffer->ref--;
if (This->buffer->ref==0) {
HeapFree(GetProcessHeap(),0,This->buffer->memory);
{
DWORD bplay = This->buf_mixpos;
DWORD pmix = This->primary_mixpos;
+ DirectSoundDevice * device = This->device;
TRACE("(%p, pplay=%lu, pwrite=%lu)\n", This, pplay, pwrite);
/* the actual primary play position (pplay) is always behind last mixed (pmix),
* unless the computer is too slow or something */
/* we need to know how far away we are from there */
- if (pmix < pplay) pmix += This->dsound->device->buflen; /* wraparound */
+ if (pmix < pplay) pmix += device->buflen; /* wraparound */
pmix -= pplay;
/* detect buffer underrun */
- if (pwrite < pplay) pwrite += This->dsound->device->buflen; /* wraparound */
+ if (pwrite < pplay) pwrite += device->buflen; /* wraparound */
pwrite -= pplay;
- if (pmix > (ds_snd_queue_max * This->dsound->device->fraglen + pwrite + This->dsound->device->writelead)) {
+ if (pmix > (ds_snd_queue_max * device->fraglen + pwrite + device->writelead)) {
WARN("detected an underrun: primary queue was %ld\n",pmix);
pmix = 0;
}
/* divide the offset by its sample size */
- pmix /= This->dsound->device->pwfx->nBlockAlign;
+ pmix /= device->pwfx->nBlockAlign;
TRACE("primary back-samples=%ld\n",pmix);
/* adjust for our frequency */
pmix = (pmix * This->freqAdjust) >> DSOUND_FREQSHIFT;
} else if (playpos) {
DWORD pplay, pwrite;
/* let's get this exact; first, recursively call GetPosition on the primary */
- EnterCriticalSection(&(This->dsound->device->mixlock));
- if (DSOUND_PrimaryGetPosition(This->dsound->device, &pplay, &pwrite) != DS_OK)
+ EnterCriticalSection(&(This->device->mixlock));
+ if (DSOUND_PrimaryGetPosition(This->device, &pplay, &pwrite) != DS_OK)
WARN("DSOUND_PrimaryGetPosition failed\n");
/* detect HEL mode underrun */
- if (!(This->dsound->device->hwbuf || This->dsound->device->pwqueue))
+ if (!(This->device->hwbuf || This->device->pwqueue))
TRACE("detected an underrun\n");
- if ((This->dsbd.dwFlags & DSBCAPS_GETCURRENTPOSITION2) || This->dsound->device->hwbuf) {
+ if ((This->dsbd.dwFlags & DSBCAPS_GETCURRENTPOSITION2) || This->device->hwbuf) {
/* calculate play position using this */
*playpos = DSOUND_CalcPlayPosition(This, pplay, pwrite);
} else {
* behind write cursor, hmm... */
/* let's just do what might work for Half-Life */
DWORD wp;
- wp = (This->dsound->device->pwplay + ds_hel_margin) * This->dsound->device->fraglen;
- wp %= This->dsound->device->buflen;
+ wp = (This->device->pwplay + ds_hel_margin) * This->device->fraglen;
+ wp %= This->device->buflen;
*playpos = DSOUND_CalcPlayPosition(This, wp, pwrite);
}
- LeaveCriticalSection(&(This->dsound->device->mixlock));
+ LeaveCriticalSection(&(This->device->mixlock));
}
if (writepos)
*writepos = This->buf_mixpos;
else
This->probably_valid_to = writecursor;
- if (!(This->dsound->device->drvdesc.dwFlags & DSDDESC_DONTNEEDSECONDARYLOCK) && This->hwbuf) {
+ if (!(This->device->drvdesc.dwFlags & DSDDESC_DONTNEEDSECONDARYLOCK) && This->hwbuf) {
hres = IDsDriverBuffer_Lock(This->hwbuf,
lplpaudioptr1, audiobytes1,
lplpaudioptr2, audiobytes2,
/* **** */
EnterCriticalSection(&(This->lock));
- if (!(This->dsound->device->drvdesc.dwFlags & DSDDESC_DONTNEEDSECONDARYLOCK) && This->hwbuf) {
+ if (!(This->device->drvdesc.dwFlags & DSDDESC_DONTNEEDSECONDARYLOCK) && This->hwbuf) {
hres = IDsDriverBuffer_Unlock(This->hwbuf, p1, x1, p2, x2);
if (hres != DS_OK)
WARN("IDsDriverBuffer_Unlock failed\n");
};
HRESULT IDirectSoundBufferImpl_Create(
- IDirectSoundImpl *ds,
+ DirectSoundDevice * device,
IDirectSoundBufferImpl **pdsb,
LPCDSBUFFERDESC dsbd)
{
HRESULT err = DS_OK;
DWORD capf = 0;
int use_hw, alloc_size, cp_size;
- TRACE("(%p,%p,%p)\n",ds,pdsb,dsbd);
+ TRACE("(%p,%p,%p)\n",device,pdsb,dsbd);
if (dsbd->dwBufferBytes < DSBSIZE_MIN || dsbd->dwBufferBytes > DSBSIZE_MAX) {
WARN("invalid parameter: dsbd->dwBufferBytes = %ld\n", dsbd->dwBufferBytes);
dsb->ref = 0;
dsb->secondary = 0;
- dsb->dsound = ds;
+ dsb->device = device;
dsb->lpVtbl = &dsbvt;
dsb->iks = NULL;
if (wfex->wBitsPerSample==16) capf |= DSCAPS_SECONDARY16BIT;
else capf |= DSCAPS_SECONDARY8BIT;
- use_hw = (ds->device->drvcaps.dwFlags & capf) == capf;
- TRACE("use_hw = 0x%08x, capf = 0x%08lx, ds->drvcaps.dwFlags = 0x%08lx\n", use_hw, capf, ds->device->drvcaps.dwFlags);
+ use_hw = (device->drvcaps.dwFlags & capf) == capf;
+ TRACE("use_hw = 0x%08x, capf = 0x%08lx, device->drvcaps.dwFlags = 0x%08lx\n", use_hw, capf, device->drvcaps.dwFlags);
/* FIXME: check hardware sample rate mixing capabilities */
/* FIXME: check app hints for software/hardware buffer (STATIC, LOCHARDWARE, etc) */
}
/* Allocate system memory for buffer if applicable */
- if ((ds->device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) || !use_hw) {
+ if ((device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) || !use_hw) {
dsb->buffer->memory = HeapAlloc(GetProcessHeap(),0,dsb->buflen);
if (dsb->buffer->memory == NULL) {
WARN("out of memory\n");
/* Allocate the hardware buffer */
if (use_hw) {
- err = IDsDriver_CreateSoundBuffer(ds->device->driver,wfex,dsbd->dwFlags,0,
+ err = IDsDriver_CreateSoundBuffer(device->driver,wfex,dsbd->dwFlags,0,
&(dsb->buflen),&(dsb->buffer->memory),
(LPVOID*)&(dsb->hwbuf));
/* fall back to software buffer on failure */
if (err != DS_OK) {
TRACE("IDsDriver_CreateSoundBuffer failed, falling back to software buffer\n");
use_hw = 0;
- if (ds->device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) {
+ if (device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) {
dsb->buffer->memory = HeapAlloc(GetProcessHeap(),0,dsb->buflen);
if (dsb->buffer->memory == NULL) {
WARN("out of memory\n");
dsb->state = STATE_STOPPED;
dsb->freqAdjust = (dsb->freq << DSOUND_FREQSHIFT) /
- ds->device->pwfx->nSamplesPerSec;
+ device->pwfx->nSamplesPerSec;
dsb->nAvgBytesPerSec = dsb->freq *
dsbd->lpwfxFormat->nBlockAlign;
/* register buffer if not primary */
if (!(dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER)) {
- err = DSOUND_AddBuffer(ds, dsb);
+ err = DSOUND_AddBuffer(device, dsb);
if (err != DS_OK) {
HeapFree(GetProcessHeap(),0,dsb->buffer->memory);
HeapFree(GetProcessHeap(),0,dsb->buffer);
static ULONG WINAPI SecondaryBufferImpl_Release(LPDIRECTSOUNDBUFFER8 iface)
{
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
- ULONG ref = InterlockedDecrement(&(This->ref));
- TRACE("(%p) ref was %ld\n", This, ref + 1);
+ ULONG ref;
+ TRACE("(%p)\n", This);
+ ref = InterlockedDecrement(&(This->ref));
+ TRACE("ref was %ld\n", ref + 1);
if (!ref) {
This->dsb->secondary = NULL;
TRACE("(%p) ref was %ld\n", This, ref + 1);
if (!ref) {
- if (This->device) {
- if (DirectSoundDevice_Release(This->device) != 0) {
- /* device not released so make sure primary reference to This removed */
- if (This->device->primary)
- This->device->primary->dsound = NULL;
- }
- }
+ if (This->device)
+ DirectSoundDevice_Release(This->device);
HeapFree(GetProcessHeap(),0,This);
TRACE("(%p) released\n", This);
}
WARN("Primary Buffer already created\n");
IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER8)(This->device->primary));
*ppdsb = (LPDIRECTSOUNDBUFFER)(This->device->primary);
- This->device->primary->dsound = This;
} else {
This->device->dsbd = *dsbd;
- hres = PrimaryBufferImpl_Create(This, (PrimaryBufferImpl**)&(This->device->primary), &(This->device->dsbd));
+ hres = PrimaryBufferImpl_Create(This->device, (PrimaryBufferImpl**)&(This->device->primary), &(This->device->dsbd));
if (This->device->primary) {
IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER8)(This->device->primary));
*ppdsb = (LPDIRECTSOUNDBUFFER)(This->device->primary);
return DSERR_INVALIDPARAM;
}
- hres = IDirectSoundBufferImpl_Create(This, (IDirectSoundBufferImpl**)&dsb, dsbd);
+ hres = IDirectSoundBufferImpl_Create(This->device, (IDirectSoundBufferImpl**)&dsb, dsbd);
if (dsb) {
hres = SecondaryBufferImpl_Create(dsb, (SecondaryBufferImpl**)ppdsb);
if (*ppdsb) {
return DSERR_INVALIDPARAM;
}
- /* FIXME: hack to make sure we have a secondary buffer */
- if ((IDirectSoundImpl *)((SecondaryBufferImpl *)psb)->dsb == This) {
+ /* make sure we have a secondary buffer */
+ if ((PrimaryBufferImpl *)psb == This->device->primary) {
WARN("trying to duplicate primary buffer\n");
*ppdsb = NULL;
return DSERR_INVALIDCALL;
dsb->state = STATE_STOPPED;
dsb->playpos = 0;
dsb->buf_mixpos = 0;
- dsb->dsound = This;
+ dsb->device = This->device;
dsb->ds3db = NULL;
dsb->iks = NULL; /* FIXME? */
dsb->secondary = NULL;
dsb->lock.DebugInfo->Spare[0] = (DWORD_PTR)"DSOUNDBUFFER_lock";
/* register buffer */
- hres = DSOUND_AddBuffer(This, dsb);
+ hres = DSOUND_AddBuffer(This->device, dsb);
if (hres != DS_OK) {
IDirectSoundBuffer8_Release(psb);
dsb->lock.DebugInfo->Spare[0] = 0;
* Gets exclusive access to buffer for writing.
*/
HRESULT DSOUND_AddBuffer(
- IDirectSoundImpl * pDS,
+ DirectSoundDevice * device,
IDirectSoundBufferImpl * pDSB)
{
IDirectSoundBufferImpl **newbuffers;
HRESULT hr = DS_OK;
- TRACE("(%p, %p)\n", pDS, pDSB);
+ TRACE("(%p, %p)\n", device, pDSB);
- RtlAcquireResourceExclusive(&(pDS->device->buffer_list_lock), TRUE);
+ RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
- if (pDS->device->buffers)
- newbuffers = HeapReAlloc(GetProcessHeap(),0,pDS->device->buffers,sizeof(IDirectSoundBufferImpl*)*(pDS->device->nrofbuffers+1));
+ if (device->buffers)
+ newbuffers = HeapReAlloc(GetProcessHeap(),0,device->buffers,sizeof(IDirectSoundBufferImpl*)*(device->nrofbuffers+1));
else
- newbuffers = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectSoundBufferImpl*)*(pDS->device->nrofbuffers+1));
+ newbuffers = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectSoundBufferImpl*)*(device->nrofbuffers+1));
if (newbuffers) {
- pDS->device->buffers = newbuffers;
- pDS->device->buffers[pDS->device->nrofbuffers] = pDSB;
- pDS->device->nrofbuffers++;
- TRACE("buffer count is now %d\n", pDS->device->nrofbuffers);
+ device->buffers = newbuffers;
+ device->buffers[device->nrofbuffers] = pDSB;
+ device->nrofbuffers++;
+ TRACE("buffer count is now %d\n", device->nrofbuffers);
} else {
- ERR("out of memory for buffer list! Current buffer count is %d\n", pDS->device->nrofbuffers);
+ ERR("out of memory for buffer list! Current buffer count is %d\n", device->nrofbuffers);
hr = DSERR_OUTOFMEMORY;
}
- RtlReleaseResource(&(pDS->device->buffer_list_lock));
+ RtlReleaseResource(&(device->buffer_list_lock));
return hr;
}
* Gets exclusive access to buffer for writing.
*/
HRESULT DSOUND_RemoveBuffer(
- IDirectSoundImpl * pDS,
+ DirectSoundDevice * device,
IDirectSoundBufferImpl * pDSB)
{
int i;
HRESULT hr = DS_OK;
- TRACE("(%p, %p)\n", pDS, pDSB);
+ TRACE("(%p, %p)\n", device, pDSB);
- RtlAcquireResourceExclusive(&(pDS->device->buffer_list_lock), TRUE);
+ RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
- for (i = 0; i < pDS->device->nrofbuffers; i++)
- if (pDS->device->buffers[i] == pDSB)
+ for (i = 0; i < device->nrofbuffers; i++)
+ if (device->buffers[i] == pDSB)
break;
- if (i < pDS->device->nrofbuffers) {
+ if (i < device->nrofbuffers) {
/* Put the last buffer of the list in the (now empty) position */
- pDS->device->buffers[i] = pDS->device->buffers[pDS->device->nrofbuffers - 1];
- pDS->device->nrofbuffers--;
- pDS->device->buffers = HeapReAlloc(GetProcessHeap(),0,pDS->device->buffers,sizeof(LPDIRECTSOUNDBUFFER8)*pDS->device->nrofbuffers);
- TRACE("buffer count is now %d\n", pDS->device->nrofbuffers);
+ device->buffers[i] = device->buffers[device->nrofbuffers - 1];
+ device->nrofbuffers--;
+ device->buffers = HeapReAlloc(GetProcessHeap(),0,device->buffers,sizeof(LPDIRECTSOUNDBUFFER8)*device->nrofbuffers);
+ TRACE("buffer count is now %d\n", device->nrofbuffers);
}
- if (pDS->device->nrofbuffers == 0) {
- HeapFree(GetProcessHeap(),0,pDS->device->buffers);
- pDS->device->buffers = NULL;
+ if (device->nrofbuffers == 0) {
+ HeapFree(GetProcessHeap(),0,device->buffers);
+ device->buffers = NULL;
}
- RtlReleaseResource(&(pDS->device->buffer_list_lock));
+ RtlReleaseResource(&(device->buffer_list_lock));
return hr;
}
LONG ref;
/* IDirectSoundBufferImpl fields */
SecondaryBufferImpl* secondary;
- IDirectSoundImpl* dsound;
+ DirectSoundDevice* device;
CRITICAL_SECTION lock;
PIDSDRIVERBUFFER hwbuf;
PWAVEFORMATEX pwfx;
};
HRESULT IDirectSoundBufferImpl_Create(
- IDirectSoundImpl *ds,
- IDirectSoundBufferImpl **pdsb,
+ DirectSoundDevice *device,
+ IDirectSoundBufferImpl **ppdsb,
LPCDSBUFFERDESC dsbd);
HRESULT IDirectSoundBufferImpl_Destroy(
IDirectSoundBufferImpl *pdsb);
{
const IDirectSoundBuffer8Vtbl *lpVtbl;
LONG ref;
- IDirectSoundImpl* dsound;
+ DirectSoundDevice* device;
};
HRESULT PrimaryBufferImpl_Create(
- IDirectSoundImpl *ds,
- PrimaryBufferImpl **pdsb,
+ DirectSoundDevice * device,
+ PrimaryBufferImpl **ppdsb,
LPCDSBUFFERDESC dsbd);
/*****************************************************************************
const IDirectSound3DListenerVtbl *lpVtbl;
LONG ref;
/* IDirectSound3DListenerImpl fields */
- IDirectSoundImpl* dsound;
+ DirectSoundDevice* device;
};
HRESULT IDirectSound3DListenerImpl_Create(
- PrimaryBufferImpl *pb,
+ DirectSoundDevice *device,
IDirectSound3DListenerImpl **pdsl);
/*****************************************************************************
/* dsound.c */
-HRESULT DSOUND_AddBuffer(IDirectSoundImpl * pDS, IDirectSoundBufferImpl * pDSB);
-HRESULT DSOUND_RemoveBuffer(IDirectSoundImpl * pDS, IDirectSoundBufferImpl * pDSB);
+HRESULT DSOUND_AddBuffer(DirectSoundDevice *device, IDirectSoundBufferImpl * pDSB);
+HRESULT DSOUND_RemoveBuffer(DirectSoundDevice *device, IDirectSoundBufferImpl * pDSB);
/* primary.c */
static inline void cp_fields(const IDirectSoundBufferImpl *dsb, BYTE *ibuf, BYTE *obuf )
{
- DirectSoundDevice * device = dsb->dsound->device;
+ DirectSoundDevice * device = dsb->device;
INT fl,fr;
if (dsb->pwfx->wBitsPerSample == 8) {
INT i, size, ipos, ilen;
BYTE *ibp, *obp;
INT iAdvance = dsb->pwfx->nBlockAlign;
- INT oAdvance = dsb->dsound->device->pwfx->nBlockAlign;
+ INT oAdvance = dsb->device->pwfx->nBlockAlign;
ibp = dsb->buffer->memory + dsb->buf_mixpos;
obp = buf;
TRACE("(%p, %p, %p), buf_mixpos=%ld\n", dsb, ibp, obp, dsb->buf_mixpos);
/* Check for the best case */
- if ((dsb->freq == dsb->dsound->device->pwfx->nSamplesPerSec) &&
- (dsb->pwfx->wBitsPerSample == dsb->dsound->device->pwfx->wBitsPerSample) &&
- (dsb->pwfx->nChannels == dsb->dsound->device->pwfx->nChannels)) {
+ if ((dsb->freq == dsb->device->pwfx->nSamplesPerSec) &&
+ (dsb->pwfx->wBitsPerSample == dsb->device->pwfx->wBitsPerSample) &&
+ (dsb->pwfx->nChannels == dsb->device->pwfx->nChannels)) {
INT bytesleft = dsb->buflen - dsb->buf_mixpos;
TRACE("(%p) Best case\n", dsb);
if (len <= bytesleft )
}
/* Check for same sample rate */
- if (dsb->freq == dsb->dsound->device->pwfx->nSamplesPerSec) {
+ if (dsb->freq == dsb->device->pwfx->nSamplesPerSec) {
TRACE("(%p) Same sample rate %ld = primary %ld\n", dsb,
- dsb->freq, dsb->dsound->device->pwfx->nSamplesPerSec);
+ dsb->freq, dsb->device->pwfx->nSamplesPerSec);
ilen = 0;
for (i = 0; i < len; i += oAdvance) {
cp_fields(dsb, ibp, obp );
* TransGaming Technologies Inc. */
/* FIXME("(%p) Adjusting frequency: %ld -> %ld (need optimization)\n",
- dsb, dsb->freq, dsb->dsound->device->pwfx->nSamplesPerSec); */
+ dsb, dsb->freq, dsb->device->pwfx->nSamplesPerSec); */
size = len / oAdvance;
ilen = 0;
/* with a mono primary buffer, it could sound very weird using */
/* this method. Oh well, tough patooties. */
- switch (dsb->dsound->device->pwfx->wBitsPerSample) {
+ switch (dsb->device->pwfx->wBitsPerSample) {
case 8:
/* 8-bit WAV is unsigned, but we need to operate */
/* on signed data for this to work properly */
- switch (dsb->dsound->device->pwfx->nChannels) {
+ switch (dsb->device->pwfx->nChannels) {
case 1:
for (i = 0; i < len; i++) {
INT val = *bpc - 128;
}
break;
default:
- FIXME("doesn't support %d channels\n", dsb->dsound->device->pwfx->nChannels);
+ FIXME("doesn't support %d channels\n", dsb->device->pwfx->nChannels);
break;
}
break;
case 16:
/* 16-bit WAV is signed -- much better */
- switch (dsb->dsound->device->pwfx->nChannels) {
+ switch (dsb->device->pwfx->nChannels) {
case 1:
for (i = 0; i < len; i += 2) {
*bps = (*bps * dsb->cvolpan.dwTotalLeftAmpFactor) >> 16;
}
break;
default:
- FIXME("doesn't support %d channels\n", dsb->dsound->device->pwfx->nChannels);
+ FIXME("doesn't support %d channels\n", dsb->device->pwfx->nChannels);
break;
}
break;
default:
- FIXME("doesn't support %d bit samples\n", dsb->dsound->device->pwfx->wBitsPerSample);
+ FIXME("doesn't support %d bit samples\n", dsb->device->pwfx->wBitsPerSample);
break;
}
}
len = fraglen;
if (!(dsb->playflags & DSBPLAY_LOOPING)) {
int secondary_remainder = dsb->buflen - dsb->buf_mixpos;
- int adjusted_remainder = MulDiv(dsb->dsound->device->pwfx->nAvgBytesPerSec, secondary_remainder, dsb->nAvgBytesPerSec);
+ int adjusted_remainder = MulDiv(dsb->device->pwfx->nAvgBytesPerSec, secondary_remainder, dsb->nAvgBytesPerSec);
assert(adjusted_remainder >= 0);
TRACE("secondary_remainder = %d, adjusted_remainder = %d, len = %d\n", secondary_remainder, adjusted_remainder, len);
if (adjusted_remainder < len) {
return 0;
}
- if (len % dsb->dsound->device->pwfx->nBlockAlign) {
- INT nBlockAlign = dsb->dsound->device->pwfx->nBlockAlign;
+ if (len % dsb->device->pwfx->nBlockAlign) {
+ INT nBlockAlign = dsb->device->pwfx->nBlockAlign;
ERR("length not a multiple of block size, len = %d, block size = %d\n", len, nBlockAlign);
len = (len / nBlockAlign) * nBlockAlign; /* data alignment */
}
- if ((buf = ibuf = DSOUND_tmpbuffer(dsb->dsound->device, len)) == NULL)
+ if ((buf = ibuf = DSOUND_tmpbuffer(dsb->device, len)) == NULL)
return 0;
TRACE("MixInBuffer (%p) len = %d, dest = %ld\n", dsb, len, writepos);
(dsb->dsbd.dwFlags & DSBCAPS_CTRL3D))
DSOUND_MixerVol(dsb, ibuf, len);
- if (dsb->dsound->device->pwfx->wBitsPerSample == 8) {
- BYTE *obuf = dsb->dsound->device->buffer + writepos;
+ if (dsb->device->pwfx->wBitsPerSample == 8) {
+ BYTE *obuf = dsb->device->buffer + writepos;
- if ((writepos + len) <= dsb->dsound->device->buflen)
+ if ((writepos + len) <= dsb->device->buflen)
todo = len;
else
- todo = dsb->dsound->device->buflen - writepos;
+ todo = dsb->device->buflen - writepos;
for (i = 0; i < todo; i++) {
/* 8-bit WAV is unsigned */
if (todo < len) {
todo = len - todo;
- obuf = dsb->dsound->device->buffer;
+ obuf = dsb->device->buffer;
for (i = 0; i < todo; i++) {
/* 8-bit WAV is unsigned */
INT16 *ibufs, *obufs;
ibufs = (INT16 *) ibuf;
- obufs = (INT16 *)(dsb->dsound->device->buffer + writepos);
+ obufs = (INT16 *)(dsb->device->buffer + writepos);
- if ((writepos + len) <= dsb->dsound->device->buflen)
+ if ((writepos + len) <= dsb->device->buflen)
todo = len / 2;
else
- todo = (dsb->dsound->device->buflen - writepos) / 2;
+ todo = (dsb->device->buflen - writepos) / 2;
for (i = 0; i < todo; i++) {
/* 16-bit WAV is signed */
if (todo < (len / 2)) {
todo = (len / 2) - todo;
- obufs = (INT16 *)dsb->dsound->device->buffer;
+ obufs = (INT16 *)dsb->device->buffer;
for (i = 0; i < todo; i++) {
/* 16-bit WAV is signed */
TRACE("(%p,%ld,%ld)\n",dsb,writepos,len);
- if (len % dsb->dsound->device->pwfx->nBlockAlign) {
- INT nBlockAlign = dsb->dsound->device->pwfx->nBlockAlign;
+ if (len % dsb->device->pwfx->nBlockAlign) {
+ INT nBlockAlign = dsb->device->pwfx->nBlockAlign;
ERR("length not a multiple of block size, len = %ld, block size = %d\n", len, nBlockAlign);
len = (len / nBlockAlign) * nBlockAlign; /* data alignment */
}
- if ((buf = ibuf = DSOUND_tmpbuffer(dsb->dsound->device, len)) == NULL)
+ if ((buf = ibuf = DSOUND_tmpbuffer(dsb->device, len)) == NULL)
return;
TRACE("PhaseCancel (%p) len = %ld, dest = %ld\n", dsb, len, writepos);
DSOUND_MixerVol(dsb, ibuf, len);
/* subtract instead of add, to phase out premixed data */
- if (dsb->dsound->device->pwfx->wBitsPerSample == 8) {
- BYTE *obuf = dsb->dsound->device->buffer + writepos;
+ if (dsb->device->pwfx->wBitsPerSample == 8) {
+ BYTE *obuf = dsb->device->buffer + writepos;
- if ((writepos + len) <= dsb->dsound->device->buflen)
+ if ((writepos + len) <= dsb->device->buflen)
todo = len;
else
- todo = dsb->dsound->device->buflen - writepos;
+ todo = dsb->device->buflen - writepos;
for (i = 0; i < todo; i++) {
/* 8-bit WAV is unsigned */
if (todo < len) {
todo = len - todo;
- obuf = dsb->dsound->device->buffer;
+ obuf = dsb->device->buffer;
for (i = 0; i < todo; i++) {
/* 8-bit WAV is unsigned */
INT16 *ibufs, *obufs;
ibufs = (INT16 *) ibuf;
- obufs = (INT16 *)(dsb->dsound->device->buffer + writepos);
+ obufs = (INT16 *)(dsb->device->buffer + writepos);
- if ((writepos + len) <= dsb->dsound->device->buflen)
+ if ((writepos + len) <= dsb->device->buflen)
todo = len / 2;
else
- todo = (dsb->dsound->device->buflen - writepos) / 2;
+ todo = (dsb->device->buflen - writepos) / 2;
for (i = 0; i < todo; i++) {
/* 16-bit WAV is signed */
if (todo < (len / 2)) {
todo = (len / 2) - todo;
- obufs = (INT16 *)dsb->dsound->device->buffer;
+ obufs = (INT16 *)dsb->device->buffer;
for (i = 0; i < todo; i++) {
/* 16-bit WAV is signed */
{
DWORD size, flen, len, npos, nlen;
INT iAdvance = dsb->pwfx->nBlockAlign;
- INT oAdvance = dsb->dsound->device->pwfx->nBlockAlign;
+ INT oAdvance = dsb->device->pwfx->nBlockAlign;
/* determine amount of premixed data to cancel */
DWORD primary_done =
- ((dsb->primary_mixpos < writepos) ? dsb->dsound->device->buflen : 0) +
+ ((dsb->primary_mixpos < writepos) ? dsb->device->buflen : 0) +
dsb->primary_mixpos - writepos;
TRACE("(%p, %ld), buf_mixpos=%ld\n", dsb, writepos, dsb->buf_mixpos);
flen = dsb->freqAcc;
nlen = len / dsb->pwfx->nBlockAlign;
nlen = ((nlen << DSOUND_FREQSHIFT) + flen) / dsb->freqAdjust;
- nlen *= dsb->dsound->device->pwfx->nBlockAlign;
+ nlen *= dsb->device->pwfx->nBlockAlign;
writepos =
- ((dsb->primary_mixpos < nlen) ? dsb->dsound->device->buflen : 0) +
+ ((dsb->primary_mixpos < nlen) ? dsb->device->buflen : 0) +
dsb->primary_mixpos - nlen;
}
#if 0
DWORD i, size, flen, len, npos, nlen;
INT iAdvance = dsb->pwfx->nBlockAlign;
- INT oAdvance = dsb->dsound->device->pwfx->nBlockAlign;
+ INT oAdvance = dsb->device->pwfx->nBlockAlign;
/* determine amount of premixed data to cancel */
DWORD buf_done =
((dsb->buf_mixpos < buf_writepos) ? dsb->buflen : 0) +
WARN("(%p, %ld), buf_mixpos=%ld\n", dsb, buf_writepos, dsb->buf_mixpos);
/* since this is not implemented yet, just cancel *ALL* prebuffering for now
* (which is faster anyway when there's only a single secondary buffer) */
- dsb->dsound->device->need_remix = TRUE;
+ dsb->device->need_remix = TRUE;
}
void DSOUND_ForceRemix(IDirectSoundBufferImpl *dsb)
TRACE("(%p)\n",dsb);
EnterCriticalSection(&dsb->lock);
if (dsb->state == STATE_PLAYING)
- dsb->dsound->device->need_remix = TRUE;
+ dsb->device->need_remix = TRUE;
LeaveCriticalSection(&dsb->lock);
}
((dsb->buf_mixpos < buf_writepos) ? dsb->buflen : 0) +
dsb->buf_mixpos - buf_writepos;
DWORD primary_done =
- ((dsb->primary_mixpos < writepos) ? dsb->dsound->device->buflen : 0) +
+ ((dsb->primary_mixpos < writepos) ? dsb->device->buflen : 0) +
dsb->primary_mixpos - writepos;
DWORD adv_done =
- ((dsb->dsound->device->mixpos < writepos) ? dsb->dsound->device->buflen : 0) +
- dsb->dsound->device->mixpos - writepos;
+ ((dsb->device->mixpos < writepos) ? dsb->device->buflen : 0) +
+ dsb->device->mixpos - writepos;
DWORD played =
((buf_writepos < dsb->playpos) ? dsb->buflen : 0) +
buf_writepos - dsb->playpos;
probably_valid_left = MulDiv(probably_valid_left,
1 << DSOUND_FREQSHIFT,
dsb->pwfx->nBlockAlign * dsb->freqAdjust) *
- dsb->dsound->device->pwfx->nBlockAlign;
+ dsb->device->pwfx->nBlockAlign;
/* check whether to clip mix_len */
if (probably_valid_left < mixlen) {
TRACE("clipping to probably_valid_left=%ld\n", probably_valid_left);
len = mixlen - primary_done;
TRACE("remaining mixlen=%ld\n", len);
- if (len < dsb->dsound->device->fraglen) {
+ if (len < dsb->device->fraglen) {
/* smaller than a fragment, wait until it gets larger
* before we take the mixing overhead */
TRACE("mixlen not worth it, deferring mixing\n");
/* ok, we know how much to mix, let's go */
still_behind = (adv_done > primary_done);
while (len) {
- slen = dsb->dsound->device->buflen - dsb->primary_mixpos;
+ slen = dsb->device->buflen - dsb->primary_mixpos;
if (slen > len) slen = len;
slen = DSOUND_MixInBuffer(dsb, dsb->primary_mixpos, slen);
- if ((dsb->primary_mixpos < dsb->dsound->device->mixpos) &&
- (dsb->primary_mixpos + slen >= dsb->dsound->device->mixpos))
+ if ((dsb->primary_mixpos < dsb->device->mixpos) &&
+ (dsb->primary_mixpos + slen >= dsb->device->mixpos))
still_behind = FALSE;
dsb->primary_mixpos += slen; len -= slen;
- dsb->primary_mixpos %= dsb->dsound->device->buflen;
+ dsb->primary_mixpos %= dsb->device->buflen;
if ((dsb->state == STATE_STOPPED) || !slen) break;
}
- TRACE("new primary_mixpos=%ld, primary_advbase=%ld\n", dsb->primary_mixpos, dsb->dsound->device->mixpos);
+ TRACE("new primary_mixpos=%ld, primary_advbase=%ld\n", dsb->primary_mixpos, dsb->device->mixpos);
TRACE("mixed data len=%ld, still_behind=%d\n", mixlen-len, still_behind);
post_mix:
* advance its underrun detector...*/
if (still_behind) return 0;
if ((mixlen - len) < primary_done) return 0;
- slen = ((dsb->primary_mixpos < dsb->dsound->device->mixpos) ?
- dsb->dsound->device->buflen : 0) + dsb->primary_mixpos -
- dsb->dsound->device->mixpos;
+ slen = ((dsb->primary_mixpos < dsb->device->mixpos) ?
+ dsb->device->buflen : 0) + dsb->primary_mixpos -
+ dsb->device->mixpos;
if (slen > mixlen) {
/* the primary_done and still_behind checks above should have worked */
FIXME("problem with advancement calculation (advlen=%ld > mixlen=%ld)\n", slen, mixlen);
static HRESULT WINAPI PrimaryBufferImpl_SetFormat(
LPDIRECTSOUNDBUFFER8 iface,LPCWAVEFORMATEX wfex
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
HRESULT err = DS_OK;
int i, alloc_size, cp_size;
DWORD nSamplesPerSec;
static HRESULT WINAPI PrimaryBufferImpl_SetVolume(
LPDIRECTSOUNDBUFFER8 iface,LONG vol
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
DWORD ampfactors;
DSVOLUMEPAN volpan;
HRESULT hres = DS_OK;
static HRESULT WINAPI PrimaryBufferImpl_GetVolume(
LPDIRECTSOUNDBUFFER8 iface,LPLONG vol
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
DWORD ampfactors;
DSVOLUMEPAN volpan;
TRACE("(%p,%p)\n", iface, vol);
static HRESULT WINAPI PrimaryBufferImpl_Play(
LPDIRECTSOUNDBUFFER8 iface,DWORD reserved1,DWORD reserved2,DWORD flags
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
TRACE("(%p,%08lx,%08lx,%08lx)\n", iface, reserved1, reserved2, flags);
if (!(flags & DSBPLAY_LOOPING)) {
static HRESULT WINAPI PrimaryBufferImpl_Stop(LPDIRECTSOUNDBUFFER8 iface)
{
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
TRACE("(%p)\n", iface);
/* **** */
TRACE("(%p) ref was %ld\n", This, ref + 1);
if (!ref) {
- This->dsound->device->primary = NULL;
+ This->device->primary = NULL;
HeapFree(GetProcessHeap(), 0, This);
TRACE("(%p) released\n", This);
}
LPDIRECTSOUNDBUFFER8 iface,LPDWORD playpos,LPDWORD writepos
) {
HRESULT hres;
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
TRACE("(%p,%p,%p)\n", iface, playpos, writepos);
hres = DSOUND_PrimaryGetPosition(device, playpos, writepos);
static HRESULT WINAPI PrimaryBufferImpl_GetStatus(
LPDIRECTSOUNDBUFFER8 iface,LPDWORD status
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
TRACE("(%p,%p)\n", iface, status);
if (status == NULL) {
LPDWORD wfwritten)
{
DWORD size;
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
TRACE("(%p,%p,%ld,%p)\n", iface, lpwf, wfsize, wfwritten);
size = sizeof(WAVEFORMATEX) + device->pwfx->cbSize;
static HRESULT WINAPI PrimaryBufferImpl_Lock(
LPDIRECTSOUNDBUFFER8 iface,DWORD writecursor,DWORD writebytes,LPVOID lplpaudioptr1,LPDWORD audiobytes1,LPVOID lplpaudioptr2,LPDWORD audiobytes2,DWORD flags
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
TRACE("(%p,%ld,%ld,%p,%p,%p,%p,0x%08lx) at %ld\n",
iface,
writecursor,
static HRESULT WINAPI PrimaryBufferImpl_SetPan(
LPDIRECTSOUNDBUFFER8 iface,LONG pan
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
DWORD ampfactors;
DSVOLUMEPAN volpan;
HRESULT hres = DS_OK;
static HRESULT WINAPI PrimaryBufferImpl_GetPan(
LPDIRECTSOUNDBUFFER8 iface,LPLONG pan
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
DWORD ampfactors;
DSVOLUMEPAN volpan;
TRACE("(%p,%p)\n", iface, pan);
static HRESULT WINAPI PrimaryBufferImpl_Unlock(
LPDIRECTSOUNDBUFFER8 iface,LPVOID p1,DWORD x1,LPVOID p2,DWORD x2
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
TRACE("(%p,%p,%ld,%p,%ld)\n", iface, p1, x1, p2, x2);
if (device->priolevel != DSSCL_WRITEPRIMARY) {
static HRESULT WINAPI PrimaryBufferImpl_GetFrequency(
LPDIRECTSOUNDBUFFER8 iface,LPDWORD freq
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
TRACE("(%p,%p)\n", iface, freq);
if (freq == NULL) {
static HRESULT WINAPI PrimaryBufferImpl_GetCaps(
LPDIRECTSOUNDBUFFER8 iface,LPDSBCAPS caps
) {
- DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
+ DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
TRACE("(%p,%p)\n", iface, caps);
if (caps == NULL) {
LPDIRECTSOUNDBUFFER8 iface,REFIID riid,LPVOID *ppobj
) {
PrimaryBufferImpl *This = (PrimaryBufferImpl *)iface;
- DirectSoundDevice *device = This->dsound->device;
+ DirectSoundDevice *device = This->device;
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(riid), ppobj);
if (ppobj == NULL) {
if ( IsEqualGUID( &IID_IDirectSound3DListener, riid ) ) {
if (!device->listener)
- IDirectSound3DListenerImpl_Create(This, &device->listener);
+ IDirectSound3DListenerImpl_Create(device, &device->listener);
if (device->listener) {
*ppobj = device->listener;
IDirectSound3DListener_AddRef((LPDIRECTSOUND3DLISTENER)*ppobj);
};
HRESULT PrimaryBufferImpl_Create(
- IDirectSoundImpl *ds,
- PrimaryBufferImpl **pdsb,
+ DirectSoundDevice * device,
+ PrimaryBufferImpl ** ppdsb,
LPCDSBUFFERDESC dsbd)
{
PrimaryBufferImpl *dsb;
- TRACE("%p,%p,%p)\n",ds,pdsb,dsbd);
+ TRACE("%p,%p,%p)\n",device,ppdsb,dsbd);
if (dsbd->lpwfxFormat) {
WARN("invalid parameter: dsbd->lpwfxFormat != NULL\n");
- *pdsb = NULL;
+ *ppdsb = NULL;
return DSERR_INVALIDPARAM;
}
if (dsb == NULL) {
WARN("out of memory\n");
- *pdsb = NULL;
+ *ppdsb = NULL;
return DSERR_OUTOFMEMORY;
}
dsb->ref = 0;
- dsb->dsound = ds;
+ dsb->device = device;
dsb->lpVtbl = &dspbvt;
- CopyMemory(&ds->device->dsbd, dsbd, sizeof(*dsbd));
+ CopyMemory(&device->dsbd, dsbd, sizeof(*dsbd));
TRACE("Created primary buffer at %p\n", dsb);
TRACE("(formattag=0x%04x,chans=%d,samplerate=%ld,"
"bytespersec=%ld,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
- ds->device->pwfx->wFormatTag, ds->device->pwfx->nChannels, ds->device->pwfx->nSamplesPerSec,
- ds->device->pwfx->nAvgBytesPerSec, ds->device->pwfx->nBlockAlign,
- ds->device->pwfx->wBitsPerSample, ds->device->pwfx->cbSize);
+ device->pwfx->wFormatTag, device->pwfx->nChannels,
+ device->pwfx->nSamplesPerSec, device->pwfx->nAvgBytesPerSec,
+ device->pwfx->nBlockAlign, device->pwfx->wBitsPerSample,
+ device->pwfx->cbSize);
- *pdsb = dsb;
+ *ppdsb = dsb;
return S_OK;
}
S(prop).Set = *guidPropSet;
S(prop).Id = dwPropID;
S(prop).Flags = 0; /* unused */
- S(prop).InstanceId = (ULONG)This->dsb->dsound;
+ S(prop).InstanceId = (ULONG)This->dsb->device;
hres = IDsDriverPropertySet_Get(ps, &prop, pInstanceData, cbInstanceData, pPropData, cbPropData, pcbReturned);
S(prop).Set = *guidPropSet;
S(prop).Id = dwPropID;
S(prop).Flags = 0; /* unused */
- S(prop).InstanceId = (ULONG)This->dsb->dsound;
+ S(prop).InstanceId = (ULONG)This->dsb->device;
hres = IDsDriverPropertySet_Set(ps,&prop,pInstanceData,cbInstanceData,pPropData,cbPropData);
IDsDriverPropertySet_Release(ps);
case DS3DMODE_NORMAL:
TRACE("Normal 3D processing mode\n");
/* we need to calculate distance between buffer and listener*/
- vDistance = VectorBetweenTwoPoints(&dsb->ds3db_ds3db.vPosition, &dsb->dsound->device->ds3dl.vPosition);
+ vDistance = VectorBetweenTwoPoints(&dsb->ds3db_ds3db.vPosition, &dsb->device->ds3dl.vPosition);
flDistance = VectorMagnitude (&vDistance);
break;
case DS3DMODE_HEADRELATIVE:
dsb->volpan.lVolume = lVolume;
/* panning */
- if (dsb->dsound->device->ds3dl.vPosition.x == dsb->ds3db_ds3db.vPosition.x &&
- dsb->dsound->device->ds3dl.vPosition.y == dsb->ds3db_ds3db.vPosition.y &&
- dsb->dsound->device->ds3dl.vPosition.z == dsb->ds3db_ds3db.vPosition.z) {
+ if (dsb->device->ds3dl.vPosition.x == dsb->ds3db_ds3db.vPosition.x &&
+ dsb->device->ds3dl.vPosition.y == dsb->ds3db_ds3db.vPosition.y &&
+ dsb->device->ds3dl.vPosition.z == dsb->ds3db_ds3db.vPosition.z) {
dsb->volpan.lPan = 0;
flAngle = 0.0;
}
else
{
- vDistance = VectorBetweenTwoPoints(&dsb->dsound->device->ds3dl.vPosition, &dsb->ds3db_ds3db.vPosition);
- vLeft = VectorProduct(&dsb->dsound->device->ds3dl.vOrientFront, &dsb->dsound->device->ds3dl.vOrientTop);
+ vDistance = VectorBetweenTwoPoints(&dsb->device->ds3dl.vPosition, &dsb->ds3db_ds3db.vPosition);
+ vLeft = VectorProduct(&dsb->device->ds3dl.vOrientFront, &dsb->device->ds3dl.vOrientTop);
flAngle = AngleBetweenVectorsRad(&vLeft, &vDistance);
/* for now, we'll use "linear formula" (which is probably incorrect); if someone has it in book, correct it */
dsb->volpan.lPan = 10000*2*flAngle/M_PI - 10000;
/* FIXME: Doppler Effect disabled since i have no idea which frequency to change and how to do it */
#if 0
/* doppler shift*/
- if ((VectorMagnitude(&ds3db.vVelocity) == 0) && (VectorMagnitude(&dsb->dsound->device->ds3dl.vVelocity) == 0))
+ if ((VectorMagnitude(&ds3db.vVelocity) == 0) && (VectorMagnitude(&dsb->device->ds3dl.vVelocity) == 0))
{
TRACE("doppler: Buffer and Listener don't have velocities\n");
}
/* calculate length of ds3dl.vVelocity component which causes Doppler Effect
NOTE: if listener moves TOWARDS the buffer, it's velocity component is POSITIVE
if listener moves AWAY from buffer, it's velocity component is NEGATIVE */
- flListenerVel = ProjectVector(&dsb->dsound->device->ds3dl.vVelocity, &vDistance);
+ flListenerVel = ProjectVector(&dsb->device->ds3dl.vVelocity, &vDistance);
/* formula taken from Gianicoli D.: Physics, 4th edition: */
/* FIXME: replace dsb->freq with appropriate frequency ! */
flFreq = dsb->freq * ((DEFAULT_VELOCITY + flListenerVel)/(DEFAULT_VELOCITY + flBufferVel));
{
int i;
TRACE("(%p)\n",ds3dl);
- for (i = 0; i < ds3dl->dsound->device->nrofbuffers; i++)
+ for (i = 0; i < ds3dl->device->nrofbuffers; i++)
{
/* some buffers don't have 3d buffer (Ultima IX seems to
crash without the following line) */
- if (ds3dl->dsound->device->buffers[i]->ds3db == NULL)
+ if (ds3dl->device->buffers[i]->ds3db == NULL)
continue;
- if (ds3dl->dsound->device->buffers[i]->ds3db_need_recalc)
+ if (ds3dl->device->buffers[i]->ds3db_need_recalc)
{
- DSOUND_Mix3DBuffer(ds3dl->dsound->device->buffers[i]);
+ DSOUND_Mix3DBuffer(ds3dl->device->buffers[i]);
}
}
}
}
if ( IsEqualGUID(riid, &IID_IDirectSoundBuffer) ) {
- if (!This->dsound->device->primary)
- PrimaryBufferImpl_Create(This->dsound, &(This->dsound->device->primary), &(This->dsound->device->dsbd));
- if (This->dsound->device->primary) {
- *ppobj = This->dsound->device->primary;
+ if (!This->device->primary)
+ PrimaryBufferImpl_Create(This->device, &(This->device->primary), &(This->device->dsbd));
+ if (This->device->primary) {
+ *ppobj = This->device->primary;
IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER)*ppobj);
return S_OK;
}
TRACE("(%p) ref was %ld\n", This, ref + 1);
if (!ref) {
- This->dsound->device->listener = 0;
+ This->device->listener = 0;
HeapFree(GetProcessHeap(), 0, This);
TRACE("(%p) released\n", This);
}
}
TRACE("returning: all parameters\n");
- *lpDS3DL = This->dsound->device->ds3dl;
+ *lpDS3DL = This->device->ds3dl;
return DS_OK;
}
LPD3DVALUE lpfDistanceFactor)
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
- TRACE("returning: Distance Factor = %f\n", This->dsound->device->ds3dl.flDistanceFactor);
- *lpfDistanceFactor = This->dsound->device->ds3dl.flDistanceFactor;
+ TRACE("returning: Distance Factor = %f\n", This->device->ds3dl.flDistanceFactor);
+ *lpfDistanceFactor = This->device->ds3dl.flDistanceFactor;
return DS_OK;
}
LPD3DVALUE lpfDopplerFactor)
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
- TRACE("returning: Doppler Factor = %f\n", This->dsound->device->ds3dl.flDopplerFactor);
- *lpfDopplerFactor = This->dsound->device->ds3dl.flDopplerFactor;
+ TRACE("returning: Doppler Factor = %f\n", This->device->ds3dl.flDopplerFactor);
+ *lpfDopplerFactor = This->device->ds3dl.flDopplerFactor;
return DS_OK;
}
LPD3DVECTOR lpvOrientTop)
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
- TRACE("returning: OrientFront vector = (%f,%f,%f); OrientTop vector = (%f,%f,%f)\n", This->dsound->device->ds3dl.vOrientFront.x, \
- This->dsound->device->ds3dl.vOrientFront.y, This->dsound->device->ds3dl.vOrientFront.z, This->dsound->device->ds3dl.vOrientTop.x, This->dsound->device->ds3dl.vOrientTop.y, \
- This->dsound->device->ds3dl.vOrientTop.z);
- *lpvOrientFront = This->dsound->device->ds3dl.vOrientFront;
- *lpvOrientTop = This->dsound->device->ds3dl.vOrientTop;
+ TRACE("returning: OrientFront vector = (%f,%f,%f); OrientTop vector = (%f,%f,%f)\n", This->device->ds3dl.vOrientFront.x, \
+ This->device->ds3dl.vOrientFront.y, This->device->ds3dl.vOrientFront.z, This->device->ds3dl.vOrientTop.x, This->device->ds3dl.vOrientTop.y, \
+ This->device->ds3dl.vOrientTop.z);
+ *lpvOrientFront = This->device->ds3dl.vOrientFront;
+ *lpvOrientTop = This->device->ds3dl.vOrientTop;
return DS_OK;
}
LPD3DVECTOR lpvPosition)
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
- TRACE("returning: Position vector = (%f,%f,%f)\n", This->dsound->device->ds3dl.vPosition.x, This->dsound->device->ds3dl.vPosition.y, This->dsound->device->ds3dl.vPosition.z);
- *lpvPosition = This->dsound->device->ds3dl.vPosition;
+ TRACE("returning: Position vector = (%f,%f,%f)\n", This->device->ds3dl.vPosition.x, This->device->ds3dl.vPosition.y, This->device->ds3dl.vPosition.z);
+ *lpvPosition = This->device->ds3dl.vPosition;
return DS_OK;
}
LPD3DVALUE lpfRolloffFactor)
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
- TRACE("returning: RolloffFactor = %f\n", This->dsound->device->ds3dl.flRolloffFactor);
- *lpfRolloffFactor = This->dsound->device->ds3dl.flRolloffFactor;
+ TRACE("returning: RolloffFactor = %f\n", This->device->ds3dl.flRolloffFactor);
+ *lpfRolloffFactor = This->device->ds3dl.flRolloffFactor;
return DS_OK;
}
LPD3DVECTOR lpvVelocity)
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
- TRACE("returning: Velocity vector = (%f,%f,%f)\n", This->dsound->device->ds3dl.vVelocity.x, This->dsound->device->ds3dl.vVelocity.y, This->dsound->device->ds3dl.vVelocity.z);
- *lpvVelocity = This->dsound->device->ds3dl.vVelocity;
+ TRACE("returning: Velocity vector = (%f,%f,%f)\n", This->device->ds3dl.vVelocity.x, This->device->ds3dl.vVelocity.y, This->device->ds3dl.vVelocity.z);
+ *lpvVelocity = This->device->ds3dl.vVelocity;
return DS_OK;
}
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
TRACE("setting: all parameters; dwApply = %ld\n", dwApply);
- This->dsound->device->ds3dl = *lpcDS3DL;
+ This->device->ds3dl = *lpcDS3DL;
if (dwApply == DS3D_IMMEDIATE)
{
- This->dsound->device->ds3dl_need_recalc = FALSE;
+ This->device->ds3dl_need_recalc = FALSE;
DSOUND_ChangeListener(This);
}
- This->dsound->device->ds3dl_need_recalc = TRUE;
+ This->device->ds3dl_need_recalc = TRUE;
return DS_OK;
}
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
TRACE("setting: Distance Factor = %f; dwApply = %ld\n", fDistanceFactor, dwApply);
- This->dsound->device->ds3dl.flDistanceFactor = fDistanceFactor;
+ This->device->ds3dl.flDistanceFactor = fDistanceFactor;
if (dwApply == DS3D_IMMEDIATE)
{
- This->dsound->device->ds3dl_need_recalc = FALSE;
+ This->device->ds3dl_need_recalc = FALSE;
DSOUND_ChangeListener(This);
}
- This->dsound->device->ds3dl_need_recalc = TRUE;
+ This->device->ds3dl_need_recalc = TRUE;
return DS_OK;
}
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
TRACE("setting: Doppler Factor = %f; dwApply = %ld\n", fDopplerFactor, dwApply);
- This->dsound->device->ds3dl.flDopplerFactor = fDopplerFactor;
+ This->device->ds3dl.flDopplerFactor = fDopplerFactor;
if (dwApply == DS3D_IMMEDIATE)
{
- This->dsound->device->ds3dl_need_recalc = FALSE;
+ This->device->ds3dl_need_recalc = FALSE;
DSOUND_ChangeListener(This);
}
- This->dsound->device->ds3dl_need_recalc = TRUE;
+ This->device->ds3dl_need_recalc = TRUE;
return DS_OK;
}
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %ld\n", \
xFront, yFront, zFront, xTop, yTop, zTop, dwApply);
- This->dsound->device->ds3dl.vOrientFront.x = xFront;
- This->dsound->device->ds3dl.vOrientFront.y = yFront;
- This->dsound->device->ds3dl.vOrientFront.z = zFront;
- This->dsound->device->ds3dl.vOrientTop.x = xTop;
- This->dsound->device->ds3dl.vOrientTop.y = yTop;
- This->dsound->device->ds3dl.vOrientTop.z = zTop;
+ This->device->ds3dl.vOrientFront.x = xFront;
+ This->device->ds3dl.vOrientFront.y = yFront;
+ This->device->ds3dl.vOrientFront.z = zFront;
+ This->device->ds3dl.vOrientTop.x = xTop;
+ This->device->ds3dl.vOrientTop.y = yTop;
+ This->device->ds3dl.vOrientTop.z = zTop;
if (dwApply == DS3D_IMMEDIATE)
{
- This->dsound->device->ds3dl_need_recalc = FALSE;
+ This->device->ds3dl_need_recalc = FALSE;
DSOUND_ChangeListener(This);
}
- This->dsound->device->ds3dl_need_recalc = TRUE;
+ This->device->ds3dl_need_recalc = TRUE;
return DS_OK;
}
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
- This->dsound->device->ds3dl.vPosition.x = x;
- This->dsound->device->ds3dl.vPosition.y = y;
- This->dsound->device->ds3dl.vPosition.z = z;
+ This->device->ds3dl.vPosition.x = x;
+ This->device->ds3dl.vPosition.y = y;
+ This->device->ds3dl.vPosition.z = z;
if (dwApply == DS3D_IMMEDIATE)
{
- This->dsound->device->ds3dl_need_recalc = FALSE;
+ This->device->ds3dl_need_recalc = FALSE;
DSOUND_ChangeListener(This);
}
- This->dsound->device->ds3dl_need_recalc = TRUE;
+ This->device->ds3dl_need_recalc = TRUE;
return DS_OK;
}
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
TRACE("setting: Rolloff Factor = %f; dwApply = %ld\n", fRolloffFactor, dwApply);
- This->dsound->device->ds3dl.flRolloffFactor = fRolloffFactor;
+ This->device->ds3dl.flRolloffFactor = fRolloffFactor;
if (dwApply == DS3D_IMMEDIATE)
{
- This->dsound->device->ds3dl_need_recalc = FALSE;
+ This->device->ds3dl_need_recalc = FALSE;
DSOUND_ChangeListener(This);
}
- This->dsound->device->ds3dl_need_recalc = TRUE;
+ This->device->ds3dl_need_recalc = TRUE;
return DS_OK;
}
{
IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
- This->dsound->device->ds3dl.vVelocity.x = x;
- This->dsound->device->ds3dl.vVelocity.y = y;
- This->dsound->device->ds3dl.vVelocity.z = z;
+ This->device->ds3dl.vVelocity.x = x;
+ This->device->ds3dl.vVelocity.y = y;
+ This->device->ds3dl.vVelocity.z = z;
if (dwApply == DS3D_IMMEDIATE)
{
- This->dsound->device->ds3dl_need_recalc = FALSE;
+ This->device->ds3dl_need_recalc = FALSE;
DSOUND_ChangeListener(This);
}
- This->dsound->device->ds3dl_need_recalc = TRUE;
+ This->device->ds3dl_need_recalc = TRUE;
return DS_OK;
}
};
HRESULT IDirectSound3DListenerImpl_Create(
- PrimaryBufferImpl *This,
- IDirectSound3DListenerImpl **pdsl)
+ DirectSoundDevice * device,
+ IDirectSound3DListenerImpl ** ppdsl)
{
- IDirectSound3DListenerImpl *dsl;
- TRACE("(%p,%p)\n",This,pdsl);
+ IDirectSound3DListenerImpl *pdsl;
+ TRACE("(%p,%p)\n",device,ppdsl);
- dsl = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*dsl));
+ pdsl = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*pdsl));
- if (dsl == NULL) {
+ if (pdsl == NULL) {
WARN("out of memory\n");
- *pdsl = 0;
+ *ppdsl = 0;
return DSERR_OUTOFMEMORY;
}
- dsl->ref = 0;
- dsl->lpVtbl = &ds3dlvt;
-
- dsl->dsound = This->dsound;
-
- dsl->dsound->device->ds3dl.dwSize = sizeof(DS3DLISTENER);
- dsl->dsound->device->ds3dl.vPosition.x = 0.0;
- dsl->dsound->device->ds3dl.vPosition.y = 0.0;
- dsl->dsound->device->ds3dl.vPosition.z = 0.0;
- dsl->dsound->device->ds3dl.vVelocity.x = 0.0;
- dsl->dsound->device->ds3dl.vVelocity.y = 0.0;
- dsl->dsound->device->ds3dl.vVelocity.z = 0.0;
- dsl->dsound->device->ds3dl.vOrientFront.x = 0.0;
- dsl->dsound->device->ds3dl.vOrientFront.y = 0.0;
- dsl->dsound->device->ds3dl.vOrientFront.z = 1.0;
- dsl->dsound->device->ds3dl.vOrientTop.x = 0.0;
- dsl->dsound->device->ds3dl.vOrientTop.y = 1.0;
- dsl->dsound->device->ds3dl.vOrientTop.z = 0.0;
- dsl->dsound->device->ds3dl.flDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;
- dsl->dsound->device->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;
- dsl->dsound->device->ds3dl.flDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;
-
- dsl->dsound->device->ds3dl_need_recalc = TRUE;
-
- *pdsl = dsl;
+ pdsl->ref = 0;
+ pdsl->lpVtbl = &ds3dlvt;
+
+ pdsl->device = device;
+
+ pdsl->device->ds3dl.dwSize = sizeof(DS3DLISTENER);
+ pdsl->device->ds3dl.vPosition.x = 0.0;
+ pdsl->device->ds3dl.vPosition.y = 0.0;
+ pdsl->device->ds3dl.vPosition.z = 0.0;
+ pdsl->device->ds3dl.vVelocity.x = 0.0;
+ pdsl->device->ds3dl.vVelocity.y = 0.0;
+ pdsl->device->ds3dl.vVelocity.z = 0.0;
+ pdsl->device->ds3dl.vOrientFront.x = 0.0;
+ pdsl->device->ds3dl.vOrientFront.y = 0.0;
+ pdsl->device->ds3dl.vOrientFront.z = 1.0;
+ pdsl->device->ds3dl.vOrientTop.x = 0.0;
+ pdsl->device->ds3dl.vOrientTop.y = 1.0;
+ pdsl->device->ds3dl.vOrientTop.z = 0.0;
+ pdsl->device->ds3dl.flDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;
+ pdsl->device->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;
+ pdsl->device->ds3dl.flDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;
+
+ pdsl->device->ds3dl_need_recalc = TRUE;
+
+ *ppdsl = pdsl;
return S_OK;
}