summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-05-12 07:49:31 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-05-12 07:49:31 -0700
commit227e443a43d70b9463b2e685688f73cfb1b72096 (patch)
tree228fd3775bc9ba2d038b702ff2723975a2f3047c /media
parent625de488973f262e56d3ee6825a8cf1ebaee089b (diff)
parentd6ad7c85faf55fa8d0459f0fbc4fa32abdfefb6e (diff)
downloadframeworks_base-227e443a43d70b9463b2e685688f73cfb1b72096.zip
frameworks_base-227e443a43d70b9463b2e685688f73cfb1b72096.tar.gz
frameworks_base-227e443a43d70b9463b2e685688f73cfb1b72096.tar.bz2
am d6ad7c85: Merge "Better seek handling and proper reset of the vorbis decoder after a discontinuity (seek)" into froyo
Merge commit 'd6ad7c85faf55fa8d0459f0fbc4fa32abdfefb6e' into froyo-plus-aosp * commit 'd6ad7c85faf55fa8d0459f0fbc4fa32abdfefb6e': Better seek handling and proper reset of the vorbis decoder after a discontinuity (seek)
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/OggExtractor.cpp13
-rw-r--r--media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp18
2 files changed, 22 insertions, 9 deletions
diff --git a/media/libstagefright/OggExtractor.cpp b/media/libstagefright/OggExtractor.cpp
index 699b955..d0d1b14 100644
--- a/media/libstagefright/OggExtractor.cpp
+++ b/media/libstagefright/OggExtractor.cpp
@@ -94,6 +94,8 @@ private:
size_t mCurrentPageSize;
size_t mNextLaceIndex;
+ off_t mFirstDataOffset;
+
vorbis_info mVi;
vorbis_comment mVc;
@@ -183,7 +185,8 @@ MyVorbisExtractor::MyVorbisExtractor(const sp<DataSource> &source)
: mSource(source),
mOffset(0),
mCurrentPageSize(0),
- mNextLaceIndex(0) {
+ mNextLaceIndex(0),
+ mFirstDataOffset(-1) {
mCurrentPage.mNumSegments = 0;
}
@@ -222,6 +225,12 @@ status_t MyVorbisExtractor::findNextPage(
}
status_t MyVorbisExtractor::seekToOffset(off_t offset) {
+ if (mFirstDataOffset >= 0 && offset < mFirstDataOffset) {
+ // Once we know where the actual audio data starts (past the headers)
+ // don't ever seek to anywhere before that.
+ offset = mFirstDataOffset;
+ }
+
off_t pageOffset;
status_t err = findNextPage(offset, &pageOffset);
@@ -438,6 +447,8 @@ void MyVorbisExtractor::init() {
verifyHeader(packet, 5);
packet->release();
packet = NULL;
+
+ mFirstDataOffset = mOffset + mCurrentPageSize;
}
void MyVorbisExtractor::verifyHeader(
diff --git a/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp b/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp
index 5485f25..df3f16a 100644
--- a/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp
+++ b/media/libstagefright/codecs/vorbis/dec/VorbisDecoder.cpp
@@ -173,18 +173,19 @@ int VorbisDecoder::decodePacket(MediaBuffer *packet, MediaBuffer *out) {
pack.granulepos = 0;
pack.packetno = 0;
+ int numFrames = 0;
+
int err = vorbis_dsp_synthesis(mState, &pack, 1);
if (err != 0) {
LOGW("vorbis_dsp_synthesis returned %d", err);
- return 0;
- }
-
- int numFrames = vorbis_dsp_pcmout(
- mState, (int16_t *)out->data(), kMaxNumSamplesPerBuffer);
+ } else {
+ numFrames = vorbis_dsp_pcmout(
+ mState, (int16_t *)out->data(), kMaxNumSamplesPerBuffer);
- if (numFrames < 0) {
- LOGE("vorbis_dsp_pcmout returned %d", numFrames);
- return 0;
+ if (numFrames < 0) {
+ LOGE("vorbis_dsp_pcmout returned %d", numFrames);
+ numFrames = 0;
+ }
}
out->set_range(0, numFrames * sizeof(int16_t) * mNumChannels);
@@ -203,6 +204,7 @@ status_t VorbisDecoder::read(
CHECK(seekTimeUs >= 0);
mNumFramesOutput = 0;
+ vorbis_dsp_restart(mState);
} else {
seekTimeUs = -1;
}