dsound: Keep track of locked bytes.
This commit is contained in:
parent
fc324d97bc
commit
e6ae73359f
|
@ -519,16 +519,20 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Lock(IDirectSoundBuffer8 *iface, DW
|
||||||
TRACE("Locked %p(%i bytes) and %p(%i bytes) writecursor=%d\n",
|
TRACE("Locked %p(%i bytes) and %p(%i bytes) writecursor=%d\n",
|
||||||
*(LPBYTE*)lplpaudioptr1, *audiobytes1, lplpaudioptr2 ? *(LPBYTE*)lplpaudioptr2 : NULL, audiobytes2 ? *audiobytes2: 0, writecursor);
|
*(LPBYTE*)lplpaudioptr1, *audiobytes1, lplpaudioptr2 ? *(LPBYTE*)lplpaudioptr2 : NULL, audiobytes2 ? *audiobytes2: 0, writecursor);
|
||||||
TRACE("->%d.0\n",writebytes);
|
TRACE("->%d.0\n",writebytes);
|
||||||
|
This->buffer->lockedbytes += writebytes;
|
||||||
} else {
|
} else {
|
||||||
DWORD remainder = writebytes + writecursor - This->buflen;
|
DWORD remainder = writebytes + writecursor - This->buflen;
|
||||||
*(LPBYTE*)lplpaudioptr1 = This->buffer->memory+writecursor;
|
*(LPBYTE*)lplpaudioptr1 = This->buffer->memory+writecursor;
|
||||||
*audiobytes1 = This->buflen-writecursor;
|
*audiobytes1 = This->buflen-writecursor;
|
||||||
|
This->buffer->lockedbytes += *audiobytes1;
|
||||||
if (This->sec_mixpos >= writecursor && This->sec_mixpos < writecursor + writebytes && This->state == STATE_PLAYING)
|
if (This->sec_mixpos >= writecursor && This->sec_mixpos < writecursor + writebytes && This->state == STATE_PLAYING)
|
||||||
WARN("Overwriting mixing position, case 2\n");
|
WARN("Overwriting mixing position, case 2\n");
|
||||||
if (lplpaudioptr2)
|
if (lplpaudioptr2)
|
||||||
*(LPBYTE*)lplpaudioptr2 = This->buffer->memory;
|
*(LPBYTE*)lplpaudioptr2 = This->buffer->memory;
|
||||||
if (audiobytes2)
|
if (audiobytes2) {
|
||||||
*audiobytes2 = writebytes-(This->buflen-writecursor);
|
*audiobytes2 = writebytes-(This->buflen-writecursor);
|
||||||
|
This->buffer->lockedbytes += *audiobytes2;
|
||||||
|
}
|
||||||
if (audiobytes2 && This->sec_mixpos < remainder && This->state == STATE_PLAYING)
|
if (audiobytes2 && This->sec_mixpos < remainder && This->state == STATE_PLAYING)
|
||||||
WARN("Overwriting mixing position, case 3\n");
|
WARN("Overwriting mixing position, case 3\n");
|
||||||
TRACE("Locked %p(%i bytes) and %p(%i bytes) writecursor=%d\n", *(LPBYTE*)lplpaudioptr1, *audiobytes1, lplpaudioptr2 ? *(LPBYTE*)lplpaudioptr2 : NULL, audiobytes2 ? *audiobytes2: 0, writecursor);
|
TRACE("Locked %p(%i bytes) and %p(%i bytes) writecursor=%d\n", *(LPBYTE*)lplpaudioptr1, *audiobytes1, lplpaudioptr2 ? *(LPBYTE*)lplpaudioptr2 : NULL, audiobytes2 ? *audiobytes2: 0, writecursor);
|
||||||
|
@ -644,7 +648,17 @@ static HRESULT WINAPI IDirectSoundBufferImpl_Unlock(IDirectSoundBuffer8 *iface,
|
||||||
{
|
{
|
||||||
if(x1 + (DWORD_PTR)p1 - (DWORD_PTR)iter->buffer->memory > iter->buflen)
|
if(x1 + (DWORD_PTR)p1 - (DWORD_PTR)iter->buffer->memory > iter->buflen)
|
||||||
hres = DSERR_INVALIDPARAM;
|
hres = DSERR_INVALIDPARAM;
|
||||||
|
else
|
||||||
|
iter->buffer->lockedbytes -= x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (x2)
|
||||||
|
{
|
||||||
|
if(x2 + (DWORD_PTR)p2 - (DWORD_PTR)iter->buffer->memory > iter->buflen)
|
||||||
|
hres = DSERR_INVALIDPARAM;
|
||||||
|
else
|
||||||
|
iter->buffer->lockedbytes -= x2;
|
||||||
|
}
|
||||||
RtlReleaseResource(&iter->lock);
|
RtlReleaseResource(&iter->lock);
|
||||||
}
|
}
|
||||||
RtlReleaseResource(&This->device->buffer_list_lock);
|
RtlReleaseResource(&This->device->buffer_list_lock);
|
||||||
|
@ -927,6 +941,7 @@ HRESULT IDirectSoundBufferImpl_Create(
|
||||||
}
|
}
|
||||||
|
|
||||||
dsb->buffer->ref = 1;
|
dsb->buffer->ref = 1;
|
||||||
|
dsb->buffer->lockedbytes = 0;
|
||||||
list_init(&dsb->buffer->buffers);
|
list_init(&dsb->buffer->buffers);
|
||||||
list_add_head(&dsb->buffer->buffers, &dsb->entry);
|
list_add_head(&dsb->buffer->buffers, &dsb->entry);
|
||||||
FillMemory(dsb->buffer->memory, dsb->buflen, dsbd->lpwfxFormat->wBitsPerSample == 8 ? 128 : 0);
|
FillMemory(dsb->buffer->memory, dsb->buflen, dsbd->lpwfxFormat->wBitsPerSample == 8 ? 128 : 0);
|
||||||
|
|
|
@ -107,6 +107,7 @@ struct DirectSoundDevice
|
||||||
typedef struct BufferMemory
|
typedef struct BufferMemory
|
||||||
{
|
{
|
||||||
LONG ref;
|
LONG ref;
|
||||||
|
LONG lockedbytes;
|
||||||
LPBYTE memory;
|
LPBYTE memory;
|
||||||
struct list buffers;
|
struct list buffers;
|
||||||
} BufferMemory;
|
} BufferMemory;
|
||||||
|
|
Loading…
Reference in New Issue