summaryrefslogtreecommitdiff
path: root/libs/audioflinger/AudioFlinger.cpp
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2010-03-11 14:47:00 -0800
committer Eric Laurent <elaurent@google.com> 2010-03-16 17:32:18 -0700
commitef9500fe53b6ec67b610207832b52f8bfbb20cd5 (patch)
tree00a5eea1602d0a358603b0d4e741b0b51f2a36b5 /libs/audioflinger/AudioFlinger.cpp
parent1a3786a3e34112e3e68e6a9b07ba72802867a002 (diff)
Fix issue 2416481: Support Voice Dialer over BT SCO.
- AudioPolicyManager: allow platform specific choice for opening a direct output. Also fixed problems in direct output management. - AudioFliinger: use shorter standby delay and track inactivity grace period for direct output thread to free hardware resources as soon as possible. - AudioSystem: do not use cached output selection in getOutput() when a direct output can be selected. Change-Id: If44b50d29237b8402ffd7a5ba1dc43c56f903e9b
Diffstat (limited to 'libs/audioflinger/AudioFlinger.cpp')
-rw-r--r--libs/audioflinger/AudioFlinger.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 790221285517..815a36737ef9 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -72,6 +72,10 @@ static const float MAX_GAIN = 4096.0f;
// 50 * ~20msecs = 1 second
static const int8_t kMaxTrackRetries = 50;
static const int8_t kMaxTrackStartupRetries = 50;
+// allow less retry attempts on direct output thread.
+// direct outputs can be a scarce resource in audio hardware and should
+// be released as quickly as possible.
+static const int8_t kMaxTrackRetriesDirect = 2;
static const int kDumpLockRetries = 50;
static const int kDumpLockSleep = 20000;
@@ -1794,6 +1798,9 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
uint32_t activeSleepTime = activeSleepTimeUs();
uint32_t idleSleepTime = idleSleepTimeUs();
uint32_t sleepTime = idleSleepTime;
+ // use shorter standby delay as on normal output to release
+ // hardware resources as soon as possible
+ nsecs_t standbyDelay = microseconds(activeSleepTime*2);
while (!exitPending())
@@ -1810,6 +1817,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
mixBufferSize = mFrameCount*mFrameSize;
activeSleepTime = activeSleepTimeUs();
idleSleepTime = idleSleepTimeUs();
+ standbyDelay = microseconds(activeSleepTime*2);
}
// put audio hardware into standby after short delay
@@ -1842,7 +1850,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
}
}
- standbyTime = systemTime() + kStandbyTimeInNsecs;
+ standbyTime = systemTime() + standbyDelay;
sleepTime = idleSleepTime;
continue;
}
@@ -1896,7 +1904,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
}
// reset retry count
- track->mRetryCount = kMaxTrackRetries;
+ track->mRetryCount = kMaxTrackRetriesDirect;
activeTrack = t;
mixerStatus = MIXER_TRACKS_READY;
} else {
@@ -1949,7 +1957,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
activeTrack->releaseBuffer(&buffer);
}
sleepTime = 0;
- standbyTime = systemTime() + kStandbyTimeInNsecs;
+ standbyTime = systemTime() + standbyDelay;
} else {
if (sleepTime == 0) {
if (mixerStatus == MIXER_TRACKS_ENABLED) {