summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2009-09-24 07:03:14 -0700
committerEric Laurent <elaurent@google.com>2009-09-24 23:49:40 -0700
commitaf141d529f76a3e3bccf67de798f13568e37f3cf (patch)
treec8a24dad81fa544b9d5c274648514d5bcf57921d /include
parentfdf53a4628f915203752660aa07049aa22c01b5a (diff)
downloadframeworks_base-af141d529f76a3e3bccf67de798f13568e37f3cf.zip
frameworks_base-af141d529f76a3e3bccf67de798f13568e37f3cf.tar.gz
frameworks_base-af141d529f76a3e3bccf67de798f13568e37f3cf.tar.bz2
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.
Diffstat (limited to 'include')
-rw-r--r--include/media/ToneGenerator.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/media/ToneGenerator.h b/include/media/ToneGenerator.h
index ea6bf5d..e8df08e 100644
--- a/include/media/ToneGenerator.h
+++ b/include/media/ToneGenerator.h
@@ -167,7 +167,8 @@ private:
TONE_STARTING, // ToneGenerator is starting playing
TONE_PLAYING, // ToneGenerator is playing
TONE_STOPPING, // ToneGenerator is stoping
- TONE_RESTARTING //
+ TONE_STOPPED, // ToneGenerator is stopped: the AudioTrack will be stopped
+ TONE_RESTARTING // A start request was received in active state (playing or stopping)
};