ระบบควบคุมเสียง HAL

การควบคุมเสียง HAL เปิดตัวใน Android 9 เพื่อรองรับกรณีการใช้เสียงที่เกี่ยวข้องกับยานยนต์ ตั้งแต่ Android 14 เป็นต้นไป การควบคุมเสียง HAL รองรับ:

  • จางลงและสมดุล
  • คำขอโฟกัสเสียง HAL
  • การปิดเสียงและการหลบอุปกรณ์
  • อุปกรณ์เสียงได้รับการเปลี่ยนแปลง
  • การเปลี่ยนแปลงการกำหนดค่าพอร์ตเสียง

รูปที่ 1 แสดงภาพรวมระดับสูงของสถาปัตยกรรมบริการเครื่องเสียงรถยนต์ ซึ่งบริการเครื่องเสียงรถยนต์สื่อสารกับระบบควบคุมเสียง HAL

กำหนดค่าเสียงหลายโซน

รูปที่ 1. กำหนดค่าเสียงหลายโซน

เสียงจางลงและสมดุล

การควบคุมเสียง HIDL HAL เวอร์ชัน 1 เปิดตัวใน Android 9 เพื่อรองรับเสียงจางและความสมดุลในกรณีการใช้งานในยานยนต์ แยกจากเอฟเฟกต์เสียงทั่วไปที่มีให้แล้วใน Android กลไกนี้ช่วยให้แอประบบตั้งค่าความสมดุลของเสียงและจางหายไปผ่าน CarAudioManager API:

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);
}

เมื่อเรียก API เหล่านี้แล้ว HAL API ควบคุมเสียงที่เกี่ยวข้องจะถูกเรียกจากบริการเครื่องเสียงรถยนต์:

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 เพื่อเข้าร่วมในคำขอโฟกัสเสียง ดังนั้นจึงมีการแนะนำการควบคุมเสียง HIDL HAL เวอร์ชัน 2 เพื่ออนุญาตคำขอโฟกัสที่มาจากภายนอก 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);
}

API ข้างต้นสามารถใช้เพื่อขอและละทิ้งโฟกัสเสียงจาก HAL ตามลำดับ ในการตอบสนอง บริการเครื่องเสียงรถยนต์จะพิจารณาคำขอโฟกัสเสียงและส่งต่อผลลัพธ์แบบอะซิงโครนัสไปยังเมธอด IAudioControl#onAudioFocusChange

API นี้ยังสามารถใช้เพื่อตรวจสอบการเปลี่ยนแปลงสำหรับคำขอโฟกัสเสียงที่มาจากการควบคุมเสียง HAL โดยทั่วไป คำขอโฟกัสเสียงแบบยืนใดๆ จาก HAL จะถือว่า ใช้งานอยู่ ซึ่งแตกต่างจากคำขอโฟกัสเสียงจาก Android ซึ่งมีเพียงการเล่นแทร็กเสียงที่ใช้งานอยู่ที่เกี่ยวข้องเท่านั้นที่จะถือว่าใช้งานอยู่

ย้าย HIDL ไปยัง AIDL การควบคุมเสียง HAL

ด้วยการถือกำเนิดของ AIDL และการย้ายข้อมูลที่จำเป็นใน Android 12 (หากต้องการเรียนรู้เพิ่มเติม โปรดดู AIDL สำหรับ HAL ) ระบบควบคุมเสียง HAL จึงถูกย้ายไปยัง AIDL สำหรับ API การควบคุมเสียง 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 รับเหตุการณ์การปิดเสียงที่ถูกดักฟังโดยบริการเครื่องเสียงรถยนต์

หากต้องการเปิดใช้งานคุณสมบัตินี้ OEM ต้องตั้งค่าคอนฟิก 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 แล้ว การควบคุมเสียง AIDL HAL จะต้อง ใช้กลไกการปิดเสียงกลุ่มวอลุ่ม:

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}

  • โทรโดยตรงไปยังบริการเครื่องเสียงรถยนต์โดยใช้ API ปิดเสียงตัวจัดการเครื่องเสียงรถยนต์ CarAudioManager#setVolumeGroupMute

เมื่อเปิดใช้งาน กลไกทั้งสองจะกระตุ้นการปิดเสียงการโทรไปยังตัวควบคุมเสียง HAL

เครื่องเสียงรถยนต์หลบ

Android 12 เปิดตัวระบบลดเสียงรถยนต์เพื่อเพิ่มประสิทธิภาพการควบคุมการเล่นสตรีมเสียงพร้อมกัน ซึ่งช่วยให้ OEM สามารถใช้พฤติกรรมการหลบเสียงของตนเองโดยอิงตามการกำหนดค่าเสียงจริงของรถยนต์และสถานะการเล่นปัจจุบัน ตามที่กำหนดโดยบริการเครื่องเสียงรถยนต์

กลไกการหลบจะขึ้นอยู่กับการเปลี่ยนแปลงสแต็คโฟกัสเสียง เมื่อใดก็ตามที่มีการเปลี่ยนแปลงโฟกัสเกิดขึ้น (ไม่ว่าจะขอโฟกัสหรือละทิ้งโฟกัส) ระบบจะแจ้งระบบควบคุมเสียง 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>

หากต้องการเปิดใช้งานคุณสมบัตินี้ ระบบควบคุมเสียง AIDL HAL จะต้องใช้ตรรกะที่เกี่ยวข้องกับสัญญาณที่ได้รับจากบริการเครื่องเสียงรถยนต์:

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;
}

นอกเหนือจากข้อมูลการกำหนดค่าเครื่องเสียงรถยนต์ที่อยู่ในที่อยู่อุปกรณ์เพื่อ (ไม่) หลบข้อมูลแล้ว ข้อมูลการหลบยังมีข้อมูลเกี่ยวกับการใช้งานคุณลักษณะเสียงที่เน้นอยู่ จุดประสงค์ของข้อมูลนี้คือการแจ้งให้ระบบเสียงทราบว่ามีการใช้คุณลักษณะเสียงใดบ้าง

ซึ่งจำเป็นเนื่องจากในการกำหนดค่าเครื่องเสียงรถยนต์ สามารถกำหนดคุณลักษณะเสียงหลายรายการให้กับอุปกรณ์เครื่องเดียวได้ และหากไม่มีข้อมูลเพิ่มเติม ก็จะไม่ชัดเจนว่าการใช้งานใดที่ใช้งานอยู่

ระบบควบคุมเสียง AIDL HAL 2.0

เพื่ออัปเดต API และอำนวยความสะดวกในการใช้งานใหม่ 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;
}

ฟังก์ชันอื่นๆ ทั้งหมดจากการควบคุมเสียง AIDL เวอร์ชัน 1.0 ยังคงอยู่และสามารถใช้งานได้ ข้อยกเว้นเกี่ยวข้องกับวิธีการเปลี่ยนโฟกัสเสียง ดังที่อธิบายไว้ใน วิธีเปลี่ยนโฟกัสเสียง

โฟกัสการควบคุมเสียงพร้อมข้อมูลเมตาของแทร็กการเล่น

หากต้องการเปิดเผยข้อมูลเพิ่มเติมไปยังระบบเสียงด้านล่าง 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 เฉพาะข้อมูลเมตาของแทร็กการเล่นเท่านั้นที่มีข้อมูลเพิ่มเติมพร้อมกับการใช้แอตทริบิวต์เสียง โดยทั่วไป ยกเว้นในกรณีที่จำเป็นต้องมีข้อมูลเพิ่มเติมจากข้อมูลเมตาของแทร็กการเล่น การควบคุม Android ที่อัปเดตแล้ว HAL สามารถใช้วิธีการก่อนหน้าต่อไปได้

หากนักพัฒนา HAL ตัดสินใจที่จะไม่สนับสนุน IAudioControl#onAudioFocusChangeWithMetaData วิธีการควรส่งคืนผลลัพธ์พร้อมกับข้อผิดพลาด UNKNOWN_TRANSACTION ตามที่อธิบายไว้ โดยใช้ Versioned Interface Methods

บริการเสียงจะเรียก 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 ต่อบริการเครื่องเสียงรถยนต์ และสุดท้ายคือเปิดเผยต่อแอป UI ของระบบเพื่อแจ้งให้ผู้ใช้ทราบ ส่วนหลัง การเปิดรับ UI ของระบบที่เป็นไปได้ ได้รับการขยายเพิ่มเติมใน Android 14 เพื่อให้แอป UI ของระบบรับข้อมูลนี้พร้อมมากขึ้นผ่านกลไกการเรียกกลับข้อมูลกลุ่มวอลุ่ม

การควบคุมเสียง HAL API จะลงทะเบียนการรับการติดต่อกลับดังต่อไปนี้:

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 โดยหลักแล้วเพื่อรายงานการเปลี่ยนแปลงสถานะดัชนีกำไร ตามข้อกำหนดด้านกฎระเบียบ ระบบเครื่องเสียงของรถยนต์ควรดำเนินการที่จำเป็น และใช้การโทรกลับเพื่อรายงานข้อมูลไปยังบริการเครื่องเสียงรถยนต์เพื่อให้ผู้ใช้ใช้งานได้ เช่น เพื่อแสดง UI ให้กับผู้ใช้

ระบบควบคุมเสียง AIDL HAL 3.0

เวอร์ชัน HAL สำหรับการควบคุมเสียงของ Android 14 AIDL ได้รับการอัปเดตเป็นเวอร์ชัน 3.0 เพื่ออัปเดต API เพื่อให้ฟังก์ชันดัชนีเกนเสียงที่มีประสิทธิภาพมากขึ้น HAL API การควบคุมเสียงอนุญาตให้บริการเสียงตั้งค่าและยกเลิกการตั้งค่า 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 Binder ที่ได้รับจากบริการเครื่องเสียงรถยนต์ การใช้ HAL ควบคุมเสียงควรแทนที่การเรียกกลับการเปลี่ยนแปลงโมดูลที่มีอยู่เมื่อมีการเรียก API

สำหรับ clearModuleChangeCallback API การใช้งานควรล้างการเรียกกลับที่มีอยู่หรือไม่ดำเนินการใดๆ หากไม่มีอยู่ แนวทางปฏิบัติที่ดีสำหรับการนำการควบคุมเสียงไปใช้ในการลงทะเบียนผู้สังเกตการณ์การเสียชีวิตสำหรับการโทรกลับ จากนั้นล้างการโทรกลับหากมีการทริกเกอร์การเสียชีวิตของ on Binder

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 ได้ตลอดเวลา การเปลี่ยนแปลงที่เกี่ยวข้องจะถูกนำมาใช้ และบริการเครื่องเสียงรถยนต์จะได้รับการอัปเดตตามนั้น