IAudioSessionControl2 인터페이스(audiopolicy.h)

IAudioSessionControl2 인터페이스는 클라이언트에서 오디오 세션에 대한 정보를 가져오는 데 사용할 수 있습니다.

IAudioSessionControl2 인터페이스에 대한 참조를 얻으려면 애플리케이션이 IAudioSessionControl::QueryInterface를 호출하여 스트림 개체의 IAudioSessionControl 인터페이스에서 인터페이스 포인터를 요청해야 합니다. 애플리케이션에서 IAudioSessionControl 인터페이스에 대한 포인터를 가져올 수 있는 두 가지 방법이 있습니다.

애플리케이션이 instance IAudioSessionControl2 인터페이스를 해제하려는 경우 애플리케이션은 개체를 만든 IAudioClient::GetService 호출과 동일한 스레드에서 인터페이스의 Release 메서드를 호출해야 합니다.

이 인터페이스를 사용하는 애플리케이션 스레드는 COM에 대해 초기화되어야 합니다. COM 초기화에 대한 자세한 내용은 Windows SDK 설명서의 CoInitializeEx 함수 설명을 참조하세요.

상속

IAudioSessionControl2 인터페이스는 IAudioSessionControl에서 상속됩니다. IAudioSessionControl2 에는 다음과 같은 유형의 멤버도 있습니다.

메서드

IAudioSessionControl2 인터페이스에는 이러한 메서드가 있습니다.

 
IAudioSessionControl2::GetProcessId

GetProcessId 메서드는 오디오 세션의 프로세스 식별자를 검색합니다.
IAudioSessionControl2::GetSessionIdentifier

GetSessionIdentifier 메서드는 오디오 세션 식별자를 검색합니다.
IAudioSessionControl2::GetSessionInstanceIdentifier

GetSessionInstanceIdentifier 메서드는 오디오 세션 instance 식별자를 검색합니다.
IAudioSessionControl2::IsSystemSoundsSession

IsSystemSoundsSession 메서드는 세션이 시스템 사운드 세션인지 여부를 나타냅니다.
IAudioSessionControl2::SetDuckingPreference

SetDuckingPreference 메서드는 시스템에서 제공하는 기본 스트림 감쇠 환경(자동 더킹)을 사용하거나 사용하지 않도록 설정합니다.

설명

이 인터페이스는 Windows 7의 새로운 기능인 스트림 감쇠 또는 더킹에 대한 사용자 지정 구현을 지원합니다. 미디어 스트림을 재생하는 애플리케이션은 기본 통신 디바이스에서 새 통신 스트림을 열 때 다르게 동작할 수 있습니다. 예를 들어 새 통신 스트림이 열려 있는 동안 원래 미디어 스트림을 일시 중지할 수 있습니다. 이 기능에 대한 자세한 내용은 기본 더킹 환경을 참조하세요.

애플리케이션은 이 인터페이스를 사용하여 다음 작업을 수행할 수 있습니다.

  • 시스템에서 제공하는 기본 스트림 감쇠 환경을 옵트아웃하도록 지정합니다.
  • 스트림과 연결된 오디오 세션 식별자를 가져옵니다. 알림 등록 중에 식별자가 필요합니다. 애플리케이션은 시스템에서 더킹 알림을 수신하기 위해 자신을 등록할 수 있습니다.
  • 오디오 세션과 연결된 스트림이 시스템 사운드인지 확인합니다.

예제

다음 예제 코드에서는 IAudioSessionControl2 인터페이스에 대한 참조를 얻고 해당 메서드를 호출하여 오디오 세션과 연결된 스트림이 시스템 사운드인지 여부를 확인하는 방법을 보여 줍니다.

HRESULT SetDuckingForSystemSounds()
{
 
    HRESULT hr = S_OK;
    
    IMMDevice* pDevice = NULL;
    IMMDeviceEnumerator* pEnumerator = NULL;
    IAudioSessionControl* pSessionControl = NULL;
    IAudioSessionControl2* pSessionControl2 = NULL;
    IAudioSessionManager* pSessionManager = NULL;

    CHECK_HR( hr = CoInitialize(NULL));

    // Create the device enumerator.
    CHECK_HR( hr = CoCreateInstance(
        __uuidof(MMDeviceEnumerator), 
        NULL, CLSCTX_ALL, 
        __uuidof(IMMDeviceEnumerator), 
        (void**)&pEnumerator));

    // Get the default audio device.
    CHECK_HR( hr = pEnumerator->GetDefaultAudioEndpoint(
                    eRender, eConsole, &pDevice));

    // Get the audio client.
    CHECK_HR( hr = pDevice->Activate(
        __uuidof(IID_IAudioSessionManager), CLSCTX_ALL,
        NULL, (void**)&pSessionManager));

    // Get a reference to the session manager.
    CHECK_HR( hr = pSessionManager->GetAudioSessionControl (GUID_NULL, FALSE, &pSessionControl));
    
    // Get the extended session control interface pointer.
    CHECK_HR( hr = pSessionControl->QueryInterface(
        __uuidof(IAudioSessionControl2), (void**) &pSessionControl2));

    // Check whether this is a system sound.
    CHECK_HR( hr = pSessionControl2->IsSystemSoundsSession());

    // If it is a system sound, opt out of the default
    // stream attenuation experience.
    CHECK_HR( hr = pSessionControl2->SetDuckingPreference(TRUE));

done:

    // Clean up.
    SAFE_RELEASE(pSessionControl2);
    SAFE_RELEASE(pSessionControl);
    SAFE_RELEASE(pEnumerator);
    SAFE_RELEASE(pDevice);


    return hr;
}

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows 7 [데스크톱 앱만 해당]
지원되는 최소 서버 Windows Server 2008 R2 [데스크톱 앱만 해당]
대상 플랫폼 Windows
헤더 audiopolicy.h

추가 정보

핵심 오디오 인터페이스

IAudioSessionControl

통신 디바이스 사용