VirtualBox

Changeset 62909 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Aug 3, 2016 12:11:48 PM (8 years ago)
Author:
vboxsync
Message:

Devices: warnings, HN, ++

Location:
trunk/src/VBox/Devices/Audio
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp

    r62372 r62909  
    13621362 * @param   pcRead                  Number of audio samples read. Optional.
    13631363 */
    1364 int AudioMixBufReadCirc(PPDMAUDIOMIXBUF pMixBuf,
    1365                         void *pvBuf, uint32_t cbBuf, uint32_t *pcRead)
    1366 {
    1367     return AudioMixBufReadCircEx(pMixBuf, pMixBuf->AudioFmt,
    1368                                  pvBuf, cbBuf, pcRead);
     1364int AudioMixBufReadCirc(PPDMAUDIOMIXBUF pMixBuf, void *pvBuf, uint32_t cbBuf, uint32_t *pcRead)
     1365{
     1366    return AudioMixBufReadCircEx(pMixBuf, pMixBuf->AudioFmt, pvBuf, cbBuf, pcRead);
    13691367}
    13701368
     
    13811379 * @param   pcRead                  Number of audio samples read. Optional.
    13821380 */
    1383 int AudioMixBufReadCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt,
    1384                           void *pvBuf, uint32_t cbBuf, uint32_t *pcRead)
     1381int AudioMixBufReadCircEx(PPDMAUDIOMIXBUF pMixBuf, PDMAUDIOMIXBUFFMT enmFmt, void *pvBuf, uint32_t cbBuf, uint32_t *pcRead)
    13851382{
    13861383    AssertPtrReturn(pMixBuf, VERR_INVALID_POINTER);
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.h

    r61609 r62909  
    11/* $Id$ */
    22/** @file
    3  * VBox audio: Mixing buffer to convert audio samples to/from different
    4  *             rates / formats.
     3 * VBox audio - Mixing buffer to convert audio samples to/from different rates / formats.
    54 */
    65
     
    8281#endif
    8382
    84 #endif /* AUDIO_MIXBUF_H */
     83#endif
    8584
  • trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp

    r62463 r62909  
    1414 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
    1515 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    16  * --------------------------------------------------------------------
    1716 *
    1817 */
     18
     19
     20/*********************************************************************************************************************************
     21*   Header Files                                                                                                                 *
     22*********************************************************************************************************************************/
    1923#define LOG_GROUP LOG_GROUP_DRV_HOST_AUDIO
    2024#include <VBox/log.h>
     25#include <iprt/win/windows.h>
    2126#include <dsound.h>
    2227
     
    2833#include "VBoxDD.h"
    2934
     35
     36/*********************************************************************************************************************************
     37*   Defined Constants And Macros                                                                                                 *
     38*********************************************************************************************************************************/
    3039/*
    3140 * IDirectSound* interface uses HRESULT status codes and the driver callbacks use
     
    4554 */
    4655/* General code behavior. */
    47 #define DSLOG(a) do { LogRel2(a); } while(0)
     56#define DSLOG(a)    do { LogRel2(a); } while(0)
    4857/* Something which produce a lot of logging during playback/recording. */
    49 #define DSLOGF(a) do { LogRel3(a); } while(0)
     58#define DSLOGF(a)   do { LogRel3(a); } while(0)
    5059/* Important messages like errors. Limited in the default release log to avoid log flood. */
    51 #define DSLOGREL(a)                 \
    52     do {                            \
    53         static int8_t scLogged = 0; \
    54         if (scLogged < 8) {         \
    55             ++scLogged;             \
    56             LogRel(a);              \
    57         }                           \
    58         else {                      \
    59             DSLOG(a);               \
    60         }                           \
     60#define DSLOGREL(a) \
     61    do {  \
     62        static int8_t s_cLogged = 0; \
     63        if (s_cLogged < 8) { \
     64            ++s_cLogged; \
     65            LogRel(a); \
     66        } else DSLOG(a); \
    6167    } while (0)
    6268
     69
     70/** Maximum number of attempts to restore the sound buffer before giving up. */
     71#define DRV_DSOUND_RESTORE_ATTEMPTS_MAX         3
     72
     73/** Makes DRVHOSTDSOUND out of PDMIHOSTAUDIO. */
     74#define PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface) \
     75    ( (PDRVHOSTDSOUND)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTDSOUND, IHostAudio)) )
     76
     77
     78/*********************************************************************************************************************************
     79*   Structures and Typedefs                                                                                                      *
     80*********************************************************************************************************************************/
    6381/* Dynamically load dsound.dll. */
    64 typedef HRESULT WINAPI FNDIRECTSOUNDENUMERATEW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext);
     82typedef HRESULT WINAPI FNDIRECTSOUNDENUMERATEW(LPDSENUMCALLBACKW pDSEnumCallback, PVOID pContext);
    6583typedef FNDIRECTSOUNDENUMERATEW *PFNDIRECTSOUNDENUMERATEW;
    66 typedef HRESULT WINAPI FNDIRECTSOUNDCAPTUREENUMERATEW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext);
     84typedef HRESULT WINAPI FNDIRECTSOUNDCAPTUREENUMERATEW(LPDSENUMCALLBACKW pDSEnumCallback, PVOID pContext);
    6785typedef FNDIRECTSOUNDCAPTUREENUMERATEW *PFNDIRECTSOUNDCAPTUREENUMERATEW;
    6886
     
    95113    LPDIRECTSOUND8       pDS;     /** @todo Move this out of this structure! Not required per-stream (e.g. for multi-channel). */
    96114    LPDIRECTSOUNDBUFFER8 pDSB;
    97     DWORD                cbPlayWritePos;
    98     DWORD                csPlaybackBufferSize;
     115    DWORD                offPlayWritePos;
     116    DWORD                cMaxSamplesInBuffer;
    99117    bool                 fEnabled;
    100118    bool                 fRestartPlayback;
     
    183201
    184202/*********************************************************************************************************************************
    185 *   Defines                                                                                                                      *
     203*   Internal Functions                                                                                                           *
    186204*********************************************************************************************************************************/
    187 
    188 /** Maximum number of attempts to restore the sound buffer before giving up. */
    189 #define DRV_DSOUND_RESTORE_ATTEMPTS_MAX         3
    190 
    191 /** Makes DRVHOSTDSOUND out of PDMIHOSTAUDIO. */
    192 #define PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface) \
    193     ( (PDRVHOSTDSOUND)((uintptr_t)pInterface - RT_OFFSETOF(DRVHOSTDSOUND, IHostAudio)) )
    194 
    195 
    196 /*********************************************************************************************************************************
    197 *   Prototypes                                                                                                                   *
    198 *********************************************************************************************************************************/
    199 
    200 static HRESULT directSoundPlayRestore(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB);
    201 
    202 static void dsoundDeviceRemove(PDSOUNDDEV pDev);
    203 static int dsoundDevicesEnumerate(PDRVHOSTDSOUND pThis, PPDMAUDIOBACKENDCFG pCfg);
     205static HRESULT  directSoundPlayRestore(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB);
     206static void     dsoundDeviceRemove(PDSOUNDDEV pDev);
     207static int      dsoundDevicesEnumerate(PDRVHOSTDSOUND pThis, PPDMAUDIOBACKENDCFG pCfg);
    204208#ifdef VBOX_WITH_AUDIO_CALLBACKS
    205 static int dsoundNotifyThread(PDRVHOSTDSOUND pThis, bool fShutdown);
     209static int      dsoundNotifyThread(PDRVHOSTDSOUND pThis, bool fShutdown);
    206210#endif
     211
     212
    207213
    208214static DWORD dsoundRingDistance(DWORD offEnd, DWORD offBegin, DWORD cSize)
     
    259265    AssertPtrReturn(pThis,         VERR_INVALID_POINTER);
    260266    AssertPtrReturn(pDSoundStream, VERR_INVALID_POINTER);
    261     /* pdwBuffer is optional. */
    262     /* pdwFree is optional. */
    263     /* pdwPlayPos is optional. */
     267    AssertPtrNull(pdwBuffer);
     268    AssertPtrNull(pdwFree);
     269    AssertPtrNull(pdwPlayPos);
    264270
    265271    LPDIRECTSOUNDBUFFER8 pDSB = pDSoundStream->pDSB;
     
    267273        return VERR_INVALID_POINTER;
    268274
    269     DWORD cbBuffer = AUDIOMIXBUF_S2B(&pDSoundStream->Stream.MixBuf, pDSoundStream->csPlaybackBufferSize);
    270 
    271275    /* Get the current play position which is used for calculating the free space in the buffer. */
    272276    DWORD cbPlayPos;
    273 
    274     HRESULT hr;
     277    HRESULT hr = E_FAIL;
    275278    for (unsigned i = 0; i < DRV_DSOUND_RESTORE_ATTEMPTS_MAX; i++)
    276279    {
    277280        hr = IDirectSoundBuffer8_GetCurrentPosition(pDSB, &cbPlayPos, NULL);
    278         if (   SUCCEEDED(hr)
    279             || hr != DSERR_BUFFERLOST) /** @todo: MSDN doesn't state this error for GetCurrentPosition(). */
    280         {
    281             break;
    282         }
    283         else
    284         {
    285             LogFlowFunc(("Getting playing position failed due to lost buffer, restoring ...\n"));
    286             directSoundPlayRestore(pThis, pDSB);
    287         }
    288     }
    289 
    290     int rc = VINF_SUCCESS;
    291 
    292     if (FAILED(hr))
    293     {
    294         if (hr != DSERR_BUFFERLOST) /* Avoid log flooding if the error is still there. */
    295             DSLOGREL(("DSound: Getting current playback position failed with %Rhrc\n", hr));
    296         LogFlowFunc(("Failed with %Rhrc\n", hr));
    297 
    298         rc = VERR_NOT_AVAILABLE;
    299     }
    300     else
    301     {
    302         if (pdwBuffer)
    303             *pdwBuffer = cbBuffer;
    304 
    305         if (pdwFree)
    306             *pdwFree = cbBuffer - dsoundRingDistance(pDSoundStream->cbPlayWritePos, cbPlayPos, cbBuffer);
    307 
    308         if (pdwPlayPos)
    309             *pdwPlayPos = cbPlayPos;
    310     }
    311 
    312     if (RT_FAILURE(rc))
    313         LogFlowFuncLeaveRC(rc);
     281        if (SUCCEEDED(hr))
     282        {
     283            DWORD const cbBuffer = AUDIOMIXBUF_S2B(&pDSoundStream->Stream.MixBuf, pDSoundStream->cMaxSamplesInBuffer);
     284            if (pdwBuffer)
     285                *pdwBuffer  = cbBuffer;
     286            if (pdwFree)
     287                *pdwFree    = cbBuffer - dsoundRingDistance(pDSoundStream->offPlayWritePos, cbPlayPos, cbBuffer);
     288            if (pdwPlayPos)
     289                *pdwPlayPos = cbPlayPos;
     290            return VINF_SUCCESS;
     291        }
     292        if (hr != DSERR_BUFFERLOST) /** @todo MSDN doesn't state this error for GetCurrentPosition(). */
     293            break;
     294        LogFlowFunc(("Getting playing position failed due to lost buffer, restoring ...\n"));
     295        directSoundPlayRestore(pThis, pDSB);
     296    }
     297
     298    if (hr != DSERR_BUFFERLOST) /* Avoid log flooding if the error is still there. */
     299        DSLOGREL(("DSound: Getting current playback position failed with %Rhrc\n", hr));
     300    LogFlowFunc(("Failed with %Rhrc\n", hr));
     301
     302    int rc = VERR_NOT_AVAILABLE;
     303    LogFlowFuncLeaveRC(rc);
    314304    return rc;
    315305}
     
    359349static HRESULT directSoundPlayRestore(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB)
    360350{
     351    RT_NOREF(pThis);
    361352    HRESULT hr = IDirectSoundBuffer8_Restore(pDSB);
    362353    if (FAILED(hr))
     
    366357
    367358static HRESULT directSoundPlayUnlock(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB,
    368                                      LPVOID pv1, LPVOID pv2,
     359                                     PVOID pv1, PVOID pv2,
    369360                                     DWORD cb1, DWORD cb2)
    370361{
     362    RT_NOREF(pThis);
    371363    HRESULT hr = IDirectSoundBuffer8_Unlock(pDSB, pv1, cb1, pv2, cb2);
    372364    if (FAILED(hr))
     
    376368
    377369static HRESULT directSoundCaptureUnlock(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB,
    378                                         LPVOID pv1, LPVOID pv2,
     370                                        PVOID pv1, PVOID pv2,
    379371                                        DWORD cb1, DWORD cb2)
    380372{
     
    388380                                   LPDIRECTSOUNDBUFFER8 pDSB, PDMPCMPROPS *pProps,
    389381                                   DWORD dwOffset, DWORD dwBytes,
    390                                    LPVOID *ppv1, LPVOID *ppv2,
     382                                   PVOID *ppv1, PVOID *ppv2,
    391383                                   DWORD *pcb1, DWORD *pcb2,
    392384                                   DWORD dwFlags)
    393385{
    394     LPVOID pv1 = NULL;
    395     LPVOID pv2 = NULL;
    396     DWORD cb1 = 0;
    397     DWORD cb2 = 0;
    398 
    399     HRESULT hr;
     386    HRESULT hr = E_FAIL;
     387    AssertCompile(DRV_DSOUND_RESTORE_ATTEMPTS_MAX > 0);
    400388    for (unsigned i = 0; i < DRV_DSOUND_RESTORE_ATTEMPTS_MAX; i++)
    401389    {
    402         hr = IDirectSoundBuffer8_Lock(pDSB, dwOffset, dwBytes, &pv1, &cb1, &pv2, &cb2, dwFlags);
    403         if (   SUCCEEDED(hr)
    404             || hr != DSERR_BUFFERLOST)
    405             break;
    406         else
    407         {
    408             LogFlowFunc(("Locking failed due to lost buffer, restoring ...\n"));
    409             directSoundPlayRestore(pThis, pDSB);
    410         }
    411     }
    412 
    413     if (FAILED(hr))
    414     {
    415         DSLOGREL(("DSound: Locking playback buffer failed with %Rhrc\n", hr));
    416         return hr;
    417     }
    418 
    419     if (   (pv1 && (cb1 & pProps->uAlign))
    420         || (pv2 && (cb2 & pProps->uAlign)))
    421     {
    422         DSLOGREL(("DSound: Locking playback buffer returned misaligned buffer: cb1=%RI32, cb2=%RI32 (alignment: %RU32)\n",
    423                   cb1, cb2, pProps->uAlign));
    424         directSoundPlayUnlock(pThis, pDSB, pv1, pv2, cb1, cb2);
    425         return E_FAIL;
    426     }
    427 
    428     *ppv1 = pv1;
    429     *ppv2 = pv2;
    430     *pcb1 = cb1;
    431     *pcb2 = cb2;
    432 
    433     return S_OK;
     390        *ppv1 = *ppv2 = NULL;
     391        *pcb1 = *pcb2 = 0;
     392        hr = IDirectSoundBuffer8_Lock(pDSB, dwOffset, dwBytes, ppv1, pcb1, ppv2, pcb2, dwFlags);
     393        if (SUCCEEDED(hr))
     394        {
     395            if (   (!*ppv1 || !(*pcb1 & pProps->uAlign))
     396                && (!*ppv2 || !(*pcb2 & pProps->uAlign)) )
     397                return S_OK;
     398            DSLOGREL(("DSound: Locking playback buffer returned misaligned buffer: cb1=%#RX32, cb2=%#RX32 (alignment: %#RX32)\n",
     399                      *pcb1, *pcb2, pProps->uAlign));
     400            directSoundPlayUnlock(pThis, pDSB, *ppv1, *ppv2, *pcb1, *pcb2);
     401            return E_FAIL;
     402        }
     403
     404        if (hr != DSERR_BUFFERLOST)
     405            break;
     406
     407        LogFlowFunc(("Locking failed due to lost buffer, restoring ...\n"));
     408        directSoundPlayRestore(pThis, pDSB);
     409    }
     410
     411    DSLOGREL(("DSound: Locking playback buffer failed with %Rhrc\n", hr));
     412    return hr;
    434413}
    435414
    436415static HRESULT directSoundCaptureLock(LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB, PPDMPCMPROPS pProps,
    437416                                      DWORD dwOffset, DWORD dwBytes,
    438                                       LPVOID *ppv1, LPVOID *ppv2,
     417                                      PVOID *ppv1, PVOID *ppv2,
    439418                                      DWORD *pcb1, DWORD *pcb2,
    440419                                      DWORD dwFlags)
    441420{
    442     LPVOID pv1 = NULL;
    443     LPVOID pv2 = NULL;
     421    PVOID pv1 = NULL;
     422    PVOID pv2 = NULL;
    444423    DWORD cb1 = 0;
    445424    DWORD cb2 = 0;
     
    628607
    629608        /* "Upgrade" to IDirectSoundBuffer8 interface. */
    630         hr = IDirectSoundBuffer_QueryInterface(pDSB, IID_IDirectSoundBuffer8, (LPVOID *)&pDSoundStream->pDSB);
     609        hr = IDirectSoundBuffer_QueryInterface(pDSB, IID_IDirectSoundBuffer8, (PVOID *)&pDSoundStream->pDSB);
    631610        IDirectSoundBuffer_Release(pDSB);
    632611        if (FAILED(hr))
     
    689668         * playback buffer position.
    690669         */
    691         pDSoundStream->csPlaybackBufferSize = bc.dwBufferBytes >> pDSoundStream->Stream.Props.cShift;
    692         DSLOG(("DSound: csPlaybackBufferSize=%RU32\n", pDSoundStream->csPlaybackBufferSize));
     670        pDSoundStream->cMaxSamplesInBuffer = bc.dwBufferBytes >> pDSoundStream->Stream.Props.cShift;
     671        DSLOG(("DSound: cMaxSamplesInBuffer=%RU32\n", pDSoundStream->cMaxSamplesInBuffer));
    693672
    694673#ifdef VBOX_WITH_AUDIO_CALLBACKS
     
    707686
    708687        LPDIRECTSOUNDNOTIFY8 pNotify;
    709         hr = IDirectSoundNotify_QueryInterface(pDSoundStream->pDSB, IID_IDirectSoundNotify8, (LPVOID *)&pNotify);
     688        hr = IDirectSoundNotify_QueryInterface(pDSoundStream->pDSB, IID_IDirectSoundNotify8, (PVOID *)&pNotify);
    710689        if (SUCCEEDED(hr))
    711690        {
     
    754733    PPDMAUDIOSTREAM pStream = &pDSoundStream->Stream;
    755734
    756     LPVOID pv1, pv2;
     735    PVOID pv1, pv2;
    757736    DWORD cb1, cb2;
    758737    HRESULT hr = directSoundPlayLock(pThis, pDSoundStream->pDSB, &pDSoundStream->Stream.Props,
    759                                      0 /* dwOffset */, AUDIOMIXBUF_S2B(&pStream->MixBuf, pDSoundStream->csPlaybackBufferSize),
     738                                     0 /* dwOffset */, AUDIOMIXBUF_S2B(&pStream->MixBuf, pDSoundStream->cMaxSamplesInBuffer),
    760739                                     &pv1, &pv2, &cb1, &cb2, DSBLOCK_ENTIREBUFFER);
    761740    if (SUCCEEDED(hr))
     
    778757    AssertPtrReturn(pThis, E_POINTER);
    779758    AssertPtrReturn(pDSB,  E_POINTER);
    780     /* pdwStatus is optional. */
     759    AssertPtrNull(pdwStatus);
    781760
    782761    DWORD dwStatus = 0;
    783 
    784     HRESULT hr;
     762    HRESULT hr = E_FAIL;
    785763    for (unsigned i = 0; i < DRV_DSOUND_RESTORE_ATTEMPTS_MAX; i++)
    786764    {
     
    12821260
    12831261static BOOL CALLBACK dsoundDevicesEnumCbPlayback(LPGUID lpGUID, LPCWSTR lpwstrDescription,
    1284                                                  LPCWSTR lpwstrModule, LPVOID lpContext)
     1262                                                 LPCWSTR lpwstrModule, PVOID lpContext)
    12851263{
    12861264    PDSOUNDENUMCBCTX pCtx = (PDSOUNDENUMCBCTX)lpContext;
     
    13081286
    13091287static BOOL CALLBACK dsoundDevicesEnumCbCapture(LPGUID lpGUID, LPCWSTR lpwstrDescription,
    1310                                                 LPCWSTR lpwstrModule, LPVOID lpContext)
     1288                                                LPCWSTR lpwstrModule, PVOID lpContext)
    13111289{
    13121290    PDSOUNDENUMCBCTX pCtx = (PDSOUNDENUMCBCTX)lpContext;
     
    14581436        pDSoundStream->pDS = NULL;
    14591437        pDSoundStream->pDSB = NULL;
    1460         pDSoundStream->cbPlayWritePos = 0;
     1438        pDSoundStream->offPlayWritePos = 0;
    14611439        pDSoundStream->fRestartPlayback = true;
    1462         pDSoundStream->csPlaybackBufferSize = 0;
     1440        pDSoundStream->cMaxSamplesInBuffer = 0;
    14631441
    14641442        if (pcSamples)
     
    15601538
    15611539        /*
    1562          * Check for full buffer, do not allow the cbPlayWritePos to catch cbPlayPos during playback,
     1540         * Check for full buffer, do not allow the offPlayWritePos to catch cbPlayPos during playback,
    15631541         * i.e. always leave a free space for 1 audio sample.
    15641542         */
     
    15731551        /* Do not write more than available space in the DirectSound playback buffer. */
    15741552        cbLive = RT_MIN(cbFree, cbLive);
    1575 
    15761553        cbLive &= ~pStream->Props.uAlign;
    15771554        if (cbLive == 0 || cbLive > cbBuffer)
    15781555        {
    1579             DSLOG(("DSound: cbLive=%RU32, cbBuffer=%ld, cbPlayWritePos=%ld, cbPlayPos=%ld\n",
    1580                    cbLive, cbBuffer, pDSoundStream->cbPlayWritePos, cbPlayPos));
     1556            DSLOG(("DSound: cbLive=%RU32, cbBuffer=%ld, offPlayWritePos=%ld, cbPlayPos=%ld\n",
     1557                   cbLive, cbBuffer, pDSoundStream->offPlayWritePos, cbPlayPos));
    15811558            break;
    15821559        }
     
    15851562        AssertPtr(pDSB);
    15861563
    1587         LPVOID pv1, pv2;
     1564        PVOID pv1, pv2;
    15881565        DWORD cb1, cb2;
    1589         HRESULT hr = directSoundPlayLock(pThis, pDSB, &pStream->Props, pDSoundStream->cbPlayWritePos, cbLive,
     1566        HRESULT hr = directSoundPlayLock(pThis, pDSB, &pStream->Props, pDSoundStream->offPlayWritePos, cbLive,
    15901567                                         &pv1, &pv2, &cb1, &cb2, 0 /* dwFlags */);
    15911568        if (FAILED(hr))
     
    15951572        }
    15961573
    1597         DWORD len1 = AUDIOMIXBUF_B2S(&pStream->MixBuf, cb1);
    1598         DWORD len2 = AUDIOMIXBUF_B2S(&pStream->MixBuf, cb2);
    1599 
     1574        /** @todo r=bird: Can pv1/cb1 really be NULL? Docs says they're always set
     1575         *        and pv2/cb2 only used when there is a buffer wrap araound. */
     1576
     1577        DWORD cSamplesIn1 = AUDIOMIXBUF_B2S(&pStream->MixBuf, cb1);
    16001578        uint32_t cRead = 0;
    16011579
     
    16081586
    16091587        if (   RT_SUCCESS(rc)
    1610             && cReadTotal == len1
     1588            && cReadTotal == cSamplesIn1
    16111589            && pv2 && cb2)
    16121590        {
     
    16181596        directSoundPlayUnlock(pThis, pDSB, pv1, pv2, cb1, cb2);
    16191597
    1620         pDSoundStream->cbPlayWritePos =
    1621             (pDSoundStream->cbPlayWritePos + AUDIOMIXBUF_S2B(&pStream->MixBuf, cReadTotal)) % cbBuffer;
     1598        pDSoundStream->offPlayWritePos = (pDSoundStream->offPlayWritePos + AUDIOMIXBUF_S2B(&pStream->MixBuf, cReadTotal))
     1599                                      % cbBuffer;
    16221600
    16231601        DSLOGF(("DSound: %RU32 (%RU32 samples) out of %RU32%s, buffer write pos %ld, rc=%Rrc\n",
    16241602                AUDIOMIXBUF_S2B(&pStream->MixBuf, cReadTotal), cReadTotal, cbLive,
    16251603                cbLive != AUDIOMIXBUF_S2B(&pStream->MixBuf, cReadTotal) ? " !!!": "",
    1626                 pDSoundStream->cbPlayWritePos, rc));
     1604                pDSoundStream->offPlayWritePos, rc));
    16271605
    16281606        if (cReadTotal)
     
    16721650
    16731651    if (RT_FAILURE(rc))
    1674     {
    16751652        dsoundUpdateStatusInternal(pThis);
    1676     }
    1677     else
    1678     {
    1679         if (pcSamplesPlayed)
    1680             *pcSamplesPlayed = cReadTotal;
    1681     }
     1653    else if (pcSamplesPlayed)
     1654        *pcSamplesPlayed = cReadTotal;
    16821655
    16831656    LogFlowFuncLeaveRC(rc);
     
    16921665    directSoundPlayClose(pThis, pDSoundStream);
    16931666
    1694     pDSoundStream->cbPlayWritePos       = 0;
     1667    pDSoundStream->offPlayWritePos      = 0;
    16951668    pDSoundStream->fRestartPlayback     = true;
    1696     pDSoundStream->csPlaybackBufferSize = 0;
     1669    pDSoundStream->cMaxSamplesInBuffer = 0;
    16971670
    16981671    RT_ZERO(pDSoundStream->streamCfg);
     
    18621835
    18631836        /* Lock relevant range in the DirectSound capture buffer. */
    1864         LPVOID pv1, pv2;
     1837        PVOID pv1, pv2;
    18651838        DWORD cb1, cb2;
    18661839        hr = directSoundCaptureLock(pDSCB, &pStream->Props,
     
    19261899static int dsoundDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    19271900{
    1928     PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
     1901    RT_NOREF(pInterface);
    19291902    PDSOUNDSTREAMIN pDSoundStream = (PDSOUNDSTREAMIN)pStream;
    19301903
     
    20782051        CloseHandle(pThis->aEvents[DSOUNDEVENT_NOTIFY]);
    20792052        pThis->aEvents[DSOUNDEVENT_NOTIFY] = NULL;
    2080 }
     2053    }
     2054#else
     2055    RT_NOREF_PV(pThis);
    20812056#endif
    20822057
     
    21912166static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostDSoundGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
    21922167{
     2168    RT_NOREF(enmDir);
    21932169    AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN);
    21942170
     
    22792255}
    22802256
     2257
    22812258static DECLCALLBACK(int) drvHostDSoundStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    22822259{
     
    22902267}
    22912268
     2269
     2270/**
     2271 * @callback_method_impl{FNPDMDRVDESTRUCT, pfnDestruct}
     2272 */
    22922273static DECLCALLBACK(void) drvHostDSoundDestruct(PPDMDRVINS pDrvIns)
    22932274{
     
    23022283}
    23032284
     2285
    23042286/**
    2305  * Construct a DirectSound Audio driver instance.
    2306  *
    2307  * @copydoc FNPDMDRVCONSTRUCT
     2287 * @callback_method_impl{FNPDMDRVCONSTRUCT,
     2288 *      Construct a DirectSound Audio driver instance.}
    23082289 */
    23092290static DECLCALLBACK(int) drvHostDSoundConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
    23102291{
     2292    RT_NOREF(fFlags);
    23112293    PDRVHOSTDSOUND pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTDSOUND);
    23122294
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette