- fix some prototypes, remove dxroslayer from dsound
[reactos.git] / reactos / dll / directx / dsound / sound3d.c
index 91879a3..252c763 100644 (file)
@@ -17,7 +17,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 /*
  * Most thread locking is complete. There may be a few race
@@ -44,8 +44,8 @@
 #define NONAMELESSSTRUCT
 #include "windef.h"
 #include "winbase.h"
+#include "winuser.h"
 #include "mmsystem.h"
-#include "winreg.h"
 #include "winternl.h"
 #include "mmddk.h"
 #include "wine/debug.h"
@@ -53,8 +53,6 @@
 #include "dsdriver.h"
 #include "dsound_private.h"
 
-/* default intensity level for human ears */
-#define DEFAULT_INTENSITY 0.000000000001f
 /* default velocity of sound in the air */
 #define DEFAULT_VELOCITY 340
 
@@ -65,29 +63,29 @@ WINE_DEFAULT_DEBUG_CHANNEL(dsound3d);
  */
 
 /* scalar product (i believe it's called dot product in english) */
-static inline D3DVALUE ScalarProduct (LPD3DVECTOR a, LPD3DVECTOR b)
+static inline D3DVALUE ScalarProduct (const D3DVECTOR *a, const D3DVECTOR *b)
 {
        D3DVALUE c;
        c = (a->x*b->x) + (a->y*b->y) + (a->z*b->z);
-       TRACE("(%f,%f,%f) * (%f,%f,%f) = %f)\n", a->x, a->y, a->z, b->x, b->y, \
+       TRACE("(%f,%f,%f) * (%f,%f,%f) = %f)\n", a->x, a->y, a->z, b->x, b->y,
              b->z, c);
        return c;
 }
 
 /* vector product (i believe it's called cross product in english */
-static inline D3DVECTOR VectorProduct (LPD3DVECTOR a, LPD3DVECTOR b)
+static inline D3DVECTOR VectorProduct (const D3DVECTOR *a, const D3DVECTOR *b)
 {
        D3DVECTOR c;
        c.x = (a->y*b->z) - (a->z*b->y);
        c.y = (a->z*b->x) - (a->x*b->z);
        c.z = (a->x*b->y) - (a->y*b->x);
-       TRACE("(%f,%f,%f) x (%f,%f,%f) = (%f,%f,%f)\n", a->x, a->y, a->z, b->x, b->y, \
+       TRACE("(%f,%f,%f) x (%f,%f,%f) = (%f,%f,%f)\n", a->x, a->y, a->z, b->x, b->y,
              b->z, c.x, c.y, c.z);
        return c;
 }
 
 /* magnitude (length) of vector */
-static inline D3DVALUE VectorMagnitude (LPD3DVECTOR a)
+static inline D3DVALUE VectorMagnitude (const D3DVECTOR *a)
 {
        D3DVALUE l;
        l = sqrt (ScalarProduct (a, a));
@@ -104,49 +102,31 @@ static inline D3DVALUE RadToDeg (D3DVALUE angle)
        return newangle;
 }
 
-/* conversion between degrees and radians */
-static inline D3DVALUE DegToRad (D3DVALUE angle)
-{
-       D3DVALUE newangle;
-       newangle = angle * (2*M_PI/360);
-       TRACE("%f deg = %f rad\n", angle, newangle);
-       return newangle;
-}
-
-/* angle between vectors - deg version */
-static inline D3DVALUE AngleBetweenVectorsDeg (LPD3DVECTOR a, LPD3DVECTOR b)
+/* angle between vectors - rad version */
+static inline D3DVALUE AngleBetweenVectorsRad (const D3DVECTOR *a, const D3DVECTOR *b)
 {
        D3DVALUE la, lb, product, angle, cos;
-       /* definition of scalar product: a*b = |a|*|b|*cos...therefore: */
+       /* definition of scalar product: a*b = |a|*|b|*cos... therefore: */
        product = ScalarProduct (a,b);
        la = VectorMagnitude (a);
        lb = VectorMagnitude (b);
+       if (!la || !lb)
+               return 0;
+
        cos = product/(la*lb);
        angle = acos(cos);
-       /* we now have angle in radians */
-       angle = RadToDeg(angle);
-       TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f degrees\n",  a->x, a->y, a->z, b->x,
-             b->y, b->z, angle);
-       return angle;
+       TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f radians (%f degrees)\n",  a->x, a->y, a->z, b->x,
+             b->y, b->z, angle, RadToDeg(angle));
+       return angle;   
 }
 
-/* angle between vectors - rad version */
-static inline D3DVALUE AngleBetweenVectorsRad (LPD3DVECTOR a, LPD3DVECTOR b)
+static inline D3DVALUE AngleBetweenVectorsDeg (const D3DVECTOR *a, const D3DVECTOR *b)
 {
-       D3DVALUE la, lb, product, angle, cos;
-       /* definition of scalar product: a*b = |a|*|b|*cos...therefore: */
-       product = ScalarProduct (a,b);
-       la = VectorMagnitude (a);
-       lb = VectorMagnitude (b);
-       cos = product/(la*lb);
-       angle = acos(cos);
-       TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f radians\n",  a->x, a->y, a->z, b->x,
-             b->y, b->z, angle);
-       return angle;
+       return RadToDeg(AngleBetweenVectorsRad(a, b));
 }
 
 /* calculates vector between two points */
-static inline D3DVECTOR VectorBetweenTwoPoints (LPD3DVECTOR a, LPD3DVECTOR b)
+static inline D3DVECTOR VectorBetweenTwoPoints (const D3DVECTOR *a, const D3DVECTOR *b)
 {
        D3DVECTOR c;
        c.x = b->x - a->x;
@@ -158,7 +138,7 @@ static inline D3DVECTOR VectorBetweenTwoPoints (LPD3DVECTOR a, LPD3DVECTOR b)
 }
 
 /* calculates the length of vector's projection on another vector */
-static inline D3DVALUE ProjectVector (LPD3DVECTOR a, LPD3DVECTOR p)
+static inline D3DVALUE ProjectVector (const D3DVECTOR *a, const D3DVECTOR *p)
 {
        D3DVALUE prod, result;
        prod = ScalarProduct(a, p);
@@ -176,9 +156,6 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
 {
        /* volume, at which the sound will be played after all calcs. */
        D3DVALUE lVolume = 0;
-       /* intensity (used for distance related stuff) */
-       double flIntensity;
-       double flTemp;
        /* stuff for distance related stuff calc. */
        D3DVECTOR vDistance;
        D3DVALUE flDistance = 0;
@@ -194,19 +171,18 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
 
        /* initial buffer volume */
        lVolume = dsb->ds3db_lVolume;
-
+       
        switch (dsb->ds3db_ds3db.dwMode)
        {
                case DS3DMODE_DISABLE:
                        TRACE("3D processing disabled\n");
                        /* this one is here only to eliminate annoying warning message */
                        DSOUND_RecalcVolPan (&dsb->volpan);
-                       DSOUND_ForceRemix (dsb);
                        break;
                case DS3DMODE_NORMAL:
                        TRACE("Normal 3D processing mode\n");
                        /* we need to calculate distance between buffer and listener*/
-                       vDistance = VectorBetweenTwoPoints(&dsb->ds3db_ds3db.vPosition, &dsb->dsound->device->ds3dl.vPosition);
+                       vDistance = VectorBetweenTwoPoints(&dsb->ds3db_ds3db.vPosition, &dsb->device->ds3dl.vPosition);
                        flDistance = VectorMagnitude (&vDistance);
                        break;
                case DS3DMODE_HEADRELATIVE:
@@ -215,35 +191,27 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
                        flDistance = VectorMagnitude (&dsb->ds3db_ds3db.vPosition);
                        break;
        }
-
+       
        if (flDistance > dsb->ds3db_ds3db.flMaxDistance)
        {
                /* some apps don't want you to hear too distant sounds... */
                if (dsb->dsbd.dwFlags & DSBCAPS_MUTE3DATMAXDISTANCE)
                {
                        dsb->volpan.lVolume = DSBVOLUME_MIN;
-                       DSOUND_RecalcVolPan (&dsb->volpan);
+                       DSOUND_RecalcVolPan (&dsb->volpan);             
                        /* i guess mixing here would be a waste of power */
                        return;
                }
                else
                        flDistance = dsb->ds3db_ds3db.flMaxDistance;
-       }
+       }               
 
        if (flDistance < dsb->ds3db_ds3db.flMinDistance)
                flDistance = dsb->ds3db_ds3db.flMinDistance;
-
-       /* 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 */
-       lVolume += 10000; /* ms likes working with negative volume...i don't */
-       lVolume /= 1000; /* convert hundreths of dB into B */
-       /* intensity level (loudness) = log10(Intensity/DefaultIntensity)...therefore */
-       flIntensity = pow(10,lVolume)*DEFAULT_INTENSITY;
-       flTemp = (flDistance/dsb->ds3db_ds3db.flMinDistance)*(flDistance/dsb->ds3db_ds3db.flMinDistance);
-       flIntensity /= flTemp;
-       lVolume = log10(flIntensity/DEFAULT_INTENSITY);
-       lVolume *= 1000; /* convert back to hundreths of dB */
-       lVolume -= 10000; /* we need to do it in ms way */
-       TRACE("dist. att: Distance = %f, MinDistance = %f => adjusting volume %ld to %f\n", flDistance, dsb->ds3db_ds3db.flMinDistance, dsb->ds3db_lVolume, lVolume);
+       
+       /* attenuation proportional to the distance squared, converted to millibels as in lVolume*/
+       lVolume -= log10(flDistance/dsb->ds3db_ds3db.flMinDistance * flDistance/dsb->ds3db_ds3db.flMinDistance)*1000;
+       TRACE("dist. att: Distance = %f, MinDistance = %f => adjusting volume %d to %f\n", flDistance, dsb->ds3db_ds3db.flMinDistance, dsb->ds3db_lVolume, lVolume);
 
        /* conning */
        /* sometimes it happens that vConeOrientation vector = (0,0,0); in this case angle is "nan" and it's useless*/
@@ -261,6 +229,9 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
                        /* my test show that for my way of calc., we need only half of angles */
                        DWORD dwInsideConeAngle = dsb->ds3db_ds3db.dwInsideConeAngle/2;
                        DWORD dwOutsideConeAngle = dsb->ds3db_ds3db.dwOutsideConeAngle/2;
+                       if (dwOutsideConeAngle == dwInsideConeAngle)
+                               ++dwOutsideConeAngle;
+
                        /* full volume */
                        if (flAngle < dwInsideConeAngle)
                                flAngle = dwInsideConeAngle;
@@ -270,55 +241,57 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb)
                        /* this probably isn't the right thing, but it's ok for the time being */
                        lVolume += ((dsb->ds3db_ds3db.lConeOutsideVolume)/((dwOutsideConeAngle) - (dwInsideConeAngle))) * flAngle;
                }
-               TRACE("conning: Angle = %f deg; InsideConeAngle(/2) = %ld deg; OutsideConeAngle(/2) = %ld deg; ConeOutsideVolume = %ld => adjusting volume to %f\n",
+               TRACE("conning: Angle = %f deg; InsideConeAngle(/2) = %d deg; OutsideConeAngle(/2) = %d deg; ConeOutsideVolume = %d => adjusting volume to %f\n",
                       flAngle, dsb->ds3db_ds3db.dwInsideConeAngle/2, dsb->ds3db_ds3db.dwOutsideConeAngle/2, dsb->ds3db_ds3db.lConeOutsideVolume, lVolume);
        }
        dsb->volpan.lVolume = lVolume;
-
+       
        /* panning */
-       if (dsb->dsound->device->ds3dl.vPosition.x == dsb->ds3db_ds3db.vPosition.x &&
-           dsb->dsound->device->ds3dl.vPosition.y == dsb->ds3db_ds3db.vPosition.y &&
-           dsb->dsound->device->ds3dl.vPosition.z == dsb->ds3db_ds3db.vPosition.z) {
+       if (dsb->device->ds3dl.vPosition.x == dsb->ds3db_ds3db.vPosition.x &&
+           dsb->device->ds3dl.vPosition.y == dsb->ds3db_ds3db.vPosition.y &&
+           dsb->device->ds3dl.vPosition.z == dsb->ds3db_ds3db.vPosition.z) {
                dsb->volpan.lPan = 0;
                flAngle = 0.0;
        }
        else
        {
-               vDistance = VectorBetweenTwoPoints(&dsb->dsound->device->ds3dl.vPosition, &dsb->ds3db_ds3db.vPosition);
-               vLeft = VectorProduct(&dsb->dsound->device->ds3dl.vOrientFront, &dsb->dsound->device->ds3dl.vOrientTop);
+               vDistance = VectorBetweenTwoPoints(&dsb->device->ds3dl.vPosition, &dsb->ds3db_ds3db.vPosition);
+               vLeft = VectorProduct(&dsb->device->ds3dl.vOrientFront, &dsb->device->ds3dl.vOrientTop);
                flAngle = AngleBetweenVectorsRad(&vLeft, &vDistance);
                /* for now, we'll use "linear formula" (which is probably incorrect); if someone has it in book, correct it */
                dsb->volpan.lPan = 10000*2*flAngle/M_PI - 10000;
        }
-       TRACE("panning: Angle = %f rad, lPan = %ld\n", flAngle, dsb->volpan.lPan);
+       TRACE("panning: Angle = %f rad, lPan = %d\n", flAngle, dsb->volpan.lPan);
 
        /* FIXME: Doppler Effect disabled since i have no idea which frequency to change and how to do it */
-#if 0
+#if 0  
        /* doppler shift*/
-       if ((VectorMagnitude(&ds3db.vVelocity) == 0) && (VectorMagnitude(&dsb->dsound->device->ds3dl.vVelocity) == 0))
+       if ((VectorMagnitude(&ds3db_ds3db.vVelocity) == 0) && (VectorMagnitude(&dsb->device->ds3dl.vVelocity) == 0))
        {
                TRACE("doppler: Buffer and Listener don't have velocities\n");
        }
-       else
+       else if (ds3db_ds3db.vVelocity != dsb->device->ds3dl.vVelocity)
        {
-               /* calculate length of ds3db.vVelocity component which causes Doppler Effect
+               /* calculate length of ds3db_ds3db.vVelocity component which causes Doppler Effect
                   NOTE: if buffer moves TOWARDS the listener, it's velocity component is NEGATIVE
                         if buffer moves AWAY from listener, it's velocity component is POSITIVE */
                flBufferVel = ProjectVector(&dsb->ds3db_ds3db.vVelocity, &vDistance);
                /* calculate length of ds3dl.vVelocity component which causes Doppler Effect
                   NOTE: if listener moves TOWARDS the buffer, it's velocity component is POSITIVE
                         if listener moves AWAY from buffer, it's velocity component is NEGATIVE */
-               flListenerVel = ProjectVector(&dsb->dsound->device->ds3dl.vVelocity, &vDistance);
+               flListenerVel = ProjectVector(&dsb->device->ds3dl.vVelocity, &vDistance);
                /* formula taken from Gianicoli D.: Physics, 4th edition: */
                /* FIXME: replace dsb->freq with appropriate frequency ! */
                flFreq = dsb->freq * ((DEFAULT_VELOCITY + flListenerVel)/(DEFAULT_VELOCITY + flBufferVel));
-               TRACE("doppler: Buffer velocity (component) = %lf, Listener velocity (component) = %lf => Doppler shift: %ld Hz -> %lf Hz\n", flBufferVel, flListenerVel, \
+               TRACE("doppler: Buffer velocity (component) = %lf, Listener velocity (component) = %lf => Doppler shift: %ld Hz -> %lf Hz\n", flBufferVel, flListenerVel,
                      dsb->freq, flFreq);
                /* FIXME: replace following line with correct frequency setting ! */
                dsb->freq = flFreq;
+               DSOUND_RecalcFormat(dsb);
+               DSOUND_MixToTemporary(dsb, 0, dsb->buflen);
        }
-#endif
-
+#endif 
+       
        /* time for remix */
        DSOUND_RecalcVolPan(&dsb->volpan);
 }
@@ -328,22 +301,18 @@ static void DSOUND_Mix3DBuffer(IDirectSoundBufferImpl *dsb)
        TRACE("(%p)\n",dsb);
 
        DSOUND_Calc3DBuffer(dsb);
-       DSOUND_ForceRemix(dsb);
 }
 
-static void WINAPI DSOUND_ChangeListener(IDirectSound3DListenerImpl *ds3dl)
+static void DSOUND_ChangeListener(IDirectSound3DListenerImpl *ds3dl)
 {
        int i;
        TRACE("(%p)\n",ds3dl);
-       for (i = 0; i < ds3dl->dsound->device->nrofbuffers; i++)
+       for (i = 0; i < ds3dl->device->nrofbuffers; i++)
        {
-               /* some buffers don't have 3d buffer (Ultima IX seems to
-               crash without the following line) */
-               if (ds3dl->dsound->device->buffers[i]->ds3db == NULL)
-                       continue;
-               if (ds3dl->dsound->device->buffers[i]->ds3db_need_recalc)
+               /* check if this buffer is waiting for recalculation */
+               if (ds3dl->device->buffers[i]->ds3db_need_recalc)
                {
-                       DSOUND_Mix3DBuffer(ds3dl->dsound->device->buffers[i]);
+                       DSOUND_Mix3DBuffer(ds3dl->device->buffers[i]);
                }
        }
 }
@@ -366,7 +335,7 @@ static ULONG WINAPI IDirectSound3DBufferImpl_AddRef(LPDIRECTSOUND3DBUFFER iface)
 {
     IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
     ULONG ref = InterlockedIncrement(&(This->ref));
-    TRACE("(%p) ref was %ld\n", This, ref - 1);
+    TRACE("(%p) ref was %d\n", This, ref - 1);
     return ref;
 }
 
@@ -374,7 +343,7 @@ static ULONG WINAPI IDirectSound3DBufferImpl_Release(LPDIRECTSOUND3DBUFFER iface
 {
     IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
     ULONG ref = InterlockedDecrement(&(This->ref));
-    TRACE("(%p) ref was %ld\n", This, ref + 1);
+    TRACE("(%p) ref was %d\n", This, ref + 1);
 
     if (!ref) {
         This->dsb->ds3db = NULL;
@@ -399,10 +368,10 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_GetAllParameters(
        }
 
        if (lpDs3dBuffer->dwSize < sizeof(*lpDs3dBuffer)) {
-               WARN("invalid parameter: lpDs3dBuffer->dwSize = %ld < %d\n",lpDs3dBuffer->dwSize, sizeof(*lpDs3dBuffer));
+               WARN("invalid parameter: lpDs3dBuffer->dwSize = %d\n",lpDs3dBuffer->dwSize);
                return DSERR_INVALIDPARAM;
        }
-
+       
        TRACE("returning: all parameters\n");
        *lpDs3dBuffer = This->dsb->ds3db_ds3db;
        return DS_OK;
@@ -414,7 +383,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_GetConeAngles(
        LPDWORD lpdwOutsideConeAngle)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("returning: Inside Cone Angle = %ld degrees; Outside Cone Angle = %ld degrees\n",
+       TRACE("returning: Inside Cone Angle = %d degrees; Outside Cone Angle = %d degrees\n",
                This->dsb->ds3db_ds3db.dwInsideConeAngle, This->dsb->ds3db_ds3db.dwOutsideConeAngle);
        *lpdwInsideConeAngle = This->dsb->ds3db_ds3db.dwInsideConeAngle;
        *lpdwOutsideConeAngle = This->dsb->ds3db_ds3db.dwOutsideConeAngle;
@@ -439,7 +408,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_GetConeOutsideVolume(
        LPLONG lplConeOutsideVolume)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("returning: Cone Outside Volume = %ld\n", This->dsb->ds3db_ds3db.lConeOutsideVolume);
+       TRACE("returning: Cone Outside Volume = %d\n", This->dsb->ds3db_ds3db.lConeOutsideVolume);
        *lplConeOutsideVolume = This->dsb->ds3db_ds3db.lConeOutsideVolume;
        return DS_OK;
 }
@@ -469,7 +438,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_GetMode(
        LPDWORD lpdwMode)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("returning: Mode = %ld\n", This->dsb->ds3db_ds3db.dwMode);
+       TRACE("returning: Mode = %d\n", This->dsb->ds3db_ds3db.dwMode);
        *lpdwMode = This->dsb->ds3db_ds3db.dwMode;
        return DS_OK;
 }
@@ -507,7 +476,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetAllParameters(
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
        DWORD status = DSERR_INVALIDPARAM;
-       TRACE("(%p,%p,%lx)\n",iface,lpcDs3dBuffer,dwApply);
+       TRACE("(%p,%p,%x)\n",iface,lpcDs3dBuffer,dwApply);
 
        if (lpcDs3dBuffer == NULL) {
                WARN("invalid parameter: lpcDs3dBuffer == NULL\n");
@@ -515,12 +484,11 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetAllParameters(
        }
 
        if (lpcDs3dBuffer->dwSize != sizeof(DS3DBUFFER)) {
-               WARN("invalid parameter: lpcDs3dBuffer->dwSize = %ld != %d\n",
-                       lpcDs3dBuffer->dwSize, sizeof(DS3DBUFFER));
+               WARN("invalid parameter: lpcDs3dBuffer->dwSize = %d\n", lpcDs3dBuffer->dwSize);
                return status;
        }
 
-       TRACE("setting: all parameters; dwApply = %ld\n", dwApply);
+       TRACE("setting: all parameters; dwApply = %d\n", dwApply);
        This->dsb->ds3db_ds3db = *lpcDs3dBuffer;
 
        if (dwApply == DS3D_IMMEDIATE)
@@ -540,7 +508,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetConeAngles(
        DWORD dwApply)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("setting: Inside Cone Angle = %ld; Outside Cone Angle = %ld; dwApply = %ld\n",
+       TRACE("setting: Inside Cone Angle = %d; Outside Cone Angle = %d; dwApply = %d\n",
                dwInsideConeAngle, dwOutsideConeAngle, dwApply);
        This->dsb->ds3db_ds3db.dwInsideConeAngle = dwInsideConeAngle;
        This->dsb->ds3db_ds3db.dwOutsideConeAngle = dwOutsideConeAngle;
@@ -558,7 +526,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetConeOrientation(
        DWORD dwApply)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("setting: Cone Orientation vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
+       TRACE("setting: Cone Orientation vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
        This->dsb->ds3db_ds3db.vConeOrientation.x = x;
        This->dsb->ds3db_ds3db.vConeOrientation.y = y;
        This->dsb->ds3db_ds3db.vConeOrientation.z = z;
@@ -577,7 +545,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetConeOutsideVolume(
        DWORD dwApply)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("setting: ConeOutsideVolume = %ld; dwApply = %ld\n", lConeOutsideVolume, dwApply);
+       TRACE("setting: ConeOutsideVolume = %d; dwApply = %d\n", lConeOutsideVolume, dwApply);
        This->dsb->ds3db_ds3db.lConeOutsideVolume = lConeOutsideVolume;
        if (dwApply == DS3D_IMMEDIATE)
        {
@@ -594,7 +562,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetMaxDistance(
        DWORD dwApply)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("setting: MaxDistance = %f; dwApply = %ld\n", fMaxDistance, dwApply);
+       TRACE("setting: MaxDistance = %f; dwApply = %d\n", fMaxDistance, dwApply);
        This->dsb->ds3db_ds3db.flMaxDistance = fMaxDistance;
        if (dwApply == DS3D_IMMEDIATE)
        {
@@ -611,7 +579,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetMinDistance(
        DWORD dwApply)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("setting: MinDistance = %f; dwApply = %ld\n", fMinDistance, dwApply);
+       TRACE("setting: MinDistance = %f; dwApply = %d\n", fMinDistance, dwApply);
        This->dsb->ds3db_ds3db.flMinDistance = fMinDistance;
        if (dwApply == DS3D_IMMEDIATE)
        {
@@ -628,7 +596,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetMode(
        DWORD dwApply)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("setting: Mode = %ld; dwApply = %ld\n", dwMode, dwApply);
+       TRACE("setting: Mode = %d; dwApply = %d\n", dwMode, dwApply);
        This->dsb->ds3db_ds3db.dwMode = dwMode;
        if (dwApply == DS3D_IMMEDIATE)
        {
@@ -645,7 +613,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetPosition(
        DWORD dwApply)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
+       TRACE("setting: Position vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
        This->dsb->ds3db_ds3db.vPosition.x = x;
        This->dsb->ds3db_ds3db.vPosition.y = y;
        This->dsb->ds3db_ds3db.vPosition.z = z;
@@ -664,7 +632,7 @@ static HRESULT WINAPI IDirectSound3DBufferImpl_SetVelocity(
        DWORD dwApply)
 {
        IDirectSound3DBufferImpl *This = (IDirectSound3DBufferImpl *)iface;
-       TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
+       TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
        This->dsb->ds3db_ds3db.vVelocity.x = x;
        This->dsb->ds3db_ds3db.vVelocity.y = y;
        This->dsb->ds3db_ds3db.vVelocity.z = z;
@@ -704,7 +672,7 @@ static const IDirectSound3DBufferVtbl ds3dbvt =
        IDirectSound3DBufferImpl_SetVelocity,
 };
 
-HRESULT WINAPI IDirectSound3DBufferImpl_Create(
+HRESULT IDirectSound3DBufferImpl_Create(
        IDirectSoundBufferImpl *dsb,
        IDirectSound3DBufferImpl **pds3db)
 {
@@ -748,7 +716,7 @@ HRESULT WINAPI IDirectSound3DBufferImpl_Create(
        return S_OK;
 }
 
-HRESULT WINAPI IDirectSound3DBufferImpl_Destroy(
+HRESULT IDirectSound3DBufferImpl_Destroy(
     IDirectSound3DBufferImpl *pds3db)
 {
     TRACE("(%p)\n",pds3db);
@@ -785,10 +753,10 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_QueryInterface(
        }
 
        if ( IsEqualGUID(riid, &IID_IDirectSoundBuffer) ) {
-               if (!This->dsound->device->primary)
-                       PrimaryBufferImpl_Create(This->dsound, &(This->dsound->device->primary), &(This->dsound->device->dsbd));
-               if (This->dsound->device->primary) {
-                       *ppobj = This->dsound->device->primary;
+               if (!This->device->primary)
+                       PrimaryBufferImpl_Create(This->device, &(This->device->primary), &(This->device->dsbd));
+               if (This->device->primary) {
+                       *ppobj = This->device->primary;
                        IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER)*ppobj);
                        return S_OK;
                }
@@ -802,7 +770,7 @@ static ULONG WINAPI IDirectSound3DListenerImpl_AddRef(LPDIRECTSOUND3DLISTENER if
 {
     IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
     ULONG ref = InterlockedIncrement(&(This->ref));
-    TRACE("(%p) ref was %ld\n", This, ref - 1);
+    TRACE("(%p) ref was %d\n", This, ref - 1);
     return ref;
 }
 
@@ -810,10 +778,10 @@ static ULONG WINAPI IDirectSound3DListenerImpl_Release(LPDIRECTSOUND3DLISTENER i
 {
     IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
     ULONG ref = InterlockedDecrement(&(This->ref));
-    TRACE("(%p) ref was %ld\n", This, ref + 1);
+    TRACE("(%p) ref was %d\n", This, ref + 1);
 
     if (!ref) {
-        This->dsound->device->listener = 0;
+        This->device->listener = 0;
         HeapFree(GetProcessHeap(), 0, This);
         TRACE("(%p) released\n", This);
     }
@@ -834,12 +802,12 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetAllParameter(
        }
 
        if (lpDS3DL->dwSize < sizeof(*lpDS3DL)) {
-               WARN("invalid parameter: lpDS3DL->dwSize = %ld < %d\n",lpDS3DL->dwSize, sizeof(*lpDS3DL));
+               WARN("invalid parameter: lpDS3DL->dwSize = %d\n",lpDS3DL->dwSize);
                return DSERR_INVALIDPARAM;
        }
-
+       
        TRACE("returning: all parameters\n");
-       *lpDS3DL = This->dsound->device->ds3dl;
+       *lpDS3DL = This->device->ds3dl;
        return DS_OK;
 }
 
@@ -848,8 +816,8 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetDistanceFactor(
        LPD3DVALUE lpfDistanceFactor)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("returning: Distance Factor = %f\n", This->dsound->device->ds3dl.flDistanceFactor);
-       *lpfDistanceFactor = This->dsound->device->ds3dl.flDistanceFactor;
+       TRACE("returning: Distance Factor = %f\n", This->device->ds3dl.flDistanceFactor);
+       *lpfDistanceFactor = This->device->ds3dl.flDistanceFactor;
        return DS_OK;
 }
 
@@ -858,8 +826,8 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetDopplerFactor(
        LPD3DVALUE lpfDopplerFactor)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("returning: Doppler Factor = %f\n", This->dsound->device->ds3dl.flDopplerFactor);
-       *lpfDopplerFactor = This->dsound->device->ds3dl.flDopplerFactor;
+       TRACE("returning: Doppler Factor = %f\n", This->device->ds3dl.flDopplerFactor);
+       *lpfDopplerFactor = This->device->ds3dl.flDopplerFactor;
        return DS_OK;
 }
 
@@ -869,11 +837,11 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetOrientation(
        LPD3DVECTOR lpvOrientTop)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("returning: OrientFront vector = (%f,%f,%f); OrientTop vector = (%f,%f,%f)\n", This->dsound->device->ds3dl.vOrientFront.x, \
-       This->dsound->device->ds3dl.vOrientFront.y, This->dsound->device->ds3dl.vOrientFront.z, This->dsound->device->ds3dl.vOrientTop.x, This->dsound->device->ds3dl.vOrientTop.y, \
-       This->dsound->device->ds3dl.vOrientTop.z);
-       *lpvOrientFront = This->dsound->device->ds3dl.vOrientFront;
-       *lpvOrientTop = This->dsound->device->ds3dl.vOrientTop;
+       TRACE("returning: OrientFront vector = (%f,%f,%f); OrientTop vector = (%f,%f,%f)\n", This->device->ds3dl.vOrientFront.x,
+       This->device->ds3dl.vOrientFront.y, This->device->ds3dl.vOrientFront.z, This->device->ds3dl.vOrientTop.x, This->device->ds3dl.vOrientTop.y,
+       This->device->ds3dl.vOrientTop.z);
+       *lpvOrientFront = This->device->ds3dl.vOrientFront;
+       *lpvOrientTop = This->device->ds3dl.vOrientTop;
        return DS_OK;
 }
 
@@ -882,8 +850,8 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetPosition(
        LPD3DVECTOR lpvPosition)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("returning: Position vector = (%f,%f,%f)\n", This->dsound->device->ds3dl.vPosition.x, This->dsound->device->ds3dl.vPosition.y, This->dsound->device->ds3dl.vPosition.z);
-       *lpvPosition = This->dsound->device->ds3dl.vPosition;
+       TRACE("returning: Position vector = (%f,%f,%f)\n", This->device->ds3dl.vPosition.x, This->device->ds3dl.vPosition.y, This->device->ds3dl.vPosition.z);
+       *lpvPosition = This->device->ds3dl.vPosition;
        return DS_OK;
 }
 
@@ -892,8 +860,8 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetRolloffFactor(
        LPD3DVALUE lpfRolloffFactor)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("returning: RolloffFactor = %f\n", This->dsound->device->ds3dl.flRolloffFactor);
-       *lpfRolloffFactor = This->dsound->device->ds3dl.flRolloffFactor;
+       TRACE("returning: RolloffFactor = %f\n", This->device->ds3dl.flRolloffFactor);
+       *lpfRolloffFactor = This->device->ds3dl.flRolloffFactor;
        return DS_OK;
 }
 
@@ -902,8 +870,8 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_GetVelocity(
        LPD3DVECTOR lpvVelocity)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("returning: Velocity vector = (%f,%f,%f)\n", This->dsound->device->ds3dl.vVelocity.x, This->dsound->device->ds3dl.vVelocity.y, This->dsound->device->ds3dl.vVelocity.z);
-       *lpvVelocity = This->dsound->device->ds3dl.vVelocity;
+       TRACE("returning: Velocity vector = (%f,%f,%f)\n", This->device->ds3dl.vVelocity.x, This->device->ds3dl.vVelocity.y, This->device->ds3dl.vVelocity.z);
+       *lpvVelocity = This->device->ds3dl.vVelocity;
        return DS_OK;
 }
 
@@ -913,14 +881,14 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetAllParameters(
        DWORD dwApply)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("setting: all parameters; dwApply = %ld\n", dwApply);
-       This->dsound->device->ds3dl = *lpcDS3DL;
+       TRACE("setting: all parameters; dwApply = %d\n", dwApply);
+       This->device->ds3dl = *lpcDS3DL;
        if (dwApply == DS3D_IMMEDIATE)
        {
-               This->dsound->device->ds3dl_need_recalc = FALSE;
+               This->device->ds3dl_need_recalc = FALSE;
                DSOUND_ChangeListener(This);
        }
-       This->dsound->device->ds3dl_need_recalc = TRUE;
+       This->device->ds3dl_need_recalc = TRUE;
        return DS_OK;
 }
 
@@ -930,14 +898,14 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetDistanceFactor(
        DWORD dwApply)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("setting: Distance Factor = %f; dwApply = %ld\n", fDistanceFactor, dwApply);
-       This->dsound->device->ds3dl.flDistanceFactor = fDistanceFactor;
+       TRACE("setting: Distance Factor = %f; dwApply = %d\n", fDistanceFactor, dwApply);
+       This->device->ds3dl.flDistanceFactor = fDistanceFactor;
        if (dwApply == DS3D_IMMEDIATE)
        {
-               This->dsound->device->ds3dl_need_recalc = FALSE;
+               This->device->ds3dl_need_recalc = FALSE;
                DSOUND_ChangeListener(This);
        }
-       This->dsound->device->ds3dl_need_recalc = TRUE;
+       This->device->ds3dl_need_recalc = TRUE;
        return DS_OK;
 }
 
@@ -947,14 +915,14 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetDopplerFactor(
        DWORD dwApply)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("setting: Doppler Factor = %f; dwApply = %ld\n", fDopplerFactor, dwApply);
-       This->dsound->device->ds3dl.flDopplerFactor = fDopplerFactor;
+       TRACE("setting: Doppler Factor = %f; dwApply = %d\n", fDopplerFactor, dwApply);
+       This->device->ds3dl.flDopplerFactor = fDopplerFactor;
        if (dwApply == DS3D_IMMEDIATE)
        {
-               This->dsound->device->ds3dl_need_recalc = FALSE;
+               This->device->ds3dl_need_recalc = FALSE;
                DSOUND_ChangeListener(This);
        }
-       This->dsound->device->ds3dl_need_recalc = TRUE;
+       This->device->ds3dl_need_recalc = TRUE;
        return DS_OK;
 }
 
@@ -965,20 +933,20 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetOrientation(
        DWORD dwApply)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %ld\n", \
+       TRACE("setting: Front vector = (%f,%f,%f); Top vector = (%f,%f,%f); dwApply = %d\n",
        xFront, yFront, zFront, xTop, yTop, zTop, dwApply);
-       This->dsound->device->ds3dl.vOrientFront.x = xFront;
-       This->dsound->device->ds3dl.vOrientFront.y = yFront;
-       This->dsound->device->ds3dl.vOrientFront.z = zFront;
-       This->dsound->device->ds3dl.vOrientTop.x = xTop;
-       This->dsound->device->ds3dl.vOrientTop.y = yTop;
-       This->dsound->device->ds3dl.vOrientTop.z = zTop;
+       This->device->ds3dl.vOrientFront.x = xFront;
+       This->device->ds3dl.vOrientFront.y = yFront;
+       This->device->ds3dl.vOrientFront.z = zFront;
+       This->device->ds3dl.vOrientTop.x = xTop;
+       This->device->ds3dl.vOrientTop.y = yTop;
+       This->device->ds3dl.vOrientTop.z = zTop;
        if (dwApply == DS3D_IMMEDIATE)
        {
-               This->dsound->device->ds3dl_need_recalc = FALSE;
+               This->device->ds3dl_need_recalc = FALSE;
                DSOUND_ChangeListener(This);
        }
-       This->dsound->device->ds3dl_need_recalc = TRUE;
+       This->device->ds3dl_need_recalc = TRUE;
        return DS_OK;
 }
 
@@ -988,16 +956,16 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetPosition(
        DWORD dwApply)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("setting: Position vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
-       This->dsound->device->ds3dl.vPosition.x = x;
-       This->dsound->device->ds3dl.vPosition.y = y;
-       This->dsound->device->ds3dl.vPosition.z = z;
+       TRACE("setting: Position vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
+       This->device->ds3dl.vPosition.x = x;
+       This->device->ds3dl.vPosition.y = y;
+       This->device->ds3dl.vPosition.z = z;
        if (dwApply == DS3D_IMMEDIATE)
        {
-               This->dsound->device->ds3dl_need_recalc = FALSE;
+               This->device->ds3dl_need_recalc = FALSE;
                DSOUND_ChangeListener(This);
        }
-       This->dsound->device->ds3dl_need_recalc = TRUE;
+       This->device->ds3dl_need_recalc = TRUE;
        return DS_OK;
 }
 
@@ -1007,14 +975,14 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetRolloffFactor(
        DWORD dwApply)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("setting: Rolloff Factor = %f; dwApply = %ld\n", fRolloffFactor, dwApply);
-       This->dsound->device->ds3dl.flRolloffFactor = fRolloffFactor;
+       TRACE("setting: Rolloff Factor = %f; dwApply = %d\n", fRolloffFactor, dwApply);
+       This->device->ds3dl.flRolloffFactor = fRolloffFactor;
        if (dwApply == DS3D_IMMEDIATE)
        {
-               This->dsound->device->ds3dl_need_recalc = FALSE;
+               This->device->ds3dl_need_recalc = FALSE;
                DSOUND_ChangeListener(This);
        }
-       This->dsound->device->ds3dl_need_recalc = TRUE;
+       This->device->ds3dl_need_recalc = TRUE;
        return DS_OK;
 }
 
@@ -1024,16 +992,16 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_SetVelocity(
        DWORD dwApply)
 {
        IDirectSound3DListenerImpl *This = (IDirectSound3DListenerImpl *)iface;
-       TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %ld\n", x, y, z, dwApply);
-       This->dsound->device->ds3dl.vVelocity.x = x;
-       This->dsound->device->ds3dl.vVelocity.y = y;
-       This->dsound->device->ds3dl.vVelocity.z = z;
+       TRACE("setting: Velocity vector = (%f,%f,%f); dwApply = %d\n", x, y, z, dwApply);
+       This->device->ds3dl.vVelocity.x = x;
+       This->device->ds3dl.vVelocity.y = y;
+       This->device->ds3dl.vVelocity.z = z;
        if (dwApply == DS3D_IMMEDIATE)
        {
-               This->dsound->device->ds3dl_need_recalc = FALSE;
+               This->device->ds3dl_need_recalc = FALSE;
                DSOUND_ChangeListener(This);
        }
-       This->dsound->device->ds3dl_need_recalc = TRUE;
+       This->device->ds3dl_need_recalc = TRUE;
        return DS_OK;
 }
 
@@ -1070,45 +1038,45 @@ static const IDirectSound3DListenerVtbl ds3dlvt =
        IDirectSound3DListenerImpl_CommitDeferredSettings,
 };
 
-HRESULT WINAPI IDirectSound3DListenerImpl_Create(
-       PrimaryBufferImpl *This,
-       IDirectSound3DListenerImpl **pdsl)
+HRESULT IDirectSound3DListenerImpl_Create(
+       DirectSoundDevice * device,
+       IDirectSound3DListenerImpl ** ppdsl)
 {
-       IDirectSound3DListenerImpl *dsl;
-       TRACE("(%p,%p)\n",This,pdsl);
+       IDirectSound3DListenerImpl *pdsl;
+       TRACE("(%p,%p)\n",device,ppdsl);
 
-       dsl = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*dsl));
+       pdsl = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*pdsl));
 
-       if (dsl == NULL) {
+       if (pdsl == NULL) {
                WARN("out of memory\n");
-               *pdsl = 0;
+               *ppdsl = 0;
                return DSERR_OUTOFMEMORY;
        }
 
-       dsl->ref = 0;
-       dsl->lpVtbl = &ds3dlvt;
-
-       dsl->dsound = This->dsound;
-
-       dsl->dsound->device->ds3dl.dwSize = sizeof(DS3DLISTENER);
-       dsl->dsound->device->ds3dl.vPosition.x = 0.0;
-       dsl->dsound->device->ds3dl.vPosition.y = 0.0;
-       dsl->dsound->device->ds3dl.vPosition.z = 0.0;
-       dsl->dsound->device->ds3dl.vVelocity.x = 0.0;
-       dsl->dsound->device->ds3dl.vVelocity.y = 0.0;
-       dsl->dsound->device->ds3dl.vVelocity.z = 0.0;
-       dsl->dsound->device->ds3dl.vOrientFront.x = 0.0;
-       dsl->dsound->device->ds3dl.vOrientFront.y = 0.0;
-       dsl->dsound->device->ds3dl.vOrientFront.z = 1.0;
-       dsl->dsound->device->ds3dl.vOrientTop.x = 0.0;
-       dsl->dsound->device->ds3dl.vOrientTop.y = 1.0;
-       dsl->dsound->device->ds3dl.vOrientTop.z = 0.0;
-       dsl->dsound->device->ds3dl.flDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;
-       dsl->dsound->device->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;
-       dsl->dsound->device->ds3dl.flDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;
-
-       dsl->dsound->device->ds3dl_need_recalc = TRUE;
-
-       *pdsl = dsl;
+       pdsl->ref = 0;
+       pdsl->lpVtbl = &ds3dlvt;
+
+       pdsl->device = device;
+
+       pdsl->device->ds3dl.dwSize = sizeof(DS3DLISTENER);
+       pdsl->device->ds3dl.vPosition.x = 0.0;
+       pdsl->device->ds3dl.vPosition.y = 0.0;
+       pdsl->device->ds3dl.vPosition.z = 0.0;
+       pdsl->device->ds3dl.vVelocity.x = 0.0;
+       pdsl->device->ds3dl.vVelocity.y = 0.0;
+       pdsl->device->ds3dl.vVelocity.z = 0.0;
+       pdsl->device->ds3dl.vOrientFront.x = 0.0;
+       pdsl->device->ds3dl.vOrientFront.y = 0.0;
+       pdsl->device->ds3dl.vOrientFront.z = 1.0;
+       pdsl->device->ds3dl.vOrientTop.x = 0.0;
+       pdsl->device->ds3dl.vOrientTop.y = 1.0;
+       pdsl->device->ds3dl.vOrientTop.z = 0.0;
+       pdsl->device->ds3dl.flDistanceFactor = DS3D_DEFAULTDISTANCEFACTOR;
+       pdsl->device->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;
+       pdsl->device->ds3dl.flDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;
+
+       pdsl->device->ds3dl_need_recalc = TRUE;
+
+       *ppdsl = pdsl;
        return S_OK;
 }