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

Commit a0c98417 authored by Marco Nelissen's avatar Marco Nelissen Committed by Pawin Vongmasa
Browse files

Notify swcodec crashes too

Bug: 129426284
Test: manual/CTS
Change-Id: I086a2b8253757f941e4dd2e160490cbb59edb627
parent 71028253
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ cc_library_shared {
    ],

    shared_libs: [
        "android.hardware.media.c2@1.0",
        "android.hardware.media.omx@1.0",
        "libbase",
        "libaudioclient",
@@ -21,7 +22,6 @@ cc_library_shared {
        "libdl",
        "libgui",
        "libhidlbase",
        "libhidlmemory",
        "liblog",
        "libmedia",
        "libmedia_omx",
+46 −17
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@

#include <utils/misc.h>

#include <android/hardware/media/omx/1.0/IOmxStore.h>
#include <android/hardware/media/c2/1.0/IComponentStore.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/MemoryHeapBase.h>
@@ -650,17 +652,17 @@ MediaPlayerService::Client::ServiceDeathNotifier::ServiceDeathNotifier(
        const sp<MediaPlayerBase>& listener,
        int which) {
    mService = service;
    mOmx = nullptr;
    mHService = nullptr;
    mListener = listener;
    mWhich = which;
}

MediaPlayerService::Client::ServiceDeathNotifier::ServiceDeathNotifier(
        const sp<IOmx>& omx,
        const sp<android::hidl::base::V1_0::IBase>& hService,
        const sp<MediaPlayerBase>& listener,
        int which) {
    mService = nullptr;
    mOmx = omx;
    mHService = hService;
    mListener = listener;
    mWhich = which;
}
@@ -692,9 +694,9 @@ void MediaPlayerService::Client::ServiceDeathNotifier::unlinkToDeath() {
    if (mService != nullptr) {
        mService->unlinkToDeath(this);
        mService = nullptr;
    } else if (mOmx != nullptr) {
        mOmx->unlinkToDeath(this);
        mOmx = nullptr;
    } else if (mHService != nullptr) {
        mHService->unlinkToDeath(this);
        mHService = nullptr;
    }
}

@@ -714,11 +716,13 @@ void MediaPlayerService::Client::clearDeathNotifiers_l() {
        mExtractorDeathListener->unlinkToDeath();
        mExtractorDeathListener = nullptr;
    }
    if (mCodecDeathListener != nullptr) {
        mCodecDeathListener->unlinkToDeath();
        mCodecDeathListener = nullptr;
    for (const sp<ServiceDeathNotifier>& codecDeathListener : mCodecDeathListeners) {
        if (codecDeathListener != nullptr) {
            codecDeathListener->unlinkToDeath();
        }
    }
    mCodecDeathListeners.clear();
}

sp<MediaPlayerBase> MediaPlayerService::Client::setDataSource_pre(
        player_type playerType)
@@ -741,20 +745,45 @@ sp<MediaPlayerBase> MediaPlayerService::Client::setDataSource_pre(
            new ServiceDeathNotifier(binder, p, MEDIAEXTRACTOR_PROCESS_DEATH);
    binder->linkToDeath(extractorDeathListener);

    sp<IOmx> omx = IOmx::getService();
    if (omx == nullptr) {
        ALOGE("IOmx service is not available");
        return NULL;
    std::vector<sp<ServiceDeathNotifier>> codecDeathListeners;
    {
        using ::android::hidl::base::V1_0::IBase;

        // Listen to OMX's IOmxStore/default
        {
            sp<IBase> store = ::android::hardware::media::omx::V1_0::
                    IOmxStore::getService();
            if (store == nullptr) {
                ALOGD("OMX service is not available");
            } else {
                sp<ServiceDeathNotifier> codecDeathListener =
                        new ServiceDeathNotifier(store, p, MEDIACODEC_PROCESS_DEATH);
                store->linkToDeath(codecDeathListener, 0);
                codecDeathListeners.emplace_back(codecDeathListener);
            }
        }

        // Listen to Codec2's IComponentStore/software
        // TODO: Listen to all Codec2 services.
        {
            sp<IBase> store = ::android::hardware::media::c2::V1_0::
                    IComponentStore::getService();
            if (store == nullptr) {
                ALOGD("Codec2 system service is not available");
            } else {
                sp<ServiceDeathNotifier> codecDeathListener =
            new ServiceDeathNotifier(omx, p, MEDIACODEC_PROCESS_DEATH);
    omx->linkToDeath(codecDeathListener, 0);
                        new ServiceDeathNotifier(store, p, MEDIACODEC_PROCESS_DEATH);
                store->linkToDeath(codecDeathListener, 0);
                codecDeathListeners.emplace_back(codecDeathListener);
            }
        }
    }

    Mutex::Autolock lock(mLock);

    clearDeathNotifiers_l();
    mExtractorDeathListener = extractorDeathListener;
    mCodecDeathListener = codecDeathListener;
    mCodecDeathListeners.swap(codecDeathListeners);
    mAudioDeviceUpdatedListener = new AudioDeviceUpdatedNotifier(p);

    if (!p->hardwareOutput()) {
+4 −6
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
#include <media/Metadata.h>
#include <media/stagefright/foundation/ABase.h>

#include <android/hardware/media/omx/1.0/IOmx.h>
#include <hidl/HidlSupport.h>

#include <system/audio.h>

@@ -42,7 +42,6 @@ struct AVSyncSettings;
class IDataSource;
class IMediaRecorder;
class IMediaMetadataRetriever;
class IOMX;
class IRemoteDisplay;
class IRemoteDisplayClient;
class MediaRecorderClient;
@@ -70,7 +69,6 @@ private:
class MediaPlayerService : public BnMediaPlayerService
{
    class Client;
    typedef ::android::hardware::media::omx::V1_0::IOmx IOmx;

    class AudioOutput : public MediaPlayerBase::AudioSink
    {
@@ -400,7 +398,7 @@ private:
                    const sp<MediaPlayerBase>& listener,
                    int which);
            ServiceDeathNotifier(
                    const sp<IOmx>& omx,
                    const sp<android::hidl::base::V1_0::IBase>& hService,
                    const sp<MediaPlayerBase>& listener,
                    int which);
            virtual ~ServiceDeathNotifier();
@@ -413,7 +411,7 @@ private:
        private:
            int mWhich;
            sp<IBinder> mService;
            sp<IOmx> mOmx;
            sp<android::hidl::base::V1_0::IBase> mHService; // HIDL service
            wp<MediaPlayerBase> mListener;
        };

@@ -509,7 +507,7 @@ private:
        media::Metadata::Filter mMetadataUpdated;  // protected by mLock

        sp<ServiceDeathNotifier> mExtractorDeathListener;
        sp<ServiceDeathNotifier> mCodecDeathListener;
        std::vector<sp<ServiceDeathNotifier>> mCodecDeathListeners;
        sp<AudioDeviceUpdatedNotifier> mAudioDeviceUpdatedListener;
#if CALLBACK_ANTAGONIZER
                    Antagonizer*                  mAntagonizer;
+1 −0
Original line number Diff line number Diff line
@@ -227,6 +227,7 @@ cc_library {

    export_shared_lib_headers: [
        "libgui",
        "libhidlmemory",
        "libmedia",
        "android.hidl.allocator@1.0",
    ],