Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is AudioFlinger and why does it fail TONE_PROP_ACK?

In my application I issue the following statement:

toneGenerator.startTone(ToneGenerator.TONE_PROP_ACK, 600);

Which works very well on a cheap LG LS670 running Android 2.3.3 but doesn't sound at all on all other phones I have, ranging from Android 2.2.1 to Android 2.3.4.

So I know the OS version doesn't play a role here (I also verified in the documentation that it has been supported since API 1).

Also, both Ringer volume and Media volume are set to maximum and toneGenerator is initialized with:

toneGenerator = new ToneGenerator(ToneGenerator.TONE_DTMF_1, 100);

And I verified that Settings.System.DTMF_TONE_WHEN_DIALING is set to 1.

Baffled by this inconsistent behavior (across different phones), I examined the system logs when this happens and the only suspicious difference I have been able to find is that the phones who fail to sound TONE_PROP_ACK have this line in their log:

AudioFlinger    setParameters(): io 25, keyvalue routing=0, tid 155, calling tid 121

What is the purpose of AudioFlinger and what could be its connection to muting TONE_PROP_ACK?

Any idea how to fix my code so that that TONE_PROP_ACK always sounds, regardless of phone model?

like image 463
Eternal Learner Avatar asked Jun 27 '12 03:06

Eternal Learner


People also ask

What is AudioFlinger?

We know that AudioFlinger (Sometimes called AF) is the core of the entire audio system in Android. It is a system service which starts during boot and enables the platform for audio related use-cases in the following ways. 1. Provide the access interface for the upper layer for using Audio.

What is the functionality of audio flinger?

AudioFlinger debugging feature available in custom builds only. Used for logging audio events to a circular buffer where they can then be retroactively dumped when needed. Android system process that contains media-related services, including AudioFlinger. Non-blocking audio input/output.


1 Answers

One work around is to generate the tone in something like Audacity and play it through SoundPool or the api of your choice.

According to the Android docs ToneGenerator.TONE_PROP_ACK is:

1200Hz, 100ms ON, 100ms OFF 2 bursts

If you choose SoundPool, I suggest saving in ogg file format and loop the tone until complete. This while provide seamless audio with a very small clip and not using a lot of resources.

like image 73
dan Avatar answered Oct 10 '22 21:10

dan