dsound: Refactor playback.
Replace references of IDirectSoundImpl with DirectSoundDevice to remove one level of indirection and remove the problem of a three object circular reference.
This commit is contained in:
parent
ead00327e9
commit
e49a5c22fb
|
@ -277,7 +277,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_SetFrequency(
|
|||
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)
|
||||
|
@ -364,14 +364,14 @@ static ULONG WINAPI IDirectSoundBufferImpl_Release(LPDIRECTSOUNDBUFFER8 iface)
|
|||
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);
|
||||
|
@ -399,22 +399,23 @@ DWORD DSOUND_CalcPlayPosition(IDirectSoundBufferImpl *This, DWORD pplay, DWORD p
|
|||
{
|
||||
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;
|
||||
|
@ -452,13 +453,13 @@ static HRESULT WINAPI IDirectSoundBufferImpl_GetCurrentPosition(
|
|||
} 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 {
|
||||
|
@ -468,11 +469,11 @@ static HRESULT WINAPI IDirectSoundBufferImpl_GetCurrentPosition(
|
|||
* 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;
|
||||
|
@ -595,7 +596,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Lock(
|
|||
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,
|
||||
|
@ -748,7 +749,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Unlock(
|
|||
/* **** */
|
||||
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");
|
||||
|
@ -984,7 +985,7 @@ static const IDirectSoundBuffer8Vtbl dsbvt =
|
|||
};
|
||||
|
||||
HRESULT IDirectSoundBufferImpl_Create(
|
||||
IDirectSoundImpl *ds,
|
||||
DirectSoundDevice * device,
|
||||
IDirectSoundBufferImpl **pdsb,
|
||||
LPCDSBUFFERDESC dsbd)
|
||||
{
|
||||
|
@ -993,7 +994,7 @@ HRESULT IDirectSoundBufferImpl_Create(
|
|||
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);
|
||||
|
@ -1013,7 +1014,7 @@ HRESULT IDirectSoundBufferImpl_Create(
|
|||
|
||||
dsb->ref = 0;
|
||||
dsb->secondary = 0;
|
||||
dsb->dsound = ds;
|
||||
dsb->device = device;
|
||||
dsb->lpVtbl = &dsbvt;
|
||||
dsb->iks = NULL;
|
||||
|
||||
|
@ -1056,8 +1057,8 @@ HRESULT IDirectSoundBufferImpl_Create(
|
|||
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) */
|
||||
|
@ -1075,7 +1076,7 @@ HRESULT IDirectSoundBufferImpl_Create(
|
|||
}
|
||||
|
||||
/* 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");
|
||||
|
@ -1091,14 +1092,14 @@ HRESULT IDirectSoundBufferImpl_Create(
|
|||
|
||||
/* 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");
|
||||
|
@ -1125,7 +1126,7 @@ HRESULT IDirectSoundBufferImpl_Create(
|
|||
dsb->state = STATE_STOPPED;
|
||||
|
||||
dsb->freqAdjust = (dsb->freq << DSOUND_FREQSHIFT) /
|
||||
ds->device->pwfx->nSamplesPerSec;
|
||||
device->pwfx->nSamplesPerSec;
|
||||
dsb->nAvgBytesPerSec = dsb->freq *
|
||||
dsbd->lpwfxFormat->nBlockAlign;
|
||||
|
||||
|
@ -1157,7 +1158,7 @@ HRESULT IDirectSoundBufferImpl_Create(
|
|||
|
||||
/* 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);
|
||||
|
@ -1235,8 +1236,10 @@ static ULONG WINAPI SecondaryBufferImpl_AddRef(LPDIRECTSOUNDBUFFER8 iface)
|
|||
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;
|
||||
|
|
|
@ -248,13 +248,8 @@ static ULONG WINAPI IDirectSoundImpl_Release(
|
|||
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);
|
||||
}
|
||||
|
@ -330,10 +325,9 @@ static HRESULT WINAPI DSOUND_CreateSoundBuffer(
|
|||
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);
|
||||
|
@ -362,7 +356,7 @@ static HRESULT WINAPI DSOUND_CreateSoundBuffer(
|
|||
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) {
|
||||
|
@ -474,8 +468,8 @@ static HRESULT WINAPI IDirectSoundImpl_DuplicateSoundBuffer(
|
|||
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;
|
||||
|
@ -532,7 +526,7 @@ static HRESULT WINAPI IDirectSoundImpl_DuplicateSoundBuffer(
|
|||
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;
|
||||
|
@ -555,7 +549,7 @@ static HRESULT WINAPI IDirectSoundImpl_DuplicateSoundBuffer(
|
|||
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;
|
||||
|
@ -1855,32 +1849,32 @@ HRESULT WINAPI DirectSoundCreate8(
|
|||
* 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;
|
||||
}
|
||||
|
@ -1890,34 +1884,34 @@ HRESULT DSOUND_AddBuffer(
|
|||
* 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;
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ struct IDirectSoundBufferImpl
|
|||
LONG ref;
|
||||
/* IDirectSoundBufferImpl fields */
|
||||
SecondaryBufferImpl* secondary;
|
||||
IDirectSoundImpl* dsound;
|
||||
DirectSoundDevice* device;
|
||||
CRITICAL_SECTION lock;
|
||||
PIDSDRIVERBUFFER hwbuf;
|
||||
PWAVEFORMATEX pwfx;
|
||||
|
@ -235,8 +235,8 @@ struct IDirectSoundBufferImpl
|
|||
};
|
||||
|
||||
HRESULT IDirectSoundBufferImpl_Create(
|
||||
IDirectSoundImpl *ds,
|
||||
IDirectSoundBufferImpl **pdsb,
|
||||
DirectSoundDevice *device,
|
||||
IDirectSoundBufferImpl **ppdsb,
|
||||
LPCDSBUFFERDESC dsbd);
|
||||
HRESULT IDirectSoundBufferImpl_Destroy(
|
||||
IDirectSoundBufferImpl *pdsb);
|
||||
|
@ -264,12 +264,12 @@ struct PrimaryBufferImpl
|
|||
{
|
||||
const IDirectSoundBuffer8Vtbl *lpVtbl;
|
||||
LONG ref;
|
||||
IDirectSoundImpl* dsound;
|
||||
DirectSoundDevice* device;
|
||||
};
|
||||
|
||||
HRESULT PrimaryBufferImpl_Create(
|
||||
IDirectSoundImpl *ds,
|
||||
PrimaryBufferImpl **pdsb,
|
||||
DirectSoundDevice * device,
|
||||
PrimaryBufferImpl **ppdsb,
|
||||
LPCDSBUFFERDESC dsbd);
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -413,11 +413,11 @@ struct IDirectSound3DListenerImpl
|
|||
const IDirectSound3DListenerVtbl *lpVtbl;
|
||||
LONG ref;
|
||||
/* IDirectSound3DListenerImpl fields */
|
||||
IDirectSoundImpl* dsound;
|
||||
DirectSoundDevice* device;
|
||||
};
|
||||
|
||||
HRESULT IDirectSound3DListenerImpl_Create(
|
||||
PrimaryBufferImpl *pb,
|
||||
DirectSoundDevice *device,
|
||||
IDirectSound3DListenerImpl **pdsl);
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -488,8 +488,8 @@ void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
|
|||
|
||||
/* 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 */
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ static inline BYTE cvtS16toU8(INT16 s)
|
|||
|
||||
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) {
|
||||
|
@ -215,16 +215,16 @@ static INT DSOUND_MixerNorm(IDirectSoundBufferImpl *dsb, BYTE *buf, INT len)
|
|||
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 )
|
||||
|
@ -237,9 +237,9 @@ static INT DSOUND_MixerNorm(IDirectSoundBufferImpl *dsb, BYTE *buf, INT len)
|
|||
}
|
||||
|
||||
/* 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 );
|
||||
|
@ -261,7 +261,7 @@ static INT DSOUND_MixerNorm(IDirectSoundBufferImpl *dsb, BYTE *buf, INT len)
|
|||
* 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;
|
||||
|
@ -299,11 +299,11 @@ static void DSOUND_MixerVol(IDirectSoundBufferImpl *dsb, BYTE *buf, INT len)
|
|||
/* 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;
|
||||
|
@ -324,13 +324,13 @@ static void DSOUND_MixerVol(IDirectSoundBufferImpl *dsb, BYTE *buf, INT len)
|
|||
}
|
||||
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;
|
||||
|
@ -346,12 +346,12 @@ static void DSOUND_MixerVol(IDirectSoundBufferImpl *dsb, BYTE *buf, INT len)
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO
|
|||
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) {
|
||||
|
@ -393,13 +393,13 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO
|
|||
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);
|
||||
|
@ -410,13 +410,13 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO
|
|||
(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 */
|
||||
|
@ -429,7 +429,7 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO
|
|||
|
||||
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 */
|
||||
|
@ -444,12 +444,12 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO
|
|||
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 */
|
||||
|
@ -462,7 +462,7 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO
|
|||
|
||||
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 */
|
||||
|
@ -508,13 +508,13 @@ static void DSOUND_PhaseCancel(IDirectSoundBufferImpl *dsb, DWORD writepos, DWOR
|
|||
|
||||
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);
|
||||
|
@ -526,13 +526,13 @@ static void DSOUND_PhaseCancel(IDirectSoundBufferImpl *dsb, DWORD writepos, DWOR
|
|||
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 */
|
||||
|
@ -545,7 +545,7 @@ static void DSOUND_PhaseCancel(IDirectSoundBufferImpl *dsb, DWORD writepos, DWOR
|
|||
|
||||
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 */
|
||||
|
@ -560,12 +560,12 @@ static void DSOUND_PhaseCancel(IDirectSoundBufferImpl *dsb, DWORD writepos, DWOR
|
|||
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 */
|
||||
|
@ -578,7 +578,7 @@ static void DSOUND_PhaseCancel(IDirectSoundBufferImpl *dsb, DWORD writepos, DWOR
|
|||
|
||||
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 */
|
||||
|
@ -596,10 +596,10 @@ static void DSOUND_MixCancel(IDirectSoundBufferImpl *dsb, DWORD writepos, BOOL c
|
|||
{
|
||||
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);
|
||||
|
@ -624,9 +624,9 @@ static void DSOUND_MixCancel(IDirectSoundBufferImpl *dsb, DWORD writepos, BOOL c
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -645,7 +645,7 @@ void DSOUND_MixCancelAt(IDirectSoundBufferImpl *dsb, DWORD buf_writepos)
|
|||
#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) +
|
||||
|
@ -655,7 +655,7 @@ void DSOUND_MixCancelAt(IDirectSoundBufferImpl *dsb, DWORD buf_writepos)
|
|||
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)
|
||||
|
@ -663,7 +663,7 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -677,11 +677,11 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD playpos, DWORD wri
|
|||
((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;
|
||||
|
@ -750,7 +750,7 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD playpos, DWORD wri
|
|||
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);
|
||||
|
@ -768,7 +768,7 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD playpos, DWORD wri
|
|||
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");
|
||||
|
@ -779,20 +779,20 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD playpos, DWORD wri
|
|||
/* 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:
|
||||
|
@ -812,9 +812,9 @@ 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);
|
||||
|
|
|
@ -326,7 +326,7 @@ HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LP
|
|||
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;
|
||||
|
@ -433,7 +433,7 @@ done:
|
|||
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;
|
||||
|
@ -478,7 +478,7 @@ static HRESULT WINAPI PrimaryBufferImpl_SetVolume(
|
|||
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);
|
||||
|
@ -515,7 +515,7 @@ static HRESULT WINAPI PrimaryBufferImpl_SetFrequency(
|
|||
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)) {
|
||||
|
@ -539,7 +539,7 @@ static HRESULT WINAPI PrimaryBufferImpl_Play(
|
|||
|
||||
static HRESULT WINAPI PrimaryBufferImpl_Stop(LPDIRECTSOUNDBUFFER8 iface)
|
||||
{
|
||||
DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->dsound->device;
|
||||
DirectSoundDevice *device = ((PrimaryBufferImpl *)iface)->device;
|
||||
TRACE("(%p)\n", iface);
|
||||
|
||||
/* **** */
|
||||
|
@ -571,7 +571,7 @@ static ULONG WINAPI PrimaryBufferImpl_Release(LPDIRECTSOUNDBUFFER8 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);
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ static HRESULT WINAPI PrimaryBufferImpl_GetCurrentPosition(
|
|||
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);
|
||||
|
@ -603,7 +603,7 @@ static HRESULT WINAPI PrimaryBufferImpl_GetCurrentPosition(
|
|||
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) {
|
||||
|
@ -628,7 +628,7 @@ static HRESULT WINAPI PrimaryBufferImpl_GetFormat(
|
|||
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;
|
||||
|
@ -659,7 +659,7 @@ static HRESULT WINAPI PrimaryBufferImpl_GetFormat(
|
|||
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,
|
||||
|
@ -742,7 +742,7 @@ static HRESULT WINAPI PrimaryBufferImpl_SetCurrentPosition(
|
|||
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;
|
||||
|
@ -787,7 +787,7 @@ static HRESULT WINAPI PrimaryBufferImpl_SetPan(
|
|||
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);
|
||||
|
@ -813,7 +813,7 @@ static HRESULT WINAPI PrimaryBufferImpl_GetPan(
|
|||
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) {
|
||||
|
@ -845,7 +845,7 @@ static HRESULT WINAPI PrimaryBufferImpl_Restore(
|
|||
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) {
|
||||
|
@ -915,7 +915,7 @@ static HRESULT WINAPI PrimaryBufferImpl_Initialize(
|
|||
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) {
|
||||
|
@ -948,7 +948,7 @@ static HRESULT WINAPI PrimaryBufferImpl_QueryInterface(
|
|||
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) {
|
||||
|
@ -985,7 +985,7 @@ static HRESULT WINAPI PrimaryBufferImpl_QueryInterface(
|
|||
|
||||
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);
|
||||
|
@ -1034,16 +1034,16 @@ static const IDirectSoundBuffer8Vtbl dspbvt =
|
|||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1051,23 +1051,24 @@ HRESULT PrimaryBufferImpl_Create(
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ static HRESULT WINAPI IKsBufferPropertySetImpl_Get(
|
|||
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);
|
||||
|
||||
|
@ -146,7 +146,7 @@ static HRESULT WINAPI IKsBufferPropertySetImpl_Set(
|
|||
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);
|
||||
|
|
|
@ -207,7 +207,7 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
|
|||
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:
|
||||
|
@ -277,16 +277,16 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
|
|||
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;
|
||||
|
@ -296,7 +296,7 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
|
|||
/* 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");
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
|
|||
/* 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));
|
||||
|
@ -336,15 +336,15 @@ static void DSOUND_ChangeListener(IDirectSound3DListenerImpl *ds3dl)
|
|||
{
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -786,10 +786,10 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_QueryInterface(
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -814,7 +814,7 @@ static ULONG WINAPI IDirectSound3DListenerImpl_Release(LPDIRECTSOUND3DLISTENER i
|
|||
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);
|
||||
}
|
||||
|
@ -840,7 +840,7 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetAllParameter(
|
|||
}
|
||||
|
||||
TRACE("returning: all parameters\n");
|
||||
*lpDS3DL = This->dsound->device->ds3dl;
|
||||
*lpDS3DL = This->device->ds3dl;
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
|
@ -849,8 +849,8 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetDistanceFactor(
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -859,8 +859,8 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetDopplerFactor(
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -870,11 +870,11 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetOrientation(
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -883,8 +883,8 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetPosition(
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -893,8 +893,8 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetRolloffFactor(
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -903,8 +903,8 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetVelocity(
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -915,13 +915,13 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetAllParameters(
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -932,13 +932,13 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetDistanceFactor(
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -949,13 +949,13 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetDopplerFactor(
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -968,18 +968,18 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetOrientation(
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -990,15 +990,15 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetPosition(
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1009,13 +1009,13 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetRolloffFactor(
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1026,15 +1026,15 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetVelocity(
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1072,44 +1072,44 @@ static const IDirectSound3DListenerVtbl ds3dlvt =
|
|||
};
|
||||
|
||||
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;
|
||||
pdsl->ref = 0;
|
||||
pdsl->lpVtbl = &ds3dlvt;
|
||||
|
||||
dsl->dsound = This->dsound;
|
||||
pdsl->device = device;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
dsl->dsound->device->ds3dl_need_recalc = TRUE;
|
||||
pdsl->device->ds3dl_need_recalc = TRUE;
|
||||
|
||||
*pdsl = dsl;
|
||||
*ppdsl = pdsl;
|
||||
return S_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue