التحكم في الصوت هال

تم تقديم التحكم الصوتي (HAL) في نظام التشغيل Android 9 لدعم حالات استخدام الصوت ذات الصلة بالسيارات. اعتبارًا من Android 14، يدعم التحكم في الصوت HAL:

  • تتلاشى والتوازن
  • طلب تركيز الصوت HAL
  • كتم صوت الجهاز والتهرب
  • تغييرات كسب جهاز الصوت
  • تغييرات تكوين منفذ الصوت

يوضح الشكل 1 نظرة عامة عالية المستوى على بنية خدمة الصوت في السيارة، حيث تتواصل خدمة الصوت في السيارة مع HAL للتحكم في الصوت.

تكوين الصوت متعدد المناطق

الشكل 1. تكوين الصوت متعدد المناطق.

يتلاشى الصوت والتوازن

تم تقديم الإصدار 1 للتحكم في الصوت HIDL HAL في Android 9 لدعم تلاشي الصوت وتوازنه في حالات استخدام السيارات. بشكل منفصل عن التأثيرات الصوتية العامة المتوفرة بالفعل في Android، تسمح هذه الآلية لتطبيقات النظام بضبط توازن الصوت والتلاشي من خلال واجهات برمجة تطبيقات CarAudioManager :

class CarAudioManager {
       /**
       *   Adjust the relative volume in the front vs back of the vehicle cabin.
       *
       *   @param value in the range -1.0 to 1.0 for fully toward the back through
       *   fully toward the front. 0.0 means evenly balanced.
       */
       @SystemApi
       @RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
       public void setFadeTowardFront(float value);

       /**
       *   Adjust the relative volume on the left vs right side of the vehicle cabin.
       *
       *   @param value in the range -1.0 to 1.0 for fully toward the left through
       *   fully toward the right. 0.0 means evenly balanced.
       */
       @SystemApi
       @RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME)
       public void setBalanceTowardRight(float value);
}

بمجرد استدعاء واجهات برمجة التطبيقات هذه، يتم استدعاء واجهات برمجة تطبيقات HAL الخاصة بالتحكم في الصوت من خدمة الصوت في السيارة:

interface IAudioControl {
       /**
       *   Control the right/left balance setting of the car speakers.
       */
       oneway setBalanceTowardRight(float value);

       /**
       *   Control the fore/aft fade setting of the car speakers.
       */
       oneway setFadeTowardFront(float value);
}

تتوفر واجهة برمجة التطبيقات (API) في جميع إصدارات HAL للتحكم في الصوت، بما في ذلك واجهة AIDL HAL الجديدة.

طلب التركيز الصوتي من HAL

ويعتمد نظام AAOS، المشابه لنظام Android، على المشاركة النشطة للتطبيقات في التركيز الصوتي لإدارة تشغيل الصوت في السيارات. يتم استخدام معلومات التركيز لإدارة التدفقات التي سيتم التحكم فيها من حيث الحجم والخفض. على هذا النحو، لمزيد من التوسع في التركيز الصوتي وتوفير تكامل أفضل للأصوات الخاصة بالسيارة في تجربة Android، تم تقديم سمات الصوت التالية في Android 11:

  • EMERGENCY
  • SAFETY
  • VEHICLE_STATUS
  • ANNOUNCEMENT

وبالإضافة إلى هذا التغيير، تمت إضافة آلية للأصوات التي تنشأ من خارج Android للمشاركة في طلبات التركيز الصوتي. وبالتالي، تم تقديم الإصدار 2 للتحكم في الصوت HIDL HAL للسماح بطلبات التركيز التي تنشأ من خارج Android:

interface IAudioControl {
       /**
       *   Registers focus listener to be used by HAL for requesting and
       *   abandoning audio focus.
       *   @param listener the listener interface
       *   @return closeHandle A handle to unregister observer.
       */
       registerFocusListener(IFocusListener listener)
       generates (ICloseHandle closeHandle);

       /**
       *   Notifies HAL of changes in audio focus status for focuses requested
       *   or abandoned by the HAL.
       *
       *   @param usage The audio usage associated with the focus change
       *   @param zoneId The identifier for the audio zone that the HAL is
       *   playing the stream in
       *   @param focusChange the AudioFocusChange that has occurred
       */
       oneway onAudioFocusChange(bitfield<AudioUsage> usage, int32_t zoneId,
       bitfield<AudioFocusChange> focusChange);
}

حيث يتم تعريف IFocusListener على النحو التالي:

interface IFocusListener {
       /**
       *   Called whenever HAL is requesting focus as it is starting to play
       *   audio of a given usage in a specified zone.
       *
       *   @param usage The audio usage associated with the focus request
       *    {@code AttributeUsage}
       *   @param zoneId The identifier for the audio zone where the HAL is
       *    requesting focus
       *   @param focusGain The AudioFocusChange associated with this request.
       */
       oneway requestAudioFocus(bitfield<AudioUsage> usage,
       int32_t zoneId, bitfield<AudioFocusChange> focusGain);
       /**
       *   Called whenever HAL is abandoning focus as it is finished playing audio
       *   of a given usage in a specific zone.
       *
       *   @param usage The audio usage for which the HAL is abandoning focus
       *    {@code AttributeUsage}
       *   @param zoneId The identifier for the audio zone that the HAL
       *    abandoning focus
       */
       oneway abandonAudioFocus(bitfield<AudioUsage> usage, int32_t zoneId);
}

يمكن استخدام واجهات برمجة التطبيقات المذكورة أعلاه لطلب التركيز الصوتي من HAL والتخلي عنه، على التوالي. ردًا على ذلك، تأخذ خدمة الصوت في السيارة بعين الاعتبار طلب التركيز الصوتي وتعيد توجيه النتائج بشكل غير متزامن إلى أسلوب IAudioControl#onAudioFocusChange .

يمكن أيضًا استخدام واجهة برمجة التطبيقات (API) هذه لمراقبة التغييرات في طلب التركيز الصوتي الذي ينشأ من التحكم في الصوت (HAL). بشكل عام، يعتبر أي طلب تركيز صوتي ثابت من HAL نشطًا ، وهو ما يختلف عن طلب التركيز الصوتي من Android، والذي يعتبر فيه تشغيل المسار الصوتي النشط المقابل نشطًا فقط.

قم بترحيل HIDL إلى التحكم الصوتي AIDL HAL

مع ظهور AIDL والترحيل المطلوب في Android 12 (لمعرفة المزيد، راجع AIDL لـ HALs )، تم ترحيل التحكم في الصوت HAL إلى AIDL. بالنسبة لواجهات برمجة التطبيقات الحالية للتحكم في الصوت لـ HIDL، الإصدار 2، يتطلب الترحيل تحديثات بسيطة للطرق الحالية:

interface IAudioControl {
       /**
       *   Notifies HAL of changes in audio focus status for focuses requested
       *   or abandoned by the HAL.
       *
       *   @param usage The audio usage associated with the focus change
       *        {@code AttributeUsage}. See {@code audioUsage} in
       *        audio_policy_configuration.xsd for the list of allowed values.
       *   @param zoneId The identifier for the audio zone that the HAL is
       *        playing the stream in
       *   @param focusChange the AudioFocusChange that has occurred.
       */
       oneway void onAudioFocusChange(in String usage, in int zoneId,
              in AudioFocusChange focusChange);
       /**
       *   Registers focus listener to be used by HAL for requesting and
       *   abandoning audio focus.
       *   @param listener the listener interface.
       */
       oneway void registerFocusListener(in IFocusListener listener);
       /**
       *   Control the right/left balance setting of the car speakers.
       */
       oneway void setBalanceTowardRight(in float value);
       /**
       *   Control the fore/aft fade setting of the car speakers.
       */
       oneway void setFadeTowardFront(in float value);
}

و IFocusListener المقابل:

       interface IFocusListener {
       /**
       *   Called whenever HAL is abandoning focus as it is finished playing audio
       *   of a given usage in a specific zone.
       *
       *   @param usage The audio usage for which the HAL is abandoning focus
       *        {@code AttributeUsage}. See {@code audioUsage} in
       *        audio_policy_configuration.xsd for the list of allowed values.
       *   @param zoneId The identifier for the audio zone that the HAL
       *        abandoning focus
       */
       oneway void abandonAudioFocus(in String usage, in int zoneId);
       /**
       *   Called whenever HAL is requesting focus as it is starting to play audio
       *        of a given usage in a specified zone.
       *
       *   @param usage The audio usage associated with the focus request
       *        {@code AttributeUsage}. See {@code audioUsage} in
       *        audio_policy_configuration.xsd for the list of allowed values.
       *   @param zoneId The identifier for the audio zone where the HAL is
       *        requesting focus
       *   @param focusGain The AudioFocusChange associated with this request.
       */
       oneway void requestAudioFocus(in String usage, in int zoneId,
              in AudioFocusChange focusGain);
}

كتم صوت مجموعة الصوت

قدم Android 12 ميزة كتم صوت مجموعة الصوت للسماح بتحكم أكثر شمولاً في كتم الصوت أثناء التفاعلات الصوتية للمستخدم. وهذا يسمح لـ HAL للتحكم في الصوت باستقبال أحداث كتم الصوت التي يتم اعتراضها بواسطة خدمة الصوت في السيارة.

لتمكين هذه الميزة، يجب على مصنعي المعدات الأصلية ضبط تكوين audioUseCarVolumeGroupMuting على true في ملف config.xml الخاص بخدمة السيارة:

<!-- Configuration to enable muting of individual volume groups.
If this is set to false, muting of individual volume groups is disabled,
instead muting will toggle master mute. If this is set to true, car volume
group muting is enabled and each individual volume group can be muted separately. -->
<bool name="audioUseCarVolumeGroupMuting">true</bool>

قبل Android 13، كان لا بد من استبدال التكوين بتراكب موارد وقت التشغيل packages/services/Car/service/res/values/config.xml (لمعرفة المزيد، راجع تخصيص البنية باستخدام تراكبات الموارد ). بدءًا من Android 13، يمكنك استخدام تراكبات موارد وقت التشغيل لتغيير قيمة التكوين. لمعرفة المزيد، راجع تغيير قيمة موارد التطبيق في وقت التشغيل .

يمكن لتطبيقات النظام تحديد ما إذا كانت الميزة ممكّنة باستخدام CarAudioManager#isAudioFeatureEnabled API. يجب أن تكون المعلمة التي تم تمريرها هي CarAudioManager.AUDIO_FEATURE_VOLUME_GROUP_MUTING الثابت. تُرجع الطريقة true إذا كانت الميزة ممكّنة على الجهاز، وإلا false .

بالإضافة إلى تمكين ميزة audioUseCarVolumeGroupMuting ، يجب أن يقوم HAL للتحكم في الصوت AIDL بتنفيذ آلية كتم صوت مجموعة الصوت:

interface IAudioControl {
       /**
       *   Notifies HAL of changes in output devices that the HAL should apply
       *   muting to.
       *
       *   This will be called in response to changes in audio mute state for each
       *   volume group and will include a {@link MutingInfo} object per audio
       *   zone that experienced a mute state event.
       *
       *   @param mutingInfos an array of {@link MutingInfo} objects for the audio
       *   zones where audio mute state has changed.
       */
       oneway void onDevicesToMuteChange(in MutingInfo[] mutingInfos);
}

حيث تحتوي معلومات كتم الصوت على معلومات كتم الصوت ذات الصلة بالنظام الصوتي:

parcelable MutingInfo {
       /**
       *   ID of the associated audio zone
       */
       int zoneId;
       /**
       *   List of addresses for audio output devices that should be muted.
       */
       String[] deviceAddressesToMute;
       /**
       *   List of addresses for audio output devices that were previously be
       *   muted and should now be unmuted.
       */
       String[] deviceAddressesToUnmute;
}

لدى AAOS آليتين مختلفتين لكتم الصوت، بناءً على:

  • الأحداث الرئيسية باستخدام الصوت KEYCODE_VOLUME_MUTE {:.external}.

  • مكالمات مباشرة إلى خدمة الصوت في السيارة باستخدام واجهة برمجة التطبيقات لكتم صوت مدير صوت السيارة، CarAudioManager#setVolumeGroupMute .

عند التمكين، تقوم كلتا الآليتين بتشغيل كتم صوت المكالمة إلى وحدة التحكم في الصوت HAL.

تقليص صوت السيارة

قدم Android 12 ميزة تجنب صوت السيارة لتحسين التحكم في التشغيل المتزامن لتدفقات الصوت. يتيح ذلك لمصنعي المعدات الأصلية تنفيذ سلوك الابتعاد الخاص بهم استنادًا إلى تكوين الصوت الفعلي للسيارة وحالة التشغيل الحالية، وفقًا لما تحدده خدمة الصوت في السيارة.

تعتمد آلية التنصت على تغييرات مكدس التركيز الصوتي. كلما حدث تغيير في التركيز (سواء كان طلب التركيز أو التخلي عن التركيز)، يتم إعلام وحدة التحكم في الصوت (HAL). على غرار دعم كتم صوت مجموعة مستوى صوت السيارة، يمكن تمكين خفض صوت السيارة باستخدام علامة التكوين audioUseHalDuckingSignals :

<!-- Configuration to enable IAudioControl#onDevicesToDuckChange API to
inform HAL when to duck. If this is set to true, the API will receive signals
indicating which output devices to duck as well as what usages are currently
holding focus. If set to false, the API will not be called. -->
<bool name="audioUseHalDuckingSignals">true</bool>

لتمكين الميزة، يجب أن يقوم HAL للتحكم في الصوت AIDL بتنفيذ المنطق ذي الصلة مع الإشارة المستلمة من الخدمة الصوتية للسيارة:

interface IAudioControl {
       /**
       *   Notifies HAL of changes in output devices that the HAL should apply
       *   ducking to.
       *
       *   This will be called in response to changes in audio focus, and will
       *   include a {@link DuckingInfo} object per audio zone that experienced
       *   a change in audo focus.
       *
       *   @param duckingInfos an array of {@link DuckingInfo} objects for the
       *   audio zones where audio focus has changed.
       */
       oneway void onDevicesToDuckChange(in DuckingInfo[] duckingInfos);
}

معلومات النظام الصوتي ذات الصلة موجودة في معلومات خفض الصوت:

parcelable DuckingInfo {
       /**
       *   ID of the associated audio zone
       */
       int zoneId;
       /**
       *   List of addresses for audio output devices that should be ducked.
       */
       String[] deviceAddressesToDuck;
       /**
       *   List of addresses for audio output devices that were previously be
       *   ducked and should now be unducked.
       */
       String[] deviceAddressesToUnduck;
       /**
       *   List of usages currently holding focus for this audio zone.
       */
       String[] usagesHoldingFocus;
}

وبصرف النظر عن معلومات تكوين الصوت في السيارة الموجودة في عناوين الجهاز لـ (un)duck، تحتوي معلومات التهرب أيضًا على معلومات حول استخدامات سمات الصوت التي تستحوذ على التركيز. الهدف من هذه البيانات هو إعلام النظام الصوتي باستخدامات السمات الصوتية النشطة.

وهذا مطلوب لأنه، في تكوين صوت السيارة، يمكن تعيين سمات صوتية متعددة لجهاز واحد، وبدون المعلومات الإضافية، ليس من الواضح أي الاستخدامات النشطة.

AIDL التحكم في الصوت HAL 2.0

لتحديث واجهات برمجة التطبيقات وتسهيل الوظائف الجديدة، تم تحديث HAL للتحكم في الصوت AIDL إلى الإصدار 2.0 في Android 13:

  • التركيز الصوتي مع PlaybackTrackMetadata
  • رد اتصال مكاسب الصوت

يتم تعريف بيانات تعريف التشغيل في android.hardware.audio.common على النحو التالي:

parcelable PlaybackTrackMetadata {
       AudioUsage usage = INVALID;
       AudioContentType contentType = UNKNOWN;
       float gain;
       AudioChannelLayout channelMask;
       AudioDevice sourceDevice;
       String[] tags;
}

بقيت جميع الوظائف الأخرى من الإصدار 1.0 للتحكم في الصوت AIDL ويمكن استخدامها. يتعلق الاستثناء بطريقة تغيير تركيز الصوت، كما هو موضح في طريقة تغيير تركيز الصوت .

التركيز على التحكم في الصوت مع البيانات الوصفية لمسار التشغيل

لعرض مزيد من المعلومات للنظام الصوتي الموجود أسفل طبقة HAL، تعرض التحديثات الآن PlaybackTrackMetadata . على وجه التحديد، تم توسيع التحكم في الصوت HAL بطريقة جديدة:

interface IAudioControl {
       /**
       *   Notifies HAL of changes in audio focus status for focuses requested
       *   or abandoned by the HAL.
       *
       *   The HAL is not required to wait for a callback of AUDIOFOCUS_GAIN
       *   before playing audio, nor is it required to stop playing audio in the
       *   event of a AUDIOFOCUS_LOSS callback is received.
       *
       *   @param playbackMetaData The output stream metadata associated with
       *    the focus request
       *   @param zoneId The identifier for the audio zone that the HAL is
       *    playing the stream in
       *   @param focusChange the AudioFocusChange that has occurred.
       */
       oneway void onAudioFocusChangeWithMetaData(
       in PlaybackTrackMetadata playbackMetaData, in int zoneId,
       in AudioFocusChange focusChange);
}

تم إجراء تغيير مماثل ومطابق على IFocusListener :

       /**
       *   Called to indicate that the audio output stream associated with
       *   {@link android.hardware.audio.common.PlaybackTrackMetadata} is
       *   abandoning focus as playback has stopped.
       *
       *   @param playbackMetaData The output stream metadata associated with
       *    the focus request
       *   @param zoneId The identifier for the audio zone that the HAL
       *    abandoning focus
       */
       oneway void abandonAudioFocusWithMetaData(
       in PlaybackTrackMetadata playbackMetaData, in int zoneId);
       /**
       *   Called to indicate that the audio output stream associated with
       *   {@link android.hardware.audio.common.PlaybackTrackMetadata} has taken
       *   the focus as playback is starting for the corresponding stream.
       *
       *   @param playbackMetaData The output stream metadata associated with
       *    the focus request
       *   @param zoneId The identifier for the audio zone that the HAL
       *    abandoning focus
       *   @param focusGain The focus type requested.
       */
       oneway void requestAudioFocusWithMetaData(
       in PlaybackTrackMetadata playbackMetaData, in int zoneId,
       in AudioFocusChange focusGain);
}

على طريقة تغيير التركيز الصوتي

يتم تنفيذ عمليات التركيز أعلاه بنفس الطريقة الموضحة في طلب التركيز الصوتي من HAL . تحتوي البيانات التعريفية لمسار التشغيل فقط على مزيد من المعلومات بالإضافة إلى استخدامات سمات الصوت. بشكل عام، ما لم تكن هناك حاجة إلى معلومات إضافية توفرها البيانات التعريفية لمسار التشغيل، يمكن لـ HAL للتحكم في Android المحدث الاستمرار في استخدام الطرق السابقة.

إذا قرر مطورو HAL عدم دعم IAudioControl#onAudioFocusChangeWithMetaData ، فيجب أن يقوم الأسلوب بإرجاع النتائج مع خطأ UNKNOWN_TRANSACTION كما هو موضح باستخدام أساليب الواجهة ذات الإصدار .

تستدعي خدمة الصوت أولاً onAudioFocusChangeWithMetaData ثم تعيد المحاولة باستخدام أسلوب onAudioFocusChange في حالة فشل UNKNOWN_TRANSACTION .

خفض صوت السيارة مع البيانات الوصفية لمسار التشغيل

أضاف الإصدار 2.0 من التحكم الصوتي AIDL HAL البيانات التعريفية لمسار التشغيل إلى معلومات خفض الصوت:

parcelable DuckingInfo {
       /**
       *   ID of the associated audio zone
       */
       int zoneId;
       /**
       *   List of addresses for audio output devices that should be ducked.
       */
       String[] deviceAddressesToDuck;
       /**
       *   List of addresses for audio output devices that were previously be
       *   ducked and should now be unducked.
       */
       String[] deviceAddressesToUnduck;
       /**
       *   List of usages currently holding focus for this audio zone.
       */
       String[] usagesHoldingFocus;
       /**
       *   List of output stream metadata associated with the current focus
       *   holder for this audio zone
       */
       @nullable PlaybackTrackMetadata[] playbackMetaDataHoldingFocus;
}

تم إهمال usagesHoldingFocus . يجب على المطورين الآن استخدام playbackMetaDataHoldingFocus لتحديد استخدام سمة الصوت والمعلومات الصوتية الأخرى. ومع ذلك، لا تزال المعلمة usagesHoldingFocus تحتوي على المعلومات المطلوبة حتى تتم إزالة هذا الخيار رسميًا.

رد اتصال كسب الصوت

لجعل التغييرات الصوتية الموجودة أسفل HAL أكثر وضوحًا لـ AAOS في Android 13، أضفنا آلية يمكنك استخدامها لتوصيل تغييرات مكاسب الصوت من النظام الصوتي للسيارة إلى الخدمة الصوتية للسيارة. تكشف الآلية عن تغييرات في مؤشر حجم كسب الصوت مع سبب تغيير الكسب:

  • القيود المحظورة أو الصامتة
  • قيود القيود
  • قيود التوهين

تكشف هذه التغييرات هذه القيود من أسفل HAL إلى خدمة الصوت في السيارة، وأخيرًا إلى تطبيق واجهة مستخدم النظام لإعلام المستخدم. تم توسيع الجزء الأخير، وهو التعرض لواجهة مستخدم محتملة للنظام، بشكل أكبر في Android 14 للسماح لتطبيقات واجهة مستخدم النظام بالحصول على هذه المعلومات بسهولة أكبر من خلال آلية رد اتصال معلومات مجموعة الحجم.

تسجل واجهة برمجة تطبيقات HAL للتحكم في الصوت رد اتصال الكسب كما يلي:

interface IAudioControl {
       /**
       *   Registers callback to be used by HAL for reporting unexpected gain(s)
       *    changed and the reason(s) why.
       *
       *   @param callback The {@link IAudioGainCallback}.
       */
       oneway void registerGainCallback(in IAudioGainCallback callback);
}

يتم تعريف IAudioGainCallback على النحو التالي:

interface IAudioGainCallback {
       /**
       *   Used to indicate that one or more audio device port gains have changed,
       *   i.e. initiated by HAL, not by CarAudioService.
       *   This is the counter part of the
       *   {@link onDevicesToDuckChange}, {@link onDevicesToMuteChange} and,
       *   {@link setAudioDeviceGainsChanged} APIs.
       *
       *   @param reasons List of reasons that triggered the given gains changed.
       *   @param gains List of gains affected by the change.
       */
       void onAudioDeviceGainsChanged(in Reasons[] reasons,
       in AudioGainConfigInfo[] gains);
}

كما هو موضح في وثائق API، يتم تسجيل رد اتصال الكسب بواسطة خدمة صوت السيارة إلى HAL للتحكم في الصوت. عندما يتم استدعاء واجهة برمجة التطبيقات (API) من HAL للتحكم في الصوت، تستجيب خدمة الصوت في السيارة بالإجراء المقابل (مثل الحظر أو الحد أو مؤشر الكسب المخفف).

تحدد HAL متى يتم استدعاء واجهة برمجة التطبيقات (API)، بشكل أساسي للإبلاغ عن التغييرات في حالة فهرس الربح. بالنسبة لمتطلبات التنظيم، يجب على نظام الصوت في السيارة اتخاذ الإجراء المطلوب واستخدام رد الاتصال لإبلاغ المعلومات إلى خدمة الصوت في السيارة للسماح باستهلاك المستخدم. على سبيل المثال، لإظهار واجهة المستخدم للمستخدم.

AIDL التحكم في الصوت HAL 3.0

تم تحديث إصدار HAL للتحكم في الصوت لنظام Android 14 AIDL إلى الإصدار 3.0 لتحديث واجهات برمجة التطبيقات لتوفير وظائف أكثر قوة لفهرس كسب الصوت. تسمح واجهة برمجة تطبيقات HAL للتحكم في الصوت للخدمة الصوتية بتعيين وإلغاء تعيين IModuleChangeCallback :

interface IAudioControl {
       /**
       *   Sets callback with HAL for notifying changes to hardware module
       *   (that is: {@link android.hardware.audio.core.IModule}) configurations.
       *
       *   @param callback The {@link IModuleChangeCallback} interface to use
       *    use when new updates are available for
       */
       void setModuleChangeCallback(in IModuleChangeCallback callback);
       /**
       *   Clears module change callback
       */
       void clearModuleChangeCallback();
}

يتم تسجيل setModuleChangeCallback بواسطة خدمة الصوت في السيارة عند بدء الخدمة أو عند التعافي من خطأ ما. على سبيل المثال، إشعار وفاة رابط HAL للتحكم في الصوت الذي تتلقاه خدمة الصوت في السيارة. يجب أن يحل تطبيق HAL للتحكم في الصوت محل أي رد اتصال لتغيير الوحدة النمطية عند استدعاء واجهة برمجة التطبيقات (API).

بالنسبة لواجهة برمجة تطبيقات clearModuleChangeCallback ، يجب أن يقوم التنفيذ بمسح رد الاتصال الحالي أو عدم القيام بأي شيء في حالة عدم وجوده. من الممارسات الجيدة لتطبيق التحكم الصوتي تسجيل مراقب الموت لاستدعاء الاتصال ثم مسح رد الاتصال إذا تم تشغيل وفاة الموثق.

يتم تعريف IModuleChangeCallback على النحو التالي:

oneway interface IModuleChangeCallback {
       /**
       *   Used to indicate that one or more {@link AudioPort} configs have
       *   changed. Implementations MUST return at least one AudioPort.
       *
       *   @param audioPorts list of {@link AudioPort} that are updated
       */
       void onAudioPortsChanged(in AudioPort[] audioPorts);
}

عندما يتم تسجيل رد اتصال تغيير الوحدة بواسطة خدمة الصوت في السيارة، يكون جاهزًا لتلقي تغييرات منفذ الصوت من خلال onAudioPortChanged API. يمكن استخدام واجهة برمجة التطبيقات (API) لتهيئة مكاسب الحجم للنظام الصوتي بمجرد تسجيل رد الاتصال. بالنسبة لتغييرات الكسب الديناميكي الأخرى، يمكن استدعاء واجهة برمجة التطبيقات (API) في أي وقت. يتم تطبيق التغييرات المقابلة ويتم تحديث الخدمة الصوتية للسيارة وفقًا لذلك.