History log of /frameworks/av/media/libmedia/ToneGenerator.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
66e4635cb09fadcaccf912f37c387396c428378a 17-Jan-2014 Glenn Kasten <gkasten@google.com> Use symbolic constants from <system/audio.h>

AUDIO_INTERLEAVE_*
AUDIO_STREAM_MIN
AUDIO_SESSION_ALLOCATE

Change-Id: I31dd6f327204685e50716079ce21c4ba206dff11
/frameworks/av/media/libmedia/ToneGenerator.cpp
1ab85ec401801ef9a9184650d0f5a1639b45eeb9 31-May-2013 Glenn Kasten <gkasten@google.com> Include what is needed

Remove old includes.
Header files only include other header files that they directly need themselves.

Change-Id: Ic471386808d9f42ea19ccbd59cb50a5f83a89dd0
/frameworks/av/media/libmedia/ToneGenerator.cpp
9f80dd223d83d9bb9077fb6baee056cee4eaf7e5 19-Dec-2012 Glenn Kasten <gkasten@google.com> New control block for AudioTrack and AudioRecord

Main differences between old and new control block:
- removes the mutex, which was a potential source of priority inversion
- circular indices into shared buffer, which is now always a power-of-2 size

Change-Id: I4e9b7fa99858b488ac98a441fa70e31dbba1b865
/frameworks/av/media/libmedia/ToneGenerator.cpp
2799d743ee2ae5a25fe869a7f9c052acc029559f 30-May-2013 Glenn Kasten <gkasten@google.com> Use sp<AudioTrack> instead of raw AudioTrack *

This change prepares for the new implementation of AudioTrack client, which
will require clients to use only sp<AudioTrack>, not raw AudioTrack *.
A raw delete will cause a race condition during AudioTrack destruction.

AudioTrack was made a RefBase by commit b68a91a70bc8d0d18e7404e14443d4e4020b3635
on 2011/11/15, when it was needed by OpenSL ES (for the callback protector).
At that time, the only other client that was also converted from
AudioTrack * to sp<AudioTrack> was android.media.AudioTrack JNI in
project frameworks/base (file android_media_AudioTrack.cpp).

Details:
* Use .clear() instead of delete followed by = NULL.
* ALOG %p need .get().
* sp<> don't need to be listed in constructor initializer, if initially 0.
* Use == 0 for sp<> vs == NULL for raw pointers.
* Use if (sp != 0) instead of if (raw).

Change-Id: Ic7cad25795d6e862e112abdc227b6d33afdfce17
/frameworks/av/media/libmedia/ToneGenerator.cpp
704455a5a6cd22f03bb8984e0c7f46108eb1afb7 13-May-2013 Eric Laurent <elaurent@google.com> Fix unreleased mutex in ToneGenerator stopTone()

Commit 09108ade introduced a regression by not releasing
the ToneGenerator mutex before exiting in case of error.

Bug: 8852855
Change-Id: I8ba2755b218842e2034ed8dbd54b18bf2a5fc571
/frameworks/av/media/libmedia/ToneGenerator.cpp
a8eccec73a40d4afcff505eb463a016c89aeed42 28-Mar-2013 Eric Laurent <elaurent@google.com> ToneGenerator: fix overflow in stopTone

Fix overflow in tone duration calculation introduced in
commit 681be039.

Bug 6607077

Change-Id: Ie12f13701345c2b2d3be0b3c4d71cbfa2394a29b
/frameworks/av/media/libmedia/ToneGenerator.cpp
681be0398a06da7e24db4ed934a92af64d1409b1 27-Mar-2013 Eric Laurent <elaurent@google.com> ToneGenerator: fix truncated tones

The first DTMF tone after a silent period is truncated.
This is because the phone app starts and stops the tone
when the user presses and releases the key.
This combined to the fact that the tones use the low latency path
and that when the output stream exists standby there is a period
of several milliseconds during which no audio is mixed until the
stream is "warmed up".
The result is that much less audio is generated than the actual
key press duration.

The fix consists in storing the tone start time and making sure that
the number of samples generated corresponds at least to the time difference
between the tone start and stop commands.

Bug 6607077

Change-Id: I070d20dd8600c25a9e5d5a60c1d3313b7917b00d
/frameworks/av/media/libmedia/ToneGenerator.cpp
09108adeca8cbbf3fbb21f8aea2a2ff250db9531 27-Mar-2013 Eric Laurent <elaurent@google.com> ToneGenerator: fix stop/destroy concurrency

There is a problem if the stopTone() method is called
from two different threads (for instance if the destructor is called
while stopTone() is waiting for the audio callback to finish).

In this case, the second call to stopTone() will not wait for the
condition to be signaled and call clearWaveGens() while the callback
can still be active, thus causing a crash.

There is a similar problem in case of concurrent calls to startTone()
and stopTone().

The fix consists in making sure that stopTone() always waits for call
back completion or timeout and exits before calling clearWaveGens()
if a concurrent start request is detected.

Bug 8163071

Change-Id: I9ddb4390407701dcad5bf83660fd9903f0d72268
/frameworks/av/media/libmedia/ToneGenerator.cpp
6386b50b67185a966d43ee761acdfe7add569d10 26-Mar-2013 Eric Laurent <elaurent@google.com> ToneGenerator: fix AudioTrack pointer init

The pointer to AudioTrack should be initialized before
early return from ToneGenerator constructor because
it is tested by the destructor.

Bug 8140963

Change-Id: I9a7dfb60ba162b75dfaa5630ab7fc9485afd0074
/frameworks/av/media/libmedia/ToneGenerator.cpp
6eb954f54e4a92b3c4bfbee177a3259d1320500d 25-Mar-2013 Eric Laurent <elaurent@google.com> ToneGenerator: optimize silent tone

Do not create an AudioTrack and start playback when a silent
tone is requested to ToneGenerator.

Bug 7946399

Change-Id: Ib9282871a56f7a862af7d1504ce3fbd7c18e34e2
/frameworks/av/media/libmedia/ToneGenerator.cpp
b1c0993b215c5c3eebd1c6bafc22bba23d57a70b 28-Feb-2012 Glenn Kasten <gkasten@google.com> Add all-channel AudioTrack::setVolume() API

Add combined channel APIs setVolume to AudioTrack,
and remove obsolete getVolume.

Change-Id: I0c87bfdbff4f4292259fa33e65f67badbafd270b
/frameworks/av/media/libmedia/ToneGenerator.cpp
98f153091e8f4190b35b9ce15250f308baf4805c 25-Apr-2012 Glenn Kasten <gkasten@google.com> Re-enable fast track for ToneGenerator

Change-Id: If4152169778df124c750dc45023322ee23c80587
/frameworks/av/media/libmedia/ToneGenerator.cpp
1d685d767a5dd1003eb62f6ad1a26b39645a474f 23-Apr-2012 Glenn Kasten <gkasten@google.com> Fix ToneGenerator regression

Bug: 6378847
Change-Id: Ib3324c7a5951ac95f99993bfae27ea02bfda08ff
/frameworks/av/media/libmedia/ToneGenerator.cpp
0ca3cf94c0dfc173ad7886ae162c4b67067539f6 18-Apr-2012 Eric Laurent <elaurent@google.com> rename audio policy output flags

Change-Id: I27c46bd1d1b2b5f96b87af7d05b951fef18a1312
/frameworks/av/media/libmedia/ToneGenerator.cpp
2120fe5bd4e14b53d8bef4a220e8a32830cf8cf9 11-Apr-2012 Glenn Kasten <gkasten@google.com> ToneGenerator requests fast track

Also add comments to AudioTrack::set() parameter list

Change-Id: I28c76e9d813778d86b15d75cf7f01a17c258b6d9
/frameworks/av/media/libmedia/ToneGenerator.cpp
e53b9ead781c36e96d6b6f012ddffc93a3d80f0d 13-Mar-2012 Glenn Kasten <gkasten@google.com> Whitespace and indentation

Fix indentation to be multiple of 4.
Make it easier to search:
sp< not sp < to
"switch (...)" instead of "switch(...)" (also "if" and "while")
Remove redundant blank line at start or EOF.
Remove whitespace at end of line.
Remove extra blank lines where they don't add value.

Use git diff -b or -w to verify.

Change-Id: I966b7ba852faa5474be6907fb212f5e267c2874e
/frameworks/av/media/libmedia/ToneGenerator.cpp
18868c5db2f90309c6d11e5837822135e4a0c0fa 07-Mar-2012 Glenn Kasten <gkasten@google.com> Use audio_policy_output_flags_t consistently

This affects:
- IAudioFlinger::openOutput
- AudioTrack::AudioTrack
- AudioTrack::set
- apps that call these

Change-Id: I26fb281bac6cb87593d17697bc9cb37a835af205
/frameworks/av/media/libmedia/ToneGenerator.cpp
99e53b86eebb605b70dd7591b89bf61a9414ed0e 19-Jan-2012 Glenn Kasten <gkasten@google.com> Update comments

We no longer put the filename at start of file.

Change-Id: Ic435b159a23105681e3d4a6cb1ac097bc853302e
/frameworks/av/media/libmedia/ToneGenerator.cpp
9d1f02d74fd395ec4de6861147da289423f0ab6f 09-Feb-2012 Glenn Kasten <gkasten@google.com> Follow raw pointer and sp<> conventions

Unconditional delete for raw pointers.
Use "if (sp != 0)" not "if (sp.get() != 0)" or "if (sp != NULL)".
Use "if (raw != NULL)" not "if (raw)".

Change-Id: I531a8da7c37149261ed2f34b862ec4896a4b785b
/frameworks/av/media/libmedia/ToneGenerator.cpp
90bebef5669a9385c706b042d146a31dca2e5d9b 28-Jan-2012 Glenn Kasten <gkasten@google.com> No newline or space at end of ALOG format string

Change-Id: I0bef580cbc818cb7c87aea23919d26f1446cec32
/frameworks/av/media/libmedia/ToneGenerator.cpp
ff3c83e04ae459c4252b86dd4440b4e37ee92c16 03-Feb-2012 Glenn Kasten <gkasten@google.com> Merge "Use ToneGenerator::tone_type consistently"
a0d68338a88c2ddb4502f95017b546d603ef1ec7 28-Jan-2012 Glenn Kasten <gkasten@google.com> Use NULL not 0 for raw pointers

Use if (p != NULL) instead of if (ptr)

Change-Id: Iaec3413a59ccbf233c98fcd918cc7d70ac5da9fa
/frameworks/av/media/libmedia/ToneGenerator.cpp
3d2f877c1cb4e4ae4ddde7f57f4353de9341f11b 28-Jan-2012 Glenn Kasten <gkasten@google.com> Use ToneGenerator::tone_type consistently

Also remove defaults in startToneCommand(), they're not needed and the
default for tone type was nonsense.

Change-Id: I70fa8cee4f3dbb8c66ceb3719c8d3d2f447f05b9
/frameworks/av/media/libmedia/ToneGenerator.cpp
fff6d715a8db0daf08a50634f242c40268de3d49 13-Jan-2012 Glenn Kasten <gkasten@google.com> Use audio_stream_type_t consistently

At native level it was a mixture of audio_stream_type_t, int, uint32_t,
and uint8_t. Java is still int. Also fixed a couple of hard-coded -1
instead of AUDIO_STREAM_DEFAULT, and in startToneCommand a hard-coded 0
instead of AUDIO_STREAM_VOICE_CALL.

Change-Id: Ia33bfd70edca8c2daec9052984b369cd8eee2a83
/frameworks/av/media/libmedia/ToneGenerator.cpp
83bc7f3cf78b28a818417f40a4f0c00593993366 04-Jan-2012 Glenn Kasten <gkasten@google.com> libmedia new can't fail on Android

Change-Id: Ie79dd5abb8078b35474bf0f1b3a6ff994a3a3360
/frameworks/av/media/libmedia/ToneGenerator.cpp
29357bc2c0dd7c43ad3bd0c8e3efa4e6fd9bfd47 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/157220

Bug: 5449033
Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
/frameworks/av/media/libmedia/ToneGenerator.cpp
5ff1dd576bb93c45b44088a51544a18fc43ebf58 06-Jan-2012 Steve Block <steveblock@google.com> Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: I00a4b904f9449e6f93b7fd35eac28640d7929e69
/frameworks/av/media/libmedia/ToneGenerator.cpp
3856b090cd04ba5dd4a59a12430ed724d5995909 20-Oct-2011 Steve Block <steveblock@google.com> Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGE

See https://android-git.corp.google.com/g/#/c/143865

Bug: 5449033
Change-Id: I0122812ed6ff6f5b59fe4a43ab8bff0577adde0a
/frameworks/av/media/libmedia/ToneGenerator.cpp
b8e9897b8ad5d722e424d7a7e256153307ecbd93 15-Jun-2011 Glenn Kasten <gkasten@google.com> Remove unneeded #include <sys/resource.h>

Suggested in code review for previous change.

Change-Id: Ic3225b240367dc6c9bf56fb4498fb8a0f9f806ec
/frameworks/av/media/libmedia/ToneGenerator.cpp
d217a8c4632b3e3065f8c2a26b9ce4dc4c97171f 02-Jun-2011 Glenn Kasten <gkasten@google.com> Revert "Use AudioTrack::event_type not int in callback"

This reverts commit 2225e4b7049fa3fb9d39a068b8268b63c952d7c1
/frameworks/av/media/libmedia/ToneGenerator.cpp
013b5a67d6f8e12a1b06e74863daec1bee4d99c1 05-May-2011 Glenn Kasten <gkasten@google.com> Use AudioTrack::event_type not int in callback

Change-Id: Ifefc708d46874e04fd0d01cb6e2d43b987ee796c
/frameworks/av/media/libmedia/ToneGenerator.cpp
fce7a473248381cc83a01855f92581077d3c9ee2 20-Apr-2011 Dima Zavin <dima@android.com> audio/media: convert to using the audio HAL and new audio defs

Change-Id: Ibc637918637329e4f2b62f4ac7781102fbc269f5
Signed-off-by: Dima Zavin <dima@android.com>
/frameworks/av/media/libmedia/ToneGenerator.cpp
981594f5c3697c3330bdbd4bb5a743fb9f01e6ab 14-Oct-2009 Naveen Kalla <nkalla@quicinc.com> Media/ToneGenerator: Change tone format for TONE_CDMA_ANSWER

Tone format for TONE_CDMA_ANSWER should be 660Hz + 1000Hz, with a 500ms ON
duration.
/frameworks/av/media/libmedia/ToneGenerator.cpp
34f1d8ecd23169a5f299937e3aaf1bd7937578a0 04-Nov-2009 Eric Laurent <elaurent@google.com> Fix issue 2203561: Sholes: audio playing out of earpiece.

Create a new IAudioTrack interface to AudioFlinger when start() fails due to a broken pipe error.
Do the same if start fails due to the same error after time out in obtainBuffer().
Do not indicate that the AudioTrack is started to AudioPolicyManager if IAudioTrack start fails.
This avoids that an AudioTrack keeps a dead IAudioTrack after a media server crash.

Same modifications for AudioRecord.

Add a flag to ToneGenerator indicating that the callback thread can call Java. Without it, when the media server crashes and restarts, the AudioSystem error callback will crash in JNI if the IAudiotrack is created from AudioTrack callback thread.
/frameworks/av/media/libmedia/ToneGenerator.cpp
a9a4390989072d579eedab6b71fb41248b3ad8fe 23-Oct-2009 Eric Laurent <elaurent@google.com> Fix 2209967 Tonegenerator: mutex not release in startTone() upon timeout waiting for the stop sequence to complete.

Unlock mLock mutex when exiting upon wait stop timeout condition.
Increase timeout delays to avoid timing out when A2DP exits standby.
/frameworks/av/media/libmedia/ToneGenerator.cpp
e33e00e931d1381d402484aa5cde67e540e3c82c 06-Oct-2009 Eric Laurent <elaurent@google.com> Fix issue 2139634: DTMF tones on Sholes popping, hissing (audio latency too high).

This change is a complement to the main fix in kernel driver for the same issue (partner change #1250).
It removes clicks sometimes heard after the end of the tones while audio flinger is sending 0s to the audio output stream.
The problem was that the sleep time between two writes was more than the duration of one audio output stream buffer which could cause some underrun.

Also fixed a recent regression in ToneGenerator that made that the end of previous tone was repeated at the beginning of current one under certain timing circumstances when the maximum tone duration was specified.
/frameworks/av/media/libmedia/ToneGenerator.cpp
824b6a4a67166c3937400702944f659bd0d5d386 24-Sep-2009 Eric Laurent <elaurent@google.com> Fix issue 2142613: ToneGenerator: short tones sometimes don't play on sholes or over A2DP.

When the AudioTrack callback notification size is relatively high (Which is the case on Sholes and over A2DP), it is likely that the end of tone is reached during the first callback. In this case, the AudioTrack is stopped before exiting the callback which causes 2 problems:
- 1: If the AudioFlinger thread is scheduled before we exit the ToneGenerator callback, the track can be stopped and reset before the data is actually marked as present in the buffer by the AudioTrack callback => no audio will be processed by AudioFlinger.
- 2: In this case, the data write index in the AudioTrack buffer is incremented after the track was reset by the AudioFlinger which leaves unplayed data in the buffer. This data will be played the next time the AudioTrack is started if not flushed in between.

The fix consists in adding an intermediate state to ToneGenerator state machine so that we exit the callback function when the stop condition is reached and stop the AudioTrack the next time we execute the callback.
/frameworks/av/media/libmedia/ToneGenerator.cpp
85fa14d35468acca07ce0085d67b909f673fae07 07-Sep-2009 Eric Laurent <elaurent@google.com> Fix issue 1992233: DTMF tones on Sholes is really long.

Add a parameter to ToneGenerator.startTone() allowing the caller to specify the tone duration. This is used by the phone application to have a precise control on the DTMF tone duration which was not possible with the use of delayed messaged.
Also modified AudioFlinger output threads so that 0s are written to the audio output stream when no more tracks are ready to mix instead of just sleeping. This avoids an issue where the end of a previous DTMF tone could stay in audio hardware buffers and be played just before the beginning of the next DTMF tone.
/frameworks/av/media/libmedia/ToneGenerator.cpp
5a22b909c9e8fc0d9321dcc014706a790b26b971 11-Aug-2009 Eric Laurent <elaurent@google.com> Fix issue 2045983 ToneGenerator: fix void statement.

There is a void statement at line 917 of ToneGenerator.cpp: mState == TONE_IDLE;
This problem is harmless as in current code this execution path is never taken; it can only happen if a "new" operator fails in prepareWave() which is a case we usually consider as unlikely in android audio framework.
/frameworks/av/media/libmedia/ToneGenerator.cpp
c2f1f07084818942352c6bbfb36af9b6b330eb4e 17-Jul-2009 Eric Laurent <elaurent@google.com> Fix issue 1795088 Improve audio routing code

Initial commit for review.
Integrated comments after patch set 1 review.
Fixed lockup in AudioFlinger::ThreadBase::exit()
Fixed lockup when playing tone with AudioPlocyService startTone()
/frameworks/av/media/libmedia/ToneGenerator.cpp
c38bb0614dc0b5dee682b9a1de47de5ae7d215d8 09-Jul-2009 Eric Laurent <elaurent@google.com> Fix issue 1946033: dialer deadlocks and/or ANRs when using dialpad in-call

The cause is very likely that the WaveGenerator *lpWaveGen returned by lpToneGen->mWaveGens.valueFor(lFrequency) just before calling lpWaveGen->getSamples(lpOut, lGenSmp, lWaveCmd) is invalid. The frequency lFrequency is not part of the frequencies in mWaveGens.
This can happen if a different tone is started while the callback function is active: The state is changed to TONE_RESTARTING and the call to prepareWave() at line 1226 will change the tone descriptor pointed to by mpToneDesc as well as the content of mWaveGens. However, mpToneDesc was cached in a local variable lpToneDesc when entering the callback and is not reloaded when exiting prepareWave(). This causes a mismatch between the tone frequencies listed in lpToneDesc and the frequencies present in mWaveGens.
This regression was introduced in change 973 when mpToneDesc was cached in a local variable.
/frameworks/av/media/libmedia/ToneGenerator.cpp
5e0a3043af16bc71a4211ee00dc00724de6623a7 17-Jun-2009 David Krause <david.krause@motorola.com> Fill in CDMA gaps and clean up ToneGenerator code
/frameworks/av/media/libmedia/ToneGenerator.cpp
4afdfa7fd7e9fe59fb298ef2ac252686e68bc73a 07-May-2009 Dave Sparks <davidsparks@android.com> Don't allow negative numbers in ToneGenerator toneType parameter
Bug 1836596
/frameworks/av/media/libmedia/ToneGenerator.cpp
0b62e242d112d46e9357242b0a4e11c720c98ca0 05-May-2009 Eric Laurent <elaurent@google.com> Fixed issue 1709450: Requirements for CDMA Tone Generator

Added new tone types for CDMA IS-95 specific tones.
Automatic selection between IS-95, CEPT and JAPAN version base on operator
country code for call supervisory tones.
Also improved tone generator capabilities:
- Each tone segment can now generate its own set of frequencies
- A tone does not have to be a succession of alternating ON/OFF segments
- The sequence repetition does not have to start from first segment
/frameworks/av/media/libmedia/ToneGenerator.cpp
8365529381f6284f2d59dcc38e26f73adeec9c67 09-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@137197
/frameworks/av/media/libmedia/ToneGenerator.cpp
89fa4ad53f2f4d57adbc97ae1149fc00c9b6f3c5 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/av/media/libmedia/ToneGenerator.cpp
15f767b960b38059a74a42a33e16d8df2aec8bc1 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/av/media/libmedia/ToneGenerator.cpp
925a349b45d1d16eaaca6a1f4827191831271ca0 20-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@132569
/frameworks/av/media/libmedia/ToneGenerator.cpp
7a2146d5807030b2629f347736be5301b61e8811 13-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@131421
/frameworks/av/media/libmedia/ToneGenerator.cpp
5e07b5774c8b376776caa4f5b0a193767697e97e 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
/frameworks/av/media/libmedia/ToneGenerator.cpp
cce8bd12da6d8419a8770e4552a51ec297c250c2 10-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@125939
/frameworks/av/media/libmedia/ToneGenerator.cpp
7b5eb023f8d87cca6d830ae6c11c6aadbe02aca8 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
/frameworks/av/media/libmedia/ToneGenerator.cpp
2729ea9262ca60d93047e984739887cfc89e82eb 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
/frameworks/av/media/libmedia/ToneGenerator.cpp