Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release thay vì aosp-main để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Lớp trừu tượng phần cứng âm thanh (HAL) của Android kết nối các API khung cấp cao hơn, dành riêng cho âm thanh vào android.media, trình điều khiển và phần cứng âm thanh cơ bản. Audio HAL xác định giao diện tiêu chuẩn mà các dịch vụ âm thanh gọi đến. Bạn phải triển khai Audio HAL để phần cứng âm thanh hoạt động đúng cách.
Trang này cung cấp thông tin tổng quan về Audio HAL và cung cấp thông tin chi tiết về API cũng như các yêu cầu triển khai của API đó.
Giao diện Audio HAL
Kể từ Android 14, giao diện Audio HAL được xác định bằng AIDL. Đối với các phiên bản trước, giao diện Audio HAL được xác định bằng HIDL.
Đối tác và nhà cung cấp SoC nên triển khai lại HAL âm thanh để cung cấp giao diện AIDL.
Các API HAL mới cho các tính năng được thêm vào Android 14 trở lên chỉ được hỗ trợ khi triển khai giao diện AIDL.
Kể từ Android 14, không có API mới nào được thêm vào quá trình triển khai HIDL.
Việc chuyển sang AIDL, ngừng sử dụng và xoá tính năng hỗ trợ cho các phiên bản HAL âm thanh chính trước đó sẽ giải phóng dung lượng ổ đĩa và RAM trên thiết bị. Điều này dẫn đến trải nghiệm người dùng mượt mà hơn và cho phép người dùng cuối thấy các tính năng mới hơn.
Core HAL là API chính mà AudioFlinger sử dụng để phát âm thanh và điều khiển việc định tuyến âm thanh.
Khung hiệu ứng sử dụng API Effects HAL để kiểm soát hiệu ứng âm thanh.
Bạn cũng có thể định cấu hình các hiệu ứng xử lý trước như tự động điều khiển độ lợi và loại bỏ tạp âm thông qua API HAL hiệu ứng.
API HAL chung là một thư viện gồm các loại dữ liệu phổ biến mà API HAL Core và Effects sử dụng. HAL phổ biến không có giao diện và không có kiểm thử VTS liên kết vì chỉ xác định cấu trúc dữ liệu.
Hãy xem AIDL Audio HAL và HIDL Audio HAL để biết thông tin chi tiết cụ thể liên quan đến AIDL và HIDL tương ứng.
Yêu cầu
Ngoài việc triển khai Audio HAL và tạo tệp cấu hình chính sách âm thanh, bạn phải tuân thủ các yêu cầu sau đây về HAL:
Nếu một hồ sơ đầu vào hỗ trợ tính năng ghi âm cho tính năng Kích hoạt bằng âm thanh (ghi âm từ vùng đệm DSP của cụm từ kích hoạt), thì quá trình triển khai phải hỗ trợ số lượng luồng đang hoạt động trên hồ sơ này tương ứng với số lượng phiên đồng thời mà HAL Kích hoạt bằng âm thanh hỗ trợ.
Tính năng đồng thời của TX cuộc gọi thoại và tính năng ghi từ bộ xử lý ứng dụng như mô tả chi tiết trên trang Ghi đồng thời.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 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."]]