summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2011-10-26 11:22:40 -0700
committerAndreas Huber <andih@google.com>2011-10-26 12:35:03 -0700
commitd2b76d707bcc93855336f0729697df9555c469fb (patch)
tree98fb70fefcb4c289c1743e0f23cf22d07baf1371 /media/libstagefright
parent3c5b65c95ea4814cbf9c0a3904a9ee13cf41d5c3 (diff)
downloadframeworks_base-d2b76d707bcc93855336f0729697df9555c469fb.zip
frameworks_base-d2b76d707bcc93855336f0729697df9555c469fb.tar.gz
frameworks_base-d2b76d707bcc93855336f0729697df9555c469fb.tar.bz2
Fix a reference to a stale pointer in AwesomePlayer.
The pointer returned by MetaData::findCString may become stale if the metadata object is modified. Make a copy of the returned mime type in order to prevent MediaPlayer::dump log corruption. Change-Id: I9077aee36c4316d83b37fb909bf91e6b3f75d5d2
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/AwesomePlayer.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 1c7e58d..f37e75b 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -385,10 +385,12 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
for (size_t i = 0; i < extractor->countTracks(); ++i) {
sp<MetaData> meta = extractor->getTrackMetaData(i);
- const char *mime;
- CHECK(meta->findCString(kKeyMIMEType, &mime));
+ const char *_mime;
+ CHECK(meta->findCString(kKeyMIMEType, &_mime));
- if (!haveVideo && !strncasecmp(mime, "video/", 6)) {
+ String8 mime = String8(_mime);
+
+ if (!haveVideo && !strncasecmp(mime.string(), "video/", 6)) {
setVideoSource(extractor->getTrack(i));
haveVideo = true;
@@ -409,9 +411,9 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
mStats.mTracks.push();
TrackStat *stat =
&mStats.mTracks.editItemAt(mStats.mVideoTrackIndex);
- stat->mMIME = mime;
+ stat->mMIME = mime.string();
}
- } else if (!haveAudio && !strncasecmp(mime, "audio/", 6)) {
+ } else if (!haveAudio && !strncasecmp(mime.string(), "audio/", 6)) {
setAudioSource(extractor->getTrack(i));
haveAudio = true;
@@ -421,10 +423,10 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
mStats.mTracks.push();
TrackStat *stat =
&mStats.mTracks.editItemAt(mStats.mAudioTrackIndex);
- stat->mMIME = mime;
+ stat->mMIME = mime.string();
}
- if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_VORBIS)) {
+ if (!strcasecmp(mime.string(), MEDIA_MIMETYPE_AUDIO_VORBIS)) {
// Only do this for vorbis audio, none of the other audio
// formats even support this ringtone specific hack and
// retrieving the metadata on some extractors may turn out
@@ -436,7 +438,7 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
modifyFlags(AUTO_LOOPING, SET);
}
}
- } else if (!strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP)) {
+ } else if (!strcasecmp(mime.string(), MEDIA_MIMETYPE_TEXT_3GPP)) {
addTextSource(extractor->getTrack(i));
}
}