From a1182edac31e3e48193761c8030b2a2a5232ddfd Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sat, 2 Sep 2023 20:58:26 +0200 Subject: [PATCH] movieplayer: rework player handling Signed-off-by: GetAway --- src/gui/movieplayer.cpp | 12 ++++++++++-- src/gui/movieplayer.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 32d837cf8..5f6abfaf1 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -170,8 +170,8 @@ void CMoviePlayerGui::Init(void) frameBuffer = CFrameBuffer::getInstance(); - if (playback == NULL) - playback = new cPlayback(0); + // init playback instance + playback = getPlayback(); #if HAVE_CST_HARDWARE videoDecoder->setPlaybackPtr(playback); #endif @@ -3515,3 +3515,11 @@ size_t CMoviePlayerGui::GetReadCount() //printf("GetReadCount: %lld\n", res); return (size_t) res; } + +cPlayback *CMoviePlayerGui::getPlayback() +{ + if (playback == NULL) // mutex needed ? + playback = new cPlayback(0); + + return playback; +} diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index 49adce52e..4516a51d6 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -275,7 +275,7 @@ class CMoviePlayerGui : public CMenuTarget tshift_mode timeshift; void deleteTimeshift() { timeshift_deletion = true; } int file_prozent; - cPlayback *getPlayback() { return playback; } + static cPlayback *getPlayback(); void SetFile(std::string &name, std::string &file, std::string info1="", std::string info2="", std::string file2="") { pretty_name = name; file_name = file; info_1 = info1; info_2 = info2; second_file_name = file2; } bool PlayBackgroundStart(const std::string &file, const std::string &name, t_channel_id chan, const std::string &script=""); void stopPlayBack(void);