Commit a4ed8e77 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

- make parameter checking and error notification consistent

- propagate driver and local function errors where needed - fix error returns where pointer is given for returned data - add 3d listener to primary buffer when needed - copy 3d part of buffer when duplicated - fix bug when primary buffer is reopened with smaller buffer - loosen requirements on caps data size check - set caps for emulated mode based on actual driver caps
parent a4d733ae
......@@ -877,8 +877,7 @@ void DSOUND_PerformMix(void)
while (writepos >= dsound->buflen)
writepos -= dsound->buflen;
} else writepos = playpos;
}
else {
} else {
playpos = dsound->pwplay * dsound->fraglen;
writepos = playpos;
if (!paused) {
......@@ -887,8 +886,9 @@ void DSOUND_PerformMix(void)
writepos -= dsound->buflen;
}
}
TRACE("primary playpos=%ld, writepos=%ld, clrpos=%ld, mixpos=%ld\n",
playpos,writepos,dsound->playpos,dsound->mixpos);
TRACE("primary playpos=%ld, writepos=%ld, clrpos=%ld, mixpos=%ld, buflen=%ld\n",
playpos,writepos,dsound->playpos,dsound->mixpos,dsound->buflen);
assert(dsound->playpos < dsound->buflen);
/* wipe out just-played sound data */
if (playpos < dsound->playpos) {
memset(dsound->buffer + dsound->playpos, nfiller, dsound->buflen - dsound->playpos);
......@@ -943,7 +943,8 @@ void DSOUND_PerformMix(void)
/* DSOUND_callback may need this lock */
LeaveCriticalSection(&(dsound->mixlock));
#endif
DSOUND_PrimaryStop(dsound);
if (DSOUND_PrimaryStop(dsound) != DS_OK)
WARN("DSOUND_PrimaryStop failed\n");
#ifdef SYNC_CALLBACK
EnterCriticalSection(&(dsound->mixlock));
#endif
......@@ -988,8 +989,10 @@ void DSOUND_PerformMix(void)
}
LeaveCriticalSection(&(dsound->mixlock));
if (paused) {
DSOUND_PrimaryPlay(dsound);
TRACE("starting playback\n");
if (DSOUND_PrimaryPlay(dsound) != DS_OK)
WARN("DSOUND_PrimaryPlay failed\n");
else
TRACE("starting playback\n");
}
}
else
......@@ -997,12 +1000,16 @@ void DSOUND_PerformMix(void)
} else {
/* in the DSSCL_WRITEPRIMARY mode, the app is totally in charge... */
if (dsound->state == STATE_STARTING) {
DSOUND_PrimaryPlay(dsound);
dsound->state = STATE_PLAYING;
if (DSOUND_PrimaryPlay(dsound) != DS_OK)
WARN("DSOUND_PrimaryPlay failed\n");
else
dsound->state = STATE_PLAYING;
}
else if (dsound->state == STATE_STOPPING) {
DSOUND_PrimaryStop(dsound);
dsound->state = STATE_STOPPED;
if (DSOUND_PrimaryStop(dsound) != DS_OK)
WARN("DSOUND_PrimaryStop failed\n");
else
dsound->state = STATE_STOPPED;
}
}
TRACE("completed processing at %ld\n", GetTickCount());
......
......@@ -68,6 +68,7 @@ static ULONG WINAPI IKsPropertySetImpl_AddRef(LPKSPROPERTYSET iface) {
ICOM_THIS(IKsPropertySetImpl,iface);
ULONG ulReturn;
TRACE("(%p) ref was %ld\n", This, This->ref);
ulReturn = InterlockedIncrement(&This->ref);
if (ulReturn == 1)
IDirectSoundBuffer_AddRef((LPDIRECTSOUND3DBUFFER)This->dsb);
......@@ -78,6 +79,7 @@ static ULONG WINAPI IKsPropertySetImpl_Release(LPKSPROPERTYSET iface) {
ICOM_THIS(IKsPropertySetImpl,iface);
ULONG ulReturn;
TRACE("(%p) ref was %ld\n", This, This->ref);
ulReturn = InterlockedDecrement(&This->ref);
if (ulReturn)
return ulReturn;
......
......@@ -187,7 +187,8 @@ static inline D3DVALUE ProjectVector (LPD3DVECTOR a, LPD3DVECTOR p)
static void WINAPI DSOUND_Mix3DBuffer(IDirectSound3DBufferImpl *ds3db)
{
IDirectSound3DListenerImpl *dsl;
TRACE("(%p)\n",ds3db);
/* volume, at which the sound will be played after all calcs. */
D3DVALUE lVolume = 0;
/* intensity (used for distance related stuff) */
......@@ -333,6 +334,7 @@ static void WINAPI DSOUND_Mix3DBuffer(IDirectSound3DBufferImpl *ds3db)
static void WINAPI DSOUND_ChangeListener(IDirectSound3DListenerImpl *ds3dl)
{
int i;
TRACE("(%p)\n",ds3dl);
for (i = 0; i < ds3dl->dsb->dsound->nrofbuffers; i++)
{
/* some buffers don't have 3d buffer (Ultima IX seems to
......@@ -687,8 +689,15 @@ HRESULT WINAPI IDirectSound3DBufferImpl_Create(
IDirectSound3DBufferImpl **pds3db)
{
IDirectSound3DBufferImpl *ds3db;
TRACE("(%p,%p)\n",This,pds3db);
ds3db = (IDirectSound3DBufferImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*ds3db));
if (ds3db == NULL) {
WARN("out of memory\n");
return DSERR_OUTOFMEMORY;
}
ds3db = (IDirectSound3DBufferImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(*ds3db));
ds3db->ref = 0;
ds3db->dsb = This;
ds3db->lpVtbl = &ds3dbvt;
......@@ -732,6 +741,7 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_QueryInterface(
static ULONG WINAPI IDirectSound3DListenerImpl_AddRef(LPDIRECTSOUND3DLISTENER iface)
{
ICOM_THIS(IDirectSound3DListenerImpl,iface);
TRACE("(%p) ref was %ld\n", This, This->ref);
return InterlockedIncrement(&This->ref);
}
......@@ -1000,8 +1010,15 @@ HRESULT WINAPI IDirectSound3DListenerImpl_Create(
IDirectSound3DListenerImpl **pdsl)
{
IDirectSound3DListenerImpl *dsl;
TRACE("(%p,%p)\n",This,pdsl);
dsl = (IDirectSound3DListenerImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*dsl));
if (dsl == NULL) {
WARN("out of memory\n");
return DSERR_OUTOFMEMORY;
}
dsl = (IDirectSound3DListenerImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(*dsl));
dsl->ref = 1;
dsl->lpVtbl = &ds3dlvt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment