⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sound3d.c

📁 一个类似windows
💻 C
📖 第 1 页 / 共 3 页
字号:
	IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER8)dsb);	*pds3db = ds3db;	return S_OK;}HRESULT WINAPI IDirectSound3DBufferImpl_Destroy(    IDirectSound3DBufferImpl *pds3db){    TRACE("(%p)\n",pds3db);    while (IDirectSound3DBufferImpl_Release((LPDIRECTSOUND3DBUFFER)pds3db) > 0);    return S_OK;}/******************************************************************************* *	      IDirectSound3DListener *//* IUnknown methods */static HRESULT WINAPI IDirectSound3DListenerImpl_QueryInterface(	LPDIRECTSOUND3DLISTENER iface, REFIID riid, LPVOID *ppobj){	IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;	TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);	if (ppobj == NULL) {		WARN("invalid parameter\n");		return E_INVALIDARG;	}	*ppobj = NULL;  /* assume failure */	if ( IsEqualGUID(riid, &IID_IUnknown) ||	     IsEqualGUID(riid, &IID_IDirectSound3DListener ) ) {                IDirectSound3DListener_AddRef((LPDIRECTSOUND3DLISTENER)This);		*ppobj = This;		return S_OK;	}	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;			IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER)*ppobj);			return S_OK;		}	}        FIXME( "Unknown IID %s\n", debugstr_guid( riid ) );	return E_NOINTERFACE;}static ULONG WINAPI IDirectSound3DListenerImpl_AddRef(LPDIRECTSOUND3DLISTENER iface){    IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;    ULONG ref = InterlockedIncrement(&(This->ref));    TRACE("(%p) ref was %ld\n", This, ref - 1);    return ref;}static ULONG WINAPI IDirectSound3DListenerImpl_Release(LPDIRECTSOUND3DLISTENER iface){    IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;    ULONG ref = InterlockedDecrement(&(This->ref));    TRACE("(%p) ref was %ld\n", This, ref + 1);    if (!ref) {        This->dsound->device->listener = 0;        HeapFree(GetProcessHeap(), 0, This);        TRACE("(%p) released\n", This);    }    return ref;}/* IDirectSound3DListener methods */static HRESULT WINAPI IDirectSound3DListenerImpl_GetAllParameter(	LPDIRECTSOUND3DLISTENER iface,	LPDS3DLISTENER lpDS3DL){	IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;	TRACE("(%p,%p)\n",This,lpDS3DL);	if (lpDS3DL == NULL) {		WARN("invalid parameter: lpDS3DL == NULL\n");		return DSERR_INVALIDPARAM;	}	if (lpDS3DL->dwSize < sizeof(*lpDS3DL)) {		WARN("invalid parameter: lpDS3DL->dwSize = %ld < %d\n",lpDS3DL->dwSize, sizeof(*lpDS3DL));		return DSERR_INVALIDPARAM;	}		TRACE("returning: all parameters\n");	*lpDS3DL = This->dsound->device->ds3dl;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_GetDistanceFactor(	LPDIRECTSOUND3DLISTENER iface,	LPD3DVALUE lpfDistanceFactor){	IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;	TRACE("returning: Distance Factor = %f\n", This->dsound->device->ds3dl.flDistanceFactor);	*lpfDistanceFactor = This->dsound->device->ds3dl.flDistanceFactor;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_GetDopplerFactor(	LPDIRECTSOUND3DLISTENER iface,	LPD3DVALUE lpfDopplerFactor){	IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;	TRACE("returning: Doppler Factor = %f\n", This->dsound->device->ds3dl.flDopplerFactor);	*lpfDopplerFactor = This->dsound->device->ds3dl.flDopplerFactor;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_GetOrientation(	LPDIRECTSOUND3DLISTENER iface,	LPD3DVECTOR lpvOrientFront,	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;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_GetPosition(	LPDIRECTSOUND3DLISTENER iface,	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;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_GetRolloffFactor(	LPDIRECTSOUND3DLISTENER iface,	LPD3DVALUE lpfRolloffFactor){	IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;	TRACE("returning: RolloffFactor = %f\n", This->dsound->device->ds3dl.flRolloffFactor);	*lpfRolloffFactor = This->dsound->device->ds3dl.flRolloffFactor;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_GetVelocity(	LPDIRECTSOUND3DLISTENER iface,	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;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_SetAllParameters(	LPDIRECTSOUND3DLISTENER iface,	LPCDS3DLISTENER lpcDS3DL,	DWORD dwApply){	IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;	TRACE("setting: all parameters; dwApply = %ld\n", dwApply);	This->dsound->device->ds3dl = *lpcDS3DL;	if (dwApply == DS3D_IMMEDIATE)	{		This->dsound->device->ds3dl_need_recalc = FALSE;		DSOUND_ChangeListener(This);	}	This->dsound->device->ds3dl_need_recalc = TRUE;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_SetDistanceFactor(	LPDIRECTSOUND3DLISTENER iface,	D3DVALUE fDistanceFactor,	DWORD dwApply){	IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;	TRACE("setting: Distance Factor = %f; dwApply = %ld\n", fDistanceFactor, dwApply);	This->dsound->device->ds3dl.flDistanceFactor = fDistanceFactor;	if (dwApply == DS3D_IMMEDIATE)	{		This->dsound->device->ds3dl_need_recalc = FALSE;		DSOUND_ChangeListener(This);	}	This->dsound->device->ds3dl_need_recalc = TRUE;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_SetDopplerFactor(	LPDIRECTSOUND3DLISTENER iface,	D3DVALUE fDopplerFactor,	DWORD dwApply){	IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;	TRACE("setting: Doppler Factor = %f; dwApply = %ld\n", fDopplerFactor, dwApply);	This->dsound->device->ds3dl.flDopplerFactor = fDopplerFactor;	if (dwApply == DS3D_IMMEDIATE)	{		This->dsound->device->ds3dl_need_recalc = FALSE;		DSOUND_ChangeListener(This);	}	This->dsound->device->ds3dl_need_recalc = TRUE;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_SetOrientation(	LPDIRECTSOUND3DLISTENER iface,	D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront,	D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop,	DWORD dwApply){	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;	if (dwApply == DS3D_IMMEDIATE)	{		This->dsound->device->ds3dl_need_recalc = FALSE;		DSOUND_ChangeListener(This);	}	This->dsound->device->ds3dl_need_recalc = TRUE;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_SetPosition(	LPDIRECTSOUND3DLISTENER iface,	D3DVALUE x, D3DVALUE y, D3DVALUE z,	DWORD dwApply){	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;	if (dwApply == DS3D_IMMEDIATE)	{		This->dsound->device->ds3dl_need_recalc = FALSE;		DSOUND_ChangeListener(This);	}	This->dsound->device->ds3dl_need_recalc = TRUE;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_SetRolloffFactor(	LPDIRECTSOUND3DLISTENER iface,	D3DVALUE fRolloffFactor,	DWORD dwApply){	IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;	TRACE("setting: Rolloff Factor = %f; dwApply = %ld\n", fRolloffFactor, dwApply);	This->dsound->device->ds3dl.flRolloffFactor = fRolloffFactor;	if (dwApply == DS3D_IMMEDIATE)	{		This->dsound->device->ds3dl_need_recalc = FALSE;		DSOUND_ChangeListener(This);	}	This->dsound->device->ds3dl_need_recalc = TRUE;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_SetVelocity(	LPDIRECTSOUND3DLISTENER iface,	D3DVALUE x, D3DVALUE y, D3DVALUE z,	DWORD dwApply){	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;	if (dwApply == DS3D_IMMEDIATE)	{		This->dsound->device->ds3dl_need_recalc = FALSE;		DSOUND_ChangeListener(This);	}	This->dsound->device->ds3dl_need_recalc = TRUE;	return DS_OK;}static HRESULT WINAPI IDirectSound3DListenerImpl_CommitDeferredSettings(	LPDIRECTSOUND3DLISTENER iface){	IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;	TRACE("\n");	DSOUND_ChangeListener(This);	return DS_OK;}static const IDirectSound3DListenerVtbl ds3dlvt ={	/* IUnknown methods */	IDirectSound3DListenerImpl_QueryInterface,	IDirectSound3DListenerImpl_AddRef,	IDirectSound3DListenerImpl_Release,	/* IDirectSound3DListener methods */	IDirectSound3DListenerImpl_GetAllParameter,	IDirectSound3DListenerImpl_GetDistanceFactor,	IDirectSound3DListenerImpl_GetDopplerFactor,	IDirectSound3DListenerImpl_GetOrientation,	IDirectSound3DListenerImpl_GetPosition,	IDirectSound3DListenerImpl_GetRolloffFactor,	IDirectSound3DListenerImpl_GetVelocity,	IDirectSound3DListenerImpl_SetAllParameters,	IDirectSound3DListenerImpl_SetDistanceFactor,	IDirectSound3DListenerImpl_SetDopplerFactor,	IDirectSound3DListenerImpl_SetOrientation,	IDirectSound3DListenerImpl_SetPosition,	IDirectSound3DListenerImpl_SetRolloffFactor,	IDirectSound3DListenerImpl_SetVelocity,	IDirectSound3DListenerImpl_CommitDeferredSettings,};HRESULT WINAPI IDirectSound3DListenerImpl_Create(	PrimaryBufferImpl *This,	IDirectSound3DListenerImpl **pdsl){	IDirectSound3DListenerImpl *dsl;	TRACE("(%p,%p)\n",This,pdsl);	dsl = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*dsl));	if (dsl == NULL) {		WARN("out of memory\n");		*pdsl = 0;		return DSERR_OUTOFMEMORY;	}	dsl->ref = 0;	dsl->lpVtbl = &ds3dlvt;	dsl->dsound = This->dsound;	dsl->dsound->device->ds3dl.dwSize = sizeof(DS3DLISTENER);	dsl->dsound->device->ds3dl.vPosition.x = 0.0;	dsl->dsound->device->ds3dl.vPosition.y = 0.0;	dsl->dsound->device->ds3dl.vPosition.z = 0.0;	dsl->dsound->device->ds3dl.vVelocity.x = 0.0;	dsl->dsound->device->ds3dl.vVelocity.y = 0.0;	dsl->dsound->device->ds3dl.vVelocity.z = 0.0;	dsl->dsound->device->ds3dl.vOrientFront.x = 0.0;	dsl->dsound->device->ds3dl.vOrientFront.y = 0.0;	dsl->dsound->device->ds3dl.vOrientFront.z = 1.0;	dsl->dsound->device->ds3dl.vOrientTop.x = 0.0;	dsl->dsound->device->ds3dl.vOrientTop.y = 1.0;	dsl->dsound->device->ds3dl.vOrientTop.z = 0.0;	dsl->dsound->device->ds3dl.flDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;	dsl->dsound->device->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;	dsl->dsound->device->ds3dl.flDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;	dsl->dsound->device->ds3dl_need_recalc = TRUE;	*pdsl = dsl;	return S_OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -