VirtualBox

Changeset 100874 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Aug 14, 2023 4:56:27 PM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158791
Message:

Audio/WAS: Make sure to invalidate the cached audio interfaces of the device entry configurations. This is needed when the audio interface becomes invalid on a host device switch. See comment for details. bugref:10503.

File:
1 edited

Legend:

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

    r99828 r100874  
    812812}
    813813
     814/**
     815 * Invalidates device cache entry configurations.
     816 *
     817 * @param   pThis       The WASAPI host audio driver instance data.
     818 * @param   pDevEntry   The device entry to invalidate.
     819 */
     820static void drvHostAudioWasCacheInvalidateDevEntryConfig(PDRVHOSTAUDIOWAS pThis, PDRVHOSTAUDIOWASCACHEDEV pDevEntry)
     821{
     822    RT_NOREF(pThis);
     823
     824    Log8Func(("Invalidating cache entry configurations: %p - '%ls'\n", pDevEntry, pDevEntry->wszDevId));
     825
     826    PDRVHOSTAUDIOWASCACHEDEVCFG pDevCfg, pDevCfgNext;
     827    RTListForEachSafe(&pDevEntry->ConfigList, pDevCfg, pDevCfgNext, DRVHOSTAUDIOWASCACHEDEVCFG, ListEntry)
     828        pDevCfg->pIAudioClient = NULL;
     829}
    814830
    815831/**
     
    12241240         * The cache has two levels, so first the device entry.
    12251241         */
    1226         PDRVHOSTAUDIOWASCACHEDEV pDevEntry;
     1242        PDRVHOSTAUDIOWASCACHEDEV pDevEntry, pDevEntryNext;
    12271243        RTCritSectEnter(&pThis->CritSectCache);
    1228         RTListForEach(&pThis->CacheHead, pDevEntry, DRVHOSTAUDIOWASCACHEDEV, ListEntry)
     1244        RTListForEachSafe(&pThis->CacheHead, pDevEntry, pDevEntryNext, DRVHOSTAUDIOWASCACHEDEV, ListEntry)
    12291245        {
    12301246            if (   pDevEntry->cwcDevId == cwcDevId
     
    12321248                && RTUtf16Cmp(pDevEntry->wszDevId, pwszDevId) == 0)
    12331249            {
     1250                /*
     1251                 * Cache hit -- here we now need to also check if the device interface we want to look up
     1252                 * actually matches the one we have in the cache entry.
     1253                 *
     1254                 * If it doesn't, invalidate + remove the cache entry from the cache and bail out.
     1255                 * Add a new device entry to the cache with the new interface below then.
     1256                 *
     1257                 * This is needed when switching audio interfaces and the device interface becomes invalid via
     1258                 * AUDCLNT_E_DEVICE_INVALIDATED.  See @bugref{10503}
     1259                 */
     1260                if (pIDevice != pDevEntry->pIDevice)
     1261                {
     1262                    Log2Func(("Cache hit for device '%ls': Stale interface (new: %p, old: %p)\n",
     1263                              pDevEntry->wszDevId, pIDevice, pDevEntry->pIDevice));
     1264
     1265                    drvHostAudioWasCacheInvalidateDevEntryConfig(pThis, pDevEntry);
     1266                    RTListNodeRemove(&pDevEntry->ListEntry);
     1267                    drvHostAudioWasCacheDestroyDevEntry(pThis, pDevEntry);
     1268                    pDevEntry = NULL;
     1269                    break;
     1270                }
     1271
    12341272                CoTaskMemFree(pwszDevId);
    12351273                Log8Func(("Cache hit for device '%ls': %p\n", pDevEntry->wszDevId, pDevEntry));
     
    12381276        }
    12391277        RTCritSectLeave(&pThis->CritSectCache);
     1278
     1279        Log8Func(("Cache miss for device '%ls': %p\n", pDevEntry->wszDevId, pDevEntry));
    12401280
    12411281        /*
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