2002-06-13 21:15:06 +02:00
|
|
|
/* DirectSound
|
|
|
|
*
|
|
|
|
* Copyright 1998 Marcus Meissner
|
|
|
|
* Copyright 1998 Rob Riggs
|
|
|
|
* Copyright 2000-2002 TransGaming Technologies, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-06-13 21:15:06 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
#define NONAMELESSSTRUCT
|
|
|
|
#define NONAMELESSUNION
|
2002-06-13 21:15:06 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2005-10-17 11:24:50 +02:00
|
|
|
#include "winuser.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
#include "mmsystem.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
2009-12-04 14:09:32 +01:00
|
|
|
#include "vfwmsgs.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "dsound.h"
|
|
|
|
#include "dsdriver.h"
|
|
|
|
#include "dsound_private.h"
|
2009-12-04 14:09:32 +01:00
|
|
|
#include "dsconf.h"
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
|
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT SecondaryBufferImpl_Destroy(SecondaryBufferImpl *pdsb);
|
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSoundNotify
|
|
|
|
*/
|
2006-08-02 13:26:14 +02:00
|
|
|
|
|
|
|
struct IDirectSoundNotifyImpl
|
|
|
|
{
|
|
|
|
/* IUnknown fields */
|
|
|
|
const IDirectSoundNotifyVtbl *lpVtbl;
|
|
|
|
LONG ref;
|
|
|
|
IDirectSoundBufferImpl* dsb;
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT IDirectSoundNotifyImpl_Create(IDirectSoundBufferImpl *dsb,
|
|
|
|
IDirectSoundNotifyImpl **pdsn);
|
|
|
|
static HRESULT IDirectSoundNotifyImpl_Destroy(IDirectSoundNotifyImpl *pdsn);
|
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
static HRESULT WINAPI IDirectSoundNotifyImpl_QueryInterface(
|
|
|
|
LPDIRECTSOUNDNOTIFY iface,REFIID riid,LPVOID *ppobj
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundNotifyImpl *This = (IDirectSoundNotifyImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
2003-05-02 22:16:48 +02:00
|
|
|
|
2003-09-02 01:58:43 +02:00
|
|
|
if (This->dsb == NULL) {
|
2003-08-07 00:57:24 +02:00
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2003-09-02 01:58:43 +02:00
|
|
|
return IDirectSoundBuffer_QueryInterface((LPDIRECTSOUNDBUFFER)This->dsb, riid, ppobj);
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2004-09-17 20:10:59 +02:00
|
|
|
static ULONG WINAPI IDirectSoundNotifyImpl_AddRef(LPDIRECTSOUNDNOTIFY iface)
|
|
|
|
{
|
2005-02-11 12:49:05 +01:00
|
|
|
IDirectSoundNotifyImpl *This = (IDirectSoundNotifyImpl *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2005-02-11 12:49:05 +01:00
|
|
|
static ULONG WINAPI IDirectSoundNotifyImpl_Release(LPDIRECTSOUNDNOTIFY iface)
|
|
|
|
{
|
|
|
|
IDirectSoundNotifyImpl *This = (IDirectSoundNotifyImpl *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2005-02-11 12:49:05 +01:00
|
|
|
|
|
|
|
if (!ref) {
|
|
|
|
This->dsb->notify = NULL;
|
2009-05-30 18:59:13 +02:00
|
|
|
IDirectSoundBuffer_Release((LPDIRECTSOUNDBUFFER)This->dsb);
|
2005-02-11 12:49:05 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
TRACE("(%p) released\n", This);
|
|
|
|
}
|
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundNotifyImpl_SetNotificationPositions(
|
|
|
|
LPDIRECTSOUNDNOTIFY iface,DWORD howmuch,LPCDSBPOSITIONNOTIFY notify
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundNotifyImpl *This = (IDirectSoundNotifyImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,0x%08x,%p)\n",This,howmuch,notify);
|
2003-05-02 22:16:48 +02:00
|
|
|
|
2004-04-19 04:58:45 +02:00
|
|
|
if (howmuch > 0 && notify == NULL) {
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("invalid parameter: notify == NULL\n");
|
2003-05-02 22:16:48 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
if (TRACE_ON(dsound)) {
|
2004-09-08 03:23:57 +02:00
|
|
|
unsigned int i;
|
2002-06-13 21:15:06 +02:00
|
|
|
for (i=0;i<howmuch;i++)
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("notify at %d to %p\n",
|
2005-09-12 12:30:05 +02:00
|
|
|
notify[i].dwOffset,notify[i].hEventNotify);
|
2003-05-02 22:16:48 +02:00
|
|
|
}
|
|
|
|
|
2003-09-02 01:58:43 +02:00
|
|
|
if (This->dsb->hwnotify) {
|
2003-05-22 05:39:13 +02:00
|
|
|
HRESULT hres;
|
2003-09-02 01:58:43 +02:00
|
|
|
hres = IDsDriverNotify_SetNotificationPositions(This->dsb->hwnotify, howmuch, notify);
|
2003-05-22 05:39:13 +02:00
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsDriverNotify_SetNotificationPositions failed\n");
|
|
|
|
return hres;
|
2004-04-19 04:58:45 +02:00
|
|
|
} else if (howmuch > 0) {
|
2003-05-02 22:16:48 +02:00
|
|
|
/* Make an internal copy of the caller-supplied array.
|
|
|
|
* Replace the existing copy if one is already present. */
|
2009-02-24 00:33:58 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->dsb->notifies);
|
2009-03-03 06:17:00 +01:00
|
|
|
This->dsb->notifies = HeapAlloc(GetProcessHeap(), 0,
|
2003-10-14 07:24:20 +02:00
|
|
|
howmuch * sizeof(DSBPOSITIONNOTIFY));
|
|
|
|
|
2003-09-02 01:58:43 +02:00
|
|
|
if (This->dsb->notifies == NULL) {
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("out of memory\n");
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
2005-01-24 13:40:45 +01:00
|
|
|
CopyMemory(This->dsb->notifies, notify, howmuch * sizeof(DSBPOSITIONNOTIFY));
|
2003-09-02 01:58:43 +02:00
|
|
|
This->dsb->nrofnotifies = howmuch;
|
2004-04-19 04:58:45 +02:00
|
|
|
} else {
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->dsb->notifies);
|
|
|
|
This->dsb->notifies = NULL;
|
2004-04-19 04:58:45 +02:00
|
|
|
This->dsb->nrofnotifies = 0;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-01 21:57:42 +02:00
|
|
|
static const IDirectSoundNotifyVtbl dsnvt =
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
2003-09-02 01:58:43 +02:00
|
|
|
IDirectSoundNotifyImpl_QueryInterface,
|
|
|
|
IDirectSoundNotifyImpl_AddRef,
|
|
|
|
IDirectSoundNotifyImpl_Release,
|
|
|
|
IDirectSoundNotifyImpl_SetNotificationPositions,
|
2002-06-13 21:15:06 +02:00
|
|
|
};
|
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT IDirectSoundNotifyImpl_Create(
|
2003-09-02 01:58:43 +02:00
|
|
|
IDirectSoundBufferImpl * dsb,
|
|
|
|
IDirectSoundNotifyImpl **pdsn)
|
|
|
|
{
|
|
|
|
IDirectSoundNotifyImpl * dsn;
|
|
|
|
TRACE("(%p,%p)\n",dsb,pdsn);
|
2004-07-14 01:35:09 +02:00
|
|
|
|
2008-05-10 17:25:26 +02:00
|
|
|
dsn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dsn));
|
2004-07-14 01:35:09 +02:00
|
|
|
|
2003-09-02 01:58:43 +02:00
|
|
|
if (dsn == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsn->ref = 0;
|
|
|
|
dsn->lpVtbl = &dsnvt;
|
|
|
|
dsn->dsb = dsb;
|
|
|
|
dsb->notify = dsn;
|
|
|
|
IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER)dsb);
|
2004-07-14 01:35:09 +02:00
|
|
|
|
2003-09-02 01:58:43 +02:00
|
|
|
*pdsn = dsn;
|
|
|
|
return DS_OK;
|
|
|
|
}
|
2004-07-14 01:35:09 +02:00
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT IDirectSoundNotifyImpl_Destroy(
|
2004-07-14 01:35:09 +02:00
|
|
|
IDirectSoundNotifyImpl *pdsn)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n",pdsn);
|
|
|
|
|
|
|
|
while (IDirectSoundNotifyImpl_Release((LPDIRECTSOUNDNOTIFY)pdsn) > 0);
|
|
|
|
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* IDirectSoundBuffer
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_SetFormat(
|
2004-01-09 23:06:54 +01:00
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPCWAVEFORMATEX wfex
|
2002-06-13 21:15:06 +02:00
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%p)\n",This,wfex);
|
|
|
|
/* This method is not available on secondary buffers */
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("invalid call\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_SetVolume(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LONG vol
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
LONG oldVol;
|
2004-09-10 21:34:01 +02:00
|
|
|
HRESULT hres = DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%d)\n",This,vol);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (!(This->dsbd.dwFlags & DSBCAPS_CTRLVOLUME)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("control unavailable: This->dsbd.dwFlags = 0x%08x\n", This->dsbd.dwFlags);
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_CONTROLUNAVAIL;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if ((vol > DSBVOLUME_MAX) || (vol < DSBVOLUME_MIN)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("invalid parameter: vol = %d\n", vol);
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
/* **** */
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlAcquireResourceExclusive(&This->lock, TRUE);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
if (This->dsbd.dwFlags & DSBCAPS_CTRL3D) {
|
2003-06-28 00:22:15 +02:00
|
|
|
oldVol = This->ds3db_lVolume;
|
|
|
|
This->ds3db_lVolume = vol;
|
2007-05-30 18:31:21 +02:00
|
|
|
if (vol != oldVol)
|
|
|
|
/* recalc 3d volume, which in turn recalcs the pans */
|
|
|
|
DSOUND_Calc3DBuffer(This);
|
2002-06-13 21:15:06 +02:00
|
|
|
} else {
|
|
|
|
oldVol = This->volpan.lVolume;
|
|
|
|
This->volpan.lVolume = vol;
|
2004-07-14 01:35:09 +02:00
|
|
|
if (vol != oldVol)
|
2003-05-22 05:39:13 +02:00
|
|
|
DSOUND_RecalcVolPan(&(This->volpan));
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (vol != oldVol) {
|
|
|
|
if (This->hwbuf) {
|
2003-05-22 05:39:13 +02:00
|
|
|
hres = IDsDriverBuffer_SetVolumePan(This->hwbuf, &(This->volpan));
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsDriverBuffer_SetVolumePan failed\n");
|
2007-06-13 17:05:49 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2002-06-13 21:15:06 +02:00
|
|
|
/* **** */
|
|
|
|
|
2004-09-10 21:34:01 +02:00
|
|
|
return hres;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_GetVolume(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPLONG vol
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
TRACE("(%p,%p)\n",This,vol);
|
|
|
|
|
2003-09-15 22:08:05 +02:00
|
|
|
if (!(This->dsbd.dwFlags & DSBCAPS_CTRLVOLUME)) {
|
|
|
|
WARN("control unavailable\n");
|
|
|
|
return DSERR_CONTROLUNAVAIL;
|
|
|
|
}
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (vol == NULL) {
|
|
|
|
WARN("invalid parameter: vol == NULL\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-09-15 22:08:05 +02:00
|
|
|
*vol = This->volpan.lVolume;
|
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_SetFrequency(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD freq
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
DWORD oldFreq;
|
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%d)\n",This,freq);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (!(This->dsbd.dwFlags & DSBCAPS_CTRLFREQUENCY)) {
|
|
|
|
WARN("control unavailable\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_CONTROLUNAVAIL;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
if (freq == DSBFREQUENCY_ORIGINAL)
|
2004-08-18 02:30:37 +02:00
|
|
|
freq = This->pwfx->nSamplesPerSec;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if ((freq < DSBFREQUENCY_MIN) || (freq > DSBFREQUENCY_MAX)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("invalid parameter: freq = %d\n", freq);
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
/* **** */
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlAcquireResourceExclusive(&This->lock, TRUE);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
oldFreq = This->freq;
|
|
|
|
This->freq = freq;
|
|
|
|
if (freq != oldFreq) {
|
2007-07-29 23:47:01 +02:00
|
|
|
This->freqAdjust = ((DWORD64)This->freq << DSOUND_FREQSHIFT) / This->device->pwfx->nSamplesPerSec;
|
2004-08-18 02:30:37 +02:00
|
|
|
This->nAvgBytesPerSec = freq * This->pwfx->nBlockAlign;
|
2002-06-13 21:15:06 +02:00
|
|
|
DSOUND_RecalcFormat(This);
|
2008-03-04 05:18:04 +01:00
|
|
|
DSOUND_MixToTemporary(This, 0, This->buflen, FALSE);
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2002-06-13 21:15:06 +02:00
|
|
|
/* **** */
|
|
|
|
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_Play(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD reserved1,DWORD reserved2,DWORD flags
|
|
|
|
) {
|
2003-05-22 05:39:13 +02:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%08x,%08x,%08x)\n",This,reserved1,reserved2,flags);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
/* **** */
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlAcquireResourceExclusive(&This->lock, TRUE);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
This->playflags = flags;
|
2007-07-29 23:47:01 +02:00
|
|
|
if (This->state == STATE_STOPPED && !This->hwbuf) {
|
2002-06-13 21:15:06 +02:00
|
|
|
This->leadin = TRUE;
|
|
|
|
This->state = STATE_STARTING;
|
|
|
|
} else if (This->state == STATE_STOPPING)
|
|
|
|
This->state = STATE_PLAYING;
|
|
|
|
if (This->hwbuf) {
|
2003-05-22 05:39:13 +02:00
|
|
|
hres = IDsDriverBuffer_Play(This->hwbuf, 0, 0, This->playflags);
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsDriverBuffer_Play failed\n");
|
|
|
|
else
|
|
|
|
This->state = STATE_PLAYING;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2002-06-13 21:15:06 +02:00
|
|
|
/* **** */
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
return hres;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_Stop(LPDIRECTSOUNDBUFFER8 iface)
|
|
|
|
{
|
2003-05-22 05:39:13 +02:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
/* **** */
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlAcquireResourceExclusive(&This->lock, TRUE);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
if (This->state == STATE_PLAYING)
|
|
|
|
This->state = STATE_STOPPING;
|
|
|
|
else if (This->state == STATE_STARTING)
|
2007-07-29 23:47:01 +02:00
|
|
|
{
|
2002-06-13 21:15:06 +02:00
|
|
|
This->state = STATE_STOPPED;
|
2007-07-29 23:47:01 +02:00
|
|
|
DSOUND_CheckEvent(This, 0, 0);
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
if (This->hwbuf) {
|
2003-05-22 05:39:13 +02:00
|
|
|
hres = IDsDriverBuffer_Stop(This->hwbuf);
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsDriverBuffer_Stop failed\n");
|
|
|
|
else
|
|
|
|
This->state = STATE_STOPPED;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2002-06-13 21:15:06 +02:00
|
|
|
/* **** */
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
return hres;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2004-09-17 20:10:59 +02:00
|
|
|
static ULONG WINAPI IDirectSoundBufferImpl_AddRef(LPDIRECTSOUNDBUFFER8 iface)
|
|
|
|
{
|
2005-02-11 12:49:05 +01:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2004-09-17 20:10:59 +02:00
|
|
|
static ULONG WINAPI IDirectSoundBufferImpl_Release(LPDIRECTSOUNDBUFFER8 iface)
|
2004-09-07 21:32:21 +02:00
|
|
|
{
|
2005-02-11 12:49:05 +01:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2005-02-11 12:49:05 +01:00
|
|
|
if (!ref) {
|
2006-01-14 17:06:52 +01:00
|
|
|
DirectSoundDevice_RemoveBuffer(This->device, This);
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlDeleteResource(&This->lock);
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2009-02-24 00:34:03 +01:00
|
|
|
if (This->hwbuf)
|
2002-06-13 21:15:06 +02:00
|
|
|
IDsDriverBuffer_Release(This->hwbuf);
|
2009-02-24 00:34:03 +01:00
|
|
|
if (!This->hwbuf || (This->device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY)) {
|
2003-06-28 00:22:15 +02:00
|
|
|
This->buffer->ref--;
|
2007-07-29 23:47:01 +02:00
|
|
|
list_remove(&This->entry);
|
2003-06-28 00:22:15 +02:00
|
|
|
if (This->buffer->ref==0) {
|
|
|
|
HeapFree(GetProcessHeap(),0,This->buffer->memory);
|
2002-06-13 21:15:06 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,This->buffer);
|
2003-06-28 00:22:15 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2007-07-29 23:47:01 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->tmp_buffer);
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->notifies);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->pwfx);
|
2005-02-11 12:49:05 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2005-02-11 12:49:05 +01:00
|
|
|
TRACE("(%p) released\n", This);
|
|
|
|
}
|
|
|
|
return ref;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_GetCurrentPosition(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPDWORD playpos,LPDWORD writepos
|
|
|
|
) {
|
|
|
|
HRESULT hres;
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",This,playpos,writepos);
|
2007-07-29 23:47:01 +02:00
|
|
|
|
|
|
|
RtlAcquireResourceShared(&This->lock, TRUE);
|
2002-06-13 21:15:06 +02:00
|
|
|
if (This->hwbuf) {
|
|
|
|
hres=IDsDriverBuffer_GetPosition(This->hwbuf,playpos,writepos);
|
2003-05-22 05:39:13 +02:00
|
|
|
if (hres != DS_OK) {
|
|
|
|
WARN("IDsDriverBuffer_GetPosition failed\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return hres;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2004-08-18 02:30:37 +02:00
|
|
|
} else {
|
2007-07-29 23:47:01 +02:00
|
|
|
DWORD pos = This->sec_mixpos;
|
|
|
|
|
|
|
|
/* sanity */
|
|
|
|
if (pos >= This->buflen){
|
|
|
|
FIXME("Bad play position. playpos: %d, buflen: %d\n", pos, This->buflen);
|
|
|
|
pos %= This->buflen;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (playpos)
|
|
|
|
*playpos = pos;
|
2004-08-18 02:30:37 +02:00
|
|
|
if (writepos)
|
2007-07-29 23:47:01 +02:00
|
|
|
*writepos = pos;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
2007-07-29 23:47:01 +02:00
|
|
|
if (writepos && This->state != STATE_STOPPED && (!This->hwbuf || !(This->device->drvdesc.dwFlags & DSDDESC_DONTNEEDWRITELEAD))) {
|
|
|
|
/* apply the documented 10ms lead to writepos */
|
|
|
|
*writepos += This->writelead;
|
2004-08-18 02:30:37 +02:00
|
|
|
*writepos %= This->buflen;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
2007-07-29 23:47:01 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2007-06-13 17:05:49 +02:00
|
|
|
|
|
|
|
TRACE("playpos = %d, writepos = %d, buflen=%d (%p, time=%d)\n",
|
2007-07-08 16:36:46 +02:00
|
|
|
playpos?*playpos:-1, writepos?*writepos:-1, This->buflen, This, GetTickCount());
|
2007-06-13 17:05:49 +02:00
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_GetStatus(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPDWORD status
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%p), thread is %04x\n",This,status,GetCurrentThreadId());
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (status == NULL) {
|
|
|
|
WARN("invalid parameter: status = NULL\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
*status = 0;
|
2008-04-03 00:01:27 +02:00
|
|
|
RtlAcquireResourceShared(&This->lock, TRUE);
|
2002-06-13 21:15:06 +02:00
|
|
|
if ((This->state == STATE_STARTING) || (This->state == STATE_PLAYING)) {
|
|
|
|
*status |= DSBSTATUS_PLAYING;
|
|
|
|
if (This->playflags & DSBPLAY_LOOPING)
|
|
|
|
*status |= DSBSTATUS_LOOPING;
|
|
|
|
}
|
2008-04-03 00:01:27 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("status=%x\n", *status);
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_GetFormat(
|
2004-08-18 02:30:37 +02:00
|
|
|
LPDIRECTSOUNDBUFFER8 iface,
|
|
|
|
LPWAVEFORMATEX lpwf,
|
|
|
|
DWORD wfsize,
|
|
|
|
LPDWORD wfwritten)
|
|
|
|
{
|
|
|
|
DWORD size;
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%p,%d,%p)\n",This,lpwf,wfsize,wfwritten);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2004-08-18 02:30:37 +02:00
|
|
|
size = sizeof(WAVEFORMATEX) + This->pwfx->cbSize;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2004-08-18 02:30:37 +02:00
|
|
|
if (lpwf) { /* NULL is valid */
|
|
|
|
if (wfsize >= size) {
|
2005-01-24 13:40:45 +01:00
|
|
|
CopyMemory(lpwf,This->pwfx,size);
|
2004-08-18 02:30:37 +02:00
|
|
|
if (wfwritten)
|
|
|
|
*wfwritten = size;
|
|
|
|
} else {
|
2005-05-06 17:44:31 +02:00
|
|
|
WARN("invalid parameter: wfsize too small\n");
|
2007-11-05 23:23:11 +01:00
|
|
|
CopyMemory(lpwf,This->pwfx,wfsize);
|
2004-08-18 02:30:37 +02:00
|
|
|
if (wfwritten)
|
2007-11-05 23:23:11 +01:00
|
|
|
*wfwritten = wfsize;
|
2004-08-18 02:30:37 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (wfwritten)
|
|
|
|
*wfwritten = sizeof(WAVEFORMATEX) + This->pwfx->cbSize;
|
|
|
|
else {
|
|
|
|
WARN("invalid parameter: wfwritten == NULL\n");
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_Lock(
|
2007-03-08 14:48:45 +01:00
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD writecursor,DWORD writebytes,LPVOID *lplpaudioptr1,LPDWORD audiobytes1,LPVOID *lplpaudioptr2,LPDWORD audiobytes2,DWORD flags
|
2002-06-13 21:15:06 +02:00
|
|
|
) {
|
2003-05-22 05:39:13 +02:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%d,%d,%p,%p,%p,%p,0x%08x) at %d\n",
|
2002-06-13 21:15:06 +02:00
|
|
|
This,
|
|
|
|
writecursor,
|
|
|
|
writebytes,
|
|
|
|
lplpaudioptr1,
|
|
|
|
audiobytes1,
|
|
|
|
lplpaudioptr2,
|
|
|
|
audiobytes2,
|
|
|
|
flags,
|
|
|
|
GetTickCount()
|
|
|
|
);
|
|
|
|
|
2009-01-02 07:39:10 +01:00
|
|
|
if (!audiobytes1)
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
|
2006-04-29 05:40:09 +02:00
|
|
|
/* when this flag is set, writecursor is meaningless and must be calculated */
|
2002-06-13 21:15:06 +02:00
|
|
|
if (flags & DSBLOCK_FROMWRITECURSOR) {
|
|
|
|
/* GetCurrentPosition does too much magic to duplicate here */
|
2006-04-29 05:40:09 +02:00
|
|
|
hres = IDirectSoundBufferImpl_GetCurrentPosition(iface, NULL, &writecursor);
|
2003-05-22 05:39:13 +02:00
|
|
|
if (hres != DS_OK) {
|
|
|
|
WARN("IDirectSoundBufferImpl_GetCurrentPosition failed\n");
|
|
|
|
return hres;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
2006-04-29 05:40:09 +02:00
|
|
|
|
|
|
|
/* when this flag is set, writebytes is meaningless and must be set */
|
2002-06-13 21:15:06 +02:00
|
|
|
if (flags & DSBLOCK_ENTIREBUFFER)
|
|
|
|
writebytes = This->buflen;
|
2006-04-29 05:40:09 +02:00
|
|
|
|
|
|
|
if (writecursor >= This->buflen) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("Invalid parameter, writecursor: %u >= buflen: %u\n",
|
2006-04-29 05:40:09 +02:00
|
|
|
writecursor, This->buflen);
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (writebytes > This->buflen) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("Invalid parameter, writebytes: %u > buflen: %u\n",
|
2006-04-29 05:40:09 +02:00
|
|
|
writebytes, This->buflen);
|
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2007-06-13 17:05:49 +02:00
|
|
|
/* **** */
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlAcquireResourceShared(&This->lock, TRUE);
|
2003-03-15 01:54:11 +01:00
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
if (!(This->device->drvdesc.dwFlags & DSDDESC_DONTNEEDSECONDARYLOCK) && This->hwbuf) {
|
2003-05-22 05:39:13 +02:00
|
|
|
hres = IDsDriverBuffer_Lock(This->hwbuf,
|
2002-06-13 21:15:06 +02:00
|
|
|
lplpaudioptr1, audiobytes1,
|
|
|
|
lplpaudioptr2, audiobytes2,
|
|
|
|
writecursor, writebytes,
|
|
|
|
0);
|
2003-05-22 05:39:13 +02:00
|
|
|
if (hres != DS_OK) {
|
|
|
|
WARN("IDsDriverBuffer_Lock failed\n");
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2003-05-22 05:39:13 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
} else {
|
2002-06-13 21:15:06 +02:00
|
|
|
if (writecursor+writebytes <= This->buflen) {
|
2003-06-28 00:22:15 +02:00
|
|
|
*(LPBYTE*)lplpaudioptr1 = This->buffer->memory+writecursor;
|
2007-07-29 23:47:01 +02:00
|
|
|
if (This->sec_mixpos >= writecursor && This->sec_mixpos < writecursor + writebytes && This->state == STATE_PLAYING)
|
|
|
|
WARN("Overwriting mixing position, case 1\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
*audiobytes1 = writebytes;
|
|
|
|
if (lplpaudioptr2)
|
|
|
|
*(LPBYTE*)lplpaudioptr2 = NULL;
|
|
|
|
if (audiobytes2)
|
|
|
|
*audiobytes2 = 0;
|
2007-06-13 17:05:49 +02:00
|
|
|
TRACE("Locked %p(%i bytes) and %p(%i bytes) writecursor=%d\n",
|
|
|
|
*(LPBYTE*)lplpaudioptr1, *audiobytes1, lplpaudioptr2 ? *(LPBYTE*)lplpaudioptr2 : NULL, audiobytes2 ? *audiobytes2: 0, writecursor);
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("->%d.0\n",writebytes);
|
2002-06-13 21:15:06 +02:00
|
|
|
} else {
|
2007-07-29 23:47:01 +02:00
|
|
|
DWORD remainder = writebytes + writecursor - This->buflen;
|
2003-06-28 00:22:15 +02:00
|
|
|
*(LPBYTE*)lplpaudioptr1 = This->buffer->memory+writecursor;
|
2002-06-13 21:15:06 +02:00
|
|
|
*audiobytes1 = This->buflen-writecursor;
|
2007-07-29 23:47:01 +02:00
|
|
|
if (This->sec_mixpos >= writecursor && This->sec_mixpos < writecursor + writebytes && This->state == STATE_PLAYING)
|
|
|
|
WARN("Overwriting mixing position, case 2\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
if (lplpaudioptr2)
|
2003-06-28 00:22:15 +02:00
|
|
|
*(LPBYTE*)lplpaudioptr2 = This->buffer->memory;
|
2002-06-13 21:15:06 +02:00
|
|
|
if (audiobytes2)
|
|
|
|
*audiobytes2 = writebytes-(This->buflen-writecursor);
|
2007-07-29 23:47:01 +02:00
|
|
|
if (audiobytes2 && This->sec_mixpos < remainder && This->state == STATE_PLAYING)
|
|
|
|
WARN("Overwriting mixing position, case 3\n");
|
2007-06-13 17:05:49 +02:00
|
|
|
TRACE("Locked %p(%i bytes) and %p(%i bytes) writecursor=%d\n", *(LPBYTE*)lplpaudioptr1, *audiobytes1, lplpaudioptr2 ? *(LPBYTE*)lplpaudioptr2 : NULL, audiobytes2 ? *audiobytes2: 0, writecursor);
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
}
|
2003-03-15 01:54:11 +01:00
|
|
|
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2007-06-13 17:05:49 +02:00
|
|
|
/* **** */
|
2006-04-29 05:40:09 +02:00
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_SetCurrentPosition(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD newpos
|
|
|
|
) {
|
2003-05-22 05:39:13 +02:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2007-07-29 23:47:01 +02:00
|
|
|
DWORD oldpos;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%d)\n",This,newpos);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
/* **** */
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlAcquireResourceExclusive(&This->lock, TRUE);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2007-07-29 23:47:01 +02:00
|
|
|
oldpos = This->sec_mixpos;
|
|
|
|
|
2007-06-13 17:05:49 +02:00
|
|
|
/* start mixing from this new location instead */
|
2004-08-18 02:30:37 +02:00
|
|
|
newpos %= This->buflen;
|
2007-05-24 20:42:14 +02:00
|
|
|
newpos -= newpos%This->pwfx->nBlockAlign;
|
2007-07-29 23:47:01 +02:00
|
|
|
This->sec_mixpos = newpos;
|
2007-06-13 17:05:49 +02:00
|
|
|
|
|
|
|
/* at this point, do not attempt to reset buffers, mess with primary mix position,
|
|
|
|
or anything like that to reduce latancy. The data already prebuffered cannot be changed */
|
|
|
|
|
2007-07-29 23:47:01 +02:00
|
|
|
/* position HW buffer if applicable, else just start mixing from new location instead */
|
2003-05-22 05:39:13 +02:00
|
|
|
if (This->hwbuf) {
|
|
|
|
hres = IDsDriverBuffer_SetPosition(This->hwbuf, This->buf_mixpos);
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsDriverBuffer_SetPosition failed\n");
|
|
|
|
}
|
2007-07-29 23:47:01 +02:00
|
|
|
else if (oldpos != newpos)
|
|
|
|
/* FIXME: Perhaps add a call to DSOUND_MixToTemporary here? Not sure it's needed */
|
|
|
|
This->buf_mixpos = DSOUND_secpos_to_bufpos(This, newpos, 0, NULL);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2002-06-13 21:15:06 +02:00
|
|
|
/* **** */
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
return hres;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_SetPan(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LONG pan
|
|
|
|
) {
|
2003-05-22 05:39:13 +02:00
|
|
|
HRESULT hres = DS_OK;
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%d)\n",This,pan);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if ((pan > DSBPAN_RIGHT) || (pan < DSBPAN_LEFT)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("invalid parameter: pan = %d\n", pan);
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
/* You cannot use both pan and 3D controls */
|
|
|
|
if (!(This->dsbd.dwFlags & DSBCAPS_CTRLPAN) ||
|
2003-05-22 05:39:13 +02:00
|
|
|
(This->dsbd.dwFlags & DSBCAPS_CTRL3D)) {
|
|
|
|
WARN("control unavailable\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_CONTROLUNAVAIL;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
/* **** */
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlAcquireResourceExclusive(&This->lock, TRUE);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2004-07-24 00:58:59 +02:00
|
|
|
if (This->volpan.lPan != pan) {
|
|
|
|
This->volpan.lPan = pan;
|
2002-06-13 21:15:06 +02:00
|
|
|
DSOUND_RecalcVolPan(&(This->volpan));
|
|
|
|
|
|
|
|
if (This->hwbuf) {
|
2003-05-22 05:39:13 +02:00
|
|
|
hres = IDsDriverBuffer_SetVolumePan(This->hwbuf, &(This->volpan));
|
|
|
|
if (hres != DS_OK)
|
|
|
|
WARN("IDsDriverBuffer_SetVolumePan failed\n");
|
2007-06-13 17:05:49 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2002-06-13 21:15:06 +02:00
|
|
|
/* **** */
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
return hres;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_GetPan(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPLONG pan
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
TRACE("(%p,%p)\n",This,pan);
|
|
|
|
|
2003-09-15 22:08:05 +02:00
|
|
|
if (!(This->dsbd.dwFlags & DSBCAPS_CTRLPAN)) {
|
|
|
|
WARN("control unavailable\n");
|
|
|
|
return DSERR_CONTROLUNAVAIL;
|
|
|
|
}
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (pan == NULL) {
|
|
|
|
WARN("invalid parameter: pan = NULL\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
*pan = This->volpan.lPan;
|
|
|
|
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_Unlock(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPVOID p1,DWORD x1,LPVOID p2,DWORD x2
|
|
|
|
) {
|
2007-07-29 23:47:01 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface, *iter;
|
2004-09-10 21:34:01 +02:00
|
|
|
HRESULT hres = DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%p,%d,%p,%d)\n", This,p1,x1,p2,x2);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2004-08-18 02:30:37 +02:00
|
|
|
/* **** */
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlAcquireResourceShared(&This->lock, TRUE);
|
2004-08-18 02:30:37 +02:00
|
|
|
|
2006-01-06 12:35:20 +01:00
|
|
|
if (!(This->device->drvdesc.dwFlags & DSDDESC_DONTNEEDSECONDARYLOCK) && This->hwbuf) {
|
2003-05-22 05:39:13 +02:00
|
|
|
hres = IDsDriverBuffer_Unlock(This->hwbuf, p1, x1, p2, x2);
|
2004-09-10 21:34:01 +02:00
|
|
|
if (hres != DS_OK)
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("IDsDriverBuffer_Unlock failed\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlReleaseResource(&This->lock);
|
2004-08-18 02:30:37 +02:00
|
|
|
/* **** */
|
|
|
|
|
2007-07-29 23:47:01 +02:00
|
|
|
if (!p2)
|
|
|
|
x2 = 0;
|
|
|
|
|
2007-08-26 17:34:45 +02:00
|
|
|
if (!This->hwbuf && (x1 || x2))
|
2007-07-29 23:47:01 +02:00
|
|
|
{
|
|
|
|
RtlAcquireResourceShared(&This->device->buffer_list_lock, TRUE);
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, &This->buffer->buffers, IDirectSoundBufferImpl, entry )
|
|
|
|
{
|
|
|
|
RtlAcquireResourceShared(&iter->lock, TRUE);
|
|
|
|
if (x1)
|
2008-09-02 23:08:21 +02:00
|
|
|
{
|
|
|
|
if(x1 + (DWORD_PTR)p1 - (DWORD_PTR)iter->buffer->memory > iter->buflen)
|
|
|
|
hres = DSERR_INVALIDPARAM;
|
|
|
|
else
|
|
|
|
DSOUND_MixToTemporary(iter, (DWORD_PTR)p1 - (DWORD_PTR)iter->buffer->memory, x1, FALSE);
|
|
|
|
}
|
2007-07-29 23:47:01 +02:00
|
|
|
if (x2)
|
2008-03-04 05:18:04 +01:00
|
|
|
DSOUND_MixToTemporary(iter, 0, x2, FALSE);
|
2007-07-29 23:47:01 +02:00
|
|
|
RtlReleaseResource(&iter->lock);
|
|
|
|
}
|
|
|
|
RtlReleaseResource(&This->device->buffer_list_lock);
|
|
|
|
}
|
|
|
|
|
2004-09-10 21:34:01 +02:00
|
|
|
return hres;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_Restore(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
FIXME("(%p):stub\n",This);
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_GetFrequency(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPDWORD freq
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
TRACE("(%p,%p)\n",This,freq);
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (freq == NULL) {
|
|
|
|
WARN("invalid parameter: freq = NULL\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
*freq = This->freq;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("-> %d\n", *freq);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_SetFX(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD dwEffectsCount,LPDSEFFECTDESC pDSFXDesc,LPDWORD pdwResultCodes
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
DWORD u;
|
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
FIXME("(%p,%u,%p,%p): stub\n",This,dwEffectsCount,pDSFXDesc,pdwResultCodes);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
if (pdwResultCodes)
|
|
|
|
for (u=0; u<dwEffectsCount; u++) pdwResultCodes[u] = DSFXR_UNKNOWN;
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("control unavailable\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_CONTROLUNAVAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_AcquireResources(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD dwFlags,DWORD dwEffectsCount,LPDWORD pdwResultCodes
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
DWORD u;
|
|
|
|
|
2011-05-10 00:59:02 +02:00
|
|
|
FIXME("(%p,%08u,%u,%p): stub, faking success\n",This,dwFlags,dwEffectsCount,pdwResultCodes);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
if (pdwResultCodes)
|
|
|
|
for (u=0; u<dwEffectsCount; u++) pdwResultCodes[u] = DSFXR_UNKNOWN;
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("control unavailable\n");
|
2011-05-10 00:59:02 +02:00
|
|
|
return DS_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_GetObjectInPath(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,REFGUID rguidObject,DWORD dwIndex,REFGUID rguidInterface,LPVOID* ppObject
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2006-11-12 14:40:35 +01:00
|
|
|
FIXME("(%p,%s,%u,%s,%p): stub\n",This,debugstr_guid(rguidObject),dwIndex,debugstr_guid(rguidInterface),ppObject);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("control unavailable\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_CONTROLUNAVAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_Initialize(
|
2004-07-06 21:27:00 +02:00
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPDIRECTSOUND dsound,LPCDSBUFFERDESC dbsd
|
2002-06-13 21:15:06 +02:00
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2007-07-29 21:29:33 +02:00
|
|
|
WARN("(%p) already initialized\n", This);
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_ALREADYINITIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_GetCaps(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPDSBCAPS caps
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
TRACE("(%p)->(%p)\n",This,caps);
|
|
|
|
|
2003-05-22 05:39:13 +02:00
|
|
|
if (caps == NULL) {
|
|
|
|
WARN("invalid parameter: caps == NULL\n");
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (caps->dwSize < sizeof(*caps)) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("invalid parameter: caps->dwSize = %d\n",caps->dwSize);
|
2003-05-22 05:39:13 +02:00
|
|
|
return DSERR_INVALIDPARAM;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
caps->dwFlags = This->dsbd.dwFlags;
|
|
|
|
if (This->hwbuf) caps->dwFlags |= DSBCAPS_LOCHARDWARE;
|
|
|
|
else caps->dwFlags |= DSBCAPS_LOCSOFTWARE;
|
|
|
|
|
|
|
|
caps->dwBufferBytes = This->buflen;
|
|
|
|
|
2007-05-30 18:32:35 +02:00
|
|
|
/* According to windows, this is zero*/
|
|
|
|
caps->dwUnlockTransferRate = 0;
|
2002-06-13 21:15:06 +02:00
|
|
|
caps->dwPlayCpuOverhead = 0;
|
|
|
|
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectSoundBufferImpl_QueryInterface(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,REFIID riid,LPVOID *ppobj
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
IDirectSoundBufferImpl *This = (IDirectSoundBufferImpl *)iface;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
|
2003-08-07 00:57:24 +02:00
|
|
|
if (ppobj == NULL) {
|
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
*ppobj = NULL; /* assume failure */
|
|
|
|
|
2004-07-14 01:35:09 +02:00
|
|
|
if ( IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IDirectSoundBuffer) ||
|
2003-06-28 00:22:15 +02:00
|
|
|
IsEqualGUID(riid, &IID_IDirectSoundBuffer8) ) {
|
2005-10-19 21:21:38 +02:00
|
|
|
if (!This->secondary)
|
|
|
|
SecondaryBufferImpl_Create(This, &(This->secondary));
|
|
|
|
if (This->secondary) {
|
|
|
|
IDirectSoundBuffer8_AddRef((LPDIRECTSOUNDBUFFER8)This->secondary);
|
|
|
|
*ppobj = This->secondary;
|
2003-09-02 01:58:43 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
WARN("IID_IDirectSoundBuffer\n");
|
|
|
|
return E_NOINTERFACE;
|
2003-06-28 00:22:15 +02:00
|
|
|
}
|
|
|
|
|
2004-09-07 21:32:21 +02:00
|
|
|
if ( IsEqualGUID( &IID_IDirectSoundNotify, riid ) ) {
|
2003-09-02 01:58:43 +02:00
|
|
|
if (!This->notify)
|
|
|
|
IDirectSoundNotifyImpl_Create(This, &(This->notify));
|
2003-05-02 22:16:48 +02:00
|
|
|
if (This->notify) {
|
|
|
|
IDirectSoundNotify_AddRef((LPDIRECTSOUNDNOTIFY)This->notify);
|
2003-09-02 01:58:43 +02:00
|
|
|
*ppobj = This->notify;
|
2003-05-02 22:16:48 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("IID_IDirectSoundNotify\n");
|
2003-06-28 00:22:15 +02:00
|
|
|
return E_NOINTERFACE;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( IsEqualGUID( &IID_IDirectSound3DBuffer, riid ) ) {
|
|
|
|
if (!This->ds3db)
|
2003-09-02 01:58:43 +02:00
|
|
|
IDirectSound3DBufferImpl_Create(This, &(This->ds3db));
|
|
|
|
if (This->ds3db) {
|
|
|
|
IDirectSound3DBuffer_AddRef((LPDIRECTSOUND3DBUFFER)This->ds3db);
|
|
|
|
*ppobj = This->ds3db;
|
2002-06-13 21:15:06 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("IID_IDirectSound3DBuffer\n");
|
2003-06-28 00:22:15 +02:00
|
|
|
return E_NOINTERFACE;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
if ( IsEqualGUID( &IID_IDirectSound3DListener, riid ) ) {
|
2002-06-13 21:15:06 +02:00
|
|
|
ERR("app requested IDirectSound3DListener on secondary buffer\n");
|
2003-06-28 00:22:15 +02:00
|
|
|
return E_NOINTERFACE;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( IsEqualGUID( &IID_IKsPropertySet, riid ) ) {
|
2004-12-06 12:42:58 +01:00
|
|
|
if (!This->iks)
|
|
|
|
IKsBufferPropertySetImpl_Create(This, &(This->iks));
|
|
|
|
if (This->iks) {
|
|
|
|
IKsPropertySet_AddRef((LPKSPROPERTYSET)This->iks);
|
|
|
|
*ppobj = This->iks;
|
|
|
|
return S_OK;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
2003-05-22 05:39:13 +02:00
|
|
|
WARN("IID_IKsPropertySet\n");
|
2003-06-28 00:22:15 +02:00
|
|
|
return E_NOINTERFACE;
|
2003-03-04 03:12:34 +01:00
|
|
|
}
|
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
FIXME( "Unknown IID %s\n", debugstr_guid( riid ) );
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2005-06-01 21:57:42 +02:00
|
|
|
static const IDirectSoundBuffer8Vtbl dsbvt =
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
|
|
|
IDirectSoundBufferImpl_QueryInterface,
|
|
|
|
IDirectSoundBufferImpl_AddRef,
|
|
|
|
IDirectSoundBufferImpl_Release,
|
|
|
|
IDirectSoundBufferImpl_GetCaps,
|
|
|
|
IDirectSoundBufferImpl_GetCurrentPosition,
|
|
|
|
IDirectSoundBufferImpl_GetFormat,
|
|
|
|
IDirectSoundBufferImpl_GetVolume,
|
|
|
|
IDirectSoundBufferImpl_GetPan,
|
2003-02-15 01:01:17 +01:00
|
|
|
IDirectSoundBufferImpl_GetFrequency,
|
2002-06-13 21:15:06 +02:00
|
|
|
IDirectSoundBufferImpl_GetStatus,
|
|
|
|
IDirectSoundBufferImpl_Initialize,
|
|
|
|
IDirectSoundBufferImpl_Lock,
|
|
|
|
IDirectSoundBufferImpl_Play,
|
|
|
|
IDirectSoundBufferImpl_SetCurrentPosition,
|
|
|
|
IDirectSoundBufferImpl_SetFormat,
|
|
|
|
IDirectSoundBufferImpl_SetVolume,
|
|
|
|
IDirectSoundBufferImpl_SetPan,
|
|
|
|
IDirectSoundBufferImpl_SetFrequency,
|
|
|
|
IDirectSoundBufferImpl_Stop,
|
|
|
|
IDirectSoundBufferImpl_Unlock,
|
|
|
|
IDirectSoundBufferImpl_Restore,
|
|
|
|
IDirectSoundBufferImpl_SetFX,
|
|
|
|
IDirectSoundBufferImpl_AcquireResources,
|
|
|
|
IDirectSoundBufferImpl_GetObjectInPath
|
|
|
|
};
|
|
|
|
|
2006-01-03 17:32:50 +01:00
|
|
|
HRESULT IDirectSoundBufferImpl_Create(
|
2006-01-06 12:35:20 +01:00
|
|
|
DirectSoundDevice * device,
|
2002-06-13 21:15:06 +02:00
|
|
|
IDirectSoundBufferImpl **pdsb,
|
2004-01-09 23:06:54 +01:00
|
|
|
LPCDSBUFFERDESC dsbd)
|
2002-06-13 21:15:06 +02:00
|
|
|
{
|
|
|
|
IDirectSoundBufferImpl *dsb;
|
|
|
|
LPWAVEFORMATEX wfex = dsbd->lpwfxFormat;
|
|
|
|
HRESULT err = DS_OK;
|
|
|
|
DWORD capf = 0;
|
2009-10-04 08:05:20 +02:00
|
|
|
int use_hw;
|
2006-01-06 12:35:20 +01:00
|
|
|
TRACE("(%p,%p,%p)\n",device,pdsb,dsbd);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
if (dsbd->dwBufferBytes < DSBSIZE_MIN || dsbd->dwBufferBytes > DSBSIZE_MAX) {
|
2006-11-12 14:40:35 +01:00
|
|
|
WARN("invalid parameter: dsbd->dwBufferBytes = %d\n", dsbd->dwBufferBytes);
|
2003-05-22 05:39:13 +02:00
|
|
|
*pdsb = NULL;
|
2002-06-13 21:15:06 +02:00
|
|
|
return DSERR_INVALIDPARAM; /* FIXME: which error? */
|
|
|
|
}
|
|
|
|
|
2004-08-18 02:30:37 +02:00
|
|
|
dsb = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*dsb));
|
2003-05-22 05:39:13 +02:00
|
|
|
|
|
|
|
if (dsb == 0) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*pdsb = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
2004-08-18 02:30:37 +02:00
|
|
|
|
|
|
|
TRACE("Created buffer at %p\n", dsb);
|
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
dsb->ref = 0;
|
2005-10-19 21:21:38 +02:00
|
|
|
dsb->secondary = 0;
|
2006-01-06 12:35:20 +01:00
|
|
|
dsb->device = device;
|
2003-04-10 20:17:34 +02:00
|
|
|
dsb->lpVtbl = &dsbvt;
|
2003-09-03 21:28:20 +02:00
|
|
|
dsb->iks = NULL;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2004-08-18 02:30:37 +02:00
|
|
|
/* size depends on version */
|
2005-01-24 13:40:45 +01:00
|
|
|
CopyMemory(&dsb->dsbd, dsbd, dsbd->dwSize);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2009-10-04 08:05:20 +02:00
|
|
|
dsb->pwfx = DSOUND_CopyFormat(wfex);
|
2004-08-18 02:30:37 +02:00
|
|
|
if (dsb->pwfx == NULL) {
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb);
|
|
|
|
*pdsb = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2005-02-16 17:09:02 +01:00
|
|
|
if (dsbd->dwBufferBytes % dsbd->lpwfxFormat->nBlockAlign)
|
|
|
|
dsb->buflen = dsbd->dwBufferBytes +
|
|
|
|
(dsbd->lpwfxFormat->nBlockAlign -
|
|
|
|
(dsbd->dwBufferBytes % dsbd->lpwfxFormat->nBlockAlign));
|
|
|
|
else
|
|
|
|
dsb->buflen = dsbd->dwBufferBytes;
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2005-02-16 17:09:02 +01:00
|
|
|
dsb->freq = dsbd->lpwfxFormat->nSamplesPerSec;
|
2003-09-02 01:58:43 +02:00
|
|
|
dsb->notify = NULL;
|
|
|
|
dsb->notifies = NULL;
|
|
|
|
dsb->nrofnotifies = 0;
|
|
|
|
dsb->hwnotify = 0;
|
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
/* Check necessary hardware mixing capabilities */
|
|
|
|
if (wfex->nChannels==2) capf |= DSCAPS_SECONDARYSTEREO;
|
|
|
|
else capf |= DSCAPS_SECONDARYMONO;
|
|
|
|
if (wfex->wBitsPerSample==16) capf |= DSCAPS_SECONDARY16BIT;
|
|
|
|
else capf |= DSCAPS_SECONDARY8BIT;
|
2003-09-03 21:28:20 +02:00
|
|
|
|
2007-08-26 17:34:45 +02:00
|
|
|
use_hw = !!(dsbd->dwFlags & DSBCAPS_LOCHARDWARE);
|
|
|
|
TRACE("use_hw = %d, capf = 0x%08x, device->drvcaps.dwFlags = 0x%08x\n", use_hw, capf, device->drvcaps.dwFlags);
|
2007-09-04 22:58:23 +02:00
|
|
|
if (use_hw && ((device->drvcaps.dwFlags & capf) != capf || !device->driver))
|
2007-08-26 17:34:45 +02:00
|
|
|
{
|
2007-09-04 22:58:23 +02:00
|
|
|
if (device->driver)
|
|
|
|
WARN("Format not supported for hardware buffer\n");
|
2007-08-26 17:34:45 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,dsb->pwfx);
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb);
|
|
|
|
*pdsb = NULL;
|
2007-09-04 22:58:23 +02:00
|
|
|
if ((device->drvcaps.dwFlags & capf) != capf)
|
|
|
|
return DSERR_BADFORMAT;
|
|
|
|
return DSERR_GENERIC;
|
2007-08-26 17:34:45 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
|
|
|
|
/* FIXME: check hardware sample rate mixing capabilities */
|
|
|
|
/* FIXME: check app hints for software/hardware buffer (STATIC, LOCHARDWARE, etc) */
|
|
|
|
/* FIXME: check whether any hardware buffers are left */
|
|
|
|
/* FIXME: handle DSDHEAP_CREATEHEAP for hardware buffers */
|
|
|
|
|
2005-02-10 18:09:20 +01:00
|
|
|
/* Allocate an empty buffer */
|
|
|
|
dsb->buffer = HeapAlloc(GetProcessHeap(),0,sizeof(*(dsb->buffer)));
|
|
|
|
if (dsb->buffer == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb->pwfx);
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb);
|
|
|
|
*pdsb = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2005-02-10 18:09:20 +01:00
|
|
|
/* Allocate system memory for buffer if applicable */
|
2006-01-06 12:35:20 +01:00
|
|
|
if ((device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY) || !use_hw) {
|
2004-08-18 02:30:37 +02:00
|
|
|
dsb->buffer->memory = HeapAlloc(GetProcessHeap(),0,dsb->buflen);
|
2003-06-28 00:22:15 +02:00
|
|
|
if (dsb->buffer->memory == NULL) {
|
|
|
|
WARN("out of memory\n");
|
2004-08-18 02:30:37 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,dsb->pwfx);
|
2003-06-28 00:22:15 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,dsb->buffer);
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb);
|
|
|
|
*pdsb = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate the hardware buffer */
|
2003-05-22 05:39:13 +02:00
|
|
|
if (use_hw) {
|
2006-01-06 12:35:20 +01:00
|
|
|
err = IDsDriver_CreateSoundBuffer(device->driver,wfex,dsbd->dwFlags,0,
|
2003-06-28 00:22:15 +02:00
|
|
|
&(dsb->buflen),&(dsb->buffer->memory),
|
2002-06-13 21:15:06 +02:00
|
|
|
(LPVOID*)&(dsb->hwbuf));
|
2007-08-26 17:34:45 +02:00
|
|
|
if (FAILED(err))
|
|
|
|
{
|
|
|
|
WARN("Failed to create hardware secondary buffer: %08x\n", err);
|
|
|
|
if (device->drvdesc.dwFlags & DSDDESC_USESYSTEMMEMORY)
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb->buffer->memory);
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb->buffer);
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb->pwfx);
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb);
|
|
|
|
*pdsb = NULL;
|
|
|
|
return DSERR_GENERIC;
|
2003-05-22 05:39:13 +02:00
|
|
|
}
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
|
2007-08-26 17:34:45 +02:00
|
|
|
dsb->buffer->ref = 1;
|
|
|
|
list_init(&dsb->buffer->buffers);
|
|
|
|
list_add_head(&dsb->buffer->buffers, &dsb->entry);
|
|
|
|
FillMemory(dsb->buffer->memory, dsb->buflen, dsbd->lpwfxFormat->wBitsPerSample == 8 ? 128 : 0);
|
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
/* It's not necessary to initialize values to zero since */
|
|
|
|
/* we allocated this structure with HEAP_ZERO_MEMORY... */
|
2007-07-29 23:47:01 +02:00
|
|
|
dsb->buf_mixpos = dsb->sec_mixpos = 0;
|
2002-06-13 21:15:06 +02:00
|
|
|
dsb->state = STATE_STOPPED;
|
|
|
|
|
2007-07-29 23:47:01 +02:00
|
|
|
dsb->freqAdjust = ((DWORD64)dsb->freq << DSOUND_FREQSHIFT) / device->pwfx->nSamplesPerSec;
|
2002-06-13 21:15:06 +02:00
|
|
|
dsb->nAvgBytesPerSec = dsb->freq *
|
|
|
|
dsbd->lpwfxFormat->nBlockAlign;
|
|
|
|
|
2007-07-29 23:47:01 +02:00
|
|
|
/* calculate fragment size and write lead */
|
|
|
|
DSOUND_RecalcFormat(dsb);
|
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
if (dsb->dsbd.dwFlags & DSBCAPS_CTRL3D) {
|
|
|
|
dsb->ds3db_ds3db.dwSize = sizeof(DS3DBUFFER);
|
2003-09-06 01:08:26 +02:00
|
|
|
dsb->ds3db_ds3db.vPosition.x = 0.0;
|
|
|
|
dsb->ds3db_ds3db.vPosition.y = 0.0;
|
|
|
|
dsb->ds3db_ds3db.vPosition.z = 0.0;
|
|
|
|
dsb->ds3db_ds3db.vVelocity.x = 0.0;
|
|
|
|
dsb->ds3db_ds3db.vVelocity.y = 0.0;
|
|
|
|
dsb->ds3db_ds3db.vVelocity.z = 0.0;
|
2003-06-28 00:22:15 +02:00
|
|
|
dsb->ds3db_ds3db.dwInsideConeAngle = DS3D_DEFAULTCONEANGLE;
|
|
|
|
dsb->ds3db_ds3db.dwOutsideConeAngle = DS3D_DEFAULTCONEANGLE;
|
2003-09-06 01:08:26 +02:00
|
|
|
dsb->ds3db_ds3db.vConeOrientation.x = 0.0;
|
|
|
|
dsb->ds3db_ds3db.vConeOrientation.y = 0.0;
|
|
|
|
dsb->ds3db_ds3db.vConeOrientation.z = 0.0;
|
2003-06-28 00:22:15 +02:00
|
|
|
dsb->ds3db_ds3db.lConeOutsideVolume = DS3D_DEFAULTCONEOUTSIDEVOLUME;
|
|
|
|
dsb->ds3db_ds3db.flMinDistance = DS3D_DEFAULTMINDISTANCE;
|
|
|
|
dsb->ds3db_ds3db.flMaxDistance = DS3D_DEFAULTMAXDISTANCE;
|
|
|
|
dsb->ds3db_ds3db.dwMode = DS3DMODE_NORMAL;
|
|
|
|
|
|
|
|
dsb->ds3db_need_recalc = FALSE;
|
|
|
|
DSOUND_Calc3DBuffer(dsb);
|
2003-05-22 05:39:13 +02:00
|
|
|
} else
|
2002-06-13 21:15:06 +02:00
|
|
|
DSOUND_RecalcVolPan(&(dsb->volpan));
|
|
|
|
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlInitializeResource(&dsb->lock);
|
2002-06-13 21:15:06 +02:00
|
|
|
|
2004-09-07 21:32:21 +02:00
|
|
|
/* register buffer if not primary */
|
2002-06-13 21:15:06 +02:00
|
|
|
if (!(dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER)) {
|
2006-01-14 17:06:52 +01:00
|
|
|
err = DirectSoundDevice_AddBuffer(device, dsb);
|
2004-09-07 21:32:21 +02:00
|
|
|
if (err != DS_OK) {
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,dsb->buffer->memory);
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb->buffer);
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlDeleteResource(&dsb->lock);
|
2004-08-18 02:30:37 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,dsb->pwfx);
|
2003-05-22 05:39:13 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,dsb);
|
2004-09-07 21:32:21 +02:00
|
|
|
dsb = NULL;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
|
|
|
}
|
2004-09-07 21:32:21 +02:00
|
|
|
|
2002-06-13 21:15:06 +02:00
|
|
|
*pdsb = dsb;
|
2004-09-07 21:32:21 +02:00
|
|
|
return err;
|
2002-06-13 21:15:06 +02:00
|
|
|
}
|
2003-09-02 01:58:43 +02:00
|
|
|
|
2006-01-03 17:32:50 +01:00
|
|
|
HRESULT IDirectSoundBufferImpl_Destroy(
|
2004-07-14 01:35:09 +02:00
|
|
|
IDirectSoundBufferImpl *pdsb)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n",pdsb);
|
|
|
|
|
|
|
|
/* This keeps the *_Destroy functions from possibly deleting
|
|
|
|
* this object until it is ready to be deleted */
|
|
|
|
IDirectSoundBufferImpl_AddRef((LPDIRECTSOUNDBUFFER8)pdsb);
|
|
|
|
|
|
|
|
if (pdsb->iks) {
|
|
|
|
WARN("iks not NULL\n");
|
|
|
|
IKsBufferPropertySetImpl_Destroy(pdsb->iks);
|
|
|
|
pdsb->iks = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pdsb->ds3db) {
|
|
|
|
WARN("ds3db not NULL\n");
|
|
|
|
IDirectSound3DBufferImpl_Destroy(pdsb->ds3db);
|
|
|
|
pdsb->ds3db = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pdsb->notify) {
|
|
|
|
WARN("notify not NULL\n");
|
|
|
|
IDirectSoundNotifyImpl_Destroy(pdsb->notify);
|
|
|
|
pdsb->notify = NULL;
|
|
|
|
}
|
|
|
|
|
2005-10-19 21:21:38 +02:00
|
|
|
if (pdsb->secondary) {
|
2004-07-14 01:35:09 +02:00
|
|
|
WARN("dsb not NULL\n");
|
2005-10-19 21:21:38 +02:00
|
|
|
SecondaryBufferImpl_Destroy(pdsb->secondary);
|
|
|
|
pdsb->secondary = NULL;
|
2004-07-14 01:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
while (IDirectSoundBuffer8_Release((LPDIRECTSOUNDBUFFER8)pdsb) > 0);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-14 17:06:52 +01:00
|
|
|
HRESULT IDirectSoundBufferImpl_Duplicate(
|
|
|
|
DirectSoundDevice *device,
|
|
|
|
IDirectSoundBufferImpl **ppdsb,
|
|
|
|
IDirectSoundBufferImpl *pdsb)
|
|
|
|
{
|
|
|
|
IDirectSoundBufferImpl *dsb;
|
|
|
|
HRESULT hres = DS_OK;
|
2011-07-18 08:02:07 +02:00
|
|
|
TRACE("(%p,%p,%p)\n", device, ppdsb, pdsb);
|
2006-01-14 17:06:52 +01:00
|
|
|
|
2009-10-04 09:13:53 +02:00
|
|
|
dsb = HeapAlloc(GetProcessHeap(),0,sizeof(*dsb));
|
2006-01-14 17:06:52 +01:00
|
|
|
if (dsb == NULL) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*ppdsb = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
2009-10-04 09:13:53 +02:00
|
|
|
CopyMemory(dsb, pdsb, sizeof(*dsb));
|
2006-01-14 17:06:52 +01:00
|
|
|
|
2009-10-04 09:13:53 +02:00
|
|
|
dsb->pwfx = DSOUND_CopyFormat(pdsb->pwfx);
|
|
|
|
if (dsb->pwfx == NULL) {
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb);
|
|
|
|
*ppdsb = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
2006-01-14 17:06:52 +01:00
|
|
|
|
|
|
|
if (pdsb->hwbuf) {
|
|
|
|
TRACE("duplicating hardware buffer\n");
|
|
|
|
|
|
|
|
hres = IDsDriver_DuplicateSoundBuffer(device->driver, pdsb->hwbuf,
|
|
|
|
(LPVOID *)&dsb->hwbuf);
|
2007-08-26 17:34:45 +02:00
|
|
|
if (FAILED(hres)) {
|
|
|
|
WARN("IDsDriver_DuplicateSoundBuffer failed (%08x)\n", hres);
|
2009-10-04 09:13:53 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,dsb->pwfx);
|
2007-08-26 17:34:45 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,dsb);
|
|
|
|
*ppdsb = NULL;
|
|
|
|
return hres;
|
2006-01-14 17:06:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-26 17:34:45 +02:00
|
|
|
dsb->buffer->ref++;
|
|
|
|
list_add_head(&dsb->buffer->buffers, &dsb->entry);
|
2006-01-14 17:06:52 +01:00
|
|
|
dsb->ref = 0;
|
|
|
|
dsb->state = STATE_STOPPED;
|
2007-07-29 23:47:01 +02:00
|
|
|
dsb->buf_mixpos = dsb->sec_mixpos = 0;
|
2006-01-14 17:06:52 +01:00
|
|
|
dsb->device = device;
|
|
|
|
dsb->ds3db = NULL;
|
|
|
|
dsb->iks = NULL; /* FIXME? */
|
|
|
|
dsb->secondary = NULL;
|
2007-07-29 23:47:01 +02:00
|
|
|
dsb->tmp_buffer = NULL;
|
|
|
|
DSOUND_RecalcFormat(dsb);
|
2008-03-04 05:18:04 +01:00
|
|
|
DSOUND_MixToTemporary(dsb, 0, dsb->buflen, FALSE);
|
2006-01-14 17:06:52 +01:00
|
|
|
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlInitializeResource(&dsb->lock);
|
2006-01-14 17:06:52 +01:00
|
|
|
|
|
|
|
/* register buffer */
|
|
|
|
hres = DirectSoundDevice_AddBuffer(device, dsb);
|
|
|
|
if (hres != DS_OK) {
|
2007-07-29 21:01:43 +02:00
|
|
|
RtlDeleteResource(&dsb->lock);
|
2007-07-29 23:47:01 +02:00
|
|
|
HeapFree(GetProcessHeap(),0,dsb->tmp_buffer);
|
2009-10-04 09:13:53 +02:00
|
|
|
list_remove(&dsb->entry);
|
|
|
|
dsb->buffer->ref--;
|
2006-01-14 17:06:52 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,dsb->pwfx);
|
|
|
|
HeapFree(GetProcessHeap(),0,dsb);
|
2009-10-04 09:13:53 +02:00
|
|
|
dsb = NULL;
|
2006-01-14 17:06:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
*ppdsb = dsb;
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2003-09-02 01:58:43 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* SecondaryBuffer
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_QueryInterface(
|
2004-07-14 01:35:09 +02:00
|
|
|
LPDIRECTSOUNDBUFFER8 iface,REFIID riid,LPVOID *ppobj)
|
2003-09-02 01:58:43 +02:00
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_QueryInterface((LPDIRECTSOUNDBUFFER8)This->dsb,riid,ppobj);
|
|
|
|
}
|
|
|
|
|
2004-09-17 20:10:59 +02:00
|
|
|
static ULONG WINAPI SecondaryBufferImpl_AddRef(LPDIRECTSOUNDBUFFER8 iface)
|
2003-09-02 01:58:43 +02:00
|
|
|
{
|
2005-10-19 21:21:38 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2005-02-11 12:49:05 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
2005-02-11 12:49:05 +01:00
|
|
|
return ref;
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
2004-09-17 20:10:59 +02:00
|
|
|
static ULONG WINAPI SecondaryBufferImpl_Release(LPDIRECTSOUNDBUFFER8 iface)
|
2003-09-02 01:58:43 +02:00
|
|
|
{
|
2005-10-19 21:21:38 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-01-06 12:35:20 +01:00
|
|
|
ULONG ref;
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
ref = InterlockedDecrement(&(This->ref));
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("ref was %d\n", ref + 1);
|
2005-02-11 12:49:05 +01:00
|
|
|
|
|
|
|
if (!ref) {
|
2005-10-19 21:21:38 +02:00
|
|
|
This->dsb->secondary = NULL;
|
2005-02-11 12:49:05 +01:00
|
|
|
IDirectSoundBuffer_Release((LPDIRECTSOUNDBUFFER8)This->dsb);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
TRACE("(%p) released\n", This);
|
|
|
|
}
|
|
|
|
return ref;
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_GetCaps(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPDSBCAPS caps)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p)->(%p)\n",This,caps);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_GetCaps((LPDIRECTSOUNDBUFFER8)This->dsb,caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_GetCurrentPosition(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPDWORD playpos,LPDWORD writepos)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",This,playpos,writepos);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_GetCurrentPosition((LPDIRECTSOUNDBUFFER8)This->dsb,playpos,writepos);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_GetFormat(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPWAVEFORMATEX lpwf,DWORD wfsize,LPDWORD wfwritten)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%p,%d,%p)\n",This,lpwf,wfsize,wfwritten);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_GetFormat((LPDIRECTSOUNDBUFFER8)This->dsb,lpwf,wfsize,wfwritten);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_GetVolume(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPLONG vol)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p,%p)\n",This,vol);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_GetVolume((LPDIRECTSOUNDBUFFER8)This->dsb,vol);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_GetPan(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPLONG pan)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p,%p)\n",This,pan);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_GetPan((LPDIRECTSOUNDBUFFER8)This->dsb,pan);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_GetFrequency(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPDWORD freq)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p,%p)\n",This,freq);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_GetFrequency((LPDIRECTSOUNDBUFFER8)This->dsb,freq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_GetStatus(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPDWORD status)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p,%p)\n",This,status);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_GetStatus((LPDIRECTSOUNDBUFFER8)This->dsb,status);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_Initialize(
|
2004-07-06 21:27:00 +02:00
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPDIRECTSOUND dsound,LPCDSBUFFERDESC dbsd)
|
2003-09-02 01:58:43 +02:00
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p,%p,%p)\n",This,dsound,dbsd);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_Initialize((LPDIRECTSOUNDBUFFER8)This->dsb,dsound,dbsd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_Lock(
|
2004-02-06 06:25:56 +01:00
|
|
|
LPDIRECTSOUNDBUFFER8 iface,
|
|
|
|
DWORD writecursor,
|
|
|
|
DWORD writebytes,
|
2007-03-08 14:48:45 +01:00
|
|
|
LPVOID *lplpaudioptr1,
|
2004-02-06 06:25:56 +01:00
|
|
|
LPDWORD audiobytes1,
|
2007-03-08 14:48:45 +01:00
|
|
|
LPVOID *lplpaudioptr2,
|
2004-02-06 06:25:56 +01:00
|
|
|
LPDWORD audiobytes2,
|
|
|
|
DWORD dwFlags)
|
2003-09-02 01:58:43 +02:00
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%d,%d,%p,%p,%p,%p,0x%08x)\n",
|
2004-02-06 06:25:56 +01:00
|
|
|
This,writecursor,writebytes,lplpaudioptr1,audiobytes1,lplpaudioptr2,audiobytes2,dwFlags);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
2004-02-06 06:25:56 +01:00
|
|
|
return IDirectSoundBufferImpl_Lock((LPDIRECTSOUNDBUFFER8)This->dsb,
|
|
|
|
writecursor,writebytes,lplpaudioptr1,audiobytes1,lplpaudioptr2,audiobytes2,dwFlags);
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_Play(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD reserved1,DWORD reserved2,DWORD flags)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%08x,%08x,%08x)\n",This,reserved1,reserved2,flags);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_Play((LPDIRECTSOUNDBUFFER8)This->dsb,reserved1,reserved2,flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_SetCurrentPosition(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD newpos)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%d)\n",This,newpos);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_SetCurrentPosition((LPDIRECTSOUNDBUFFER8)This->dsb,newpos);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_SetFormat(
|
2004-01-09 23:06:54 +01:00
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LPCWAVEFORMATEX wfex)
|
2003-09-02 01:58:43 +02:00
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p,%p)\n",This,wfex);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_SetFormat((LPDIRECTSOUNDBUFFER8)This->dsb,wfex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_SetVolume(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LONG vol)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%d)\n",This,vol);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_SetVolume((LPDIRECTSOUNDBUFFER8)This->dsb,vol);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_SetPan(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,LONG pan)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%d)\n",This,pan);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_SetPan((LPDIRECTSOUNDBUFFER8)This->dsb,pan);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_SetFrequency(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD freq)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%d)\n",This,freq);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_SetFrequency((LPDIRECTSOUNDBUFFER8)This->dsb,freq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_Stop(LPDIRECTSOUNDBUFFER8 iface)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_Stop((LPDIRECTSOUNDBUFFER8)This->dsb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_Unlock(
|
2004-02-06 06:25:56 +01:00
|
|
|
LPDIRECTSOUNDBUFFER8 iface,
|
|
|
|
LPVOID lpvAudioPtr1,
|
|
|
|
DWORD dwAudioBytes1,
|
|
|
|
LPVOID lpvAudioPtr2,
|
|
|
|
DWORD dwAudioBytes2)
|
2003-09-02 01:58:43 +02:00
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%p,%d,%p,%d)\n",
|
2004-02-06 06:25:56 +01:00
|
|
|
This, lpvAudioPtr1, dwAudioBytes1, lpvAudioPtr2, dwAudioBytes2);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
2004-02-06 06:25:56 +01:00
|
|
|
return IDirectSoundBufferImpl_Unlock((LPDIRECTSOUNDBUFFER8)This->dsb,
|
|
|
|
lpvAudioPtr1,dwAudioBytes1,lpvAudioPtr2,dwAudioBytes2);
|
2003-09-02 01:58:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_Restore(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2003-09-02 01:58:43 +02:00
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_Restore((LPDIRECTSOUNDBUFFER8)This->dsb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_SetFX(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD dwEffectsCount,LPDSEFFECTDESC pDSFXDesc,LPDWORD pdwResultCodes)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%u,%p,%p)\n",This,dwEffectsCount,pDSFXDesc,pdwResultCodes);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_SetFX((LPDIRECTSOUNDBUFFER8)This->dsb,dwEffectsCount,pDSFXDesc,pdwResultCodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_AcquireResources(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,DWORD dwFlags,DWORD dwEffectsCount,LPDWORD pdwResultCodes)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%08u,%u,%p)\n",This,dwFlags,dwEffectsCount,pdwResultCodes);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_AcquireResources((LPDIRECTSOUNDBUFFER8)This->dsb,dwFlags,dwEffectsCount,pdwResultCodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SecondaryBufferImpl_GetObjectInPath(
|
|
|
|
LPDIRECTSOUNDBUFFER8 iface,REFGUID rguidObject,DWORD dwIndex,REFGUID rguidInterface,LPVOID* ppObject)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SecondaryBufferImpl *This = (SecondaryBufferImpl *)iface;
|
2006-11-12 14:40:35 +01:00
|
|
|
TRACE("(%p,%s,%u,%s,%p)\n",This,debugstr_guid(rguidObject),dwIndex,debugstr_guid(rguidInterface),ppObject);
|
2003-09-02 01:58:43 +02:00
|
|
|
|
|
|
|
return IDirectSoundBufferImpl_GetObjectInPath((LPDIRECTSOUNDBUFFER8)This->dsb,rguidObject,dwIndex,rguidInterface,ppObject);
|
|
|
|
}
|
|
|
|
|
2005-06-01 21:57:42 +02:00
|
|
|
static const IDirectSoundBuffer8Vtbl sbvt =
|
2003-09-02 01:58:43 +02:00
|
|
|
{
|
|
|
|
SecondaryBufferImpl_QueryInterface,
|
|
|
|
SecondaryBufferImpl_AddRef,
|
|
|
|
SecondaryBufferImpl_Release,
|
|
|
|
SecondaryBufferImpl_GetCaps,
|
|
|
|
SecondaryBufferImpl_GetCurrentPosition,
|
|
|
|
SecondaryBufferImpl_GetFormat,
|
|
|
|
SecondaryBufferImpl_GetVolume,
|
|
|
|
SecondaryBufferImpl_GetPan,
|
|
|
|
SecondaryBufferImpl_GetFrequency,
|
|
|
|
SecondaryBufferImpl_GetStatus,
|
|
|
|
SecondaryBufferImpl_Initialize,
|
|
|
|
SecondaryBufferImpl_Lock,
|
|
|
|
SecondaryBufferImpl_Play,
|
|
|
|
SecondaryBufferImpl_SetCurrentPosition,
|
|
|
|
SecondaryBufferImpl_SetFormat,
|
|
|
|
SecondaryBufferImpl_SetVolume,
|
|
|
|
SecondaryBufferImpl_SetPan,
|
|
|
|
SecondaryBufferImpl_SetFrequency,
|
|
|
|
SecondaryBufferImpl_Stop,
|
|
|
|
SecondaryBufferImpl_Unlock,
|
|
|
|
SecondaryBufferImpl_Restore,
|
|
|
|
SecondaryBufferImpl_SetFX,
|
|
|
|
SecondaryBufferImpl_AcquireResources,
|
|
|
|
SecondaryBufferImpl_GetObjectInPath
|
|
|
|
};
|
|
|
|
|
2006-01-03 17:32:50 +01:00
|
|
|
HRESULT SecondaryBufferImpl_Create(
|
2003-09-02 01:58:43 +02:00
|
|
|
IDirectSoundBufferImpl *dsb,
|
|
|
|
SecondaryBufferImpl **psb)
|
|
|
|
{
|
|
|
|
SecondaryBufferImpl *sb;
|
|
|
|
TRACE("(%p,%p)\n",dsb,psb);
|
|
|
|
|
2004-08-18 02:30:37 +02:00
|
|
|
sb = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*sb));
|
2003-09-02 01:58:43 +02:00
|
|
|
|
|
|
|
if (sb == 0) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*psb = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
sb->ref = 0;
|
|
|
|
sb->dsb = dsb;
|
|
|
|
sb->lpVtbl = &sbvt;
|
|
|
|
|
|
|
|
IDirectSoundBuffer8_AddRef((LPDIRECTSOUNDBUFFER8)dsb);
|
|
|
|
*psb = sb;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2004-07-14 01:35:09 +02:00
|
|
|
|
2006-08-02 13:26:14 +02:00
|
|
|
static HRESULT SecondaryBufferImpl_Destroy(
|
2004-07-14 01:35:09 +02:00
|
|
|
SecondaryBufferImpl *pdsb)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n",pdsb);
|
|
|
|
|
|
|
|
while (SecondaryBufferImpl_Release((LPDIRECTSOUNDBUFFER8)pdsb) > 0);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2009-12-04 14:09:32 +01:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* IKsBufferPropertySet
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* IUnknown methods */
|
|
|
|
static HRESULT WINAPI IKsBufferPropertySetImpl_QueryInterface(
|
|
|
|
LPKSPROPERTYSET iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppobj )
|
|
|
|
{
|
|
|
|
IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
|
|
|
|
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
|
|
|
|
return IDirectSoundBuffer_QueryInterface((LPDIRECTSOUNDBUFFER8)This->dsb, riid, ppobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IKsBufferPropertySetImpl_AddRef(LPKSPROPERTYSET iface)
|
|
|
|
{
|
|
|
|
IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %d\n", This, ref - 1);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IKsBufferPropertySetImpl_Release(LPKSPROPERTYSET iface)
|
|
|
|
{
|
|
|
|
IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&(This->ref));
|
|
|
|
TRACE("(%p) ref was %d\n", This, ref + 1);
|
|
|
|
|
|
|
|
if (!ref) {
|
|
|
|
This->dsb->iks = 0;
|
|
|
|
IDirectSoundBuffer_Release((LPDIRECTSOUND3DBUFFER)This->dsb);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
TRACE("(%p) released\n", This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IKsBufferPropertySetImpl_Get(
|
|
|
|
LPKSPROPERTYSET iface,
|
|
|
|
REFGUID guidPropSet,
|
|
|
|
ULONG dwPropID,
|
|
|
|
LPVOID pInstanceData,
|
|
|
|
ULONG cbInstanceData,
|
|
|
|
LPVOID pPropData,
|
|
|
|
ULONG cbPropData,
|
|
|
|
PULONG pcbReturned )
|
|
|
|
{
|
|
|
|
IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
|
|
|
|
PIDSDRIVERPROPERTYSET ps;
|
|
|
|
TRACE("(iface=%p,guidPropSet=%s,dwPropID=%d,pInstanceData=%p,cbInstanceData=%d,pPropData=%p,cbPropData=%d,pcbReturned=%p)\n",
|
|
|
|
This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData,pcbReturned);
|
|
|
|
|
|
|
|
if (This->dsb->hwbuf) {
|
|
|
|
IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
|
|
|
|
|
|
|
|
if (ps) {
|
|
|
|
DSPROPERTY prop;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
prop.s.Set = *guidPropSet;
|
|
|
|
prop.s.Id = dwPropID;
|
|
|
|
prop.s.Flags = 0; /* unused */
|
|
|
|
prop.s.InstanceId = (ULONG)This->dsb->device;
|
|
|
|
|
|
|
|
|
|
|
|
hres = IDsDriverPropertySet_Get(ps, &prop, pInstanceData, cbInstanceData, pPropData, cbPropData, pcbReturned);
|
|
|
|
|
|
|
|
IDsDriverPropertySet_Release(ps);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IKsBufferPropertySetImpl_Set(
|
|
|
|
LPKSPROPERTYSET iface,
|
|
|
|
REFGUID guidPropSet,
|
|
|
|
ULONG dwPropID,
|
|
|
|
LPVOID pInstanceData,
|
|
|
|
ULONG cbInstanceData,
|
|
|
|
LPVOID pPropData,
|
|
|
|
ULONG cbPropData )
|
|
|
|
{
|
|
|
|
IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
|
|
|
|
PIDSDRIVERPROPERTYSET ps;
|
|
|
|
TRACE("(%p,%s,%d,%p,%d,%p,%d)\n",This,debugstr_guid(guidPropSet),dwPropID,pInstanceData,cbInstanceData,pPropData,cbPropData);
|
|
|
|
|
|
|
|
if (This->dsb->hwbuf) {
|
|
|
|
IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
|
|
|
|
|
|
|
|
if (ps) {
|
|
|
|
DSPROPERTY prop;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
prop.s.Set = *guidPropSet;
|
|
|
|
prop.s.Id = dwPropID;
|
|
|
|
prop.s.Flags = 0; /* unused */
|
|
|
|
prop.s.InstanceId = (ULONG)This->dsb->device;
|
|
|
|
hres = IDsDriverPropertySet_Set(ps,&prop,pInstanceData,cbInstanceData,pPropData,cbPropData);
|
|
|
|
|
|
|
|
IDsDriverPropertySet_Release(ps);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IKsBufferPropertySetImpl_QuerySupport(
|
|
|
|
LPKSPROPERTYSET iface,
|
|
|
|
REFGUID guidPropSet,
|
|
|
|
ULONG dwPropID,
|
|
|
|
PULONG pTypeSupport )
|
|
|
|
{
|
|
|
|
IKsBufferPropertySetImpl *This = (IKsBufferPropertySetImpl *)iface;
|
|
|
|
PIDSDRIVERPROPERTYSET ps;
|
|
|
|
TRACE("(%p,%s,%d,%p)\n",This,debugstr_guid(guidPropSet),dwPropID,pTypeSupport);
|
|
|
|
|
|
|
|
if (This->dsb->hwbuf) {
|
|
|
|
IDsDriver_QueryInterface(This->dsb->hwbuf, &IID_IDsDriverPropertySet, (void **)&ps);
|
|
|
|
|
|
|
|
if (ps) {
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IDsDriverPropertySet_QuerySupport(ps,guidPropSet, dwPropID,pTypeSupport);
|
|
|
|
|
|
|
|
IDsDriverPropertySet_Release(ps);
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IKsPropertySetVtbl iksbvt = {
|
|
|
|
IKsBufferPropertySetImpl_QueryInterface,
|
|
|
|
IKsBufferPropertySetImpl_AddRef,
|
|
|
|
IKsBufferPropertySetImpl_Release,
|
|
|
|
IKsBufferPropertySetImpl_Get,
|
|
|
|
IKsBufferPropertySetImpl_Set,
|
|
|
|
IKsBufferPropertySetImpl_QuerySupport
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT IKsBufferPropertySetImpl_Create(
|
|
|
|
IDirectSoundBufferImpl *dsb,
|
|
|
|
IKsBufferPropertySetImpl **piks)
|
|
|
|
{
|
|
|
|
IKsBufferPropertySetImpl *iks;
|
|
|
|
TRACE("(%p,%p)\n",dsb,piks);
|
|
|
|
*piks = NULL;
|
|
|
|
|
|
|
|
iks = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*iks));
|
|
|
|
if (iks == 0) {
|
|
|
|
WARN("out of memory\n");
|
|
|
|
*piks = NULL;
|
|
|
|
return DSERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
iks->ref = 0;
|
|
|
|
iks->dsb = dsb;
|
|
|
|
dsb->iks = iks;
|
|
|
|
iks->lpVtbl = &iksbvt;
|
|
|
|
|
|
|
|
IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER)dsb);
|
|
|
|
|
|
|
|
*piks = iks;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT IKsBufferPropertySetImpl_Destroy(
|
|
|
|
IKsBufferPropertySetImpl *piks)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n",piks);
|
|
|
|
|
|
|
|
while (IKsBufferPropertySetImpl_Release((LPKSPROPERTYSET)piks) > 0);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|