เลเยอร์การแยกแยะฮาร์ดแวร์เสียง (HAL) ของ Android จะเชื่อมต่อ API ของเฟรมเวิร์กเฉพาะเสียงในระดับที่สูงขึ้นเข้ากับandroid.mediaโปรแกรมควบคุมและฮาร์ดแวร์เสียงพื้นฐาน HAL เสียงจะกำหนดอินเทอร์เฟซมาตรฐานที่บริการเสียงเรียกใช้ ต้องติดตั้งใช้งาน Audio HAL เพื่อให้ฮาร์ดแวร์เสียงทำงานได้อย่างถูกต้อง
หน้านี้จะกล่าวถึงภาพรวมของ Audio HAL รวมถึงให้รายละเอียดเกี่ยวกับ API และข้อกำหนดในการใช้งาน
อินเทอร์เฟซ HAL ของเสียง
ตั้งแต่ Android 14 เป็นต้นไป อินเทอร์เฟซ HAL ของเสียงจะกำหนดโดยใช้ AIDL สำหรับเวอร์ชันที่ผ่านมา อินเทอร์เฟซ HAL ของเสียงจะกำหนดโดยใช้ HIDL
เราขอแนะนำให้พาร์ทเนอร์และผู้จำหน่าย SoC ใช้ Audio HAL อีกครั้งเพื่อให้อินเทอร์เฟซ AIDL
HAL API ใหม่สำหรับฟีเจอร์ที่เพิ่มใน Android 14 ขึ้นไปจะรองรับเฉพาะการใช้งานอินเทอร์เฟซ AIDL
ตั้งแต่ Android 14 เป็นต้นไป จะไม่มีการเพิ่ม API ใหม่ลงในการใช้งาน HIDL
การเปลี่ยนไปใช้ AIDL และการเลิกใช้งานและนำการรองรับ HAL เสียงเวอร์ชันหลักก่อนหน้าออกจะช่วยเพิ่มพื้นที่ว่างในดิสก์และ RAM ในอุปกรณ์ ซึ่งส่งผลให้ UX ราบรื่นขึ้นและช่วยให้ผู้ใช้ปลายทางเห็นฟีเจอร์ใหม่ๆ
Core HAL คือ API หลักที่ AudioFlinger ใช้เล่นเสียงและควบคุมการกำหนดเส้นทางเสียง
เฟรมเวิร์กเอฟเฟกต์ใช้ Effects HAL API เพื่อควบคุมเอฟเฟกต์เสียง
นอกจากนี้ คุณยังกำหนดค่าเอฟเฟกต์การประมวลผลก่อนการแปลงได้ เช่น การควบคุมระดับสัญญาณอัตโนมัติและการลดเสียงรบกวนผ่าน Effects HAL API
Common HAL API เป็นไลบรารีประเภทข้อมูลทั่วไปที่ Core และ Effects HAL API ใช้ HAL ทั่วไปไม่มีอินเทอร์เฟซและไม่มี VTS ที่เกี่ยวข้องเนื่องจากจะกำหนดเฉพาะโครงสร้างข้อมูลเท่านั้น
[[["เข้าใจง่าย","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-07-26 UTC"],[],[],null,["# Audio HAL\n\nAndroid's Audio hardware abstraction layer (HAL) connects the higher-level,\naudio-specific framework APIs into\n[`android.media`](http://developer.android.com/reference/android/media/package-summary.html)\nthe underlying audio drivers and hardware. The Audio HAL defines the standard\ninterface that audio services call in to. The Audio HAL must be implemented for\nthe audio hardware to function correctly.\n\nThis page gives an overview of the Audio HAL and provides details of its API and\nimplementation requirements.\n\nAudio HAL interface\n-------------------\n\nStarting with Android 14, the Audio HAL interface is\ndefined using [AIDL](/docs/core/audio/aidl-implement). For past versions, the\nAudio HAL interface is defined using [HIDL](/docs/core/audio/hidl-implement).\nPartners and SoC vendors are encouraged to reimplement their\nAudio HAL to provide an AIDL interface.\n\nNew HAL APIs for features added in Android 14 and\nhigher are supported **only** with the implementation of the AIDL interface.\nStarting with Android 14, no new API is added to the\nHIDL implementation.\n\nSwitching to AIDL and deprecating and removing support for previous\nmajor Audio HAL versions frees up disk space and RAM on devices. This\nleads to a smoother UX and allows for newer user-visible features for end users.\n\nSee [AIDL and HIDL Audio HAL comparison](/docs/core/audio/aidl-hidl-comp)\nfor more information about the differences between the AIDL and HIDL Audio HAL.\n\n### Audio HAL API\n\nThe Audio HAL contains the following APIs:\n\n- The Core HAL is the main API used by AudioFlinger to play audio and control the audio routing.\n- The Effects HAL API is used by the effects framework to control audio effects.\n You can also configure [preprocessing effects](/devices/audio/implement-pre-processing)\n such as automatic gain control and noise suppression through the Effects HAL\n API.\n\n | **Note:** The Audio Effects HAL API is similar to the [framework effects APIs](https://developer.android.com/reference/android/media/audiofx/AudioEffect).\n- The Common HAL API is a library of common data types used by the Core and\n Effects HAL APIs. The Common HAL has no interfaces and no associated VTS\n tests as it defines only data structures.\n\nSee [AIDL Audio HAL](/docs/core/audio/aidl-implement) and\n[HIDL Audio HAL](/docs/core/audio/hidl-implement) for specific details\nrelated to AIDL and HIDL respectively.\n| **Note:** Starting with Android 13, Audio HAL is updated to version 7.1.\n\nRequirements\n------------\n\nIn addition to implementing the Audio HAL and creating the audio policy\nconfiguration file, you must adhere to the following HAL requirements:\n\n- If capture for Sound Trigger (capture from hotword DSP buffer) is supported\n by one input profile, the implementation must support the number of active\n streams on this profile corresponding to the number of concurrent sessions\n supported by Sound Trigger HAL.\n\n | **Note:** The implementation of the [Sound trigger HAL](/docs/core/audio/sound-trigger) is located at `/hardware/interfaces/soundtrigger` and is coupled with the Audio HAL.\n- Concurrency of voice call TX and capture from the app processor as\n detailed on the [Concurrent capture](/docs/core/audio/concurrent) page."]]