> ## 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.

# XUserDefaultAudioEndpointKind

> XUserDefaultAudioEndpointKind

# XUserDefaultAudioEndpointKind

ユーザーの既定のオーディオ エンドポイントがオーディオをレンダリングするか、キャプチャするかを指定します。

## 構文

```cpp theme={null}
enum class XUserDefaultAudioEndpointKind  : uint32_t  
{  
    CommunicationRender = 0,  
    CommunicationCapture = 1  
}  
```

## 定数

| 定数                   | 説明                                     |
| -------------------- | -------------------------------------- |
| CommunicationRender  | ユーザーの既定のオーディオ エンドポイントがオーディオをレンダリングします。 |
| CommunicationCapture | ユーザーの既定のオーディオ エンドポイントがオーディオをキャプチャします。  |

## 解説

[XUserGetDefaultAudioEndpointUtf16](/reference/system/xuser/functions/xusergetdefaultaudioendpointutf16) 関数は、XUserDefaultAudioEndpointKind 列挙型の引数を使用して、ユーザーの既定のオーディオ エンドポイントを取得します。
[XUserDefaultAudioEndpointUtf16ChangedCallback](/reference/system/xuser/functions/xuserdefaultaudioendpointutf16changedcallback) 関数は、XUserDefaultAudioEndpointKind 列挙型の引数を受け取り、ユーザーの既定のオーディオ エンドポイントが変更されたときに呼び出されます。

次の例では、ユーザーの既定のオーディオ エンドポイントを取得する方法を示します。

```cpp theme={null}
HRESULT GetAudioDeviceAssociation(
    IMMDeviceEnumerator* audioDeviceEnumerator,
    XUserLocalId user,
    XUserDefaultAudioEndpointKind defaultAudioEndpointKind,
    _Outptr_result_maybenull_ IMMDevice** endpoint)
{
    wchar_t audioDeviceId[XUserAudioEndpointMaxUtf16Count];
    RETURN_IF_FAILED_WITH_EXPECTED(XUserGetDefaultAudioEndpointUtf16(user, defaultAudioEndpointKind, std::size(audioDeviceId), audioDeviceId, nullptr), E_NOTFOUND);

    return audioDeviceEnumerator->GetDevice(audioDeviceId, endpoint);
}

HRESULT GetAudioAssociations()
{
    Mwrl::ComPtr<IMMDeviceEnumerator> audioDeviceEnumerator;

    RETURN_IF_FAILED(CoCreateInstance(
        __uuidof(MMDeviceEnumerator),
        nullptr,
        CLSCTX_ALL,
        __uuidof(IMMDeviceEnumerator),
        (void**)&audioDeviceEnumerator));

    XUserLocalId userLocalId;
    RETURN_IF_FAILED(XUserGetLocalId(_handle.get(), &userLocalId));

    {
        wil::unique_cotaskmem_string id;
        Mwrl::ComPtr<IMMDevice> device;
        if (SUCCEEDED(GetAudioDeviceAssociation(audioDeviceEnumerator.Get(), userLocalId, XUserDefaultAudioEndpointKind::CommunicationRender, &device)))
        {
            RETURN_IF_FAILED(device->GetId(&id));
        }
        appLog.AddLog("Preferred render communication device id: %S\n", id.get());
    }

    {
        wil::unique_cotaskmem_string id;
        Mwrl::ComPtr<IMMDevice> device;
        if (SUCCEEDED(GetAudioDeviceAssociation(audioDeviceEnumerator.Get(), userLocalId, XUserDefaultAudioEndpointKind::CommunicationCapture, &device)))
        {
            RETURN_IF_FAILED(device->GetId(&id));
        }
        appLog.AddLog("Preferred capture communication device id: %S\n", id.get());
    }

    return S_OK;
}
```

## 要件

**ヘッダー:** XUser.h

**サポートされているプラットフォーム:** Windows、XBOX One 本体、XBOX Series 本体

## 関連項目

[XUser](/reference/system/xuser/xuser_members)

[XUserGetDefaultAudioEndpointUtf16](/reference/system/xuser/functions/xusergetdefaultaudioendpointutf16)

[XUserDefaultAudioEndpointUtf16ChangedCallback](/reference/system/xuser/functions/xuserdefaultaudioendpointutf16changedcallback)


## Related topics

- [XUserDefaultAudioEndpointUtf16ChangedCallback](/ja-jp/reference/system/xuser/functions/xuserdefaultaudioendpointutf16changedcallback.md)
- [XUserGetDefaultAudioEndpointUtf16](/ja-jp/reference/system/xuser/functions/xusergetdefaultaudioendpointutf16.md)
- [XUser](/ja-jp/reference/system/xuser/xuser_members.md)
- [XUserUnregisterForDefaultAudioEndpointUtf16Changed](/ja-jp/reference/system/xuser/functions/xuserunregisterfordefaultaudioendpointutf16changed.md)
- [XUserRegisterForDefaultAudioEndpointUtf16Changed](/ja-jp/reference/system/xuser/functions/xuserregisterfordefaultaudioendpointutf16changed.md)
