summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/timedtext
diff options
context:
space:
mode:
authorInsun Kang <insun@google.com>2012-09-20 21:03:44 +0900
committerInsun Kang <insun@google.com>2012-09-20 22:20:26 +0900
commit23580bb8d6cafbc2b65dd0a4ce1acb52562d1b05 (patch)
tree9674f693e29d36d50df581d61d7040e9b756dfa8 /media/libstagefright/timedtext
parent74e58c55bc5259b957a51f1bb44a5911ad1f8400 (diff)
downloadframeworks_av-23580bb8d6cafbc2b65dd0a4ce1acb52562d1b05.zip
frameworks_av-23580bb8d6cafbc2b65dd0a4ce1acb52562d1b05.tar.gz
frameworks_av-23580bb8d6cafbc2b65dd0a4ce1acb52562d1b05.tar.bz2
Bug fix: MediaPlayer's deselectTrack() for subtitle.
o Previously, deselectTrack() actually doesn't work properly in TimedTextDriver / TimedTextPlayer. o Ignores select track operation when the same track is selected in a row. Bug: 7200096 TESTED=runtest -d cts-media -c android.media.cts.MediaPlayerTest Change-Id: If7feac294cf9b358f616be45574bc2e26001c887
Diffstat (limited to 'media/libstagefright/timedtext')
-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) {