From 20fd49eada7631c8866b71703b5cf91f8972561a Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 14 Mar 2020 18:50:45 +0000 Subject: [PATCH] CWFs, brace-inits, clean up PlayerVideoLive and WProgressBar --- playervideolive.cc | 245 ++++++++++++++++++++++----------------------- playervideolive.h | 26 ++--- wprogressbar.cc | 19 +--- wprogressbar.h | 13 +-- 4 files changed, 137 insertions(+), 166 deletions(-) diff --git a/playervideolive.cc b/playervideolive.cc index d41f992..38e928f 100644 --- a/playervideolive.cc +++ b/playervideolive.cc @@ -36,24 +36,13 @@ // ----------------------------------- Called from outside, one offs or info funcs PlayerVideoLive::PlayerVideoLive(MessageQueue* tmessageQueue, void* tmessageReceiver, OSDReceiver* tosdReceiver, ChannelList* tchanList) -: vfeed(this), afeed(this), tfeed(this) +: vfeed(this), afeed(this), tfeed(this), + messageQueue(tmessageQueue), messageReceiver(tmessageReceiver), osdReceiver(tosdReceiver), chanList(tchanList) { - messageQueue = tmessageQueue; - messageReceiver = tmessageReceiver; - osdReceiver = tosdReceiver; - chanList = tchanList; - audio = Audio::getInstance(); video = Video::getInstance(); logger = Log::getInstance(); vdr = VDR::getInstance(); - initted = false; - - subtitlesShowing = false; - videoStartup = false; - pendingAudioPlay = false; - - state = S_STOP; video->turnVideoOn(); } @@ -96,7 +85,6 @@ int PlayerVideoLive::init() return 0; } - video->stop(); video->blank(); audio->stop(); @@ -729,132 +717,133 @@ void PlayerVideoLive::threadMethod() if (!checkError()) { - Channel* chan = (*chanList)[i.channelIndex]; - chan->loadPids(); - h264=chan->vstreamtype==0x1b; - demuxer->seth264(h264); - video->seth264mode(chan->vstreamtype==0x1b); - demuxer->setVID(chan->vpid); - video->seth264mode(chan->vstreamtype==0x1b); - - bool dolby=false; - int selected=-1; - int prefered=-1; - Command* command = Command::getInstance(); - - if (chan->numDPids > 0 && audio->maysupportAc3()) - { - ULONG j = 0; - while (j < chan->numDPids) - { - int newpref = command->getLangPref(false, chan->dpids[j].desc); - if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type) - && (prefered < 0 || newpref < prefered)) - { - selected = j; - dolby=true; - prefered = newpref; - } - j++; - } - } - - - - if (chan->numAPids > 0) - { - ULONG j = 0; - while (j < chan->numAPids) - { - int newpref = command->getLangPref(false, chan->apids[j].desc); - if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type) - && (prefered < 0 || newpref < prefered)) - { - selected = j; - dolby=false; - prefered = newpref; - } - j++; - } - } - - - if (selected >= 0) { - if (dolby) { - demuxer->setAID(chan->dpids[selected].pid, 1, chan->dpids[selected].type, true); - audio->setStreamType(Audio::MPEG2_PES); - logger->log("PlayerVideoLive", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u", - chan->vpid, chan->dpids[selected].pid, chan->dpids[selected].type); - } else { - demuxer->setAID(chan->apids[selected].pid, 0, chan->apids[selected].type, true); - audio->setStreamType(Audio::MPEG2_PES); - logger->log("PlayerVideoLive", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[selected].pid, - chan->apids[selected].type); - } - - } else { - logger->log("PlayerVideoLive", Log::WARN, "Demuxer video pid only: %u", chan->vpid); - } - - - selected = -1; - prefered=-1; - if (chan->numSPids) { - ULONG j = 0; - while (j < chan->numSPids) - { - int newpref = command->getLangPref(true, chan->spids[j].desc); - if ( (prefered < 0 || newpref < prefered)) - { - selected = j; - prefered = newpref; - } - j++; - } - } - - if (selected >= 0) - { - demuxer->setSubID(chan->spids[selected].pid); + Channel* chan = (*chanList)[i.channelIndex]; + chan->loadPids(); + h264 = (chan->vstreamtype == 0x1b); + demuxer->seth264(h264); + video->seth264mode(h264); + demuxer->setVID(chan->vpid); + video->seth264mode(h264); - if (firstStart) + bool dolby = false; + int selected = -1; + int prefered = -1; + + Command* command = Command::getInstance(); + + if (chan->numDPids > 0 && audio->maysupportAc3()) + { + ULONG j = 0; + while (j < chan->numDPids) + { + int newpref = command->getLangPref(false, chan->dpids[j].desc); + if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type) && (prefered < 0 || newpref < prefered)) { - firstStart = false; + selected = j; + dolby=true; + prefered = newpref; + } + j++; + } + } - if (command->getSubDefault()) - turnSubtitlesOn(true); - else - turnSubtitlesOn(false); + if (chan->numAPids > 0) + { + ULONG j = 0; + while (j < chan->numAPids) + { + int newpref = command->getLangPref(false, chan->apids[j].desc); + if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type) && (prefered < 0 || newpref < prefered)) + { + selected = j; + dolby = false; + prefered = newpref; } - else + j++; + } + } + + if (selected >= 0) + { + if (dolby) + { + demuxer->setAID(chan->dpids[selected].pid, 1, chan->dpids[selected].type, true); + audio->setStreamType(Audio::MPEG2_PES); + logger->log("PlayerVideoLive", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u", + chan->vpid, chan->dpids[selected].pid, chan->dpids[selected].type); + } + else + { + demuxer->setAID(chan->apids[selected].pid, 0, chan->apids[selected].type, true); + audio->setStreamType(Audio::MPEG2_PES); + logger->log("PlayerVideoLive", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[selected].pid, + chan->apids[selected].type); + } + } + else + { + logger->log("PlayerVideoLive", Log::WARN, "Demuxer video pid only: %u", chan->vpid); + } + + selected = -1; + prefered = -1; + if (chan->numSPids) + { + ULONG j = 0; + while (j < chan->numSPids) + { + int newpref = command->getLangPref(true, chan->spids[j].desc); + if ((prefered < 0 || newpref < prefered)) { - if (subsRestore) - turnSubtitlesOn(true); - else - turnSubtitlesOn(false); + selected = j; + prefered = newpref; } + j++; + } + } + + if (selected >= 0) + { + demuxer->setSubID(chan->spids[selected].pid); + + if (firstStart) + { + firstStart = false; + + if (command->getSubDefault()) + turnSubtitlesOn(true); + else + turnSubtitlesOn(false); } + else + { + if (subsRestore) + turnSubtitlesOn(true); + else + turnSubtitlesOn(false); + } + } - demuxer->setTID(chan->tpid); - teletext->ResetDecoder(); - int streamSuccess = vdr->streamChannel(chan->number, this); - if (!checkError() && !streamSuccess) - { - Message* m = new Message(); - m->from = this; - m->to = messageReceiver; - m->message = Message::PLAYER_EVENT; - m->parameter = PlayerVideoLive::STREAM_END; - messageQueue->postMessage(m); - } + demuxer->setTID(chan->tpid); + teletext->ResetDecoder(); + int streamSuccess = vdr->streamChannel(chan->number, this); + if (!checkError() && !streamSuccess) + { + Message* m = new Message(); + m->from = this; + m->to = messageReceiver; + m->message = Message::PLAYER_EVENT; + m->parameter = PlayerVideoLive::STREAM_END; + messageQueue->postMessage(m); + } } } else if (i.instruction == I_STOP) { - logger->log("PlayerVideoLive", Log::DEBUG, "Stopping by instruction"); - switchState(S_STOP); - checkError(); - return; + logger->log("PlayerVideoLive", Log::DEBUG, "Stopping by instruction"); + switchState(S_STOP); + checkError(); + return; } } diff --git a/playervideolive.h b/playervideolive.h index a707748..b619433 100644 --- a/playervideolive.h +++ b/playervideolive.h @@ -1,5 +1,5 @@ /* - Copyright 2004-2005 Chris Tallon + Copyright 2004-2020 Chris Tallon This file is part of VOMP. @@ -98,10 +98,13 @@ class PlayerVideoLive : public PlayerLive, public Callback, public StreamReceive void threadMethod(); private: - bool subtitlesShowing; + VFeed vfeed; + AFeed afeed; + TFeed tfeed; MessageQueue* messageQueue; void* messageReceiver; OSDReceiver* osdReceiver; + ChannelList* chanList; Log* logger; Audio* audio; Video* video; @@ -109,25 +112,18 @@ class PlayerVideoLive : public PlayerLive, public Callback, public StreamReceive DVBSubtitles* subtitles; TeletextDecoderVBIEBU *teletext; VDR* vdr; - VFeed vfeed; - AFeed afeed; - TFeed tfeed; - ChannelList* chanList; - bool firstStart{true}; std::queue instructions; const static UCHAR I_SETCHANNEL = 1; const static UCHAR I_STOP = 2; - + std::queue streamChunks; - - bool initted; + std::thread playerThread; std::mutex playerThreadMutex; std::condition_variable playerThreadCond; - UCHAR state; const static UCHAR S_STOP = 1; const static UCHAR S_VIDEOSTARTUP = 2; const static UCHAR S_PREBUFFERING = 3; @@ -135,8 +131,12 @@ class PlayerVideoLive : public PlayerLive, public Callback, public StreamReceive void switchState(UCHAR newState); bool checkError(); - bool videoStartup; - bool pendingAudioPlay; + bool initted{}; + UCHAR state{S_STOP}; + bool subtitlesShowing{}; + bool firstStart{true}; + bool videoStartup{}; + bool pendingAudioPlay{}; bool h264; int preBufferCount; const static int preBufferAmount = 3; diff --git a/wprogressbar.cc b/wprogressbar.cc index a41f219..9931563 100644 --- a/wprogressbar.cc +++ b/wprogressbar.cc @@ -1,5 +1,5 @@ /* - Copyright 2008 Chris Tallon + Copyright 2008-2020 Chris Tallon This file is part of VOMP. @@ -14,22 +14,12 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ -#include "wprogressbar.h" - #include "colour.h" -WProgressBar::WProgressBar() -{ - percent = 0; -} - -WProgressBar::~WProgressBar() -{ -} +#include "wprogressbar.h" void WProgressBar::setPercent(UINT tpercent) { @@ -50,7 +40,6 @@ void WProgressBar::draw() rectangle(0, 0, 2, area.h, DrawStyle::LIGHTTEXT); // left rectangle(area.w - 2, 0, 2, area.h, DrawStyle::LIGHTTEXT); // right - int progressWidth = (int)((area.w - 4) * (float)percent / 100); + int progressWidth = (area.w - 4) * percent / 100; rectangle(2, 2, progressWidth, area.h - 4, DrawStyle::PROGRESSBAR); } - diff --git a/wprogressbar.h b/wprogressbar.h index d7addc4..5b28f68 100644 --- a/wprogressbar.h +++ b/wprogressbar.h @@ -1,5 +1,5 @@ /* - Copyright 2008 Chris Tallon + Copyright 2008-2020 Chris Tallon This file is part of VOMP. @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ /* @@ -26,23 +25,17 @@ recording playback bar could be rolled into this class #ifndef WPROGRESSBAR_H #define WPROGRESSBAR_H -#include -#include - #include "defines.h" #include "boxx.h" class WProgressBar : public Boxx { public: - WProgressBar(); - virtual ~WProgressBar(); void setPercent(UINT percent); void draw(); private: - UINT percent; + UINT percent{}; }; #endif - -- 2.39.2