diff options
-rw-r--r-- | include/media/stagefright/MediaCodecList.h | 6 | ||||
-rw-r--r-- | media/libstagefright/MediaCodecList.cpp | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/include/media/stagefright/MediaCodecList.h b/include/media/stagefright/MediaCodecList.h index 8605d99..c2bbe4d 100644 --- a/include/media/stagefright/MediaCodecList.h +++ b/include/media/stagefright/MediaCodecList.h @@ -52,6 +52,12 @@ struct MediaCodecList : public BnMediaCodecList { static sp<IMediaCodecList> getLocalInstance(); private: + class BinderDeathObserver : public IBinder::DeathRecipient { + void binderDied(const wp<IBinder> &the_late_who __unused); + }; + + static sp<BinderDeathObserver> sBinderDeathObserver; + enum Section { SECTION_TOPLEVEL, SECTION_DECODERS, diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp index 5b8be46..cf6e937 100644 --- a/media/libstagefright/MediaCodecList.cpp +++ b/media/libstagefright/MediaCodecList.cpp @@ -62,6 +62,14 @@ static Mutex sRemoteInitMutex; sp<IMediaCodecList> MediaCodecList::sRemoteList; +sp<MediaCodecList::BinderDeathObserver> MediaCodecList::sBinderDeathObserver; + +void MediaCodecList::BinderDeathObserver::binderDied(const wp<IBinder> &who __unused) { + Mutex::Autolock _l(sRemoteInitMutex); + sRemoteList.clear(); + sBinderDeathObserver.clear(); +} + // static sp<IMediaCodecList> MediaCodecList::getInstance() { Mutex::Autolock _l(sRemoteInitMutex); @@ -72,8 +80,11 @@ sp<IMediaCodecList> MediaCodecList::getInstance() { interface_cast<IMediaPlayerService>(binder); if (service.get() != NULL) { sRemoteList = service->getCodecList(); + if (sRemoteList != NULL) { + sBinderDeathObserver = new BinderDeathObserver(); + binder->linkToDeath(sBinderDeathObserver.get()); + } } - if (sRemoteList == NULL) { // if failed to get remote list, create local list sRemoteList = getLocalInstance(); |