From d3becd8bbaf12a5328585b429fad2472628da920 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 14 Mar 2020 15:51:01 +0000 Subject: [PATCH] 31 CWFs --- audioomx.cc | 59 ++++++++++-------------- vvideolivetv.cc | 120 ++++++++++++++++++++++++++---------------------- 2 files changed, 90 insertions(+), 89 deletions(-) diff --git a/audioomx.cc b/audioomx.cc index d331d37..e522d2d 100644 --- a/audioomx.cc +++ b/audioomx.cc @@ -94,7 +94,7 @@ int AudioOMX::init(UCHAR tstreamType) { unMute(); decompress_buffer_size=20000; - decompress_buffer=(UCHAR*)malloc(decompress_buffer_size); + decompress_buffer=static_cast(malloc(decompress_buffer_size)); decompress_buffer_filled=0; #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100) @@ -505,10 +505,9 @@ bool AudioOMX::addOptionsToPanes(int panenumber,Options *options,WOptionPane* pa OMX_ERRORTYPE AudioOMX::EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp,OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* buffer){ //Log::getInstance()->log("Audio", Log::NOTICE, "EmptyBufferDone"); - AudioOMX *audio=(AudioOMX *)getInstance(); + AudioOMX* audio = static_cast(getInstance()); audio->ReturnEmptyOMXBuffer(buffer); return OMX_ErrorNone; - } void AudioOMX::ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* buffer){ @@ -517,13 +516,13 @@ void AudioOMX::ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* buffer){ input_bufs_omx_free.push_back(buffer); //Log::getInstance()->log("Audio", Log::NOTICE, "ReturnEmptyOMXBuffer %d",input_bufs_omx_free.size()); input_bufs_omx_mutex.unlock(); - VideoOMX *video=(VideoOMX*)Video::getInstance(); + VideoOMX* video = static_cast(Video::getInstance()); video->signalOmx(); } OMX_ERRORTYPE AudioOMX::FillBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp, OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* buffer) { Log::getInstance()->log("Audio", Log::NOTICE, "FillBufferDone"); - VideoOMX *video=(VideoOMX*)Video::getInstance(); + VideoOMX* video = static_cast(Video::getInstance()); video->signalOmx(); return OMX_ErrorNone; } @@ -568,7 +567,7 @@ int AudioOMX::play() { lastAType=MPTYPE_MPEG_AUDIO; Log::getInstance()->log("Audio", Log::DEBUG, "enter play"); - ((VideoOMX*)Video::getInstance())->interlaceSwitch4Demux(); // switch resolution if necessary + static_cast(Video::getInstance())->interlaceSwitch4Demux(); // switch resolution if necessary if (!AllocateCodecsOMX()) { return 0; @@ -700,7 +699,7 @@ int AudioOMX::ChangeAudioPortConfig(bool disport) //clock aka omx mutex needs to DeAllocateCodecsOMX(); return 0; }*/ - VideoOMX* video=(VideoOMX*)Video::getInstance(); + VideoOMX* video = static_cast(Video::getInstance()); if (disport) { video->DisablePort(omx_aud_rend,omx_rend_input_port,false); //DestroyInputBufsOMXwhilePlaying(); @@ -957,7 +956,7 @@ int AudioOMX::AllocateCodecsOMX() Log::getInstance()->log("Audio", Log::NOTICE, "Allocate Codecs OMX"); //Clock, move later to audio - VideoOMX *video=(VideoOMX*)Video::getInstance(); + VideoOMX* video = static_cast(Video::getInstance()); if (!InitDecoderLibAV()) return 0;; @@ -1181,12 +1180,10 @@ int AudioOMX::AllocateCodecsOMX() return 1; } - - - int AudioOMX::PrepareInputBufsOMX(bool setportdef) //needs to be called with locvke omx clock mutex { - VideoOMX *video=(VideoOMX*)Video::getInstance(); + VideoOMX* video = static_cast(Video::getInstance()); + OMX_ERRORTYPE error; OMX_PARAM_PORTDEFINITIONTYPE port_def_type; memset(&port_def_type,0,sizeof(port_def_type)); @@ -1299,11 +1296,10 @@ int AudioOMX::DestroyInputBufsOMXwhilePlaying() //call with clock mutex locked int AudioOMX::DeAllocateCodecsOMX() { - OMX_ERRORTYPE error; - omx_running=false; - VideoOMX *video=(VideoOMX*)Video::getInstance(); - Log::getInstance()->log("Audio", Log::DEBUG, "enter deallocatecodecsomx"); - + OMX_ERRORTYPE error; + omx_running=false; + VideoOMX* video = static_cast(Video::getInstance()); + Log::getInstance()->log("Audio", Log::DEBUG, "enter deallocatecodecsomx"); Log::getInstance()->log("Audio", Log::DEBUG, "deallocatecodecsomx mark 1"); @@ -1467,7 +1463,7 @@ int AudioOMX::mute() { if (!initted) return 0; Log::getInstance()->log("Audio", Log::DEBUG, "MUTE MUTE MUTE"); - VideoOMX *vw = (VideoOMX*) Video::getInstance(); + VideoOMX* vw = static_cast(Video::getInstance()); vw->LockClock(); if (omx_running) { @@ -1499,7 +1495,7 @@ int AudioOMX::unMute() if (!initted) return 0; Log::getInstance()->log("Audio", Log::DEBUG, "MUTE OFF OFF OFF"); - VideoOMX *vw = (VideoOMX*) Video::getInstance(); + VideoOMX* vw = static_cast(Video::getInstance()); vw->LockClock(); if (omx_running) { @@ -1526,24 +1522,19 @@ int AudioOMX::unMute() return 1; } -int AudioOMX::pause() { - if (!initted) - return 0; - - VideoOMX *vw = (VideoOMX*) Video::getInstance(); +int AudioOMX::pause() +{ + if (!initted) return 0; + VideoOMX* vw = static_cast(Video::getInstance()); vw->clockPause(); - return 1; } int AudioOMX::unPause() { if (!initted) return 0; - - VideoOMX *vw = (VideoOMX*) Video::getInstance(); - + VideoOMX* vw = static_cast(Video::getInstance()); vw->clockUnpause(); - return 1; } @@ -1573,8 +1564,8 @@ int AudioOMX::setVolume(int tvolume) // over the whole 0-20 range volume=tvolume; + VideoOMX* vw = static_cast(Video::getInstance()); - VideoOMX *vw = (VideoOMX*) Video::getInstance(); vw->LockClock(); if (omx_running) { @@ -1755,9 +1746,9 @@ UINT AudioOMX::DeliverMediaSample(UCHAR* buffer, UINT* samplepos) { } -long long AudioOMX::correctAudioLatency(long long pts,int addsamples,int srate) { - - VideoOMX *video = (VideoOMX*) Video::getInstance(); +long long AudioOMX::correctAudioLatency(long long pts,int addsamples,int srate) +{ + VideoOMX* video = static_cast(Video::getInstance()); video->LockClock(); OMX_PARAM_U32TYPE audio_lat; OMX_ERRORTYPE error; @@ -1803,7 +1794,7 @@ bool AudioOMX::DrainTargetBufferFull() UINT AudioOMX::DeliverMediaPacket(MediaPacket mpacket, const UCHAR* buffer, UINT *samplepos) { /*First Check, if we have an audio sample*/ - VideoOMX *vw = (VideoOMX*) Video::getInstance(); + VideoOMX* vw = static_cast(Video::getInstance()); bool achange=false; OMX_ERRORTYPE error; //Log *logger=Log::getInstance(); diff --git a/vvideolivetv.cc b/vvideolivetv.cc index a332417..6ff8273 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -477,7 +477,7 @@ void VVideoLiveTV::doLeftRight(bool right) displayOSD(true); } -void VVideoLiveTV::doUpDown(bool down) +void VVideoLiveTV::doUpDown(bool /* down */) { if (osd.getVisible()) { @@ -601,8 +601,11 @@ void VVideoLiveTV::doKey(int command) void VVideoLiveTV::doTeletext(bool subtitlemode) { - if (streamType !=VDR::VIDEO) return; - (static_cast(player))->tellSubtitlesOSDVisible(true); + if (streamType != VDR::VIDEO) return; + + PlayerVideoLive* playervl = static_cast(player); + + playervl->tellSubtitlesOSDVisible(true); bool exists = true; // Cancel keying @@ -615,14 +618,14 @@ void VVideoLiveTV::doTeletext(bool subtitlemode) osdChanNum.setText(formatChanNum); osdChanName.setText((*chanList)[osdChannelIndex]->name); } - (static_cast(player))->tellSubtitlesOSDVisible(true); + playervl->tellSubtitlesOSDVisible(true); if (osd.getVisible()) clearScreen(); // Draw the teletxt - VTeletextView *vtxv=((PlayerVideoLive*)player)->getTeletextDecoder()->getTeletxtView(); - if (vtxv==NULL) + VTeletextView* vtxv = playervl->getTeletextDecoder()->getTeletxtView(); + if (vtxv == NULL) { - vtxv= new VTeletextView(((PlayerVideoLive*)player)->getTeletextDecoder(),this, (PlayerVideoLive*)player); - ((PlayerVideoLive*)player)->getTeletextDecoder()->registerTeletextView(vtxv); + vtxv = new VTeletextView(playervl->getTeletextDecoder(), this, playervl); + playervl->getTeletextDecoder()->registerTeletextView(vtxv); exists=false; } @@ -641,6 +644,9 @@ void VVideoLiveTV::doTeletext(bool subtitlemode) void VVideoLiveTV::doAudioSelector() { + // Only called if streamtype == VDR::VIDEO + PlayerVideoLive* playervl = static_cast(player); + // If the osd is already visisble there might be a timer for it Timers::getInstance()->cancelTimer(this, 1); //This causes a deadlock with the timertrhread itself is locked @@ -655,23 +661,25 @@ void VVideoLiveTV::doAudioSelector() osdChanNum.setText(formatChanNum); osdChanName.setText((*chanList)[osdChannelIndex]->name); } - int subtitleChannel=((PlayerVideoLive*)player)->getCurrentSubtitleChannel(); - int subtitleType=0x10; - if (!(static_cast(player))->isSubtitlesOn()) { - if (((PlayerVideoLive*)player)->getTeletextDecoder()->getTeletxtView() && - ((PlayerVideoLive*)player)->getTeletextDecoder()->getTeletxtView()->isInSubtitleMode() - ) { - subtitleChannel=((PlayerVideoLive*)player)->getTeletextDecoder()->getPage(); - subtitleType=0x11; - - } else { - subtitleType=0xFF; //turnedOff - subtitleChannel=0; - } + int subtitleChannel = playervl->getCurrentSubtitleChannel(); + int subtitleType = 0x10; + if (!playervl->isSubtitlesOn()) + { + if (playervl->getTeletextDecoder()->getTeletxtView() && + playervl->getTeletextDecoder()->getTeletxtView()->isInSubtitleMode()) + { + subtitleChannel = playervl->getTeletextDecoder()->getPage(); + subtitleType = 0x11; + } + else + { + subtitleType = 0xFF; //turnedOff + subtitleChannel = 0; + } } // Draw the selector - vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], ((PlayerVideoLive*)player)->getCurrentAudioChannel(), + vas = new VAudioSelector(this, (*chanList)[currentChannelIndex], playervl->getCurrentAudioChannel(), subtitleType,subtitleChannel,NULL); vas->setBackgroundColour(DrawStyle::OSDBACKGROUND); @@ -731,26 +739,25 @@ void VVideoLiveTV::setNowNextData() sort(eventList->begin(), eventList->end(), EventSorter()); char tempString[300]; - char tempString2[300]; struct tm btime; Event* event; int eventListSize = eventList->size(); - std::stringstream string; + std::stringstream ss; for(int i = 0; i < eventListSize; i++) { event = (*eventList)[i]; time_t etime = event->time; LOCALTIME_R(&etime, &btime); + // FIXME convert following to std::strftime #ifndef _MSC_VER - strftime(tempString2, 299, "%0H:%0M ", &btime); + strftime(tempString, 299, "%0H:%0M ", &btime); #else - strftime(tempString2, 299, "%H:%M ", &btime); + strftime(tempString, 299, "%H:%M ", &btime); #endif - SNPRINTF(tempString, 299, "%s %s", tempString2, event->title); - string << tempString << "\n"; + ss << tempString << " " << event->title << "\n"; } - sl.setText(string.str().c_str()); + sl.setText(ss.str().c_str()); } } @@ -901,7 +908,7 @@ bool VVideoLiveTV::channelChange(UCHAR changeType, UINT newData) UINT newChannel = 0; if (streamType == VDR::VIDEO) { - VTeletextView *vtxt=((PlayerVideoLive*)player)->getTeletextDecoder()->getTeletxtView(); + VTeletextView* vtxt = static_cast(player)->getTeletextDecoder()->getTeletxtView(); if (vtxt) { BoxStack::getInstance()->remove(vtxt); @@ -1059,6 +1066,9 @@ void VVideoLiveTV::processMessage(Message* m) else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL) { if (streamType != VDR::VIDEO) return; + + PlayerVideoLive* playervl = static_cast(player); + Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change subtitle channel to %x", m->parameter); int type = (m->parameter & 0xFF0000) >> 16; switch (type) @@ -1066,35 +1076,35 @@ void VVideoLiveTV::processMessage(Message* m) case 0x10: { //dvbsubtitle - if (streamType == VDR::VIDEO) + playervl->setSubtitleChannel((m->parameter & 0xFFFF)); + playervl->turnSubtitlesOn(true); + VTeletextView* vtxt = playervl->getTeletextDecoder()->getTeletxtView(); + if (vtxt && vtxt->isInSubtitleMode()) { - player->setSubtitleChannel((m->parameter & 0xFFFF)); - (static_cast(player))->turnSubtitlesOn(true); - VTeletextView *vtxt=((PlayerVideoLive*)player)->getTeletextDecoder()->getTeletxtView(); - if (vtxt && vtxt->isInSubtitleMode()) - { - BoxStack::getInstance()->remove(vtxt); - } + BoxStack::getInstance()->remove(vtxt); } - } break; + break; + } case 0xFF: - { //nosubtitles - if (streamType == VDR::VIDEO){ - (static_cast(player))->turnSubtitlesOn(false); - VTeletextView *vtxt=((PlayerVideoLive*)player)->getTeletextDecoder()->getTeletxtView(); - if (vtxt && vtxt->isInSubtitleMode()) { - BoxStack::getInstance()->remove(vtxt); - } - } + { + //nosubtitles + playervl->turnSubtitlesOn(false); + VTeletextView* vtxt = playervl->getTeletextDecoder()->getTeletxtView(); + if (vtxt && vtxt->isInSubtitleMode()) + { + BoxStack::getInstance()->remove(vtxt); + } + break; } - break; case 0x11: - { //videotext - (static_cast(player))->turnSubtitlesOn(false); - doTeletext(true); - ((PlayerVideoLive*)player)->getTeletextDecoder()->setPage((m->parameter & 0xFFFF)); - } break; - }; + { + //videotext + playervl->turnSubtitlesOn(false); + doTeletext(true); + playervl->getTeletextDecoder()->setPage((m->parameter & 0xFFFF)); + break; + } + } if (vas) { @@ -1105,7 +1115,7 @@ void VVideoLiveTV::processMessage(Message* m) } else if (m->message == Message::PLAYER_EVENT) { - switch (m->parameter) + switch (m->parameter) { case PlayerVideoLive::CONNECTION_LOST: // connection lost detected { -- 2.39.5