VirtualBox

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


Ignore:
Timestamp:
May 6, 2021 11:24:07 AM (4 years ago)
Author:
vboxsync
Message:

DrvAudio: Status cleanup. bugref:9890

File:
1 edited

Legend:

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

    r88892 r88896  
    5454/** No flags being set. */
    5555#define PDMAUDIOSTREAM_STS_NONE                 UINT32_C(0)
     56/** Set if the stream is enabled, clear if disabled. */
     57#define PDMAUDIOSTREAM_STS_ENABLED              RT_BIT_32(0)
     58/** Set if the stream is paused.
     59 * Requires the ENABLED status to be set when used. */
     60#define PDMAUDIOSTREAM_STS_PAUSED               RT_BIT_32(1)
     61/** Output only: Set when the stream is draining.
     62 * Requires the ENABLED status to be set when used. */
     63#define PDMAUDIOSTREAM_STS_PENDING_DISABLE      RT_BIT_32(2)
     64
    5665/** Set if the backend for the stream has been created.
    5766 *
    58  * PDMIAUDIOCONNECTOR: This is generally always set after stream creation, but
     67 * This is generally always set after stream creation, but
    5968 * can be cleared if the re-initialization of the stream fails later on.
    6069 * Asynchronous init may still be incomplete, see
    61  *
    62  * PDMIHOSTAUDIO: This may not be set immediately if the backend is doing some
    63  * of the stream creation asynchronously via PDMIHOSTAUDIO::pfnStreamInitAsync.
    64  * The DrvAudio code will not report this to the devices, but keep on
    65  * prebuffering till pfnStreamInitAsync is done and this bit is set. */
    66 #define PDMAUDIOSTREAM_STS_INITIALIZED          RT_BIT_32(0)
    67 /** Set if the stream is enabled, clear if disabled. */
    68 #define PDMAUDIOSTREAM_STS_ENABLED              RT_BIT_32(1)
    69 /** Set if the stream is paused.
    70  * Requires the ENABLED status to be set when used. */
    71 #define PDMAUDIOSTREAM_STS_PAUSED               RT_BIT_32(2)
    72 /** Output only: Set when the stream is draining.
    73  * Requires the ENABLED status to be set when used.
    74  * @todo See todo in drvAudioStreamPlay() regarding the suitability of this
    75  *       for PDMIHOSTAUDIO. */
    76 #define PDMAUDIOSTREAM_STS_PENDING_DISABLE      RT_BIT_32(3)
    77 
    78 /** PDMIAUDIOCONNECTOR: Set if the stream needs to be re-initialized by the
    79  * device (i.e. call PDMIAUDIOCONNECTOR::pfnStreamReInit). (The other status
    80  * bits are preserved and are worked as normal while in this state, so that the
    81  * stream can resume operation where it left off.)  */
    82 #define PDMAUDIOSTREAM_STS_NEED_REINIT          RT_BIT_32(8)
    83 /** PDMIAUDIOCONNECTOR: The backend is ready (PDMIHOSTAUDIO::pfnStreamInitAsync  done).
    84  * Requires the INITIALIZED status to be set.  */
    85 #define PDMAUDIOSTREAM_STS_BACKEND_READY        RT_BIT_32(9)
     70 * PDMAUDIOSTREAM_STS_BACKEND_READY. */
     71#define PDMAUDIOSTREAM_STS_BACKEND_CREATED      RT_BIT_32(3)
     72/** The backend is ready (PDMIHOSTAUDIO::pfnStreamInitAsync is done).
     73 * Requires the BACKEND_CREATED status to be set.  */
     74#define PDMAUDIOSTREAM_STS_BACKEND_READY        RT_BIT_32(4)
     75/** Set if the stream needs to be re-initialized by the device (i.e. call
     76 * PDMIAUDIOCONNECTOR::pfnStreamReInit). (The other status bits are preserved
     77 * and are worked as normal while in this state, so that the stream can
     78 * resume operation where it left off.)  */
     79#define PDMAUDIOSTREAM_STS_NEED_REINIT          RT_BIT_32(5)
    8680/** Validation mask for PDMIAUDIOCONNECTOR. */
    87 #define PDMAUDIOSTREAM_STS_VALID_MASK           UINT32_C(0x0000030f)
     81#define PDMAUDIOSTREAM_STS_VALID_MASK           UINT32_C(0x0000003f)
    8882/** Asserts the validity of the given stream status mask for PDMIAUDIOCONNECTOR. */
    8983#define PDMAUDIOSTREAM_STS_ASSERT_VALID(a_fStreamStatus) do { \
     
    9185        Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_PAUSED)          || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_ENABLED)); \
    9286        Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_PENDING_DISABLE) || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_ENABLED)); \
    93         Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_BACKEND_READY)   || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_INITIALIZED)); \
     87        Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_BACKEND_READY)   || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_BACKEND_CREATED)); \
    9488    } while (0)
    9589
     
    409403static int drvAudioStreamIterateInternal(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx);
    410404
     405
    411406/** Buffer size for drvAudioStreamStatusToStr.  */
    412 # define DRVAUDIO_STATUS_STR_MAX sizeof("INITIALIZED ENABLED PAUSED PENDING_DISABLED NEED_REINIT BACKEND_READY 0x12345678")
     407# define DRVAUDIO_STATUS_STR_MAX sizeof("BACKEND_CREATED BACKEND_READY ENABLED PAUSED PENDING_DISABLED NEED_REINIT 0x12345678")
    413408
    414409/**
     
    429424    } s_aFlags[] =
    430425    {
    431         { RT_STR_TUPLE("INITIALIZED "),      PDMAUDIOSTREAM_STS_INITIALIZED      },
     426        { RT_STR_TUPLE("BACKEND_CREATED "),  PDMAUDIOSTREAM_STS_BACKEND_CREATED  },
     427        { RT_STR_TUPLE("BACKEND_READY "),    PDMAUDIOSTREAM_STS_BACKEND_READY    },
    432428        { RT_STR_TUPLE("ENABLED "),          PDMAUDIOSTREAM_STS_ENABLED          },
    433429        { RT_STR_TUPLE("PAUSED "),           PDMAUDIOSTREAM_STS_PAUSED           },
    434430        { RT_STR_TUPLE("PENDING_DISABLE "),  PDMAUDIOSTREAM_STS_PENDING_DISABLE  },
    435431        { RT_STR_TUPLE("NEED_REINIT "),      PDMAUDIOSTREAM_STS_NEED_REINIT      },
    436         { RT_STR_TUPLE("BACKEND_READY "),    PDMAUDIOSTREAM_STS_BACKEND_READY    },
    437432    };
    438433    if (!fStatus)
     
    492487    PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus);
    493488    AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false);
    494     return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
     489    return (fStatus & (  PDMAUDIOSTREAM_STS_BACKEND_CREATED
    495490                       | PDMAUDIOSTREAM_STS_ENABLED
    496491                       | PDMAUDIOSTREAM_STS_PAUSED
    497492                       | PDMAUDIOSTREAM_STS_NEED_REINIT))
    498         == (  PDMAUDIOSTREAM_STS_INITIALIZED
     493        == (  PDMAUDIOSTREAM_STS_BACKEND_CREATED
    499494            | PDMAUDIOSTREAM_STS_ENABLED);
    500495}
     
    511506    PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus);
    512507    AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false);
    513     return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
     508    return (fStatus & (  PDMAUDIOSTREAM_STS_BACKEND_CREATED
    514509                       | PDMAUDIOSTREAM_STS_ENABLED
    515510                       | PDMAUDIOSTREAM_STS_PAUSED
    516511                       | PDMAUDIOSTREAM_STS_PENDING_DISABLE
    517512                       | PDMAUDIOSTREAM_STS_NEED_REINIT))
    518         == (  PDMAUDIOSTREAM_STS_INITIALIZED
     513        == (  PDMAUDIOSTREAM_STS_BACKEND_CREATED
    519514            | PDMAUDIOSTREAM_STS_ENABLED);
    520515}
     
    531526    PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus);
    532527    AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false);
    533     return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
     528    return (fStatus & (  PDMAUDIOSTREAM_STS_BACKEND_CREATED
    534529                       | PDMAUDIOSTREAM_STS_ENABLED
    535530                       | PDMAUDIOSTREAM_STS_NEED_REINIT))
    536         == (  PDMAUDIOSTREAM_STS_INITIALIZED
     531        == (  PDMAUDIOSTREAM_STS_BACKEND_CREATED
    537532            | PDMAUDIOSTREAM_STS_ENABLED);
    538533}
     
    12431238                                               PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
    12441239{
    1245     AssertMsg((pStreamEx->fStatus & PDMAUDIOSTREAM_STS_INITIALIZED) == 0,
     1240    AssertMsg((pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED) == 0,
    12461241              ("Stream '%s' already initialized in backend\n", pStreamEx->Core.szName));
    12471242
     
    12811276           destroyed (this used to be done at the end of this function, with
    12821277           several possible early return paths before it). */
    1283         pStreamEx->fStatus |= PDMAUDIOSTREAM_STS_INITIALIZED;
     1278        pStreamEx->fStatus |= PDMAUDIOSTREAM_STS_BACKEND_CREATED;
    12841279    }
    12851280    else
     
    17901785    LogFunc(("[%s] fStatus=%s\n", pStreamEx->Core.szName, drvAudioStreamStatusToStr(szStreamSts, pStreamEx->fStatus)));
    17911786
    1792     if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_INITIALIZED)
     1787    if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED)
    17931788    {
    17941789        AssertPtr(pStreamEx->pBackend);
     
    17991794            rc = pThis->pHostDrvAudio->pfnStreamDestroy(pThis->pHostDrvAudio, pStreamEx->pBackend);
    18001795
    1801         pStreamEx->fStatus &= ~(PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_BACKEND_READY);
     1796        pStreamEx->fStatus &= ~(PDMAUDIOSTREAM_STS_BACKEND_CREATED | PDMAUDIOSTREAM_STS_BACKEND_READY);
    18021797        PDMAUDIOSTREAM_STS_ASSERT_VALID(pStreamEx->fStatus);
    18031798    }
     
    20822077     * Destroy and re-create stream on backend side.
    20832078     */
    2084     if (   (pStreamEx->fStatus & (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_BACKEND_READY))
    2085         ==                       (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_BACKEND_READY))
     2079    if (   (pStreamEx->fStatus & (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_BACKEND_CREATED | PDMAUDIOSTREAM_STS_BACKEND_READY))
     2080        ==                       (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_BACKEND_CREATED | PDMAUDIOSTREAM_STS_BACKEND_READY))
    20862081        drvAudioStreamControlInternalBackend(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE);
    20872082
    2088     if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_INITIALIZED)
     2083    if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED)
    20892084        drvAudioStreamDestroyInternalBackend(pThis, pStreamEx);
    20902085
    20912086    int rc = VERR_AUDIO_STREAM_NOT_READY;
    2092     if (!(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_INITIALIZED))
     2087    if (!(pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED))
    20932088    {
    20942089        drvAudioStreamResetInternal(pStreamEx);
     
    21282123                 * let the worker thread do it after the async init has completed.
    21292124                 */
    2130                 if (   (pStreamEx->fStatus & (PDMAUDIOSTREAM_STS_BACKEND_READY | PDMAUDIOSTREAM_STS_INITIALIZED))
    2131                     ==                       (PDMAUDIOSTREAM_STS_BACKEND_READY | PDMAUDIOSTREAM_STS_INITIALIZED))
     2125                if (   (pStreamEx->fStatus & (PDMAUDIOSTREAM_STS_BACKEND_READY | PDMAUDIOSTREAM_STS_BACKEND_CREATED))
     2126                    ==                       (PDMAUDIOSTREAM_STS_BACKEND_READY | PDMAUDIOSTREAM_STS_BACKEND_CREATED))
    21322127                {
    21332128                    rc = drvAudioStreamUpdateBackendOnStatus(pThis, pStreamEx, "re-initializing");
    21342129                    /** @todo not sure if we really need to care about this status code...   */
    21352130                }
    2136                 else if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_INITIALIZED)
     2131                else if (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED)
    21372132                {
    21382133                    Assert(pStreamEx->hReqInitAsync != NIL_RTREQ);
     
    23902385    LogFunc(("[%s]\n", pStreamEx->Core.szName));
    23912386
    2392     pStreamEx->fStatus            &= PDMAUDIOSTREAM_STS_INITIALIZED | PDMAUDIOSTREAM_STS_BACKEND_READY;
     2387    pStreamEx->fStatus            &= PDMAUDIOSTREAM_STS_BACKEND_CREATED | PDMAUDIOSTREAM_STS_BACKEND_READY;
    23932388    pStreamEx->Core.fWarningsShown = PDMAUDIOSTREAM_WARN_FLAGS_NONE;
    23942389
     
    32523247    if (!(fStrmStatus & PDMAUDIOSTREAM_STS_NEED_REINIT))
    32533248    {
    3254         if (fStrmStatus & PDMAUDIOSTREAM_STS_INITIALIZED)
     3249        if (fStrmStatus & PDMAUDIOSTREAM_STS_BACKEND_CREATED)
    32553250        {
    32563251            if (   (fStrmStatus & PDMAUDIOSTREAM_STS_ENABLED)
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