summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2010-09-10 17:44:44 -0700
committerEric Laurent <elaurent@google.com>2010-09-13 09:08:28 -0700
commite0aed6ddcb4e3c301b80aa26706b6052dab42c41 (patch)
tree4a85e38eefe3ad4ac70ca1b182660aefacc07658 /services
parenta1754133ee6640346b5fd6daa4666f5d2285379a (diff)
downloadframeworks_av-e0aed6ddcb4e3c301b80aa26706b6052dab42c41.zip
frameworks_av-e0aed6ddcb4e3c301b80aa26706b6052dab42c41.tar.gz
frameworks_av-e0aed6ddcb4e3c301b80aa26706b6052dab42c41.tar.bz2
Fix volume problems with insert revert
- Use a constant input level to the reverb engine and implement volume control in the insert reverb. This avoids the volume spikes when an effect that was inserted after the reverb is disabled or removed. - Fix clicks (one silent buffer) at the end of the reverb disable period. - Modified volume management in audioflinger so that the volume ramp is also done by the insert effect if present when the track is paused (avoids clicks). - Increased room level for all presets. Also fixed problems with output stage session (-1): - effect bundle wrapper was not designed to support session -1 - the permission check in audioflinger for using session -1 failed due to a wrong usage of getCallingPid() Change-Id: Id1ff51327263364bf71d3f2668fa5cde4311d84f
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/AudioFlinger.cpp60
1 files changed, 31 insertions, 29 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 3770b55..886c25b 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1752,14 +1752,15 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
}
// compute volume for this track
- int16_t left, right, aux;
+ uint32_t vl, vr, va;
if (track->isMuted() || track->isPausing() ||
mStreamTypes[track->type()].mute) {
- left = right = aux = 0;
+ vl = vr = va = 0;
if (track->isPausing()) {
track->setPaused();
}
} else {
+
// read original volumes with volume control
float typeVolume = mStreamTypes[track->type()].volume;
#ifdef LVMX
@@ -1774,36 +1775,37 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
}
#endif
float v = masterVolume * typeVolume;
- uint32_t vl = (uint32_t)(v * cblk->volume[0]) << 12;
- uint32_t vr = (uint32_t)(v * cblk->volume[1]) << 12;
+ vl = (uint32_t)(v * cblk->volume[0]) << 12;
+ vr = (uint32_t)(v * cblk->volume[1]) << 12;
- // Delegate volume control to effect in track effect chain if needed
- if (chain != 0 && chain->setVolume_l(&vl, &vr)) {
- // Do not ramp volume is volume is controlled by effect
+ va = (uint32_t)(v * cblk->sendLevel);
+ }
+ // Delegate volume control to effect in track effect chain if needed
+ if (chain != 0 && chain->setVolume_l(&vl, &vr)) {
+ // Do not ramp volume if volume is controlled by effect
+ param = AudioMixer::VOLUME;
+ track->mHasVolumeController = true;
+ } else {
+ // force no volume ramp when volume controller was just disabled or removed
+ // from effect chain to avoid volume spike
+ if (track->mHasVolumeController) {
param = AudioMixer::VOLUME;
- track->mHasVolumeController = true;
- } else {
- // force no volume ramp when volume controller was just disabled or removed
- // from effect chain to avoid volume spike
- if (track->mHasVolumeController) {
- param = AudioMixer::VOLUME;
- }
- track->mHasVolumeController = false;
}
-
- // Convert volumes from 8.24 to 4.12 format
- uint32_t v_clamped = (vl + (1 << 11)) >> 12;
- if (v_clamped > MAX_GAIN_INT) v_clamped = MAX_GAIN_INT;
- left = int16_t(v_clamped);
- v_clamped = (vr + (1 << 11)) >> 12;
- if (v_clamped > MAX_GAIN_INT) v_clamped = MAX_GAIN_INT;
- right = int16_t(v_clamped);
-
- v_clamped = (uint32_t)(v * cblk->sendLevel);
- if (v_clamped > MAX_GAIN_INT) v_clamped = MAX_GAIN_INT;
- aux = int16_t(v_clamped);
+ track->mHasVolumeController = false;
}
+ // Convert volumes from 8.24 to 4.12 format
+ int16_t left, right, aux;
+ uint32_t v_clamped = (vl + (1 << 11)) >> 12;
+ if (v_clamped > MAX_GAIN_INT) v_clamped = MAX_GAIN_INT;
+ left = int16_t(v_clamped);
+ v_clamped = (vr + (1 << 11)) >> 12;
+ if (v_clamped > MAX_GAIN_INT) v_clamped = MAX_GAIN_INT;
+ right = int16_t(v_clamped);
+
+ if (va > MAX_GAIN_INT) va = MAX_GAIN_INT;
+ aux = int16_t(va);
+
#ifdef LVMX
if ( tracksConnectedChanged || stateChanged )
{
@@ -2283,7 +2285,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
// only one effect chain can be present on DirectOutputThread, so if
// there is one, the track is connected to it
if (!effectChains.isEmpty()) {
- // Do not ramp volume is volume is controlled by effect
+ // Do not ramp volume if volume is controlled by effect
if(effectChains[0]->setVolume_l(&vl, &vr)) {
rampVolume = false;
}
@@ -4728,7 +4730,7 @@ sp<IEffect> AudioFlinger::createEffect(pid_t pid,
// Session AudioSystem::SESSION_OUTPUT_STAGE is reserved for output stage effects
// that can only be created by audio policy manager (running in same process)
if (sessionId == AudioSystem::SESSION_OUTPUT_STAGE &&
- getpid() != IPCThreadState::self()->getCallingPid()) {
+ getpid() != pid) {
lStatus = INVALID_OPERATION;
goto Exit;
}