summaryrefslogtreecommitdiffstats
path: root/media/libmedia/ToneGenerator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* libmedia: Add support for LHR tonesKarthik Reddy Katta2016-01-231-1/+5
| | | | | | | Add tones to the ToneGenerator that are to be used for Local Hold Recall. Change-Id: I92cc1d63a3f6d38fc224774909b5b27d58be969c
* Fix benign overflow in ToneGenerator.cppChad Brubaker2015-12-071-2/+4
| | | | | | | while (count--) causes an unsigned overflow when count = 0, refactor the condition to avoid this. Change-Id: I91a8c93e6be715d80070a4c94c1de712cb659265
* ToneGenerator: Limit tones to 48kHaynes Mathew George2015-10-061-1/+7
| | | | | | | | | DTMF tones are played at the hardware module sampling rate. Until now, this rate was limited to 48k. Tones sound not too pleasant at higher rates (like 96k and 192k). Ergo, limit the rate to 48k. Change-Id: I7fbc3185d988628ce3ee478076a322857221dece
* libmedia: fix all warning, make warnings errors, use clangLajos Molnar2015-04-171-1/+0
| | | | Change-Id: Ic00d2c5d0bbb1605e96666e25c9ccc22bea6d3ff
* Use standard syntax to initialize fields.Chih-Hung Hsieh2014-11-141-712/+712
| | | | | | | Clang compiler gives warning to old gnu syntax. BUG: 18193625 Change-Id: I1b5237d60866fc357fc808f6a6955ab20418a7d8
* Use symbolic constants from <system/audio.h>Glenn Kasten2014-03-251-1/+1
| | | | | | | | AUDIO_INTERLEAVE_* AUDIO_STREAM_MIN AUDIO_SESSION_ALLOCATE Change-Id: I31dd6f327204685e50716079ce21c4ba206dff11
* Include what is neededGlenn Kasten2013-07-021-4/+0
| | | | | | | Remove old includes. Header files only include other header files that they directly need themselves. Change-Id: Ic471386808d9f42ea19ccbd59cb50a5f83a89dd0
* New control block for AudioTrack and AudioRecordGlenn Kasten2013-06-121-1/+3
| | | | | | | | 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
* Use sp<AudioTrack> instead of raw AudioTrack *Glenn Kasten2013-06-031-15/+7
| | | | | | | | | | | | | | | | | | | | | 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
* Fix unreleased mutex in ToneGenerator stopTone()Eric Laurent2013-05-131-0/+1
| | | | | | | | Commit 09108ade introduced a regression by not releasing the ToneGenerator mutex before exiting in case of error. Bug: 8852855 Change-Id: I8ba2755b218842e2034ed8dbd54b18bf2a5fc571
* ToneGenerator: fix overflow in stopToneEric Laurent2013-03-281-2/+2
| | | | | | | | | Fix overflow in tone duration calculation introduced in commit 681be039. Bug 6607077 Change-Id: Ie12f13701345c2b2d3be0b3c4d71cbfa2394a29b
* ToneGenerator: fix truncated tonesEric Laurent2013-03-271-1/+31
| | | | | | | | | | | | | | | | | | | | 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
* ToneGenerator: fix stop/destroy concurrencyEric Laurent2013-03-261-5/+10
| | | | | | | | | | | | | | | | | | | | | 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
* ToneGenerator: fix AudioTrack pointer initEric Laurent2013-03-261-1/+1
| | | | | | | | | | 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
* ToneGenerator: optimize silent toneEric Laurent2013-03-251-1/+5
| | | | | | | | | Do not create an AudioTrack and start playback when a silent tone is requested to ToneGenerator. Bug 7946399 Change-Id: Ib9282871a56f7a862af7d1504ce3fbd7c18e34e2
* Add all-channel AudioTrack::setVolume() APIGlenn Kasten2012-11-051-1/+1
| | | | | | | Add combined channel APIs setVolume to AudioTrack, and remove obsolete getVolume. Change-Id: I0c87bfdbff4f4292259fa33e65f67badbafd270b
* Re-enable fast track for ToneGeneratorGlenn Kasten2012-04-301-1/+1
| | | | Change-Id: If4152169778df124c750dc45023322ee23c80587
* Fix ToneGenerator regressionGlenn Kasten2012-04-231-1/+1
| | | | | Bug: 6378847 Change-Id: Ib3324c7a5951ac95f99993bfae27ea02bfda08ff
* rename audio policy output flagsEric Laurent2012-04-181-1/+1
| | | | Change-Id: I27c46bd1d1b2b5f96b87af7d05b951fef18a1312
* ToneGenerator requests fast trackGlenn Kasten2012-04-161-6/+6
| | | | | | Also add comments to AudioTrack::set() parameter list Change-Id: I28c76e9d813778d86b15d75cf7f01a17c258b6d9
* Whitespace and indentationGlenn Kasten2012-03-131-6/+5
| | | | | | | | | | | | | | 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
* Use audio_policy_output_flags_t consistentlyGlenn Kasten2012-03-091-1/+1
| | | | | | | | | | This affects: - IAudioFlinger::openOutput - AudioTrack::AudioTrack - AudioTrack::set - apps that call these Change-Id: I26fb281bac6cb87593d17697bc9cb37a835af205
* Update commentsGlenn Kasten2012-02-141-1/+1
| | | | | | We no longer put the filename at start of file. Change-Id: Ic435b159a23105681e3d4a6cb1ac097bc853302e
* Follow raw pointer and sp<> conventionsGlenn Kasten2012-02-101-1/+1
| | | | | | | | 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
* No newline or space at end of ALOG format stringGlenn Kasten2012-02-081-29/+29
| | | | Change-Id: I0bef580cbc818cb7c87aea23919d26f1446cec32
* Merge "Use ToneGenerator::tone_type consistently"Glenn Kasten2012-02-031-5/+5
|\
| * Use ToneGenerator::tone_type consistentlyGlenn Kasten2012-01-271-5/+5
| | | | | | | | | | | | | | Also remove defaults in startToneCommand(), they're not needed and the default for tone type was nonsense. Change-Id: I70fa8cee4f3dbb8c66ceb3719c8d3d2f447f05b9
* | Use NULL not 0 for raw pointersGlenn Kasten2012-02-031-7/+7
|/ | | | | | Use if (p != NULL) instead of if (ptr) Change-Id: Iaec3413a59ccbf233c98fcd918cc7d70ac5da9fa
* Use audio_stream_type_t consistentlyGlenn Kasten2012-01-131-1/+1
| | | | | | | | | 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
* libmedia new can't fail on AndroidGlenn Kasten2012-01-111-13/+0
| | | | Change-Id: Ie79dd5abb8078b35474bf0f1b3a6ff994a3a3360
* Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGESteve Block2012-01-081-7/+7
| | | | | | | See https://android-git.corp.google.com/g/#/c/157220 Bug: 5449033 Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
* Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGESteve Block2012-01-061-2/+2
| | | | | | | See https://android-git.corp.google.com/g/157065 Bug: 5449033 Change-Id: I00a4b904f9449e6f93b7fd35eac28640d7929e69
* Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGESteve Block2011-10-261-41/+41
| | | | | | | See https://android-git.corp.google.com/g/#/c/143865 Bug: 5449033 Change-Id: I0122812ed6ff6f5b59fe4a43ab8bff0577adde0a
* Remove unneeded #include <sys/resource.h>Glenn Kasten2011-06-151-1/+0
| | | | | | Suggested in code review for previous change. Change-Id: Ic3225b240367dc6c9bf56fb4498fb8a0f9f806ec
* Revert "Use AudioTrack::event_type not int in callback"Glenn Kasten2011-06-011-1/+1
| | | This reverts commit 2225e4b7049fa3fb9d39a068b8268b63c952d7c1
* Use AudioTrack::event_type not int in callbackGlenn Kasten2011-06-011-1/+1
| | | | Change-Id: Ifefc708d46874e04fd0d01cb6e2d43b987ee796c
* audio/media: convert to using the audio HAL and new audio defsDima Zavin2011-04-271-2/+2
| | | | | Change-Id: Ibc637918637329e4f2b62f4ac7781102fbc269f5 Signed-off-by: Dima Zavin <dima@android.com>
* Media/ToneGenerator: Change tone format for TONE_CDMA_ANSWERNaveen Kalla2009-12-031-1/+2
| | | | | Tone format for TONE_CDMA_ANSWER should be 660Hz + 1000Hz, with a 500ms ON duration.
* Fix issue 2203561: Sholes: audio playing out of earpiece.Eric Laurent2009-11-041-4/+15
| | | | | | | | | | | 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.
* Fix 2209967 Tonegenerator: mutex not release in startTone() upon timeout ↵Eric Laurent2009-10-231-4/+6
| | | | | | | 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.
* Fix issue 2139634: DTMF tones on Sholes popping, hissing (audio latency too ↵Eric Laurent2009-10-061-11/+23
| | | | | | | | | | 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.
* Fix issue 2142613: ToneGenerator: short tones sometimes don't play on sholes ↵Eric Laurent2009-09-241-8/+19
| | | | | | | | | | 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.
* Fix issue 1992233: DTMF tones on Sholes is really long.Eric Laurent2009-09-081-5/+24
| | | | | 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.
* Fix issue 2045983 ToneGenerator: fix void statement.Eric Laurent2009-08-111-1/+1
| | | | | 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.
* Fix issue 1795088 Improve audio routing codeEric Laurent2009-07-231-1/+1
| | | | | | | 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()
* Fix issue 1946033: dialer deadlocks and/or ANRs when using dialpad in-callEric Laurent2009-07-091-0/+2
| | | | | | 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.
* Fill in CDMA gaps and clean up ToneGenerator codeDavid Krause2009-06-231-135/+681
|
* Don't allow negative numbers in ToneGenerator toneType parameterDave Sparks2009-05-071-1/+1
| | | | Bug 1836596
* Fixed issue 1709450: Requirements for CDMA Tone GeneratorEric Laurent2009-05-061-85/+342
| | | | | | | | | | 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
* auto import from //branches/cupcake/...@137197The Android Open Source Project2009-03-091-4/+8
|