From febc4309ac78a07aaee95ad15890b4522448aa05 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Thu, 12 Mar 2020 22:16:18 +0000 Subject: [PATCH] Work on VAudioSelector class Fix some casts Switch to C++ casts All compiler warnings Switch to std::string for audio/subs channel name Use a vector of objects rather than pointers in channel lists Code reformatted with astyle Init-lists for constructors Brace-init in class header Update GPL notices Remove a dead constructor from header --- .astylerc | 17 ++ vaudioselector.cc | 747 ++++++++++++++++++++++------------------------ vaudioselector.h | 35 +-- vvideorec.cc | 2 +- 4 files changed, 394 insertions(+), 407 deletions(-) create mode 100644 .astylerc diff --git a/.astylerc b/.astylerc new file mode 100644 index 0000000..f1a7f7c --- /dev/null +++ b/.astylerc @@ -0,0 +1,17 @@ +mode=c +style=allman +indent=spaces=2 +attach-closing-while +indent-classes +indent-switches +indent-namespaces +indent-col1-comments +break-blocks +pad-oper +pad-header +align-pointer=type +keep-one-line-statements +keep-one-line-blocks +attach-return-type +attach-return-type-decl +lineend=linux diff --git a/vaudioselector.cc b/vaudioselector.cc index c4f9196..de94e9c 100644 --- a/vaudioselector.cc +++ b/vaudioselector.cc @@ -1,5 +1,5 @@ /* - Copyright 2006 Chris Tallon, Marten Richter + Copyright 2006-2020 Chris Tallon, Marten Richter This file is part of VOMP. @@ -14,11 +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 "vaudioselector.h" +#include +#include +#include #include "input.h" #include "colour.h" @@ -32,63 +33,59 @@ #include "log.h" #include "channel.h" - +#include "vaudioselector.h" VAudioSelector::VAudioSelector(void* tparent, bool* availableMpegAudioChannels, - bool* availableAc3AudioChannels, int currentAudioChannel, bool *availableSubtitleChannels,int*ttxtpages, - int currentSubtitleChannel,int currentSubtitleType, RecInfo* recInfo) + bool* availableAc3AudioChannels, int currentAudioChannel, bool* availableSubtitleChannels, int* ttxtpages, + int currentSubtitleChannel, int currentSubtitleType, RecInfo* recInfo) +: parent(tparent), liveMode(false) { Log::getInstance()->log("VAS", Log::DEBUG, "%i", currentAudioChannel); - - parent = tparent; - - liveMode = false; - subtitles =false; - editsubtitles = false; - int i; - if (availableSubtitleChannels != NULL) { - for (i = 0; i < PES_DVBSUBTITLE_MAXCHANNELS; i++) { - if (availableSubtitleChannels[i]) - { - AudioSubtitleChannel* sc = new AudioSubtitleChannel(); - sc->type = 0x10;//dvbsubtitle - sc->name = NULL; - sc->pestype = PES_DVBSUBTITLE_START+ i; - scl.push_back(sc); - } + + if (availableSubtitleChannels != NULL) + { + for (i = 0; i < PES_DVBSUBTITLE_MAXCHANNELS; i++) + { + if (availableSubtitleChannels[i]) + { + AudioSubtitleChannel sc; + sc.type = 0x10; //dvbsubtitle + sc.pestype = PES_DVBSUBTITLE_START + i; + scl.push_back(std::move(sc)); } - for (i=0;i<10;i++) { - if (ttxtpages[i]>0) { - AudioSubtitleChannel* sc = new AudioSubtitleChannel(); - int length=strlen(tr("TTxt:"))+1+1+3+1; - sc->type = 0x11;//Teletxt - sc->name = new char[length]; - SNPRINTF(sc->name,length,"%s %3x",tr("TTxt:"),ttxtpages[i]); - sc->pestype = ttxtpages[i]; - scl.push_back(sc); - } + } + + for (i = 0; i < 10; i++) + { + if (ttxtpages[i] > 0) + { + AudioSubtitleChannel sc; + sc.type = 0x11; //Teletxt + sc.pestype = ttxtpages[i]; + std::ostringstream oss; + oss << tr("TTxt:") << " " << std::hex << std::setw(3) << ttxtpages[i]; + sc.name = std::move(oss.str()); + scl.push_back(std::move(sc)); } + } } - if (scl.size()>0) { - AudioSubtitleChannel* sc = new AudioSubtitleChannel(); - sc->type = 0xFF;//special - sc->name = new char[strlen(tr("No Subtitles"))+1]; - strcpy(sc->name,tr("No Subtitles")); - sc->pestype = 0; - scl.insert(scl.begin(),sc); - subtitles=true; + if (scl.size() > 0) + { + AudioSubtitleChannel sc; + sc.type = 0xFF; //special + sc.name = tr("No Subtitles"); + sc.pestype = 0; + scl.insert(scl.begin(), std::move(sc)); + subtitles = true; } - - - if (subtitles) { - setSize(400, 120); - } else { - setSize(200, 120); - } + if (subtitles) + setSize(400, 120); + else + setSize(200, 120); createBuffer(); @@ -96,64 +93,49 @@ VAudioSelector::VAudioSelector(void* tparent, bool* availableMpegAudioChannels, asl.setSize(200 - 45, area.h - 30); add(&asl); - if (subtitles) { - ssl.setPosition(200+40,30); - ssl.setSize(200 - 45, area.h - 30); - add(&ssl); + if (subtitles) + { + ssl.setPosition(200 + 40, 30); + ssl.setSize(200 - 45, area.h - 30); + add(&ssl); } // Load data from availableAudioChannels, currentAudioChannel and recInfo - for (i = 0; i < PES_AUDIO_MAXCHANNELS; i++) { if (availableMpegAudioChannels[i]) { - AudioSubtitleChannel* ac = new AudioSubtitleChannel(); - ac->type = 0; - ac->name = NULL; - ac->pestype = PES_AUDIO_START + i; - acl.push_back(ac); + AudioSubtitleChannel ac; + ac.type = 0; + ac.pestype = PES_AUDIO_START + i; + acl.push_back(std::move(ac)); } } + if (availableAc3AudioChannels != NULL) { for (i = 0; i < PES_AUDIO_AC3_MAXCHANNELS; i++) { if (availableAc3AudioChannels[i]) { - AudioSubtitleChannel* ac = new AudioSubtitleChannel(); - ac->type = 1;//ac3 - ac->name = NULL; - ac->pestype = PES_AUDIO_AC3_START + i; - acl.push_back(ac); + AudioSubtitleChannel ac; + ac.type = 1; //ac3 + ac.pestype = PES_AUDIO_AC3_START + i; + acl.push_back(std::move(ac)); } } } - - - - - - unsigned char numchan_recinfo = recInfo->numComponents; - unsigned char numchan_siz = acl.size(); - unsigned char numchan_subtitles_siz = scl.size(); - int mp_audcounter = 0; - int ac3_counter = 0; + int numchan_recinfo = recInfo->numComponents; + UINT mp_audcounter = 0; + UINT ac3_counter = 0; int ac3_offset = 0; - int dvb_subcounter = 1; + UINT dvb_subcounter = 1; - for (i = 0; i < numchan_siz; i++) + for (auto& ac : acl) { - AudioSubtitleChannel* ac = acl[i]; - if (ac) - { - if (ac->type==0) - { - ac3_offset++; - } - } + if (ac.type == 0) ++ac3_offset; } unsigned char type; @@ -162,49 +144,55 @@ VAudioSelector::VAudioSelector(void* tparent, bool* availableMpegAudioChannels, int type_int; for (i = 0; i < numchan_recinfo; i++) - { - + { type = recInfo->types[i]; lang = recInfo->languages[i]; description = recInfo->descriptions[i]; - AudioSubtitleChannel* ac = NULL; + AudioSubtitleChannel* acp = NULL; type_int = 0; - if (recInfo->streams[i] == 2) { - switch (type) - { + + if (recInfo->streams[i] == 2) + { + switch (type) + { case 1: //mpaudio mono case 3: //mpaudio stereo - if (mp_audcounter < numchan_siz) ac = acl[mp_audcounter]; - type_int = 0; - break; + if (mp_audcounter < acl.size()) acp = &acl[mp_audcounter]; + + type_int = 0; + break; + case 5: //ac3 - if (ac3_counter + ac3_offset < numchan_siz) ac = acl[ac3_counter + ac3_offset]; - type_int = 1; - break; - } - } else if (recInfo->streams[i] == 3){ + if (ac3_counter + ac3_offset < acl.size()) acp = &acl[ac3_counter + ac3_offset]; + + type_int = 1; + break; + } + } + else if (recInfo->streams[i] == 3) + { /* switch (type) { case 20:*/ - if (dvb_subcounter < numchan_subtitles_siz) ac = scl[dvb_subcounter]; - type_int=0x10; - /* break; - };*/ - } else continue; //neither audio nor subtitle + if (dvb_subcounter < scl.size()) acp = &scl[dvb_subcounter]; + + type_int = 0x10; + /* break; + };*/ + } + else continue; //neither audio nor subtitle - if (ac) + if (acp) { - if (ac->type == type_int) + if (acp->type == type_int) { if (description && (strlen(description) > 0)) { - ac->name = new char[strlen(description)+1]; - strcpy(ac->name, description); + acp->name = description; } else if (lang && (strlen(lang) > 0)) { - ac->name = new char[strlen(lang)+1]; - strcpy(ac->name, lang); + acp->name = lang; } } } @@ -214,45 +202,36 @@ VAudioSelector::VAudioSelector(void* tparent, bool* availableMpegAudioChannels, case 0: //mpaudio mp_audcounter++; break; + case 1: //ac3 ac3_counter++; break; + case 0x10: - dvb_subcounter++; + dvb_subcounter++; break; } } - // Now do display + // Now do display. acl and scl are read only from now on, so pointers always remain valid - char tempString[300]; - int audioChannelListSize = acl.size(); - - if (audioChannelListSize) + if (acl.size()) { - for(i = 0; i < audioChannelListSize; i++) + for (auto& ac : acl) { - AudioSubtitleChannel* ac = acl[i]; - - if (ac->name) + if (!ac.name.empty()) { - asl.addOption(ac->name, ac, (ac->pestype == currentAudioChannel)); + asl.addOption(ac.name.c_str(), &ac, (ac.pestype == currentAudioChannel)); } else { - if (ac->type==0) - { - SNPRINTF(tempString, 299, "%lu", (ULONG)(ac->pestype - PES_AUDIO_START)); - } - else if (ac->type==1) - { - SNPRINTF(tempString, 299, "ac3 %lu", (ULONG)(ac->pestype - PES_AUDIO_AC3_START)); - } - else - { - SNPRINTF(tempString, 299, "unknown"); - } - asl.addOption(tempString, ac, (ac->pestype == currentAudioChannel)); + std::string tempString; + + if (ac.type == 0) tempString = std::to_string(ac.pestype - PES_AUDIO_START); + else if (ac.type == 1) tempString = "ac3 " + std::to_string(ac.pestype - PES_AUDIO_AC3_START); + else tempString = "unknown"; + + asl.addOption(tempString.c_str(), &ac, (ac.pestype == currentAudioChannel)); } } } @@ -261,182 +240,152 @@ VAudioSelector::VAudioSelector(void* tparent, bool* availableMpegAudioChannels, asl.addOption(tr("No audio channel data available"), 0, 1); } - int subtitlesChannelListSize = scl.size(); + if (subtitles) + { + ssl.setDarkSelOption(true); - if (subtitles) { - ssl.setDarkSelOption(true); - for(i = 0; i < subtitlesChannelListSize; i++) + for (auto& sc : scl) + { + bool selected = false; + + if (sc.pestype == currentSubtitleChannel && sc.type == currentSubtitleType) selected = true; + + if (!sc.name.empty()) { - AudioSubtitleChannel* sc = scl[i]; - bool selected=false; - if (sc->pestype == currentSubtitleChannel && sc->type ==currentSubtitleType) selected=true; - - if (sc->name) - { - ssl.addOption(sc->name, sc, selected); - } - else - { - if (sc->type==0x10) - { - SNPRINTF(tempString, 299, "%lu", (ULONG)(sc->pestype - PES_DVBSUBTITLE_START)); - } - else - { - SNPRINTF(tempString, 299, "unknown"); - } - ssl.addOption(tempString, sc, selected); - } + ssl.addOption(sc.name.c_str(), &sc, selected); } - } + else + { + std::string tempString; + if (sc.type == 0x10) tempString = std::to_string(sc.pestype - PES_DVBSUBTITLE_START); + else tempString = "unknown"; + + ssl.addOption(tempString.c_str(), &sc, selected); + } + } + } } -VAudioSelector::VAudioSelector(void* tparent, Channel* channel, int currentAudioChannel,int currentSubtitletype,int currentSubtitleChannel,int*ttxtpages) +VAudioSelector::VAudioSelector(void* tparent, Channel* channel, int currentAudioChannel, int currentSubtitletype, int currentSubtitleChannel, int* ttxtpages) +: parent(tparent), liveMode(true) { - parent = tparent; - - liveMode = true; - editsubtitles = false; - subtitles =false; UINT i; - + for (i = 0; i < channel->numSPids; i++) { - AudioSubtitleChannel* sc = new AudioSubtitleChannel(); - sc->type = 0x10; - sc->name = new char[strlen(channel->spids[i].desc) + 1]; - strcpy(sc->name, channel->spids[i].desc); - sc->pestype = channel->spids[i].pid; - scl.push_back(sc); - } - if (ttxtpages) { - for (i=0;i<10;i++) { - if (ttxtpages[i]>0) { - AudioSubtitleChannel* sc = new AudioSubtitleChannel(); - int length=strlen(tr("TTxt:"))+1+1+3+1; - sc->type = 0x11;//Teletxt - sc->name = new char[length]; - SNPRINTF(sc->name,length,"%s %3x",tr("TTxt:"),ttxtpages[i]); - sc->pestype = ttxtpages[i]; - scl.push_back(sc); - } - } + AudioSubtitleChannel sc; + sc.type = 0x10; + sc.name = channel->spids[i].desc; + sc.pestype = channel->spids[i].pid; + scl.push_back(std::move(sc)); } - - - if (scl.size()>0) { - AudioSubtitleChannel* sc = new AudioSubtitleChannel(); - sc->type = 0xFF;//special - sc->name = new char[strlen(tr("No Subtitles"))+1]; - strcpy(sc->name,tr("No Subtitles")); - sc->pestype = 0; - scl.insert(scl.begin(),sc); - subtitles=true; + + if (ttxtpages) + { + for (i = 0; i < 10; i++) + { + if (ttxtpages[i] > 0) + { + AudioSubtitleChannel sc; + sc.type = 0x11; //Teletxt + sc.pestype = ttxtpages[i]; + std::ostringstream oss; + oss << tr("TTxt:") << " " << std::hex << std::setw(3) << ttxtpages[i]; + sc.name = std::move(oss.str()); + scl.push_back(std::move(sc)); + } + } } + if (scl.size() > 0) + { + AudioSubtitleChannel sc; + sc.type = 0xFF; //special + sc.name = tr("No Subtitles"); + sc.pestype = 0; + scl.insert(scl.begin(), std::move(sc)); + subtitles = true; + } + if (subtitles) + setSize(400, 120); + else + setSize(200, 120); - if (subtitles) { - setSize(400, 120); - } else { - setSize(200, 120); - } createBuffer(); - asl.setPosition(40, 30); asl.setSize(200 - 45, area.h - 30); add(&asl); - if (subtitles) { - ssl.setPosition(200+40,30); - ssl.setSize(200 - 45, area.h - 30); - add(&ssl); + if (subtitles) + { + ssl.setPosition(200 + 40, 30); + ssl.setSize(200 - 45, area.h - 30); + add(&ssl); } // Load data from availableAudioChannels, currentAudioChannel and recInfo for (i = 0; i < channel->numAPids; i++) { - AudioSubtitleChannel* ac = new AudioSubtitleChannel(); - ac->type = 0; - ac->name = new char[strlen(channel->apids[i].desc) + 1]; - strcpy(ac->name, channel->apids[i].desc); - ac->pestype = channel->apids[i].pid; - ac->streamtype=channel->apids[i].type; - if (Audio::getInstance()->streamTypeSupported(ac->streamtype))acl.push_back(ac); + if (Audio::getInstance()->streamTypeSupported(channel->apids[i].type)) + { + AudioSubtitleChannel ac; + ac.type = 0; + ac.name = channel->apids[i].desc; + ac.pestype = channel->apids[i].pid; + ac.streamtype = channel->apids[i].type; + acl.push_back(std::move(ac)); + } } - + if (Audio::getInstance()->supportsAc3()) { for (i = 0; i < channel->numDPids; i++) { - AudioSubtitleChannel* ac = new AudioSubtitleChannel(); - ac->type = 1; - ac->name = new char[strlen(channel->dpids[i].desc) + 1]; - strcpy(ac->name, channel->dpids[i].desc); - ac->pestype = channel->dpids[i].pid; - ac->streamtype=channel->dpids[i].type; - if (Audio::getInstance()->streamTypeSupported(ac->streamtype))acl.push_back(ac); + if (Audio::getInstance()->streamTypeSupported(channel->dpids[i].type)) + { + AudioSubtitleChannel ac; + ac.type = 1; + ac.name = channel->dpids[i].desc; + ac.pestype = channel->dpids[i].pid; + ac.streamtype = channel->dpids[i].type; + acl.push_back(std::move(ac)); + } } } - - int audioChannelListSize = acl.size(); - if (audioChannelListSize) + // acl and scl now read only so pointers are always valid + + if (acl.size()) { - for(int j = 0; j < audioChannelListSize; j++) + for (auto& ac : acl) { - AudioSubtitleChannel* ac = acl[j]; - asl.addOption(ac->name, ac, (ac->pestype == currentAudioChannel)); + asl.addOption(ac.name.c_str(), &ac, (ac.pestype == currentAudioChannel)); } } else { asl.addOption(tr("No audio channel data available"), 0, 1); } - int subtitlesChannelListSize = scl.size(); - if (subtitles) { - ssl.setDarkSelOption(true); - for(int j = 0; j < subtitlesChannelListSize; j++) - { - AudioSubtitleChannel* sc = scl[j]; - bool selected=false; - if ((sc->type==currentSubtitletype) && (sc->pestype == currentSubtitleChannel)) selected=true; - ssl.addOption(sc->name, sc, selected); - - } + if (subtitles) + { + ssl.setDarkSelOption(true); + + for (auto& sc : scl) + { + bool selected = false; + if ((sc.type == currentSubtitletype) && (sc.pestype == currentSubtitleChannel)) selected = true; + ssl.addOption(sc.name.c_str(), &sc, selected); + } } } VAudioSelector::~VAudioSelector() { - int audioChannelListSize = acl.size(); - for(int i = 0; i < audioChannelListSize; i++) - { - // FIXME memory leak - nobody is deleting audio channel name? // try: - delete[] acl[i]->name; - Log::getInstance()->log("VAudioSelector", Log::DEBUG, "Deleted char[] on close"); - delete acl[i]; - } - acl.clear(); - - asl.clear(); - - int subtitleChannelListSize = scl.size(); - for(int i = 0; i < subtitleChannelListSize; i++) - { - // FIXME memory leak - nobody is deleting audio channel name? // try: - delete[] scl[i]->name; - Log::getInstance()->log("VAudioSelector", Log::DEBUG, "Deleted char[] on close"); - delete scl[i]; - } - scl.clear(); - - ssl.clear(); - Message* m = new Message(); m->from = this; m->to = parent; @@ -447,21 +396,22 @@ VAudioSelector::~VAudioSelector() void VAudioSelector::draw() { TBBoxx::draw(); - + // FIXME bad drawing - + rectangle(0, 0, area.w, 30, DrawStyle::TITLEBARBACKGROUND); drawText(tr("Audio"), 45, 5, DrawStyle::LIGHTTEXT); - if (subtitles) { - drawText(tr("Subtitles"), 45+200, 5, DrawStyle::LIGHTTEXT); - ssl.setBackgroundColour(backgroundColour); - ssl.draw(); + if (subtitles) + { + drawText(tr("Subtitles"), 45 + 200, 5, DrawStyle::LIGHTTEXT); + + ssl.setBackgroundColour(backgroundColour); + ssl.draw(); } + asl.setBackgroundColour(backgroundColour); asl.draw(); - - } int VAudioSelector::handleCommand(int command) @@ -474,84 +424,105 @@ int VAudioSelector::handleCommand(int command) { return 4; } + case Input::UP: { - if (editsubtitles) { - ssl.up(); - ssl.draw(); - BoxStack::getInstance()->update(this); - Message* m = new Message(); - m->from = this; - m->to = parent; - m->message = Message::SUBTITLE_CHANGE_CHANNEL; - m->parameter = (((AudioSubtitleChannel*)ssl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)ssl.getCurrentOptionData())->type &0xFF)<<16 ; - MessageQueue::getInstance()->postMessage(m); - } else { - asl.up(); - asl.draw(); - BoxStack::getInstance()->update(this); - Message* m = new Message(); - m->from = this; - m->to = parent; - m->message = Message::AUDIO_CHANGE_CHANNEL; - m->parameter = (((AudioSubtitleChannel*)asl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)asl.getCurrentOptionData())->type &0xFF)<<16 ; - MessageQueue::getInstance()->postMessage(m); - } + if (editsubtitles) + { + ssl.up(); + ssl.draw(); + BoxStack::getInstance()->update(this); + Message* m = new Message(); + m->from = this; + m->to = parent; + m->message = Message::SUBTITLE_CHANGE_CHANNEL; + AudioSubtitleChannel* asc = static_cast(ssl.getCurrentOptionData()); + m->parameter = (asc->pestype & 0xFFFF) | (asc->type & 0xFF) << 16; + MessageQueue::getInstance()->postMessage(m); + } + else + { + asl.up(); + asl.draw(); + BoxStack::getInstance()->update(this); + Message* m = new Message(); + m->from = this; + m->to = parent; + m->message = Message::AUDIO_CHANGE_CHANNEL; + AudioSubtitleChannel* asc = static_cast(asl.getCurrentOptionData()); + m->parameter = (asc->pestype & 0xFFFF) | (asc->type & 0xFF) << 16; + MessageQueue::getInstance()->postMessage(m); + } return 2; } + case Input::DOWN: { - if (editsubtitles) { - ssl.down(); - ssl.draw(); - BoxStack::getInstance()->update(this); - Message* m = new Message(); - m->from = this; - m->to = parent; - m->message = Message::SUBTITLE_CHANGE_CHANNEL; - m->parameter = (((AudioSubtitleChannel*)ssl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)ssl.getCurrentOptionData())->type &0xFF)<<16 - |(((AudioSubtitleChannel*)asl.getCurrentOptionData())->streamtype &0xFF)<<24 ; - MessageQueue::getInstance()->postMessage(m); - } else { - asl.down(); - asl.draw(); - BoxStack::getInstance()->update(this); - Message* m = new Message(); - m->from = this; - m->to = parent; - m->message = Message::AUDIO_CHANGE_CHANNEL; - m->parameter = (((AudioSubtitleChannel*)asl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)asl.getCurrentOptionData())->type &0xFF)<<16 - |(((AudioSubtitleChannel*)asl.getCurrentOptionData())->streamtype &0xFF)<<24 ; - MessageQueue::getInstance()->postMessage(m); - } + if (editsubtitles) + { + ssl.down(); + ssl.draw(); + BoxStack::getInstance()->update(this); + Message* m = new Message(); + m->from = this; + m->to = parent; + m->message = Message::SUBTITLE_CHANGE_CHANNEL; + AudioSubtitleChannel* subchan = static_cast(ssl.getCurrentOptionData()); + AudioSubtitleChannel* audchan = static_cast(asl.getCurrentOptionData()); + m->parameter = (subchan->pestype & 0xFFFF) + | (subchan->type & 0xFF) << 16 + | (audchan->streamtype & 0xFF) << 24; // FIXME: Is this really supposed to be audio channel here? Old code did audio, looks wrong + MessageQueue::getInstance()->postMessage(m); + } + else + { + asl.down(); + asl.draw(); + BoxStack::getInstance()->update(this); + Message* m = new Message(); + m->from = this; + m->to = parent; + m->message = Message::AUDIO_CHANGE_CHANNEL; + AudioSubtitleChannel* asc = static_cast(asl.getCurrentOptionData()); + m->parameter = (asc->pestype & 0xFFFF) + | (asc->type & 0xFF) << 16 + | (asc->streamtype & 0xFF) << 24; + MessageQueue::getInstance()->postMessage(m); + } return 2; } + case Input::LEFT: - { - if (editsubtitles && subtitles) { - ssl.setDarkSelOption(true); - asl.setDarkSelOption(false); - editsubtitles=false; - asl.draw(); - ssl.draw(); - BoxStack::getInstance()->update(this); - } - return 2; - } - case Input::RIGHT: - { - if (!editsubtitles && subtitles) { - ssl.setDarkSelOption(false); - asl.setDarkSelOption(true); - editsubtitles=true; - asl.draw(); - ssl.draw(); - BoxStack::getInstance()->update(this); - } - return 2; - } + { + if (editsubtitles && subtitles) + { + ssl.setDarkSelOption(true); + asl.setDarkSelOption(false); + editsubtitles = false; + asl.draw(); + ssl.draw(); + BoxStack::getInstance()->update(this); + } + + return 2; + } + + case Input::RIGHT: + { + if (!editsubtitles && subtitles) + { + ssl.setDarkSelOption(false); + asl.setDarkSelOption(true); + editsubtitles = true; + asl.draw(); + ssl.draw(); + BoxStack::getInstance()->update(this); + } + + return 2; + } } return 1; @@ -561,65 +532,70 @@ void VAudioSelector::processMessage(Message* m) { if (m->message == Message::MOUSE_MOVE) { - - UINT lastsel=asl.getCurrentOption(); - - if (((m->parameter>>16)-getScreenX()) < 200 && asl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + int lastsel = asl.getCurrentOption(); + + if (((m->parameter >> 16) - getScreenX()) < 200 && asl.mouseMove((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY())) + { + editsubtitles = false; + ssl.setDarkSelOption(true); + asl.setDarkSelOption(false); + asl.draw(); + ssl.draw(); + BoxStack::getInstance()->update(this); + + if (lastsel != asl.getCurrentOption()) { - editsubtitles=false; - ssl.setDarkSelOption(true); - asl.setDarkSelOption(false); - asl.draw(); - ssl.draw(); - BoxStack::getInstance()->update(this); - if ((int)lastsel!=asl.getCurrentOption()) - { - Message* m2 = new Message(); - m2->from = this; - m2->to = parent; - m2->message = Message::AUDIO_CHANGE_CHANNEL; - m2->parameter = (((AudioSubtitleChannel*)asl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)asl.getCurrentOptionData())->type &0xFF)<<16 ; - MessageQueue::getInstance()->postMessage(m2); - } - return; - + Message* m2 = new Message(); + m2->from = this; + m2->to = parent; + m2->message = Message::AUDIO_CHANGE_CHANNEL; + AudioSubtitleChannel* asc = static_cast(asl.getCurrentOptionData()); + m2->parameter = (asc->pestype & 0xFFFF) | (asc->type & 0xFF) << 16 ; + MessageQueue::getInstance()->postMessage(m2); } - lastsel=ssl.getCurrentOption(); - - if (ssl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + + return; + } + + lastsel = ssl.getCurrentOption(); + + if (ssl.mouseMove((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY())) + { + editsubtitles = true; + ssl.setDarkSelOption(false); + asl.setDarkSelOption(true); + asl.draw(); + ssl.draw(); + BoxStack::getInstance()->update(this); + + if (lastsel != ssl.getCurrentOption()) { - editsubtitles=true; - ssl.setDarkSelOption(false); - asl.setDarkSelOption(true); - asl.draw(); - ssl.draw(); - BoxStack::getInstance()->update(this); - if ((int)lastsel!=ssl.getCurrentOption()) - { - Message* m2 = new Message(); - m2->from = this; - m2->to = parent; - m2->message = Message::SUBTITLE_CHANGE_CHANNEL; - m2->parameter = (((AudioSubtitleChannel*)ssl.getCurrentOptionData())->pestype &0xFFFF)|(((AudioSubtitleChannel*)ssl.getCurrentOptionData())->type &0xFF)<<16 ; - MessageQueue::getInstance()->postMessage(m2); - } - return; - } + Message* m2 = new Message(); + m2->from = this; + m2->to = parent; + m2->message = Message::SUBTITLE_CHANGE_CHANNEL; + AudioSubtitleChannel* asc = static_cast(ssl.getCurrentOptionData()); + m2->parameter = (asc->pestype & 0xFFFF) | (asc->type & 0xFF) << 16 ; + MessageQueue::getInstance()->postMessage(m2); + } + + return; + } } else if (m->message == Message::MOUSE_LBDOWN) { - if (asl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + if (asl.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY())) { - editsubtitles=false; + editsubtitles = false; ssl.setDarkSelOption(true); asl.setDarkSelOption(false); asl.draw(); ssl.draw(); BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press } - else if (ssl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + else if (ssl.mouseLBDOWN((m->parameter >> 16) - getScreenX(), (m->parameter & 0xFFFF) - getScreenY())) { - editsubtitles=true; + editsubtitles = true; ssl.setDarkSelOption(false); asl.setDarkSelOption(true); asl.draw(); @@ -627,14 +603,15 @@ void VAudioSelector::processMessage(Message* m) BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press } else - { //check if press is outside this view! then simulate cancel - int x=(m->parameter>>16)-getScreenX(); - int y=(m->parameter&0xFFFF)-getScreenY(); - if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) + { + //check if press is outside this view! then simulate cancel + int x = (m->parameter >> 16) - getScreenX(); + int y = (m->parameter & 0xFFFF) - getScreenY(); + + if (x < 0 || y < 0 || x > static_cast(getWidth()) || y > static_cast(getHeight())) { BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press } } } } - diff --git a/vaudioselector.h b/vaudioselector.h index 17b229e..8131190 100644 --- a/vaudioselector.h +++ b/vaudioselector.h @@ -14,17 +14,14 @@ 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 . */ #ifndef VAUDIOSELECTOR_H #define VAUDIOSELECTOR_H -#include -#include +#include #include -#include #include "tbboxx.h" #include "wselectlist.h" @@ -43,28 +40,25 @@ class AudioSubtitleChannel { public: int type; - char* name; int pestype; int streamtype; + std::string name; }; - -typedef std::vector AudioSubtitleChannelList; +typedef std::vector AudioSubtitleChannelList; class VAudioSelector : public TBBoxx { public: VAudioSelector(void* parent, bool* availableMpegAudioChannels, // Recording mode - bool* availableAc3AudioChannels, int currentAudioChannel, - bool *availableSubtitleChannels, - int*ttxtpages, - int currentSubtitleChannel,int currentSubtitleType, - RecInfo* recInfo); + bool* availableAc3AudioChannels, int currentAudioChannel, + bool* availableSubtitleChannels, + int* ttxtpages, + int currentSubtitleChannel, int currentSubtitleType, + RecInfo* recInfo); VAudioSelector(void* tparent, Channel* channel, int currentAudioChannel, - int currentSubtitleChannel,int currentSubtitletype,int*ttxtpages); // Live mode - - VAudioSelector(void* parent, Channel* channel); + int currentSubtitleChannel, int currentSubtitletype, int* ttxtpages); // Live mode virtual ~VAudioSelector(); @@ -73,17 +67,16 @@ class VAudioSelector : public TBBoxx void draw(); private: - void* parent; WSelectList asl; WSelectList ssl; - + + void* parent; bool liveMode; - bool subtitles; - bool editsubtitles; + bool subtitles{}; + bool editsubtitles{}; AudioSubtitleChannelList acl; AudioSubtitleChannelList scl; }; #endif - diff --git a/vvideorec.cc b/vvideorec.cc index 2e406b8..6709ef1 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -852,7 +852,7 @@ void VVideoRec::doBar(int action_in) if (!barGenHold && !barScanHold && !barVasHold) timers->setTimerD(this, 1, 4); - Log::getInstance()->log("VVideoRec", Log::DEBUG, "player state: %i", playerState); + Log::getInstance()->log("VVideoRec", Log::DEBUG, "player state: %i", playerState); if ((playerState == PlayerVideoRec::S_PAUSE_P) || (playerState == PlayerVideoRec::S_PAUSE_I)) timers->cancelTimer(this, 2); -- 2.39.5