Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06f99521 authored by Lajos Molnar's avatar Lajos Molnar Committed by Android Git Automerger
Browse files

am 2aa82e78: Merge "MediaCodecList: handle binder death" into lmp-mr1-dev

* commit '2aa82e78':
  MediaCodecList: handle binder death
parents a0b3a0a4 2aa82e78
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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,
+12 −1
Original line number Diff line number Diff line
@@ -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();