VirtualBox

Changeset 89229 in vbox for trunk/include/VBox


Ignore:
Timestamp:
May 23, 2021 1:21:16 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144572
Message:

Audio: Must have a PDMAUDIOHOSTDEV_F_DEFAULT flag for each direction or we'll mess up when two duplex devices are default devices for one direction each. Added a pszId member to the enumeration entires. Rewrote the core audio enumeration code. bugref:9890

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

Legend:

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

    r88355 r89229  
    9191    {
    9292        Assert(pDev->uMagic == PDMAUDIOHOSTDEV_MAGIC);
    93         Assert(pDev->cRefCount == 0);
    9493        pDev->uMagic = ~PDMAUDIOHOSTDEV_MAGIC;
    9594        pDev->cbSelf = 0;
     
    192191 * Appends copies of matching host device entries from one to another enumeration.
    193192 *
    194  * @returns IPRT status code.
     193 * @returns VBox status code.
    195194 * @param   pDstDevEnm      The target to append copies of matching device to.
    196195 * @param   pSrcDevEnm      The source to copy matching devices from.
     
    227226
    228227/**
     228 * Moves all the device entries from one enumeration to another, destroying the
     229 * former.
     230 *
     231 * @returns VBox status code.
     232 * @param   pDstDevEnm          The target to put move @a pSrcDevEnm to.  This
     233 *                              does not need to be initialized, but if it is it
     234 *                              must not have any device entries.
     235 * @param   pSrcDevEnm          The source to move from.  This will be empty
     236 *                              upon successful return.
     237 */
     238DECLINLINE(int) PDMAudioHostEnumMove(PPDMAUDIOHOSTENUM pDstDevEnm, PPDMAUDIOHOSTENUM pSrcDevEnm)
     239{
     240    AssertPtrReturn(pDstDevEnm, VERR_INVALID_POINTER);
     241    AssertReturn(pDstDevEnm->uMagic != PDMAUDIOHOSTENUM_MAGIC || pDstDevEnm->cDevices == 0, VERR_WRONG_ORDER);
     242
     243    AssertPtrReturn(pSrcDevEnm, VERR_INVALID_POINTER);
     244    AssertReturn(pSrcDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC, VERR_WRONG_ORDER);
     245
     246    pDstDevEnm->uMagic   = PDMAUDIOHOSTENUM_MAGIC;
     247    RTListInit(&pDstDevEnm->LstDevices);
     248    pDstDevEnm->cDevices = pSrcDevEnm->cDevices;
     249    if (pSrcDevEnm->cDevices)
     250    {
     251        PPDMAUDIOHOSTDEV pCur;
     252        while ((pCur = RTListRemoveFirst(&pSrcDevEnm->LstDevices, PDMAUDIOHOSTDEV, ListEntry)) != NULL)
     253            RTListAppend(&pDstDevEnm->LstDevices, &pCur->ListEntry);
     254    }
     255    return VINF_SUCCESS;
     256}
     257
     258/**
    229259 * Get the default device with the given usage.
    230260 *
     
    236266 * @param   enmUsage    Usage to get default device for.
    237267 *                      Pass PDMAUDIODIR_INVALID to get the first device with
    238  *                      PDMAUDIOHOSTDEV_F_DEFAULT set.
     268 *                      either PDMAUDIOHOSTDEV_F_DEFAULT_OUT or
     269 *                      PDMAUDIOHOSTDEV_F_DEFAULT_IN set.
    239270 */
    240271DECLINLINE(PPDMAUDIOHOSTDEV) PDMAudioHostEnumGetDefault(PCPDMAUDIOHOSTENUM pDevEnm, PDMAUDIODIR enmUsage)
     
    243274    AssertReturn(pDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC, NULL);
    244275
     276    Assert(enmUsage == PDMAUDIODIR_IN || enmUsage == PDMAUDIODIR_OUT || enmUsage == PDMAUDIODIR_INVALID);
     277    uint32_t const fFlags = enmUsage == PDMAUDIODIR_IN      ? PDMAUDIOHOSTDEV_F_DEFAULT_IN
     278                          : enmUsage == PDMAUDIODIR_OUT     ? PDMAUDIOHOSTDEV_F_DEFAULT_OUT
     279                          : enmUsage == PDMAUDIODIR_INVALID ? PDMAUDIOHOSTDEV_F_DEFAULT_IN | PDMAUDIOHOSTDEV_F_DEFAULT_OUT
     280                          : 0;
     281
    245282    PPDMAUDIOHOSTDEV pDev;
    246283    RTListForEach(&pDevEnm->LstDevices, pDev, PDMAUDIOHOSTDEV, ListEntry)
    247284    {
    248         if (pDev->fFlags & PDMAUDIOHOSTDEV_F_DEFAULT)
     285        if (pDev->fFlags & fFlags)
    249286        {
    250             if (   enmUsage == pDev->enmUsage
    251                 || enmUsage == PDMAUDIODIR_INVALID)
    252                 return pDev;
     287            Assert(pDev->enmUsage == enmUsage || pDev->enmUsage == PDMAUDIODIR_DUPLEX || enmUsage == PDMAUDIODIR_INVALID);
     288            return pDev;
    253289        }
    254290    }
     
    286322/** The max string length for all PDMAUDIOHOSTDEV_F_XXX.
    287323 * @sa PDMAudioHostDevFlagsToString */
    288 #define PDMAUDIOHOSTDEV_MAX_FLAGS_STRING_LEN    (7 * 8)
     324#define PDMAUDIOHOSTDEV_MAX_FLAGS_STRING_LEN    sizeof("DEFAULT_OUT DEFAULT_IN HOTPLUG BUGGY IGNORE LOCKED DEAD NO_DUP ")
    289325
    290326/**
     
    301337    static const struct { const char *pszMnemonic; uint32_t cchMnemonic; uint32_t fFlag; } s_aFlags[] =
    302338    {
    303         { RT_STR_TUPLE("DEFAULT "), PDMAUDIOHOSTDEV_F_DEFAULT },
     339        { RT_STR_TUPLE("DEFAULT_OUT "), PDMAUDIOHOSTDEV_F_DEFAULT_OUT },
     340        { RT_STR_TUPLE("DEFAULT_IN "),  PDMAUDIOHOSTDEV_F_DEFAULT_IN },
    304341        { RT_STR_TUPLE("HOTPLUG "), PDMAUDIOHOSTDEV_F_HOTPLUG },
    305342        { RT_STR_TUPLE("BUGGY "),   PDMAUDIOHOSTDEV_F_BUGGY   },
  • trunk/include/VBox/vmm/pdmaudioifs.h

    r89218 r89229  
    313313/** No flags set. */
    314314#define PDMAUDIOHOSTDEV_F_NONE              UINT32_C(0)
    315 /** The device marks the default device within the host OS. */
    316 #define PDMAUDIOHOSTDEV_F_DEFAULT           RT_BIT_32(0)
     315/** The default input (capture/recording) device (for the user). */
     316#define PDMAUDIOHOSTDEV_F_DEFAULT_IN        RT_BIT_32(0)
     317/** The default output (playback) device (for the user). */
     318#define PDMAUDIOHOSTDEV_F_DEFAULT_OUT       RT_BIT_32(1)
    317319/** The device can be removed at any time and we have to deal with it. */
    318 #define PDMAUDIOHOSTDEV_F_HOTPLUG           RT_BIT_32(1)
     320#define PDMAUDIOHOSTDEV_F_HOTPLUG           RT_BIT_32(2)
    319321/** The device is known to be buggy and needs special treatment. */
    320 #define PDMAUDIOHOSTDEV_F_BUGGY             RT_BIT_32(2)
     322#define PDMAUDIOHOSTDEV_F_BUGGY             RT_BIT_32(3)
    321323/** Ignore the device, no matter what. */
    322 #define PDMAUDIOHOSTDEV_F_IGNORE            RT_BIT_32(3)
     324#define PDMAUDIOHOSTDEV_F_IGNORE            RT_BIT_32(4)
    323325/** The device is present but marked as locked by some other application. */
    324 #define PDMAUDIOHOSTDEV_F_LOCKED            RT_BIT_32(4)
     326#define PDMAUDIOHOSTDEV_F_LOCKED            RT_BIT_32(5)
    325327/** The device is present but not in an alive state (dead). */
    326 #define PDMAUDIOHOSTDEV_F_DEAD              RT_BIT_32(5)
     328#define PDMAUDIOHOSTDEV_F_DEAD              RT_BIT_32(6)
    327329/** Set if the extra backend specific data cannot be duplicated. */
    328330#define PDMAUDIOHOSTDEV_F_NO_DUP            RT_BIT_32(31)
     
    370372    /** Device flags, PDMAUDIOHOSTDEV_F_XXX. */
    371373    uint32_t            fFlags;
    372     /** Reference count indicating how many audio streams currently are relying on this device. */
    373     uint8_t             cRefCount;
    374374    /** Maximum number of input audio channels the device supports. */
    375375    uint8_t             cMaxInputChannels;
    376376    /** Maximum number of output audio channels the device supports. */
    377377    uint8_t             cMaxOutputChannels;
    378     uint8_t             bAlignment;
    379     /** Device type union, based on enmType. */
    380     union
    381     {
    382         /** USB type specifics. */
    383         struct
    384         {
    385             /** Vendor ID. */
    386             uint16_t    idVendor;
    387             /** Product ID. */
    388             uint16_t    idProduct;
    389         } USB;
    390         uint64_t        uPadding[ARCH_BITS >= 64 ? 3 : 4];
    391     } Type;
     378    uint8_t             abAlignment[ARCH_BITS == 32 ? 2 + 12 : 2];
     379    /** Device identifier, OS specific, can be NULL.  It it isn't, it'll point to
     380     *  the non-public part (or into szName if creative). */
     381    const char         *pszId;
    392382    /** Friendly name of the device, if any. Could be truncated. */
    393383    char                szName[64];
     
    400390
    401391/** Magic value for PDMAUDIOHOSTDEV.  */
    402 #define PDMAUDIOHOSTDEV_MAGIC       PDM_VERSION_MAKE(0xa0d0, 1, 0)
     392#define PDMAUDIOHOSTDEV_MAGIC       PDM_VERSION_MAKE(0xa0d0, 2, 0)
    403393
    404394
     
    15251515
    15261516/** PDMIHOSTAUDIO interface ID. */
    1527 #define PDMIHOSTAUDIO_IID                           "ad56b303-0c1f-4b79-9bd1-4ec04ae08c4f"
     1517#define PDMIHOSTAUDIO_IID                           "a6b33abc-1393-4548-92ab-a308d54de1e8"
    15281518
    15291519
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