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

Commit f87d8341 authored by Ronghua Wu's avatar Ronghua Wu Committed by Android (Google) Code Review
Browse files

Merge "libmediaplayerservice: propagate caller pid to MediaCodec." into mnc-dev

parents 8f0547a9 68845c14
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -61,11 +61,15 @@ struct MediaCodec : public AHandler {
        CB_RESOURCE_RECLAIMED = 5,
    };

    static const pid_t kNoPid = -1;

    static sp<MediaCodec> CreateByType(
            const sp<ALooper> &looper, const char *mime, bool encoder, status_t *err = NULL);
            const sp<ALooper> &looper, const char *mime, bool encoder, status_t *err = NULL,
            pid_t pid = kNoPid);

    static sp<MediaCodec> CreateByComponentName(
            const sp<ALooper> &looper, const char *name, status_t *err = NULL);
            const sp<ALooper> &looper, const char *name, status_t *err = NULL,
            pid_t pid = kNoPid);

    static sp<PersistentSurface> CreatePersistentInputSurface();

@@ -251,7 +255,7 @@ private:
    };

    struct ResourceManagerServiceProxy : public IBinder::DeathRecipient {
        ResourceManagerServiceProxy();
        ResourceManagerServiceProxy(pid_t pid);
        ~ResourceManagerServiceProxy();

        void init();
@@ -271,7 +275,7 @@ private:
    private:
        Mutex mLock;
        sp<IResourceManagerService> mService;
        int mPid;
        pid_t mPid;
    };

    State mState;
@@ -333,7 +337,7 @@ private:
    bool mHaveInputSurface;
    bool mHavePendingInputBuffers;

    MediaCodec(const sp<ALooper> &looper);
    MediaCodec(const sp<ALooper> &looper, pid_t pid);

    static status_t PostAndAwaitResponse(
            const sp<AMessage> &msg, sp<AMessage> *response);
+7 −6
Original line number Diff line number Diff line
@@ -135,7 +135,8 @@ player_type MediaPlayerFactory::getPlayerType(const sp<IMediaPlayer>& client,
sp<MediaPlayerBase> MediaPlayerFactory::createPlayer(
        player_type playerType,
        void* cookie,
        notify_callback_f notifyFunc) {
        notify_callback_f notifyFunc,
        pid_t pid) {
    sp<MediaPlayerBase> p;
    IFactory* factory;
    status_t init_result;
@@ -149,7 +150,7 @@ sp<MediaPlayerBase> MediaPlayerFactory::createPlayer(

    factory = sFactoryMap.valueFor(playerType);
    CHECK(NULL != factory);
    p = factory->createPlayer();
    p = factory->createPlayer(pid);

    if (p == NULL) {
        ALOGE("Failed to create player object of type %d, create failed",
@@ -217,7 +218,7 @@ class StagefrightPlayerFactory :
        return 0.0;
    }

    virtual sp<MediaPlayerBase> createPlayer() {
    virtual sp<MediaPlayerBase> createPlayer(pid_t /* pid */) {
        ALOGV(" create StagefrightPlayer");
        return new StagefrightPlayer();
    }
@@ -279,9 +280,9 @@ class NuPlayerFactory : public MediaPlayerFactory::IFactory {
        return 1.0;
    }

    virtual sp<MediaPlayerBase> createPlayer() {
    virtual sp<MediaPlayerBase> createPlayer(pid_t pid) {
        ALOGV(" create NuPlayer");
        return new NuPlayerDriver;
        return new NuPlayerDriver(pid);
    }
};

@@ -297,7 +298,7 @@ class TestPlayerFactory : public MediaPlayerFactory::IFactory {
        return 0.0;
    }

    virtual sp<MediaPlayerBase> createPlayer() {
    virtual sp<MediaPlayerBase> createPlayer(pid_t /* pid */) {
        ALOGV("Create Test Player stub");
        return new TestPlayerStub();
    }
+3 −2
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ class MediaPlayerFactory {
                                   const sp<DataSource> &/*source*/,
                                   float /*curScore*/) { return 0.0; }

        virtual sp<MediaPlayerBase> createPlayer() = 0;
        virtual sp<MediaPlayerBase> createPlayer(pid_t pid) = 0;
    };

    static status_t registerFactory(IFactory* factory,
@@ -66,7 +66,8 @@ class MediaPlayerFactory {

    static sp<MediaPlayerBase> createPlayer(player_type playerType,
                                            void* cookie,
                                            notify_callback_f notifyFunc);
                                            notify_callback_f notifyFunc,
                                            pid_t pid);

    static void registerBuiltinFactories();

+1 −1
Original line number Diff line number Diff line
@@ -633,7 +633,7 @@ sp<MediaPlayerBase> MediaPlayerService::Client::createPlayer(player_type playerT
        p.clear();
    }
    if (p == NULL) {
        p = MediaPlayerFactory::createPlayer(playerType, this, notify);
        p = MediaPlayerFactory::createPlayer(playerType, this, notify, mPid);
    }

    if (p != NULL) {
+4 −3
Original line number Diff line number Diff line
@@ -166,8 +166,9 @@ private:

////////////////////////////////////////////////////////////////////////////////

NuPlayer::NuPlayer()
NuPlayer::NuPlayer(pid_t pid)
    : mUIDValid(false),
      mPID(pid),
      mSourceFlags(0),
      mOffloadAudio(false),
      mAudioDecoderGeneration(0),
@@ -1525,7 +1526,7 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<DecoderBase> *decoder) {
            format->setInt32("has-video", hasVideo);
            *decoder = new DecoderPassThrough(notify, mSource, mRenderer);
        } else {
            *decoder = new Decoder(notify, mSource, mRenderer);
            *decoder = new Decoder(notify, mSource, mPID, mRenderer);
        }
    } else {
        sp<AMessage> notify = new AMessage(kWhatVideoNotify, this);
@@ -1533,7 +1534,7 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<DecoderBase> *decoder) {
        notify->setInt32("generation", mVideoDecoderGeneration);

        *decoder = new Decoder(
                notify, mSource, mRenderer, mSurface, mCCDecoder);
                notify, mSource, mPID, mRenderer, mSurface, mCCDecoder);

        // enable FRC if high-quality AV sync is requested, even if not
        // directly queuing to display, as this will even improve textureview
Loading