summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-09-09 13:48:53 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-09 13:48:53 -0700
commit1432a0075c0f638206a8e59e33cc81d5caea4bcf (patch)
treef5a6717734c6a5bf5bf184beb98ef9e11afafc58
parent9b2cef27bbe953c0b5c37ada9bf18d706c396513 (diff)
parent84cd8adafe0bbfc1af775c9d9a69ec988cb05714 (diff)
downloadframeworks_av-1432a0075c0f638206a8e59e33cc81d5caea4bcf.zip
frameworks_av-1432a0075c0f638206a8e59e33cc81d5caea4bcf.tar.gz
frameworks_av-1432a0075c0f638206a8e59e33cc81d5caea4bcf.tar.bz2
am f0eab98c: am a063cd64: Merge "Instead of asserting, publish no tracks if an MP3Extractor is used on non-mp3 content." into gingerbread
Merge commit 'f0eab98c4ef7449eb5a5ef659cd794e0003216b3' * commit 'f0eab98c4ef7449eb5a5ef659cd794e0003216b3': Instead of asserting, publish no tracks if an MP3Extractor is used on non-mp3 content.
-rw-r--r--media/libstagefright/MP3Extractor.cpp76
-rw-r--r--media/libstagefright/include/MP3Extractor.h5
2 files changed, 41 insertions, 40 deletions
diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp
index 2e36968..82c0426 100644
--- a/media/libstagefright/MP3Extractor.cpp
+++ b/media/libstagefright/MP3Extractor.cpp
@@ -459,7 +459,8 @@ private:
MP3Extractor::MP3Extractor(
const sp<DataSource> &source, const sp<AMessage> &meta)
- : mDataSource(source),
+ : mInitCheck(NO_INIT),
+ mDataSource(source),
mFirstFramePos(-1),
mFixedHeader(0),
mByteNumber(0) {
@@ -480,53 +481,54 @@ MP3Extractor::MP3Extractor(
success = true;
} else {
success = Resync(mDataSource, 0, &pos, &header);
- CHECK(success);
}
- if (success) {
- mFirstFramePos = pos;
- mFixedHeader = header;
-
- size_t frame_size;
- int sample_rate;
- int num_channels;
- int bitrate;
- get_mp3_frame_size(
- header, &frame_size, &sample_rate, &num_channels, &bitrate);
-
- mMeta = new MetaData;
+ if (!success) {
+ // mInitCheck will remain NO_INIT
+ return;
+ }
- mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG);
- mMeta->setInt32(kKeySampleRate, sample_rate);
- mMeta->setInt32(kKeyBitRate, bitrate * 1000);
- mMeta->setInt32(kKeyChannelCount, num_channels);
+ mFirstFramePos = pos;
+ mFixedHeader = header;
- int64_t duration;
- parse_xing_header(
- mDataSource, mFirstFramePos, NULL, &mByteNumber,
- mTableOfContents, NULL, &duration);
- if (duration > 0) {
- mMeta->setInt64(kKeyDuration, duration);
- } else {
- off_t fileSize;
- if (mDataSource->getSize(&fileSize) == OK) {
- mMeta->setInt64(
- kKeyDuration,
- 8000LL * (fileSize - mFirstFramePos) / bitrate);
- }
+ size_t frame_size;
+ int sample_rate;
+ int num_channels;
+ int bitrate;
+ get_mp3_frame_size(
+ header, &frame_size, &sample_rate, &num_channels, &bitrate);
+
+ mMeta = new MetaData;
+
+ mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG);
+ mMeta->setInt32(kKeySampleRate, sample_rate);
+ mMeta->setInt32(kKeyBitRate, bitrate * 1000);
+ mMeta->setInt32(kKeyChannelCount, num_channels);
+
+ int64_t duration;
+ parse_xing_header(
+ mDataSource, mFirstFramePos, NULL, &mByteNumber,
+ mTableOfContents, NULL, &duration);
+ if (duration > 0) {
+ mMeta->setInt64(kKeyDuration, duration);
+ } else {
+ off_t fileSize;
+ if (mDataSource->getSize(&fileSize) == OK) {
+ mMeta->setInt64(
+ kKeyDuration,
+ 8000LL * (fileSize - mFirstFramePos) / bitrate);
}
}
-}
-MP3Extractor::~MP3Extractor() {
+ mInitCheck = OK;
}
size_t MP3Extractor::countTracks() {
- return (mFirstFramePos < 0) ? 0 : 1;
+ return mInitCheck != OK ? 0 : 1;
}
sp<MediaSource> MP3Extractor::getTrack(size_t index) {
- if (mFirstFramePos < 0 || index != 0) {
+ if (mInitCheck != OK || index != 0) {
return NULL;
}
@@ -536,7 +538,7 @@ sp<MediaSource> MP3Extractor::getTrack(size_t index) {
}
sp<MetaData> MP3Extractor::getTrackMetaData(size_t index, uint32_t flags) {
- if (mFirstFramePos < 0 || index != 0) {
+ if (mInitCheck != OK || index != 0) {
return NULL;
}
@@ -713,7 +715,7 @@ status_t MP3Source::read(
sp<MetaData> MP3Extractor::getMetaData() {
sp<MetaData> meta = new MetaData;
- if (mFirstFramePos < 0) {
+ if (mInitCheck != OK) {
return meta;
}
diff --git a/media/libstagefright/include/MP3Extractor.h b/media/libstagefright/include/MP3Extractor.h
index 0e6ccde..30136e7 100644
--- a/media/libstagefright/include/MP3Extractor.h
+++ b/media/libstagefright/include/MP3Extractor.h
@@ -37,10 +37,9 @@ public:
virtual sp<MetaData> getMetaData();
-protected:
- virtual ~MP3Extractor();
-
private:
+ status_t mInitCheck;
+
sp<DataSource> mDataSource;
off_t mFirstFramePos;
sp<MetaData> mMeta;