From 2f5c4ccdaae88f054143514448db33d53f84d63c Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 24 Feb 2020 18:27:43 +0000 Subject: [PATCH] Rename Player class to PlayerVideoRec. Switch to std::mutex --- objects.mk | 4 +- osd.cc | 1 - osd.h | 2 +- osddirectfb.cc | 4 +- osdopengl.cc | 4 +- osdopenvg.cc | 4 +- osdwinpixel.cc | 4 +- osdwinpixel.h | 2 +- osdwinvector.cc | 2 +- osdwinvector.h | 2 +- playerradio.h | 1 + player.cc => playervideorec.cc | 190 ++++++++++++++------------------- player.h => playervideorec.h | 23 ++-- vdr.cc | 2 +- vradiorec.cc | 11 +- vvideorec.cc | 32 +++--- vvideorec.h | 4 +- 17 files changed, 126 insertions(+), 166 deletions(-) rename player.cc => playervideorec.cc (90%) rename player.h => playervideorec.h (94%) diff --git a/objects.mk b/objects.mk index d87d0ef..62d9089 100644 --- a/objects.mk +++ b/objects.mk @@ -1,7 +1,7 @@ OBJ_COMMON = command.o tcp.o dsock.o thread.o timers.o i18n.o vdp6.o \ message.o messagequeue.o wol.o audio.o video.o log.o \ vdr.o recman.o recording.o recinfo.o channel.o rectimer.o event.o \ - directory.o mark.o option.o player.o playerradio.o vfeed.o afeed.o \ + directory.o mark.o option.o playervideorec.o playerradio.o vfeed.o afeed.o \ demuxer.o demuxervdr.o demuxerts.o stream.o osd.o surface.o \ region.o colour.o boxstack.o boxx.o tbboxx.o vrecording.o \ vinfo.o vquestion.o vrecordinglist.o vrecordinglistclassic.o \ @@ -22,7 +22,7 @@ OBJ_COMMON = command.o tcp.o dsock.o thread.o timers.o i18n.o vdp6.o OBJ_RASPBERRY = main.o threadp.o osdopenvg.o \ ledraspberry.o videoomx.o audioomx.o imageomx.o \ - wjpegsimple.o inputlinux.o inputcec.o signal.o + wjpegsimple.o inputlinux.o inputcec.o OBJ_WINDOWS = winmain.o threadwin.o inputwin.o ledwin.o videowin.o \ audiowin.o windowsosd.o dsallocator.o dssourcefilter.o dssourcepin.o \ diff --git a/osd.cc b/osd.cc index ab8bf23..e497911 100644 --- a/osd.cc +++ b/osd.cc @@ -28,7 +28,6 @@ Osd::Osd() { if (instance) return; instance = this; - initted = 0; fdOsd = 0; screen = NULL; diff --git a/osd.h b/osd.h index aef86fa..89db75e 100644 --- a/osd.h +++ b/osd.h @@ -50,7 +50,7 @@ class Osd protected: static Osd* instance; - int initted; + bool initted{}; Surface* screen; int fdOsd; }; diff --git a/osddirectfb.cc b/osddirectfb.cc index 844288c..d7980c8 100644 --- a/osddirectfb.cc +++ b/osddirectfb.cc @@ -78,7 +78,7 @@ int OsdDirectFB::init() osd_layer->GetConfiguration(osd_layer,&layer_config); - initted = 1; // must set this here or create surface won't work + initted = true; // must set this here or create surface won't work /* TODO clean up sizes */ Video* video = Video::getInstance(); @@ -92,7 +92,7 @@ int OsdDirectFB::init() int OsdDirectFB::shutdown() { if (!initted) return 0; - initted = 0; + initted = false; delete screen; if (osd_layer) osd_layer->Release(osd_layer); if (dfb) dfb->Release(dfb); diff --git a/osdopengl.cc b/osdopengl.cc index e1986cb..2b18a35 100644 --- a/osdopengl.cc +++ b/osdopengl.cc @@ -192,7 +192,7 @@ int OsdOpenGL::init() screen->create(video->getScreenWidth(), video->getScreenHeight()); screen->display(); - initted = 1; // must set this here or create surface won't work + initted = true; // must set this here or create surface won't work //glGenBuffers(1, &vB); //glGenBuffers(1, &iB); @@ -270,7 +270,7 @@ int OsdOpenGL::shutdown() { if (!initted) return 0; glmutex.lock(); - initted = 0; + initted = false; threadStop(); delete screen; screen=NULL; diff --git a/osdopenvg.cc b/osdopenvg.cc index 4a2f15f..8101a3d 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -303,7 +303,7 @@ int OsdOpenVG::init() Log::getInstance()->log("OSD", Log::DEBUG, "Making egl current out 1%d",syscall(SYS_gettid)); eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); //Now we will create the Screen - initted = 1; // must set this here or create surface won't work + initted = true; // must set this here or create surface won't work /*if (((VideoOMX*)Video::getInstance())->initUsingOSDObjects()!=1) { //call Video for init stuff @@ -488,7 +488,7 @@ int OsdOpenVG::shutdown() if (!initted) return 0; - initted = 0; + initted = false; Log::getInstance()->log("OSD", Log::DEBUG, "shutdown mark1"); threadStop(); Log::getInstance()->log("OSD", Log::DEBUG, "shutdown mark1a"); diff --git a/osdwinpixel.cc b/osdwinpixel.cc index a64d34d..1698332 100644 --- a/osdwinpixel.cc +++ b/osdwinpixel.cc @@ -70,7 +70,7 @@ int OsdWinPixel::init() screen = new SurfaceWin(Surface::SCREEN); screen->create(video->getScreenWidth(), video->getScreenHeight()); screen->display(); - initted = 1; // must set this here or create surface won't work + initted = true; // must set this here or create surface won't work startRenderLoop(); @@ -81,7 +81,7 @@ int OsdWinPixel::init() int OsdWinPixel::shutdown() { if (!initted) return 0; - initted = 0; + initted = false; stopRenderLoop(); shutdownDirect3D9Objects(); diff --git a/osdwinpixel.h b/osdwinpixel.h index a9e4143..8ad2cc6 100644 --- a/osdwinpixel.h +++ b/osdwinpixel.h @@ -39,7 +39,7 @@ class OsdWinPixel : public Osd, public WindowsOsd int init(); int shutdown(); - int isInitialized() { return initted; } + bool isInitialized() { return initted; } int getFD(); diff --git a/osdwinvector.cc b/osdwinvector.cc index f9ef386..d6c7b34 100644 --- a/osdwinvector.cc +++ b/osdwinvector.cc @@ -398,7 +398,7 @@ int OsdWinVector::init() loadFont(false); - initted = 1; // must set this here or create surface won't work + initted = true; // must set this here or create surface won't work startRenderLoop(); diff --git a/osdwinvector.h b/osdwinvector.h index 058e205..923882a 100644 --- a/osdwinvector.h +++ b/osdwinvector.h @@ -45,7 +45,7 @@ class OsdWinVector : public OsdVector, public WindowsOsd int init(); int shutdown(); - int isInitialized() { return initted; } + bool isInitialized() { return initted; } void getScreenSize(int &width, int &height); void getRealScreenSize(int &width, int &height); diff --git a/playerradio.h b/playerradio.h index 9cf5f70..07f9f41 100644 --- a/playerradio.h +++ b/playerradio.h @@ -74,6 +74,7 @@ class PlayerRadio : public Thread_TYPE, public Callback const static UCHAR S_PLAY = 1; const static UCHAR S_PAUSE_P = 2; + const static UCHAR S_PAUSE_I = 3; const static UCHAR S_STOP = 6; const static UCHAR S_JUMP = 7; diff --git a/player.cc b/playervideorec.cc similarity index 90% rename from player.cc rename to playervideorec.cc index 6dba51f..0d138bf 100644 --- a/player.cc +++ b/playervideorec.cc @@ -17,8 +17,6 @@ along with VOMP. If not, see . */ -#include "player.h" - #include "log.h" #include "audio.h" #include "video.h" @@ -31,16 +29,16 @@ #include "dvbsubtitles.h" #include "osdreceiver.h" +#include "playervideorec.h" + #define USER_RESPONSE_TIME 500 // Milliseconds // ----------------------------------- Called from outside, one offs or info funcs -Player::Player(MessageQueue* tmessageQueue, void* tmessageReceiver, OSDReceiver* tosdReceiver) -: vfeed(this), afeed(this), tfeed(this) +PlayerVideoRec::PlayerVideoRec(MessageQueue* tmessageQueue, void* tmessageReceiver, OSDReceiver* tosdReceiver) +: vfeed(this), afeed(this), tfeed(this), messageQueue(tmessageQueue), + messageReceiver(tmessageReceiver), osdReceiver(tosdReceiver) { - messageQueue = tmessageQueue; - messageReceiver = tmessageReceiver; - osdReceiver = tosdReceiver; audio = Audio::getInstance(); video = Video::getInstance(); logger = Log::getInstance(); @@ -49,19 +47,14 @@ Player::Player(MessageQueue* tmessageQueue, void* tmessageReceiver, OSDReceiver* video->turnVideoOn(); } -Player::~Player() +PlayerVideoRec::~PlayerVideoRec() { if (initted) shutdown(); } -int Player::init(bool p_isPesRecording, double framespersecond) +int PlayerVideoRec::init(bool p_isPesRecording, double framespersecond) { if (initted) return 0; -#ifndef WIN32 - pthread_mutex_init(&mutex, NULL); -#else - mutex=CreateMutex(NULL,FALSE,NULL); -#endif is_pesrecording = p_isPesRecording; fps = framespersecond; if (is_pesrecording) @@ -110,7 +103,7 @@ int Player::init(bool p_isPesRecording, double framespersecond) return 1; } -int Player::shutdown() +int PlayerVideoRec::shutdown() { if (!initted) return 0; switchState(S_STOP); @@ -123,14 +116,10 @@ int Player::shutdown() delete teletext; teletext = NULL; -#ifdef WIN32 - CloseHandle(mutex); -#endif - return 1; } -void Player::setStartFrame(ULONG startFrame) +void PlayerVideoRec::setStartFrame(ULONG startFrame) { ULONG nextiframeNumber; ULONG iframeLength; @@ -147,24 +136,24 @@ void Player::setStartFrame(ULONG startFrame) currentFrameNumber = iframeNumber; } -void Player::setLengthBytes(ULLONG length) +void PlayerVideoRec::setLengthBytes(ULLONG length) { lengthBytes = length; logger->log("Player", Log::DEBUG, "Player has received length bytes of %llu", lengthBytes); } -void Player::setLengthFrames(ULONG length) +void PlayerVideoRec::setLengthFrames(ULONG length) { lengthFrames = length; logger->log("Player", Log::DEBUG, "Player has received length frames of %lu", lengthFrames); } -ULONG Player::getLengthFrames() +ULONG PlayerVideoRec::getLengthFrames() { return lengthFrames; } -ULONG Player::getCurrentFrameNum() +ULONG PlayerVideoRec::getCurrentFrameNum() { if (startup) return 0; switch(state) @@ -181,22 +170,22 @@ ULONG Player::getCurrentFrameNum() } } -bool* Player::getDemuxerMpegAudioChannels() +bool* PlayerVideoRec::getDemuxerMpegAudioChannels() { return demuxer->getmpAudioChannels(); } -bool* Player::getDemuxerAc3AudioChannels() +bool* PlayerVideoRec::getDemuxerAc3AudioChannels() { return demuxer->getac3AudioChannels(); } -bool* Player::getDemuxerSubtitleChannels() +bool* PlayerVideoRec::getDemuxerSubtitleChannels() { return demuxer->getSubtitleChannels(); } -int Player::getCurrentAudioChannel() +int PlayerVideoRec::getCurrentAudioChannel() { if (is_pesrecording) return demuxer->getselAudioChannel(); @@ -204,7 +193,7 @@ int Player::getCurrentAudioChannel() return dynamic_cast(demuxer)->getAID(); } -int Player::getCurrentSubtitleChannel() +int PlayerVideoRec::getCurrentSubtitleChannel() { if (is_pesrecording) return demuxer->getselSubtitleChannel(); @@ -212,7 +201,7 @@ int Player::getCurrentSubtitleChannel() return dynamic_cast(demuxer)->getSubID(); } -void Player::setSubtitleChannel(int newChannel) +void PlayerVideoRec::setSubtitleChannel(int newChannel) { if (is_pesrecording) demuxer->setDVBSubtitleStream(newChannel); @@ -220,12 +209,12 @@ void Player::setSubtitleChannel(int newChannel) dynamic_cast(demuxer)->setSubID(newChannel); } -int *Player::getTeletxtSubtitlePages() +int *PlayerVideoRec::getTeletxtSubtitlePages() { return teletext->getSubtitlePages(); } -void Player::setAudioChannel(int newChannel, int type, int streamtype) +void PlayerVideoRec::setAudioChannel(int newChannel, int type, int streamtype) { if (is_pesrecording) { @@ -239,7 +228,7 @@ void Player::setAudioChannel(int newChannel, int type, int streamtype) } } -bool Player::toggleSubtitles() +bool PlayerVideoRec::toggleSubtitles() { if (!subtitlesShowing) { @@ -254,7 +243,7 @@ bool Player::toggleSubtitles() return subtitlesShowing; } -void Player::turnSubtitlesOn(bool ison) +void PlayerVideoRec::turnSubtitlesOn(bool ison) { if (ison) { @@ -268,12 +257,12 @@ void Player::turnSubtitlesOn(bool ison) } } -void Player::tellSubtitlesOSDVisible(bool visible) +void PlayerVideoRec::tellSubtitlesOSDVisible(bool visible) { subtitles->setOSDMenuVisibility(visible); } -Channel * Player::getDemuxerChannel() +Channel * PlayerVideoRec::getDemuxerChannel() { if (!is_pesrecording) { @@ -285,22 +274,22 @@ Channel * Player::getDemuxerChannel() // ----------------------------------- Externally called events -void Player::play() +void PlayerVideoRec::play() { if (!initted) return; if (state == S_PLAY) return; - lock(); + stateMutex.lock(); bool doUnlock = false; if (state == S_PAUSE_P) doUnlock = true; switchState(S_PLAY); - if (doUnlock) unLock(); + if (doUnlock) stateMutex.unlock(); } -void Player::playpause() +void PlayerVideoRec::playpause() { if (!initted) return; - lock(); + stateMutex.lock(); bool doUnlock = false; if (state==S_PLAY) @@ -313,23 +302,23 @@ void Player::playpause() if (state == S_PAUSE_P) doUnlock = true; switchState(S_PLAY); } - if (doUnlock) unLock(); + if (doUnlock) stateMutex.unlock(); } -void Player::stop() +void PlayerVideoRec::stop() { if (!initted) return; if (state == S_STOP) return; - lock(); + stateMutex.lock(); logger->log("Player", Log::DEBUG, "Stop called lock"); switchState(S_STOP); - unLock(); + stateMutex.unlock(); } -void Player::pause() +void PlayerVideoRec::pause() { if (!initted) return; - lock(); + stateMutex.lock(); if ((state == S_FFWD) || (state == S_FBWD)) { @@ -344,13 +333,13 @@ void Player::pause() switchState(S_PAUSE_P); } - unLock(); + stateMutex.unlock(); } -void Player::fastForward() +void PlayerVideoRec::fastForward() { if (!initted) return; - lock(); + stateMutex.lock(); if (state == S_FFWD) { @@ -368,13 +357,13 @@ void Player::fastForward() ifactor = 4; switchState(S_FFWD); } - unLock(); + stateMutex.unlock(); } -void Player::fastBackward() +void PlayerVideoRec::fastBackward() { if (!initted) return; - lock(); + stateMutex.lock(); if (state == S_FBWD) { @@ -392,61 +381,61 @@ void Player::fastBackward() ifactor = 4; switchState(S_FBWD); } - unLock(); + stateMutex.unlock(); } -void Player::jumpToPercent(double percent) +void PlayerVideoRec::jumpToPercent(double percent) { - lock(); + stateMutex.lock(); logger->log("Player", Log::DEBUG, "JUMP TO %f%%", percent); ULONG newFrame = static_cast(percent * lengthFrames / 100); switchState(S_JUMP, newFrame); -// unLock(); - let thread unlock this +// stateMutex.unlock(); - let thread unlock this } -void Player::jumpToMark(int mark) +void PlayerVideoRec::jumpToMark(int mark) { - lock(); + stateMutex.lock(); logger->log("Player", Log::DEBUG, "JUMP TO MARK %i%%", mark); switchState(S_JUMP, mark); -// unLock(); - let thread unlock this +// stateMutex.unlock(); - let thread unlock this } -void Player::jumpToFrameP(int newFrame) +void PlayerVideoRec::jumpToFrameP(int newFrame) { - lock(); + stateMutex.lock(); logger->log("Player", Log::DEBUG, "JUMP TO FRAME AND PAUSE %i", newFrame); switchState(S_JUMP_PI, newFrame); - unLock(); + stateMutex.unlock(); } -void Player::skipForward(int seconds) +void PlayerVideoRec::skipForward(int seconds) { - lock(); + stateMutex.lock(); logger->log("Player", Log::DEBUG, "SKIP FORWARD %i SECONDS", seconds); ULONG newFrame = getCurrentFrameNum(); - if (newFrame == 0) { unLock(); return; } // Current pos from demuxer is not valid + if (newFrame == 0) { stateMutex.unlock(); return; } // Current pos from demuxer is not valid newFrame += static_cast(static_cast(seconds) * fps); - if (newFrame > lengthFrames) { switchState(S_PLAY); unLock(); } + if (newFrame > lengthFrames) { switchState(S_PLAY); stateMutex.unlock(); } else switchState(S_JUMP, newFrame); -// unLock(); - let thread unlock this +// stateMutex.unlock(); - let thread unlock this } -void Player::skipBackward(int seconds) +void PlayerVideoRec::skipBackward(int seconds) { - lock(); + stateMutex.lock(); logger->log("Player", Log::DEBUG, "SKIP BACKWARD %i SECONDS", seconds); long newFrame = getCurrentFrameNum(); - if (newFrame == 0) { unLock(); return; } // Current pos from demuxer is not valid + if (newFrame == 0) { stateMutex.unlock(); return; } // Current pos from demuxer is not valid newFrame -= static_cast(static_cast(seconds) * fps); if (newFrame < 0) newFrame = 0; switchState(S_JUMP, newFrame); -// unLock(); - let thread unlock this +// stateMutex.unlock(); - let thread unlock this } // ----------------------------------- Implementations called events -void Player::switchState(UCHAR toState, ULONG jumpFrame) +void PlayerVideoRec::switchState(UCHAR toState, ULONG jumpFrame) { if (!initted) return; @@ -889,28 +878,7 @@ void Player::switchState(UCHAR toState, ULONG jumpFrame) // ----------------------------------- Internal functions -void Player::lock() -{ -#ifndef WIN32 - pthread_mutex_lock(&mutex); - logger->log("Player", Log::DEBUG, "LOCKED"); - -#else - WaitForSingleObject(mutex, INFINITE); -#endif -} - -void Player::unLock() -{ -#ifndef WIN32 - logger->log("Player", Log::DEBUG, "UNLOCKING"); - pthread_mutex_unlock(&mutex); -#else - ReleaseMutex(mutex); -#endif -} - -void Player::restartAtFrame(ULONG newFrame) +void PlayerVideoRec::restartAtFrame(ULONG newFrame) { vfeed.stop(); afeed.stop(); @@ -939,7 +907,7 @@ void Player::restartAtFrame(ULONG newFrame) } -void Player::restartAtFramePI(ULONG newFrame) +void PlayerVideoRec::restartAtFramePI(ULONG newFrame) { ULLONG filePos; ULONG nextiframeNumber; @@ -972,20 +940,20 @@ void Player::restartAtFramePI(ULONG newFrame) } } -void Player::doConnectionLost() +void PlayerVideoRec::doConnectionLost() { logger->log("Player", Log::DEBUG, "Connection lost, sending message"); Message* m = new Message(); m->to = messageReceiver; m->from = this; m->message = Message::PLAYER_EVENT; - m->parameter = Player::CONNECTION_LOST; + m->parameter = PlayerVideoRec::CONNECTION_LOST; messageQueue->postMessage(m); } // ----------------------------------- Callback -void Player::call(void* caller) +void PlayerVideoRec::call(void* caller) { if (caller == demuxer) { @@ -1008,7 +976,7 @@ void Player::call(void* caller) m->from = this; m->to = messageReceiver; m->message = Message::PLAYER_EVENT; - m->parameter = Player::ASPECT43; + m->parameter = PlayerVideoRec::ASPECT43; messageQueue->postMessage(m); } else if (dxCurrentAspect == Demuxer::ASPECT_16_9) @@ -1020,7 +988,7 @@ void Player::call(void* caller) m->from = this; m->to = messageReceiver; m->message = Message::PLAYER_EVENT; - m->parameter = Player::ASPECT169; + m->parameter = PlayerVideoRec::ASPECT169; messageQueue->postMessage(m); } else @@ -1039,7 +1007,7 @@ void Player::call(void* caller) video->play(); video->sync(); vfeed.release(); - unLock(); + stateMutex.unlock(); } threadSignalNoLock(); @@ -1048,7 +1016,7 @@ void Player::call(void* caller) // ----------------------------------- Feed thread -void Player::threadMethod() +void PlayerVideoRec::threadMethod() { // this method used to be simple, the only thing it does // is farm out to threadFeed Live/Play/Scan @@ -1093,7 +1061,7 @@ void Player::threadMethod() if (state == S_PLAY) threadFeedPlay(); } -void Player::threadFeedPlay() +void PlayerVideoRec::threadFeedPlay() { ULLONG feedPosition; UINT thisRead, writeLength, thisWrite, askFor; @@ -1192,7 +1160,7 @@ void Player::threadFeedPlay() if (videoStartup) // oh woe. there never was a stream, I was conned! { videoStartup = false; - unLock(); + stateMutex.unlock(); MILLISLEEP(500); // I think this will solve a race } @@ -1203,13 +1171,13 @@ void Player::threadFeedPlay() m->to = messageReceiver; m->from = this; m->message = Message::PLAYER_EVENT; - m->parameter = Player::STOP_PLAYBACK; + m->parameter = PlayerVideoRec::STOP_PLAYBACK; logger->log("Player", Log::DEBUG, "Posting message to %p...", messageQueue); messageQueue->postMessage(m); } -void Player::threadPTSFeedScan() +void PlayerVideoRec::threadPTSFeedScan() { // This method manipulates the PTS instead of waiting, this is for the android devices, maybe later for windows? @@ -1301,7 +1269,7 @@ void Player::threadPTSFeedScan() -void Player::threadFeedScan() +void PlayerVideoRec::threadFeedScan() { // This method is actually really simple - get frame from vdr, // spit it at the video chip, wait for a time. Most of the code here @@ -1410,7 +1378,7 @@ void Player::threadFeedScan() } } -void Player::threadPostStopCleanup() +void PlayerVideoRec::threadPostStopCleanup() { if (threadBuffer) { @@ -1422,12 +1390,12 @@ void Player::threadPostStopCleanup() // ----------------------------------- Dev #ifdef DEV -void Player::test1() +void PlayerVideoRec::test1() { logger->log("Player", Log::DEBUG, "PLAYER TEST 1"); } -void Player::test2() +void PlayerVideoRec::test2() { logger->log("Player", Log::DEBUG, "PLAYER TEST 2"); } diff --git a/player.h b/playervideorec.h similarity index 94% rename from player.h rename to playervideorec.h index 45d221c..05e47b8 100644 --- a/player.h +++ b/playervideorec.h @@ -18,8 +18,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef PLAYER_H -#define PLAYER_H +#ifndef PLAYERVIDEOREC_H +#define PLAYERVIDEOREC_H #include #include @@ -27,6 +27,7 @@ #include #endif #include +#include #include "threadsystem.h" @@ -48,11 +49,11 @@ class OSDReceiver; class DVBSubtitles; class Channel; -class Player : public Thread_TYPE, public Callback +class PlayerVideoRec : public Thread_TYPE, public Callback { public: - Player(MessageQueue* messageQueue, void* messageReceiver, OSDReceiver* osdReceiver); - virtual ~Player(); + PlayerVideoRec(MessageQueue* messageQueue, void* messageReceiver, OSDReceiver* osdReceiver); + virtual ~PlayerVideoRec(); int init(bool p_isPesRecording,double framespersec); int shutdown(); @@ -149,22 +150,14 @@ class Player : public Thread_TYPE, public Callback TFeed tfeed; TeletextDecoderVBIEBU *teletext; - - bool initted{}; bool startup; bool videoStartup{}; bool is_pesrecording{true}; - double fps; + double fps; -#ifndef WIN32 - pthread_mutex_t mutex; -#else - HANDLE mutex; -#endif - void lock(); - void unLock(); + std::mutex stateMutex; ULLONG lengthBytes{}; ULONG lengthFrames{}; diff --git a/vdr.cc b/vdr.cc index c54e8f4..dc2820d 100644 --- a/vdr.cc +++ b/vdr.cc @@ -409,7 +409,7 @@ void VDR::threadMethod() vresp = new VDR_ResponsePacket(); vresp->setResponse(requestID, reinterpret_cast(userData), userDataLength); - logger->log("VDR", Log::DEBUG, "Rxd a response packet, requestID=%lu, len=%lu", requestID, userDataLength); +// logger->log("VDR", Log::DEBUG, "Rxd a response packet, requestID=%lu, len=%lu", requestID, userDataLength); if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() ) { diff --git a/vradiorec.cc b/vradiorec.cc index d53b7fa..f574ef3 100644 --- a/vradiorec.cc +++ b/vradiorec.cc @@ -19,7 +19,6 @@ #include "command.h" #include "osd.h" -#include "player.h" #include "wsymbol.h" #include "recording.h" #include "recinfo.h" @@ -312,7 +311,7 @@ void VRadioRec::processMessage(Message* m) switch(m->parameter) { - case Player::CONNECTION_LOST: // connection lost detected + case PlayerRadio::CONNECTION_LOST: // connection lost detected { // I can't handle this, send it to command Message* m2 = new Message(); @@ -321,7 +320,7 @@ void VRadioRec::processMessage(Message* m) MessageQueue::getInstance()->postMessage(m2); break; } - case Player::STOP_PLAYBACK: + case PlayerRadio::STOP_PLAYBACK: { // FIXME Obselete ish - improve this Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex @@ -386,9 +385,9 @@ void VRadioRec::doBar(int action) else { playerState = player->getState(); - if (playerState == Player::S_PAUSE_P) w.nextSymbol = WSymbol::PAUSE; - else if (playerState == Player::S_PAUSE_I) w.nextSymbol = WSymbol::PAUSE; - else w.nextSymbol = WSymbol::PLAY; + if (playerState == PlayerRadio::S_PAUSE_P) w.nextSymbol = WSymbol::PAUSE; + else if (playerState == PlayerRadio::S_PAUSE_I) w.nextSymbol = WSymbol::PAUSE; + else w.nextSymbol = WSymbol::PLAY; } w.draw(); diff --git a/vvideorec.cc b/vvideorec.cc index f212b94..e71fa0d 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -25,7 +25,7 @@ #include "audio.h" #include "vdr.h" #include "video.h" -#include "player.h" +#include "playervideorec.h" #include "recording.h" #include "vaudioselector.h" #include "message.h" @@ -56,7 +56,7 @@ VVideoRec::VVideoRec(Recording* rec, bool ish264) video->seth264mode(ish264); - player = new Player(Command::getInstance(), this, this); + player = new PlayerVideoRec(Command::getInstance(), this, this); player->init(myRec->IsPesRecording,myRec->recInfo->fps); char* cstartMargin = vdr->configLoad("Timers", "Start margin"); @@ -518,7 +518,7 @@ void VVideoRec::processMessage(Message* m) if (m->message != Message::PLAYER_EVENT) return; switch(m->parameter) { - case Player::CONNECTION_LOST: // connection lost detected + case PlayerVideoRec::CONNECTION_LOST: // connection lost detected { // I can't handle this, send it to command Message* m2 = new Message(); @@ -527,7 +527,7 @@ void VVideoRec::processMessage(Message* m) MessageQueue::getInstance()->postMessage(m2); break; } - case Player::STOP_PLAYBACK: + case PlayerVideoRec::STOP_PLAYBACK: { // FIXME Obselete ish - improve this Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex @@ -536,11 +536,11 @@ void VVideoRec::processMessage(Message* m) MessageQueue::getInstance()->postMessage(m2); break; } - case Player::ASPECT43: + case PlayerVideoRec::ASPECT43: { break; } - case Player::ASPECT169: + case PlayerVideoRec::ASPECT169: { break; } @@ -559,7 +559,7 @@ void VVideoRec::processMessage(Message* m) case 0x10: { //dvbsubtitle player->setSubtitleChannel((m->parameter & 0xFFFF)); player->turnSubtitlesOn(true); - VTeletextView *vtxt=((Player*)player)->getTeletextDecoder()->getTeletxtView(); + VTeletextView *vtxt = player->getTeletextDecoder()->getTeletxtView(); if (vtxt && vtxt->isInSubtitleMode()) { BoxStack::getInstance()->remove(vtxt); } @@ -567,7 +567,7 @@ void VVideoRec::processMessage(Message* m) case 0xFF: { //nosubtitles player->turnSubtitlesOn(false); - VTeletextView *vtxt=((Player*)player)->getTeletextDecoder()->getTeletxtView(); + VTeletextView *vtxt = player->getTeletextDecoder()->getTeletxtView(); if (vtxt && vtxt->isInSubtitleMode()) { BoxStack::getInstance()->remove(vtxt); } @@ -576,7 +576,7 @@ void VVideoRec::processMessage(Message* m) case 0x11: { //videotext player->turnSubtitlesOn(false); doTeletext(); - ((Player*)player)->getTeletextDecoder()->setPage((m->parameter & 0xFFFF)); + player->getTeletextDecoder()->setPage((m->parameter & 0xFFFF)); } break; }; if (vas) { @@ -815,16 +815,16 @@ void VVideoRec::doBar(int action_in) else { playerState = player->getState(); - if (playerState == Player::S_PAUSE_P) w.nextSymbol = WSymbol::PAUSE; - else if (playerState == Player::S_PAUSE_I) w.nextSymbol = WSymbol::PAUSE; - else if (playerState == Player::S_FFWD) w.nextSymbol = WSymbol::FFWD; - else if (playerState == Player::S_FBWD) w.nextSymbol = WSymbol::FBWD; + if (playerState == PlayerVideoRec::S_PAUSE_P) w.nextSymbol = WSymbol::PAUSE; + else if (playerState == PlayerVideoRec::S_PAUSE_I) w.nextSymbol = WSymbol::PAUSE; + else if (playerState == PlayerVideoRec::S_FFWD) w.nextSymbol = WSymbol::FFWD; + else if (playerState == PlayerVideoRec::S_FBWD) w.nextSymbol = WSymbol::FBWD; else w.nextSymbol = WSymbol::PLAY; } w.draw(); - if ((playerState == Player::S_FFWD) || (playerState == Player::S_FBWD)) + if ((playerState == PlayerVideoRec::S_FFWD) || (playerState == PlayerVideoRec::S_FBWD)) { // draw blips to show how fast the scan is UCHAR scanrate = player->getIScanRate(); @@ -844,7 +844,7 @@ void VVideoRec::doBar(int action_in) timers->cancelTimer(this, 1); - if ((playerState == Player::S_FFWD) || (playerState == Player::S_FBWD)) barScanHold = true; + if ((playerState == PlayerVideoRec::S_FFWD) || (playerState == PlayerVideoRec::S_FBWD)) barScanHold = true; else barScanHold = false; if (!barGenHold && !barScanHold && !barVasHold) timers->setTimerD(this, 1, 4); @@ -889,7 +889,7 @@ void VVideoRec::drawBarClocks() // will repaint all the bar (it will call this function again, but // this section won't run because stickyBarF will then == false) - if ((playerState != Player::S_FFWD) && (playerState != Player::S_FBWD)) + if ((playerState != PlayerVideoRec::S_FFWD) && (playerState != PlayerVideoRec::S_FBWD)) { barScanHold = false; doBar(0); diff --git a/vvideorec.h b/vvideorec.h index 9dfa4fd..2a68ee6 100644 --- a/vvideorec.h +++ b/vvideorec.h @@ -31,7 +31,7 @@ #include "video.h" class VDR; -class Player; +class PlayerVideoRec; class Recording; class VAudioSelector; class Message; @@ -65,7 +65,7 @@ class VVideoRec : public Boxx, public TimerReceiver, public OSDReceiver VDR* vdr; Video* video; Timers* timers; - Player* player; + PlayerVideoRec* player; Recording* myRec; VAudioSelector* vas; -- 2.39.5