VirtualBox

Changeset 73682 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 15, 2018 7:14:52 AM (6 years ago)
Author:
vboxsync
Message:

Audio/DrvAudio: Added support for discarding data in case a backend stream isn't ready in drvAudioStreamWrite().

File:
1 edited

Legend:

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

    r73675 r73682  
    875875#endif
    876876
     877    /* Whether to discard the incoming data or not. */
     878    bool fToBitBucket = false;
     879
    877880    do
    878881    {
     
    884887        }
    885888
    886         if (   pThis->pHostDrvAudio
    887             && pThis->pHostDrvAudio->pfnGetStatus
    888             && pThis->pHostDrvAudio->pfnGetStatus(pThis->pHostDrvAudio, PDMAUDIODIR_OUT) != PDMAUDIOBACKENDSTS_RUNNING)
    889         {
    890             rc = VERR_AUDIO_STREAM_NOT_READY;
    891             break;
     889        if (pThis->pHostDrvAudio)
     890        {
     891            /* If the backend's stream is not writable, all written data goes to /dev/null. */
     892            if (!DrvAudioHlpStreamStatusCanWrite(
     893                pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pStream->pvBackend)))
     894            {
     895                fToBitBucket = true;
     896                break;
     897            }
    892898        }
    893899
     
    978984    if (RT_SUCCESS(rc))
    979985    {
     986        if (fToBitBucket)
     987        {
     988            Log3Func(("[%s] Backend stream not ready (yet), discarding written data\n", pStream->szName));
     989            cbWrittenTotal = cbBuf; /* Report all data as being written to the caller. */
     990        }
     991
    980992        if (pcbWritten)
    981993            *pcbWritten = cbWrittenTotal;
     
    27402752        {
    27412753            /*
    2742              * If Nothing is readable, check if the stream on the backend side is ready to be read from.
     2754             * If nothing is readable, check if the stream on the backend side is ready to be read from.
    27432755             * If it isn't, return the number of bytes readable since the last read from this stream.
    27442756             *
     
    27482760             */
    27492761            if (!DrvAudioHlpStreamStatusCanRead(
    2750                     pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pStream->pvBackend)))
     2762                pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pStream->pvBackend)))
    27512763            {
    27522764                cbReadable = DrvAudioHlpNanoToBytes(RTTimeNanoTS() - pStream->tsLastReadWrittenNs,
     
    27602772    }
    27612773
    2762         Log3Func(("[%s] cbReadable=%RU32 (%RU64ms)\n",
    2763                   pStream->szName, cbReadable, DrvAudioHlpBytesToMilli(cbReadable, &pStream->Host.Cfg.Props)));
     2774    Log3Func(("[%s] cbReadable=%RU32 (%RU64ms)\n",
     2775              pStream->szName, cbReadable, DrvAudioHlpBytesToMilli(cbReadable, &pStream->Host.Cfg.Props)));
    27642776
    27652777    rc2 = RTCritSectLeave(&pThis->CritSect);
     
    27872799    uint32_t cbWritable = 0;
    27882800
     2801    /* Note: We don't propage the backend stream's status to the outside -- it's the job of this
     2802     *       audio connector to make sense of it. */
    27892803    if (DrvAudioHlpStreamStatusCanWrite(pStream->fStatus))
    27902804    {
     
    27952809    }
    27962810
    2797     Log3Func(("[%s] cbWritable=%RU32 (%RU64ms2)\n",
     2811    Log3Func(("[%s] cbWritable=%RU32 (%RU64ms)\n",
    27982812              pStream->szName, cbWritable, DrvAudioHlpBytesToMilli(cbWritable, &pStream->Host.Cfg.Props)));
    27992813
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