// ----------------------------------------------------------------------
//  Initialize this object.  Call after constructor.
//
// ----------------------------------------------------------------------
HRESULT CVolumeMonitor::Initialize()
{
    HRESULT hr;

    // create enumerator
    hr = m_spEnumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
    if (SUCCEEDED(hr))
    {
        hr = m_spEnumerator->RegisterEndpointNotificationCallback(this);
        if (SUCCEEDED(hr))
        {
            hr = AttachToDefaultEndpoint();
        }
    }

    return hr;
}
Ejemplo n.º 2
0
// ----------------------------------------------------------------------
//  Initialize this object.  Call after constructor.
//
// ----------------------------------------------------------------------
HRESULT AudioVolume::Initialize()
{
    TRACE("AudioVolume::Initialize Enters\n");
    HRESULT hr;

    // create enumerator
    hr = m_spEnumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
    if (SUCCEEDED(hr))
    {
        hr = m_spEnumerator->RegisterEndpointNotificationCallback(this);
        if (SUCCEEDED(hr))
        {
            m_bRegisteredForEndpointNotifications = TRUE;
            hr = AttachToDefaultEndpoint();
        }
    }

    return hr;
}
// ----------------------------------------------------------------------
//  Call this from the UI thread when the default device changes
//
// ----------------------------------------------------------------------
void CVolumeMonitor::ChangeEndpoint()
{
    DetachFromEndpoint();

    AttachToDefaultEndpoint();
}