VirtualBox

Changeset 83238 in vbox


Ignore:
Timestamp:
Mar 10, 2020 9:57:28 AM (5 years ago)
Author:
vboxsync
Message:

Audio/Win: Also re-enumerate if the default device has been changed. More logging for the IMMNotificationClient interface.

Location:
trunk/src/VBox/Devices/Audio
Files:
2 edited

Legend:

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

    r82968 r83238  
    126126
    127127/**
    128  * Handler implementation which is called when an audio device state
    129  * has been changed.
    130  *
    131  * @return  HRESULT
    132  * @param   pwstrDeviceId       Device ID the state is announced for.
    133  * @param   dwNewState          New state the device is now in.
    134  */
    135 STDMETHODIMP VBoxMMNotificationClient::OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState)
    136 {
    137     char *pszState = "unknown";
    138 
    139     switch (dwNewState)
    140     {
    141         case DEVICE_STATE_ACTIVE:
    142             pszState = "active";
    143             break;
    144         case DEVICE_STATE_DISABLED:
    145             pszState = "disabled";
    146             break;
    147         case DEVICE_STATE_NOTPRESENT:
    148             pszState = "not present";
    149             break;
    150         case DEVICE_STATE_UNPLUGGED:
    151             pszState = "unplugged";
    152             break;
    153         default:
    154             break;
    155     }
    156 
    157     LogRel2(("Audio: Device '%ls' has changed state to '%s'\n", pwstrDeviceId, pszState));
    158 
     128 * Helper function for invoking the audio connector callback (if any).
     129 */
     130void VBoxMMNotificationClient::doCallback(void)
     131{
    159132#ifdef VBOX_WITH_AUDIO_CALLBACKS
    160133    AssertPtr(this->m_pDrvIns);
     
    164137        /* Ignore rc */ this->m_pfnCallback(this->m_pDrvIns, PDMAUDIOBACKENDCBTYPE_DEVICES_CHANGED, NULL, 0);
    165138#endif
     139}
     140
     141/**
     142 * Handler implementation which is called when an audio device state
     143 * has been changed.
     144 *
     145 * @return  HRESULT
     146 * @param   pwstrDeviceId       Device ID the state is announced for.
     147 * @param   dwNewState          New state the device is now in.
     148 */
     149STDMETHODIMP VBoxMMNotificationClient::OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState)
     150{
     151    char *pszState = "unknown";
     152
     153    switch (dwNewState)
     154    {
     155        case DEVICE_STATE_ACTIVE:
     156            pszState = "active";
     157            break;
     158        case DEVICE_STATE_DISABLED:
     159            pszState = "disabled";
     160            break;
     161        case DEVICE_STATE_NOTPRESENT:
     162            pszState = "not present";
     163            break;
     164        case DEVICE_STATE_UNPLUGGED:
     165            pszState = "unplugged";
     166            break;
     167        default:
     168            break;
     169    }
     170
     171    LogRel(("Audio: Device '%ls' has changed state to '%s'\n", pwstrDeviceId, pszState));
     172
     173    doCallback();
    166174
    167175    return S_OK;
     
    176184STDMETHODIMP VBoxMMNotificationClient::OnDeviceAdded(LPCWSTR pwstrDeviceId)
    177185{
    178     RT_NOREF(pwstrDeviceId);
    179     LogFunc(("%ls\n", pwstrDeviceId));
     186    LogRel(("Audio: Device '%ls' has been added\n", pwstrDeviceId));
     187
    180188    return S_OK;
    181189}
     
    189197STDMETHODIMP VBoxMMNotificationClient::OnDeviceRemoved(LPCWSTR pwstrDeviceId)
    190198{
    191     RT_NOREF(pwstrDeviceId);
    192     LogFunc(("%ls\n", pwstrDeviceId));
     199    LogRel(("Audio: Device '%ls' has been removed\n", pwstrDeviceId));
     200
    193201    return S_OK;
    194202}
     
    205213STDMETHODIMP VBoxMMNotificationClient::OnDefaultDeviceChanged(EDataFlow eFlow, ERole eRole, LPCWSTR pwstrDefaultDeviceId)
    206214{
    207     RT_NOREF(eFlow, eRole, pwstrDefaultDeviceId);
     215    RT_NOREF(eRole);
     216
     217    char *pszRole = "unknown";
    208218
    209219    if (eFlow == eRender)
    210     {
    211 
    212     }
     220        pszRole = "output";
     221    else if (eFlow == eCapture)
     222        pszRole = "input";
     223
     224    LogRel(("Audio: Default %s device has been changed to '%ls'\n", pszRole, pwstrDefaultDeviceId));
     225
     226    doCallback();
    213227
    214228    return S_OK;
  • trunk/src/VBox/Devices/Audio/VBoxMMNotificationClient.h

    r82968 r83238  
    7070    void    DetachFromEndpoint();
    7171
     72    void    doCallback(void);
     73
    7274    /** @name IMMNotificationClient interface
    7375     * @{ */
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