From 21808c24992aef5fd7aaeb1d68dca29c79f2dbd1 Mon Sep 17 00:00:00 2001 From: Tellen Yu Date: Wed, 17 Feb 2016 09:18:46 +0000 Subject: tvin detect thread need use tvin object that has been initialized Change-Id: I6301a8226ea4c310ea19b86289ed75c032c069aa --- diff --git a/tvapi/libtv/tv/CTv.cpp b/tvapi/libtv/tv/CTv.cpp index 3ed762b..f3c8764 100644 --- a/tvapi/libtv/tv/CTv.cpp +++ b/tvapi/libtv/tv/CTv.cpp @@ -72,6 +72,7 @@ static void sqliteLogCallback(void *data, int iErrCode, const char *zMsg) } CTv::CTv() : + mSigDetectThread(&mTvin), mSourceConnectDetectThread(&mTvin), mHDMIRxCEC ( &mTvin ), mTvScanner ( &mTvin ), @@ -1639,7 +1640,6 @@ int CTv::StartTvLock () mFrontDev.Open(FE_ANALOG); mFrontDev.autoLoadFE(); mSigDetectThread.startDetect(); - mSigDetectThread.initSigState(); mTvMsgQueue.startMsgQueue(); resetDmxAndAvSource(); SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt); diff --git a/tvapi/libtv/tvin/CTvin.cpp b/tvapi/libtv/tvin/CTvin.cpp index 07e5b67..fd90068 100644 --- a/tvapi/libtv/tvin/CTvin.cpp +++ b/tvapi/libtv/tvin/CTvin.cpp @@ -3029,11 +3029,12 @@ int CTvin::get_hdmi_sampling_rate() } //************************************************************************** -CTvin::CTvinSigDetect::CTvinSigDetect () +CTvin::CTvinSigDetect::CTvinSigDetect (CTvin *pTvin) { mDetectState = STATE_STOPED; mpObserver = NULL; + mpTvin = pTvin; initSigState(); } @@ -3049,14 +3050,8 @@ int CTvin::CTvinSigDetect::startDetect(bool bPause) return mDetectState; } - m_cur_sig_info.trans_fmt = TVIN_TFMT_2D; - m_cur_sig_info.fmt = TVIN_SIG_FMT_NULL; - m_cur_sig_info.status = TVIN_SIG_STATUS_NULL; - m_cur_sig_info.reserved = 0; - - m_pre_sig_info = m_cur_sig_info; - m_request_pause_detect = bPause; + initSigState(); this->run(); return mDetectState; } @@ -3122,8 +3117,7 @@ void CTvin::CTvinSigDetect::setVdinNoSigCheckKeepTimes(int times, bool isOnce) int CTvin::CTvinSigDetect::Tv_TvinSigDetect ( int &sleeptime ) { - CTvin tvin; - tvin.VDIN_GetSignalInfo ( &m_cur_sig_info ); //get info + mpTvin->VDIN_GetSignalInfo ( &m_cur_sig_info ); //get info //set no sig check times static long long sNosigKeepTime = 0; //LOGD("stime=%d status=%d, fmt = %d sNosigKeepTime = %d, mKeepNosigTime = %d", sleeptime, m_cur_sig_info.status,m_cur_sig_info.fmt, sNosigKeepTime, mKeepNosigTime); diff --git a/tvapi/libtv/tvin/CTvin.h b/tvapi/libtv/tvin/CTvin.h index 1f7b8be..61ba064 100644 --- a/tvapi/libtv/tvin/CTvin.h +++ b/tvapi/libtv/tvin/CTvin.h @@ -1156,7 +1156,7 @@ public: class CTvinSigDetect: public CThread { public: static const int VDIN_NOSIG_DEFAULT_CHECK_TIMES = 1; - CTvinSigDetect (); + CTvinSigDetect (CTvin *pTvin); ~CTvinSigDetect(); int startDetect(bool bPause = true); int stopDetect(); @@ -1206,6 +1206,7 @@ public: int Tv_TvinSigDetect ( int &args ); //member + CTvin *mpTvin; tvin_info_t m_cur_sig_info; tvin_info_t m_pre_sig_info; int mKeepNosigTime; diff --git a/tvapi/libtv/tvutils/CTvInput.cpp b/tvapi/libtv/tvutils/CTvInput.cpp index 87d7352..7e3af96 100644 --- a/tvapi/libtv/tvutils/CTvInput.cpp +++ b/tvapi/libtv/tvutils/CTvInput.cpp @@ -5,14 +5,19 @@ #include #include #include + #define LOG_TAG "FBC" + +#define SEND_KEY_ACTION_UP 0x00 +#define SEND_KEY_ACTION_DOWN 0x01 + CTvInput::CTvInput() { mKeyEventFd_IR = open(KEY_EVENT_0, O_RDWR); mKeyEventFd = open(KEY_EVENT_1, O_RDWR); if (mKeyEventFd < 0 || mKeyEventFd_IR < 0) { LOGD( "could not open /dev/input/event1\n "); - return ; + return; } mRepeatKeyCode = -1; mRepeatKeydisTime = -1; @@ -38,7 +43,7 @@ void CTvInput::sendkeyEvent(const int &type, const int &code, const int &value) ret = write(mKeyEventFd, &event, sizeof(event)); if (ret < sizeof(event)) { LOGD("sendkeyEvent :write event failed, %s\n", strerror(errno)); - return ; + return; } } @@ -54,53 +59,55 @@ void CTvInput::sendIRkeyEvent(const int &type, const int &code, const int &value ret = write(mKeyEventFd_IR, &event, sizeof(event)); if (ret < sizeof(event)) { LOGD("sendIRkeyEvent :write event failed, %s\n", strerror(errno)); - return ; + return; } } void CTvInput::sendkeyCode(const int &code) { - sendkeyEvent(1 , code, 1); //down - sendkeyEvent(0, 0, 0); //clear - sendkeyEvent(1 , code, 0); //up - sendkeyEvent(0, 0, 0); //clear + sendkeyEvent(EV_KEY , code, SEND_KEY_ACTION_DOWN); //down + sendkeyEvent(EV_SYN, 0, 0); //clear + sendkeyEvent(EV_KEY , code, SEND_KEY_ACTION_UP); //up + sendkeyEvent(EV_SYN, 0, 0); //clear } void CTvInput::sendkeyCode_Up(const int &code) { - sendkeyEvent(1 , code, 0); //up - sendkeyEvent(0, 0, 0); //clear + sendkeyEvent(EV_KEY , code, SEND_KEY_ACTION_UP); //up + sendkeyEvent(EV_SYN, 0, 0); //clear } void CTvInput::sendkeyCode_Down(const int &code) { - sendkeyEvent(1 , code, 1); //down - sendkeyEvent(0, 0, 0); //clear + sendkeyEvent(EV_KEY , code, SEND_KEY_ACTION_DOWN); //down + sendkeyEvent(EV_SYN, 0, 0); //clear } + void CTvInput::sendIRkeyCode(const int &code) { - sendIRkeyEvent(1 , code, 1); //down - sendIRkeyEvent(0, 0, 0); //clear - sendIRkeyEvent(1 , code, 0); //up - sendIRkeyEvent(0, 0, 0); //clear + sendIRkeyEvent(EV_KEY , code, SEND_KEY_ACTION_DOWN); //down + sendIRkeyEvent(EV_SYN, 0, 0); //clear + sendIRkeyEvent(EV_KEY , code, SEND_KEY_ACTION_UP); //up + sendIRkeyEvent(EV_SYN, 0, 0); //clear } void CTvInput::sendIRkeyCode_Up(const int &code) { - sendIRkeyEvent(1 , code, 0); //up - sendIRkeyEvent(0, 0, 0); //clear + sendIRkeyEvent(EV_KEY , code, SEND_KEY_ACTION_UP); //up + sendIRkeyEvent(EV_SYN, 0, 0); //clear } void CTvInput::sendIRkeyCode_Down(const int &code) { - sendIRkeyEvent(1 , code, 1); //down - sendIRkeyEvent(0, 0, 0); //clear + sendIRkeyEvent(EV_KEY , code, SEND_KEY_ACTION_DOWN); //down + sendIRkeyEvent(EV_SYN, 0, 0); //clear } nsecs_t CTvInput::getNowMs() { return systemTime(SYSTEM_TIME_MONOTONIC) / 1000000; } + void CTvInput::sendKeyRepeatStart(const int &code, int disTime, int repeatDisTime) { CMutex::Autolock _l(mLock); @@ -120,7 +127,7 @@ void CTvInput::sendKeyRepeatStop() mRepeatKeydisTime = -1; } -bool CTvInput::threadLoop() +bool CTvInput::threadLoop() { int sleeptime = 100;//ms -- cgit