Index: trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
===================================================================
--- trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp	(revision 57054)
+++ trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp	(revision 57145)
@@ -68,23 +68,23 @@
 typedef struct DSOUNDSTREAMOUT
 {
-    PDMAUDIOHSTSTRMOUT  hw; /* Always must come first! */
-    LPDIRECTSOUND       pDS;
-    LPDIRECTSOUNDBUFFER pDSB;
-    DWORD               cbPlayWritePos;
-    DWORD               csPlaybackBufferSize;
-    bool                fReinitPlayPos;
-    PDMAUDIOSTREAMCFG   streamCfg;
+    PDMAUDIOHSTSTRMOUT   hw; /* Always must come first! */
+    LPDIRECTSOUND8       pDS;
+    LPDIRECTSOUNDBUFFER8 pDSB;
+    DWORD                cbPlayWritePos;
+    DWORD                csPlaybackBufferSize;
+    bool                 fReinitPlayPos;
+    PDMAUDIOSTREAMCFG    streamCfg;
 } DSOUNDSTREAMOUT, *PDSOUNDSTREAMOUT;
 
 typedef struct DSOUNDSTREAMIN
 {
-    PDMAUDIOHSTSTRMIN          hw; /* Always must come first! */
-    LPDIRECTSOUNDCAPTURE       pDSC;
-    LPDIRECTSOUNDCAPTUREBUFFER pDSCB;
-    DWORD                      csCaptureReadPos;
-    DWORD                      csCaptureBufferSize;
-    HRESULT                    hrLastCaptureIn;
-    PDMAUDIORECSOURCE          enmRecSource;
-    PDMAUDIOSTREAMCFG          streamCfg;
+    PDMAUDIOHSTSTRMIN           hw; /* Always must come first! */
+    LPDIRECTSOUNDCAPTURE8       pDSC;
+    LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB;
+    DWORD                       csCaptureReadPos;
+    DWORD                       csCaptureBufferSize;
+    HRESULT                     hrLastCaptureIn;
+    PDMAUDIORECSOURCE           enmRecSource;
+    PDMAUDIOSTREAMCFG           streamCfg;
 } DSOUNDSTREAMIN, *PDSOUNDSTREAMIN;
 
@@ -171,7 +171,7 @@
 }
 
-static int dsoundPlayRestore(LPDIRECTSOUNDBUFFER pDSB)
-{
-    HRESULT hr = IDirectSoundBuffer_Restore(pDSB);
+static int dsoundPlayRestore(LPDIRECTSOUNDBUFFER8 pDSB)
+{
+    HRESULT hr = IDirectSoundBuffer8_Restore(pDSB);
     if (SUCCEEDED(hr))
         return VINF_SUCCESS;
@@ -181,9 +181,9 @@
 }
 
-static int dsoundUnlockOutput(LPDIRECTSOUNDBUFFER pDSB,
+static int dsoundUnlockOutput(LPDIRECTSOUNDBUFFER8 pDSB,
                               LPVOID pv1, LPVOID pv2,
                               DWORD cb1, DWORD cb2)
 {
-    HRESULT hr = IDirectSoundBuffer_Unlock(pDSB, pv1, cb1, pv2, cb2);
+    HRESULT hr = IDirectSoundBuffer8_Unlock(pDSB, pv1, cb1, pv2, cb2);
     if (SUCCEEDED(hr))
         return VINF_SUCCESS;
@@ -193,9 +193,9 @@
 }
 
-static int dsoundUnlockInput(LPDIRECTSOUNDCAPTUREBUFFER pDSCB,
+static int dsoundUnlockInput(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB,
                              LPVOID pv1, LPVOID pv2,
                              DWORD cb1, DWORD cb2)
 {
-    HRESULT hr = IDirectSoundCaptureBuffer_Unlock(pDSCB, pv1, cb1, pv2, cb2);
+    HRESULT hr = IDirectSoundCaptureBuffer8_Unlock(pDSCB, pv1, cb1, pv2, cb2);
     if (SUCCEEDED(hr))
         return VINF_SUCCESS;
@@ -205,5 +205,5 @@
 }
 
-static int dsoundLockOutput(LPDIRECTSOUNDBUFFER pDSB, PDMPCMPROPS *pProps,
+static int dsoundLockOutput(LPDIRECTSOUNDBUFFER8 pDSB, PDMPCMPROPS *pProps,
                             DWORD dwOffset, DWORD dwBytes,
                             LPVOID *ppv1, LPVOID *ppv2,
@@ -218,5 +218,5 @@
     DWORD cb2 = 0;
 
-    HRESULT hr = IDirectSoundBuffer_Lock(pDSB, dwOffset, dwBytes, &pv1, &cb1, &pv2, &cb2, dwFlags);
+    HRESULT hr = IDirectSoundBuffer8_Lock(pDSB, dwOffset, dwBytes, &pv1, &cb1, &pv2, &cb2, dwFlags);
     if (hr == DSERR_BUFFERLOST)
     {
@@ -224,5 +224,5 @@
         if (RT_SUCCESS(rc))
         {
-            hr = IDirectSoundBuffer_Lock(pDSB, dwOffset, dwBytes, &pv1, &cb1, &pv2, &cb2, dwFlags);
+            hr = IDirectSoundBuffer8_Lock(pDSB, dwOffset, dwBytes, &pv1, &cb1, &pv2, &cb2, dwFlags);
         }
     }
@@ -250,5 +250,5 @@
 }
 
-static int dsoundLockInput(LPDIRECTSOUNDCAPTUREBUFFER pDSCB, PPDMPCMPROPS pProps,
+static int dsoundLockInput(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB, PPDMPCMPROPS pProps,
                            DWORD dwOffset, DWORD dwBytes,
                            LPVOID *ppv1, LPVOID *ppv2,
@@ -261,6 +261,6 @@
     DWORD cb2 = 0;
 
-    HRESULT hr = IDirectSoundCaptureBuffer_Lock(pDSCB, dwOffset, dwBytes,
-                                            &pv1, &cb1, &pv2, &cb2, dwFlags);
+    HRESULT hr = IDirectSoundCaptureBuffer8_Lock(pDSCB, dwOffset, dwBytes,
+                                                 &pv1, &cb1, &pv2, &cb2, dwFlags);
     if (FAILED(hr))
     {
@@ -294,5 +294,5 @@
     if (pDSoundStrmOut->pDS)
     {
-        IDirectSound_Release(pDSoundStrmOut->pDS);
+        IDirectSound8_Release(pDSoundStrmOut->pDS);
         pDSoundStrmOut->pDS = NULL;
     }
@@ -307,6 +307,6 @@
     }
 
-    HRESULT hr = CoCreateInstance(CLSID_DirectSound, NULL, CLSCTX_ALL,
-                                  IID_IDirectSound, (void **)&pDSoundStrmOut->pDS);
+    HRESULT hr = CoCreateInstance(CLSID_DirectSound8, NULL, CLSCTX_ALL,
+                                  IID_IDirectSound8, (void **)&pDSoundStrmOut->pDS);
     if (FAILED(hr))
     {
@@ -315,9 +315,9 @@
     else
     {
-        hr = IDirectSound_Initialize(pDSoundStrmOut->pDS, pThis->cfg.pGuidPlay);
+        hr = IDirectSound8_Initialize(pDSoundStrmOut->pDS, pThis->cfg.pGuidPlay);
         if (SUCCEEDED(hr))
         {
             HWND hwnd = GetDesktopWindow();
-            hr = IDirectSound_SetCooperativeLevel(pDSoundStrmOut->pDS, hwnd, DSSCL_PRIORITY);
+            hr = IDirectSound8_SetCooperativeLevel(pDSoundStrmOut->pDS, hwnd, DSSCL_PRIORITY);
             if (FAILED (hr))
             {
@@ -348,5 +348,5 @@
     if (pDSoundStrmOut->pDSB)
     {
-        HRESULT hr = IDirectSoundBuffer_Stop(pDSoundStrmOut->pDSB);
+        HRESULT hr = IDirectSoundBuffer8_Stop(pDSoundStrmOut->pDSB);
         if (FAILED(hr))
         {
@@ -354,5 +354,5 @@
         }
 
-        IDirectSoundBuffer_Release(pDSoundStrmOut->pDSB);
+        IDirectSoundBuffer8_Release(pDSoundStrmOut->pDSB);
         pDSoundStrmOut->pDSB = NULL;
     }
@@ -392,4 +392,5 @@
     {
         DSBUFFERDESC bd;
+        LPDIRECTSOUNDBUFFER pDSB;
         RT_ZERO(bd);
         bd.dwSize = sizeof(bd);
@@ -397,6 +398,6 @@
         bd.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2;
         bd.dwBufferBytes = pThis->cfg.cbBufferOut;
-        hr = IDirectSound_CreateSoundBuffer(pDSoundStrmOut->pDS,
-                                            &bd, &pDSoundStrmOut->pDSB, NULL);
+        hr = IDirectSound8_CreateSoundBuffer(pDSoundStrmOut->pDS,
+                                            &bd, &pDSB, NULL);
         if (FAILED(hr))
         {
@@ -405,7 +406,15 @@
         }
 
+        hr = IDirectSoundBuffer_QueryInterface(pDSB, IID_IDirectSoundBuffer8, (void **)&pDSoundStrmOut->pDSB);
+        pDSB->Release();
+        if (FAILED(hr))
+        {
+            DSLOGREL(("DSound: playback QueryInterface %Rhrc\n", hr));
+            break;
+        }
+
         /* Query the actual parameters. */
 
-        hr = IDirectSoundBuffer_GetFormat(pDSoundStrmOut->pDSB, &wfx, sizeof(wfx), NULL);
+        hr = IDirectSoundBuffer8_GetFormat(pDSoundStrmOut->pDSB, &wfx, sizeof(wfx), NULL);
         if (FAILED(hr))
         {
@@ -417,5 +426,5 @@
         RT_ZERO(bc);
         bc.dwSize = sizeof(bc);
-        hr = IDirectSoundBuffer_GetCaps(pDSoundStrmOut->pDSB, &bc);
+        hr = IDirectSoundBuffer8_GetCaps(pDSoundStrmOut->pDSB, &bc);
         if (FAILED(hr))
         {
@@ -490,10 +499,10 @@
 }
 
-static int dsoundPlayGetStatus(LPDIRECTSOUNDBUFFER pDSB, DWORD *pStatus)
+static int dsoundPlayGetStatus(LPDIRECTSOUNDBUFFER8 pDSB, DWORD *pStatus)
 {
     int rc = VINF_SUCCESS;
 
     DWORD dwStatus = 0;
-    HRESULT hr = IDirectSoundBuffer_GetStatus(pDSB, &dwStatus);
+    HRESULT hr = IDirectSoundBuffer8_GetStatus(pDSB, &dwStatus);
     if (SUCCEEDED(hr))
     {
@@ -503,5 +512,5 @@
             if (RT_SUCCESS(rc))
             {
-                hr = IDirectSoundBuffer_GetStatus(pDSB, &dwStatus);
+                hr = IDirectSoundBuffer8_GetStatus(pDSB, &dwStatus);
             }
         }
@@ -535,5 +544,5 @@
         DSLOG(("DSound: playback stop\n"));
 
-        HRESULT hr = IDirectSoundBuffer_Stop(pDSoundStrmOut->pDSB);
+        HRESULT hr = IDirectSoundBuffer8_Stop(pDSoundStrmOut->pDSB);
         if (FAILED(hr))
         {
@@ -569,5 +578,5 @@
                 DSLOG(("DSound: playback start\n"));
 
-                HRESULT hr = IDirectSoundBuffer_Play(pDSoundStrmOut->pDSB, 0, 0, DSBPLAY_LOOPING);
+                HRESULT hr = IDirectSoundBuffer8_Play(pDSoundStrmOut->pDSB, 0, 0, DSBPLAY_LOOPING);
                 if (FAILED(hr))
                 {
@@ -631,5 +640,5 @@
     if (pDSoundStrmIn->pDSC)
     {
-        IDirectSoundCapture_Release(pDSoundStrmIn->pDSC);
+        IDirectSoundCapture8_Release(pDSoundStrmIn->pDSC);
         pDSoundStrmIn->pDSC = NULL;
     }
@@ -644,6 +653,6 @@
     }
 
-    HRESULT hr = CoCreateInstance(CLSID_DirectSoundCapture, NULL, CLSCTX_ALL,
-                                  IID_IDirectSoundCapture, (void **)&pDSoundStrmIn->pDSC);
+    HRESULT hr = CoCreateInstance(CLSID_DirectSoundCapture8, NULL, CLSCTX_ALL,
+                                  IID_IDirectSoundCapture8, (void **)&pDSoundStrmIn->pDSC);
     if (FAILED(hr))
     {
@@ -653,5 +662,5 @@
     {
         LPCGUID pGUID = dsoundCaptureSelectDevice(pThis, pDSoundStrmIn);
-        hr = IDirectSoundCapture_Initialize(pDSoundStrmIn->pDSC, pGUID);
+        hr = IDirectSoundCapture8_Initialize(pDSoundStrmIn->pDSC, pGUID);
         if (FAILED(hr))
         {
@@ -677,5 +686,5 @@
     if (pDSoundStrmIn->pDSCB)
     {
-        HRESULT hr = IDirectSoundCaptureBuffer_Stop(pDSoundStrmIn->pDSCB);
+        HRESULT hr = IDirectSoundCaptureBuffer8_Stop(pDSoundStrmIn->pDSCB);
         if (FAILED (hr))
         {
@@ -683,5 +692,5 @@
         }
 
-        IDirectSoundCaptureBuffer_Release(pDSoundStrmIn->pDSCB);
+        IDirectSoundCaptureBuffer8_Release(pDSoundStrmIn->pDSCB);
         pDSoundStrmIn->pDSCB = NULL;
     }
@@ -721,10 +730,11 @@
     {
         DSCBUFFERDESC bd;
+        LPDIRECTSOUNDCAPTUREBUFFER pDSCB = NULL;
         RT_ZERO(bd);
         bd.dwSize = sizeof(bd);
         bd.lpwfxFormat = &wfx;
         bd.dwBufferBytes = pThis->cfg.cbBufferIn;
-        hr = IDirectSoundCapture_CreateCaptureBuffer(pDSoundStrmIn->pDSC,
-                                                     &bd, &pDSoundStrmIn->pDSCB, NULL);
+        hr = IDirectSoundCapture8_CreateCaptureBuffer(pDSoundStrmIn->pDSC,
+                                                      &bd, &pDSCB, NULL);
 
         if (FAILED(hr))
@@ -735,8 +745,16 @@
         }
 
+        hr = IDirectSoundCaptureBuffer_QueryInterface(pDSCB, IID_IDirectSoundCaptureBuffer8, (void **)&pDSCB);
+        IDirectSoundCaputreBuffer_Release(pDSCB);
+        if (FAILED(hr))
+        {
+            DSLOGREL(("DSound: querying capture buffer %Rhrc\n", hr));
+            break;
+        }
+
         /* Query the actual parameters. */
 
         DWORD cbReadPos = 0;
-        hr = IDirectSoundCaptureBuffer_GetCurrentPosition(pDSoundStrmIn->pDSCB, NULL, &cbReadPos);
+        hr = IDirectSoundCaptureBuffer8_GetCurrentPosition(pDSoundStrmIn->pDSCB, NULL, &cbReadPos);
         if (FAILED(hr))
         {
@@ -746,5 +764,5 @@
 
         RT_ZERO(wfx);
-        hr = IDirectSoundCaptureBuffer_GetFormat(pDSoundStrmIn->pDSCB, &wfx, sizeof(wfx), NULL);
+        hr = IDirectSoundCaptureBuffer8_GetFormat(pDSoundStrmIn->pDSCB, &wfx, sizeof(wfx), NULL);
         if (FAILED(hr))
         {
@@ -756,5 +774,5 @@
         RT_ZERO(bc);
         bc.dwSize = sizeof(bc);
-        hr = IDirectSoundCaptureBuffer_GetCaps(pDSoundStrmIn->pDSCB, &bc);
+        hr = IDirectSoundCaptureBuffer8_GetCaps(pDSoundStrmIn->pDSCB, &bc);
         if (FAILED (hr))
         {
@@ -814,5 +832,5 @@
         DSLOG(("DSound: capture stop\n"));
 
-        HRESULT hr = IDirectSoundCaptureBuffer_Stop(pDSoundStrmIn->pDSCB);
+        HRESULT hr = IDirectSoundCaptureBuffer8_Stop(pDSoundStrmIn->pDSCB);
         if (FAILED(hr))
         {
@@ -829,5 +847,5 @@
     {
         DWORD dwStatus;
-        hr = IDirectSoundCaptureBuffer_GetStatus(pDSoundStrmIn->pDSCB, &dwStatus);
+        hr = IDirectSoundCaptureBuffer8_GetStatus(pDSoundStrmIn->pDSCB, &dwStatus);
         if (FAILED(hr))
         {
@@ -844,5 +862,5 @@
                 DSLOG(("DSound: capture start\n"));
 
-                hr = IDirectSoundCaptureBuffer_Start(pDSoundStrmIn->pDSCB, DSCBSTART_LOOPING);
+                hr = IDirectSoundCaptureBuffer8_Start(pDSoundStrmIn->pDSCB, DSCBSTART_LOOPING);
                 if (FAILED (hr))
                 {
@@ -1059,5 +1077,5 @@
     PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
     PDSOUNDSTREAMOUT pDSoundStrmOut = (PDSOUNDSTREAMOUT)pHstStrmOut;
-    LPDIRECTSOUNDBUFFER pDSB = pDSoundStrmOut->pDSB;
+    LPDIRECTSOUNDBUFFER8 pDSB = pDSoundStrmOut->pDSB;
 
     int rc = VINF_SUCCESS;
@@ -1074,5 +1092,5 @@
 
     DWORD cbPlayPos, cbWritePos;
-    HRESULT hr = IDirectSoundBuffer_GetCurrentPosition(pDSB, &cbPlayPos, &cbWritePos);
+    HRESULT hr = IDirectSoundBuffer8_GetCurrentPosition(pDSB, &cbPlayPos, &cbWritePos);
     if (hr == DSERR_BUFFERLOST)
     {
@@ -1085,5 +1103,5 @@
         }
 
-        hr = IDirectSoundBuffer_GetCurrentPosition(pDSB, &cbPlayPos, &cbWritePos);
+        hr = IDirectSoundBuffer8_GetCurrentPosition(pDSB, &cbPlayPos, &cbWritePos);
         if (hr == DSERR_BUFFERLOST)
         {
