From 6f7e097ee5a495b224dc64edc64e8fc36eb9ee44 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Mon, 10 Aug 2009 08:15:12 -0700 Subject: [PATCH] Limit AudioFlinger mixer track sampling rate. When changing the audio output stream sampling rate with setParameters() make sure that all tracks have a sampling rate less or equal to 2 times the new output sampling rate. --- libs/audioflinger/AudioFlinger.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp index d019097c5c9d9..2e947d6b7d23c 100644 --- a/libs/audioflinger/AudioFlinger.cpp +++ b/libs/audioflinger/AudioFlinger.cpp @@ -1512,6 +1512,10 @@ bool AudioFlinger::MixerThread::checkForNewParameters_l() int name = getTrackName_l(); if (name < 0) break; mTracks[i]->mName = name; + // limit track sample rate to 2 x new output sample rate + if (mTracks[i]->mCblk->sampleRate > 2 * sampleRate()) { + mTracks[i]->mCblk->sampleRate = 2 * sampleRate(); + } } sendConfigEvent_l(AudioSystem::OUTPUT_CONFIG_CHANGED); }