当前位置:   article > 正文

Android CarAudio

android caraudio

一、CarAudio介绍

Android Automotive OS (AAOS) 是在核心 Android 音频堆栈的基础之上打造而成,以支持用作车辆信息娱乐系统的用例。AAOS 负责实现信息娱乐声音(即媒体、导航和通讯声音),但不直接负责具有严格可用性和计时要求的铃声和警告。虽然 AAOS 提供了信号和机制来帮助车辆管理音频,但最终还是由车辆来决定应为驾驶员和乘客播放什么声音,从而确保对保障安全至关重要的声音和监管声音能被确切听到,而不会中断。

当 Android 管理车辆的媒体体验时,应通过应用来代表外部媒体来源(例如电台调谐器),这类应用可以处理该来源的音频焦点和媒体键事件。

汽车音频系统可以处理以下声音和声音流:

二、CarAudio相关接口

ICarVolumeCallback

Binder interface to callback the volume key events.

用于回调音量键事件的绑定程序接口。

ICarVolumeCallback代码位于:

packages/services/Car/service/src/com/android/car/audio/ICarVolumeCallback.aidl

ICarVolumeCallback的定义:

  1. interface ICarVolumeCallback {
  2. void onGroupVolumeChanged(int zoneId, int groupId, int flags);
  3. void onGroupMuteChanged(int zoneId, int groupId, int flags);
  4. void onMasterMuteChanged(int zoneId, int flags);
  5. }

AudioControlWrapper

AudioControlWrapper wraps IAudioControl HAL interface, handling version specific support so that the rest of CarAudioService doesn't need to know about it.

AudioControlWrapper包装了IAudioControl HAL接口,处理特定于版本的支持,因此CarAudioService的其余部分不需要知道它。

AudioControlWrapper代码位于:

packages/services/Car/service/src/com/android/car/audio/hal/AudioControlWrapper.java

AudioControlWrapper的定义:

public interface AudioControlWrapper {}

AudioControlWrapper方法:

  1. void unregisterFocusListener():关闭在音频控制 HAL 上注册的焦点侦听器。
  2. boolean supportsFeature(@AudioControlFeature int feature):指示 HAL 是否可以支持指定的功能。
  3. void registerFocusListener(HalFocusListener focusListener):向 IAudioControl 注册 HAL 音频焦点请求的侦听器。
  4. void registerAudioGainCallback(@NonNull HalAudioGainCallback gainCallback):使用 IAudioControl 注册 HAL 音频增益更改通知的回调。
  5. void unregisterAudioGainCallback():关闭在音频控制 HAL 上注册的音频增益回调。
  6. void onAudioFocusChange(@AttributeUsage int usage, int zoneId, int focusChange):通知 HAL 已发出的请求的音频焦点更改。
  7. void dump(IndentingPrintWriter writer):dumps the current state of the AudioControlWrapper
  8. void setFadeTowardFront(float value):Sets the fade for the vehicle.
  9. void setBalanceTowardRight(float value):Sets the balance value for the vehicle.
  10. void onDevicesToDuckChange(@NonNull List<CarDuckingInfo> carDuckingInfos):Notifies HAL of changes in usages holding focus and the corresponding ducking changes for a given zone.
  11. void onDevicesToMuteChange(@NonNull List<MutingInfo> carZonesMutingInfo):Notifies HAL of changes in muting changes for all audio zones.
  12. void linkToDeath(@Nullable AudioControlDeathRecipient deathRecipient):Registers recipient to be notified if AudioControl HAL service dies.
  13. void unlinkToDeath():Unregisters recipient for AudioControl HAL service death.

HalFocusListener

Framework focus listener interface to abstract away the specific HAL version

Framework 焦点侦听器接口,用于抽象出特定的 HAL 版本。

HalFocusListener代码位于:

packages/services/Car/service/src/com/android/car/audio/hal/HalFocusListener.java

HalFocusListener的定义:

  1. public interface HalFocusListener{
  2. void requestAudioFocus(@AttributeUsage int usage, int zoneId, int focusGain);
  3. void abandonAudioFocus(@AttributeUsage int usage, int zoneId);
  4. }

三、CarAudio相关类

CarAudioManager

CarAudioManager是Android Automotive OS中提供的一个与车载音频相关的管理类,用于管理应用程序与车载音频的交互,CarAudioManager扩展了AudioManager的功能,同时增加了一些针对车载音频使用场景的特殊功能。

CarAudioManager代码位于:

packages/services/Car/car-lib/src/android/car/media/CarAudioManager.java

CarAudioManager的定义:

public final class CarAudioManager implements CarManagerBase {}

AudioManagerHelper

AudioManagerHelper 代码位于:

packages/services/Car/car-builtin-lib/src/android/car/builtin/media/AudioManagerHelper.Java

AudioManagerHelper 的定义:

public final class AudioManagerHelper {}

CarAudioSettings

CarAudioSettings在Automotive OS系统中用于管理车载音频设置,其主要功能是控制车载系统的音量设置,以及配置提升和通知的音频设置。

CarAudioSettings代码位于:

packages/services/Car/car-lib/src/android/car/audio/CarAudioSettings.java

CarAudioSettings的定义:

public class CarAudioSettings {}

CarAudioService

CarAudioService是Android Automotive OS系统中提供的一个服务,类似于AudioService,它管理整个车载音频系统,包括音频路由控制、音频设备管理、音量控制、焦点管理、车载媒体播放管理等。CarAudioService提供了对车辆音频系统功能和状态的控制,为车载音频应用提供便利,并支持多个应用程序同时执行音频任务。

CarAudioService代码位于:

packages/services/Car/service/src/com/android/car/audio/audioCarAudioService.java

CarAudioService的定义:

public class CarAudioService extends ICarAudio.Stub implements CarServiceBase {}

CarAudioContext

CarAudioContext在Android Automotive OS系统中用于管理车载音频场景相关的设置。在Android Auto中,可以通过它来管理不同的音频场景,例如导航、车载电话、媒体等,CarAudioContext包含的音频场景如下:

static final int MUSIC = 1:Music playback

static final int NAVIGATION = 2:Navigation directions

static final int VOICE_COMMAND = 3:Voice command session

static final int CALL_RING = 4:Voice call ringing

static final int CALL = 5:Voice call

static final int ALARM = 6:Alarm sound from Android

static final int NOTIFICATION = 7:Notifications

static final int SYSTEM_SOUND = 8:System sounds

static final int EMERGENCY = 9:Emergency related sounds such as collision warnings

static final int SAFETY = 10:Safety sounds such as obstacle detection when backing up or when changing lanes

static final int VEHICLE_STATUS = 11:Vehicle Status related sounds such as check engine light or seat belt chimes

static final int ANNOUNCEMENT = 12:Announcement such as traffic announcements

CarAudioContext代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioContext.java

CarAudioContext的定义:

public final class CarAudioContext {}

CarVolume

CarVolume在Android Automotive OS系统中用于管理车载音量设置。在Android Auto中,可以通过它来控制车载音量,包括媒体音频、通话音量、通知音量等。同时,CarVolume还提供了一组API,用于处理车辆速度和声音关联的特殊需求。

CarVolume代码位于:

packages/services/Car/service/src/com/android/car/audio/CarVolume.java

CarVolume的定义:

final class CarVolume {}

CarVolumeGroup

A class encapsulates a volume group in car.

CarVolumeGroup 代码位于:

packages/services/Car/service/src/com/android/car/audio/CarVolumeGroup.java

CarVolumeGroup 的定义:

final class CarVolumeGroup {}

CarVolumeGroupMuting

CarVolumeGroup代码位于:

packages/services/Car/service/src/com/android/car/audio/CarVolumeGroup.java

CarVolumeGroup的定义:

final class CarVolumeGroupMuting {}

CarAudioPolicyVolumeCallback

继承于AudioPolicy.AudioPolicyVolumeCallback,用于接收与Volume更改相关的事件的回调类。

CarAudioPolicyVolumeCallback 代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioPolicyVolumeCallback.java

CarAudioPolicyVolumeCallback 的定义:

  1. final class CarAudioPolicyVolumeCallback extends AudioPolicy.AudioPolicyVolumeCallback{
  2. public void onVolumeAdjustment(int adjustment)
  3. }

CarVolumeCallbackHandler

Manages callbacks for changes in car volume.

CarVolumeCallbackHandler代码位于:

packages/services/Car/service/src/com/android/car/audio/CarVolumeCallbackHandler.java

CarVolumeCallbackHandler的定义:

class CarVolumeCallbackHandler {}

CarAudioZone

CarAudioZone在Android Automotive OS系统中用于描述车载音频区域并提供音频设置。一个汽车通常有多个音频输出区域,例如,前排和后排,左侧和右侧等。CarAudioZone可以描述这些不同的音频区域,并提供相应的音频设置。

CarAudioZone代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioZone.java

CarAudioZone的定义:

class CarAudioZone{}

CarAudioZonesValidator

汽车音频区域验证器

CarAudioZonesValidator代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioZonesValidator.java

CarAudioZonesValidator的定义:

class CarAudioZonesValidator{}

CarAudioZonesHelper

A helper class loads all audio zones from the configuration XML file.

帮助程序类从配置 XML 文件加载所有音频区域。

CarAudioZonesHelper代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioZonesHelper.java

CarAudioZonesHelper的定义:

class CarAudioZonesHelper {}

CarAudioZonesHelperLegacy

A helper class loads volume groups from car_volume_groups.xml configuration into one zone.

帮助程序类将volume groups 从car_volume_groups.xml配置加载到一个区域中。

CarAudioZonesHelperLegacy代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioZonesHelperLegacy.java

CarAudioZonesHelperLegacy的定义:

class CarAudioZonesHelperLegacy {}

CarZonesAudioFocus

Manages audio focus on a per zone basis.

基于每个区域管理音频焦点。

CarZonesAudioFocus代码位于:

packages/services/Car/service/src/com/android/car/audio/CarZonesAudioFocus.java

CarZonesAudioFocus的定义:

final class CarZonesAudioFocus extends AudioPolicy.AudioPolicyFocusListener {}

CarAudioFocus

CarAudioFocus在Android Automotive OS系统中用于控制车载音频角度相关设置。

CarAudioFocus代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioFocus.java

CarAudioFocus的定义:

class CarAudioFocus extends AudioPolicy.AudioPolicyFocusListener {}

FocusInteraction

FocusInteraction is responsible for evaluating how incoming focus requests should be handled based on pre-defined interaction behaviors for each incoming {AudioContext} in relation to a {AudioContext} that is currently holding focus.

负责根据与当前持有焦点的 {AudioContext} 相关的每个传入 {AudioContext} 的预定义交互行为,评估如何处理传入的焦点请求。

FocusInteraction代码位于:

packages/services/Car/service/src/com/android/car/audio/FocusInteraction.java

FocusInteraction的定义:

final class FocusInteraction {}

FocusEntry

FocusEntry代码位于:

packages/services/Car/service/src/com/android/car/audio/FocusEntry.java

FocusEntry的定义:

final class FocusEntry {}

CarDucking

CarDucking代码位于:

packages/services/Car/service/src/com/android/car/audio/CarDucking.java

CarDucking的定义:

final class CarDucking implements CarFocusCallback {}

CarDuckingInfo

Ducking information for a given car audio zone based on its focus state.

CarDuckingInfo代码位于:

packages/services/Car/service/src/com/android/car/audio/CarDuckingInfo.java

CarDuckingInfo的定义:

public final class CarDuckingInfo {}

CarDuckingUtils

CarDuckingUtils代码位于:

packages/services/Car/service/src/com/android/car/audio/CarDuckingUtils.java

CarDuckingUtils的定义:

final class CarDuckingUtils {}

CarAudioDeviceInfo

A helper class wraps {@link AudioDeviceInfo}, and helps get/set the gain on a specific port in terms of millibels.

Note to the reader. For whatever reason, it seems that AudioGain contains only configuration information (min/max/step, etc) while the AudioGainConfig class contains the actual currently active gain value(s).

CarAudioDeviceInfo在Android Automotive OS系统中用于提供车载媒体系统和音频外设设备的信息。

CarAudioDeviceInfo代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioDeviceInfo.java

CarAudioDeviceInfo的定义:

class CarAudioDeviceInfo {}

CarAudioDynamicRouting

CarAudioDynamicRouting在Android Automotive OS系统中用于动态控制车载音频的路由。

CarAudioDynamicRouting代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioDynamicRouting.java

CarAudioDynamicRouting的定义:

final class CarAudioDynamicRouting {}

CarAudioGainConfigInfo

CarAudioGainConfigInfo在Android Automotive OS系统中用于描述音频输入/输出通道的增益配置信息。

CarAudioGainConfigInfo代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioGainConfigInfo.java

CarAudioGainConfigInfo的定义:

public class CarAudioGainConfigInfo {}

CarAudioGainMonitor

Provides audio gain callback registration helpers and implements AudioGain listener business logic.

提供音频增益回调注册帮助程序,实现音频增益监听器业务逻辑。

CarAudioGainMonitor代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioGainMonitor.java

CarAudioGainMonit

final class CarAudioGainMonitor {}

CarHalAudioUtils

Car HAL audio Utils

CarHalAudioUtils代码位于:

packages/services/Car/service/src/com/android/car/audio/CarHalAudioUtils.java

CarHalAudioUtils的定义:

public final class CarHalAudioUtils {}

CarAudioPlaybackCallback

CarAudioPlaybackCallback是在Android Automotive OS系统中用于音频播放事件的回调接口。

CarAudioPlaybackCallback代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioPlaybackCallback.java

CarAudioPlaybackCallback的定义:

final class CarAudioPlaybackCallback extends AudioManager.AudioPlaybackCallback {}

CarAudioPowerListener

CarAudioPowerListener代码位于:

packages/services/Car/service/src/com/android/car/audio/CarAudioPowerListener.java

CarAudioPowerListener的定义:

class CarAudioPowerListener {}

CarAudioPatchHandle

CarAudioPatchHandle是在Android Automotive OS系统中用于表示音频路径的句柄。

CarAudioPatchHandle代码位于:

packages/services/Car/service/src/com/android/car/media/CarAudioPatchHandle.java

CarAudioPatchHandle的定义:

public final class CarAudioPatchHandle implements Parcelable {}

AudioControlFactory

Factory for constructing wrappers around IAudioControl HAL instances.

用于围绕 IAudioControl HAL 实例构造包装器的工厂。

AudioControlFactory代码位于:

packages/services/Car/service/src/com/android/car/audio/hal/AudioControlFactory.java

AudioControlFactory的定义:

public final class AudioControlFactory {}

HalAudioFocus

Manages focus requests from the HAL on a per-zone per-usage basis.

基于每个区域的每次使用量管理 HAL 的焦点请求

HalAudioFocus代码位于:

packages/services/Car/service/src/com/android/car/audio/hal/HalAudioFocus.java

HalAudioFocus的定义:

  1. public final class HalAudioFocus implements HalFocusListener {
  2. private final class HalAudioFocusRequest {
  3. }

AudioControlWrapperAidl

AudioControlWrapperV1

AudioControlWrapperV2

Wrapper for AIDL interface for AudioControl HAL.

Wrapper for IAudioControl@1.0.

Wrapper for IAudioControl@2.0.

AudioControlWrapper代码位于:

packages/services/Car/service/src/com/android/car/audio/hal/AudioControlWrapperAidl.java

packages/services/Car/service/src/com/android/car/audio/hal/AudioControlWrapperV1.java

packages/services/Car/service/src/com/android/car/audio/hal/AudioControlWrapperV2.java

AudioControlWrapper的定义:

  1. public final class AudioControlWrapperAidl implements AudioControlWrapper {
  2. private static final class FocusListenerWrapper extends IFocusListener.Stub {}
  3. private static final class AudioGainCallbackWrapper extends IAudioGainCallback.Stub {}
  4. }
  5. public final class AudioControlWrapperV1 implements AudioControlWrapper {}
  6. public final class AudioControlWrapperV2 implements AudioControlWrapper {}
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/889389
推荐阅读
相关标签
  

闽ICP备14008679号