summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Powers <dylan.kyle.powers@gmail.com>2012-11-27 16:06:38 -0800
committerMarco Nelissen <marcone@google.com>2012-11-29 15:02:00 -0800
commit47c1a5f7c13d82aa8834fd4543bd1d713b97808e (patch)
tree9e9cfea022e716371a5e8d03d4b00a2f579d5d43
parent5dea84c39b5e790315b525009c635806e33c97e0 (diff)
Bug fix for the MediaPlayer::prepare() api.
For an MP3 source, within the prepare command, ID3 tags are checked in search of gapless playback info. This causes problems for streamed sources. If ID3v2 tags aren't present, then a check is done for ID3v1 tags. This results in a read command that asks the cache to jump to the end of the file, and subsequently make an extra http call to request those bytes. For a streamed source, this causes the file to not be downloaded automatically when MediaPlayer::prepare() is called, and causes stuttering and extra buffering time to be needed when start() is finally called. The solution is to ignore the ID3v1 tags as the gapless info would never exist there, and only check for ID3v2 tags. Cherrypicked from external contribution ffd6ffc5429c45577fd8e9f8fa90e79bb91b8a84 b/7638165 Change-Id: I7d1b94cffbfe7c38ca094834dedbc92a58855e20
-rw-r--r--media/libstagefright/MP3Extractor.cpp6
-rw-r--r--media/libstagefright/id3/ID3.cpp4
-rw-r--r--media/libstagefright/include/ID3.h2
3 files changed, 7 insertions, 5 deletions
diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp
index d94054bc..380dab46 100644
--- a/media/libstagefright/MP3Extractor.cpp
+++ b/media/libstagefright/MP3Extractor.cpp
@@ -350,8 +350,10 @@ MP3Extractor::MP3Extractor(
mInitCheck = OK;
- // get iTunes-style gapless info if present
- ID3 id3(mDataSource);
+ // Get iTunes-style gapless info if present.
+ // When getting the id3 tag, skip the V1 tags to prevent the source cache
+ // from being iterated to the end of the file.
+ ID3 id3(mDataSource, true);
if (id3.isValid()) {
ID3::Iterator *com = new ID3::Iterator(id3, "COM");
if (com->done()) {
diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp
index 69274ca4..22c2f5a9 100644
--- a/media/libstagefright/id3/ID3.cpp
+++ b/media/libstagefright/id3/ID3.cpp
@@ -30,7 +30,7 @@ namespace android {
static const size_t kMaxMetadataSize = 3 * 1024 * 1024;
-ID3::ID3(const sp<DataSource> &source)
+ID3::ID3(const sp<DataSource> &source, bool ignoreV1)
: mIsValid(false),
mData(NULL),
mSize(0),
@@ -38,7 +38,7 @@ ID3::ID3(const sp<DataSource> &source)
mVersion(ID3_UNKNOWN) {
mIsValid = parseV2(source);
- if (!mIsValid) {
+ if (!mIsValid && !ignoreV1) {
mIsValid = parseV1(source);
}
}
diff --git a/media/libstagefright/include/ID3.h b/media/libstagefright/include/ID3.h
index 87140084..3028f56a 100644
--- a/media/libstagefright/include/ID3.h
+++ b/media/libstagefright/include/ID3.h
@@ -35,7 +35,7 @@ struct ID3 {
ID3_V2_4,
};
- ID3(const sp<DataSource> &source);
+ ID3(const sp<DataSource> &source, bool ignoreV1 = false);
~ID3();
bool isValid() const;