VirtualBox

Changeset 88892 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 6, 2021 1:08:15 AM (4 years ago)
Author:
vboxsync
Message:

Audio: Moved the PDMAUDIOSTREAM_STS_XXX stuff into DrvAudio as it's no longer used by any public interfaces any more. bugref:9890

File:
1 edited

Legend:

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

    r88891 r88892  
    4545#include "AudioHlp.h"
    4646#include "AudioMixBuffer.h"
     47
     48
     49/*********************************************************************************************************************************
     50*   Defined Constants And Macros                                                                                                 *
     51*********************************************************************************************************************************/
     52/** @name PDMAUDIOSTREAM_STS_XXX - Used internally by DRVAUDIOSTREAM::fStatus.
     53 * @{ */
     54/** No flags being set. */
     55#define PDMAUDIOSTREAM_STS_NONE                 UINT32_C(0)
     56/** Set if the backend for the stream has been created.
     57 *
     58 * PDMIAUDIOCONNECTOR: This is generally always set after stream creation, but
     59 * can be cleared if the re-initialization of the stream fails later on.
     60 * 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)
     86/** Validation mask for PDMIAUDIOCONNECTOR. */
     87#define PDMAUDIOSTREAM_STS_VALID_MASK           UINT32_C(0x0000030f)
     88/** Asserts the validity of the given stream status mask for PDMIAUDIOCONNECTOR. */
     89#define PDMAUDIOSTREAM_STS_ASSERT_VALID(a_fStreamStatus) do { \
     90        AssertMsg(!((a_fStreamStatus) & ~PDMAUDIOSTREAM_STS_VALID_MASK), ("%#x\n", (a_fStreamStatus))); \
     91        Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_PAUSED)          || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_ENABLED)); \
     92        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)); \
     94    } while (0)
     95
     96/** @} */
    4797
    4898
     
    360410
    361411/** Buffer size for drvAudioStreamStatusToStr.  */
    362 # define DRVAUDIO_STATUS_STR_MAX sizeof("INITIALIZED ENABLED PAUSED PENDING_DISABLED NEED_REINIT BACKEND_READY PREPARING_SWITCH 0x12345678")
     412# define DRVAUDIO_STATUS_STR_MAX sizeof("INITIALIZED ENABLED PAUSED PENDING_DISABLED NEED_REINIT BACKEND_READY 0x12345678")
    363413
    364414/**
     
    385435        { RT_STR_TUPLE("NEED_REINIT "),      PDMAUDIOSTREAM_STS_NEED_REINIT      },
    386436        { RT_STR_TUPLE("BACKEND_READY "),    PDMAUDIOSTREAM_STS_BACKEND_READY    },
    387         { RT_STR_TUPLE("PREPARING_SWITCH "), PDMAUDIOSTREAM_STS_PREPARING_SWITCH },
    388437    };
    389438    if (!fStatus)
     
    430479    }
    431480    return "BAD";
     481}
     482
     483/**
     484 * Checks if the stream status is one that can be read from.
     485 *
     486 * @returns @c true if ready to be read from, @c false if not.
     487 * @param   fStatus     Stream status to evaluate, PDMAUDIOSTREAM_STS_XXX.
     488 * @note    Not for backend statuses (use PDMAudioStrmStatusBackendCanRead)!
     489 */
     490DECLINLINE(bool) PDMAudioStrmStatusCanRead(uint32_t fStatus)
     491{
     492    PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus);
     493    AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false);
     494    return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
     495                       | PDMAUDIOSTREAM_STS_ENABLED
     496                       | PDMAUDIOSTREAM_STS_PAUSED
     497                       | PDMAUDIOSTREAM_STS_NEED_REINIT))
     498        == (  PDMAUDIOSTREAM_STS_INITIALIZED
     499            | PDMAUDIOSTREAM_STS_ENABLED);
     500}
     501
     502/**
     503 * Checks if the stream status is one that can be written to.
     504 *
     505 * @returns @c true if ready to be written to, @c false if not.
     506 * @param   fStatus     Stream status to evaluate, PDMAUDIOSTREAM_STS_XXX.
     507 * @note    Not for backend statuses (use PDMAudioStrmStatusBackendCanWrite)!
     508 */
     509DECLINLINE(bool) PDMAudioStrmStatusCanWrite(uint32_t fStatus)
     510{
     511    PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus);
     512    AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false);
     513    return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
     514                       | PDMAUDIOSTREAM_STS_ENABLED
     515                       | PDMAUDIOSTREAM_STS_PAUSED
     516                       | PDMAUDIOSTREAM_STS_PENDING_DISABLE
     517                       | PDMAUDIOSTREAM_STS_NEED_REINIT))
     518        == (  PDMAUDIOSTREAM_STS_INITIALIZED
     519            | PDMAUDIOSTREAM_STS_ENABLED);
     520}
     521
     522/**
     523 * Checks if the stream status is a ready-to-operate one.
     524 *
     525 * @returns @c true if ready to operate, @c false if not.
     526 * @param   fStatus     Stream status to evaluate, PDMAUDIOSTREAM_STS_XXX.
     527 * @note    Not for backend statuses!
     528 */
     529DECLINLINE(bool) PDMAudioStrmStatusIsReady(uint32_t fStatus)
     530{
     531    PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus);
     532    AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false);
     533    return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
     534                       | PDMAUDIOSTREAM_STS_ENABLED
     535                       | PDMAUDIOSTREAM_STS_NEED_REINIT))
     536        == (  PDMAUDIOSTREAM_STS_INITIALIZED
     537            | PDMAUDIOSTREAM_STS_ENABLED);
    432538}
    433539
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