VirtualBox

Changeset 73432 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 1, 2018 3:03:03 PM (6 years ago)
Author:
vboxsync
Message:

Audio: Use the DrvAudioHlpStreamStatusXXX() helpers where applicable.

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

Legend:

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

    r73421 r73432  
    934934        /* Return how much data we expect since the last write. */
    935935        cbWritable = DrvAudioHlpNanoToBytes(deltaLastReadWriteNs, &pSink->PCMProps);
     936
     937        /* Make sure to align the writable size to the stream's frame size. */
    936938        cbWritable = DrvAudioHlpBytesAlign(cbWritable, &pSink->PCMProps);
    937939#endif
     
    11151117        Log3Func(("[%s] No recording source specified, skipping ...\n", pSink->pszName));
    11161118    }
    1117     else if (!(pStreamRecSource->pConn->pfnStreamGetStatus(pStreamRecSource->pConn, pStreamRecSource->pStream) & PDMAUDIOSTREAMSTS_FLAG_ENABLED))
     1119    else if (!DrvAudioHlpStreamStatusCanRead(
     1120       pStreamRecSource->pConn->pfnStreamGetStatus(pStreamRecSource->pConn, pStreamRecSource->pStream)))
    11181121    {
    11191122        Log3Func(("[%s] Stream '%s' disabled, skipping ...\n", pSink->pszName, pStreamRecSource->pszName));
     
    15641567
    15651568        uint32_t cfProc = 0;
     1569
     1570        if (!DrvAudioHlpStreamStatusIsReady(pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream)))
     1571            continue;
    15661572
    15671573        int rc2 = pConn->pfnStreamIterate(pConn, pStream);
     
    17211727              ("%s: Can't write to a sink which is not an output sink\n", pSink->pszName));
    17221728
    1723     Log3Func(("[%s] enmOp=%d, cbBuf=%RU32\n", pSink->pszName, enmOp, cbBuf));
    1724 
    17251729    PAUDMIXSTREAM pMixStream;
    17261730    RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node)
    17271731    {
     1732        if (!DrvAudioHlpStreamStatusCanWrite(pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream)))
     1733            continue;
     1734
    17281735        PRTCIRCBUF pCircBuf = pMixStream->pCircBuf;
    17291736        void *pvChunk;
  • trunk/src/VBox/Devices/Audio/DevSB16.cpp

    r73370 r73432  
    15551555                continue;
    15561556
     1557            if (!DrvAudioHlpStreamStatusCanWrite(pDrv->pConnector->pfnStreamGetStatus(pDrv->pConnector,  pDrv->Out.pStream)))
     1558                continue;
     1559
    15571560            uint32_t cbWrittenToStream = 0;
    15581561            rc2 = pDrv->pConnector->pfnStreamWrite(pDrv->pConnector, pDrv->Out.pStream, tmpbuf, cbRead, &cbWrittenToStream);
    15591562
    15601563            LogFlowFunc(("\tLUN#%RU8: rc=%Rrc, cbWrittenToStream=%RU32\n", pDrv->uLUN, rc2, cbWrittenToStream));
    1561 
    1562             /* The primary driver sets the overall pace. */
    1563             if (pDrv->fFlags & PDMAUDIODRVFLAGS_PRIMARY)
    1564             {
    1565                 cbWritten = cbWrittenToStream;
    1566 
    1567                 if (RT_FAILURE(rc2))
    1568                     break;
    1569             }
    15701564        }
     1565
     1566        cbWritten = cbRead; /* Always report everything written, as the backends need to keep up themselves. */
    15711567
    15721568        LogFlowFunc(("\tcbToRead=%RU32, cbToWrite=%RU32, cbWritten=%RU32, cbLeft=%RU32\n",
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r73428 r73432  
    30143014    }
    30153015
    3016     uint32_t cfReadable = 0;
     3016    uint32_t cbReadable = 0;
    30173017
    30183018    PPDMAUDIOSTREAM pGstStream = pHstStream->pPair;
    30193019    if (pGstStream)
    3020         cfReadable = AudioMixBufLive(&pGstStream->MixBuf);
    3021 
    3022     Log3Func(("[%s] cfReadable=%RU32 (%zu bytes)\n", pHstStream->szName, cfReadable,
    3023               AUDIOMIXBUF_F2B(&pGstStream->MixBuf, cfReadable)));
    3024 
    3025     uint32_t cbReadable = AUDIOMIXBUF_F2B(&pGstStream->MixBuf, cfReadable);
     3020    {
     3021        uint32_t cfReadable = AudioMixBufLive(&pGstStream->MixBuf);
     3022
     3023        Log3Func(("[%s] cfReadable=%RU32 (%zu bytes)\n", pHstStream->szName, cfReadable,
     3024                  AUDIOMIXBUF_F2B(&pGstStream->MixBuf, cfReadable)));
     3025
     3026        cbReadable = AUDIOMIXBUF_F2B(&pGstStream->MixBuf, cfReadable);
     3027    }
    30263028
    30273029    rc2 = RTCritSectLeave(&pThis->CritSect);
     
    30603062    const uint64_t deltaLastReadWriteNs = RTTimeNanoTS() - pHstStream->tsLastReadWrittenNs;
    30613063
    3062     uint32_t cbWritable = DrvAudioHlpNanoToBytes(deltaLastReadWriteNs, &pHstStream->Cfg.Props);
    3063     cbWritable = DrvAudioHlpBytesAlign(cbWritable, &pHstStream->Cfg.Props);
    3064 
    3065     Log3Func(("Audio: [%s] cbWritable=%RU32 (%RU64ms)\n", pHstStream->szName, cbWritable, deltaLastReadWriteNs / RT_NS_1MS_64));
     3064    uint32_t cbWritable = 0;
     3065
     3066    if (DrvAudioHlpStreamStatusCanWrite(pHstStream->fStatus))
     3067    {
     3068        cbWritable = DrvAudioHlpNanoToBytes(deltaLastReadWriteNs, &pHstStream->Cfg.Props);
     3069
     3070        /* Make sure to align the writable size to the stream's frame size. */
     3071        cbWritable = DrvAudioHlpBytesAlign(cbWritable, &pHstStream->Cfg.Props);
     3072    }
     3073
     3074    Log3Func(("[%s] cbWritable=%RU32 (%RU64ms)\n", pHstStream->szName, cbWritable, deltaLastReadWriteNs / RT_NS_1MS_64));
    30663075
    30673076    rc2 = RTCritSectLeave(&pThis->CritSect);
     
    30863095    AssertRC(rc2);
    30873096
    3088     PDMAUDIOSTREAMSTS strmSts = PDMAUDIOSTREAMSTS_FLAG_NONE;
     3097    PDMAUDIOSTREAMSTS stsStream = PDMAUDIOSTREAMSTS_FLAG_NONE;
    30893098
    30903099    PPDMAUDIOSTREAM pHstStream = drvAudioGetHostStream(pStream);
    30913100    if (pHstStream)
    30923101    {
    3093         strmSts = pHstStream->fStatus;
     3102        /* If the connector is ready to operate, also make sure to ask the backend. */
     3103        stsStream = pHstStream->fStatus;
     3104        if (DrvAudioHlpStreamStatusIsReady(stsStream))
     3105            stsStream = pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pHstStream->pvBackend);
     3106
    30943107#ifdef LOG_ENABLED
    3095         char *pszHstSts = dbgAudioStreamStatusToStr(pHstStream->fStatus);
    3096         Log3Func(("[%s] %s\n", pHstStream->szName, pszHstSts));
    3097         RTStrFree(pszHstSts);
     3108        char *pszStreamSts = dbgAudioStreamStatusToStr(stsStream);
     3109        Log3Func(("[%s] %s\n", pHstStream->szName, pszStreamSts));
     3110        RTStrFree(pszStreamSts);
    30983111#endif
    30993112    }
     
    31023115    AssertRC(rc2);
    31033116
    3104     return strmSts;
     3117    return stsStream;
    31053118}
    31063119
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