summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice/nuplayer/GenericSource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libmediaplayerservice/nuplayer/GenericSource.cpp')
-rw-r--r--media/libmediaplayerservice/nuplayer/GenericSource.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
index 7c99f11..3485dd5 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
@@ -128,6 +128,7 @@ status_t NuPlayer::GenericSource::setDataSource(
status_t NuPlayer::GenericSource::setDataSource(const sp<DataSource>& source) {
resetDataSource();
+ Mutex::Autolock _l(mSourceLock);
mDataSource = source;
return OK;
}
@@ -387,6 +388,7 @@ void NuPlayer::GenericSource::onPrepareAsync() {
}
}
+ Mutex::Autolock _l(mSourceLock);
mDataSource = DataSource::CreateFromURI(
mHTTPService, uri, &mUriHeaders, &contentType,
static_cast<HTTPBase *>(mHttpSource.get()),
@@ -394,6 +396,7 @@ void NuPlayer::GenericSource::onPrepareAsync() {
} else {
mIsWidevine = false;
+ Mutex::Autolock _l(mSourceLock);
mDataSource = new FileSource(mFd, mOffset, mLength);
mFd = -1;
}
@@ -484,11 +487,10 @@ void NuPlayer::GenericSource::finishPrepareAsync() {
void NuPlayer::GenericSource::notifyPreparedAndCleanup(status_t err) {
if (err != OK) {
- {
- mDataSource.clear();
- mCachedSource.clear();
- mHttpSource.clear();
- }
+ Mutex::Autolock _l(mSourceLock);
+ mDataSource.clear();
+ mCachedSource.clear();
+ mHttpSource.clear();
mBitrate = -1;
cancelPollBuffering();
@@ -541,13 +543,21 @@ void NuPlayer::GenericSource::resume() {
}
void NuPlayer::GenericSource::disconnect() {
- if (mDataSource != NULL) {
+
+ sp<DataSource> dataSource;
+ sp<DataSource> httpSource;
+ {
+ Mutex::Autolock _l(mSourceLock);
+ 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();
}
}