VirtualBox

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


Ignore:
Timestamp:
Apr 5, 2021 12:15:13 AM (4 years ago)
Author:
vboxsync
Message:

DrvHostAudioCoreAudio: Converted to use PDMIAUDIONOTIFYFROMHOST. bugref:9890

File:
1 edited

Legend:

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

    r88358 r88360  
    108108    PCOREAUDIODEVICEDATA    pDefaultDevOut;
    109109#ifdef VBOX_WITH_AUDIO_CALLBACKS
    110     /** Callback function to the upper driver.
    111      *  Can be NULL if not being used / registered. */
    112     PFNPDMHOSTAUDIOCALLBACK pfnCallback;
     110    /** Upwards notification interface. */
     111    PPDMIAUDIONOTIFYFROMHOST pIAudioNotifyFromHost;
    113112#endif
    114113} DRVHOSTCOREAUDIO, *PDRVHOSTCOREAUDIO;
     
    10321031    }
    10331032
    1034 #ifdef VBOX_WITH_AUDIO_CALLBACKS
    1035     PFNPDMHOSTAUDIOCALLBACK pfnCallback = pThis->pfnCallback;
    1036 #endif
    1037 
    1038     /* Make sure to leave the critical section before calling the callback. */
     1033    /* Make sure to leave the critical section before notify higher drivers/devices. */
    10391034    rc2 = RTCritSectLeave(&pThis->CritSect);
    10401035    AssertRC(rc2);
    10411036
    10421037#ifdef VBOX_WITH_AUDIO_CALLBACKS
    1043     if (pfnCallback)
    1044         pfnCallback(pThis->pDrvIns, PDMAUDIOBACKENDCBTYPE_DEVICES_CHANGED, NULL, 0); /* Ignore rc */
     1038    /* Notify the driver/device above us about possible changes in devices. */
     1039    if (pThis->pIAudioNotifyFromHost)
     1040        pThis->pIAudioNotifyFromHost->pfnNotifyDevicesChanged(pThis->pIAudioNotifyFromHost);
    10451041#endif
    10461042
     
    22042200    return rc;
    22052201}
    2206 
    2207 
    2208 #ifdef VBOX_WITH_AUDIO_CALLBACKS
    2209 /**
    2210  * @interface_method_impl{PDMIHOSTAUDIO,pfnSetCallback}
    2211  */
    2212 static DECLCALLBACK(int) drvHostCoreAudioHA_SetCallback(PPDMIHOSTAUDIO pInterface, PFNPDMHOSTAUDIOCALLBACK pfnCallback)
    2213 {
    2214     AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    2215     /* pfnCallback will be handled below. */
    2216 
    2217     PDRVHOSTCOREAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTCOREAUDIO(pInterface);
    2218 
    2219     int rc = RTCritSectEnter(&pThis->CritSect);
    2220     if (RT_SUCCESS(rc))
    2221     {
    2222         LogFunc(("pfnCallback=%p\n", pfnCallback));
    2223 
    2224         if (pfnCallback) /* Register. */
    2225         {
    2226             Assert(pThis->pfnCallback == NULL);
    2227             pThis->pfnCallback = pfnCallback;
    2228         }
    2229         else /* Unregister. */
    2230         {
    2231             if (pThis->pfnCallback)
    2232                 pThis->pfnCallback = NULL;
    2233         }
    2234 
    2235         int rc2 = RTCritSectLeave(&pThis->CritSect);
    2236         AssertRC(rc2);
    2237     }
    2238 
    2239     return rc;
    2240 }
    2241 #endif
    22422202
    22432203
     
    26032563    pThis->IHostAudio.pfnStreamPlay         = drvHostCoreAudioHA_StreamPlay;
    26042564    pThis->IHostAudio.pfnStreamCapture      = drvHostCoreAudioHA_StreamCapture;
    2605 #ifdef VBOX_WITH_AUDIO_CALLBACKS
    2606     pThis->IHostAudio.pfnSetCallback        = drvHostCoreAudioHA_SetCallback;
    2607     pThis->pfnCallback                      = NULL;
    2608 #else
    26092565    pThis->IHostAudio.pfnSetCallback        = NULL;
    2610 #endif
    26112566    pThis->IHostAudio.pfnGetDevices         = drvHostCoreAudioHA_GetDevices;
    26122567    pThis->IHostAudio.pfnStreamGetPending   = NULL;
     
    26182573    int rc = RTCritSectInit(&pThis->CritSect);
    26192574    AssertRCReturn(rc, rc);
     2575
     2576#ifdef VBOX_WITH_AUDIO_CALLBACKS
     2577    /*
     2578     * Query the notification interface from the driver/device above us.
     2579     */
     2580    pThis->pIAudioNotifyFromHost = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIAUDIONOTIFYFROMHOST);
     2581    Assert(pThis->pIAudioNotifyFromHost);
     2582#endif
    26202583
    26212584#ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
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