diff --git a/api/current.xml b/api/current.xml
index 2d13363ef1d0f..c8384e4889216 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -78333,6 +78333,19 @@
visibility="public"
>
+
+
+
+
+
+
GetIntField(thiz,
@@ -48,7 +48,7 @@ static jboolean android_media_ToneGenerator_startTone(JNIEnv *env, jobject thiz,
return false;
}
- return lpToneGen->startTone(toneType);
+ return lpToneGen->startTone(toneType, durationMs);
}
static void android_media_ToneGenerator_stopTone(JNIEnv *env, jobject thiz) {
@@ -120,7 +120,7 @@ static void android_media_ToneGenerator_native_finalize(JNIEnv *env,
// ----------------------------------------------------------------------------
static JNINativeMethod gMethods[] = {
- { "startTone", "(I)Z", (void *)android_media_ToneGenerator_startTone },
+ { "startTone", "(II)Z", (void *)android_media_ToneGenerator_startTone },
{ "stopTone", "()V", (void *)android_media_ToneGenerator_stopTone },
{ "release", "()V", (void *)android_media_ToneGenerator_release },
{ "native_setup", "(II)V", (void *)android_media_ToneGenerator_native_setup },
diff --git a/include/media/ToneGenerator.h b/include/media/ToneGenerator.h
index eafa661eeee1a..ea6bf5d0b45b1 100644
--- a/include/media/ToneGenerator.h
+++ b/include/media/ToneGenerator.h
@@ -154,7 +154,7 @@ public:
ToneGenerator(int streamType, float volume);
~ToneGenerator();
- bool startTone(int toneType);
+ bool startTone(int toneType, int durationMs = -1);
void stopTone();
bool isInited() { return (mState == TONE_IDLE)?false:true;}
@@ -246,6 +246,7 @@ private:
// NOTE: because mTotalSmp, mNextSegSmp are stored on 32 bit, current design will operate properly
// only if tone duration is less than about 27 Hours(@44100Hz sampling rate). If this time is exceeded,
// no crash will occur but tone sequence will show a glitch.
+ unsigned int mMaxSmp; // Maximum number of audio samples played (maximun tone duration)
unsigned short mCurSegment; // Current segment index in ToneDescriptor segments[]
unsigned short mCurCount; // Current sequence repeat count
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 8cb89c38e7882..e2b6b515ec00e 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -1160,7 +1160,7 @@ AudioFlinger::MixerThread::~MixerThread()
bool AudioFlinger::MixerThread::threadLoop()
{
- unsigned long sleepTime = kBufferRecoveryInUsecs;
+ unsigned long sleepTime = 0;
int16_t* curBuf = mMixBuffer;
Vector< sp