VirtualBox

Changeset 88887 in vbox for trunk/include


Ignore:
Timestamp:
May 5, 2021 11:38:58 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144222
Message:

Audio: Changed PDMIHOSTAUDIO::pfnStreamGetStatus into pfnStreamGetState and defined a simpler state enum (PDMHOSTAUDIOSTREAMSTATE) that fits what DrvAudio needs and the backends actually want to tell us. Fixes one VRDE issue. bugref:9890

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

Legend:

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

    r88884 r88887  
    13081308#define PDMAUDIOBACKENDSTREAM_MAGIC PDM_VERSION_MAKE(0xa0d4, 1, 0)
    13091309
     1310/**
     1311 * Host audio (backend) stream state returned by PDMIHOSTAUDIO::pfnStreamGetState.
     1312 */
     1313typedef enum PDMHOSTAUDIOSTREAMSTATE
     1314{
     1315    /** Invalid zero value, as per usual.   */
     1316    PDMHOSTAUDIOSTREAMSTATE_INVALID = 0,
     1317    /** The stream is being initialized.
     1318     * This should also be used when switching to a new device and the stream
     1319     * stops to work with the old device while the new one being configured.  */
     1320    PDMHOSTAUDIOSTREAMSTATE_INITIALIZING,
     1321    /** The stream does not work (async init failed, audio subsystem gone
     1322     *  fishing, or similar). */
     1323    PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING,
     1324    /** Backend is working okay. */
     1325    PDMHOSTAUDIOSTREAMSTATE_OKAY,
     1326    /** Backend is working but doesn't want any commands or data reads/writes. */
     1327    PDMHOSTAUDIOSTREAMSTATE_INACTIVE,
     1328    /** End of valid values. */
     1329    PDMHOSTAUDIOSTREAMSTATE_END,
     1330    /** Blow the type up to 32 bits. */
     1331    PDMHOSTAUDIOSTREAMSTATE_32BIT_HACK = 0x7fffffff
     1332} PDMHOSTAUDIOSTREAMSTATE;
     1333
    13101334
    13111335/** Pointer to a host audio interface. */
     
    15001524
    15011525    /**
    1502      * Returns the current status of the given backend stream.
    1503      *
    1504      * @returns PDMAUDIOSTREAM_STS_XXX
     1526     * Returns the current state of the given backend stream.
     1527     *
     1528     * @returns PDMHOSTAUDIOSTREAMSTATE value.
     1529     * @retval  PDMHOSTAUDIOSTREAMSTATE_INVALID if invalid stream.
    15051530     * @param   pInterface          Pointer to the interface structure containing the called function pointer.
    15061531     * @param   pStream             Pointer to audio stream.
    15071532     */
    1508     DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetStatus, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
     1533    DECLR3CALLBACKMEMBER(PDMHOSTAUDIOSTREAMSTATE, pfnStreamGetState, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
    15091534
    15101535    /**
     
    15331558    DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
    15341559                                                 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead));
    1535 
    15361560} PDMIHOSTAUDIO;
    15371561
    15381562/** PDMIHOSTAUDIO interface ID. */
    1539 #define PDMIHOSTAUDIO_IID                           "b320d6ab-6cbc-46a8-8011-57e7f7eb0e25"
     1563#define PDMIHOSTAUDIO_IID                           "53949a0a-ca2d-4d25-869f-2a8357991293"
    15401564
    15411565
  • trunk/include/VBox/vmm/pdmaudioinline.h

    r88884 r88887  
    11071107
    11081108/**
     1109 * Converts a audio stream state enum value to a string.
     1110 *
     1111 * @returns Pointer to read-only audio stream state string on success,
     1112 *          "illegal" if invalid command value.
     1113 * @param   enmStreamState  The state to convert.
     1114 */
     1115DECLINLINE(const char *) PDMAudioStreamStateGetName(PDMAUDIOSTREAMSTATE enmStreamState)
     1116{
     1117    switch (enmStreamState)
     1118    {
     1119        case PDMAUDIOSTREAMSTATE_INVALID:           return "invalid";
     1120        case PDMAUDIOSTREAMSTATE_NOT_WORKING:       return "not-working";
     1121        case PDMAUDIOSTREAMSTATE_NEED_REINIT:       return "need-reinit";
     1122        case PDMAUDIOSTREAMSTATE_INACTIVE:          return "inactive";
     1123        case PDMAUDIOSTREAMSTATE_ENABLED:           return "enabled";
     1124        case PDMAUDIOSTREAMSTATE_ENABLED_READABLE:  return "enabled-readable";
     1125        case PDMAUDIOSTREAMSTATE_ENABLED_WRITABLE:  return "enabled-writable";
     1126        /* no default: */
     1127        case PDMAUDIOSTREAMSTATE_END:
     1128        case PDMAUDIOSTREAMSTATE_32BIT_HACK:
     1129            break;
     1130    }
     1131    AssertMsgFailedReturn(("Invalid audio stream state: %d\n", enmStreamState), "illegal");
     1132}
     1133
     1134/**
     1135 * Converts a host audio (backend) stream state enum value to a string.
     1136 *
     1137 * @returns Pointer to read-only host audio stream state string on success,
     1138 *          "illegal" if invalid command value.
     1139 * @param   enmHostAudioStreamState The state to convert.
     1140 */
     1141DECLINLINE(const char *) PDMHostAudioStreamStateGetName(PDMHOSTAUDIOSTREAMSTATE enmHostAudioStreamState)
     1142{
     1143    switch (enmHostAudioStreamState)
     1144    {
     1145        case PDMHOSTAUDIOSTREAMSTATE_INVALID:       return "invalid";
     1146        case PDMHOSTAUDIOSTREAMSTATE_INITIALIZING:  return "initializing";
     1147        case PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING:   return "not-working";
     1148        case PDMHOSTAUDIOSTREAMSTATE_OKAY:          return "okay";
     1149        case PDMHOSTAUDIOSTREAMSTATE_INACTIVE:      return "inactive";
     1150        /* no default: */
     1151        case PDMHOSTAUDIOSTREAMSTATE_END:
     1152        case PDMHOSTAUDIOSTREAMSTATE_32BIT_HACK:
     1153            break;
     1154    }
     1155    AssertMsgFailedReturn(("Invalid host audio stream state: %d\n", enmHostAudioStreamState), "illegal");
     1156}
     1157
     1158/**
    11091159 * Checks if the stream status is one that can be read from.
    11101160 *
     
    11211171                       | PDMAUDIOSTREAM_STS_PAUSED
    11221172                       | PDMAUDIOSTREAM_STS_NEED_REINIT))
    1123         == (  PDMAUDIOSTREAM_STS_INITIALIZED
    1124             | PDMAUDIOSTREAM_STS_ENABLED);
    1125 }
    1126 
    1127 /**
    1128  * Checks if the stream status is one that can be read from.
    1129  *
    1130  * @returns @c true if ready to be read from, @c false if not.
    1131  * @param   fStatus     Stream status to evaluate, PDMAUDIOSTREAM_STS_XXX.
    1132  * @note    Only for backend statuses.
    1133  */
    1134 DECLINLINE(bool) PDMAudioStrmStatusBackendCanRead(uint32_t fStatus)
    1135 {
    1136     PDMAUDIOSTREAM_STS_ASSERT_VALID_BACKEND(fStatus);
    1137     AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK_BACKEND), false);
    1138     return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
    1139                        | PDMAUDIOSTREAM_STS_ENABLED
    1140                        | PDMAUDIOSTREAM_STS_PAUSED
    1141                        | PDMAUDIOSTREAM_STS_NEED_REINIT ))
    11421173        == (  PDMAUDIOSTREAM_STS_INITIALIZED
    11431174            | PDMAUDIOSTREAM_STS_ENABLED);
     
    11651196
    11661197/**
    1167  * Checks if the stream status is one that can be written to, backend edition.
    1168  *
    1169  * @returns @c true if ready to be written to, @c false if not.
    1170  * @param   fStatus     Stream status to evaluate, PDMAUDIOSTREAM_STS_XXX.
    1171  * @note    Only for backend statuses.
    1172  */
    1173 DECLINLINE(bool) PDMAudioStrmStatusBackendCanWrite(uint32_t fStatus)
    1174 {
    1175     PDMAUDIOSTREAM_STS_ASSERT_VALID_BACKEND(fStatus);
    1176     AssertReturn(!(fStatus & ~PDMAUDIOSTREAM_STS_VALID_MASK_BACKEND), false);
    1177     return (fStatus & (  PDMAUDIOSTREAM_STS_INITIALIZED
    1178                        | PDMAUDIOSTREAM_STS_ENABLED
    1179                        | PDMAUDIOSTREAM_STS_PAUSED
    1180                        | PDMAUDIOSTREAM_STS_PENDING_DISABLE))
    1181         == (  PDMAUDIOSTREAM_STS_INITIALIZED
    1182             | PDMAUDIOSTREAM_STS_ENABLED);
    1183 }
    1184 
    1185 /**
    11861198 * Checks if the stream status is a ready-to-operate one.
    11871199 *
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette