summaryrefslogtreecommitdiffstats
path: root/media/libmedia/ToneGenerator.cpp
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2009-11-04 08:27:26 -0800
committerEric Laurent <elaurent@google.com>2009-11-04 23:47:21 -0800
commit34f1d8ecd23169a5f299937e3aaf1bd7937578a0 (patch)
tree04f5504f74df6dde00b495a95bf30766be12821a /media/libmedia/ToneGenerator.cpp
parentc6c6237a67661c7b2d8822b7360cdf01e64d2c7c (diff)
downloadframeworks_av-34f1d8ecd23169a5f299937e3aaf1bd7937578a0.zip
frameworks_av-34f1d8ecd23169a5f299937e3aaf1bd7937578a0.tar.gz
frameworks_av-34f1d8ecd23169a5f299937e3aaf1bd7937578a0.tar.bz2
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.
Diffstat (limited to 'media/libmedia/ToneGenerator.cpp')
-rw-r--r--media/libmedia/ToneGenerator.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index 91d0d00..60e3d71 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -798,7 +798,7 @@ const unsigned char ToneGenerator::sToneMappingTable[NUM_REGIONS-1][NUM_SUP_TONE
// none
//
////////////////////////////////////////////////////////////////////////////////
-ToneGenerator::ToneGenerator(int streamType, float volume) {
+ToneGenerator::ToneGenerator(int streamType, float volume, bool threadCanCallJava) {
LOGV("ToneGenerator constructor: streamType=%d, volume=%f\n", streamType, volume);
@@ -808,6 +808,7 @@ ToneGenerator::ToneGenerator(int streamType, float volume) {
LOGE("Unable to marshal AudioFlinger");
return;
}
+ mThreadCanCallJava = threadCanCallJava;
mStreamType = streamType;
mVolume = volume;
mpAudioTrack = 0;
@@ -1015,15 +1016,25 @@ bool ToneGenerator::initAudioTrack() {
}
// Open audio track in mono, PCM 16bit, default sampling rate, default buffer size
- mpAudioTrack
- = new AudioTrack(mStreamType, 0, AudioSystem::PCM_16_BIT, AudioSystem::CHANNEL_OUT_MONO, 0, 0, audioCallback, this, 0);
-
+ mpAudioTrack = new AudioTrack();
if (mpAudioTrack == 0) {
LOGE("AudioTrack allocation failed");
goto initAudioTrack_exit;
}
LOGV("Create Track: %p\n", mpAudioTrack);
+ mpAudioTrack->set(mStreamType,
+ 0,
+ AudioSystem::PCM_16_BIT,
+ AudioSystem::CHANNEL_OUT_MONO,
+ 0,
+ 0,
+ audioCallback,
+ this,
+ 0,
+ 0,
+ mThreadCanCallJava);
+
if (mpAudioTrack->initCheck() != NO_ERROR) {
LOGE("AudioTrack->initCheck failed");
goto initAudioTrack_exit;