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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
44 #include <sys/types.h>
45 #include <sys/fcntl.h>
51 #include <math.h> /* Insomnia - pow() function */
53 #define NONAMELESSUNION
54 #define NONAMELESSSTRUCT
64 #include "wine/windef16.h"
65 #include "wine/debug.h"
68 #include "dsound_private.h"
70 /* default intensity level for human ears */
71 #define DEFAULT_INTENSITY 0.000000000001f
72 /* default velocity of sound in the air */
73 #define DEFAULT_VELOCITY 340
75 WINE_DEFAULT_DEBUG_CHANNEL(dsound3d
);
77 /*******************************************************************************
81 /* scalar product (i believe it's called dot product in english) */
82 static inline D3DVALUE
ScalarProduct (LPD3DVECTOR a
, LPD3DVECTOR b
)
85 c
= (a
->x
*b
->x
) + (a
->y
*b
->y
) + (a
->z
*b
->z
);
86 TRACE("(%f,%f,%f) * (%f,%f,%f) = %f)\n", a
->x
, a
->y
, a
->z
, b
->x
, b
->y
, \
91 /* vector product (i believe it's called cross product in english */
92 static inline D3DVECTOR
VectorProduct (LPD3DVECTOR a
, LPD3DVECTOR b
)
95 c
.x
= (a
->y
*b
->z
) - (a
->z
*b
->y
);
96 c
.y
= (a
->z
*b
->x
) - (a
->x
*b
->z
);
97 c
.z
= (a
->x
*b
->y
) - (a
->y
*b
->x
);
98 TRACE("(%f,%f,%f) x (%f,%f,%f) = (%f,%f,%f)\n", a
->x
, a
->y
, a
->z
, b
->x
, b
->y
, \
103 /* magnitude (length) of vector */
104 static inline D3DVALUE
VectorMagnitude (LPD3DVECTOR a
)
107 l
= sqrt (ScalarProduct (a
, a
));
108 TRACE("|(%f,%f,%f)| = %f\n", a
->x
, a
->y
, a
->z
, l
);
112 /* conversion between radians and degrees */
113 static inline D3DVALUE
RadToDeg (D3DVALUE angle
)
116 newangle
= angle
* (360/(2*M_PI
));
117 TRACE("%f rad = %f deg\n", angle
, newangle
);
121 /* conversion between degrees and radians */
122 static inline D3DVALUE
DegToRad (D3DVALUE angle
)
125 newangle
= angle
* (2*M_PI
/360);
126 TRACE("%f deg = %f rad\n", angle
, newangle
);
130 /* angle between vectors - deg version */
131 static inline D3DVALUE
AngleBetweenVectorsDeg (LPD3DVECTOR a
, LPD3DVECTOR b
)
133 D3DVALUE la
, lb
, product
, angle
, cos
;
134 /* definition of scalar product: a*b = |a|*|b|*cos...therefore: */
135 product
= ScalarProduct (a
,b
);
136 la
= VectorMagnitude (a
);
137 lb
= VectorMagnitude (b
);
138 cos
= product
/(la
*lb
);
140 /* we now have angle in radians */
141 angle
= RadToDeg(angle
);
142 TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f degrees\n", a
->x
, a
->y
, a
->z
, b
->x
,
147 /* angle between vectors - rad version */
148 static inline D3DVALUE
AngleBetweenVectorsRad (LPD3DVECTOR a
, LPD3DVECTOR b
)
150 D3DVALUE la
, lb
, product
, angle
, cos
;
151 /* definition of scalar product: a*b = |a|*|b|*cos...therefore: */
152 product
= ScalarProduct (a
,b
);
153 la
= VectorMagnitude (a
);
154 lb
= VectorMagnitude (b
);
155 cos
= product
/(la
*lb
);
157 TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f radians\n", a
->x
, a
->y
, a
->z
, b
->x
,
162 /* calculates vector between two points */
163 static inline D3DVECTOR
VectorBetweenTwoPoints (LPD3DVECTOR a
, LPD3DVECTOR b
)
169 TRACE("A (%f,%f,%f), B (%f,%f,%f), AB = (%f,%f,%f)\n", a
->x
, a
->y
, a
->z
, b
->x
, b
->y
,
170 b
->z
, c
.x
, c
.y
, c
.z
);
174 /* calculates the length of vector's projection on another vector */
175 static inline D3DVALUE
ProjectVector (LPD3DVECTOR a
, LPD3DVECTOR p
)
177 D3DVALUE prod
, result
;
178 prod
= ScalarProduct(a
, p
);
179 result
= prod
/VectorMagnitude(p
);
180 TRACE("length projection of (%f,%f,%f) on (%f,%f,%f) = %f\n", a
->x
, a
->y
, a
->z
, p
->x
,
185 /*******************************************************************************
186 * 3D Buffer and Listener mixing
189 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl
*dsb
)
191 /* volume, at which the sound will be played after all calcs. */
192 D3DVALUE lVolume
= 0;
193 /* intensity (used for distance related stuff) */
196 /* stuff for distance related stuff calc. */
198 D3DVALUE flDistance
= 0;
199 /* panning related stuff */
202 /* doppler shift related stuff */
204 D3DVALUE flFreq
, flBufferVel
, flListenerVel
;
209 /* initial buffer volume */
210 lVolume
= dsb
->ds3db_lVolume
;
212 switch (dsb
->ds3db_ds3db
.dwMode
)
214 case DS3DMODE_DISABLE
:
215 TRACE("3D processing disabled\n");
216 /* this one is here only to eliminate annoying warning message */
217 DSOUND_RecalcVolPan (&dsb
->volpan
);
218 DSOUND_ForceRemix (dsb
);
220 case DS3DMODE_NORMAL
:
221 TRACE("Normal 3D processing mode\n");
222 /* we need to calculate distance between buffer and listener*/
223 vDistance
= VectorBetweenTwoPoints(&dsb
->ds3db_ds3db
.vPosition
, &dsb
->dsound
->ds3dl
.vPosition
);
224 flDistance
= VectorMagnitude (&vDistance
);
226 case DS3DMODE_HEADRELATIVE
:
227 TRACE("Head-relative 3D processing mode\n");
228 /* distance between buffer and listener is same as buffer's position */
229 flDistance
= VectorMagnitude (&dsb
->ds3db_ds3db
.vPosition
);
233 if (flDistance
> dsb
->ds3db_ds3db
.flMaxDistance
)
235 /* some apps don't want you to hear too distant sounds... */
236 if (dsb
->dsbd
.dwFlags
& DSBCAPS_MUTE3DATMAXDISTANCE
)
238 dsb
->volpan
.lVolume
= DSBVOLUME_MIN
;
239 DSOUND_RecalcVolPan (&dsb
->volpan
);
240 /* i guess mixing here would be a waste of power */
244 flDistance
= dsb
->ds3db_ds3db
.flMaxDistance
;
247 if (flDistance
< dsb
->ds3db_ds3db
.flMinDistance
)
248 flDistance
= dsb
->ds3db_ds3db
.flMinDistance
;
250 /* the following formula is taken from my physics book. I think it's ok for the *real* world...i hope m$ does it that way */
251 lVolume
+= 10000; /* ms likes working with negative volume...i don't */
252 lVolume
/= 1000; /* convert hundreths of dB into B */
253 /* intensity level (loudness) = log10(Intensity/DefaultIntensity)...therefore */
254 flIntensity
= pow(10,lVolume
)*DEFAULT_INTENSITY
;
255 flTemp
= (flDistance
/dsb
->ds3db_ds3db
.flMinDistance
)*(flDistance
/dsb
->ds3db_ds3db
.flMinDistance
);
256 flIntensity
/= flTemp
;
257 lVolume
= log10(flIntensity
/DEFAULT_INTENSITY
);
258 lVolume
*= 1000; /* convert back to hundreths of dB */
259 lVolume
-= 10000; /* we need to do it in ms way */
260 TRACE("dist. att: Distance = %f, MinDistance = %f => adjusting volume %ld to %f\n", flDistance
, dsb
->ds3db_ds3db
.flMinDistance
, dsb
->ds3db_lVolume
, lVolume
);
263 /* sometimes it happens that vConeOrientation vector = (0,0,0); in this case angle is "nan" and it's useless*/
264 if (dsb
->ds3db_ds3db
.vConeOrientation
.x
== 0 && dsb
->ds3db_ds3db
.vConeOrientation
.y
== 0 && dsb
->ds3db_ds3db
.vConeOrientation
.z
== 0)
266 TRACE("conning: cones not set\n");
270 /* calculate angle */
271 flAngle
= AngleBetweenVectorsDeg(&dsb
->ds3db_ds3db
.vConeOrientation
, &vDistance
);
272 /* if by any chance it happens that OutsideConeAngle = InsideConeAngle (that means that conning has no effect) */
273 if (dsb
->ds3db_ds3db
.dwInsideConeAngle
!= dsb
->ds3db_ds3db
.dwOutsideConeAngle
)
275 /* my test show that for my way of calc., we need only half of angles */
276 DWORD dwInsideConeAngle
= dsb
->ds3db_ds3db
.dwInsideConeAngle
/2;
277 DWORD dwOutsideConeAngle
= dsb
->ds3db_ds3db
.dwOutsideConeAngle
/2;
279 if (flAngle
< dwInsideConeAngle
)
280 flAngle
= dwInsideConeAngle
;
281 /* min (app defined) volume */
282 if (flAngle
> dwOutsideConeAngle
)
283 flAngle
= dwOutsideConeAngle
;
284 /* this probably isn't the right thing, but it's ok for the time being */
285 lVolume
+= ((dsb
->ds3db_ds3db
.lConeOutsideVolume
)/((dwOutsideConeAngle
) - (dwInsideConeAngle
))) * flAngle
;
287 TRACE("conning: Angle = %f deg; InsideConeAngle(/2) = %ld deg; OutsideConeAngle(/2) = %ld deg; ConeOutsideVolume = %ld => adjusting volume to %f\n",
288 flAngle
, dsb
->ds3db_ds3db
.dwInsideConeAngle
/2, dsb
->ds3db_ds3db
.dwOutsideConeAngle
/2, dsb
->ds3db_ds3db
.lConeOutsideVolume
, lVolume
);
290 dsb
->volpan
.lVolume
= lVolume
;
293 if (dsb
->dsound
->ds3dl
.vPosition
.x
== dsb
->ds3db_ds3db
.vPosition
.x
&&
294 dsb
->dsound
->ds3dl
.vPosition
.y
== dsb
->ds3db_ds3db
.vPosition
.y
&&
295 dsb
->dsound
->ds3dl
.vPosition
.z
== dsb
->ds3db_ds3db
.vPosition
.z
) {
296 dsb
->volpan
.lPan
= 0;
301 vDistance
= VectorBetweenTwoPoints(&dsb
->dsound
->ds3dl
.vPosition
, &dsb
->ds3db_ds3db
.vPosition
);
302 vLeft
= VectorProduct(&dsb
->dsound
->ds3dl
.vOrientFront
, &dsb
->dsound
->ds3dl
.vOrientTop
);
303 flAngle
= AngleBetweenVectorsRad(&vLeft
, &vDistance
);
304 /* for now, we'll use "linear formula" (which is probably incorrect); if someone has it in book, correct it */
305 dsb
->volpan
.lPan
= 10000*2*flAngle
/M_PI
- 10000;
307 TRACE("panning: Angle = %f rad, lPan = %ld\n", flAngle
, dsb
->volpan
.lPan
);
309 /* FIXME: Doppler Effect disabled since i have no idea which frequency to change and how to do it */
312 if ((VectorMagnitude(&ds3db
.vVelocity
) == 0) && (VectorMagnitude(&dsb
->dsound
->ds3dl
.vVelocity
) == 0))
314 TRACE("doppler: Buffer and Listener don't have velocities\n");
318 /* calculate length of ds3db.vVelocity component which causes Doppler Effect
319 NOTE: if buffer moves TOWARDS the listener, it's velocity component is NEGATIVE
320 if buffer moves AWAY from listener, it's velocity component is POSITIVE */
321 flBufferVel
= ProjectVector(&dsb
->ds3db_ds3db
.vVelocity
, &vDistance
);
322 /* calculate length of ds3dl.vVelocity component which causes Doppler Effect
323 NOTE: if listener moves TOWARDS the buffer, it's velocity component is POSITIVE
324 if listener moves AWAY from buffer, it's velocity component is NEGATIVE */
325 flListenerVel
= ProjectVector(&dsb
->dsound
->ds3dl
.vVelocity
, &vDistance
);
326 /* formula taken from Gianicoli D.: Physics, 4th edition: */
327 /* FIXME: replace dsb->freq with appropriate frequency ! */
328 flFreq
= dsb
->freq
* ((DEFAULT_VELOCITY
+ flListenerVel
)/(DEFAULT_VELOCITY
+ flBufferVel
));
329 TRACE("doppler: Buffer velocity (component) = %lf, Listener velocity (component) = %lf => Doppler shift: %ld Hz -> %lf Hz\n", flBufferVel
, flListenerVel
, \
331 /* FIXME: replace following line with correct frequency setting ! */
337 DSOUND_RecalcVolPan(&dsb
->volpan
);
340 static void DSOUND_Mix3DBuffer(IDirectSoundBufferImpl
*dsb
)
344 DSOUND_Calc3DBuffer(dsb
);
345 DSOUND_ForceRemix(dsb
);
348 static void WINAPI
DSOUND_ChangeListener(IDirectSound3DListenerImpl
*ds3dl
)
351 TRACE("(%p)\n",ds3dl
);
352 for (i
= 0; i
< ds3dl
->dsound
->nrofbuffers
; i
++)
354 /* some buffers don't have 3d buffer (Ultima IX seems to
355 crash without the following line) */
356 if (ds3dl
->dsound
->buffers
[i
]->ds3db
== NULL
)
358 if (ds3dl
->dsound
->buffers
[i
]->ds3db_need_recalc
== TRUE
)
360 DSOUND_Mix3DBuffer(ds3dl
->dsound
->buffers
[i
]);
365 /*******************************************************************************
366 * IDirectSound3DBuffer
369 /* IUnknown methods */
370 static HRESULT WINAPI
IDirectSound3DBufferImpl_QueryInterface(
371 LPDIRECTSOUND3DBUFFER iface
, REFIID riid
, LPVOID
*ppobj
)
373 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
375 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
376 return IDirectSoundBuffer_QueryInterface((LPDIRECTSOUNDBUFFER8
)This
->dsb
, riid
, ppobj
);
379 static ULONG WINAPI
IDirectSound3DBufferImpl_AddRef(LPDIRECTSOUND3DBUFFER iface
)
381 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
382 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
383 return InterlockedIncrement(&(This
->ref
));
386 static ULONG WINAPI
IDirectSound3DBufferImpl_Release(LPDIRECTSOUND3DBUFFER iface
)
388 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
391 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
392 ulReturn
= InterlockedDecrement(&(This
->ref
));
394 This
->dsb
->ds3db
= NULL
;
395 IDirectSoundBuffer_Release((LPDIRECTSOUNDBUFFER8
)This
->dsb
);
396 HeapFree(GetProcessHeap(),0,This
);
397 TRACE("(%p) released\n",This
);
403 /* IDirectSound3DBuffer methods */
404 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetAllParameters(
405 LPDIRECTSOUND3DBUFFER iface
,
406 LPDS3DBUFFER lpDs3dBuffer
)
408 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
409 TRACE("(%p,%p)\n",This
,lpDs3dBuffer
);
411 if (lpDs3dBuffer
== NULL
) {
412 WARN("invalid parameter: lpDs3dBuffer == NULL\n");
413 return DSERR_INVALIDPARAM
;
416 if (lpDs3dBuffer
->dwSize
< sizeof(*lpDs3dBuffer
)) {
417 WARN("invalid parameter: lpDs3dBuffer->dwSize = %ld < %d\n",lpDs3dBuffer
->dwSize
, sizeof(*lpDs3dBuffer
));
418 return DSERR_INVALIDPARAM
;
421 TRACE("returning: all parameters\n");
422 *lpDs3dBuffer
= This
->dsb
->ds3db_ds3db
;
426 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetConeAngles(
427 LPDIRECTSOUND3DBUFFER iface
,
428 LPDWORD lpdwInsideConeAngle
,
429 LPDWORD lpdwOutsideConeAngle
)
431 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
432 TRACE("returning: Inside Cone Angle = %ld degrees; Outside Cone Angle = %ld degrees\n",
433 This
->dsb
->ds3db_ds3db
.dwInsideConeAngle
, This
->dsb
->ds3db_ds3db
.dwOutsideConeAngle
);
434 *lpdwInsideConeAngle
= This
->dsb
->ds3db_ds3db
.dwInsideConeAngle
;
435 *lpdwOutsideConeAngle
= This
->dsb
->ds3db_ds3db
.dwOutsideConeAngle
;
439 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetConeOrientation(
440 LPDIRECTSOUND3DBUFFER iface
,
441 LPD3DVECTOR lpvConeOrientation
)
443 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
444 TRACE("returning: Cone Orientation vector = (%f,%f,%f)\n",
445 This
->dsb
->ds3db_ds3db
.vConeOrientation
.x
,
446 This
->dsb
->ds3db_ds3db
.vConeOrientation
.y
,
447 This
->dsb
->ds3db_ds3db
.vConeOrientation
.z
);
448 *lpvConeOrientation
= This
->dsb
->ds3db_ds3db
.vConeOrientation
;
452 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetConeOutsideVolume(
453 LPDIRECTSOUND3DBUFFER iface
,
454 LPLONG lplConeOutsideVolume
)
456 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
457 TRACE("returning: Cone Outside Volume = %ld\n", This
->dsb
->ds3db_ds3db
.lConeOutsideVolume
);
458 *lplConeOutsideVolume
= This
->dsb
->ds3db_ds3db
.lConeOutsideVolume
;
462 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetMaxDistance(
463 LPDIRECTSOUND3DBUFFER iface
,
464 LPD3DVALUE lpfMaxDistance
)
466 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
467 TRACE("returning: Max Distance = %f\n", This
->dsb
->ds3db_ds3db
.flMaxDistance
);
468 *lpfMaxDistance
= This
->dsb
->ds3db_ds3db
.flMaxDistance
;
472 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetMinDistance(
473 LPDIRECTSOUND3DBUFFER iface
,
474 LPD3DVALUE lpfMinDistance
)
476 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
477 TRACE("returning: Min Distance = %f\n", This
->dsb
->ds3db_ds3db
.flMinDistance
);
478 *lpfMinDistance
= This
->dsb
->ds3db_ds3db
.flMinDistance
;
482 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetMode(
483 LPDIRECTSOUND3DBUFFER iface
,
486 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
487 TRACE("returning: Mode = %ld\n", This
->dsb
->ds3db_ds3db
.dwMode
);
488 *lpdwMode
= This
->dsb
->ds3db_ds3db
.dwMode
;
492 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetPosition(
493 LPDIRECTSOUND3DBUFFER iface
,
494 LPD3DVECTOR lpvPosition
)
496 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
497 TRACE("returning: Position vector = (%f,%f,%f)\n",
498 This
->dsb
->ds3db_ds3db
.vPosition
.x
,
499 This
->dsb
->ds3db_ds3db
.vPosition
.y
,
500 This
->dsb
->ds3db_ds3db
.vPosition
.z
);
501 *lpvPosition
= This
->dsb
->ds3db_ds3db
.vPosition
;
505 static HRESULT WINAPI
IDirectSound3DBufferImpl_GetVelocity(
506 LPDIRECTSOUND3DBUFFER iface
,
507 LPD3DVECTOR lpvVelocity
)
509 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
510 TRACE("returning: Velocity vector = (%f,%f,%f)\n",
511 This
->dsb
->ds3db_ds3db
.vVelocity
.x
,
512 This
->dsb
->ds3db_ds3db
.vVelocity
.y
,
513 This
->dsb
->ds3db_ds3db
.vVelocity
.z
);
514 *lpvVelocity
= This
->dsb
->ds3db_ds3db
.vVelocity
;
518 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetAllParameters(
519 LPDIRECTSOUND3DBUFFER iface
,
520 LPCDS3DBUFFER lpcDs3dBuffer
,
523 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
524 DWORD status
= DSERR_INVALIDPARAM
;
525 TRACE("(%p,%p,%lx)\n",iface
,lpcDs3dBuffer
,dwApply
);
527 if (lpcDs3dBuffer
== NULL
) {
528 WARN("invalid parameter: lpcDs3dBuffer == NULL\n");
532 if (lpcDs3dBuffer
->dwSize
!= sizeof(DS3DBUFFER
)) {
533 WARN("invalid parameter: lpcDs3dBuffer->dwSize = %ld != %d\n",
534 lpcDs3dBuffer
->dwSize
, sizeof(DS3DBUFFER
));
538 TRACE("setting: all parameters; dwApply = %ld\n", dwApply
);
539 This
->dsb
->ds3db_ds3db
= *lpcDs3dBuffer
;
541 if (dwApply
== DS3D_IMMEDIATE
)
543 DSOUND_Mix3DBuffer(This
->dsb
);
545 This
->dsb
->ds3db_need_recalc
= TRUE
;
551 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetConeAngles(
552 LPDIRECTSOUND3DBUFFER iface
,
553 DWORD dwInsideConeAngle
,
554 DWORD dwOutsideConeAngle
,
557 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
558 TRACE("setting: Inside Cone Angle = %ld; Outside Cone Angle = %ld; dwApply = %ld\n",
559 dwInsideConeAngle
, dwOutsideConeAngle
, dwApply
);
560 This
->dsb
->ds3db_ds3db
.dwInsideConeAngle
= dwInsideConeAngle
;
561 This
->dsb
->ds3db_ds3db
.dwOutsideConeAngle
= dwOutsideConeAngle
;
562 if (dwApply
== DS3D_IMMEDIATE
)
564 DSOUND_Mix3DBuffer(This
->dsb
);
566 This
->dsb
->ds3db_need_recalc
= TRUE
;
570 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetConeOrientation(
571 LPDIRECTSOUND3DBUFFER iface
,
572 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
,
575 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
576 TRACE("setting: Cone Orientation vector = (%f,%f,%f); dwApply = %ld\n", x
, y
, z
, dwApply
);
577 This
->dsb
->ds3db_ds3db
.vConeOrientation
.x
= x
;
578 This
->dsb
->ds3db_ds3db
.vConeOrientation
.y
= y
;
579 This
->dsb
->ds3db_ds3db
.vConeOrientation
.z
= z
;
580 if (dwApply
== DS3D_IMMEDIATE
)
582 This
->dsb
->ds3db_need_recalc
= FALSE
;
583 DSOUND_Mix3DBuffer(This
->dsb
);
585 This
->dsb
->ds3db_need_recalc
= TRUE
;
589 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetConeOutsideVolume(
590 LPDIRECTSOUND3DBUFFER iface
,
591 LONG lConeOutsideVolume
,
594 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
595 TRACE("setting: ConeOutsideVolume = %ld; dwApply = %ld\n", lConeOutsideVolume
, dwApply
);
596 This
->dsb
->ds3db_ds3db
.lConeOutsideVolume
= lConeOutsideVolume
;
597 if (dwApply
== DS3D_IMMEDIATE
)
599 This
->dsb
->ds3db_need_recalc
= FALSE
;
600 DSOUND_Mix3DBuffer(This
->dsb
);
602 This
->dsb
->ds3db_need_recalc
= TRUE
;
606 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetMaxDistance(
607 LPDIRECTSOUND3DBUFFER iface
,
608 D3DVALUE fMaxDistance
,
611 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
612 TRACE("setting: MaxDistance = %f; dwApply = %ld\n", fMaxDistance
, dwApply
);
613 This
->dsb
->ds3db_ds3db
.flMaxDistance
= fMaxDistance
;
614 if (dwApply
== DS3D_IMMEDIATE
)
616 This
->dsb
->ds3db_need_recalc
= FALSE
;
617 DSOUND_Mix3DBuffer(This
->dsb
);
619 This
->dsb
->ds3db_need_recalc
= TRUE
;
623 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetMinDistance(
624 LPDIRECTSOUND3DBUFFER iface
,
625 D3DVALUE fMinDistance
,
628 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
629 TRACE("setting: MinDistance = %f; dwApply = %ld\n", fMinDistance
, dwApply
);
630 This
->dsb
->ds3db_ds3db
.flMinDistance
= fMinDistance
;
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 HRESULT WINAPI
IDirectSound3DBufferImpl_SetMode(
641 LPDIRECTSOUND3DBUFFER iface
,
645 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
646 TRACE("setting: Mode = %ld; dwApply = %ld\n", dwMode
, dwApply
);
647 This
->dsb
->ds3db_ds3db
.dwMode
= dwMode
;
648 if (dwApply
== DS3D_IMMEDIATE
)
650 This
->dsb
->ds3db_need_recalc
= FALSE
;
651 DSOUND_Mix3DBuffer(This
->dsb
);
653 This
->dsb
->ds3db_need_recalc
= TRUE
;
657 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetPosition(
658 LPDIRECTSOUND3DBUFFER iface
,
659 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
,
662 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
663 TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x
, y
, z
, dwApply
);
664 This
->dsb
->ds3db_ds3db
.vPosition
.x
= x
;
665 This
->dsb
->ds3db_ds3db
.vPosition
.y
= y
;
666 This
->dsb
->ds3db_ds3db
.vPosition
.z
= z
;
667 if (dwApply
== DS3D_IMMEDIATE
)
669 This
->dsb
->ds3db_need_recalc
= FALSE
;
670 DSOUND_Mix3DBuffer(This
->dsb
);
672 This
->dsb
->ds3db_need_recalc
= TRUE
;
676 static HRESULT WINAPI
IDirectSound3DBufferImpl_SetVelocity(
677 LPDIRECTSOUND3DBUFFER iface
,
678 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
,
681 IDirectSound3DBufferImpl
*This
= (IDirectSound3DBufferImpl
*)iface
;
682 TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %ld\n", x
, y
, z
, dwApply
);
683 This
->dsb
->ds3db_ds3db
.vVelocity
.x
= x
;
684 This
->dsb
->ds3db_ds3db
.vVelocity
.y
= y
;
685 This
->dsb
->ds3db_ds3db
.vVelocity
.z
= z
;
686 if (dwApply
== DS3D_IMMEDIATE
)
688 This
->dsb
->ds3db_need_recalc
= FALSE
;
689 DSOUND_Mix3DBuffer(This
->dsb
);
691 This
->dsb
->ds3db_need_recalc
= TRUE
;
695 static IDirectSound3DBufferVtbl ds3dbvt
=
697 /* IUnknown methods */
698 IDirectSound3DBufferImpl_QueryInterface
,
699 IDirectSound3DBufferImpl_AddRef
,
700 IDirectSound3DBufferImpl_Release
,
701 /* IDirectSound3DBuffer methods */
702 IDirectSound3DBufferImpl_GetAllParameters
,
703 IDirectSound3DBufferImpl_GetConeAngles
,
704 IDirectSound3DBufferImpl_GetConeOrientation
,
705 IDirectSound3DBufferImpl_GetConeOutsideVolume
,
706 IDirectSound3DBufferImpl_GetMaxDistance
,
707 IDirectSound3DBufferImpl_GetMinDistance
,
708 IDirectSound3DBufferImpl_GetMode
,
709 IDirectSound3DBufferImpl_GetPosition
,
710 IDirectSound3DBufferImpl_GetVelocity
,
711 IDirectSound3DBufferImpl_SetAllParameters
,
712 IDirectSound3DBufferImpl_SetConeAngles
,
713 IDirectSound3DBufferImpl_SetConeOrientation
,
714 IDirectSound3DBufferImpl_SetConeOutsideVolume
,
715 IDirectSound3DBufferImpl_SetMaxDistance
,
716 IDirectSound3DBufferImpl_SetMinDistance
,
717 IDirectSound3DBufferImpl_SetMode
,
718 IDirectSound3DBufferImpl_SetPosition
,
719 IDirectSound3DBufferImpl_SetVelocity
,
722 HRESULT WINAPI
IDirectSound3DBufferImpl_Create(
723 IDirectSoundBufferImpl
*dsb
,
724 IDirectSound3DBufferImpl
**pds3db
)
726 IDirectSound3DBufferImpl
*ds3db
;
727 TRACE("(%p,%p)\n",dsb
,pds3db
);
729 ds3db
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(*ds3db
));
732 WARN("out of memory\n");
734 return DSERR_OUTOFMEMORY
;
739 ds3db
->lpVtbl
= &ds3dbvt
;
741 ds3db
->dsb
->ds3db_ds3db
.dwSize
= sizeof(DS3DBUFFER
);
742 ds3db
->dsb
->ds3db_ds3db
.vPosition
.x
= 0.0;
743 ds3db
->dsb
->ds3db_ds3db
.vPosition
.y
= 0.0;
744 ds3db
->dsb
->ds3db_ds3db
.vPosition
.z
= 0.0;
745 ds3db
->dsb
->ds3db_ds3db
.vVelocity
.x
= 0.0;
746 ds3db
->dsb
->ds3db_ds3db
.vVelocity
.y
= 0.0;
747 ds3db
->dsb
->ds3db_ds3db
.vVelocity
.z
= 0.0;
748 ds3db
->dsb
->ds3db_ds3db
.dwInsideConeAngle
= DS3D_DEFAULTCONEANGLE
;
749 ds3db
->dsb
->ds3db_ds3db
.dwOutsideConeAngle
= DS3D_DEFAULTCONEANGLE
;
750 ds3db
->dsb
->ds3db_ds3db
.vConeOrientation
.x
= 0.0;
751 ds3db
->dsb
->ds3db_ds3db
.vConeOrientation
.y
= 0.0;
752 ds3db
->dsb
->ds3db_ds3db
.vConeOrientation
.z
= 0.0;
753 ds3db
->dsb
->ds3db_ds3db
.lConeOutsideVolume
= DS3D_DEFAULTCONEOUTSIDEVOLUME
;
754 ds3db
->dsb
->ds3db_ds3db
.flMinDistance
= DS3D_DEFAULTMINDISTANCE
;
755 ds3db
->dsb
->ds3db_ds3db
.flMaxDistance
= DS3D_DEFAULTMAXDISTANCE
;
756 ds3db
->dsb
->ds3db_ds3db
.dwMode
= DS3DMODE_NORMAL
;
758 ds3db
->dsb
->ds3db_need_recalc
= TRUE
;
760 IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER8
)dsb
);
766 HRESULT WINAPI
IDirectSound3DBufferImpl_Destroy(
767 IDirectSound3DBufferImpl
*pds3db
)
769 TRACE("(%p)\n",pds3db
);
771 while (IDirectSound3DBufferImpl_Release((LPDIRECTSOUND3DBUFFER
)pds3db
) > 0);
776 /*******************************************************************************
777 * IDirectSound3DListener
780 /* IUnknown methods */
781 static HRESULT WINAPI
IDirectSound3DListenerImpl_QueryInterface(
782 LPDIRECTSOUND3DLISTENER iface
, REFIID riid
, LPVOID
*ppobj
)
784 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
786 TRACE("(%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
789 WARN("invalid parameter\n");
793 *ppobj
= NULL
; /* assume failure */
795 if ( IsEqualGUID(riid
, &IID_IUnknown
) ||
796 IsEqualGUID(riid
, &IID_IDirectSound3DListener
) ) {
797 IDirectSound3DListener_AddRef((LPDIRECTSOUND3DLISTENER
)This
);
802 if ( IsEqualGUID(riid
, &IID_IDirectSoundBuffer
) ) {
803 if (!This
->dsound
->primary
)
804 PrimaryBufferImpl_Create(This
->dsound
, &(This
->dsound
->primary
), &(This
->dsound
->dsbd
));
805 if (This
->dsound
->primary
) {
806 *ppobj
= This
->dsound
->primary
;
807 IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER
)*ppobj
);
812 FIXME( "Unknown IID %s\n", debugstr_guid( riid
) );
813 return E_NOINTERFACE
;
816 static ULONG WINAPI
IDirectSound3DListenerImpl_AddRef(LPDIRECTSOUND3DLISTENER iface
)
818 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
819 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
820 return InterlockedIncrement(&(This
->ref
));
823 static ULONG WINAPI
IDirectSound3DListenerImpl_Release(LPDIRECTSOUND3DLISTENER iface
)
825 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
828 TRACE("(%p) ref was %ld, thread is %04lx\n",This
, This
->ref
, GetCurrentThreadId());
829 ulReturn
= InterlockedDecrement(&(This
->ref
));
831 /* Free all resources */
832 if( ulReturn
== 0 ) {
833 This
->dsound
->listener
= 0;
834 HeapFree(GetProcessHeap(),0,This
);
835 TRACE("(%p) released\n",This
);
841 /* IDirectSound3DListener methods */
842 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetAllParameter(
843 LPDIRECTSOUND3DLISTENER iface
,
844 LPDS3DLISTENER lpDS3DL
)
846 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
847 TRACE("(%p,%p)\n",This
,lpDS3DL
);
849 if (lpDS3DL
== NULL
) {
850 WARN("invalid parameter: lpDS3DL == NULL\n");
851 return DSERR_INVALIDPARAM
;
854 if (lpDS3DL
->dwSize
< sizeof(*lpDS3DL
)) {
855 WARN("invalid parameter: lpDS3DL->dwSize = %ld < %d\n",lpDS3DL
->dwSize
, sizeof(*lpDS3DL
));
856 return DSERR_INVALIDPARAM
;
859 TRACE("returning: all parameters\n");
860 *lpDS3DL
= This
->dsound
->ds3dl
;
864 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetDistanceFactor(
865 LPDIRECTSOUND3DLISTENER iface
,
866 LPD3DVALUE lpfDistanceFactor
)
868 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
869 TRACE("returning: Distance Factor = %f\n", This
->dsound
->ds3dl
.flDistanceFactor
);
870 *lpfDistanceFactor
= This
->dsound
->ds3dl
.flDistanceFactor
;
874 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetDopplerFactor(
875 LPDIRECTSOUND3DLISTENER iface
,
876 LPD3DVALUE lpfDopplerFactor
)
878 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
879 TRACE("returning: Doppler Factor = %f\n", This
->dsound
->ds3dl
.flDopplerFactor
);
880 *lpfDopplerFactor
= This
->dsound
->ds3dl
.flDopplerFactor
;
884 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetOrientation(
885 LPDIRECTSOUND3DLISTENER iface
,
886 LPD3DVECTOR lpvOrientFront
,
887 LPD3DVECTOR lpvOrientTop
)
889 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
890 TRACE("returning: OrientFront vector = (%f,%f,%f); OrientTop vector = (%f,%f,%f)\n", This
->dsound
->ds3dl
.vOrientFront
.x
, \
891 This
->dsound
->ds3dl
.vOrientFront
.y
, This
->dsound
->ds3dl
.vOrientFront
.z
, This
->dsound
->ds3dl
.vOrientTop
.x
, This
->dsound
->ds3dl
.vOrientTop
.y
, \
892 This
->dsound
->ds3dl
.vOrientTop
.z
);
893 *lpvOrientFront
= This
->dsound
->ds3dl
.vOrientFront
;
894 *lpvOrientTop
= This
->dsound
->ds3dl
.vOrientTop
;
898 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetPosition(
899 LPDIRECTSOUND3DLISTENER iface
,
900 LPD3DVECTOR lpvPosition
)
902 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
903 TRACE("returning: Position vector = (%f,%f,%f)\n", This
->dsound
->ds3dl
.vPosition
.x
, This
->dsound
->ds3dl
.vPosition
.y
, This
->dsound
->ds3dl
.vPosition
.z
);
904 *lpvPosition
= This
->dsound
->ds3dl
.vPosition
;
908 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetRolloffFactor(
909 LPDIRECTSOUND3DLISTENER iface
,
910 LPD3DVALUE lpfRolloffFactor
)
912 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
913 TRACE("returning: RolloffFactor = %f\n", This
->dsound
->ds3dl
.flRolloffFactor
);
914 *lpfRolloffFactor
= This
->dsound
->ds3dl
.flRolloffFactor
;
918 static HRESULT WINAPI
IDirectSound3DListenerImpl_GetVelocity(
919 LPDIRECTSOUND3DLISTENER iface
,
920 LPD3DVECTOR lpvVelocity
)
922 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
923 TRACE("returning: Velocity vector = (%f,%f,%f)\n", This
->dsound
->ds3dl
.vVelocity
.x
, This
->dsound
->ds3dl
.vVelocity
.y
, This
->dsound
->ds3dl
.vVelocity
.z
);
924 *lpvVelocity
= This
->dsound
->ds3dl
.vVelocity
;
928 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetAllParameters(
929 LPDIRECTSOUND3DLISTENER iface
,
930 LPCDS3DLISTENER lpcDS3DL
,
933 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
934 TRACE("setting: all parameters; dwApply = %ld\n", dwApply
);
935 This
->dsound
->ds3dl
= *lpcDS3DL
;
936 if (dwApply
== DS3D_IMMEDIATE
)
938 This
->dsound
->ds3dl_need_recalc
= FALSE
;
939 DSOUND_ChangeListener(This
);
941 This
->dsound
->ds3dl_need_recalc
= TRUE
;
945 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetDistanceFactor(
946 LPDIRECTSOUND3DLISTENER iface
,
947 D3DVALUE fDistanceFactor
,
950 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
951 TRACE("setting: Distance Factor = %f; dwApply = %ld\n", fDistanceFactor
, dwApply
);
952 This
->dsound
->ds3dl
.flDistanceFactor
= fDistanceFactor
;
953 if (dwApply
== DS3D_IMMEDIATE
)
955 This
->dsound
->ds3dl_need_recalc
= FALSE
;
956 DSOUND_ChangeListener(This
);
958 This
->dsound
->ds3dl_need_recalc
= TRUE
;
962 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetDopplerFactor(
963 LPDIRECTSOUND3DLISTENER iface
,
964 D3DVALUE fDopplerFactor
,
967 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
968 TRACE("setting: Doppler Factor = %f; dwApply = %ld\n", fDopplerFactor
, dwApply
);
969 This
->dsound
->ds3dl
.flDopplerFactor
= fDopplerFactor
;
970 if (dwApply
== DS3D_IMMEDIATE
)
972 This
->dsound
->ds3dl_need_recalc
= FALSE
;
973 DSOUND_ChangeListener(This
);
975 This
->dsound
->ds3dl_need_recalc
= TRUE
;
979 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetOrientation(
980 LPDIRECTSOUND3DLISTENER iface
,
981 D3DVALUE xFront
, D3DVALUE yFront
, D3DVALUE zFront
,
982 D3DVALUE xTop
, D3DVALUE yTop
, D3DVALUE zTop
,
985 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
986 TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %ld\n", \
987 xFront
, yFront
, zFront
, xTop
, yTop
, zTop
, dwApply
);
988 This
->dsound
->ds3dl
.vOrientFront
.x
= xFront
;
989 This
->dsound
->ds3dl
.vOrientFront
.y
= yFront
;
990 This
->dsound
->ds3dl
.vOrientFront
.z
= zFront
;
991 This
->dsound
->ds3dl
.vOrientTop
.x
= xTop
;
992 This
->dsound
->ds3dl
.vOrientTop
.y
= yTop
;
993 This
->dsound
->ds3dl
.vOrientTop
.z
= zTop
;
994 if (dwApply
== DS3D_IMMEDIATE
)
996 This
->dsound
->ds3dl_need_recalc
= FALSE
;
997 DSOUND_ChangeListener(This
);
999 This
->dsound
->ds3dl_need_recalc
= TRUE
;
1003 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetPosition(
1004 LPDIRECTSOUND3DLISTENER iface
,
1005 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
,
1008 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
1009 TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x
, y
, z
, dwApply
);
1010 This
->dsound
->ds3dl
.vPosition
.x
= x
;
1011 This
->dsound
->ds3dl
.vPosition
.y
= y
;
1012 This
->dsound
->ds3dl
.vPosition
.z
= z
;
1013 if (dwApply
== DS3D_IMMEDIATE
)
1015 This
->dsound
->ds3dl_need_recalc
= FALSE
;
1016 DSOUND_ChangeListener(This
);
1018 This
->dsound
->ds3dl_need_recalc
= TRUE
;
1022 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetRolloffFactor(
1023 LPDIRECTSOUND3DLISTENER iface
,
1024 D3DVALUE fRolloffFactor
,
1027 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
1028 TRACE("setting: Rolloff Factor = %f; dwApply = %ld\n", fRolloffFactor
, dwApply
);
1029 This
->dsound
->ds3dl
.flRolloffFactor
= fRolloffFactor
;
1030 if (dwApply
== DS3D_IMMEDIATE
)
1032 This
->dsound
->ds3dl_need_recalc
= FALSE
;
1033 DSOUND_ChangeListener(This
);
1035 This
->dsound
->ds3dl_need_recalc
= TRUE
;
1039 static HRESULT WINAPI
IDirectSound3DListenerImpl_SetVelocity(
1040 LPDIRECTSOUND3DLISTENER iface
,
1041 D3DVALUE x
, D3DVALUE y
, D3DVALUE z
,
1044 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
1045 TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %ld\n", x
, y
, z
, dwApply
);
1046 This
->dsound
->ds3dl
.vVelocity
.x
= x
;
1047 This
->dsound
->ds3dl
.vVelocity
.y
= y
;
1048 This
->dsound
->ds3dl
.vVelocity
.z
= z
;
1049 if (dwApply
== DS3D_IMMEDIATE
)
1051 This
->dsound
->ds3dl_need_recalc
= FALSE
;
1052 DSOUND_ChangeListener(This
);
1054 This
->dsound
->ds3dl_need_recalc
= TRUE
;
1058 static HRESULT WINAPI
IDirectSound3DListenerImpl_CommitDeferredSettings(
1059 LPDIRECTSOUND3DLISTENER iface
)
1061 IDirectSound3DListenerImpl
*This
= (IDirectSound3DListenerImpl
*)iface
;
1063 DSOUND_ChangeListener(This
);
1067 static IDirectSound3DListenerVtbl ds3dlvt
=
1069 /* IUnknown methods */
1070 IDirectSound3DListenerImpl_QueryInterface
,
1071 IDirectSound3DListenerImpl_AddRef
,
1072 IDirectSound3DListenerImpl_Release
,
1073 /* IDirectSound3DListener methods */
1074 IDirectSound3DListenerImpl_GetAllParameter
,
1075 IDirectSound3DListenerImpl_GetDistanceFactor
,
1076 IDirectSound3DListenerImpl_GetDopplerFactor
,
1077 IDirectSound3DListenerImpl_GetOrientation
,
1078 IDirectSound3DListenerImpl_GetPosition
,
1079 IDirectSound3DListenerImpl_GetRolloffFactor
,
1080 IDirectSound3DListenerImpl_GetVelocity
,
1081 IDirectSound3DListenerImpl_SetAllParameters
,
1082 IDirectSound3DListenerImpl_SetDistanceFactor
,
1083 IDirectSound3DListenerImpl_SetDopplerFactor
,
1084 IDirectSound3DListenerImpl_SetOrientation
,
1085 IDirectSound3DListenerImpl_SetPosition
,
1086 IDirectSound3DListenerImpl_SetRolloffFactor
,
1087 IDirectSound3DListenerImpl_SetVelocity
,
1088 IDirectSound3DListenerImpl_CommitDeferredSettings
,
1091 HRESULT WINAPI
IDirectSound3DListenerImpl_Create(
1092 PrimaryBufferImpl
*This
,
1093 IDirectSound3DListenerImpl
**pdsl
)
1095 IDirectSound3DListenerImpl
*dsl
;
1096 TRACE("(%p,%p)\n",This
,pdsl
);
1098 dsl
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(*dsl
));
1101 WARN("out of memory\n");
1103 return DSERR_OUTOFMEMORY
;
1107 dsl
->lpVtbl
= &ds3dlvt
;
1109 dsl
->dsound
= This
->dsound
;
1111 dsl
->dsound
->ds3dl
.dwSize
= sizeof(DS3DLISTENER
);
1112 dsl
->dsound
->ds3dl
.vPosition
.x
= 0.0;
1113 dsl
->dsound
->ds3dl
.vPosition
.y
= 0.0;
1114 dsl
->dsound
->ds3dl
.vPosition
.z
= 0.0;
1115 dsl
->dsound
->ds3dl
.vVelocity
.x
= 0.0;
1116 dsl
->dsound
->ds3dl
.vVelocity
.y
= 0.0;
1117 dsl
->dsound
->ds3dl
.vVelocity
.z
= 0.0;
1118 dsl
->dsound
->ds3dl
.vOrientFront
.x
= 0.0;
1119 dsl
->dsound
->ds3dl
.vOrientFront
.y
= 0.0;
1120 dsl
->dsound
->ds3dl
.vOrientFront
.z
= 1.0;
1121 dsl
->dsound
->ds3dl
.vOrientTop
.x
= 0.0;
1122 dsl
->dsound
->ds3dl
.vOrientTop
.y
= 1.0;
1123 dsl
->dsound
->ds3dl
.vOrientTop
.z
= 0.0;
1124 dsl
->dsound
->ds3dl
.flDistanceFactor
= DS3D_DEFAULTDISTANCEFACTOR
;
1125 dsl
->dsound
->ds3dl
.flRolloffFactor
= DS3D_DEFAULTROLLOFFFACTOR
;
1126 dsl
->dsound
->ds3dl
.flDopplerFactor
= DS3D_DEFAULTDOPPLERFACTOR
;
1128 dsl
->dsound
->ds3dl_need_recalc
= TRUE
;