ऑडियो नियंत्रण एचएएल

ऑटोमोटिव से संबंधित ऑडियो उपयोग मामलों का समर्थन करने के लिए एंड्रॉइड 9 में ऑडियो नियंत्रण एचएएल पेश किया गया था। Android 14 के अनुसार, ऑडियो नियंत्रण HAL समर्थन करता है:

  • फीका और संतुलन
  • एचएएल ऑडियो फोकस अनुरोध
  • डिवाइस म्यूट करना और डक करना
  • ऑडियो डिवाइस लाभ परिवर्तन
  • ऑडियो पोर्ट कॉन्फ़िगरेशन बदलता है

चित्र 1 कार ऑडियो सेवा वास्तुकला का एक उच्च-स्तरीय अवलोकन दिखाता है, जिसमें कार ऑडियो सेवा ऑडियो नियंत्रण एचएएल के साथ संचार करती है।

मल्टी-ज़ोन ऑडियो कॉन्फ़िगर करें

चित्र 1. मल्टी-ज़ोन ऑडियो कॉन्फ़िगर करें।

ऑडियो फीका और संतुलन

ऑटोमोटिव उपयोग के मामलों में ऑडियो फीका और संतुलन का समर्थन करने के लिए एंड्रॉइड 9 में एचआईडीएल ऑडियो नियंत्रण एचएएल संस्करण 1 पेश किया गया था। एंड्रॉइड में पहले से उपलब्ध कराए गए सामान्य ऑडियो प्रभावों से अलग, यह तंत्र सिस्टम ऐप्स को ऑडियो संतुलन सेट करने और 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);
}

एक बार जब इन एपीआई को कॉल किया जाता है, तो संबंधित ऑडियो नियंत्रण एचएएल एपीआई को कार ऑडियो सेवा से कॉल किया जाता है:

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

एपीआई ऑडियो नियंत्रण एचएएल के सभी संस्करणों पर उपलब्ध है, जिसमें नया एआईडीएल एचएएल इंटरफ़ेस भी शामिल है।

एचएएल से ऑडियो फोकस अनुरोध

AAOS, एंड्रॉइड के समान, कारों में ऑडियो प्लेबैक को प्रबंधित करने के लिए ऑडियो फोकस पर ऐप्स की सक्रिय भागीदारी पर निर्भर करता है। फोकस जानकारी का उपयोग यह प्रबंधित करने के लिए किया जाता है कि वॉल्यूम और डकिंग के लिए कौन सी स्ट्रीम को नियंत्रित किया जाए। जैसे, ऑडियो फोकस पर और विस्तार करने और एंड्रॉइड अनुभव में कार विशिष्ट ध्वनियों का बेहतर एकीकरण प्रदान करने के लिए, एंड्रॉइड 11 में निम्नलिखित ऑडियो विशेषताएं पेश की गईं:

  • EMERGENCY
  • SAFETY
  • VEHICLE_STATUS
  • ANNOUNCEMENT

इस परिवर्तन के अलावा, ऑडियो फोकस अनुरोधों में भाग लेने के लिए एंड्रॉइड के बाहर से उत्पन्न होने वाली ध्वनियों के लिए एक तंत्र जोड़ा गया था। इस प्रकार, HIDL ऑडियो नियंत्रण HAL संस्करण 2 को एंड्रॉइड के बाहर से उत्पन्न होने वाले फोकस अनुरोधों की अनुमति देने के लिए पेश किया गया था:

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

उपरोक्त एपीआई का उपयोग क्रमशः एचएएल से ऑडियो फोकस का अनुरोध करने और छोड़ने के लिए किया जा सकता है। जवाब में, कार ऑडियो सेवा ऑडियो फोकस अनुरोध पर विचार करती है और परिणामों को IAudioControl#onAudioFocusChange पद्धति पर अतुल्यकालिक रूप से अग्रेषित करती है।

इस एपीआई का उपयोग ऑडियो नियंत्रण एचएएल से उत्पन्न होने वाले ऑडियो फोकस अनुरोध के परिवर्तनों की निगरानी के लिए भी किया जा सकता है। सामान्य तौर पर, एचएएल से किसी भी स्थायी ऑडियो फोकस अनुरोध को सक्रिय माना जाता है, जो एंड्रॉइड से ऑडियो फोकस अनुरोध से भिन्न होता है, जिसमें केवल संबंधित सक्रिय ऑडियो ट्रैक प्लेबैक को सक्रिय माना जाता है।

HIDL को AIDL ऑडियो नियंत्रण HAL में माइग्रेट करें

एआईडीएल के आगमन और एंड्रॉइड 12 में आवश्यक माइग्रेशन (अधिक जानने के लिए, एचएएल के लिए एआईडीएल देखें) के साथ, ऑडियो नियंत्रण एचएएल को एआईडीएल में स्थानांतरित कर दिया गया था। मौजूदा एचआईडीएल ऑडियो नियंत्रण संस्करण 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);
}

वॉल्यूम समूह म्यूटिंग

एंड्रॉइड 12 ने उपयोगकर्ता के ऑडियो इंटरैक्शन के दौरान अधिक व्यापक म्यूट नियंत्रण की अनुमति देने के लिए वॉल्यूम ग्रुप म्यूटिंग की शुरुआत की। यह ऑडियो नियंत्रण HAL को कार ऑडियो सेवा द्वारा इंटरसेप्ट किए गए म्यूटिंग इवेंट प्राप्त करने की अनुमति देता है।

सुविधा को सक्षम करने के लिए, OEM को कार सेवा config.xml में audioUseCarVolumeGroupMuting कॉन्फ़िगरेशन को true पर सेट करना होगा:

<!-- 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>

एंड्रॉइड 13 से पहले, कॉन्फ़िगरेशन packages/services/Car/service/res/values/config.xml के लिए रनटाइम रिसोर्स ओवरले के साथ ओवरराइट करना पड़ता था (अधिक जानने के लिए, रिसोर्स ओवरले के साथ बिल्ड को कस्टमाइज़ करना देखें)। एंड्रॉइड 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} का उपयोग करके मुख्य घटनाएँ।

  • कार ऑडियो मैनेजर म्यूट एपीआई, CarAudioManager#setVolumeGroupMute का उपयोग करके कार ऑडियो सेवा पर सीधी कॉल।

सक्षम होने पर, दोनों तंत्र ऑडियो नियंत्रण एचएएल पर कॉल म्यूट को ट्रिगर करते हैं।

कार ऑडियो डकिंग

एंड्रॉइड 12 ने ऑडियो स्ट्रीम के समवर्ती प्लेबैक के नियंत्रण को अनुकूलित करने के लिए कार ऑडियो डकिंग की शुरुआत की। यह ओईएम को कार के भौतिक ऑडियो कॉन्फ़िगरेशन और वर्तमान प्लेबैक स्थिति के आधार पर अपने स्वयं के डकिंग व्यवहार को लागू करने की अनुमति देता है, जैसा कि कार ऑडियो सेवा द्वारा निर्धारित किया जाता है।

डकिंग तंत्र ऑडियो फोकस स्टैक परिवर्तनों पर आधारित है। जब भी कोई फोकस परिवर्तन होता है (चाहे फोकस अनुरोध हो या फोकस परित्याग), ऑडियो नियंत्रण एचएएल को सूचित किया जाता है। कार वॉल्यूम ग्रुप म्यूटिंग समर्थन के समान, कार ऑडियो डकिंग को 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>

सुविधा को सक्षम करने के लिए, एआईडीएल ऑडियो नियंत्रण एचएएल को कार ऑडियो सेवा से प्राप्त सिग्नल के साथ प्रासंगिक तर्क लागू करना होगा:

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

डिवाइस पते में (अन)डक में निहित कार ऑडियो कॉन्फ़िगरेशन जानकारी के अलावा, डकिंग जानकारी में यह जानकारी भी शामिल है कि कौन से ऑडियो विशेषता उपयोग फोकस बनाए रख रहे हैं। इस डेटा का उद्देश्य ऑडियो सिस्टम को यह सूचित करना है कि कौन से ऑडियो विशेषताओं का उपयोग सक्रिय है।

यह आवश्यक है क्योंकि, कार ऑडियो कॉन्फ़िगरेशन में, एक ही डिवाइस को कई ऑडियो विशेषताएँ सौंपी जा सकती हैं और, अतिरिक्त जानकारी के बिना, यह स्पष्ट नहीं है कि कौन से उपयोग सक्रिय हैं।

एआईडीएल ऑडियो नियंत्रण एचएएल 2.0

एपीआई को अपडेट करने और नई कार्यक्षमता को सुविधाजनक बनाने के लिए, एआईडीएल ऑडियो नियंत्रण एचएएल को एंड्रॉइड 13 में संस्करण 2.0 में अपडेट किया गया था:

  • PlaybackTrackMetadata के साथ ऑडियो फोकस
  • ऑडियो कॉलबैक प्राप्त करता है

प्लेबैक मेटाडेटा को android.hardware.audio.common में इस प्रकार परिभाषित किया गया है:

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

एआईडीएल ऑडियो नियंत्रण संस्करण 1.0 की अन्य सभी कार्यक्षमताएँ बनी रहीं और उनका उपयोग किया जा सकता है। एक अपवाद ऑडियो फोकस परिवर्तन विधि से संबंधित है, जैसा कि ऑन ऑडियो फोकस परिवर्तन विधि में वर्णित है।

प्लेबैक ट्रैक मेटाडेटा के साथ ऑडियो नियंत्रण फोकस

एचएएल के नीचे ऑडियो सिस्टम में अधिक जानकारी प्रदर्शित करने के लिए, अपडेट अब PlaybackTrackMetadata उजागर करते हैं। विशेष रूप से, ऑडियो नियंत्रण एचएएल को एक नई विधि के साथ विस्तारित किया गया था:

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

ऑडियो फोकस परिवर्तन विधि पर

उपरोक्त फोकस ऑपरेशन उसी तरह से निष्पादित होते हैं जैसे एचएएल से ऑडियो फोकस अनुरोध में वर्णित हैं। केवल प्लेबैक ट्रैक मेटाडेटा में ऑडियो विशेषताओं के उपयोग के साथ अधिक जानकारी होती है। सामान्य तौर पर, जब तक प्लेबैक ट्रैक मेटाडेटा द्वारा प्रदान की गई अतिरिक्त जानकारी की आवश्यकता नहीं होती, अद्यतन एंड्रॉइड नियंत्रण एचएएल पिछले तरीकों का उपयोग करना जारी रख सकता है।

यदि एचएएल डेवलपर्स IAudioControl#onAudioFocusChangeWithMetaData का समर्थन नहीं करने का निर्णय लेते हैं, तो विधि को संस्करण इंटरफ़ेस विधियों का उपयोग करके वर्णित UNKNOWN_TRANSACTION त्रुटि के साथ परिणाम लौटाना चाहिए।

ऑडियो सेवा पहले onAudioFocusChangeWithMetaData कॉल करती है और फिर UNKNOWN_TRANSACTION विफलता के परिणामस्वरूप onAudioFocusChange विधि से पुनः प्रयास करती है।

प्लेबैक ट्रैक मेटाडेटा के साथ कार ऑडियो डकिंग

एआईडीएल ऑडियो नियंत्रण एचएएल के संस्करण 2.0 ने ऑडियो डकिंग जानकारी में प्लेबैक ट्रैक मेटाडेटा जोड़ा:

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 पैरामीटर में अभी भी आवश्यक जानकारी शामिल है।

ऑडियो लाभ कॉलबैक

एंड्रॉइड 13 में एचएएल के नीचे के ऑडियो परिवर्तनों को एएओएस के लिए अधिक दृश्यमान बनाने के लिए, हमने एक तंत्र जोड़ा है जिसका उपयोग आप कार के ऑडियो सिस्टम से कार ऑडियो सेवा तक ऑडियो लाभ परिवर्तनों को संचारित करने के लिए कर सकते हैं। तंत्र संबंधित कारण के साथ ऑडियो लाभ वॉल्यूम इंडेक्स परिवर्तनों को उजागर करता है कि लाभ क्यों बदला गया था:

  • अवरोधित या मौन प्रतिबंध
  • सीमाएँ प्रतिबंध
  • क्षीणन प्रतिबंध

ये परिवर्तन एचएएल के नीचे से लेकर कार ऑडियो सेवा तक और अंत में, उपयोगकर्ता को सूचित करने के लिए सिस्टम यूआई ऐप तक इन प्रतिबंधों को उजागर करते हैं। बाद वाला भाग, एक संभावित सिस्टम यूआई के संपर्क में, सिस्टम यूआई ऐप्स को वॉल्यूम समूह सूचना कॉलबैक तंत्र के माध्यम से इस जानकारी को अधिक आसानी से प्राप्त करने की अनुमति देने के लिए एंड्रॉइड 14 में और विस्तारित किया गया था।

ऑडियो नियंत्रण एचएएल एपीआई लाभ कॉलबैक को निम्नानुसार पंजीकृत करता है:

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

जैसा कि एपीआई दस्तावेज़ में हाइलाइट किया गया है, लाभ कॉलबैक कार ऑडियो सेवा द्वारा ऑडियो नियंत्रण एचएएल में पंजीकृत किया गया है। जब ऑडियो नियंत्रण एचएएल से एपीआई को कॉल किया जाता है, तो कार ऑडियो सेवा संबंधित कार्रवाई (जैसे ब्लॉक, सीमा, या क्षीण लाभ सूचकांक) के साथ प्रतिक्रिया करती है।

एचएएल यह निर्धारित करता है कि एपीआई को कब कॉल किया जाता है, मुख्य रूप से लाभ सूचकांक स्थिति में परिवर्तन की रिपोर्ट करने के लिए। विनियमन आवश्यकताओं के लिए विशिष्ट, कार के ऑडियो सिस्टम को आवश्यक कार्रवाई करनी चाहिए और उपयोगकर्ता की खपत की अनुमति देने के लिए कार ऑडियो सेवा को जानकारी रिपोर्ट करने के लिए कॉलबैक का उपयोग करना चाहिए। उदाहरण के लिए, उपयोगकर्ता को यूआई दिखाने के लिए।

एआईडीएल ऑडियो नियंत्रण एचएएल 3.0

अधिक मजबूत ऑडियो गेन इंडेक्स कार्यक्षमता प्रदान करने के लिए एपीआई को अपडेट करने के लिए एंड्रॉइड 14 एआईडीएल ऑडियो नियंत्रण एचएएल संस्करण को संस्करण 3.0 में अपडेट किया गया है। ऑडियो नियंत्रण 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 को कार ऑडियो सेवा द्वारा पंजीकृत किया जाता है। उदाहरण के लिए, कार ऑडियो सेवा द्वारा प्राप्त एक ऑडियो नियंत्रण एचएएल बाइंडर मृत्यु सूचना। एपीआई कॉल किए जाने पर ऑडियो नियंत्रण एचएएल कार्यान्वयन को किसी भी मौजूदा मॉड्यूल परिवर्तन कॉलबैक को प्रतिस्थापित करना चाहिए।

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 के माध्यम से ऑडियो पोर्ट परिवर्तन प्राप्त करने के लिए तैयार होता है। कॉलबैक पंजीकृत होते ही ऑडियो सिस्टम के लिए वॉल्यूम लाभ प्रारंभ करने के लिए एपीआई का उपयोग किया जा सकता है। अन्य गतिशील लाभ परिवर्तनों के लिए, एपीआई को किसी भी समय कॉल किया जा सकता है। तदनुरूप परिवर्तन लागू किए जाते हैं और कार ऑडियो सेवा को तदनुसार अद्यतन किया जाता है।