VirtualBox

Changeset 88731 in vbox for trunk/include/VBox/vmm


Ignore:
Timestamp:
Apr 27, 2021 12:10:00 PM (4 years ago)
Author:
vboxsync
Message:

Audio: Fixed and tightened audio stream state assertions. Doc updates. bugref:9890

Location:
trunk/include/VBox/vmm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmaudioifs.h

    r88726 r88731  
    904904/** No flags being set. */
    905905#define PDMAUDIOSTREAM_STS_NONE             UINT32_C(0)
    906 /** Whether this stream has been initialized by the backend or not. */
     906/** Set if the backend for the stream has been initialized.
     907 * This is generally always set after stream creation, but can be cleared if the
     908 * re-initialization of the stream fails later on. */
    907909#define PDMAUDIOSTREAM_STS_INITIALIZED      RT_BIT_32(0)
    908 /** Whether this stream is enabled or disabled. */
     910/** Set if the stream is enabled, clear if disabled. */
    909911#define PDMAUDIOSTREAM_STS_ENABLED          RT_BIT_32(1)
    910 /** Whether this stream has been paused or not. This also implies
    911  *  that this is an enabled stream! */
     912/** Set if the stream is paused.
     913 * Requires enabled status to be set when used. */
    912914#define PDMAUDIOSTREAM_STS_PAUSED           RT_BIT_32(2)
    913 /** Indicates that the stream is draining (output only).
    914  *  Whether this stream was marked as being disabled
    915  *  but there are still associated guest output streams
    916  *  which rely on its data. */
     915/** Output only: Set when the stream is draining.
     916 * Requires the enabled status to be set when used. */
    917917#define PDMAUDIOSTREAM_STS_PENDING_DISABLE  RT_BIT_32(3)
    918 /** Whether this stream is in re-initialization phase and requires the device
    919  *  to call pfnStreamReInit.
    920  *
    921  *  All other bits remain untouched to be able to restore the stream's state
    922  *  after the re-initialization has been completed. */
     918/** Set if the stream needs to be re-initialized by the device (i.e. call
     919 * PDMIAUDIOCONNECTOR::pfnStreamReInit).
     920 * (The other status bits are preserved and are worked as normal while in this
     921 * state, so that the stream can resume operation where it left off.)
     922 * @note This is not appropriate for PDMIHOSTAUDIO::pfnStreamGetStatus. */
    923923#define PDMAUDIOSTREAM_STS_NEED_REINIT      RT_BIT_32(4)
    924924/** Validation mask. */
    925925#define PDMAUDIOSTREAM_STS_VALID_MASK       UINT32_C(0x0000001f)
     926/** Asserts the validity of the given stream status mask.   */
     927#define PDMAUDIOSTREAM_STS_ASSERT_VALID(a_fStreamStatus) do { \
     928        AssertMsg(!((a_fStreamStatus) & ~PDMAUDIOSTREAM_STS_VALID_MASK), ("%#x\n", (a_fStreamStatus))); \
     929        Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_PAUSED)          || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_ENABLED)); \
     930        Assert(!((a_fStreamStatus) & PDMAUDIOSTREAM_STS_PENDING_DISABLE) || ((a_fStreamStatus) & PDMAUDIOSTREAM_STS_ENABLED)); \
     931    } while (0)
    926932/** @} */
    927933
  • trunk/include/VBox/vmm/pdmaudioinline.h

    r88724 r88731  
    426426DECLINLINE(bool) PDMAudioStrmStatusCanRead(uint32_t fStatus)
    427427{
    428     AssertReturn(fStatus & PDMAUDIOSTREAM_STS_VALID_MASK, false);
    429     /*
    430     return      fStatus & PDMAUDIOSTREAM_STS_INITIALIZED
    431            &&   fStatus & PDMAUDIOSTREAM_STS_ENABLED
    432            && !(fStatus & PDMAUDIOSTREAM_STS_PAUSED)
    433            && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT);*/
     428    PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus);
     429    AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false);
    434430    return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
    435431                       | PDMAUDIOSTREAM_STS_ENABLED
     
    448444DECLINLINE(bool) PDMAudioStrmStatusCanWrite(uint32_t fStatus)
    449445{
    450     AssertReturn(fStatus & PDMAUDIOSTREAM_STS_VALID_MASK, false);
    451     /*
    452     return      fStatus & PDMAUDIOSTREAM_STS_INITIALIZED
    453            &&   fStatus & PDMAUDIOSTREAM_STS_ENABLED
    454            && !(fStatus & PDMAUDIOSTREAM_STS_PAUSED)
    455            && !(fStatus & PDMAUDIOSTREAM_STS_PENDING_DISABLE)
    456            && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT);*/
     446    PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus);
     447    AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false);
    457448    return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
    458449                       | PDMAUDIOSTREAM_STS_ENABLED
     
    472463DECLINLINE(bool) PDMAudioStrmStatusIsReady(uint32_t fStatus)
    473464{
    474     AssertReturn(fStatus & PDMAUDIOSTREAM_STS_VALID_MASK, false);
    475     /*
    476     return      fStatus & PDMAUDIOSTREAM_STS_INITIALIZED
    477            &&   fStatus & PDMAUDIOSTREAM_STS_ENABLED
    478            && !(fStatus & PDMAUDIOSTREAMSTS_FLAGS_PENDING_REINIT);*/
     465    PDMAUDIOSTREAM_STS_ASSERT_VALID(fStatus);
     466    AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK), false);
    479467    return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
    480468                       | 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