summaryrefslogtreecommitdiff
path: root/media/libmediaplayerservice
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-08-26 16:13:03 -0700
committerJames Dong <jdong@google.com>2012-08-26 16:18:11 -0700
commitb8a9825bf0f5c74333b0e4ff5ba7677ac6fd2a25 (patch)
tree4dd56785fc2185f44abff6f257197ca982e4c49b /media/libmediaplayerservice
parent96272d57caa39566842795ba1f0605a5a5f72272 (diff)
Fixed a potential/rare race condtion in MediaPlayerService::Client::notify() method
o The mClient could be disconnected before the notify message is sent out. Use a local reference could help resolve this issue. o related-to-bug: 6782035 Change-Id: Ia2047bd7f2666100fed83c6e5417a3bf2e20cd2c
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r--media/libmediaplayerservice/MediaPlayerService.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index 58e47235..63463639 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -1042,9 +1042,14 @@ void MediaPlayerService::Client::notify(
void* cookie, int msg, int ext1, int ext2, const Parcel *obj)
{
Client* client = static_cast<Client*>(cookie);
+ if (client == NULL) {
+ return;
+ }
+ sp<IMediaPlayerClient> c;
{
Mutex::Autolock l(client->mLock);
+ c = client->mClient;
if (msg == MEDIA_PLAYBACK_COMPLETE && client->mNextClient != NULL) {
if (client->mAudioOutput != NULL)
client->mAudioOutput->switchToNextOutput();
@@ -1065,8 +1070,11 @@ void MediaPlayerService::Client::notify(
// also access mMetadataUpdated and clears it.
client->addNewMetadataUpdate(metadata_type);
}
- ALOGV("[%d] notify (%p, %d, %d, %d)", client->mConnId, cookie, msg, ext1, ext2);
- client->mClient->notify(msg, ext1, ext2, obj);
+
+ if (c != NULL) {
+ ALOGV("[%d] notify (%p, %d, %d, %d)", client->mConnId, cookie, msg, ext1, ext2);
+ c->notify(msg, ext1, ext2, obj);
+ }
}