Fix nuplayer seek jankiness by properly flushing decoders before
initiating the seek. Also refactor the nuplayer state machine to make this
a little more maintainable and extensible in the future.
Change-Id: I36a673bdecff732bca7094c8f72bac24f37c01e9
related-to-bug: 7120373
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h
index 31efb2e..6e174e0 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h
@@ -73,6 +73,9 @@
struct Renderer;
struct RTSPSource;
struct StreamingSource;
+ struct Action;
+ struct SeekAction;
+ struct SimpleAction;
enum {
kWhatSetDataSource = '=DaS',
@@ -102,6 +105,8 @@
sp<Decoder> mAudioDecoder;
sp<Renderer> mRenderer;
+ List<sp<Action> > mDeferredActions;
+
bool mAudioEOS;
bool mVideoEOS;
@@ -126,8 +131,6 @@
FlushStatus mFlushingAudio;
FlushStatus mFlushingVideo;
- bool mResetInProgress;
- bool mResetPostponed;
int64_t mSkipRenderingAudioUntilMediaTimeUs;
int64_t mSkipRenderingVideoUntilMediaTimeUs;
@@ -150,12 +153,19 @@
static bool IsFlushingState(FlushStatus state, bool *needShutdown = NULL);
- void finishReset();
void postScanSources();
void schedulePollDuration();
void cancelPollDuration();
+ void processDeferredActions();
+
+ void performSeek(int64_t seekTimeUs);
+ void performDecoderFlush();
+ void performDecoderShutdown();
+ void performReset();
+ void performScanSources();
+
DISALLOW_EVIL_CONSTRUCTORS(NuPlayer);
};