3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998 Rob Riggs
5 * Copyright 2000-2001 TransGaming Technologies, Inc.
6 * Copyright 2002-2003 Rok Mandeljc <rok.mandeljc@gimb.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * Most thread locking is complete. There may be a few race
24 * conditions still lurking.
26 * Tested with a Soundblaster clone, a Gravis UltraSound Classic,
27 * and a Turtle Beach Tropez+.
30 * Implement SetCooperativeLevel properly (need to address focus issues)
31 * Implement DirectSound3DBuffers (stubs in place)
32 * Use hardware 3D support if available
33 * Add critical section locking inside Release and AddRef methods
34 * Handle static buffers - put those in hardware, non-static not in hardware
35 * Hardware DuplicateSoundBuffer
36 * Proper volume calculation, and setting volume in HEL primary buffer
37 * Optimize WINMM and negotiate fragment size, decrease DS_HEL_MARGIN
40 #include "dsound_private.h"
42 /* default velocity of sound in the air */
43 #define DEFAULT_VELOCITY 340
45 /*******************************************************************************
49 /* scalar product (I believe it's called dot product in English) */
50 static inline D3DVALUE
ScalarProduct (const D3DVECTOR
*a
, const D3DVECTOR
*b
)
53 c
= (a
->x
*b
->x
) + (a
->y
*b
->y
) + (a
->z
*b
->z
);
54 TRACE("(%f,%f,%f) * (%f,%f,%f) = %f)\n", a
->x
, a
->y
, a
->z
, b
->x
, b
->y
,
59 /* vector product (I believe it's called cross product in English */
60 static inline D3DVECTOR
VectorProduct (const D3DVECTOR
*a
, const D3DVECTOR
*b
)
63 c
.x
= (a
->y
*b
->z
) - (a
->z
*b
->y
);
64 c
.y
= (a
->z
*b
->x
) - (a
->x
*b
->z
);
65 c
.z
= (a
->x
*b
->y
) - (a
->y
*b
->x
);
66 TRACE("(%f,%f,%f) x (%f,%f,%f) = (%f,%f,%f)\n", a
->x
, a
->y
, a
->z
, b
->x
, b
->y
,
71 /* magnitude (length) of vector */
72 static inline D3DVALUE
VectorMagnitude (const D3DVECTOR
*a
)
75 l
= sqrt (ScalarProduct (a
, a
));
76 TRACE("|(%f,%f,%f)| = %f\n", a
->x
, a
->y
, a
->z
, l
);
80 /* conversion between radians and degrees */
81 static inline D3DVALUE
RadToDeg (D3DVALUE angle
)
84 newangle
= angle
* (360/(2*M_PI
));
85 TRACE("%f rad = %f deg\n", angle
, newangle
);
89 /* angle between vectors - rad version */
90 static inline D3DVALUE
AngleBetweenVectorsRad (const D3DVECTOR
*a
, const D3DVECTOR
*b
)
92 D3DVALUE la
, lb
, product
, angle
, cos
;
93 /* definition of scalar product: a*b = |a|*|b|*cos... therefore: */
94 product
= ScalarProduct (a
,b
);
95 la
= VectorMagnitude (a
);
96 lb
= VectorMagnitude (b
);
100 cos
= product
/(la
*lb
);
102 TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f radians (%f degrees)\n", a
->x
, a
->y
, a
->z
, b
->x
,
103 b
->y
, b
->z
, angle
, RadToDeg(angle
));
107 static inline D3DVALUE
AngleBetweenVectorsDeg (const D3DVECTOR
*a
, const D3DVECTOR
*b
)
109 return RadToDeg(AngleBetweenVectorsRad(a
, b
));
112 /* calculates vector between two points */
113 static inline D3DVECTOR
VectorBetweenTwoPoints (const D3DVECTOR
*a
, const D3DVECTOR
*b
)
119 TRACE("A (%f,%f,%f), B (%f,%f,%f), AB = (%f,%f,%f)\n", a
->x
, a
->y
, a
->z
, b
->x
, b
->y
,
120 b
->z
, c
.x
, c
.y
, c
.z
);
125 /* calculates the length of vector's projection on another vector */
126 static inline D3DVALUE
ProjectVector (const D3DVECTOR
*a
, const D3DVECTOR
*p
)
128 D3DVALUE prod
, result
;
129 prod
= ScalarProduct(a
, p
);
130 result
= prod
/VectorMagnitude(p
);
131 TRACE("length projection of (%f,%f,%f) on (%f,%f,%f) = %f\n", a
->x
, a
->y
, a
->z
, p
->x
,
137 /*******************************************************************************
138 * 3D Buffer and Listener mixing
141 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl
*dsb
)
143 /* volume, at which the sound will be played after all calcs. */
144 D3DVALUE lVolume
= 0;
145 /* stuff for distance related stuff calc. */
147 D3DVALUE flDistance
= 0;
148 /* panning related stuff */
151 /* doppler shift related stuff */
153 D3DVALUE flFreq
, flBufferVel
, flListenerVel
;
158 /* initial buffer volume */
159 lVolume
= dsb
->ds3db_lVolume
;
161 switch (dsb
->ds3db_ds3db
.dwMode
)
163 case DS3DMODE_DISABLE
:
164 TRACE("3D processing disabled\n");
165 /* this one is here only to eliminate annoying warning message */
166 DSOUND_RecalcVolPan (&dsb
->volpan
);
168 case DS3DMODE_NORMAL
:
169 TRACE("Normal 3D processing mode\n");
170 /* we need to calculate distance between buffer and listener*/
171 vDistance
= VectorBetweenTwoPoints(&dsb
->ds3db_ds3db
.vPosition
, &dsb
->device
->ds3dl
.vPosition
);
172 flDistance
= VectorMagnitude (&vDistance
);
174 case DS3DMODE_HEADRELATIVE
:
175 TRACE("Head-relative 3D processing mode\n");
176 /* distance between buffer and listener is same as buffer's position */
177 flDistance
= VectorMagnitude (&dsb
->ds3db_ds3db
.vPosition
);
181 if (flDistance
> dsb
->ds3db_ds3db
.flMaxDistance
)
183 /* some apps don't want you to hear too distant sounds... */
184 if (dsb
->dsbd
.dwFlags
& DSBCAPS_MUTE3DATMAXDISTANCE
)
186 dsb
->volpan
.lVolume
= DSBVOLUME_MIN
;
187 DSOUND_RecalcVolPan (&dsb
->volpan
);
188 /* i guess mixing here would be a waste of power */
192 flDistance
= dsb
->ds3db_ds3db
.flMaxDistance
;
195 if (flDistance
< dsb
->ds3db_ds3db
.flMinDistance
)
196 flDistance
= dsb
->ds3db_ds3db
.flMinDistance
;
198 /* attenuation proportional to the distance squared, converted to millibels as in lVolume*/
199 lVolume
-= log10(flDistance
/dsb
->ds3db_ds3db
.flMinDistance
* flDistance
/dsb
->ds3db_ds3db
.flMinDistance
)*1000;
200 TRACE("dist. att: Distance = %f, MinDistance = %f => adjusting volume %d to %f\n", flDistance
, dsb
->ds3db_ds3db
.flMinDistance
, dsb
->ds3db_lVolume
, lVolume
);
203 /* sometimes it happens that vConeOrientation vector = (0,0,0); in this case angle is "nan" and it's useless*/
204 if (dsb
->ds3db_ds3db
.vConeOrientation
.x
== 0 && dsb
->ds3db_ds3db
.vConeOrientation
.y
== 0 && dsb
->ds3db_ds3db
.vConeOrientation
.z
== 0)
206 TRACE("conning: cones not set\n");
210 /* calculate angle */
211 flAngle
= AngleBetweenVectorsDeg(&dsb
->ds3db_ds3db
.vConeOrientation
, &vDistance
);
212 /* if by any chance it happens that OutsideConeAngle = InsideConeAngle (that means that conning has no effect) */
213 if (dsb
->ds3db_ds3db
.dwInsideConeAngle
!= dsb
->ds3db_ds3db
.dwOutsideConeAngle
)
215 /* my test show that for my way of calc., we need only half of angles */
216 DWORD dwInsideConeAngle
= dsb
->ds3db_ds3db
.dwInsideConeAngle
/2;
217 DWORD dwOutsideConeAngle
= dsb
->ds3db_ds3db
.dwOutsideConeAngle
/2;
218 if (dwOutsideConeAngle
== dwInsideConeAngle
)
219 ++dwOutsideConeAngle
;
222 if (flAngle
< dwInsideConeAngle
)
223 flAngle
= dwInsideConeAngle
;
224 /* min (app defined) volume */
225 if (flAngle
> dwOutsideConeAngle
)
226 flAngle
= dwOutsideConeAngle
;
227 /* this probably isn't the right thing, but it's ok for the time being */
228 lVolume
+= ((dsb
->ds3db_ds3db
.lConeOutsideVolume
)/((dwOutsideConeAngle
) - (dwInsideConeAngle
))) * flAngle
;
230 TRACE("conning: Angle = %f deg; InsideConeAngle(/2) = %d deg; OutsideConeAngle(/2) = %d deg; ConeOutsideVolume = %d => adjusting volume to %f\n",
231 flAngle
, dsb
->ds3db_ds3db
.dwInsideConeAngle
/2, dsb
->ds3db_ds3db
.dwOutsideConeAngle
/2, dsb
->ds3db_ds3db
.lConeOutsideVolume
, lVolume
);
233 dsb
->volpan
.lVolume
= lVolume
;
236 if (dsb
->device
->ds3dl
.vPosition
.x
== dsb
->ds3db_ds3db
.vPosition
.x
&&
237 dsb
->device
->ds3dl
.vPosition
.y
== dsb
->ds3db_ds3db
.vPosition
.y
&&
238 dsb
->device
->ds3dl
.vPosition
.z
== dsb
->ds3db_ds3db
.vPosition
.z
) {
239 dsb
->volpan
.lPan
= 0;
244 vDistance
= VectorBetweenTwoPoints(&dsb
->device
->ds3dl
.vPosition
, &dsb
->ds3db_ds3db
.vPosition
);
245 vLeft
= VectorProduct(&dsb
->device
->ds3dl
.vOrientFront
, &dsb
->device
->ds3dl
.vOrientTop
);
246 flAngle
= AngleBetweenVectorsRad(&vLeft
, &vDistance
);
247 /* for now, we'll use "linear formula" (which is probably incorrect); if someone has it in book, correct it */
248 dsb
->volpan
.lPan
= 10000*2*flAngle
/M_PI
- 10000;
250 TRACE("panning: Angle = %f rad, lPan = %d\n", flAngle
, dsb
->volpan
.lPan
);
252 /* FIXME: Doppler Effect disabled since i have no idea which frequency to change and how to do it */
255 if ((VectorMagnitude(&ds3db_ds3db
.vVelocity
) == 0) && (VectorMagnitude(&dsb
->device
->ds3dl
.vVelocity
) == 0))
257 TRACE("doppler: Buffer and Listener don't have velocities\n");
259 else if (ds3db_ds3db
.vVelocity
!= dsb
->device
->ds3dl
.vVelocity
)
261 /* calculate length of ds3db_ds3db.vVelocity component which causes Doppler Effect
262 NOTE: if buffer moves TOWARDS the listener, it's velocity component is NEGATIVE
263 if buffer moves AWAY from listener, it's velocity component is POSITIVE */
264 flBufferVel
= ProjectVector(&dsb
->ds3db_ds3db
.vVelocity
, &vDistance
);
265 /* calculate length of ds3dl.vVelocity component which causes Doppler Effect
266 NOTE: if listener moves TOWARDS the buffer, it's velocity component is POSITIVE
267 if listener moves AWAY from buffer, it's velocity component is NEGATIVE */
268 flListenerVel
= ProjectVector(&dsb
->device
->ds3dl
.vVelocity
, &vDistance
);
269 /* formula taken from Gianicoli D.: Physics, 4th edition: */
270 /* FIXME: replace dsb->freq with appropriate frequency ! */
271 flFreq
= dsb
->freq
* ((DEFAULT_VELOCITY
+ flListenerVel
)/(DEFAULT_VELOCITY
+ flBufferVel
));
272 TRACE("doppler: Buffer velocity (component) = %lf, Listener velocity (component) = %lf => Doppler shift: %ld Hz -> %lf Hz\n", flBufferVel
, flListenerVel
,
274 /* FIXME: replace following line with correct frequency setting ! */
276 DSOUND_RecalcFormat(dsb
);
277 DSOUND_MixToTemporary(dsb
, 0, dsb
->buflen
);
282 DSOUND_RecalcVolPan(&dsb
->volpan
);
285 static void DSOUND_Mix3DBuffer(IDirectSoundBufferImpl
*dsb
)
289 DSOUND_Calc3DBuffer(dsb
);
292 static void DSOUND_ChangeListener(IDirectSound3DListenerImpl
*ds3dl
)
295 TRACE("(%p)\n",ds3dl
);
296 for (i
= 0; i
< ds3dl
->device
->nrofbuffers
; i
++)
298 /* check if this buffer is waiting for recalculation */
299 if (ds3dl
->device
->buffers
[i
]->ds3db_need_recalc
)
301 DSOUND_Mix3DBuffer(ds3dl
->device
->buffers
[i
]);
306 /*******************************************************************************
307 * IDirectSound3DBuffer
310 /* IUnknown methods */
311 static HRESULT WINAPI
IDirectSound3DBufferImpl_QueryInterface(
312 LPDIRECTSOUND3DBUFFER iface
, REFIID riid
, LPVOID
*ppobj
)
314 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
316 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
317 return IDirectSoundBuffer_QueryInterface((LPDIRECTSOUNDBUFFER8
)This
->dsb
, riid
, ppobj
);
320 static ULONG WINAPI
IDirectSound3DBufferImpl_AddRef(LPDIRECTSOUND3DBUFFER iface
)
322 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
323 ULONG ref
= InterlockedIncrement(&(This
->ref
));
325 TRACE("(%p) ref was %d\n", This
, ref
- 1);
328 InterlockedIncrement(&This
->dsb
->numIfaces
);
333 static ULONG WINAPI
IDirectSound3DBufferImpl_Release(LPDIRECTSOUND3DBUFFER iface
)
335 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
336 ULONG ref
= InterlockedDecrement(&(This
->ref
));
337 TRACE("(%p) ref was %d\n", This
, ref
+ 1);
340 This
->dsb
->ds3db
= NULL
;
341 if (!InterlockedDecrement(&This
->dsb
->numIfaces
))
342 secondarybuffer_destroy(This
->dsb
);
343 HeapFree(GetProcessHeap(), 0, This
);
344 TRACE("(%p) released\n", This
);
349 /* IDirectSound3DBuffer methods */
350 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetAllParameters(
351 LPDIRECTSOUND3DBUFFER iface
,
352 LPDS3DBUFFER lpDs3dBuffer
)
354 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
355 TRACE("(%p,%p)\n",This
,lpDs3dBuffer
);
357 if (lpDs3dBuffer
== NULL
) {
358 WARN("invalid parameter: lpDs3dBuffer == NULL\n");
359 return DSERR_INVALIDPARAM
;
362 if (lpDs3dBuffer
->dwSize
< sizeof(*lpDs3dBuffer
)) {
363 WARN("invalid parameter: lpDs3dBuffer->dwSize = %d\n",lpDs3dBuffer
->dwSize
);
364 return DSERR_INVALIDPARAM
;
367 TRACE("returning: all parameters\n");
368 *lpDs3dBuffer
= This
->dsb
->ds3db_ds3db
;
372 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetConeAngles(
373 LPDIRECTSOUND3DBUFFER iface
,
374 LPDWORD lpdwInsideConeAngle
,
375 LPDWORD lpdwOutsideConeAngle
)
377 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
378 TRACE("returning: Inside Cone Angle = %d degrees; Outside Cone Angle = %d degrees\n",
379 This
->dsb
->ds3db_ds3db
.dwInsideConeAngle
, This
->dsb
->ds3db_ds3db
.dwOutsideConeAngle
);
380 *lpdwInsideConeAngle
= This
->dsb
->ds3db_ds3db
.dwInsideConeAngle
;
381 *lpdwOutsideConeAngle
= This
->dsb
->ds3db_ds3db
.dwOutsideConeAngle
;
385 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetConeOrientation(
386 LPDIRECTSOUND3DBUFFER iface
,
387 LPD3DVECTOR lpvConeOrientation
)
389 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
390 TRACE("returning: Cone Orientation vector = (%f,%f,%f)\n",
391 This
->dsb
->ds3db_ds3db
.vConeOrientation
.x
,
392 This
->dsb
->ds3db_ds3db
.vConeOrientation
.y
,
393 This
->dsb
->ds3db_ds3db
.vConeOrientation
.z
);
394 *lpvConeOrientation
= This
->dsb
->ds3db_ds3db
.vConeOrientation
;
398 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetConeOutsideVolume(
399 LPDIRECTSOUND3DBUFFER iface
,
400 LPLONG lplConeOutsideVolume
)
402 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
403 TRACE("returning: Cone Outside Volume = %d\n", This
->dsb
->ds3db_ds3db
.lConeOutsideVolume
);
404 *lplConeOutsideVolume
= This
->dsb
->ds3db_ds3db
.lConeOutsideVolume
;
408 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetMaxDistance(
409 LPDIRECTSOUND3DBUFFER iface
,
410 LPD3DVALUE lpfMaxDistance
)
412 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
413 TRACE("returning: Max Distance = %f\n", This
->dsb
->ds3db_ds3db
.flMaxDistance
);
414 *lpfMaxDistance
= This
->dsb
->ds3db_ds3db
.flMaxDistance
;
418 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetMinDistance(
419 LPDIRECTSOUND3DBUFFER iface
,
420 LPD3DVALUE lpfMinDistance
)
422 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
423 TRACE("returning: Min Distance = %f\n", This
->dsb
->ds3db_ds3db
.flMinDistance
);
424 *lpfMinDistance
= This
->dsb
->ds3db_ds3db
.flMinDistance
;
428 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetMode(
429 LPDIRECTSOUND3DBUFFER iface
,
432 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
433 TRACE("returning: Mode = %d\n", This
->dsb
->ds3db_ds3db
.dwMode
);
434 *lpdwMode
= This
->dsb
->ds3db_ds3db
.dwMode
;
438 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetPosition(
439 LPDIRECTSOUND3DBUFFER iface
,
440 LPD3DVECTOR lpvPosition
)
442 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
443 TRACE("returning: Position vector = (%f,%f,%f)\n",
444 This
->dsb
->ds3db_ds3db
.vPosition
.x
,
445 This
->dsb
->ds3db_ds3db
.vPosition
.y
,
446 This
->dsb
->ds3db_ds3db
.vPosition
.z
);
447 *lpvPosition
= This
->dsb
->ds3db_ds3db
.vPosition
;
451 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetVelocity(
452 LPDIRECTSOUND3DBUFFER iface
,
453 LPD3DVECTOR lpvVelocity
)
455 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
456 TRACE("returning: Velocity vector = (%f,%f,%f)\n",
457 This
->dsb
->ds3db_ds3db
.vVelocity
.x
,
458 This
->dsb
->ds3db_ds3db
.vVelocity
.y
,
459 This
->dsb
->ds3db_ds3db
.vVelocity
.z
);
460 *lpvVelocity
= This
->dsb
->ds3db_ds3db
.vVelocity
;
464 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetAllParameters(
465 LPDIRECTSOUND3DBUFFER iface
,
466 LPCDS3DBUFFER lpcDs3dBuffer
,
469 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
470 DWORD status
= DSERR_INVALIDPARAM
;
471 TRACE("(%p,%p,%x)\n",iface
,lpcDs3dBuffer
,dwApply
);
473 if (lpcDs3dBuffer
== NULL
) {
474 WARN("invalid parameter: lpcDs3dBuffer == NULL\n");
478 if (lpcDs3dBuffer
->dwSize
!= sizeof(DS3DBUFFER
)) {
479 WARN("invalid parameter: lpcDs3dBuffer->dwSize = %d\n", lpcDs3dBuffer
->dwSize
);
483 TRACE("setting: all parameters; dwApply = %d\n", dwApply
);
484 This
->dsb
->ds3db_ds3db
= *lpcDs3dBuffer
;
486 if (dwApply
== DS3D_IMMEDIATE
)
488 DSOUND_Mix3DBuffer(This
->dsb
);
490 This
->dsb
->ds3db_need_recalc
= TRUE
;
496 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetConeAngles(
497 LPDIRECTSOUND3DBUFFER iface
,
498 DWORD dwInsideConeAngle
,
499 DWORD dwOutsideConeAngle
,
502 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
503 TRACE("setting: Inside Cone Angle = %d; Outside Cone Angle = %d; dwApply = %d\n",
504 dwInsideConeAngle
, dwOutsideConeAngle
, dwApply
);
505 This
->dsb
->ds3db_ds3db
.dwInsideConeAngle
= dwInsideConeAngle
;
506 This
->dsb
->ds3db_ds3db
.dwOutsideConeAngle
= dwOutsideConeAngle
;
507 if (dwApply
== DS3D_IMMEDIATE
)
509 DSOUND_Mix3DBuffer(This
->dsb
);
511 This
->dsb
->ds3db_need_recalc
= TRUE
;
515 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetConeOrientation(
516 LPDIRECTSOUND3DBUFFER iface
,
517 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
,
520 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
521 TRACE("setting: Cone Orientation vector = (%f,%f,%f); dwApply = %d\n", x
, y
, z
, dwApply
);
522 This
->dsb
->ds3db_ds3db
.vConeOrientation
.x
= x
;
523 This
->dsb
->ds3db_ds3db
.vConeOrientation
.y
= y
;
524 This
->dsb
->ds3db_ds3db
.vConeOrientation
.z
= z
;
525 if (dwApply
== DS3D_IMMEDIATE
)
527 This
->dsb
->ds3db_need_recalc
= FALSE
;
528 DSOUND_Mix3DBuffer(This
->dsb
);
530 This
->dsb
->ds3db_need_recalc
= TRUE
;
534 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetConeOutsideVolume(
535 LPDIRECTSOUND3DBUFFER iface
,
536 LONG lConeOutsideVolume
,
539 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
540 TRACE("setting: ConeOutsideVolume = %d; dwApply = %d\n", lConeOutsideVolume
, dwApply
);
541 This
->dsb
->ds3db_ds3db
.lConeOutsideVolume
= lConeOutsideVolume
;
542 if (dwApply
== DS3D_IMMEDIATE
)
544 This
->dsb
->ds3db_need_recalc
= FALSE
;
545 DSOUND_Mix3DBuffer(This
->dsb
);
547 This
->dsb
->ds3db_need_recalc
= TRUE
;
551 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetMaxDistance(
552 LPDIRECTSOUND3DBUFFER iface
,
553 D3DVALUE fMaxDistance
,
556 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
557 TRACE("setting: MaxDistance = %f; dwApply = %d\n", fMaxDistance
, dwApply
);
558 This
->dsb
->ds3db_ds3db
.flMaxDistance
= fMaxDistance
;
559 if (dwApply
== DS3D_IMMEDIATE
)
561 This
->dsb
->ds3db_need_recalc
= FALSE
;
562 DSOUND_Mix3DBuffer(This
->dsb
);
564 This
->dsb
->ds3db_need_recalc
= TRUE
;
568 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetMinDistance(
569 LPDIRECTSOUND3DBUFFER iface
,
570 D3DVALUE fMinDistance
,
573 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
574 TRACE("setting: MinDistance = %f; dwApply = %d\n", fMinDistance
, dwApply
);
575 This
->dsb
->ds3db_ds3db
.flMinDistance
= fMinDistance
;
576 if (dwApply
== DS3D_IMMEDIATE
)
578 This
->dsb
->ds3db_need_recalc
= FALSE
;
579 DSOUND_Mix3DBuffer(This
->dsb
);
581 This
->dsb
->ds3db_need_recalc
= TRUE
;
585 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetMode(
586 LPDIRECTSOUND3DBUFFER iface
,
590 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
591 TRACE("setting: Mode = %d; dwApply = %d\n", dwMode
, dwApply
);
592 This
->dsb
->ds3db_ds3db
.dwMode
= dwMode
;
593 if (dwApply
== DS3D_IMMEDIATE
)
595 This
->dsb
->ds3db_need_recalc
= FALSE
;
596 DSOUND_Mix3DBuffer(This
->dsb
);
598 This
->dsb
->ds3db_need_recalc
= TRUE
;
602 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetPosition(
603 LPDIRECTSOUND3DBUFFER iface
,
604 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
,
607 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
608 TRACE("setting: Position vector = (%f,%f,%f); dwApply = %d\n", x
, y
, z
, dwApply
);
609 This
->dsb
->ds3db_ds3db
.vPosition
.x
= x
;
610 This
->dsb
->ds3db_ds3db
.vPosition
.y
= y
;
611 This
->dsb
->ds3db_ds3db
.vPosition
.z
= z
;
612 if (dwApply
== DS3D_IMMEDIATE
)
614 This
->dsb
->ds3db_need_recalc
= FALSE
;
615 DSOUND_Mix3DBuffer(This
->dsb
);
617 This
->dsb
->ds3db_need_recalc
= TRUE
;
621 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetVelocity(
622 LPDIRECTSOUND3DBUFFER iface
,
623 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
,
626 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
627 TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %d\n", x
, y
, z
, dwApply
);
628 This
->dsb
->ds3db_ds3db
.vVelocity
.x
= x
;
629 This
->dsb
->ds3db_ds3db
.vVelocity
.y
= y
;
630 This
->dsb
->ds3db_ds3db
.vVelocity
.z
= z
;
631 if (dwApply
== DS3D_IMMEDIATE
)
633 This
->dsb
->ds3db_need_recalc
= FALSE
;
634 DSOUND_Mix3DBuffer(This
->dsb
);
636 This
->dsb
->ds3db_need_recalc
= TRUE
;
640 static const IDirectSound3DBufferVtbl ds3dbvt
=
642 /* IUnknown methods */
643 IDirectSound3DBufferImpl_QueryInterface
,
644 IDirectSound3DBufferImpl_AddRef
,
645 IDirectSound3DBufferImpl_Release
,
646 /* IDirectSound3DBuffer methods */
647 IDirectSound3DBufferImpl_GetAllParameters
,
648 IDirectSound3DBufferImpl_GetConeAngles
,
649 IDirectSound3DBufferImpl_GetConeOrientation
,
650 IDirectSound3DBufferImpl_GetConeOutsideVolume
,
651 IDirectSound3DBufferImpl_GetMaxDistance
,
652 IDirectSound3DBufferImpl_GetMinDistance
,
653 IDirectSound3DBufferImpl_GetMode
,
654 IDirectSound3DBufferImpl_GetPosition
,
655 IDirectSound3DBufferImpl_GetVelocity
,
656 IDirectSound3DBufferImpl_SetAllParameters
,
657 IDirectSound3DBufferImpl_SetConeAngles
,
658 IDirectSound3DBufferImpl_SetConeOrientation
,
659 IDirectSound3DBufferImpl_SetConeOutsideVolume
,
660 IDirectSound3DBufferImpl_SetMaxDistance
,
661 IDirectSound3DBufferImpl_SetMinDistance
,
662 IDirectSound3DBufferImpl_SetMode
,
663 IDirectSound3DBufferImpl_SetPosition
,
664 IDirectSound3DBufferImpl_SetVelocity
,
667 HRESULT
IDirectSound3DBufferImpl_Create(
668 IDirectSoundBufferImpl
*dsb
,
669 IDirectSound3DBufferImpl
**pds3db
)
671 IDirectSound3DBufferImpl
*ds3db
;
672 TRACE("(%p,%p)\n",dsb
,pds3db
);
674 ds3db
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(*ds3db
));
677 WARN("out of memory\n");
679 return DSERR_OUTOFMEMORY
;
684 ds3db
->lpVtbl
= &ds3dbvt
;
686 ds3db
->dsb
->ds3db_ds3db
.dwSize
= sizeof(DS3DBUFFER
);
687 ds3db
->dsb
->ds3db_ds3db
.vPosition
.x
= 0.0;
688 ds3db
->dsb
->ds3db_ds3db
.vPosition
.y
= 0.0;
689 ds3db
->dsb
->ds3db_ds3db
.vPosition
.z
= 0.0;
690 ds3db
->dsb
->ds3db_ds3db
.vVelocity
.x
= 0.0;
691 ds3db
->dsb
->ds3db_ds3db
.vVelocity
.y
= 0.0;
692 ds3db
->dsb
->ds3db_ds3db
.vVelocity
.z
= 0.0;
693 ds3db
->dsb
->ds3db_ds3db
.dwInsideConeAngle
= DS3D_DEFAULTCONEANGLE
;
694 ds3db
->dsb
->ds3db_ds3db
.dwOutsideConeAngle
= DS3D_DEFAULTCONEANGLE
;
695 ds3db
->dsb
->ds3db_ds3db
.vConeOrientation
.x
= 0.0;
696 ds3db
->dsb
->ds3db_ds3db
.vConeOrientation
.y
= 0.0;
697 ds3db
->dsb
->ds3db_ds3db
.vConeOrientation
.z
= 0.0;
698 ds3db
->dsb
->ds3db_ds3db
.lConeOutsideVolume
= DS3D_DEFAULTCONEOUTSIDEVOLUME
;
699 ds3db
->dsb
->ds3db_ds3db
.flMinDistance
= DS3D_DEFAULTMINDISTANCE
;
700 ds3db
->dsb
->ds3db_ds3db
.flMaxDistance
= DS3D_DEFAULTMAXDISTANCE
;
701 ds3db
->dsb
->ds3db_ds3db
.dwMode
= DS3DMODE_NORMAL
;
703 ds3db
->dsb
->ds3db_need_recalc
= TRUE
;
709 HRESULT
IDirectSound3DBufferImpl_Destroy(
710 IDirectSound3DBufferImpl
*pds3db
)
712 TRACE("(%p)\n",pds3db
);
714 while (IDirectSound3DBufferImpl_Release((LPDIRECTSOUND3DBUFFER
)pds3db
) > 0);
719 /*******************************************************************************
720 * IDirectSound3DListener
723 /* IUnknown methods */
724 static HRESULT WINAPI
IDirectSound3DListenerImpl_QueryInterface(
725 LPDIRECTSOUND3DLISTENER iface
, REFIID riid
, LPVOID
*ppobj
)
727 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
729 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
732 WARN("invalid parameter\n");
736 *ppobj
= NULL
; /* assume failure */
738 if ( IsEqualGUID(riid
, &IID_IUnknown
) ||
739 IsEqualGUID(riid
, &IID_IDirectSound3DListener
) ) {
740 IDirectSound3DListener_AddRef((LPDIRECTSOUND3DLISTENER
)This
);
745 if ( IsEqualGUID(riid
, &IID_IDirectSoundBuffer
) ) {
746 *ppobj
= &This
->device
->primary
->IDirectSoundBuffer8_iface
;
747 IDirectSoundBuffer8_AddRef(&This
->device
->primary
->IDirectSoundBuffer8_iface
);
751 FIXME( "Unknown IID %s\n", debugstr_guid( riid
) );
752 return E_NOINTERFACE
;
755 static ULONG WINAPI
IDirectSound3DListenerImpl_AddRef(LPDIRECTSOUND3DLISTENER iface
)
757 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
758 ULONG ref
= InterlockedIncrement(&(This
->ref
));
760 TRACE("(%p) ref was %d\n", This
, ref
- 1);
763 InterlockedIncrement(&This
->device
->primary
->numIfaces
);
768 static ULONG WINAPI
IDirectSound3DListenerImpl_Release(LPDIRECTSOUND3DLISTENER iface
)
770 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
771 ULONG ref
= InterlockedDecrement(&(This
->ref
));
772 TRACE("(%p) ref was %d\n", This
, ref
+ 1);
775 This
->device
->listener
= 0;
776 if (!InterlockedDecrement(&This
->device
->primary
->numIfaces
))
777 primarybuffer_destroy(This
->device
->primary
);
778 HeapFree(GetProcessHeap(), 0, This
);
779 TRACE("(%p) released\n", This
);
784 /* IDirectSound3DListener methods */
785 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetAllParameter(
786 LPDIRECTSOUND3DLISTENER iface
,
787 LPDS3DLISTENER lpDS3DL
)
789 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
790 TRACE("(%p,%p)\n",This
,lpDS3DL
);
792 if (lpDS3DL
== NULL
) {
793 WARN("invalid parameter: lpDS3DL == NULL\n");
794 return DSERR_INVALIDPARAM
;
797 if (lpDS3DL
->dwSize
< sizeof(*lpDS3DL
)) {
798 WARN("invalid parameter: lpDS3DL->dwSize = %d\n",lpDS3DL
->dwSize
);
799 return DSERR_INVALIDPARAM
;
802 TRACE("returning: all parameters\n");
803 *lpDS3DL
= This
->device
->ds3dl
;
807 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetDistanceFactor(
808 LPDIRECTSOUND3DLISTENER iface
,
809 LPD3DVALUE lpfDistanceFactor
)
811 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
812 TRACE("returning: Distance Factor = %f\n", This
->device
->ds3dl
.flDistanceFactor
);
813 *lpfDistanceFactor
= This
->device
->ds3dl
.flDistanceFactor
;
817 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetDopplerFactor(
818 LPDIRECTSOUND3DLISTENER iface
,
819 LPD3DVALUE lpfDopplerFactor
)
821 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
822 TRACE("returning: Doppler Factor = %f\n", This
->device
->ds3dl
.flDopplerFactor
);
823 *lpfDopplerFactor
= This
->device
->ds3dl
.flDopplerFactor
;
827 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetOrientation(
828 LPDIRECTSOUND3DLISTENER iface
,
829 LPD3DVECTOR lpvOrientFront
,
830 LPD3DVECTOR lpvOrientTop
)
832 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
833 TRACE("returning: OrientFront vector = (%f,%f,%f); OrientTop vector = (%f,%f,%f)\n", This
->device
->ds3dl
.vOrientFront
.x
,
834 This
->device
->ds3dl
.vOrientFront
.y
, This
->device
->ds3dl
.vOrientFront
.z
, This
->device
->ds3dl
.vOrientTop
.x
, This
->device
->ds3dl
.vOrientTop
.y
,
835 This
->device
->ds3dl
.vOrientTop
.z
);
836 *lpvOrientFront
= This
->device
->ds3dl
.vOrientFront
;
837 *lpvOrientTop
= This
->device
->ds3dl
.vOrientTop
;
841 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetPosition(
842 LPDIRECTSOUND3DLISTENER iface
,
843 LPD3DVECTOR lpvPosition
)
845 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
846 TRACE("returning: Position vector = (%f,%f,%f)\n", This
->device
->ds3dl
.vPosition
.x
, This
->device
->ds3dl
.vPosition
.y
, This
->device
->ds3dl
.vPosition
.z
);
847 *lpvPosition
= This
->device
->ds3dl
.vPosition
;
851 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetRolloffFactor(
852 LPDIRECTSOUND3DLISTENER iface
,
853 LPD3DVALUE lpfRolloffFactor
)
855 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
856 TRACE("returning: RolloffFactor = %f\n", This
->device
->ds3dl
.flRolloffFactor
);
857 *lpfRolloffFactor
= This
->device
->ds3dl
.flRolloffFactor
;
861 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetVelocity(
862 LPDIRECTSOUND3DLISTENER iface
,
863 LPD3DVECTOR lpvVelocity
)
865 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
866 TRACE("returning: Velocity vector = (%f,%f,%f)\n", This
->device
->ds3dl
.vVelocity
.x
, This
->device
->ds3dl
.vVelocity
.y
, This
->device
->ds3dl
.vVelocity
.z
);
867 *lpvVelocity
= This
->device
->ds3dl
.vVelocity
;
871 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetAllParameters(
872 LPDIRECTSOUND3DLISTENER iface
,
873 LPCDS3DLISTENER lpcDS3DL
,
876 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
877 TRACE("setting: all parameters; dwApply = %d\n", dwApply
);
878 This
->device
->ds3dl
= *lpcDS3DL
;
879 if (dwApply
== DS3D_IMMEDIATE
)
881 This
->device
->ds3dl_need_recalc
= FALSE
;
882 DSOUND_ChangeListener(This
);
884 This
->device
->ds3dl_need_recalc
= TRUE
;
888 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetDistanceFactor(
889 LPDIRECTSOUND3DLISTENER iface
,
890 D3DVALUE fDistanceFactor
,
893 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
894 TRACE("setting: Distance Factor = %f; dwApply = %d\n", fDistanceFactor
, dwApply
);
895 This
->device
->ds3dl
.flDistanceFactor
= fDistanceFactor
;
896 if (dwApply
== DS3D_IMMEDIATE
)
898 This
->device
->ds3dl_need_recalc
= FALSE
;
899 DSOUND_ChangeListener(This
);
901 This
->device
->ds3dl_need_recalc
= TRUE
;
905 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetDopplerFactor(
906 LPDIRECTSOUND3DLISTENER iface
,
907 D3DVALUE fDopplerFactor
,
910 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
911 TRACE("setting: Doppler Factor = %f; dwApply = %d\n", fDopplerFactor
, dwApply
);
912 This
->device
->ds3dl
.flDopplerFactor
= fDopplerFactor
;
913 if (dwApply
== DS3D_IMMEDIATE
)
915 This
->device
->ds3dl_need_recalc
= FALSE
;
916 DSOUND_ChangeListener(This
);
918 This
->device
->ds3dl_need_recalc
= TRUE
;
922 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetOrientation(
923 LPDIRECTSOUND3DLISTENER iface
,
924 D3DVALUE xFront
, D3DVALUE yFront
, D3DVALUE zFront
,
925 D3DVALUE xTop
, D3DVALUE yTop
, D3DVALUE zTop
,
928 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
929 TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %d\n",
930 xFront
, yFront
, zFront
, xTop
, yTop
, zTop
, dwApply
);
931 This
->device
->ds3dl
.vOrientFront
.x
= xFront
;
932 This
->device
->ds3dl
.vOrientFront
.y
= yFront
;
933 This
->device
->ds3dl
.vOrientFront
.z
= zFront
;
934 This
->device
->ds3dl
.vOrientTop
.x
= xTop
;
935 This
->device
->ds3dl
.vOrientTop
.y
= yTop
;
936 This
->device
->ds3dl
.vOrientTop
.z
= zTop
;
937 if (dwApply
== DS3D_IMMEDIATE
)
939 This
->device
->ds3dl_need_recalc
= FALSE
;
940 DSOUND_ChangeListener(This
);
942 This
->device
->ds3dl_need_recalc
= TRUE
;
946 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetPosition(
947 LPDIRECTSOUND3DLISTENER iface
,
948 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
,
951 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
952 TRACE("setting: Position vector = (%f,%f,%f); dwApply = %d\n", x
, y
, z
, dwApply
);
953 This
->device
->ds3dl
.vPosition
.x
= x
;
954 This
->device
->ds3dl
.vPosition
.y
= y
;
955 This
->device
->ds3dl
.vPosition
.z
= z
;
956 if (dwApply
== DS3D_IMMEDIATE
)
958 This
->device
->ds3dl_need_recalc
= FALSE
;
959 DSOUND_ChangeListener(This
);
961 This
->device
->ds3dl_need_recalc
= TRUE
;
965 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetRolloffFactor(
966 LPDIRECTSOUND3DLISTENER iface
,
967 D3DVALUE fRolloffFactor
,
970 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
971 TRACE("setting: Rolloff Factor = %f; dwApply = %d\n", fRolloffFactor
, dwApply
);
972 This
->device
->ds3dl
.flRolloffFactor
= fRolloffFactor
;
973 if (dwApply
== DS3D_IMMEDIATE
)
975 This
->device
->ds3dl_need_recalc
= FALSE
;
976 DSOUND_ChangeListener(This
);
978 This
->device
->ds3dl_need_recalc
= TRUE
;
982 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetVelocity(
983 LPDIRECTSOUND3DLISTENER iface
,
984 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
,
987 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
988 TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %d\n", x
, y
, z
, dwApply
);
989 This
->device
->ds3dl
.vVelocity
.x
= x
;
990 This
->device
->ds3dl
.vVelocity
.y
= y
;
991 This
->device
->ds3dl
.vVelocity
.z
= z
;
992 if (dwApply
== DS3D_IMMEDIATE
)
994 This
->device
->ds3dl_need_recalc
= FALSE
;
995 DSOUND_ChangeListener(This
);
997 This
->device
->ds3dl_need_recalc
= TRUE
;
1001 static HRESULT WINAPI
IDirectSound3DListenerImpl_CommitDeferredSettings(
1002 LPDIRECTSOUND3DLISTENER iface
)
1004 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
1006 DSOUND_ChangeListener(This
);
1010 static const IDirectSound3DListenerVtbl ds3dlvt
=
1012 /* IUnknown methods */
1013 IDirectSound3DListenerImpl_QueryInterface
,
1014 IDirectSound3DListenerImpl_AddRef
,
1015 IDirectSound3DListenerImpl_Release
,
1016 /* IDirectSound3DListener methods */
1017 IDirectSound3DListenerImpl_GetAllParameter
,
1018 IDirectSound3DListenerImpl_GetDistanceFactor
,
1019 IDirectSound3DListenerImpl_GetDopplerFactor
,
1020 IDirectSound3DListenerImpl_GetOrientation
,
1021 IDirectSound3DListenerImpl_GetPosition
,
1022 IDirectSound3DListenerImpl_GetRolloffFactor
,
1023 IDirectSound3DListenerImpl_GetVelocity
,
1024 IDirectSound3DListenerImpl_SetAllParameters
,
1025 IDirectSound3DListenerImpl_SetDistanceFactor
,
1026 IDirectSound3DListenerImpl_SetDopplerFactor
,
1027 IDirectSound3DListenerImpl_SetOrientation
,
1028 IDirectSound3DListenerImpl_SetPosition
,
1029 IDirectSound3DListenerImpl_SetRolloffFactor
,
1030 IDirectSound3DListenerImpl_SetVelocity
,
1031 IDirectSound3DListenerImpl_CommitDeferredSettings
,
1034 HRESULT
IDirectSound3DListenerImpl_Create(
1035 DirectSoundDevice
* device
,
1036 IDirectSound3DListenerImpl
** ppdsl
)
1038 IDirectSound3DListenerImpl
*pdsl
;
1039 TRACE("(%p,%p)\n",device
,ppdsl
);
1041 pdsl
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(*pdsl
));
1044 WARN("out of memory\n");
1046 return DSERR_OUTOFMEMORY
;
1050 pdsl
->lpVtbl
= &ds3dlvt
;
1052 pdsl
->device
= device
;
1054 pdsl
->device
->ds3dl
.dwSize
= sizeof(DS3DLISTENER
);
1055 pdsl
->device
->ds3dl
.vPosition
.x
= 0.0;
1056 pdsl
->device
->ds3dl
.vPosition
.y
= 0.0;
1057 pdsl
->device
->ds3dl
.vPosition
.z
= 0.0;
1058 pdsl
->device
->ds3dl
.vVelocity
.x
= 0.0;
1059 pdsl
->device
->ds3dl
.vVelocity
.y
= 0.0;
1060 pdsl
->device
->ds3dl
.vVelocity
.z
= 0.0;
1061 pdsl
->device
->ds3dl
.vOrientFront
.x
= 0.0;
1062 pdsl
->device
->ds3dl
.vOrientFront
.y
= 0.0;
1063 pdsl
->device
->ds3dl
.vOrientFront
.z
= 1.0;
1064 pdsl
->device
->ds3dl
.vOrientTop
.x
= 0.0;
1065 pdsl
->device
->ds3dl
.vOrientTop
.y
= 1.0;
1066 pdsl
->device
->ds3dl
.vOrientTop
.z
= 0.0;
1067 pdsl
->device
->ds3dl
.flDistanceFactor
= DS3D_DEFAULTDISTANCEFACTOR
;
1068 pdsl
->device
->ds3dl
.flRolloffFactor
= DS3D_DEFAULTROLLOFFFACTOR
;
1069 pdsl
->device
->ds3dl
.flDopplerFactor
= DS3D_DEFAULTDOPPLERFACTOR
;
1071 pdsl
->device
->ds3dl_need_recalc
= TRUE
;