diff options
author | Robert Shih <robertshih@google.com> | 2016-08-16 16:50:54 -0700 |
---|---|---|
committer | gitbuildkicker <android-build@google.com> | 2016-08-26 16:20:40 -0700 |
commit | 4c086a8dc1d9c9772ac705d2a1509b311985e374 (patch) | |
tree | d5e0d65b58576ebb4b067983afa533c92298969b | |
parent | dda9d703d7dd2129ff6242fae84ca156caa38632 (diff) | |
download | frameworks_av-4c086a8dc1d9c9772ac705d2a1509b311985e374.zip frameworks_av-4c086a8dc1d9c9772ac705d2a1509b311985e374.tar.gz frameworks_av-4c086a8dc1d9c9772ac705d2a1509b311985e374.tar.bz2 |
MediaPlayerService: avoid invalid static cast
Bug: 30204103
Change-Id: Ie0dd3568a375f1e9fed8615ad3d85184bcc99028
(cherry picked from commit ee0a0e39acdcf8f97e0d6945c31ff36a06a36e9d)
-rw-r--r-- | media/libmediaplayerservice/MediaPlayerService.cpp | 10 | ||||
-rw-r--r-- | media/libmediaplayerservice/MediaPlayerService.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index b8c610d..0483228 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -559,6 +559,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, @@ -1056,6 +1062,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) { diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h index 60d4617..e8e5360 100644 --- a/media/libmediaplayerservice/MediaPlayerService.h +++ b/media/libmediaplayerservice/MediaPlayerService.h @@ -226,6 +226,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 { |