VirtualBox

Changeset 88025 in vbox


Ignore:
Timestamp:
Mar 8, 2021 6:31:56 PM (4 years ago)
Author:
vboxsync
Message:

Audio: Preparing to move some of the DrvAudio.h stuff into PDM. bugref:9890

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

Legend:

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

    r88023 r88025  
    21802180        const uint32_t fStreamStatus = pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream);
    21812181
    2182         if (DrvAudioHlpStreamStatusIsReady(fStreamStatus))
     2182        if (PDMAudioStrmStatusIsReady(fStreamStatus))
    21832183            pMixStream->fStatus |= AUDMIXSTREAM_STATUS_ENABLED;
    21842184
     
    21872187        {
    21882188            case AUDMIXSINKDIR_INPUT:
    2189                 if (DrvAudioHlpStreamStatusCanRead(fStreamStatus))
     2189                if (PDMAudioStrmStatusCanRead(fStreamStatus))
    21902190                   pMixStream->fStatus |= AUDMIXSTREAM_STATUS_CAN_READ;
    21912191                break;
    21922192
    21932193            case AUDMIXSINKDIR_OUTPUT:
    2194                 if (DrvAudioHlpStreamStatusCanWrite(fStreamStatus))
     2194                if (PDMAudioStrmStatusCanWrite(fStreamStatus))
    21952195                   pMixStream->fStatus |= AUDMIXSTREAM_STATUS_CAN_WRITE;
    21962196                break;
  • trunk/src/VBox/Devices/Audio/DevSB16.cpp

    r88023 r88025  
    15581558        {
    15591559            if (   pDrv->Out.pStream
    1560                 && DrvAudioHlpStreamStatusCanWrite(pDrv->pConnector->pfnStreamGetStatus(pDrv->pConnector, pDrv->Out.pStream)))
     1560                && PDMAudioStrmStatusCanWrite(pDrv->pConnector->pfnStreamGetStatus(pDrv->pConnector, pDrv->Out.pStream)))
    15611561            {
    15621562                uint32_t cbWrittenToStream = 0;
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r88023 r88025  
    303303        return rc;
    304304
    305     LogFlowFunc(("[%s] enmStreamCmd=%s\n", pStream->szName, DrvAudioHlpStreamCmdToStr(enmStreamCmd)));
     305    LogFlowFunc(("[%s] enmStreamCmd=%s\n", pStream->szName, PDMAudioStrmCmdGetName(enmStreamCmd)));
    306306
    307307    rc = drvAudioStreamControlInternal(pThis, pStream, enmStreamCmd);
     
    327327    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    328328
    329     LogFunc(("[%s] enmStreamCmd=%s\n", pStream->szName, DrvAudioHlpStreamCmdToStr(enmStreamCmd)));
     329    LogFunc(("[%s] enmStreamCmd=%s\n", pStream->szName, PDMAudioStrmCmdGetName(enmStreamCmd)));
    330330
    331331#ifdef LOG_ENABLED
     
    441441#ifdef LOG_ENABLED
    442442    char *pszStreamSts = dbgAudioStreamStatusToStr(pStream->fStatus);
    443     LogFlowFunc(("[%s] enmStreamCmd=%s, fStatus=%s\n", pStream->szName, DrvAudioHlpStreamCmdToStr(enmStreamCmd), pszStreamSts));
     443    LogFlowFunc(("[%s] enmStreamCmd=%s, fStatus=%s\n", pStream->szName, PDMAudioStrmCmdGetName(enmStreamCmd), pszStreamSts));
    444444    RTStrFree(pszStreamSts);
    445445#endif /* LOG_ENABLED */
     
    468468                              && pThis->Out.fEnabled);
    469469
    470     LogRel2(("Audio: %s stream '%s' in backend (%s is %s)\n", DrvAudioHlpStreamCmdToStr(enmStreamCmd), pStream->szName,
     470    LogRel2(("Audio: %s stream '%s' in backend (%s is %s)\n", PDMAudioStrmCmdGetName(enmStreamCmd), pStream->szName,
    471471                                                              DrvAudioHlpAudDirToStr(pStream->enmDir),
    472472                                                              fEnabled ? "enabled" : "disabled"));
     
    526526            && rc != VERR_AUDIO_STREAM_NOT_READY)
    527527        {
    528             LogRel(("Audio: %s stream '%s' failed with %Rrc\n", DrvAudioHlpStreamCmdToStr(enmStreamCmd), pStream->szName, rc));
    529         }
    530 
    531         LogFunc(("[%s] %s failed with %Rrc\n", pStream->szName, DrvAudioHlpStreamCmdToStr(enmStreamCmd), rc));
     528            LogRel(("Audio: %s stream '%s' failed with %Rrc\n", PDMAudioStrmCmdGetName(enmStreamCmd), pStream->szName, rc));
     529        }
     530
     531        LogFunc(("[%s] %s failed with %Rrc\n", pStream->szName, PDMAudioStrmCmdGetName(enmStreamCmd), rc));
    532532    }
    533533
     
    963963    do
    964964    {
    965         if (!DrvAudioHlpStreamStatusIsReady(pStream->fStatus))
     965        if (!PDMAudioStrmStatusIsReady(pStream->fStatus))
    966966        {
    967967            rc = VERR_AUDIO_STREAM_NOT_READY;
     
    979979        {
    980980            /* If the backend's stream is not writable, all written data goes to /dev/null. */
    981             if (!DrvAudioHlpStreamStatusCanWrite(
     981            if (!PDMAudioStrmStatusCanWrite(
    982982                pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pStream->pvBackend)))
    983983            {
     
    15331533
    15341534        if (   !pThis->Out.fEnabled
    1535             || !DrvAudioHlpStreamStatusIsReady(fStrmStatus))
     1535            || !PDMAudioStrmStatusIsReady(fStrmStatus))
    15361536        {
    15371537            rc = VERR_AUDIO_STREAM_NOT_READY;
     
    19121912
    19131913        if (   !pThis->In.fEnabled
    1914             || !DrvAudioHlpStreamStatusCanRead(pStream->fStatus))
     1914            || !PDMAudioStrmStatusCanRead(pStream->fStatus))
    19151915        {
    19161916            rc = VERR_AUDIO_STREAM_NOT_READY;
     
    22902290    PDRVAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIO);
    22912291
    2292     LogFlowFunc(("enmCmd=%s\n", DrvAudioHlpStreamCmdToStr(enmCmd)));
     2292    LogFlowFunc(("enmCmd=%s\n", PDMAudioStrmCmdGetName(enmCmd)));
    22932293
    22942294    int rc2 = RTCritSectEnter(&pThis->CritSect);
     
    24512451        if (pThis->In.fEnabled) /* Input for this audio driver enabled? See #9822. */
    24522452        {
    2453             if (!DrvAudioHlpStreamStatusCanRead(pStream->fStatus))
     2453            if (!PDMAudioStrmStatusCanRead(pStream->fStatus))
    24542454            {
    24552455                rc = VERR_AUDIO_STREAM_NOT_READY;
     
    29422942
    29432943    if (   pThis->pHostDrvAudio
    2944         && (   DrvAudioHlpStreamStatusCanRead(pStream->fStatus)
     2944        && (   PDMAudioStrmStatusCanRead(pStream->fStatus)
    29452945            || fDisabled)
    29462946       )
     
    29632963            if (pThis->pHostDrvAudio->pfnStreamGetStatus)
    29642964                fStatus = pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pStream->pvBackend);
    2965             if (   !DrvAudioHlpStreamStatusCanRead(fStatus)
     2965            if (   !PDMAudioStrmStatusCanRead(fStatus)
    29662966                || fDisabled)
    29672967            {
     
    30163016    /* Note: We don't propage the backend stream's status to the outside -- it's the job of this
    30173017     *       audio connector to make sense of it. */
    3018     if (DrvAudioHlpStreamStatusCanWrite(pStream->fStatus))
     3018    if (PDMAudioStrmStatusCanWrite(pStream->fStatus))
    30193019    {
    30203020        cbWritable = AudioMixBufFreeBytes(&pStream->Host.MixBuf);
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r88023 r88025  
    238238/** @name Audio stream command helper methods.
    239239 * @{ */
    240 const char *DrvAudioHlpStreamCmdToStr(PDMAUDIOSTREAMCMD enmCmd);
     240const char *PDMAudioStrmCmdGetName(PDMAUDIOSTREAMCMD enmCmd);
    241241/** @}  */
    242242
    243243/** @name Audio stream status helper methods.
    244244 * @{ */
    245 bool DrvAudioHlpStreamStatusCanRead(PDMAUDIOSTREAMSTS fStatus);
    246 bool DrvAudioHlpStreamStatusCanWrite(PDMAUDIOSTREAMSTS fStatus);
    247 bool DrvAudioHlpStreamStatusIsReady(PDMAUDIOSTREAMSTS fStatus);
     245bool PDMAudioStrmStatusCanRead(PDMAUDIOSTREAMSTS fStatus);
     246bool PDMAudioStrmStatusCanWrite(PDMAUDIOSTREAMSTS fStatus);
     247bool PDMAudioStrmStatusIsReady(PDMAUDIOSTREAMSTS fStatus);
    248248/** @}  */
    249249
     
    262262/** @}  */
    263263
    264 /** @name Audio device enumartion methods.
     264/** @name Audio device enumeration methods.
    265265 * @{ */
    266266int DrvAudioHlpDeviceEnumInit(PPDMAUDIODEVICEENUM pDevEnm);
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r88024 r88025  
    889889
    890890/**
    891  * Converts a stream command to a string.
    892  *
    893  * @returns Stringified stream command, or "Unknown", if not found.
    894  * @param   enmCmd              Stream command to convert.
    895  */
    896 const char *DrvAudioHlpStreamCmdToStr(PDMAUDIOSTREAMCMD enmCmd)
     891 * Converts a stream command enum value to a string.
     892 *
     893 * @returns Pointer to read-only stream command name on success,
     894 *          "Unknown" if invalid command value.
     895 * @param   enmCmd      The stream command to name.
     896 */
     897const char *PDMAudioStrmCmdGetName(PDMAUDIOSTREAMCMD enmCmd)
    897898{
    898899    switch (enmCmd)
     
    908909        case PDMAUDIOSTREAMCMD_32BIT_HACK:
    909910            break;
    910     }
    911     AssertMsgFailed(("Invalid stream command %d\n", enmCmd));
    912     return "Unknown";
    913 }
    914 
    915 /**
    916  * Returns @c true if the given stream status indicates a can-be-read-from stream,
    917  * @c false if not.
    918  *
    919  * @returns @c true if ready to be read from, @c if not.
     911        /* no default! */
     912    }
     913    AssertMsgFailedReturn(("Invalid stream command %d\n", enmCmd), "Unknown");
     914}
     915
     916/**
     917 * Checks if the stream status is one that can be read from.
     918 *
     919 * @returns @c true if ready to be read from, @c false if not.
    920920 * @param   fStatus     Stream status to evaluate, PDMAUDIOSTREAMSTS_FLAGS_XXX.
    921921 */
    922 bool DrvAudioHlpStreamStatusCanRead(PDMAUDIOSTREAMSTS fStatus)
     922bool PDMAudioStrmStatusCanRead(PDMAUDIOSTREAMSTS fStatus)
    923923{
    924924    AssertReturn(fStatus & PDMAUDIOSTREAMSTS_VALID_MASK, false);
    925 
     925    /*
    926926    return      fStatus & PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED
    927927           &&   fStatus & PDMAUDIOSTREAMSTS_FLAGS_ENABLED
    928928           && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PAUSED)
    929            && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT);
    930 }
    931 
    932 /**
    933  * Returns @c true if the given stream status indicates a can-be-written-to stream,
    934  * @c false if not.
    935  *
    936  * @returns @c true if ready to be written to, @c if not.
     929           && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT);*/
     930    return (fStatus & (  PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED
     931                       | PDMAUDIOSTREAMSTS_FLAGS_ENABLED
     932                       | PDMAUDIOSTREAMSTS_FLAGS_PAUSED
     933                       | PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT ))
     934        == (  PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED
     935            | PDMAUDIOSTREAMSTS_FLAGS_ENABLED);
     936}
     937
     938/**
     939 * Checks if the stream status is one that can be written to.
     940 *
     941 * @returns @c true if ready to be written to, @c false if not.
    937942 * @param   fStatus     Stream status to evaluate, PDMAUDIOSTREAMSTS_FLAGS_XXX.
    938943 */
    939 bool DrvAudioHlpStreamStatusCanWrite(PDMAUDIOSTREAMSTS fStatus)
     944bool PDMAudioStrmStatusCanWrite(PDMAUDIOSTREAMSTS fStatus)
    940945{
    941946    AssertReturn(fStatus & PDMAUDIOSTREAMSTS_VALID_MASK, false);
    942 
     947    /*
    943948    return      fStatus & PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED
    944949           &&   fStatus & PDMAUDIOSTREAMSTS_FLAGS_ENABLED
    945950           && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PAUSED)
    946951           && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PENDING_DISABLE)
    947            && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT);
    948 }
    949 
    950 /**
    951  * Returns @c true if the given stream status indicates a ready-to-operate stream,
    952  * @c false if not.
    953  *
    954  * @returns @c true if ready to operate, @c if not.
    955  * @param   fStatus Stream status to evaluate.
    956  */
    957 bool DrvAudioHlpStreamStatusIsReady(PDMAUDIOSTREAMSTS fStatus)
     952           && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT);*/
     953    return (fStatus & (  PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED
     954                       | PDMAUDIOSTREAMSTS_FLAGS_ENABLED
     955                       | PDMAUDIOSTREAMSTS_FLAGS_PAUSED
     956                       | PDMAUDIOSTREAMSTS_FLAGS_PENDING_DISABLE
     957                       | PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT))
     958        == (  PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED
     959            | PDMAUDIOSTREAMSTS_FLAGS_ENABLED);
     960}
     961
     962/**
     963 * Checks if the stream status is a read-to-operate one.
     964 *
     965 * @returns @c true if ready to operate, @c false if not.
     966 * @param   fStatus     Stream status to evaluate, PDMAUDIOSTREAMSTS_FLAGS_XXX.
     967 */
     968bool PDMAudioStrmStatusIsReady(PDMAUDIOSTREAMSTS fStatus)
    958969{
    959970    AssertReturn(fStatus & PDMAUDIOSTREAMSTS_VALID_MASK, false);
    960 
     971    /*
    961972    return      fStatus & PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED
    962973           &&   fStatus & PDMAUDIOSTREAMSTS_FLAGS_ENABLED
    963            && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT);
     974           && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT);*/
     975    return (fStatus & (  PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED
     976                       | PDMAUDIOSTREAMSTS_FLAGS_ENABLED
     977                       | PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT))
     978        == (  PDMAUDIOSTREAMSTS_FLAGS_INITIALIZED
     979            | PDMAUDIOSTREAMSTS_FLAGS_ENABLED);
    964980}
    965981
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