Android 14 には、アプリで USB オーディオ再生の優先されるミキサー属性のクエリと設定に使用できるデベロッパー向け API が用意されています。この優先されるミキサー属性を使うと、アプリでオーディオ形式、チャンネル マスク、サンプルレート、ミキサー動作を設定できるようになり、USB オーディオ再生エクスペリエンスが向上します。サポートされている USB デバイスで優先されるミキサー API を使用することによって、ユーザーは低レイテンシのオーディオ再生と高解像度のオーディオ コンテンツにアクセスできます。
また、この機能は USB デバイスでの最適なビットパーフェクトの再生ミキサー動作もサポートしています。ビットパーフェクト モードでは、互換性のあるデジタル-アナログ変換器(DAC)での Master Quality Authenticated(MQA)形式とダイレクト ストリーム デジタル(DSD)形式の再生が可能になります。
ビットパーフェクト再生属性はオプションで、オーディオ HAL の AIDL 実装でのみサポートされています。ビットパーフェクト再生をサポートするには、ベンダーはビットパーフェクト出力フラグの AUDIO_OUTPUT_FLAG_BIT_PERFECT を USB デバイスにルーティングされる動的なミックスポートに追加する必要があります。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-26 UTC。"],[],[],null,["# Preferred mixer attributes on USB devices\n\nAndroid 14 provides [developer APIs](https://developer.android.com/reference/android/media/AudioMixerAttributes)\nthat apps can use to query and configure preferred mixer attributes for USB\naudio playback. These [preferred mixer attributes](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android16-release/media/java/android/media/AudioMixerAttributes.java)\nimprove the USB audio playback experience by letting apps set the audio format,\nchannel mask, sample rate, and mixer behavior. With the use of the preferred\nmixer APIs on supported USB devices, users can get lower-latency audio playback\nand higher-resolution audio content.\n\nThis feature also provides support for the optional bit-perfect playback mixer\nbehavior for USB devices. The bit-perfect mode enables playback for master\nquality authenticated (MQA) and direct stream digital (DSD) formats on\ncompatible digital to analog converters (DACs).\n\nInterface\n---------\n\nThe Audio Policy Manager handles the mixer attributes in the framework. The\n[`AudioMixerAttributes`](https://developer.android.com/reference/android/media/AudioMixerAttributes)\nclass represents the mixer's attributes. The `AudioMixerAttributes` class includes an\n[`AudioFormat`](https://developer.android.com/reference/android/media/AudioFormat)\nobject that describes the audio data format, channel mask, and sample rate for\nthe mixer. By default, the framework determines the mixer behavior, which mixes\nall audio sources and applies volume control and effects.\n\nIf the mixer behavior uses `BIT_PERFECT` mode, the system sends the audio\ncontent without modification through the audio framework, HAL and optionally\ndigital signal processor (DSP), from the API down to the USB device. The\n`BIT_PERFECT` mode supports encoded formats, such as MQA or DSD, on which any\nvolume scaling or mixing can destroy the meaning of the data.\n\nWhen apps configure mixer attributes, the framework reopens the output stream\nwith new attributes, if needed. The following figure shows the interface between\nthe app, framework, and the HAL when mixer attributes are set:\n\n**Figure 1.** Interface between the app, framework, and HAL.\n\nImplementation\n--------------\n\nImplementation of preferred mixer attributes, other than the `BIT_PERFECT`\nattribute, for USB audio is mandatory for Android 14.\n\n### Preferred mixer attributes\n\nTo support preferred mixer attributes, vendors must support routing USB devices\nto the dynamic mix port, as follows:\n\n1. Define the dynamic mix port in [`usb_audio_policy_configuration.xml`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml).\n\n2. Declare the ability to route USB devices to dynamic mix ports either in\n [audio policy configuration](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/av/services/audiopolicy/config/audio_policy_configuration.xml)\n or in the [`getAudioPorts`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/audio/aidl/android/hardware/audio/core/IModule.aidl;drc=0abca2170b9e49c23f511ff1a6a99e5db8ab4104;l=267) and [`getAudioRoutes`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/audio/aidl/android/hardware/audio/core/IModule.aidl;drc=0abca2170b9e49c23f511ff1a6a99e5db8ab4104;l=279) AIDL methods.\n\n| **Note:** If the USB audio functionality is migrated to the primary HAL, define the dynamic mix port and USB audio routing in the [audio policy configuration](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/av/services/audiopolicy/config/audio_policy_configuration.xml) file for your primary HAL.\n\nSee the reference implementation for the USB audio HAL under [`hardware/libhardware/modules/usbaudio`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/libhardware/modules/usbaudio/).\nSee an example of a dynamic mix port in [`frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml).\n| **Note:** Only USB devices are allowed to set preferred mixer attributes.\n\n### Bit-perfect playback attribute\n\nThe bit-perfect playback attribute is optional and is supported only in the AIDL\nimplementation of the Audio HAL. To support bit-perfect playback, vendors must\nadd the bit-perfect output flag `AUDIO_OUTPUT_FLAG_BIT_PERFECT` to the dynamic\nmix port that can be routed to the USB device.\n\nThe following code sample shows the use of the `AUDIO_OUTPUT_FLAG_BIT_PERFECT`\nflag in `usb_audio_policy_configuration.xml`: \n\n \u003cmodule name=\"usb\" halVersion=\"2.0\"\u003e\n \u003cmixPorts\u003e\n \u003cmixPort name=\"hifi_output\"\n role=\"source\" flags=\"AUDIO_OUTPUT_FLAG_BIT_PERFECT\"\u003e\n \u003c/mixPort\u003e\n \u003c/mixPorts\u003e\n \u003cdevicePorts\u003e\n \u003cdevicePort tagName=\"USB Device Out\"\n type=\"AUDIO_DEVICE_OUT_USB_DEVICE\" role=\"sink\"\u003e\n \u003c/devicePort\u003e\n \u003c/devicePorts\u003e\n \u003croutes\u003e\n \u003croute type=\"mix\" sink=\"USB Device Out\"\n sources=\"hifi_output\"/\u003e\n \u003c/routes\u003e\n \u003c/module\u003e\n\nIf the bit-perfect playback attribute is specified, the HAL must ensure that the\naudio stream is sent to the USB device without any modification, that is, the\naudio stream must not have any volume scaling, sample rate conversion, or audio\nprocessing effects and must not be mixed in the DSP.\nIn this case, the hardware controls the volume as the framework doesn't provide\nany software volume control.\n| **Note:** Without the bit-perfect playback attribute, apps can't stream high-resolution content, such as DSD and MQA, through the audio framework.\n\nValidation\n----------\n\nRun the CTS tests in\n[`PreferredMixerAttributesTestActivity.java`](https://android.googlesource.com/platform/cts/+/refs/heads/android16-release/apps/CtsVerifier/src/com/android/cts/verifier/audio/PreferredMixerAttributesTestActivity.java)\nto validate support for preferred mixer attributes for USB devices.\n\nTo validate the implementation of the `BIT_PERFECT` attribute, use USB DACs that\nsupport MQA and DSD over pulse-code modulation (PCM) audio formats."]]