Using the io-acoustic API

Projects that use their own Bluetooth service need to use the io-acoustic API to manage acoustic echo cancellation and noise reduction.

If you use the io-acoustic API, you will have to perform the tasks described below.

Setting up

To enable acoustic echo cancellation on your system, you need to perform a few setup tasks when you start your system:

  1. Link to the libacoustic libraries.
  2. Call ioap_hf_attach() to attach io-acoustic and get a handle to this resource manager.


If you want to use an acoustic tuning file for the AAP library other than the one specified in the io-acoustic configuration file, you need to:

  1. Call ioap_hf_config() to set the path to the AAP library tuning file. For more information about acoustic tuning, see the AAP documentation.

If you want to change the device routing from that specified in the io-acoustic configuration file:

  1. Call ioap_hf_route() to set up the routing between the hardware devices and the acoustic processing inputs and outputs.

Registering for events

When you have completed your initial setup, you need to:

  1. Call ioap_hf_register_events() to register for io-acoustic events.
  2. Start a thread to listen for events. In this thread, use the file descriptor returned by ioap_hf_attach() to call select().
  3. When select() returns, call ioap_hf_read_events() to process the events.


To start acoustic processing:

  1. Call ioap_hf_prepare() to validate the acoustic processing paths set in the configuration file or by the call to ioap_hf_route() during setup.
  2. Call ioap_hf_go() to start the acoustic processing.


To stop acoustic processing, call ioap_hf_stop().


If you need to get information about your system and how it is configured for acoustic processing you can:

Getting and setting the output volume level

Volume control is enabled if volumecontrol is set to "true" in the configuration file. Otherwise, the volume level is fixed and specified by the tuning file.

This design supports systems that want the AAP library to control the volume, and systems that want the codec to control the volume. The acoustic echo cancellation performance will be better if the AAP library controls the volume, but this option is more difficult to implement. It requires that your system intercept the volume control change request and pass it into your handsfree application rather than just letting the audio subsystem handle it.

If you configure your system to have the AAP library control the volume, you can use the acoustic processing API to get and set the volume level. The volume level you set with the API remains in force until the next time io-acoustic is started:

Estimating system latency

If you do not know your system's latency, you can use ioap_start_latency_test() to run a latency test, and ioap_hf_get_latency_estimate() to retrieve the results of this test.