summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2012-01-04 17:39:12 -0800
committerEric Laurent <elaurent@google.com>2012-01-04 17:39:12 -0800
commit7ab41c9f773ba599646f1b0d00955c1be80f92fd (patch)
tree02a8e0276a550d6748b64e6b4e165dd562712859
parentb8a805261bf0282e992d3608035e47d05a898710 (diff)
parentfe0698f9d44ca923ff1ba528f2c42019937ea5e2 (diff)
downloadframeworks_av-7ab41c9f773ba599646f1b0d00955c1be80f92fd.zip
frameworks_av-7ab41c9f773ba599646f1b0d00955c1be80f92fd.tar.gz
frameworks_av-7ab41c9f773ba599646f1b0d00955c1be80f92fd.tar.bz2
resolved conflicts for merge of 1a4b9939 to master
Change-Id: I0c910d391a38a916d8431f7d1f5b82e39e1a66c2
-rw-r--r--services/audioflinger/AudioFlinger.cpp10
-rw-r--r--services/audioflinger/AudioMixer.cpp17
-rw-r--r--services/audioflinger/AudioMixer.h3
-rw-r--r--services/audioflinger/AudioResampler.h1
4 files changed, 30 insertions, 1 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 275de77..d055a8e 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2118,7 +2118,15 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track
if (t->sampleRate() == (int)mSampleRate) {
minFrames = mFrameCount;
} else {
- minFrames = (mFrameCount * t->sampleRate()) / mSampleRate + 1;
+ // +1 for rounding and +1 for additional sample needed for interpolation
+ minFrames = (mFrameCount * t->sampleRate()) / mSampleRate + 1 + 1;
+ // add frames already consumed but not yet released by the resampler
+ // because cblk->framesReady() will include these frames
+ minFrames += mAudioMixer->getUnreleasedFrames(track->name());
+ // the minimum track buffer size is normally twice the number of frames necessary
+ // to fill one buffer and the resampler should not leave more than one buffer worth
+ // of unreleased frames after each pass, but just in case...
+ LOG_ASSERT(minFrames <= cblk->frameCount);
}
}
if ((cblk->framesReady() >= minFrames) && track->isReady() &&
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index dc1d1a7..d230d27 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -329,6 +329,23 @@ void AudioMixer::track_t::adjustVolumeRamp(bool aux)
}
}
+size_t AudioMixer::track_t::getUnreleasedFrames()
+{
+ if (resampler != NULL) {
+ return resampler->getUnreleasedFrames();
+ }
+ return 0;
+}
+
+size_t AudioMixer::getUnreleasedFrames(int name)
+{
+ name -= TRACK0;
+ if (uint32_t(name) < MAX_NUM_TRACKS) {
+ track_t& track(mState.tracks[name]);
+ return track.getUnreleasedFrames();
+ }
+ return 0;
+}
void AudioMixer::setBufferProvider(AudioBufferProvider* buffer)
{
diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h
index 70464fc..8ba5073 100644
--- a/services/audioflinger/AudioMixer.h
+++ b/services/audioflinger/AudioMixer.h
@@ -88,6 +88,8 @@ public:
uint32_t trackNames() const { return mTrackNames; }
+ size_t getUnreleasedFrames(int name);
+
private:
enum {
@@ -159,6 +161,7 @@ private:
bool doesResample() const;
void resetResampler();
void adjustVolumeRamp(bool aux);
+ size_t getUnreleasedFrames();
};
// pad to 32-bytes to fill cache line
diff --git a/services/audioflinger/AudioResampler.h b/services/audioflinger/AudioResampler.h
index 9f06c1c..ffa690a 100644
--- a/services/audioflinger/AudioResampler.h
+++ b/services/audioflinger/AudioResampler.h
@@ -54,6 +54,7 @@ public:
AudioBufferProvider* provider) = 0;
virtual void reset();
+ virtual size_t getUnreleasedFrames() { return mInputIndex; }
protected:
// number of bits for phase fraction - 30 bits allows nearly 2x downsampling