summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-09-23 10:01:19 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-23 10:01:20 -0700
commit4bf45909bcccb46acac61c155edd031e85b9dc12 (patch)
treeb520505a9ef457b1566a28eda74abb7f1658c897
parente7fc0ece01c9672629664c07108640f589034636 (diff)
parentef58870d2c798f046c87b06be0ec0cad109a754b (diff)
downloadframeworks_av-4bf45909bcccb46acac61c155edd031e85b9dc12.zip
frameworks_av-4bf45909bcccb46acac61c155edd031e85b9dc12.tar.gz
frameworks_av-4bf45909bcccb46acac61c155edd031e85b9dc12.tar.bz2
Merge "Bug fix: MediaPlayer's deselectTrack() for subtitle." into jb-mr1-dev
-rw-r--r--media/libstagefright/timedtext/TimedTextDriver.cpp9
-rw-r--r--media/libstagefright/timedtext/TimedTextPlayer.cpp12
2 files changed, 18 insertions, 3 deletions
diff --git a/media/libstagefright/timedtext/TimedTextDriver.cpp b/media/libstagefright/timedtext/TimedTextDriver.cpp
index 54ce7ac..12fd7f4 100644
--- a/media/libstagefright/timedtext/TimedTextDriver.cpp
+++ b/media/libstagefright/timedtext/TimedTextDriver.cpp
@@ -43,7 +43,8 @@ TimedTextDriver::TimedTextDriver(
const wp<MediaPlayerBase> &listener)
: mLooper(new ALooper),
mListener(listener),
- mState(UNINITIALIZED) {
+ mState(UNINITIALIZED),
+ mCurrentTrackIndex(UINT_MAX) {
mLooper->setName("TimedTextDriver");
mLooper->start();
mPlayer = new TimedTextPlayer(listener);
@@ -57,6 +58,9 @@ TimedTextDriver::~TimedTextDriver() {
}
status_t TimedTextDriver::selectTrack_l(size_t index) {
+ if (mCurrentTrackIndex == index) {
+ return OK;
+ }
sp<TimedTextSource> source;
source = mTextSourceVector.valueFor(index);
mPlayer->setDataSource(source);
@@ -138,11 +142,12 @@ status_t TimedTextDriver::unselectTrack(size_t index) {
if (mCurrentTrackIndex != index) {
return INVALID_OPERATION;
}
+ mCurrentTrackIndex = UINT_MAX;
switch (mState) {
case UNINITIALIZED:
return INVALID_OPERATION;
case PLAYING:
- mPlayer->pause();
+ mPlayer->setDataSource(NULL);
mState = UNINITIALIZED;
return OK;
case PREPARED:
diff --git a/media/libstagefright/timedtext/TimedTextPlayer.cpp b/media/libstagefright/timedtext/TimedTextPlayer.cpp
index e3bdd8a..9fb0afe 100644
--- a/media/libstagefright/timedtext/TimedTextPlayer.cpp
+++ b/media/libstagefright/timedtext/TimedTextPlayer.cpp
@@ -183,11 +183,20 @@ void TimedTextPlayer::onMessageReceived(const sp<AMessage> &msg) {
break;
}
case kWhatSetSource: {
+ mSendSubtitleGeneration++;
sp<RefBase> obj;
msg->findObject("source", &obj);
- if (obj == NULL) break;
if (mSource != NULL) {
mSource->stop();
+ mSource.clear();
+ mSource = NULL;
+ }
+ // null source means deselect track.
+ if (obj == NULL) {
+ mPendingSeekTimeUs = kInvalidTimeUs;
+ mPaused = false;
+ notifyListener();
+ break;
}
mSource = static_cast<TimedTextSource*>(obj.get());
status_t err = mSource->start();
@@ -217,6 +226,7 @@ void TimedTextPlayer::doRead(MediaSource::ReadOptions* options) {
int64_t startTimeUs = 0;
int64_t endTimeUs = 0;
sp<ParcelEvent> parcelEvent = new ParcelEvent();
+ CHECK(mSource != NULL);
status_t err = mSource->read(&startTimeUs, &endTimeUs,
&(parcelEvent->parcel), options);
if (err == WOULD_BLOCK) {