VirtualBox

Changeset 88045 in vbox


Ignore:
Timestamp:
Mar 9, 2021 1:27:51 PM (4 years ago)
Author:
vboxsync
Message:

Audio: More prep work to move the audio device enumeration code to PDM. bugref:9890

Location:
trunk
Files:
6 edited

Legend:

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

    r88044 r88045  
    310310typedef uint32_t PDMAUDIODEVLATSPECSEC;
    311311
    312 /** @name PDMAUDIODEV_FLAGS_XXX
     312/** @name PDMAUDIOHOSTDEV_F_XXX
    313313 * @{  */
    314314/** No flags set. */
    315 #define PDMAUDIODEV_FLAGS_NONE              UINT32_C(0)
     315#define PDMAUDIOHOSTDEV_F_NONE              UINT32_C(0)
    316316/** The device marks the default device within the host OS. */
    317 #define PDMAUDIODEV_FLAGS_DEFAULT           RT_BIT_32(0)
     317#define PDMAUDIOHOSTDEV_F_DEFAULT           RT_BIT_32(0)
    318318/** The device can be removed at any time and we have to deal with it. */
    319 #define PDMAUDIODEV_FLAGS_HOTPLUG           RT_BIT_32(1)
     319#define PDMAUDIOHOSTDEV_F_HOTPLUG           RT_BIT_32(1)
    320320/** The device is known to be buggy and needs special treatment. */
    321 #define PDMAUDIODEV_FLAGS_BUGGY             RT_BIT_32(2)
     321#define PDMAUDIOHOSTDEV_F_BUGGY             RT_BIT_32(2)
    322322/** Ignore the device, no matter what. */
    323 #define PDMAUDIODEV_FLAGS_IGNORE            RT_BIT_32(3)
     323#define PDMAUDIOHOSTDEV_F_IGNORE            RT_BIT_32(3)
    324324/** The device is present but marked as locked by some other application. */
    325 #define PDMAUDIODEV_FLAGS_LOCKED            RT_BIT_32(4)
     325#define PDMAUDIOHOSTDEV_F_LOCKED            RT_BIT_32(4)
    326326/** The device is present but not in an alive state (dead). */
    327 #define PDMAUDIODEV_FLAGS_DEAD              RT_BIT_32(5)
     327#define PDMAUDIOHOSTDEV_F_DEAD              RT_BIT_32(5)
    328328/** Set if the extra backend specific data cannot be duplicated. */
    329 #define PDMAUDIODEV_FLAGS_NO_DUP            RT_BIT_32(31)
     329#define PDMAUDIOHOSTDEV_F_NO_DUP            RT_BIT_32(31)
    330330/** @} */
    331331
     
    346346    /** The device is an (external) USB device. */
    347347    PDMAUDIODEVICETYPE_USB,
     348    /** End of valid values. */
     349    PDMAUDIODEVICETYPE_END,
    348350    /** Hack to blow the type up to 32-bit. */
    349351    PDMAUDIODEVICETYPE_32BIT_HACK = 0x7fffffff
     
    351353
    352354/**
    353  * Audio device info (enumeration result).
     355 * Host audio device info, part of enumeration result.
     356 *
    354357 * @sa PDMAUDIOHOSTENUM, PDMIHOSTAUDIO::pfnGetDevices
    355358 */
    356 typedef struct PDMAUDIODEVICE
     359typedef struct PDMAUDIOHOSTDEV
    357360{
    358361    /** List entry (like PDMAUDIOHOSTENUM::LstDevices). */
    359362    RTLISTNODE          Node;
    360     /** Magic value (PDMAUDIODEVICE_MAGIC). */
     363    /** Magic value (PDMAUDIOHOSTDEV_MAGIC). */
    361364    uint32_t            uMagic;
    362365    /** Size of this structure and whatever backend specific data that follows it. */
     
    366369    /** Usage of the device. */
    367370    PDMAUDIODIR         enmUsage;
    368     /** Device flags, PDMAUDIODEV_FLAGS_XXX. */
     371    /** Device flags, PDMAUDIOHOSTDEV_F_XXX. */
    369372    uint32_t            fFlags;
    370373    /** Reference count indicating how many audio streams currently are relying on this device. */
     
    388391        uint64_t        uPadding[ARCH_BITS >= 64 ? 3 : 4];
    389392    } Type;
    390     /** Friendly name of the device, if any. */
     393    /** Friendly name of the device, if any. Could be truncated. */
    391394    char                szName[64];
    392 } PDMAUDIODEVICE;
    393 AssertCompileSizeAlignment(PDMAUDIODEVICE, 32);
     395} PDMAUDIOHOSTDEV;
     396AssertCompileSizeAlignment(PDMAUDIOHOSTDEV, 16);
    394397/** Pointer to audio device info (enum result). */
    395 typedef PDMAUDIODEVICE *PPDMAUDIODEVICE;
     398typedef PDMAUDIOHOSTDEV *PPDMAUDIOHOSTDEV;
    396399/** Pointer to a const audio device info (enum result). */
    397 typedef PDMAUDIODEVICE const *PCPDMAUDIODEVICE;
    398 
    399 /** Magic value for PDMAUDIODEVICE. (Armando Anthony "Chick" Corea) */
    400 #define PDMAUDIODEVICE_MAGIC        UINT32_C(0x19410612)
    401 /** Magic value for PDMAUDIODEVICE after free. */
    402 #define PDMAUDIODEVICE_MAGIC_DEAD   UINT32_C(0x20210209)
     400typedef PDMAUDIOHOSTDEV const *PCPDMAUDIOHOSTDEV;
     401
     402/** Magic value for PDMAUDIOHOSTDEV. (Armando Anthony "Chick" Corea) */
     403#define PDMAUDIOHOSTDEV_MAGIC           UINT32_C(0x19410612)
     404/** Magic value for PDMAUDIOHOSTDEV after free. */
     405#define PDMAUDIOHOSTDEV_MAGIC_DEAD      UINT32_C(0x20210209)
    403406
    404407
     
    414417    /** Number of audio devices in the list. */
    415418    uint32_t        cDevices;
    416     /** List of audio devices (PDMAUDIODEVICE). */
     419    /** List of audio devices (PDMAUDIOHOSTDEV). */
    417420    RTLISTANCHOR    LstDevices;
    418421} PDMAUDIOHOSTENUM;
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r88044 r88045  
    21712171                LogRel(("Audio: Found %RU16 devices for driver '%s'\n", DevEnum.cDevices, pThis->szName));
    21722172
    2173             PPDMAUDIODEVICE pDev;
    2174             RTListForEach(&DevEnum.LstDevices, pDev, PDMAUDIODEVICE, Node)
     2173            PPDMAUDIOHOSTDEV pDev;
     2174            RTListForEach(&DevEnum.LstDevices, pDev, PDMAUDIOHOSTDEV, Node)
    21752175            {
    21762176                if (fLog)
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r88044 r88045  
    209209/** @name Audio device methods.
    210210 * @{ */
    211 PPDMAUDIODEVICE PDMAudioDeviceAlloc(size_t cb);
    212 void            PDMAudioDeviceFree(PPDMAUDIODEVICE pDev);
    213 PPDMAUDIODEVICE PDMAudioDeviceDup(const PPDMAUDIODEVICE pDev, bool fOnlyCoreData);
     211PPDMAUDIOHOSTDEV PDMAudioDeviceAlloc(size_t cb);
     212void            PDMAudioDeviceFree(PPDMAUDIOHOSTDEV pDev);
     213PPDMAUDIOHOSTDEV PDMAudioDeviceDup(const PPDMAUDIOHOSTDEV pDev, bool fOnlyCoreData);
    214214/** @}  */
    215215
     
    218218void            PDMAudioHostEnumInit(PPDMAUDIOHOSTENUM pDevEnm);
    219219void            PDMAudioHostEnumDelete(PPDMAUDIOHOSTENUM pDevEnm);
    220 void            PDMAudioHostEnumAppend(PPDMAUDIOHOSTENUM pDevEnm, PPDMAUDIODEVICE pDev);
     220void            PDMAudioHostEnumAppend(PPDMAUDIOHOSTENUM pDevEnm, PPDMAUDIOHOSTDEV pDev);
    221221int             PDMAudioHostEnumCopy(PPDMAUDIOHOSTENUM pDstDevEnm, PCPDMAUDIOHOSTENUM pSrcDevEnm,
    222222                                     PDMAUDIODIR enmUsage, bool fOnlyCoreData);
    223 PPDMAUDIODEVICE PDMAudioHostEnumGetDefault(PCPDMAUDIOHOSTENUM pDevEnm, PDMAUDIODIR enmDir);
     223PPDMAUDIOHOSTDEV PDMAudioHostEnumGetDefault(PCPDMAUDIOHOSTENUM pDevEnm, PDMAUDIODIR enmDir);
    224224uint32_t        PDMAudioHostEnumCountMatching(PCPDMAUDIOHOSTENUM pDevEnm, PDMAUDIODIR enmUsage);
    225225void            PDMAudioHostEnumLog(PCPDMAUDIOHOSTENUM pDevEnm, const char *pszDesc);
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r88044 r88045  
    148148 * @returns Newly allocated audio device, or NULL on failure.
    149149 * @param   cb      The total device structure size.   This must be at least the
    150  *                  size of PDMAUDIODEVICE.  The idea is that the caller extends
    151  *                  the PDMAUDIODEVICE structure and appends additional data
     150 *                  size of PDMAUDIOHOSTDEV.  The idea is that the caller extends
     151 *                  the PDMAUDIOHOSTDEV structure and appends additional data
    152152 *                  after it in its private structure.
    153153 */
    154 PPDMAUDIODEVICE PDMAudioDeviceAlloc(size_t cb)
    155 {
    156     AssertReturn(cb >= sizeof(PDMAUDIODEVICE), NULL);
     154PPDMAUDIOHOSTDEV PDMAudioDeviceAlloc(size_t cb)
     155{
     156    AssertReturn(cb >= sizeof(PDMAUDIOHOSTDEV), NULL);
    157157    AssertReturn(cb < _4M, NULL);
    158158
    159     PPDMAUDIODEVICE pDev = (PPDMAUDIODEVICE)RTMemAllocZ(RT_ALIGN_Z(cb, 64));
     159    PPDMAUDIOHOSTDEV pDev = (PPDMAUDIOHOSTDEV)RTMemAllocZ(RT_ALIGN_Z(cb, 64));
    160160    if (pDev)
    161161    {
    162         pDev->uMagic = PDMAUDIODEVICE_MAGIC;
     162        pDev->uMagic = PDMAUDIOHOSTDEV_MAGIC;
    163163        pDev->cbSelf = (uint32_t)cb;
    164164        RTListInit(&pDev->Node);
     
    175175 * @param   pDev    The device to free.  NULL is ignored.
    176176 */
    177 void PDMAudioDeviceFree(PPDMAUDIODEVICE pDev)
     177void PDMAudioDeviceFree(PPDMAUDIOHOSTDEV pDev)
    178178{
    179179    if (pDev)
    180180    {
    181         Assert(pDev->uMagic == PDMAUDIODEVICE_MAGIC);
     181        Assert(pDev->uMagic == PDMAUDIOHOSTDEV_MAGIC);
    182182        Assert(pDev->cRefCount == 0);
    183         pDev->uMagic = PDMAUDIODEVICE_MAGIC_DEAD;
     183        pDev->uMagic = PDMAUDIOHOSTDEV_MAGIC_DEAD;
    184184        pDev->cbSelf = 0;
    185185
     
    195195 * @param   fOnlyCoreData
    196196 */
    197 PPDMAUDIODEVICE PDMAudioDeviceDup(PPDMAUDIODEVICE pDev, bool fOnlyCoreData)
     197PPDMAUDIOHOSTDEV PDMAudioDeviceDup(PPDMAUDIOHOSTDEV pDev, bool fOnlyCoreData)
    198198{
    199199    AssertPtrReturn(pDev, NULL);
    200     Assert(pDev->uMagic == PDMAUDIODEVICE_MAGIC);
    201     Assert(fOnlyCoreData || !(pDev->fFlags & PDMAUDIODEV_FLAGS_NO_DUP));
    202 
    203     uint32_t cbToDup = fOnlyCoreData ? sizeof(PDMAUDIODEVICE) : pDev->cbSelf;
     200    Assert(pDev->uMagic == PDMAUDIOHOSTDEV_MAGIC);
     201    Assert(fOnlyCoreData || !(pDev->fFlags & PDMAUDIOHOSTDEV_F_NO_DUP));
     202
     203    uint32_t cbToDup = fOnlyCoreData ? sizeof(PDMAUDIOHOSTDEV) : pDev->cbSelf;
    204204    AssertReturn(cbToDup >= sizeof(*pDev), NULL);
    205205
    206     PPDMAUDIODEVICE pDevDup = PDMAudioDeviceAlloc(cbToDup);
     206    PPDMAUDIOHOSTDEV pDevDup = PDMAudioDeviceAlloc(cbToDup);
    207207    if (pDevDup)
    208208    {
     
    244244        AssertReturnVoid(pDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC);
    245245
    246         PPDMAUDIODEVICE pDev, pDevNext;
    247         RTListForEachSafe(&pDevEnm->LstDevices, pDev, pDevNext, PDMAUDIODEVICE, Node)
     246        PPDMAUDIOHOSTDEV pDev, pDevNext;
     247        RTListForEachSafe(&pDevEnm->LstDevices, pDev, pDevNext, PDMAUDIOHOSTDEV, Node)
    248248        {
    249249            RTListNodeRemove(&pDev->Node);
     
    268268 * @param  pDev                 Device to add. The pointer will be owned by the device enumeration  then.
    269269 */
    270 void PDMAudioHostEnumAppend(PPDMAUDIOHOSTENUM pDevEnm, PPDMAUDIODEVICE pDev)
     270void PDMAudioHostEnumAppend(PPDMAUDIOHOSTENUM pDevEnm, PPDMAUDIOHOSTDEV pDev)
    271271{
    272272    AssertPtr(pDevEnm);
     
    286286 * @param   enmUsage        The usage to match for copying.
    287287 *                          Use PDMAUDIODIR_INVALID to match all entries.
    288  * @param   fOnlyCoreData   Set this to only copy the PDMAUDIODEVICE part.
     288 * @param   fOnlyCoreData   Set this to only copy the PDMAUDIOHOSTDEV part.
    289289 *                          Careful with passing @c false here as not all
    290290 *                          backends have data that can be copied.
     
    299299    AssertReturn(pSrcDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC, VERR_WRONG_ORDER);
    300300
    301     PPDMAUDIODEVICE pSrcDev;
    302     RTListForEach(&pSrcDevEnm->LstDevices, pSrcDev, PDMAUDIODEVICE, Node)
     301    PPDMAUDIOHOSTDEV pSrcDev;
     302    RTListForEach(&pSrcDevEnm->LstDevices, pSrcDev, PDMAUDIOHOSTDEV, Node)
    303303    {
    304304        if (   enmUsage == pSrcDev->enmUsage
    305305            || enmUsage == PDMAUDIODIR_INVALID /*all*/)
    306306        {
    307             PPDMAUDIODEVICE pDstDev = PDMAudioDeviceDup(pSrcDev, fOnlyCoreData);
     307            PPDMAUDIOHOSTDEV pDstDev = PDMAudioDeviceDup(pSrcDev, fOnlyCoreData);
    308308            AssertReturn(pDstDev, VERR_NO_MEMORY);
    309309
     
    325325 * @param   enmUsage    Usage to get default device for.
    326326 *                      Pass PDMAUDIODIR_INVALID to get the first device with
    327  *                      PDMAUDIODEV_FLAGS_DEFAULT set.
    328  */
    329 PPDMAUDIODEVICE PDMAudioHostEnumGetDefault(PCPDMAUDIOHOSTENUM pDevEnm, PDMAUDIODIR enmUsage)
     327 *                      PDMAUDIOHOSTDEV_F_DEFAULT set.
     328 */
     329PPDMAUDIOHOSTDEV PDMAudioHostEnumGetDefault(PCPDMAUDIOHOSTENUM pDevEnm, PDMAUDIODIR enmUsage)
    330330{
    331331    AssertPtrReturn(pDevEnm, NULL);
    332332    AssertReturn(pDevEnm->uMagic == PDMAUDIOHOSTENUM_MAGIC, NULL);
    333333
    334     PPDMAUDIODEVICE pDev;
    335     RTListForEach(&pDevEnm->LstDevices, pDev, PDMAUDIODEVICE, Node)
    336     {
    337         if (pDev->fFlags & PDMAUDIODEV_FLAGS_DEFAULT)
     334    PPDMAUDIOHOSTDEV pDev;
     335    RTListForEach(&pDevEnm->LstDevices, pDev, PDMAUDIOHOSTDEV, Node)
     336    {
     337        if (pDev->fFlags & PDMAUDIOHOSTDEV_F_DEFAULT)
    338338        {
    339339            if (   enmUsage == pDev->enmUsage
     
    363363
    364364    uint32_t        cDevs = 0;
    365     PPDMAUDIODEVICE pDev;
    366     RTListForEach(&pDevEnm->LstDevices, pDev, PDMAUDIODEVICE, Node)
     365    PPDMAUDIOHOSTDEV pDev;
     366    RTListForEach(&pDevEnm->LstDevices, pDev, PDMAUDIOHOSTDEV, Node)
    367367    {
    368368        if (enmUsage == pDev->enmUsage)
     
    387387    LogFunc(("%s: %RU32 devices\n", pszDesc, pDevEnm->cDevices));
    388388
    389     PPDMAUDIODEVICE pDev;
    390     RTListForEach(&pDevEnm->LstDevices, pDev, PDMAUDIODEVICE, Node)
     389    PPDMAUDIOHOSTDEV pDev;
     390    RTListForEach(&pDevEnm->LstDevices, pDev, PDMAUDIOHOSTDEV, Node)
    391391    {
    392392        char *pszFlags = DrvAudioHlpAudDevFlagsToStrA(pDev->fFlags);
     
    397397        LogFunc(("  Input channels  = %RU8\n",           pDev->cMaxInputChannels));
    398398        LogFunc(("  Output channels = %RU8\n",           pDev->cMaxOutputChannels));
    399         LogFunc(("  cbExtra         = %RU32 bytes\n",    pDev->cbSelf - sizeof(PDMAUDIODEVICE)));
     399        LogFunc(("  cbExtra         = %RU32 bytes\n",    pDev->cbSelf - sizeof(PDMAUDIOHOSTDEV)));
    400400
    401401        if (pszFlags)
     
    409409 * @returns Stringified audio flags. Must be free'd with RTStrFree().
    410410 *          NULL if no flags set.
    411  * @param   fFlags      Audio flags (PDMAUDIODEV_FLAGS_XXX) to convert.
     411 * @param   fFlags      Audio flags (PDMAUDIOHOSTDEV_F_XXX) to convert.
    412412 */
    413413char *DrvAudioHlpAudDevFlagsToStrA(uint32_t fFlags)
    414414{
    415415#define APPEND_FLAG_TO_STR(_aFlag)              \
    416     if (fFlags & PDMAUDIODEV_FLAGS_##_aFlag)    \
     416    if (fFlags & PDMAUDIOHOSTDEV_F_##_aFlag)    \
    417417    {                                           \
    418418        if (pszFlags)                           \
  • trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp

    r88044 r88045  
    7373{
    7474    /** The core PDM structure. */
    75     PDMAUDIODEVICE      Core;
     75    PDMAUDIOHOSTDEV      Core;
    7676
    7777    /** Pointer to driver instance this device is bound to. */
     
    561561            /* Is the device the default device? */
    562562            if (curDevID == defaultDeviceID)
    563                 pDev->Core.fFlags |= PDMAUDIODEV_FLAGS_DEFAULT;
     563                pDev->Core.fFlags |= PDMAUDIOHOSTDEV_F_DEFAULT;
    564564
    565565            AudioObjectPropertyAddress propAddrCfg = { kAudioDevicePropertyStreamConfiguration,
     
    643643                && !uAlive)
    644644            {
    645                 pDev->Core.fFlags |= PDMAUDIODEV_FLAGS_DEAD;
     645                pDev->Core.fFlags |= PDMAUDIOHOSTDEV_F_DEAD;
    646646            }
    647647
     
    657657                && (pid != -1))
    658658            {
    659                 pDev->Core.fFlags |= PDMAUDIODEV_FLAGS_LOCKED;
     659                pDev->Core.fFlags |= PDMAUDIOHOSTDEV_F_LOCKED;
    660660            }
    661661
     
    757757
    758758                /* Handle flags. */
    759                 if (pDevSrcIn->Core.fFlags & PDMAUDIODEV_FLAGS_DEFAULT)
    760                     pDevDst->Core.fFlags |= PDMAUDIODEV_FLAGS_DEFAULT;
     759                if (pDevSrcIn->Core.fFlags & PDMAUDIOHOSTDEV_F_DEFAULT)
     760                    pDevDst->Core.fFlags |= PDMAUDIOHOSTDEV_F_DEFAULT;
    761761                /** @todo Handle hot plugging? */
    762762
     
    775775                        pDevDst->Core.cMaxOutputChannels = pDevSrcOut->Core.cMaxOutputChannels;
    776776
    777                         if (pDevSrcOut->Core.fFlags & PDMAUDIODEV_FLAGS_DEFAULT)
    778                             pDevDst->Core.fFlags |= PDMAUDIODEV_FLAGS_DEFAULT;
     777                        if (pDevSrcOut->Core.fFlags & PDMAUDIOHOSTDEV_F_DEFAULT)
     778                            pDevDst->Core.fFlags |= PDMAUDIOHOSTDEV_F_DEFAULT;
    779779                        break;
    780780                    }
     
    819819
    820820                    /* Handle flags. */
    821                     if (pDevSrcOut->Core.fFlags & PDMAUDIODEV_FLAGS_DEFAULT)
    822                         pDevDst->Core.fFlags |= PDMAUDIODEV_FLAGS_DEFAULT;
     821                    if (pDevSrcOut->Core.fFlags & PDMAUDIOHOSTDEV_F_DEFAULT)
     822                        pDevDst->Core.fFlags |= PDMAUDIOHOSTDEV_F_DEFAULT;
    823823                    /** @todo Handle hot plugging? */
    824824
     
    21802180            if (pDeviceEnum)
    21812181            {
    2182                 /* Return a copy with only PDMAUDIODEVICE, none of the extra bits in COREAUDIODEVICEDATA. */
     2182                /* Return a copy with only PDMAUDIOHOSTDEV, none of the extra bits in COREAUDIODEVICEDATA. */
    21832183                PDMAudioHostEnumInit(pDeviceEnum);
    21842184                rc = PDMAudioHostEnumCopy(pDeviceEnum, &pThis->Devices, PDMAUDIODIR_INVALID /*all*/, true /*fOnlyCoreData*/);
  • trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp

    r88044 r88045  
    185185typedef struct DSOUNDDEV
    186186{
    187     PDMAUDIODEVICE  Core;
     187    PDMAUDIOHOSTDEV  Core;
    188188    /** The GUID if handy. */
    189189    GUID            Guid;
     
    15921592
    15931593        if (pGUID == NULL)
    1594             pDev->Core.fFlags = PDMAUDIODEV_FLAGS_DEFAULT;
     1594            pDev->Core.fFlags = PDMAUDIOHOSTDEV_F_DEFAULT;
    15951595
    15961596        char *pszName;
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