mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 09:21:18 +02:00
gui/movieplayer.cpp: try to fix starting MB playback on webtv channel:
create another CMoviePlayerGui instance for background playback. remove define __STDC_CONSTANT_MACROS, should be added to CXXFLAGS
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#include <stdint.h>
|
||||
#include <global.h>
|
||||
@@ -77,8 +76,14 @@ extern CInfoClock *InfoClock;
|
||||
#define ISO_MOUNT_POINT "/media/iso"
|
||||
|
||||
CMoviePlayerGui* CMoviePlayerGui::instance_mp = NULL;
|
||||
CMoviePlayerGui* CMoviePlayerGui::instance_bg = NULL;
|
||||
OpenThreads::Mutex CMoviePlayerGui::mutex;
|
||||
OpenThreads::Mutex CMoviePlayerGui::bgmutex;
|
||||
OpenThreads::Condition CMoviePlayerGui::cond;
|
||||
pthread_t CMoviePlayerGui::bgThread;
|
||||
cPlayback *CMoviePlayerGui::playback;
|
||||
CMovieBrowser* CMoviePlayerGui::moviebrowser;
|
||||
CBookmarkManager * CMoviePlayerGui::bookmarkmanager;
|
||||
|
||||
CMoviePlayerGui& CMoviePlayerGui::getInstance()
|
||||
{
|
||||
@@ -86,6 +91,7 @@ CMoviePlayerGui& CMoviePlayerGui::getInstance()
|
||||
if (!instance_mp )
|
||||
{
|
||||
instance_mp = new CMoviePlayerGui();
|
||||
instance_bg = new CMoviePlayerGui();
|
||||
printf("[neutrino CMoviePlayerGui] Instance created...\n");
|
||||
}
|
||||
return *instance_mp;
|
||||
@@ -99,11 +105,20 @@ CMoviePlayerGui::CMoviePlayerGui()
|
||||
CMoviePlayerGui::~CMoviePlayerGui()
|
||||
{
|
||||
//playback->Close();
|
||||
stopPlayBack();
|
||||
if (this == instance_mp)
|
||||
stopPlayBack();
|
||||
delete moviebrowser;
|
||||
moviebrowser = NULL;
|
||||
delete filebrowser;
|
||||
filebrowser = NULL;
|
||||
delete bookmarkmanager;
|
||||
bookmarkmanager = NULL;
|
||||
delete playback;
|
||||
playback = NULL;
|
||||
if (this == instance_mp) {
|
||||
delete instance_bg;
|
||||
instance_bg = NULL;
|
||||
}
|
||||
instance_mp = NULL;
|
||||
}
|
||||
|
||||
@@ -114,9 +129,12 @@ void CMoviePlayerGui::Init(void)
|
||||
|
||||
frameBuffer = CFrameBuffer::getInstance();
|
||||
|
||||
playback = new cPlayback(0);
|
||||
moviebrowser = new CMovieBrowser();
|
||||
bookmarkmanager = new CBookmarkManager();
|
||||
if (playback == NULL)
|
||||
playback = new cPlayback(0);
|
||||
if (moviebrowser == NULL)
|
||||
moviebrowser = new CMovieBrowser();
|
||||
if (bookmarkmanager == NULL)
|
||||
bookmarkmanager = new CBookmarkManager();
|
||||
|
||||
tsfilefilter.addFilter("ts");
|
||||
tsfilefilter.addFilter("avi");
|
||||
@@ -465,7 +483,7 @@ bool CMoviePlayerGui::prepareFile(CFile *file)
|
||||
else {
|
||||
file_name = file->Url;
|
||||
pretty_name = file->Name;
|
||||
}
|
||||
}
|
||||
if (isMovieBrowser) {
|
||||
if (filelist_it != filelist.end()) {
|
||||
unsigned idx = filelist_it - filelist.begin();
|
||||
@@ -511,6 +529,7 @@ bool CMoviePlayerGui::SelectFile()
|
||||
p_movie_info = CRecordManager::getInstance()->GetMovieInfo(live_channel_id);
|
||||
file_name = CRecordManager::getInstance()->GetFileName(live_channel_id) + ".ts";
|
||||
fillPids();
|
||||
makeFilename();
|
||||
ret = true;
|
||||
}
|
||||
#if 0 // TODO
|
||||
@@ -679,28 +698,28 @@ bool CMoviePlayerGui::PlayBackgroundStart(const std::string &file, const std::st
|
||||
}
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||
|
||||
Cleanup();
|
||||
ClearFlags();
|
||||
ClearQueue();
|
||||
instance_bg->Cleanup();
|
||||
instance_bg->ClearFlags();
|
||||
instance_bg->ClearQueue();
|
||||
|
||||
isWebTV = true;
|
||||
is_file_player = true;
|
||||
isHTTP = true;
|
||||
instance_bg->isWebTV = true;
|
||||
instance_bg->is_file_player = true;
|
||||
instance_bg->isHTTP = true;
|
||||
|
||||
file_name = file;
|
||||
pretty_name = name;
|
||||
instance_bg->file_name = file;
|
||||
instance_bg->pretty_name = name;
|
||||
|
||||
movie_info.epgTitle = name;
|
||||
movie_info.epgChannel = file;
|
||||
movie_info.epgId = chan;
|
||||
p_movie_info = &movie_info;
|
||||
instance_bg->movie_info.epgTitle = name;
|
||||
instance_bg->movie_info.epgChannel = file;
|
||||
instance_bg->movie_info.epgId = chan;
|
||||
instance_bg->p_movie_info = &movie_info;
|
||||
|
||||
bool res = PlayFileStart();
|
||||
bool res = instance_bg->PlayFileStart();
|
||||
if (res) {
|
||||
if (pthread_create (&bgThread, 0, CMoviePlayerGui::bgPlayThread, this))
|
||||
if (pthread_create (&bgThread, 0, CMoviePlayerGui::bgPlayThread, instance_bg))
|
||||
fprintf(stderr, "ERROR: pthread_create(%s)\n", __func__);
|
||||
} else
|
||||
PlayFileEnd();
|
||||
instance_bg->PlayFileEnd();
|
||||
printf("%s: this %p started: res %d thread %lx\n", __func__, this, res, bgThread);fflush(stdout);
|
||||
return res;
|
||||
}
|
||||
@@ -802,7 +821,13 @@ bool CMoviePlayerGui::PlayFileStart(void)
|
||||
startposition = -1;
|
||||
int i;
|
||||
int towait = (timeshift == TSHIFT_MODE_ON) ? TIMESHIFT_SECONDS+1 : TIMESHIFT_SECONDS;
|
||||
for(i = 0; i < 500; i++) {
|
||||
int cnt = 500;
|
||||
if (IS_WEBTV(movie_info.epgId)) {
|
||||
videoDecoder->setBlank(false);
|
||||
cnt = 200;
|
||||
towait = 20;
|
||||
}
|
||||
for(i = 0; i < cnt; i++) {
|
||||
playback->GetPosition(position, duration);
|
||||
startposition = (duration - position);
|
||||
|
||||
@@ -812,6 +837,7 @@ bool CMoviePlayerGui::PlayFileStart(void)
|
||||
|
||||
usleep(20000);
|
||||
}
|
||||
printf("CMoviePlayerGui::PlayFile: waiting for data: i=%d position %d duration %d (%d), start %d\n", i, position, duration, towait, startposition);
|
||||
if (timeshift == TSHIFT_MODE_REWIND) {
|
||||
startposition = duration;
|
||||
} else {
|
||||
@@ -820,13 +846,14 @@ bool CMoviePlayerGui::PlayFileStart(void)
|
||||
if (timeshift == TSHIFT_MODE_ON)
|
||||
startposition = 0;
|
||||
else
|
||||
startposition = duration - TIMESHIFT_SECONDS*1000;
|
||||
startposition = std::max(0, duration - towait*1000);
|
||||
}
|
||||
printf("******************* Timeshift %d, position %d, seek to %d seconds\n", timeshift, position, startposition/1000);
|
||||
}
|
||||
if (/* !is_file_player && */ startposition >= 0)//FIXME no jump for file at start yet
|
||||
if (/* !is_file_player && */ startposition >= 0)
|
||||
playback->SetPosition(startposition, true);
|
||||
|
||||
|
||||
/* playback->Start() starts paused */
|
||||
if (timeshift == TSHIFT_MODE_REWIND) {
|
||||
speed = -1;
|
||||
|
@@ -123,7 +123,7 @@ class CMoviePlayerGui : public CMenuTarget
|
||||
bool isWebTV;
|
||||
bool isYT;
|
||||
bool showStartingHint;
|
||||
CMovieBrowser* moviebrowser;
|
||||
static CMovieBrowser* moviebrowser;
|
||||
MI_MOVIE_INFO * p_movie_info;
|
||||
MI_MOVIE_INFO movie_info;
|
||||
P_MI_MOVIE_LIST milist;
|
||||
@@ -142,16 +142,17 @@ class CMoviePlayerGui : public CMenuTarget
|
||||
bool autoshot_done;
|
||||
|
||||
/* playback from bookmark */
|
||||
CBookmarkManager * bookmarkmanager;
|
||||
static CBookmarkManager * bookmarkmanager;
|
||||
bool isBookmark;
|
||||
|
||||
OpenThreads::Mutex mutex;
|
||||
static OpenThreads::Mutex mutex;
|
||||
static OpenThreads::Mutex bgmutex;
|
||||
static OpenThreads::Condition cond;
|
||||
pthread_t bgThread;
|
||||
static pthread_t bgThread;
|
||||
|
||||
cPlayback *playback;
|
||||
static cPlayback *playback;
|
||||
static CMoviePlayerGui* instance_mp;
|
||||
static CMoviePlayerGui* instance_bg;
|
||||
|
||||
void Init(void);
|
||||
void PlayFile();
|
||||
|
Reference in New Issue
Block a user