diff options
author | Robert Shih <robertshih@google.com> | 2015-09-02 14:02:47 -0700 |
---|---|---|
committer | Robert Shih <robertshih@google.com> | 2015-09-08 11:59:30 -0700 |
commit | b946648cc63a4d328318b56215214ead575bc54a (patch) | |
tree | 3461186a8b9900f419df126c4b29eed5f1dfad22 /media/libmediaplayerservice/nuplayer/GenericSource.cpp | |
parent | c336136d8a86a8a95047949955a9bb749af247ab (diff) | |
download | frameworks_av-b946648cc63a4d328318b56215214ead575bc54a.zip frameworks_av-b946648cc63a4d328318b56215214ead575bc54a.tar.gz frameworks_av-b946648cc63a4d328318b56215214ead575bc54a.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(); } } |