> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CreateCaptureAudioStateMonitorForCategory

> CreateCaptureAudioStateMonitorForCategory

# CreateCaptureAudioStateMonitorForCategory

\[일부 정보는 상용 출시 전에 크게 변경될 수 있는 사전 출시 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 명시적이든 묵시적이든 어떠한 보증도 하지 않습니다.]

지정된 카테고리에 속한 모든 오디오 캡처 스트림의 오디오 레벨을 모니터링하는 [IAudioStateMonitor](/reference/audio/audiostatemonitor/interfaces/iaudiostatemonitor)의 새 인스턴스를 만듭니다.

## Syntax

```cpp theme={null}
HRESULT WINAPI CreateCaptureAudioStateMonitorForCategory(
  AUDIO_STREAM_CATEGORY category,
  _Out_ IAudioStateMonitor **audioStateMonitor
);
```

### Parameters

*category*\
Type: AUDIO\_STREAM\_CATEGORY

모니터링할 오디오 캡처 스트림의 카테고리를 지정하는 <a href="https://learn.microsoft.com/en-us/windows/desktop/api/audiosessiontypes/ne-audiosessiontypes-audio_stream_category" target="_blank">AUDIO\_STREAM\_CATEGORY</a> 열거형의 멤버입니다.

*audioStateMonitor* \[out]\
Type: IAudioStateMonitor\*\*

이 출력 매개변수에는 생성된 `IAudioStateMonitor` 객체가 채워집니다.

### Return value

Type: HRESULT

메서드가 성공하면 `S\_OK`를 반환합니다.

## Remarks

이 함수는 `AudioStateMonitor` 인스턴스를 생성하고 반환하는 함수들 중 하나입니다.

캡처 및 렌더링 스트림 각각에 대해 네 가지 변형이 있으며, 프로세스가 특정 역할에 대해 다음 중 하나를 수행할 수 있는지 결정합니다:

* 모든 카테고리의 오디오를 캡처 또는 렌더링
* 특정 카테고리의 오디오를 캡처 또는 렌더링
* 특정 카테고리의 오디오를 특정 엔드포인트로 캡처 또는 렌더링.\
  엔드포인트는 `MMDevice` ID(`IMMDevice::GetId()`를 사용하여 얻음)나 `SWD` ID(`Windows.Devices.Enumeration` 또는 `Windows.Media.Devices.MediaDevice`를 사용하여 얻음)로 지정할 수 있습니다.
* 특정 카테고리의 오디오를 기본 엔드포인트로 캡처 또는 렌더링

다음 시나리오를 고려해 보세요. 게임이 OS 정책에 의해 오디오가 음소거되지 않을 것이 확실할 때만 게임 내 GameChat 기능을 활성화하려고 합니다. 이를 위해 게임은 기본 통신 엔드포인트에서 [AudioCategory\_GameChat](https://learn.microsoft.com/windows/win32/api/audiosessiontypes/ne-audiosessiontypes-audio_stream_category) 스트림 카테고리에 대한 SoundLevel 알림에 등록합니다.

이 카테고리의 SoundLevel이 'Muted'로 설정되면 게임은 GameChat 세션을 중지합니다. SoundLevel이 다른 값으로 설정되면 게임은 GameChat 스트림을 활성화하도록 선택합니다.

다음 코드 예제는 이 시나리오에 적합한 `IAudioStateMonitor` 객체를 게임이 어떻게 만들 수 있는지 보여줍니다.

```cpp theme={null}
HRESULT RegisterForSoundLevelChanges() 
{ 
HRESULT hr = S_OK; 

// Create a new AudioStateMonitor for the GameChat category, if needed, and 
// register for callbacks. 
if (m_audioStateMonitor == nullptr) 
{ 
hr = CreateCaptureAudioStateMonitorForCategoryAndDeviceRole( 
AudioCategory_GameChat, ERole::eCommunications, 
g_audioStateMonitor.put()); 
if (SUCCEEDED(hr)) 
{ 
// Optional "context" parameter is not used in this example, 
// and is set to nullptr. 
hr = g_audioStateMonitor->RegisterCallback(OnAudioStateMonitorCallback, nullptr, &m_registration); 
} 
} 

if (FAILED(hr)) 
{ 
// g_audioStateMonitor is a smart pointer, so if an IAudioStateMonitor was 
// allocated, setting the smart pointer to null invokes the Release method 
// which will decrement its usage count and ensure that the object is properly 
// destroyed. 
g_audioStateMonitor = nullptr; 
} 
return hr; 
} 
```

## Requirements

**Header:** Audiostatemonitorapi.h

**Library:** Windows.Media.MediaControl.lib

**지원 플랫폼:** Windows, XBOX One 제품군 콘솔 및 XBOX Series 콘솔

## See also

[AUDIO\_STREAM\_CATEGORY](https://learn.microsoft.com/windows/win32/api/audiosessiontypes/ne-audiosessiontypes-audio_stream_category)

[WASAPI 소개](https://learn.microsoft.com/windows/desktop/CoreAudio/wasapi)

[WASAPI](/build/console-features/audio/overviews/wasapi-overview)


## Related topics

- [IAudioStateMonitor interface](/ko/reference/audio/audiostatemonitor/interfaces/iaudiostatemonitor.md)
- [AudioStateMonitor](/ko/reference/audio/audiostatemonitor/audiostatemonitor_members.md)
- [CreateCaptureAudioStateMonitorForCategoryAndDeviceId](/ko/reference/audio/audiostatemonitor/functions/createcaptureaudiostatemonitorforcategoryanddeviceid.md)
- [CreateCaptureAudioStateMonitorForCategoryAndDeviceRole](/ko/reference/audio/audiostatemonitor/functions/createcaptureaudiostatemonitorforcategoryanddevicerole.md)
- [CreateCaptureAudioStateMonitor](/ko/reference/audio/audiostatemonitor/functions/createcaptureaudiostatemonitor.md)
