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
43 #include <sys/types.h>
44 #include <sys/fcntl.h>
50 #include <math.h> /* Insomnia - pow() function */
52 #define NONAMELESSUNION
53 #define NONAMELESSSTRUCT
62 #include "wine/windef16.h"
63 #include "wine/debug.h"
66 #include "dsound_private.h"
68 /* default intensity level for human ears */
69 #define DEFAULT_INTENSITY 0.000000000001f
70 /* default velocity of sound in the air */
71 #define DEFAULT_VELOCITY 340
73 WINE_DEFAULT_DEBUG_CHANNEL(dsound3d);
75 /*******************************************************************************
79 /* scalar product (i believe it's called dot product in english) */
80 static inline D3DVALUE ScalarProduct (LPD3DVECTOR a, LPD3DVECTOR b)
83 c = (a->u1.x*b->u1.x) + (a->u2.y*b->u2.y) + (a->u3.z*b->u3.z);
84 TRACE("(%f,%f,%f) * (%f,%f,%f) = %f)\n", a->u1.x, a->u2.y, a->u3.z, b->u1.x, b->u2.y, \
89 /* vector product (i believe it's called cross product in english */
90 static inline D3DVECTOR VectorProduct (LPD3DVECTOR a, LPD3DVECTOR b)
93 c.u1.x = (a->u2.y*b->u3.z) - (a->u3.z*b->u2.y);
94 c.u2.y = (a->u3.z*b->u1.x) - (a->u1.x*b->u3.z);
95 c.u3.z = (a->u1.x*b->u2.y) - (a->u2.y*b->u1.x);
96 TRACE("(%f,%f,%f) x (%f,%f,%f) = (%f,%f,%f)\n", a->u1.x, a->u2.y, a->u3.z, b->u1.x, b->u2.y, \
97 b->u3.z, c.u1.x, c.u2.y, c.u3.z);
101 /* magnitude (length) of vector */
102 static inline D3DVALUE VectorMagnitude (LPD3DVECTOR a)
105 l = sqrt (ScalarProduct (a, a));
106 TRACE("|(%f,%f,%f)| = %f\n", a->u1.x, a->u2.y, a->u3.z, l);
110 /* conversion between radians and degrees */
111 static inline D3DVALUE RadToDeg (D3DVALUE angle)
114 newangle = angle * (360/(2*M_PI));
115 TRACE("%f rad = %f deg\n", angle, newangle);
119 /* conversion between degrees and radians */
120 static inline D3DVALUE DegToRad (D3DVALUE angle)
123 newangle = angle * (2*M_PI/360);
124 TRACE("%f deg = %f rad\n", angle, newangle);
128 /* angle between vectors - deg version */
129 static inline D3DVALUE AngleBetweenVectorsDeg (LPD3DVECTOR a, LPD3DVECTOR b)
131 D3DVALUE la, lb, product, angle, cos;
132 /* definition of scalar product: a*b = |a|*|b|*cos...therefore: */
133 product = ScalarProduct (a,b);
134 la = VectorMagnitude (a);
135 lb = VectorMagnitude (b);
136 cos = product/(la*lb);
138 /* we now have angle in radians */
139 angle = RadToDeg(angle);
140 TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f degrees\n", a->u1.x, a->u2.y, a->u3.z, b->u1.x,
141 b->u2.y, b->u3.z, angle);
145 /* angle between vectors - rad version */
146 static inline D3DVALUE AngleBetweenVectorsRad (LPD3DVECTOR a, LPD3DVECTOR b)
148 D3DVALUE la, lb, product, angle, cos;
149 /* definition of scalar product: a*b = |a|*|b|*cos...therefore: */
150 product = ScalarProduct (a,b);
151 la = VectorMagnitude (a);
152 lb = VectorMagnitude (b);
153 cos = product/(la*lb);
155 TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f radians\n", a->u1.x, a->u2.y, a->u3.z, b->u1.x,
156 b->u2.y, b->u3.z, angle);
160 /* calculates vector between two points */
161 static inline D3DVECTOR VectorBetweenTwoPoints (LPD3DVECTOR a, LPD3DVECTOR b)
164 c.u1.x = b->u1.x - a->u1.x;
165 c.u2.y = b->u2.y - a->u2.y;
166 c.u3.z = b->u3.z - a->u3.z;
167 TRACE("A (%f,%f,%f), B (%f,%f,%f), AB = (%f,%f,%f)\n", a->u1.x, a->u2.y, a->u3.z, b->u1.x, b->u2.y,
168 b->u3.z, c.u1.x, c.u2.y, c.u3.z);
172 /* calculates the length of vector's projection on another vector */
173 static inline D3DVALUE ProjectVector (LPD3DVECTOR a, LPD3DVECTOR p)
175 D3DVALUE prod, result;
176 prod = ScalarProduct(a, p);
177 result = prod/VectorMagnitude(p);
178 TRACE("length projection of (%f,%f,%f) on (%f,%f,%f) = %f\n", a->u1.x, a->u2.y, a->u3.z, p->u1.x,
179 p->u2.y, p->u3.z, result);
183 /*******************************************************************************
184 * 3D Buffer and Listener mixing
187 void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
189 /* volume, at which the sound will be played after all calcs. */
190 D3DVALUE lVolume = 0;
191 /* intensity (used for distance related stuff) */
194 /* stuff for distance related stuff calc. */
196 D3DVALUE flDistance = 0;
197 /* panning related stuff */
200 /* doppler shift related stuff */
202 D3DVALUE flFreq, flBufferVel, flListenerVel;
207 /* initial buffer volume */
208 lVolume = dsb->ds3db_lVolume;
210 switch (dsb->ds3db_ds3db.dwMode)
212 case DS3DMODE_DISABLE:
213 TRACE("3D processing disabled\n");
214 /* this one is here only to eliminate annoying warning message */
215 DSOUND_RecalcVolPan (&dsb->volpan);
216 DSOUND_ForceRemix (dsb);
218 case DS3DMODE_NORMAL:
219 TRACE("Normal 3D processing mode\n");
220 /* we need to calculate distance between buffer and listener*/
221 vDistance = VectorBetweenTwoPoints(&dsb->ds3db_ds3db.vPosition, &dsb->dsound->ds3dl.vPosition);
222 flDistance = VectorMagnitude (&vDistance);
224 case DS3DMODE_HEADRELATIVE:
225 TRACE("Head-relative 3D processing mode\n");
226 /* distance between buffer and listener is same as buffer's position */
227 flDistance = VectorMagnitude (&dsb->ds3db_ds3db.vPosition);
231 if (flDistance > dsb->ds3db_ds3db.flMaxDistance)
233 /* some apps don't want you to hear too distant sounds... */
234 if (dsb->dsbd.dwFlags & DSBCAPS_MUTE3DATMAXDISTANCE)
236 dsb->volpan.lVolume = DSBVOLUME_MIN;
237 DSOUND_RecalcVolPan (&dsb->volpan);
238 /* i guess mixing here would be a waste of power */
242 flDistance = dsb->ds3db_ds3db.flMaxDistance;
245 if (flDistance < dsb->ds3db_ds3db.flMinDistance)
246 flDistance = dsb->ds3db_ds3db.flMinDistance;
248 /* 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 */
249 lVolume += 10000; /* ms likes working with negative volume...i don't */
250 lVolume /= 1000; /* convert hundreths of dB into B */
251 /* intensity level (loudness) = log10(Intensity/DefaultIntensity)...therefore */
252 flIntensity = pow(10,lVolume)*DEFAULT_INTENSITY;
253 flTemp = (flDistance/dsb->ds3db_ds3db.flMinDistance)*(flDistance/dsb->ds3db_ds3db.flMinDistance);
254 flIntensity /= flTemp;
255 lVolume = log10(flIntensity/DEFAULT_INTENSITY);
256 lVolume *= 1000; /* convert back to hundreths of dB */
257 lVolume -= 10000; /* we need to do it in ms way */
258 TRACE("dist. att: Distance = %f, MinDistance = %f => adjusting volume %ld to %f\n", flDistance, dsb->ds3db_ds3db.flMinDistance, dsb->ds3db_lVolume, lVolume);
261 /* sometimes it happens that vConeOrientation vector = (0,0,0); in this case angle is "nan" and it's useless*/
262 if (dsb->ds3db_ds3db.vConeOrientation.u1.x == 0 && dsb->ds3db_ds3db.vConeOrientation.u2.y == 0 && dsb->ds3db_ds3db.vConeOrientation.u3.z == 0)
264 TRACE("conning: cones not set\n");
268 /* calculate angle */
269 flAngle = AngleBetweenVectorsDeg(&dsb->ds3db_ds3db.vConeOrientation, &vDistance);
270 /* if by any chance it happens that OutsideConeAngle = InsideConeAngle (that means that conning has no effect) */
271 if (dsb->ds3db_ds3db.dwInsideConeAngle != dsb->ds3db_ds3db.dwOutsideConeAngle)
273 /* my test show that for my way of calc., we need only half of angles */
274 DWORD dwInsideConeAngle = dsb->ds3db_ds3db.dwInsideConeAngle/2;
275 DWORD dwOutsideConeAngle = dsb->ds3db_ds3db.dwOutsideConeAngle/2;
277 if (flAngle < dwInsideConeAngle)
278 flAngle = dwInsideConeAngle;
279 /* min (app defined) volume */
280 if (flAngle > dwOutsideConeAngle)
281 flAngle = dwOutsideConeAngle;
282 /* this probably isn't the right thing, but it's ok for the time being */
283 lVolume += ((dsb->ds3db_ds3db.lConeOutsideVolume)/((dwOutsideConeAngle) - (dwInsideConeAngle))) * flAngle;
285 TRACE("conning: Angle = %f deg; InsideConeAngle(/2) = %ld deg; OutsideConeAngle(/2) = %ld deg; ConeOutsideVolume = %ld => adjusting volume to %f\n",
286 flAngle, dsb->ds3db_ds3db.dwInsideConeAngle/2, dsb->ds3db_ds3db.dwOutsideConeAngle/2, dsb->ds3db_ds3db.lConeOutsideVolume, lVolume);
288 dsb->volpan.lVolume = lVolume;
291 if (dsb->dsound->ds3dl.vPosition.u1.x == dsb->ds3db_ds3db.vPosition.u1.x &&
292 dsb->dsound->ds3dl.vPosition.u2.y == dsb->ds3db_ds3db.vPosition.u2.y &&
293 dsb->dsound->ds3dl.vPosition.u3.z == dsb->ds3db_ds3db.vPosition.u3.z) {
294 dsb->volpan.lPan = 0;
299 vDistance = VectorBetweenTwoPoints(&dsb->dsound->ds3dl.vPosition, &dsb->ds3db_ds3db.vPosition);
300 vLeft = VectorProduct(&dsb->dsound->ds3dl.vOrientFront, &dsb->dsound->ds3dl.vOrientTop);
301 flAngle = AngleBetweenVectorsRad(&vLeft, &vDistance);
302 /* for now, we'll use "linear formula" (which is probably incorrect); if someone has it in book, correct it */
303 dsb->volpan.lPan = 10000*2*flAngle/M_PI - 10000;
305 TRACE("panning: Angle = %f rad, lPan = %ld\n", flAngle, dsb->volpan.lPan);
307 /* FIXME: Doppler Effect disabled since i have no idea which frequency to change and how to do it */
310 if ((VectorMagnitude(&ds3db.vVelocity) == 0) && (VectorMagnitude(&dsb->dsound->ds3dl.vVelocity) == 0))
312 TRACE("doppler: Buffer and Listener don't have velocities\n");
316 /* calculate length of ds3db.vVelocity component which causes Doppler Effect
317 NOTE: if buffer moves TOWARDS the listener, it's velocity component is NEGATIVE
318 if buffer moves AWAY from listener, it's velocity component is POSITIVE */
319 flBufferVel = ProjectVector(&dsb->ds3db_ds3db.vVelocity, &vDistance);
320 /* calculate length of ds3dl.vVelocity component which causes Doppler Effect
321 NOTE: if listener moves TOWARDS the buffer, it's velocity component is POSITIVE
322 if listener moves AWAY from buffer, it's velocity component is NEGATIVE */
323 flListenerVel = ProjectVector(&dsb->dsound->ds3dl.vVelocity, &vDistance);
324 /* formula taken from Gianicoli D.: Physics, 4th edition: */
325 /* FIXME: replace dsb->freq with appropriate frequency ! */
326 flFreq = dsb->freq * ((DEFAULT_VELOCITY + flListenerVel)/(DEFAULT_VELOCITY + flBufferVel));
327 TRACE("doppler: Buffer velocity (component) = %lf, Listener velocity (component) = %lf => Doppler shift: %ld Hz -> %lf Hz\n", flBufferVel, flListenerVel, \
329 /* FIXME: replace following line with correct frequency setting ! */
335 DSOUND_RecalcVolPan(&dsb->volpan);
338 static void DSOUND_Mix3DBuffer(IDirectSoundBufferImpl *dsb)
342 DSOUND_Calc3DBuffer(dsb);
343 DSOUND_ForceRemix(dsb);
346 static void WINAPI DSOUND_ChangeListener(IDirectSound3DListenerImpl *ds3dl)
349 TRACE("(%p)\n",ds3dl);
350 for (i = 0; i < ds3dl->dsound->nrofbuffers; i++)
352 /* some buffers don't have 3d buffer (Ultima IX seems to
353 crash without the following line) */
354 if (ds3dl->dsound->buffers[i]->ds3db == NULL)
356 if (ds3dl->dsound->buffers[i]->ds3db_need_recalc == TRUE)
358 DSOUND_Mix3DBuffer(ds3dl->dsound->buffers[i]);
363 /*******************************************************************************
364 * IDirectSound3DBuffer
367 /* IUnknown methods */
368 static HRESULT WINAPI IDirectSound3DBufferImpl_QueryInterface(
369 LPDIRECTSOUND3DBUFFER iface, REFIID riid, LPVOID *ppobj)
371 ICOM_THIS(IDirectSound3DBufferImpl,iface);
373 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
374 return IDirectSoundBuffer_QueryInterface((LPDIRECTSOUNDBUFFER8)This->dsb, riid, ppobj);
377 static ULONG WINAPI IDirectSound3DBufferImpl_AddRef(LPDIRECTSOUND3DBUFFER iface)
379 ICOM_THIS(IDirectSound3DBufferImpl,iface);
382 TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
383 ref = InterlockedIncrement(&This->ref);
385 FIXME("thread-safety alert! AddRef-ing with a zero refcount!\n");
390 static ULONG WINAPI IDirectSound3DBufferImpl_Release(LPDIRECTSOUND3DBUFFER iface)
392 ICOM_THIS(IDirectSound3DBufferImpl,iface);
395 TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
396 ulReturn = InterlockedDecrement(&This->ref);
398 IDirectSoundBuffer_Release((LPDIRECTSOUNDBUFFER8)This);
399 This->dsb->ds3db = NULL;
400 DeleteCriticalSection(&(This->lock));
401 HeapFree(GetProcessHeap(),0,This);
407 /* IDirectSound3DBuffer methods */
408 static HRESULT WINAPI IDirectSound3DBufferImpl_GetAllParameters(
409 LPDIRECTSOUND3DBUFFER iface,
410 LPDS3DBUFFER lpDs3dBuffer)
412 ICOM_THIS(IDirectSound3DBufferImpl,iface);
413 TRACE("(%p,%p)\n",This,lpDs3dBuffer);
415 if (lpDs3dBuffer == NULL) {
416 WARN("invalid parameter: lpDs3dBuffer == NULL\n");
417 return DSERR_INVALIDPARAM;
420 if (lpDs3dBuffer->dwSize < sizeof(*lpDs3dBuffer)) {
421 WARN("invalid parameter: lpDs3dBuffer->dwSize = %ld < %d\n",lpDs3dBuffer->dwSize, sizeof(*lpDs3dBuffer));
422 return DSERR_INVALIDPARAM;
426 TRACE("returning: all parameters\n");
427 *lpDs3dBuffer = This->dsb->ds3db_ds3db;
432 static HRESULT WINAPI IDirectSound3DBufferImpl_GetConeAngles(
433 LPDIRECTSOUND3DBUFFER iface,
434 LPDWORD lpdwInsideConeAngle,
435 LPDWORD lpdwOutsideConeAngle)
437 ICOM_THIS(IDirectSound3DBufferImpl,iface);
439 TRACE("returning: Inside Cone Angle = %ld degrees; Outside Cone Angle = %ld degrees\n",
440 This->dsb->ds3db_ds3db.dwInsideConeAngle, This->dsb->ds3db_ds3db.dwOutsideConeAngle);
441 *lpdwInsideConeAngle = This->dsb->ds3db_ds3db.dwInsideConeAngle;
442 *lpdwOutsideConeAngle = This->dsb->ds3db_ds3db.dwOutsideConeAngle;
447 static HRESULT WINAPI IDirectSound3DBufferImpl_GetConeOrientation(
448 LPDIRECTSOUND3DBUFFER iface,
449 LPD3DVECTOR lpvConeOrientation)
451 ICOM_THIS(IDirectSound3DBufferImpl,iface);
453 TRACE("returning: Cone Orientation vector = (%f,%f,%f)\n",
454 This->dsb->ds3db_ds3db.vConeOrientation.u1.x,
455 This->dsb->ds3db_ds3db.vConeOrientation.u2.y,
456 This->dsb->ds3db_ds3db.vConeOrientation.u3.z);
457 *lpvConeOrientation = This->dsb->ds3db_ds3db.vConeOrientation;
462 static HRESULT WINAPI IDirectSound3DBufferImpl_GetConeOutsideVolume(
463 LPDIRECTSOUND3DBUFFER iface,
464 LPLONG lplConeOutsideVolume)
466 ICOM_THIS(IDirectSound3DBufferImpl,iface);
468 TRACE("returning: Cone Outside Volume = %ld\n", This->dsb->ds3db_ds3db.lConeOutsideVolume);
469 *lplConeOutsideVolume = This->dsb->ds3db_ds3db.lConeOutsideVolume;
474 static HRESULT WINAPI IDirectSound3DBufferImpl_GetMaxDistance(
475 LPDIRECTSOUND3DBUFFER iface,
476 LPD3DVALUE lpfMaxDistance)
478 ICOM_THIS(IDirectSound3DBufferImpl,iface);
480 TRACE("returning: Max Distance = %f\n", This->dsb->ds3db_ds3db.flMaxDistance);
481 *lpfMaxDistance = This->dsb->ds3db_ds3db.flMaxDistance;
486 static HRESULT WINAPI IDirectSound3DBufferImpl_GetMinDistance(
487 LPDIRECTSOUND3DBUFFER iface,
488 LPD3DVALUE lpfMinDistance)
490 ICOM_THIS(IDirectSound3DBufferImpl,iface);
492 TRACE("returning: Min Distance = %f\n", This->dsb->ds3db_ds3db.flMinDistance);
493 *lpfMinDistance = This->dsb->ds3db_ds3db.flMinDistance;
498 static HRESULT WINAPI IDirectSound3DBufferImpl_GetMode(
499 LPDIRECTSOUND3DBUFFER iface,
502 ICOM_THIS(IDirectSound3DBufferImpl,iface);
504 TRACE("returning: Mode = %ld\n", This->dsb->ds3db_ds3db.dwMode);
505 *lpdwMode = This->dsb->ds3db_ds3db.dwMode;
510 static HRESULT WINAPI IDirectSound3DBufferImpl_GetPosition(
511 LPDIRECTSOUND3DBUFFER iface,
512 LPD3DVECTOR lpvPosition)
514 ICOM_THIS(IDirectSound3DBufferImpl,iface);
516 TRACE("returning: Position vector = (%f,%f,%f)\n",
517 This->dsb->ds3db_ds3db.vPosition.u1.x,
518 This->dsb->ds3db_ds3db.vPosition.u2.y,
519 This->dsb->ds3db_ds3db.vPosition.u3.z);
520 *lpvPosition = This->dsb->ds3db_ds3db.vPosition;
525 static HRESULT WINAPI IDirectSound3DBufferImpl_GetVelocity(
526 LPDIRECTSOUND3DBUFFER iface,
527 LPD3DVECTOR lpvVelocity)
529 ICOM_THIS(IDirectSound3DBufferImpl,iface);
531 TRACE("returning: Velocity vector = (%f,%f,%f)\n",
532 This->dsb->ds3db_ds3db.vVelocity.u1.x,
533 This->dsb->ds3db_ds3db.vVelocity.u2.y,
534 This->dsb->ds3db_ds3db.vVelocity.u3.z);
535 *lpvVelocity = This->dsb->ds3db_ds3db.vVelocity;
540 static HRESULT WINAPI IDirectSound3DBufferImpl_SetAllParameters(
541 LPDIRECTSOUND3DBUFFER iface,
542 LPCDS3DBUFFER lpcDs3dBuffer,
545 ICOM_THIS(IDirectSound3DBufferImpl,iface);
546 DWORD status = DSERR_INVALIDPARAM;
547 TRACE("(%p,%p,%lx)\n",iface,lpcDs3dBuffer,dwApply);
549 if (lpcDs3dBuffer == NULL) {
550 WARN("invalid parameter: lpcDs3dBuffer == NULL\n");
554 if (lpcDs3dBuffer->dwSize != sizeof(DS3DBUFFER)) {
555 WARN("invalid parameter: lpcDs3dBuffer->dwSize = %ld != %d\n",
556 lpcDs3dBuffer->dwSize, sizeof(DS3DBUFFER));
560 EnterCriticalSection(&This->lock);
563 TRACE("setting: all parameters; dwApply = %ld\n", dwApply);
564 This->dsb->ds3db_ds3db = *lpcDs3dBuffer;
566 if (dwApply == DS3D_IMMEDIATE)
568 DSOUND_Mix3DBuffer(This->dsb);
570 This->dsb->ds3db_need_recalc = TRUE;
573 WARN("pointer no longer valid\n");
575 LeaveCriticalSection(&This->lock);
580 static HRESULT WINAPI IDirectSound3DBufferImpl_SetConeAngles(
581 LPDIRECTSOUND3DBUFFER iface,
582 DWORD dwInsideConeAngle,
583 DWORD dwOutsideConeAngle,
586 ICOM_THIS(IDirectSound3DBufferImpl,iface);
587 TRACE("setting: Inside Cone Angle = %ld; Outside Cone Angle = %ld; dwApply = %ld\n",
588 dwInsideConeAngle, dwOutsideConeAngle, dwApply);
590 This->dsb->ds3db_ds3db.dwInsideConeAngle = dwInsideConeAngle;
591 This->dsb->ds3db_ds3db.dwOutsideConeAngle = dwOutsideConeAngle;
592 if (dwApply == DS3D_IMMEDIATE)
594 DSOUND_Mix3DBuffer(This->dsb);
596 This->dsb->ds3db_need_recalc = TRUE;
601 static HRESULT WINAPI IDirectSound3DBufferImpl_SetConeOrientation(
602 LPDIRECTSOUND3DBUFFER iface,
603 D3DVALUE x, D3DVALUE y, D3DVALUE z,
606 ICOM_THIS(IDirectSound3DBufferImpl,iface);
607 TRACE("setting: Cone Orientation vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
609 This->dsb->ds3db_ds3db.vConeOrientation.u1.x = x;
610 This->dsb->ds3db_ds3db.vConeOrientation.u2.y = y;
611 This->dsb->ds3db_ds3db.vConeOrientation.u3.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;
622 static HRESULT WINAPI IDirectSound3DBufferImpl_SetConeOutsideVolume(
623 LPDIRECTSOUND3DBUFFER iface,
624 LONG lConeOutsideVolume,
627 ICOM_THIS(IDirectSound3DBufferImpl,iface);
628 TRACE("setting: ConeOutsideVolume = %ld; dwApply = %ld\n", lConeOutsideVolume, dwApply);
630 This->dsb->ds3db_ds3db.lConeOutsideVolume = lConeOutsideVolume;
631 if (dwApply == DS3D_IMMEDIATE)
633 This->dsb->ds3db_need_recalc = FALSE;
634 DSOUND_Mix3DBuffer(This->dsb);
636 This->dsb->ds3db_need_recalc = TRUE;
641 static HRESULT WINAPI IDirectSound3DBufferImpl_SetMaxDistance(
642 LPDIRECTSOUND3DBUFFER iface,
643 D3DVALUE fMaxDistance,
646 ICOM_THIS(IDirectSound3DBufferImpl,iface);
647 TRACE("setting: MaxDistance = %f; dwApply = %ld\n", fMaxDistance, dwApply);
649 This->dsb->ds3db_ds3db.flMaxDistance = fMaxDistance;
650 if (dwApply == DS3D_IMMEDIATE)
652 This->dsb->ds3db_need_recalc = FALSE;
653 DSOUND_Mix3DBuffer(This->dsb);
655 This->dsb->ds3db_need_recalc = TRUE;
660 static HRESULT WINAPI IDirectSound3DBufferImpl_SetMinDistance(
661 LPDIRECTSOUND3DBUFFER iface,
662 D3DVALUE fMinDistance,
665 ICOM_THIS(IDirectSound3DBufferImpl,iface);
666 TRACE("setting: MinDistance = %f; dwApply = %ld\n", fMinDistance, dwApply);
668 This->dsb->ds3db_ds3db.flMinDistance = fMinDistance;
669 if (dwApply == DS3D_IMMEDIATE)
671 This->dsb->ds3db_need_recalc = FALSE;
672 DSOUND_Mix3DBuffer(This->dsb);
674 This->dsb->ds3db_need_recalc = TRUE;
679 static HRESULT WINAPI IDirectSound3DBufferImpl_SetMode(
680 LPDIRECTSOUND3DBUFFER iface,
684 ICOM_THIS(IDirectSound3DBufferImpl,iface);
685 TRACE("setting: Mode = %ld; dwApply = %ld\n", dwMode, dwApply);
687 This->dsb->ds3db_ds3db.dwMode = dwMode;
688 if (dwApply == DS3D_IMMEDIATE)
690 This->dsb->ds3db_need_recalc = FALSE;
691 DSOUND_Mix3DBuffer(This->dsb);
693 This->dsb->ds3db_need_recalc = TRUE;
698 static HRESULT WINAPI IDirectSound3DBufferImpl_SetPosition(
699 LPDIRECTSOUND3DBUFFER iface,
700 D3DVALUE x, D3DVALUE y, D3DVALUE z,
703 ICOM_THIS(IDirectSound3DBufferImpl,iface);
704 TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
706 This->dsb->ds3db_ds3db.vPosition.u1.x = x;
707 This->dsb->ds3db_ds3db.vPosition.u2.y = y;
708 This->dsb->ds3db_ds3db.vPosition.u3.z = z;
709 if (dwApply == DS3D_IMMEDIATE)
711 This->dsb->ds3db_need_recalc = FALSE;
712 DSOUND_Mix3DBuffer(This->dsb);
714 This->dsb->ds3db_need_recalc = TRUE;
719 static HRESULT WINAPI IDirectSound3DBufferImpl_SetVelocity(
720 LPDIRECTSOUND3DBUFFER iface,
721 D3DVALUE x, D3DVALUE y, D3DVALUE z,
724 ICOM_THIS(IDirectSound3DBufferImpl,iface);
725 TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
727 This->dsb->ds3db_ds3db.vVelocity.u1.x = x;
728 This->dsb->ds3db_ds3db.vVelocity.u2.y = y;
729 This->dsb->ds3db_ds3db.vVelocity.u3.z = z;
730 if (dwApply == DS3D_IMMEDIATE)
732 This->dsb->ds3db_need_recalc = FALSE;
733 DSOUND_Mix3DBuffer(This->dsb);
735 This->dsb->ds3db_need_recalc = TRUE;
740 static ICOM_VTABLE(IDirectSound3DBuffer) ds3dbvt =
742 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
743 /* IUnknown methods */
744 IDirectSound3DBufferImpl_QueryInterface,
745 IDirectSound3DBufferImpl_AddRef,
746 IDirectSound3DBufferImpl_Release,
747 /* IDirectSound3DBuffer methods */
748 IDirectSound3DBufferImpl_GetAllParameters,
749 IDirectSound3DBufferImpl_GetConeAngles,
750 IDirectSound3DBufferImpl_GetConeOrientation,
751 IDirectSound3DBufferImpl_GetConeOutsideVolume,
752 IDirectSound3DBufferImpl_GetMaxDistance,
753 IDirectSound3DBufferImpl_GetMinDistance,
754 IDirectSound3DBufferImpl_GetMode,
755 IDirectSound3DBufferImpl_GetPosition,
756 IDirectSound3DBufferImpl_GetVelocity,
757 IDirectSound3DBufferImpl_SetAllParameters,
758 IDirectSound3DBufferImpl_SetConeAngles,
759 IDirectSound3DBufferImpl_SetConeOrientation,
760 IDirectSound3DBufferImpl_SetConeOutsideVolume,
761 IDirectSound3DBufferImpl_SetMaxDistance,
762 IDirectSound3DBufferImpl_SetMinDistance,
763 IDirectSound3DBufferImpl_SetMode,
764 IDirectSound3DBufferImpl_SetPosition,
765 IDirectSound3DBufferImpl_SetVelocity,
768 HRESULT WINAPI IDirectSound3DBufferImpl_Create(
769 IDirectSoundBufferImpl *This,
770 IDirectSound3DBufferImpl **pds3db)
772 IDirectSound3DBufferImpl *ds3db;
773 TRACE("(%p,%p)\n",This,pds3db);
775 ds3db = (IDirectSound3DBufferImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*ds3db));
778 WARN("out of memory\n");
780 return DSERR_OUTOFMEMORY;
785 ds3db->lpVtbl = &ds3dbvt;
787 ds3db->dsb->ds3db_ds3db.dwSize = sizeof(DS3DBUFFER);
788 ds3db->dsb->ds3db_ds3db.vPosition.u1.x = 0.0;
789 ds3db->dsb->ds3db_ds3db.vPosition.u2.y = 0.0;
790 ds3db->dsb->ds3db_ds3db.vPosition.u3.z = 0.0;
791 ds3db->dsb->ds3db_ds3db.vVelocity.u1.x = 0.0;
792 ds3db->dsb->ds3db_ds3db.vVelocity.u2.y = 0.0;
793 ds3db->dsb->ds3db_ds3db.vVelocity.u3.z = 0.0;
794 ds3db->dsb->ds3db_ds3db.dwInsideConeAngle = DS3D_DEFAULTCONEANGLE;
795 ds3db->dsb->ds3db_ds3db.dwOutsideConeAngle = DS3D_DEFAULTCONEANGLE;
796 ds3db->dsb->ds3db_ds3db.vConeOrientation.u1.x = 0.0;
797 ds3db->dsb->ds3db_ds3db.vConeOrientation.u2.y = 0.0;
798 ds3db->dsb->ds3db_ds3db.vConeOrientation.u3.z = 0.0;
799 ds3db->dsb->ds3db_ds3db.lConeOutsideVolume = DS3D_DEFAULTCONEOUTSIDEVOLUME;
800 ds3db->dsb->ds3db_ds3db.flMinDistance = DS3D_DEFAULTMINDISTANCE;
801 ds3db->dsb->ds3db_ds3db.flMaxDistance = DS3D_DEFAULTMAXDISTANCE;
802 ds3db->dsb->ds3db_ds3db.dwMode = DS3DMODE_NORMAL;
804 ds3db->dsb->ds3db_need_recalc = TRUE;
806 InitializeCriticalSection(&(ds3db->lock));
812 /*******************************************************************************
813 * IDirectSound3DListener
816 /* IUnknown methods */
817 static HRESULT WINAPI IDirectSound3DListenerImpl_QueryInterface(
818 LPDIRECTSOUND3DLISTENER iface, REFIID riid, LPVOID *ppobj)
820 ICOM_THIS(IDirectSound3DListenerImpl,iface);
822 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
825 WARN("invalid parameter\n");
829 *ppobj = NULL; /* assume failure */
831 if ( IsEqualGUID(riid, &IID_IUnknown) ||
832 IsEqualGUID(riid, &IID_IDirectSound3DListener ) ) {
833 IDirectSound3DListener_AddRef((LPDIRECTSOUND3DLISTENER)This);
838 if ( IsEqualGUID(riid, &IID_IDirectSoundBuffer) ) {
839 *ppobj = This->dsound->primary;
840 IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER)*ppobj);
844 FIXME( "Unknown IID %s\n", debugstr_guid( riid ) );
845 return E_NOINTERFACE;
848 static ULONG WINAPI IDirectSound3DListenerImpl_AddRef(LPDIRECTSOUND3DLISTENER iface)
850 ICOM_THIS(IDirectSound3DListenerImpl,iface);
852 TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
854 ref = InterlockedIncrement(&This->ref);
857 FIXME("thread-safety alert! AddRef-ing with a zero refcount!\n");
863 static ULONG WINAPI IDirectSound3DListenerImpl_Release(LPDIRECTSOUND3DLISTENER iface)
865 ICOM_THIS(IDirectSound3DListenerImpl,iface);
868 TRACE("(%p) ref was %ld, thread is %04lx\n",This, This->ref, GetCurrentThreadId());
869 ulReturn = InterlockedDecrement(&This->ref);
871 /* Free all resources */
872 if( ulReturn == 0 ) {
873 IDirectSound8_Release((LPDIRECTSOUND8)This->dsound);
874 This->dsound->listener = 0;
875 HeapFree(GetProcessHeap(),0,This);
881 /* IDirectSound3DListener methods */
882 static HRESULT WINAPI IDirectSound3DListenerImpl_GetAllParameter(
883 LPDIRECTSOUND3DLISTENER iface,
884 LPDS3DLISTENER lpDS3DL)
886 ICOM_THIS(IDirectSound3DListenerImpl,iface);
887 TRACE("(%p,%p)\n",This,lpDS3DL);
889 if (lpDS3DL == NULL) {
890 WARN("invalid parameter: lpDS3DL == NULL\n");
891 return DSERR_INVALIDPARAM;
894 if (lpDS3DL->dwSize < sizeof(*lpDS3DL)) {
895 WARN("invalid parameter: lpDS3DL->dwSize = %ld < %d\n",lpDS3DL->dwSize, sizeof(*lpDS3DL));
896 return DSERR_INVALIDPARAM;
899 TRACE("returning: all parameters\n");
900 *lpDS3DL = This->dsound->ds3dl;
904 static HRESULT WINAPI IDirectSound3DListenerImpl_GetDistanceFactor(
905 LPDIRECTSOUND3DLISTENER iface,
906 LPD3DVALUE lpfDistanceFactor)
908 ICOM_THIS(IDirectSound3DListenerImpl,iface);
909 TRACE("returning: Distance Factor = %f\n", This->dsound->ds3dl.flDistanceFactor);
910 *lpfDistanceFactor = This->dsound->ds3dl.flDistanceFactor;
914 static HRESULT WINAPI IDirectSound3DListenerImpl_GetDopplerFactor(
915 LPDIRECTSOUND3DLISTENER iface,
916 LPD3DVALUE lpfDopplerFactor)
918 ICOM_THIS(IDirectSound3DListenerImpl,iface);
919 TRACE("returning: Doppler Factor = %f\n", This->dsound->ds3dl.flDopplerFactor);
920 *lpfDopplerFactor = This->dsound->ds3dl.flDopplerFactor;
924 static HRESULT WINAPI IDirectSound3DListenerImpl_GetOrientation(
925 LPDIRECTSOUND3DLISTENER iface,
926 LPD3DVECTOR lpvOrientFront,
927 LPD3DVECTOR lpvOrientTop)
929 ICOM_THIS(IDirectSound3DListenerImpl,iface);
930 TRACE("returning: OrientFront vector = (%f,%f,%f); OrientTop vector = (%f,%f,%f)\n", This->dsound->ds3dl.vOrientFront.u1.x, \
931 This->dsound->ds3dl.vOrientFront.u2.y, This->dsound->ds3dl.vOrientFront.u3.z, This->dsound->ds3dl.vOrientTop.u1.x, This->dsound->ds3dl.vOrientTop.u2.y, \
932 This->dsound->ds3dl.vOrientTop.u3.z);
933 *lpvOrientFront = This->dsound->ds3dl.vOrientFront;
934 *lpvOrientTop = This->dsound->ds3dl.vOrientTop;
938 static HRESULT WINAPI IDirectSound3DListenerImpl_GetPosition(
939 LPDIRECTSOUND3DLISTENER iface,
940 LPD3DVECTOR lpvPosition)
942 ICOM_THIS(IDirectSound3DListenerImpl,iface);
943 TRACE("returning: Position vector = (%f,%f,%f)\n", This->dsound->ds3dl.vPosition.u1.x, This->dsound->ds3dl.vPosition.u2.y, This->dsound->ds3dl.vPosition.u3.z);
944 *lpvPosition = This->dsound->ds3dl.vPosition;
948 static HRESULT WINAPI IDirectSound3DListenerImpl_GetRolloffFactor(
949 LPDIRECTSOUND3DLISTENER iface,
950 LPD3DVALUE lpfRolloffFactor)
952 ICOM_THIS(IDirectSound3DListenerImpl,iface);
953 TRACE("returning: RolloffFactor = %f\n", This->dsound->ds3dl.flRolloffFactor);
954 *lpfRolloffFactor = This->dsound->ds3dl.flRolloffFactor;
958 static HRESULT WINAPI IDirectSound3DListenerImpl_GetVelocity(
959 LPDIRECTSOUND3DLISTENER iface,
960 LPD3DVECTOR lpvVelocity)
962 ICOM_THIS(IDirectSound3DListenerImpl,iface);
963 TRACE("returning: Velocity vector = (%f,%f,%f)\n", This->dsound->ds3dl.vVelocity.u1.x, This->dsound->ds3dl.vVelocity.u2.y, This->dsound->ds3dl.vVelocity.u3.z);
964 *lpvVelocity = This->dsound->ds3dl.vVelocity;
968 static HRESULT WINAPI IDirectSound3DListenerImpl_SetAllParameters(
969 LPDIRECTSOUND3DLISTENER iface,
970 LPCDS3DLISTENER lpcDS3DL,
973 ICOM_THIS(IDirectSound3DListenerImpl,iface);
974 TRACE("setting: all parameters; dwApply = %ld\n", dwApply);
975 This->dsound->ds3dl = *lpcDS3DL;
976 if (dwApply == DS3D_IMMEDIATE)
978 This->dsound->ds3dl_need_recalc = FALSE;
979 DSOUND_ChangeListener(This);
981 This->dsound->ds3dl_need_recalc = TRUE;
985 static HRESULT WINAPI IDirectSound3DListenerImpl_SetDistanceFactor(
986 LPDIRECTSOUND3DLISTENER iface,
987 D3DVALUE fDistanceFactor,
990 ICOM_THIS(IDirectSound3DListenerImpl,iface);
991 TRACE("setting: Distance Factor = %f; dwApply = %ld\n", fDistanceFactor, dwApply);
992 This->dsound->ds3dl.flDistanceFactor = fDistanceFactor;
993 if (dwApply == DS3D_IMMEDIATE)
995 This->dsound->ds3dl_need_recalc = FALSE;
996 DSOUND_ChangeListener(This);
998 This->dsound->ds3dl_need_recalc = TRUE;
1002 static HRESULT WINAPI IDirectSound3DListenerImpl_SetDopplerFactor(
1003 LPDIRECTSOUND3DLISTENER iface,
1004 D3DVALUE fDopplerFactor,
1007 ICOM_THIS(IDirectSound3DListenerImpl,iface);
1008 TRACE("setting: Doppler Factor = %f; dwApply = %ld\n", fDopplerFactor, dwApply);
1009 This->dsound->ds3dl.flDopplerFactor = fDopplerFactor;
1010 if (dwApply == DS3D_IMMEDIATE)
1012 This->dsound->ds3dl_need_recalc = FALSE;
1013 DSOUND_ChangeListener(This);
1015 This->dsound->ds3dl_need_recalc = TRUE;
1019 static HRESULT WINAPI IDirectSound3DListenerImpl_SetOrientation(
1020 LPDIRECTSOUND3DLISTENER iface,
1021 D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront,
1022 D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop,
1025 ICOM_THIS(IDirectSound3DListenerImpl,iface);
1026 TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %ld\n", \
1027 xFront, yFront, zFront, xTop, yTop, zTop, dwApply);
1028 This->dsound->ds3dl.vOrientFront.u1.x = xFront;
1029 This->dsound->ds3dl.vOrientFront.u2.y = yFront;
1030 This->dsound->ds3dl.vOrientFront.u3.z = zFront;
1031 This->dsound->ds3dl.vOrientTop.u1.x = xTop;
1032 This->dsound->ds3dl.vOrientTop.u2.y = yTop;
1033 This->dsound->ds3dl.vOrientTop.u3.z = zTop;
1034 if (dwApply == DS3D_IMMEDIATE)
1036 This->dsound->ds3dl_need_recalc = FALSE;
1037 DSOUND_ChangeListener(This);
1039 This->dsound->ds3dl_need_recalc = TRUE;
1043 static HRESULT WINAPI IDirectSound3DListenerImpl_SetPosition(
1044 LPDIRECTSOUND3DLISTENER iface,
1045 D3DVALUE x, D3DVALUE y, D3DVALUE z,
1048 ICOM_THIS(IDirectSound3DListenerImpl,iface);
1049 TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
1050 This->dsound->ds3dl.vPosition.u1.x = x;
1051 This->dsound->ds3dl.vPosition.u2.y = y;
1052 This->dsound->ds3dl.vPosition.u3.z = z;
1053 if (dwApply == DS3D_IMMEDIATE)
1055 This->dsound->ds3dl_need_recalc = FALSE;
1056 DSOUND_ChangeListener(This);
1058 This->dsound->ds3dl_need_recalc = TRUE;
1062 static HRESULT WINAPI IDirectSound3DListenerImpl_SetRolloffFactor(
1063 LPDIRECTSOUND3DLISTENER iface,
1064 D3DVALUE fRolloffFactor,
1067 ICOM_THIS(IDirectSound3DListenerImpl,iface);
1068 TRACE("setting: Rolloff Factor = %f; dwApply = %ld\n", fRolloffFactor, dwApply);
1069 This->dsound->ds3dl.flRolloffFactor = fRolloffFactor;
1070 if (dwApply == DS3D_IMMEDIATE)
1072 This->dsound->ds3dl_need_recalc = FALSE;
1073 DSOUND_ChangeListener(This);
1075 This->dsound->ds3dl_need_recalc = TRUE;
1079 static HRESULT WINAPI IDirectSound3DListenerImpl_SetVelocity(
1080 LPDIRECTSOUND3DLISTENER iface,
1081 D3DVALUE x, D3DVALUE y, D3DVALUE z,
1084 ICOM_THIS(IDirectSound3DListenerImpl,iface);
1085 TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
1086 This->dsound->ds3dl.vVelocity.u1.x = x;
1087 This->dsound->ds3dl.vVelocity.u2.y = y;
1088 This->dsound->ds3dl.vVelocity.u3.z = z;
1089 if (dwApply == DS3D_IMMEDIATE)
1091 This->dsound->ds3dl_need_recalc = FALSE;
1092 DSOUND_ChangeListener(This);
1094 This->dsound->ds3dl_need_recalc = TRUE;
1098 static HRESULT WINAPI IDirectSound3DListenerImpl_CommitDeferredSettings(
1099 LPDIRECTSOUND3DLISTENER iface)
1101 ICOM_THIS(IDirectSound3DListenerImpl,iface);
1103 DSOUND_ChangeListener(This);
1107 static ICOM_VTABLE(IDirectSound3DListener) ds3dlvt =
1109 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1110 /* IUnknown methods */
1111 IDirectSound3DListenerImpl_QueryInterface,
1112 IDirectSound3DListenerImpl_AddRef,
1113 IDirectSound3DListenerImpl_Release,
1114 /* IDirectSound3DListener methods */
1115 IDirectSound3DListenerImpl_GetAllParameter,
1116 IDirectSound3DListenerImpl_GetDistanceFactor,
1117 IDirectSound3DListenerImpl_GetDopplerFactor,
1118 IDirectSound3DListenerImpl_GetOrientation,
1119 IDirectSound3DListenerImpl_GetPosition,
1120 IDirectSound3DListenerImpl_GetRolloffFactor,
1121 IDirectSound3DListenerImpl_GetVelocity,
1122 IDirectSound3DListenerImpl_SetAllParameters,
1123 IDirectSound3DListenerImpl_SetDistanceFactor,
1124 IDirectSound3DListenerImpl_SetDopplerFactor,
1125 IDirectSound3DListenerImpl_SetOrientation,
1126 IDirectSound3DListenerImpl_SetPosition,
1127 IDirectSound3DListenerImpl_SetRolloffFactor,
1128 IDirectSound3DListenerImpl_SetVelocity,
1129 IDirectSound3DListenerImpl_CommitDeferredSettings,
1132 HRESULT WINAPI IDirectSound3DListenerImpl_Create(
1133 PrimaryBufferImpl *This,
1134 IDirectSound3DListenerImpl **pdsl)
1136 IDirectSound3DListenerImpl *dsl;
1137 TRACE("(%p,%p)\n",This,pdsl);
1139 dsl = (IDirectSound3DListenerImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*dsl));
1142 WARN("out of memory\n");
1144 return DSERR_OUTOFMEMORY;
1148 dsl->lpVtbl = &ds3dlvt;
1150 dsl->dsound = This->dsound;
1152 dsl->dsound->ds3dl.dwSize = sizeof(DS3DLISTENER);
1153 dsl->dsound->ds3dl.vPosition.u1.x = 0.0;
1154 dsl->dsound->ds3dl.vPosition.u2.y = 0.0;
1155 dsl->dsound->ds3dl.vPosition.u3.z = 0.0;
1156 dsl->dsound->ds3dl.vVelocity.u1.x = 0.0;
1157 dsl->dsound->ds3dl.vVelocity.u2.y = 0.0;
1158 dsl->dsound->ds3dl.vVelocity.u3.z = 0.0;
1159 dsl->dsound->ds3dl.vOrientFront.u1.x = 0.0;
1160 dsl->dsound->ds3dl.vOrientFront.u2.y = 0.0;
1161 dsl->dsound->ds3dl.vOrientFront.u3.z = 1.0;
1162 dsl->dsound->ds3dl.vOrientTop.u1.x = 0.0;
1163 dsl->dsound->ds3dl.vOrientTop.u2.y = 1.0;
1164 dsl->dsound->ds3dl.vOrientTop.u3.z = 0.0;
1165 dsl->dsound->ds3dl.flDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;
1166 dsl->dsound->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;
1167 dsl->dsound->ds3dl.flDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;
1169 dsl->dsound->ds3dl_need_recalc = TRUE;
1171 InitializeCriticalSection(&dsl->dsound->ds3dl_lock);
1173 IDirectSound8_AddRef((LPDIRECTSOUND8)This->dsound);