VirtualBox

Changeset 89220 in vbox


Ignore:
Timestamp:
May 21, 2021 12:16:52 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144562
Message:

DrvHostAudioCoreAudio: Removed PCOREAUDIODEVICEDATA from the stream as we only need it during construction (and then only the UID) and would risk having a stale pointer if enumeration was re-triggered (harmless, as it was never used). bugref:9890

File:
1 edited

Legend:

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

    r89213 r89220  
    167167    PCOREAUDIOBUF               paBuffers;
    168168
    169     /** The audio unit for this stream. */
    170     struct
    171     {
    172         /** Pointer to the device this audio unit is bound to.
    173          *  Can be NULL if not bound to a device (anymore). */
    174         PCOREAUDIODEVICEDATA    pDevice;
    175 #if 0 /* not used */
    176         /** The actual audio unit object. */
    177         AudioUnit                   hAudioUnit;
    178         /** Stream description for using with VBox:
    179          *  - When using this audio unit for input (capturing), this format states
    180          *    the unit's output format.
    181          *  - When using this audio unit for output (playback), this format states
    182          *    the unit's input format. */
    183         AudioStreamBasicDescription StreamFmt;
    184 #endif
    185     } Unit;
    186169    /** Initialization status tracker, actually COREAUDIOINITSTATE.
    187170     * Used when some of the device parameters or the device itself is changed
     
    14591442     * Do we have a device for the requested stream direction?
    14601443     */
    1461     PCOREAUDIODEVICEDATA pDev = pCfgReq->enmDir == PDMAUDIODIR_IN ? pThis->pDefaultDevIn : pThis->pDefaultDevOut;
     1444    RTCritSectEnter(&pThis->CritSect);
     1445    CFStringRef hDevUidStr = NULL;
     1446    {
     1447        PCOREAUDIODEVICEDATA pDev = pCfgReq->enmDir == PDMAUDIODIR_IN ? pThis->pDefaultDevIn : pThis->pDefaultDevOut;
     1448        if (pDev)
     1449        {
     1450            Assert(pDev->Core.cbSelf == sizeof(*pDev));
     1451            hDevUidStr = pDev->UUID;
     1452            CFRetain(pDev->UUID);
     1453        }
     1454    }
     1455    RTCritSectLeave(&pThis->CritSect);
     1456
    14621457#ifdef LOG_ENABLED
    14631458    char szTmp[PDMAUDIOSTRMCFGTOSTRING_MAX];
    14641459#endif
    1465     LogFunc(("pDev=%p *pCfgReq: %s\n", pDev, PDMAudioStrmCfgToString(pCfgReq, szTmp, sizeof(szTmp)) ));
    1466     if (pDev)
    1467     {
    1468         Assert(pDev->Core.cbSelf == sizeof(*pDev));
    1469 
     1460    LogFunc(("hDevUidStr=%p *pCfgReq: %s\n", hDevUidStr, PDMAudioStrmCfgToString(pCfgReq, szTmp, sizeof(szTmp)) ));
     1461    if (hDevUidStr)
     1462    {
    14701463        /*
    14711464         * Basic structure init.
     
    14771470        pStreamCA->offInternal      = 0;
    14781471        pStreamCA->idxBuffer        = 0;
    1479         pStreamCA->Unit.pDevice     = pDev;   /** @todo r=bird: How do we protect this against enumeration releasing pDefaultDevOut/In. */
    14801472        pStreamCA->enmInitState     = COREAUDIOINITSTATE_IN_INIT;
    14811473
     
    15191511                 * Assign device to the queue.
    15201512                 */
    1521                 UInt32 uSize = sizeof(pDev->UUID);
    1522                 orc = AudioQueueSetProperty(pStreamCA->hAudioQueue, kAudioQueueProperty_CurrentDevice, &pDev->UUID, uSize);
     1513                UInt32 uSize = sizeof(hDevUidStr);
     1514                orc = AudioQueueSetProperty(pStreamCA->hAudioQueue, kAudioQueueProperty_CurrentDevice, &hDevUidStr, uSize);
    15231515                LogFlowFunc(("AudioQueueSetProperty -> %#x\n", orc));
    15241516                if (orc == noErr)
     
    16101602
    16111603                            LogFunc(("returns VINF_SUCCESS\n"));
     1604                            CFRelease(hDevUidStr);
    16121605                            return VINF_SUCCESS;
    16131606                        }
     1607
    16141608                        RTMemFree(pStreamCA->paBuffers);
    16151609                    }
     
    16271621        else
    16281622            LogRel(("CoreAudio: Failed to initialize critical section for stream: %Rrc\n", rc));
     1623        CFRelease(hDevUidStr);
    16291624    }
    16301625    else
     
    17351730
    17361731        /*
    1737          * Release the device and delete the critsect.
     1732         * Delete the critsect and we're done.
    17381733         */
    1739         pStreamCA->Unit.pDevice = NULL; /** @todo This bugger must be refcounted! */
    1740 
    17411734        RTCritSectDelete(&pStreamCA->CritSect);
    17421735
    1743         /*
    1744          * Done.
    1745          */
    17461736        ASMAtomicWriteU32(&pStreamCA->enmInitState, COREAUDIOINITSTATE_UNINIT);
    17471737    }
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