diff options
author | Mike Lockwood <lockwood@android.com> | 2011-01-25 15:20:04 -0800 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2011-01-25 15:20:04 -0800 |
commit | 0a095d09464ba18e288a3f529410af0f1257ac2a (patch) | |
tree | 1c3810dbf07e83724c4d11cb012dd664669a8623 | |
parent | 4feffd1a8d95cf3843c06a37160580d30d421d8e (diff) | |
download | frameworks_av-0a095d09464ba18e288a3f529410af0f1257ac2a.zip frameworks_av-0a095d09464ba18e288a3f529410af0f1257ac2a.tar.gz frameworks_av-0a095d09464ba18e288a3f529410af0f1257ac2a.tar.bz2 |
StagefrightMediaScanner: Close metadata retriever after we are done scanning
This prevents the mediaserver from leaking a file descriptor after
the media scanner runs
BUG: 3373546
Change-Id: I82a8bae82306de3da56a5c7da5b03ecf106a4efc
Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r-- | include/media/stagefright/StagefrightMediaScanner.h | 4 | ||||
-rw-r--r-- | media/libstagefright/StagefrightMediaScanner.cpp | 67 |
2 files changed, 35 insertions, 36 deletions
diff --git a/include/media/stagefright/StagefrightMediaScanner.h b/include/media/stagefright/StagefrightMediaScanner.h index 4437eee..108acb4 100644 --- a/include/media/stagefright/StagefrightMediaScanner.h +++ b/include/media/stagefright/StagefrightMediaScanner.h @@ -22,8 +22,6 @@ namespace android { -struct MediaMetadataRetriever; - struct StagefrightMediaScanner : public MediaScanner { StagefrightMediaScanner(); virtual ~StagefrightMediaScanner(); @@ -35,8 +33,6 @@ struct StagefrightMediaScanner : public MediaScanner { virtual char *extractAlbumArt(int fd); private: - sp<MediaMetadataRetriever> mRetriever; - StagefrightMediaScanner(const StagefrightMediaScanner &); StagefrightMediaScanner &operator=(const StagefrightMediaScanner &); }; diff --git a/media/libstagefright/StagefrightMediaScanner.cpp b/media/libstagefright/StagefrightMediaScanner.cpp index 39b0021..be3df7c 100644 --- a/media/libstagefright/StagefrightMediaScanner.cpp +++ b/media/libstagefright/StagefrightMediaScanner.cpp @@ -28,9 +28,7 @@ namespace android { -StagefrightMediaScanner::StagefrightMediaScanner() - : mRetriever(new MediaMetadataRetriever) { -} +StagefrightMediaScanner::StagefrightMediaScanner() {} StagefrightMediaScanner::~StagefrightMediaScanner() {} @@ -131,37 +129,41 @@ status_t StagefrightMediaScanner::processFile( if (status != OK) { return status; } - } else if (mRetriever->setDataSource(path) == OK) { - const char *value; - if ((value = mRetriever->extractMetadata( - METADATA_KEY_MIMETYPE)) != NULL) { - client.setMimeType(value); - } + } else { + sp<MediaMetadataRetriever> mRetriever(new MediaMetadataRetriever); - struct KeyMap { - const char *tag; - int key; - }; - static const KeyMap kKeyMap[] = { - { "tracknumber", METADATA_KEY_CD_TRACK_NUMBER }, - { "discnumber", METADATA_KEY_DISC_NUMBER }, - { "album", METADATA_KEY_ALBUM }, - { "artist", METADATA_KEY_ARTIST }, - { "albumartist", METADATA_KEY_ALBUMARTIST }, - { "composer", METADATA_KEY_COMPOSER }, - { "genre", METADATA_KEY_GENRE }, - { "title", METADATA_KEY_TITLE }, - { "year", METADATA_KEY_YEAR }, - { "duration", METADATA_KEY_DURATION }, - { "writer", METADATA_KEY_WRITER }, - { "compilation", METADATA_KEY_COMPILATION }, - }; - static const size_t kNumEntries = sizeof(kKeyMap) / sizeof(kKeyMap[0]); - - for (size_t i = 0; i < kNumEntries; ++i) { + if (mRetriever->setDataSource(path) == OK) { const char *value; - if ((value = mRetriever->extractMetadata(kKeyMap[i].key)) != NULL) { - client.addStringTag(kKeyMap[i].tag, value); + if ((value = mRetriever->extractMetadata( + METADATA_KEY_MIMETYPE)) != NULL) { + client.setMimeType(value); + } + + struct KeyMap { + const char *tag; + int key; + }; + static const KeyMap kKeyMap[] = { + { "tracknumber", METADATA_KEY_CD_TRACK_NUMBER }, + { "discnumber", METADATA_KEY_DISC_NUMBER }, + { "album", METADATA_KEY_ALBUM }, + { "artist", METADATA_KEY_ARTIST }, + { "albumartist", METADATA_KEY_ALBUMARTIST }, + { "composer", METADATA_KEY_COMPOSER }, + { "genre", METADATA_KEY_GENRE }, + { "title", METADATA_KEY_TITLE }, + { "year", METADATA_KEY_YEAR }, + { "duration", METADATA_KEY_DURATION }, + { "writer", METADATA_KEY_WRITER }, + { "compilation", METADATA_KEY_COMPILATION }, + }; + static const size_t kNumEntries = sizeof(kKeyMap) / sizeof(kKeyMap[0]); + + for (size_t i = 0; i < kNumEntries; ++i) { + const char *value; + if ((value = mRetriever->extractMetadata(kKeyMap[i].key)) != NULL) { + client.addStringTag(kKeyMap[i].tag, value); + } } } } @@ -180,6 +182,7 @@ char *StagefrightMediaScanner::extractAlbumArt(int fd) { } lseek64(fd, 0, SEEK_SET); + sp<MediaMetadataRetriever> mRetriever(new MediaMetadataRetriever); if (mRetriever->setDataSource(fd, 0, size) == OK) { sp<IMemory> mem = mRetriever->extractAlbumArt(); |