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

Commit ee0a0e39 authored by Robert Shih's avatar Robert Shih
Browse files

MediaPlayerService: avoid invalid static cast

Bug: 30204103
Change-Id: Ie0dd3568a375f1e9fed8615ad3d85184bcc99028
parent 8f4b1a7d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -572,6 +572,12 @@ void MediaPlayerService::removeClient(wp<Client> client)
    mClients.remove(client);
}

bool MediaPlayerService::hasClient(wp<Client> client)
{
    Mutex::Autolock lock(mLock);
    return mClients.indexOf(client) != NAME_NOT_FOUND;
}

MediaPlayerService::Client::Client(
        const sp<MediaPlayerService>& service, pid_t pid,
        int32_t connId, const sp<IMediaPlayerClient>& client,
@@ -1008,6 +1014,10 @@ status_t MediaPlayerService::Client::setNextPlayer(const sp<IMediaPlayer>& playe
    ALOGV("setNextPlayer");
    Mutex::Autolock l(mLock);
    sp<Client> c = static_cast<Client*>(player.get());
    if (!mService->hasClient(c)) {
      return BAD_VALUE;
    }

    mNextClient = c;

    if (c != NULL) {
+1 −0
Original line number Diff line number Diff line
@@ -287,6 +287,7 @@ public:
    virtual status_t            dump(int fd, const Vector<String16>& args);

            void                removeClient(wp<Client> client);
            bool                hasClient(wp<Client> client);

    // For battery usage tracking purpose
    struct BatteryUsageInfo {