diff options
author | Robert Shih <robertshih@google.com> | 2015-09-02 14:02:47 -0700 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2015-09-28 17:08:18 -0700 |
commit | f2e5350cfd164cac1220cc00cd98e97199439c6e (patch) | |
tree | df6ca3f9c46ff2ea8d5f6522b147ae34d00ae661 /media/libmediaplayerservice/nuplayer/GenericSource.cpp | |
parent | f605c786c375105c9ffc4cb34dd30a3c36c37682 (diff) | |
download | frameworks_av-f2e5350cfd164cac1220cc00cd98e97199439c6e.zip frameworks_av-f2e5350cfd164cac1220cc00cd98e97199439c6e.tar.gz frameworks_av-f2e5350cfd164cac1220cc00cd98e97199439c6e.tar.bz2 |
Protect data source access with mutex during disconnect
Bug: 23658148
Change-Id: Ic37cac7b5d166143e0b77e9919b0aaef486e4fdd
Diffstat (limited to 'media/libmediaplayerservice/nuplayer/GenericSource.cpp')
-rw-r--r-- | media/libmediaplayerservice/nuplayer/GenericSource.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp index 7dc9be7..b3eb5fd 100644 --- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp +++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp @@ -467,9 +467,17 @@ void NuPlayer::GenericSource::finishPrepareAsync() { void NuPlayer::GenericSource::notifyPreparedAndCleanup(status_t err) { if (err != OK) { - mDataSource.clear(); - mCachedSource.clear(); - mHttpSource.clear(); + { + sp<DataSource> dataSource = mDataSource; + sp<NuCachedSource2> cachedSource = mCachedSource; + sp<DataSource> httpSource = mHttpSource; + { + Mutex::Autolock _l(mDisconnectLock); + mDataSource.clear(); + mCachedSource.clear(); + mHttpSource.clear(); + } + } mBitrate = -1; cancelPollBuffering(); @@ -522,13 +530,20 @@ void NuPlayer::GenericSource::resume() { } void NuPlayer::GenericSource::disconnect() { - if (mDataSource != NULL) { + sp<DataSource> dataSource, httpSource; + { + Mutex::Autolock _l(mDisconnectLock); + dataSource = mDataSource; + httpSource = mHttpSource; + } + + if (dataSource != NULL) { // disconnect data source - if (mDataSource->flags() & DataSource::kIsCachingDataSource) { - static_cast<NuCachedSource2 *>(mDataSource.get())->disconnect(); + if (dataSource->flags() & DataSource::kIsCachingDataSource) { + static_cast<NuCachedSource2 *>(dataSource.get())->disconnect(); } - } else if (mHttpSource != NULL) { - static_cast<HTTPBase *>(mHttpSource.get())->disconnect(); + } else if (httpSource != NULL) { + static_cast<HTTPBase *>(httpSource.get())->disconnect(); } } |