webtv: try to restart channel once, if play position not advance

Origin commit data
------------------
Branch: ni/coolstream
Commit: 7bef4bcb8e
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2015-05-19 (Tue, 19 May 2015)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2015-05-19 17:21:22 +03:00
parent 4cea1f8c82
commit cad4b9057c
2 changed files with 35 additions and 10 deletions

View File

@@ -609,9 +609,31 @@ void* CMoviePlayerGui::bgPlayThread(void *arg)
set_threadname(__func__);
CMoviePlayerGui *mp = (CMoviePlayerGui *) arg;
int eof = 0, pos = 0;
while(true) {
if (mp->playback->GetPosition(mp->position, mp->duration)) {
#if 0
printf("CMoviePlayerGui::bgPlayThread: position %d duration %d (%d)\n", mp->position, mp->duration, mp->duration-mp->position);
#endif
if (pos == mp->position)
eof++;
else
eof = 0;
if (eof > 2) {
printf("CMoviePlayerGui::bgPlayThread: playback stopped, try to rezap...\n");
t_channel_id * chid = new t_channel_id;
*chid = mp->movie_info.epgId;
g_RCInput->postMsg(NeutrinoMessages::EVT_WEBTV_ZAP_COMPLETE, (neutrino_msg_data_t) chid);
break;
}
pos = mp->position;
}
bgmutex.lock();
cond.wait(&bgmutex);
int res = cond.wait(&bgmutex, 1000);
bgmutex.unlock();
if (res == 0)
break;
}
printf("%s: play end...\n", __func__);
mp->PlayFileEnd();
pthread_exit(NULL);
@@ -660,7 +682,7 @@ bool CMoviePlayerGui::PlayBackgroundStart(const std::string &file, const std::st
fprintf(stderr, "ERROR: pthread_create(%s)\n", __func__);
} else
PlayFileEnd();
printf("%s: this %p started: res %d thread %p\n", __func__, this, res, CMoviePlayerGui::bgPlayThread);fflush(stdout);
printf("%s: this %p started: res %d thread %lx\n", __func__, this, res, bgThread);fflush(stdout);
return res;
}
@@ -671,7 +693,7 @@ void CMoviePlayerGui::stopPlayBack(void)
repeat_mode = REPEAT_OFF;
if (bgThread) {
printf("%s: this %p join background thread %p\n", __func__, this, CMoviePlayerGui::bgPlayThread);fflush(stdout);
printf("%s: this %p join background thread %lx\n", __func__, this, bgThread);fflush(stdout);
cond.broadcast();
pthread_join(bgThread, NULL);
bgThread = 0;

View File

@@ -2676,11 +2676,14 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
delete [] (unsigned char*) data;
} else {
CZapitChannel * cc = CZapit::getInstance()->GetCurrentChannel();
if (cc && (chid == cc->getChannelID())) {
CMoviePlayerGui::getInstance().stopPlayBack();
if (CMoviePlayerGui::getInstance().PlayBackgroundStart(cc->getUrl(), cc->getName(), cc->getChannelID()))
delete [] (unsigned char*) data;
else
g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_FAILED, data);
} else
delete [] (unsigned char*) data;
}
return messages_return::handled;
}