From 06f96dee2c0dd65b9a2571e66dd239e4ce9733b0 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 2 Mar 2013 17:35:43 +0000 Subject: [PATCH] Compiler messages, code cleaning --- boxx.cc | 87 ++++++++++++----------- playerliveradio.cc | 82 +++++++++++----------- playerlivetv.cc | 169 +++++++++++++++++++++++---------------------- 3 files changed, 176 insertions(+), 162 deletions(-) diff --git a/boxx.cc b/boxx.cc index a1b31b1..e6b76a1 100644 --- a/boxx.cc +++ b/boxx.cc @@ -18,12 +18,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "boxx.h" +#include + +#include "defines.h" #include "bitmap.h" #include "log.h" #include "osd.h" -#include +#include "boxx.h" char Boxx::numBoxxes = 0; Boxx::Boxx() @@ -167,7 +169,7 @@ int Boxx::getScreenY() return area.y; } -int Boxx::getRootBoxOffsetX() // convert this to be getX and silently do the parent/not thing? same for Y below? +int Boxx::getRootBoxOffsetX() // convert this to be getX and silently do the parent/not thing? same for Y below? { if (parent) return area.x + parent->getRootBoxOffsetX(); return 0; @@ -261,14 +263,14 @@ void Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour) while(1) { printLine = 0; - unsigned int cur_length=1; - wchar_t cur_char=getWChar(text+textPos,&cur_length); + UINT cur_length = 1; + wchar_t cur_char = getWChar(text + textPos, &cur_length); if (cur_char == '\0') break; if (cur_char == '\n') { - textPos+=cur_length; // ignore the \n + textPos += cur_length; // ignore the \n printLine = 1; break; } @@ -279,7 +281,7 @@ void Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour) if (cur_char == ' ') { // this char is a space, ignore and break - textPos+=cur_length; + textPos += cur_length; break; } else @@ -287,22 +289,22 @@ void Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour) // Need to go back to the last space in the line while ((cur_char != ' ') && (linePos >= 0)) { - textPos-=cur_length; - cur_char=getWChar(text+textPos,&cur_length); + textPos -= cur_length; + cur_char = getWChar(text + textPos, &cur_length); linePos--; } // Now take the space we just found - textPos+=cur_length; + textPos += cur_length; break; } } - for (int n=0;n=0) line[linePos++] = '\0'; //Here is the change + if (linePos >= 0) line[linePos++] = '\0'; //Here is the change if (printLine || (linePos > 1)) // if some text was put in line { @@ -397,60 +399,65 @@ void Boxx::drawBitmap(UINT x, UINT y, const Bitmap& bm, const DisplayRegion & re else if (surface) surface->drawBitmap(x, y, bm, region); } -void Boxx::drawJpeg(const char *fileName,int x, int y,int *width, int *height) +void Boxx::drawJpeg(const char *fileName, int x, int y, int *width, int *height) { - if (parent) parent->drawJpeg(fileName,area.x +x,area.y +y,width,height); - else if (surface) surface->drawJpeg(fileName,x,y,width,height); + if (parent) parent->drawJpeg(fileName, area.x + x, area.y + y, width, height); + else if (surface) surface->drawJpeg(fileName, x, y, width, height); } -void Boxx::drawMonoBitmap(UCHAR*base, int dx, int dy, unsigned int height,unsigned int width, Colour& nextColour) +void Boxx::drawMonoBitmap(UCHAR*base, int dx, int dy, UINT height, UINT width, Colour& nextColour) { - if (parent) parent->drawMonoBitmap(base, area.x +dx,area.y +dy, height,width, nextColour); - else if (surface) surface->drawMonoBitmap(base, dx,dy, height,width, nextColour); + if (parent) parent->drawMonoBitmap(base, area.x +dx, area.y + dy, height, width, nextColour); + else if (surface) surface->drawMonoBitmap(base, dx,dy, height, width, nextColour); } int Boxx::getFontHeight() { - if (parent) return parent->getFontHeight(); - else if (surface) return surface->getFontHeight(); - else return 18; + if (parent) return parent->getFontHeight(); + else if (surface) return surface->getFontHeight(); + else return 18; } void Boxx::startFastDraw() { - if (parent) parent->startFastDraw(); - else - { - if (surface) surface->startFastDraw(); - } + if (parent) + { + parent->startFastDraw(); + } + else + { + if (surface) surface->startFastDraw(); + } } void Boxx::endFastDraw() { - if (parent) parent->endFastDraw(); - else - { - if (surface) surface->endFastDraw(); - } + if (parent) + { + parent->endFastDraw(); + } + else + { + if (surface) surface->endFastDraw(); + } } - float Boxx::charWidth(wchar_t c) { if (parent) return parent->charWidth(c); - else if (surface) return surface->getCharWidth(c); + else if (surface) return surface->getCharWidth(c); else return 16.; //? } -wchar_t Boxx::getWChar(const char* str, unsigned int *length) +wchar_t Boxx::getWChar(const char* str, UINT *length) { - if (parent) return parent->getWChar(str,length); - else if (surface) return surface->getWChar(str,length); - else return '?'; //? + if (parent) return parent->getWChar(str, length); + else if (surface) return surface->getWChar(str, length); + else return '?'; //? } -Surface * Boxx::getSurface() { +Surface* Boxx::getSurface() +{ if (parent) return parent->getSurface(); return surface; } - diff --git a/playerliveradio.cc b/playerliveradio.cc index c72ea60..2782302 100644 --- a/playerliveradio.cc +++ b/playerliveradio.cc @@ -20,6 +20,7 @@ #include "playerliveradio.h" +#include "defines.h" #include "log.h" #include "audio.h" #include "demuxerts.h" @@ -61,7 +62,7 @@ int PlayerLiveRadio::init() demuxer = new DemuxerTS(); if (!demuxer) return 0; - if (!demuxer->init(this, audio, NULL, NULL, 0, 200000,0)) + if (!demuxer->init(this, audio, NULL, NULL, 0, 200000, 0)) { logger->log("PlayerLiveRadio", Log::ERR, "Demuxer failed to init"); shutdown(); @@ -80,11 +81,7 @@ int PlayerLiveRadio::shutdown() if (!initted) return 0; stop(); initted = false; - delete demuxer; - - - return 1; } @@ -103,17 +100,19 @@ int PlayerLiveRadio::getCurrentAudioChannel() return demuxer->getAID(); } -int *PlayerLiveRadio::getTeletxtSubtitlePages(){ - return NULL; +int* PlayerLiveRadio::getTeletxtSubtitlePages() +{ + return NULL; } -int PlayerLiveRadio::getCurrentSubtitleChannel(){ - return demuxer->getSubID(); +int PlayerLiveRadio::getCurrentSubtitleChannel() +{ + return demuxer->getSubID(); } -void PlayerLiveRadio::setAudioChannel(int newChannel, int type,int streamtype) +void PlayerLiveRadio::setAudioChannel(int newChannel, int type, int streamtype) { - demuxer->setAID(newChannel, type,streamtype,true); + demuxer->setAID(newChannel, type, streamtype, true); } void PlayerLiveRadio::setSubtitleChannel(int newChannel) @@ -408,41 +407,43 @@ void PlayerLiveRadio::threadMethod() if (chan->numAPids > 0) { - int j=0; - while (jnumAPids && !found) { - if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type)) { - demuxer->setAID(chan->apids[j].pid,0,chan->apids[j].type,true); - audio->setStreamType(Audio::MPEG2_PES); - logger->log("PlayerLiveRadio", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[j].pid,chan->apids[j].type); - found=true; - } - j++; - } + ULONG j = 0; + while (j < chan->numAPids && !found) + { + if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type)) + { + demuxer->setAID(chan->apids[j].pid, 0, chan->apids[j].type, true); + audio->setStreamType(Audio::MPEG2_PES); + logger->log("PlayerLiveRadio", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[j].pid, chan->apids[j].type); + found = true; + } + j++; + } } if (!found) { - if (chan->numDPids > 0 && audio->maysupportAc3()) - { - int j=0; - while (jnumDPids && !found) { - if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type)) { - demuxer->setAID(chan->dpids[j].pid,1,chan->dpids[j].type,true); - audio->setStreamType(Audio::MPEG2_PES); - logger->log("PlayerLiveRadio", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u", chan->vpid, chan->dpids[j].pid,chan->dpids[j].type); - found=true; - } - j++; - } - } - else - { - logger->log("PlayerLiveRadio", Log::WARN, "Demuxer no pids!"); - } + if (chan->numDPids > 0 && audio->maysupportAc3()) + { + ULONG j = 0; + while (j < chan->numDPids && !found) + { + if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type)) + { + demuxer->setAID(chan->dpids[j].pid, 1, chan->dpids[j].type, true); + audio->setStreamType(Audio::MPEG2_PES); + logger->log("PlayerLiveRadio", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u", chan->vpid, chan->dpids[j].pid, chan->dpids[j].type); + found=true; + } + j++; + } + } + else + { + logger->log("PlayerLiveRadio", Log::WARN, "Demuxer no pids!"); + } } - - int streamSuccess = vdr->streamChannel(chan->number, this); if (!checkError() && !streamSuccess) { @@ -501,4 +502,3 @@ void PlayerLiveRadio::threadMethod() logger->log("PlayerLiveRadio", Log::DEBUG, "End of thread"); } - diff --git a/playerlivetv.cc b/playerlivetv.cc index 3868638..4d73d41 100644 --- a/playerlivetv.cc +++ b/playerlivetv.cc @@ -20,6 +20,7 @@ #include "playerlivetv.h" +#include "defines.h" #include "log.h" #include "audio.h" #include "video.h" @@ -74,20 +75,22 @@ int PlayerLiveTV::init() teletext = new TeletextDecoderVBIEBU(); - unsigned int demux_video_size=2097152; - unsigned int demux_audio_size=524288; - if (video->supportsh264()) { - demux_video_size*=5*1;//5; + unsigned int demux_video_size = 2097152; + unsigned int demux_audio_size = 524288; - } - if (audio->maysupportAc3()) { - //demux_audio_size*=2; - } + if (video->supportsh264()) + { + demux_video_size *= 5 * 1;//5; + } + + if (audio->maysupportAc3()) + { + //demux_audio_size*=2; + } - int text_fak=video->getTeletextBufferFaktor(); + int text_fak = video->getTeletextBufferFaktor(); - - if (!demuxer->init(this, audio, video, teletext, demux_video_size,demux_audio_size, 65536*text_fak,25./*unimportant*/,subtitles)) + if (!demuxer->init(this, audio, video, teletext, demux_video_size, demux_audio_size, 65536 * text_fak, 25./*unimportant*/, subtitles)) { logger->log("PlayerLiveTV", Log::ERR, "Demuxer failed to init"); shutdown(); @@ -137,21 +140,22 @@ int PlayerLiveTV::getCurrentAudioChannel() void PlayerLiveTV::setAudioChannel(int newChannel, int type,int streamtype) { - demuxer->setAID(newChannel,type,streamtype,true); + demuxer->setAID(newChannel, type, streamtype, true); } void PlayerLiveTV::setSubtitleChannel(int newChannel) { - demuxer->setSubID(newChannel); + demuxer->setSubID(newChannel); } -int *PlayerLiveTV::getTeletxtSubtitlePages() +int* PlayerLiveTV::getTeletxtSubtitlePages() { - return teletext->getSubtitlePages(); + return teletext->getSubtitlePages(); } -int PlayerLiveTV::getCurrentSubtitleChannel(){ - return demuxer->getSubID(); +int PlayerLiveTV::getCurrentSubtitleChannel() +{ + return demuxer->getSubID(); } bool PlayerLiveTV::toggleSubtitles() @@ -169,9 +173,9 @@ bool PlayerLiveTV::toggleSubtitles() return subtitlesShowing; } - -void PlayerLiveTV::turnSubtitlesOn(bool ison) { - if (ison) +void PlayerLiveTV::turnSubtitlesOn(bool ison) +{ + if (ison) { subtitlesShowing = true; subtitles->show(); @@ -181,12 +185,11 @@ void PlayerLiveTV::turnSubtitlesOn(bool ison) { subtitlesShowing = false; subtitles->hide(); } - } void PlayerLiveTV::tellSubtitlesOSDVisible(bool visible) { -subtitles->setOSDMenuVisibility(visible); + subtitles->setOSDMenuVisibility(visible); } // ----------------------------------- Externally called events @@ -230,13 +233,13 @@ void PlayerLiveTV::call(void* caller) logger->log("PlayerLiveTV", Log::DEBUG, "Callback from demuxer"); int parx,pary; - int dxCurrentAspect = demuxer->getAspectRatio(&parx,&pary); + int dxCurrentAspect = demuxer->getAspectRatio(&parx, &pary); if (dxCurrentAspect == Demuxer::ASPECT_4_3) { if (video->getTVsize() == Video::ASPECT16X9) { logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer said video is 4:3 aspect, switching TV"); - video->setAspectRatio(Video::ASPECT4X3,parx,pary); + video->setAspectRatio(Video::ASPECT4X3, parx, pary); } else { @@ -255,7 +258,7 @@ void PlayerLiveTV::call(void* caller) if (video->getTVsize() == Video::ASPECT16X9) { logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer said video is 16:9 aspect, switching TV"); - video->setAspectRatio(Video::ASPECT16X9,parx,pary); + video->setAspectRatio(Video::ASPECT16X9, parx, pary); } else { @@ -272,7 +275,7 @@ void PlayerLiveTV::call(void* caller) else { logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer said video is something else... switch anyway"); - video->setAspectRatio( dxCurrentAspect,parx,pary); + video->setAspectRatio(dxCurrentAspect, parx, pary); } } else if (caller == &afeed) @@ -344,16 +347,16 @@ void PlayerLiveTV::chunkToDemuxer() /* int a =*/ demuxer->put((UCHAR*)s.data, s.len); // logger->log("PlayerLiveTV", Log::DEBUG, "put %i to demuxer", a); free(s.data); - if (pendingAudioPlay && (demuxer->getHorizontalSize()|| !video->independentAVStartUp())) //Horizontal Size is zero, if not parsed + if (pendingAudioPlay && (demuxer->getHorizontalSize() || !video->independentAVStartUp())) //Horizontal Size is zero, if not parsed { - video->sync(); - video->play(); - video->pause(); - //audio->setStreamType(Audio::MPEG2_PES); - audio->sync(); - audio->play(); - audio->pause(); - pendingAudioPlay = false; + video->sync(); + video->play(); + video->pause(); + //audio->setStreamType(Audio::MPEG2_PES); + audio->sync(); + audio->play(); + audio->pause(); + pendingAudioPlay = false; } } @@ -401,9 +404,10 @@ void PlayerLiveTV::switchState(UCHAR newState) tfeed.start(); state = newState; - if (!video->independentAVStartUp()){ - videoStartup = true; - threadSignalNoLock(); + if (!video->independentAVStartUp()) + { + videoStartup = true; + threadSignalNoLock(); } return; } @@ -430,7 +434,6 @@ void PlayerLiveTV::switchState(UCHAR newState) case S_VIDEOSTARTUP: { - vdr->stopStreaming(); clearStreamChunks(); vfeed.stop(); @@ -460,9 +463,10 @@ void PlayerLiveTV::switchState(UCHAR newState) subtitles->start(); tfeed.start(); state = newState; - if (!video->independentAVStartUp()){ - videoStartup = true; - threadSignalNoLock(); + if (!video->independentAVStartUp()) + { + videoStartup = true; + threadSignalNoLock(); } return; } @@ -620,9 +624,10 @@ void PlayerLiveTV::switchState(UCHAR newState) subtitles->start(); tfeed.start(); state = newState; - if (!video->independentAVStartUp()){ - videoStartup = true; - threadSignalNoLock(); + if (!video->independentAVStartUp()) + { + videoStartup = true; + threadSignalNoLock(); } return; } @@ -631,7 +636,7 @@ void PlayerLiveTV::switchState(UCHAR newState) logger->log("PlayerLiveTV", Log::EMERG, "Thread called state %u to state %u which is not supported", state, newState); abort(); break; - } + } } } } @@ -680,15 +685,13 @@ void PlayerLiveTV::threadMethod() { while(1) { - - //logger->log("PlayerLiveTV", Log::DEBUG, "VS: %d pA %d",videoStartup,pendingAudioPlay); + //logger->log("PlayerLiveTV", Log::DEBUG, "VS: %d pA %d",videoStartup,pendingAudioPlay); if (videoStartup && !pendingAudioPlay) // we are in S_VIDEOSTARTUP, afeed has signalled that it has written some data { - logger->log("PlayerLiveTV", Log::DEBUG, "Enter prebuffering"); + logger->log("PlayerLiveTV", Log::DEBUG, "Enter prebuffering"); switchState(S_PREBUFFERING); videoStartup = false; preBufferCount = 0; - checkError(); } @@ -702,7 +705,6 @@ void PlayerLiveTV::threadMethod() if (i.instruction == I_SETCHANNEL) { logger->log("PlayerLiveTV", Log::DEBUG, "start new stream"); - switchState(S_VIDEOSTARTUP); @@ -720,40 +722,46 @@ void PlayerLiveTV::threadMethod() if (chan->numAPids > 0) { - int j=0; - while (jnumAPids && !found) { - if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type)) { - demuxer->setAID(chan->apids[j].pid,0,chan->apids[j].type,true); - audio->setStreamType(Audio::MPEG2_PES); - logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[j].pid,chan->apids[j].type); - found=true; - } - j++; - } + ULONG j = 0; + while (j < chan->numAPids && !found) + { + if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type)) + { + demuxer->setAID(chan->apids[j].pid, 0, chan->apids[j].type, true); + audio->setStreamType(Audio::MPEG2_PES); + logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[j].pid, chan->apids[j].type); + found = true; + } + j++; + } } if (!found) { - if (chan->numDPids > 0 && audio->maysupportAc3()) - { - int j=0; - while (jnumDPids && !found) { - if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type)) { - demuxer->setAID(chan->dpids[j].pid,1,chan->dpids[j].type,true); - audio->setStreamType(Audio::MPEG2_PES); - logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u", chan->vpid, chan->dpids[j].pid,chan->dpids[j].type); - found=true; - } - j++; - } - } - else + if (chan->numDPids > 0 && audio->maysupportAc3()) + { + ULONG j = 0; + while (j < chan->numDPids && !found) { - logger->log("PlayerLiveTV", Log::WARN, "Demuxer video pid only: %u", chan->vpid); + if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type)) + { + demuxer->setAID(chan->dpids[j].pid, 1, chan->dpids[j].type, true); + audio->setStreamType(Audio::MPEG2_PES); + logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u", chan->vpid, chan->dpids[j].pid, chan->dpids[j].type); + found = true; + } + j++; } + } + else + { + logger->log("PlayerLiveTV", Log::WARN, "Demuxer video pid only: %u", chan->vpid); + } } + if (chan->numSPids > 0) demuxer->setSubID(chan->spids[0].pid); + demuxer->setTID(chan->tpid); teletext->ResetDecoder(); int streamSuccess = vdr->streamChannel(chan->number, this); @@ -779,19 +787,19 @@ void PlayerLiveTV::threadMethod() } } - threadCheckExit(); + threadCheckExit(); if (stopNow) break; while(streamChunks.size()) { - //logger->log("PlayerLiveTV", Log::DEBUG, "chunk mark1 %d", streamChunks.size()); + //logger->log("PlayerLiveTV", Log::DEBUG, "chunk mark1 %d", streamChunks.size()); chunkToDemuxer(); //logger->log("PlayerLiveTV", Log::DEBUG, "chunk mark2 %d", streamChunks.size()); if (state == S_PREBUFFERING) { - // logger->log("PlayerLiveTV", Log::DEBUG, "chunk mark3"); + // logger->log("PlayerLiveTV", Log::DEBUG, "chunk mark3"); ++preBufferCount; ULONG percentDone = (ULONG)(preBufferCount / (float)preBufferAmount * 100); logger->log("PlayerLiveTV", Log::DEBUG, "Prebuffering %lu%%", percentDone); @@ -811,7 +819,7 @@ void PlayerLiveTV::threadMethod() } } } - // logger->log("PlayerLiveTV", Log::DEBUG, "wait for signal %d", streamChunks.size()); + //logger->log("PlayerLiveTV", Log::DEBUG, "wait for signal %d", streamChunks.size()); threadLock(); threadWaitForSignal(); // unlocks and waits for signal threadUnlock(); @@ -820,4 +828,3 @@ void PlayerLiveTV::threadMethod() logger->log("PlayerLiveTV", Log::DEBUG, "End of thread"); } - -- 2.39.5