hfp support at android hal

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

hfp support at android hal

2,452 Views
pravverma
Contributor III

Hi,

We want to support hfp profile along with normal audio on our board. Please let me know what changes required in android hal to support both?

On our board, We have created two sound cards in kernel:

sound card 0: for noarmal audio data. It works as a primary sound card.

sound card 1: for bluetooth sco data.

We have seperately tested both. Both are working fine.(I have disabled the "sound card 0" for audio codec, so "sound card 1" becomes "sound card 0".Doing this all the bt sco data goes to primary. This way I tested bt through android & it is working fine.)

To support both,

I created one more "myandroid/hardware/imx/alsa_hfp" directory & added the hfp entry in /system/etc/audio_policy.conf.

It is able to properly found the "sound card 1" for bt. but it is failing at  function "str_parms_get_str()" inside "out_set_parameters()".

Please see the below logs:

=====================

W/audio_hw_hfp( 2137): file = hardware/imx/alsa_hfp/tinyalsa_hal.c === line = 3301 ===

W/audio_hw_hfp( 2137): out rate 8000

W/audio_hw_hfp( 2137): in rate 8000, channels 1 format 0

E/audio_hw_hfp( 2137): select_output_device,387

E/audio_hw_hfp( 2137): headphone 0 ,headset 0 ,speaker 0, earpiece 0,

I/AudioFlinger( 2137): loadHwModule() Loaded hfp audio interface from Freescale i.MX Audio HW HAL (audio) handle 5

W/audio_hw_hfp( 2137): In channels 1, rate 44100, devices 0x4

W/audio_hw_hfp( 2137): get_input_buffer_size size = 5648, channel_count = 1

W/audio_hw_hfp( 2137): get_input_buffer_size size = 5648, channel_count = 1

I/AudioFlinger( 2137): AudioFlinger's thread 0x75a52000 ready to run

E/AudioService(  414): Media server started.

W/audio_hw_primary( 2137): set parameters restarting=true

E/audio_hw_hfp( 2137): MIT: adev_set_parameters,2989

W/audio_hw_hfp( 2137): set parameters restarting=true

E/audio_hw_hfp( 2137): MIT: file - hardware/imx/alsa_hfp/tinyalsa_hal.c adev_open_output_stream,2827

W/audio_hw_hfp( 2137): open output stream devices 32, format 1, channels 1, sample_rate 8000, flag 1

W/audio_hw_hfp( 2137): opened out stream...1964143488, type 1

I/AudioFlinger( 2137): HAL output buffer size 192 frames, normal sink buffer size 192 frames

I/AudioFlinger( 2137): AudioFlinger's thread 0x75138300 ready to run

W/audio_hw_hfp( 2137): out_set_parameters 80:57:19:8A:B4:0D, ret -2, out 1964143488

W/audio_hw_hfp( 2137): out_set_parameters closing=true, ret -2, out 1964143488

W/audio_hw_hfp( 2137): out_set_parameters exiting=1, ret -2, out 1964143488

W/audio_hw_hfp( 2137): adev_close_output_stream...1964143488

W/audio_hw_primary( 2137): out_set_parameters routing=0, ret 0, out 1980319936

W/audio_hw_hfp( 2137): In channels 1, rate 44100, devices 0x80000008

W/audio_hw_hfp( 2137): get_input_buffer_size size = 5648, channel_count = 1

W/audio_hw_hfp( 2137): get_input_buffer_size size = 5648, channel_count = 1

I/AudioFlinger( 2137): AudioFlinger's thread 0x74f25000 ready to run

W/audio_hw_hfp( 2137): in_set_parameters 80:57:19:8A:B4:0D, ret -2

W/audio_hw_primary( 2137): Leaving IN_CALL state, in_call=0, mode=3

W/audio_hw_primary( 2137): out_set_parameters routing=2, ret 0, out 1980319936

W/audio_hw_primary( 2137): set parameters restarting=false

W/audio_hw_hfp( 2137): set parameters restarting=false

Please let me know what is the reason for this error? Is there any code which i could refer to support hfp?

0 Kudos
2 Replies

1,106 Views
baiaaren
Contributor II

Hello sandesh gowda,

  I work on bt sco over pcm, I also have this problem.

Could you share your experience?

I would like to thank you very much

Aaren

0 Kudos

1,106 Views
sandeshgowda
Contributor III

Hi,

Could anybody explain, at which scenario I should use "AUDIO_OUTPUT_FLAG_DIRECT".

I have created a module named hfp in /system/etc/audio_policy.conf file as following.

hfp {

    outputs {

      hfp {

        sampling_rates 8000

        channel_masks AUDIO_CHANNEL_OUT_MONO

        formats AUDIO_FORMAT_PCM_16_BIT

        devices AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET|AUDIO_DEVICE_OUT_BLUETOOTH_SCO

        flags AUDIO_OUTPUT_FLAG_DIRECT

      }

    }

    inputs {

      hfp {

        sampling_rates 8000|44100

        channel_masks AUDIO_CHANNEL_IN_MONO

        formats AUDIO_FORMAT_PCM_16_BIT

        devices AUDIO_DEVICE_IN_ALL_SCO|AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET

        flags AUDIO_OUTPUT_FLAG_DIRECT

      }

    }

  }

Based on this flag, the following actions are performing

1. DirectOutputThread() function is creating threads in AudioFlinger.cpp file.

2. In AudioPolicyManager.cpp, closeOutput() function is called which is closing the output. Please let me know why closeOutput() is called & how to again open it?

Thanks,

0 Kudos