diff options
author | Lajos Molnar <lajos@google.com> | 2014-09-11 10:01:55 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2014-09-11 14:02:11 -0700 |
commit | 84f5278a36f2816cc38f64307b4a1ad8a6818507 (patch) | |
tree | a70b12822e0c000bef10379a6938889fd59ed933 /media/libmediaplayerservice | |
parent | 7c12b0358b6d3b66e231fe4a67bb55f424b3857e (diff) | |
download | frameworks_av-84f5278a36f2816cc38f64307b4a1ad8a6818507.zip frameworks_av-84f5278a36f2816cc38f64307b4a1ad8a6818507.tar.gz frameworks_av-84f5278a36f2816cc38f64307b4a1ad8a6818507.tar.bz2 |
avoid kWhatReadBuffer message spam in GenericSource
When playig WVM video, an extra readBuffer is posted for each
dequeueAccessUnit, resulting in an unbounded number of messages.
Bug: 17472979
Change-Id: Ice92ccf2454bf7a70856a4a8b535cefffc9e61ac
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r-- | media/libmediaplayerservice/nuplayer/GenericSource.cpp | 21 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/GenericSource.h | 2 |
2 files changed, 19 insertions, 4 deletions
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp index 8e1987a..ec1a9a0 100644 --- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp +++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp @@ -54,7 +54,8 @@ NuPlayer::GenericSource::GenericSource( mDrmManagerClient(NULL), mMetaDataSize(-1ll), mBitrate(-1ll), - mPollBufferingGeneration(0) { + mPollBufferingGeneration(0), + mPendingReadBufferTypes(0) { resetDataSource(); DataSource::RegisterDefaultSniffers(); } @@ -1148,15 +1149,27 @@ sp<ABuffer> NuPlayer::GenericSource::mediaBufferToABuffer( } void NuPlayer::GenericSource::postReadBuffer(media_track_type trackType) { - sp<AMessage> msg = new AMessage(kWhatReadBuffer, id()); - msg->setInt32("trackType", trackType); - msg->post(); + Mutex::Autolock _l(mReadBufferLock); + + if ((mPendingReadBufferTypes & (1 << trackType)) == 0) { + mPendingReadBufferTypes |= (1 << trackType); + sp<AMessage> msg = new AMessage(kWhatReadBuffer, id()); + msg->setInt32("trackType", trackType); + msg->post(); + } } void NuPlayer::GenericSource::onReadBuffer(sp<AMessage> msg) { int32_t tmpType; CHECK(msg->findInt32("trackType", &tmpType)); media_track_type trackType = (media_track_type)tmpType; + { + // only protect the variable change, as readBuffer may + // take considerable time. This may result in one extra + // read being processed, but that is benign. + Mutex::Autolock _l(mReadBufferLock); + mPendingReadBufferTypes &= ~(1 << trackType); + } readBuffer(trackType); } diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.h b/media/libmediaplayerservice/nuplayer/GenericSource.h index 50ff98a..c70c48e 100644 --- a/media/libmediaplayerservice/nuplayer/GenericSource.h +++ b/media/libmediaplayerservice/nuplayer/GenericSource.h @@ -131,6 +131,8 @@ private: off64_t mMetaDataSize; int64_t mBitrate; int32_t mPollBufferingGeneration; + uint32_t mPendingReadBufferTypes; + mutable Mutex mReadBufferLock; sp<ALooper> mLooper; |