HwAudioSource connects the audio source device directly to an Android mixer.
Several limitations may arise when using a device-to-device or hardware audio patch with Android. These are unable to receive media key events such as PLAY, PAUSE, and STOP and, because they circumvent Android's audio stack, they require hardware to mix the patch into other audio from Android.
HwAudioSource is a new type of player designed as a software patch. This enables applications that use this player to receive media key events and the output stream to be mixed and routed by Android.
mHwAudioSource = new HwAudioSource.Builder() .setAudioDeviceInfo(AudioDeviceInfo: info) .setAudioAttributes(new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_MEDIA) .build()) .build(); mHwAudioSource.play(); mHwAudioSource.stop();
Changes to the audio HAL
With this new player, there are a couple of expectations for the audio HAL
Adev_create_audio_patchexpects the request to establish an audio patch from a device to a mixer. This does not require anything special.
Adev_open_input_streamexpects the audio_source to be
In_readfill the audio buffer with actual broadcast radio audio data
It is recommended to configure a tuner device with type
<devicePort tagName="Tuner_source" type="AUDIO_DEVICE_IN_FM_TUNER" role="source" address="tuner0"> <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" samplingRates="48000" channelMasks="AUDIO_CHANNEL_IN_STEREO"/> </devicePort>
With this device configuration, finding the FM radio input device can be
facilitated by using the