状态参考BlurayPlayer.cpp中的PlayerStatus
enum PlayerStatus {
PLAYER_STATE_ERROR = 0,
PLAYER_IDLE = 0x01,
PLAYER_INITIALIZED = 0x02,
PLAYER_PREPARING = 0x04,
PLAYER_PREPARED = 0x08,
PLAYER_STARTING = 0x09,
PLAYER_STARTED = 0x10,
PLAYER_PLAY = 0x11,
PLAYER_PAUSED = 0x20,
PLAYER_STOPPED = 0x40,
PLAYER_PLAYBACK_COMPLETE = 0x80,
PLAYER_DECODED = 0x0100,
PLAYER_READ_END_OF_STREAM = 0x0200,
PLAYER_PLAY_NEXT_LIST = 0x0400, // for bluray
};
FFMPlayer::reset()
{
if (getCurrentStatus()== PLAYER_IDLE) {
//1.idle状态直接返回
ALOGD("CurrentStatus is IDLE,already reset");
return OK;
}
if ((getCurrentStatus() != PLAYER_STOPPED && getCurrentStatus() != PLAYER_IDLE) || !mPlayer_sisExited) {
//2.非idle和非stopped状态,调用stop_l()停止
ALOGD("reset(),stop_l");
stop_l();
}
if (mMessageQ.get() != NULL) {
//3.经过上述过程,已经在stopped状态,要清除message序列,回到最开始的位置,进入idle状态
enqueueMessage(new MessageReset(NULL, 1));// PLAYER_IDLE = 0x01,
//运行完该语句后,当前状态MessageCurrentStatus::mCurrentStatus为idle状态
if (mMessageQ.get() != NULL) {
mMessageQ->stop();
mMessageQ->clearQueue();
mMessageQ.clear();
}
mMsgQueueCond.signal();
AUTO_LOCK_END(mMsgQueueLock);