החל מ-27 במרץ 2025, מומלץ להשתמש ב-android-latest-release
במקום ב-aosp-main
כדי ליצור תרומות ל-AOSP. מידע נוסף זמין במאמר שינויים ב-AOSP.
אודיו
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
שכבת האובייקטים המצומצמים לחומרה (HAL) של האודיו ב-Android מחברת את ממשקי ה-API ברמה גבוהה יותר של המסגרת הספציפית לאודיו ב-android.media למנהל האודיו ולחומרה הבסיסיים. הקטע הזה כולל הוראות הטמעה וטיפים לשיפור הביצועים.
ארכיטקטורת האודיו של Android מגדירה איך הפונקציונליות של האודיו מיושמת ומפנה לקוד המקור הרלוונטי שמעורב בהטמעה.
איור 1. ארכיטקטורת האודיו של Android
-
מסגרת אפליקציה
-
מסגרת האפליקציה כוללת את קוד האפליקציה, שמשתמש בממשקי ה-API של android.media כדי לבצע אינטראקציה עם חומרת האודיו. באופן פנימי, הקוד הזה קורא לכיתות ה-glue של JNI כדי לגשת לקוד המקורי שמתקשר עם חומרת האודיו.
-
JNI
-
קוד ה-JNI שמשויך ל-android.media קורא לקוד מקומי ברמה נמוכה יותר כדי לגשת לחומרה של האודיו. JNI נמצא ב-
frameworks/base/core/jni/
וב-frameworks/base/media/jni
.
-
מסגרת מקורית
-
המסגרת המקורית מספקת מקבילה מקורית לחבילה android.media, ומפעילה שרתים מרוצים של Binder IPC כדי לגשת לשירותים הספציפיים לאודיו של שרת המדיה.
קוד המסגרת המקומי נמצא ב-
frameworks/av/media/libmedia
.
-
Binder IPC
- Proxy של IPC ב-Binder מאפשרים תקשורת מעבר לגבולות התהליכים. שרתים proxy נמצאים ב-
frameworks/av/media/libmedia
ומתחילים באות 'I'.
-
שרת מדיה
-
שרת המדיה מכיל שירותי אודיו, שהם הקוד בפועל שמקיים אינטראקציה עם הטמעות ה-HAL. שרת המדיה נמצא ב-
frameworks/av/services/audioflinger
.
-
HAL
-
HAL מגדיר את הממשק הסטנדרטי שאליו שירותי האודיו קוראים, וחייבים להטמיע אותו כדי שחומרת האודיו תפעל כמו שצריך. פרטים נוספים זמינים בממשק HAL של אודיו ובתגובות בקובצי
*.hal
בספרייה של גרסת ה-HAL המתאימה.
-
מנהל ליבה
-
ממשק ה-HAL של האודיו יוצר אינטראקציה עם החומרה וההטמעה של HAL. אפשר להשתמש ב-Advanced Linux Sound Architecture (ALSA), ב-Open Sound System (OSS) או בנהג מותאם אישית (HAL הוא ניטרלי לנהגים).
הערה: אם אתם משתמשים ב-ALSA, מומלץ להשתמש ב-external/tinyalsa
בחלק של המשתמש בנהג בגלל הרישיון התואם שלו (הספרייה הרגילה במצב משתמש ברישיון GPL).
-
אודיו מקורי ל-Android שמבוסס על Open SL ES (לא מוצג)
-
ה-API הזה מוצג כחלק מ-Android NDK
ומצוי באותה רמת ארכיטקטורה כמו android.media.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","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-27 (שעון UTC)."],[],[],null,["# Audio\n\nAndroid's audio Hardware Abstraction Layer (HAL) connects the higher-level,\naudio-specific framework APIs in [android.media](http://developer.android.com/reference/android/media/package-summary.html) to the underlying audio driver and\nhardware. This section includes implementation instructions and tips for\nimproving performance.\n\n\nAndroid audio architecture defines how audio functionality is implemented and\npoints to the relevant source code involved in the implementation.\n\n\n**Figure 1.** Android audio architecture\n\n\nApplication framework\n:\n The application framework includes the app code, which uses the [android.media](http://developer.android.com/reference/android/media/package-summary.html) APIs to\n interact with audio hardware. Internally, this code calls corresponding JNI glue\n classes to access the native code that interacts with audio hardware.\n\n\nJNI\n:\n The JNI code associated with [android.media](http://developer.android.com/reference/android/media/package-summary.html) calls lower level native code to access audio\n hardware. JNI is located in `frameworks/base/core/jni/` and\n `frameworks/base/media/jni`.\n\n\nNative framework\n:\n The native framework provides a native equivalent to the [android.media](http://developer.android.com/reference/android/media/package-summary.html) package, calling\n Binder IPC proxies to access the audio-specific services of the media server.\n Native framework code is located in `frameworks/av/media/libmedia`.\n\n\nBinder IPC\n:\n Binder IPC proxies facilitate communication over process boundaries. Proxies are\n located in `frameworks/av/media/libmedia` and begin with the letter\n \"I\".\n\n\nMedia server\n:\n The media server contains audio services, which are the actual code that\n interacts with your HAL implementations. The media server is located in\n `frameworks/av/services/audioflinger`.\n\n\nHAL\n:\n The HAL defines the standard interface that audio services call into and that\n you must implement for your audio hardware to function correctly. For more details, refer to the [audio HAL\n interface](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/audio/) and comments in the `*.hal` files of the corresponding HAL version directory.\n\n\nKernel driver\n\n: The audio driver interacts with your hardware and HAL implementation. You can use Advanced Linux Sound Architecture (ALSA), Open Sound System (OSS), or a custom driver (HAL is driver-agnostic). **Note** : If you use ALSA, we recommend\n `external/tinyalsa` for the user portion of the driver because of its\n compatible licensing (the standard user-mode library is GPL-licensed).\n\n\nAndroid native audio based on Open SL ES *(not shown)*\n:\n This API is exposed as part of\n [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html)\n and is at the same architecture level as\n [android.media](http://developer.android.com/reference/android/media/package-summary.html)."]]