X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/c606126c3efaec7e3fdf1283fc37dfb7140bee13..25b95b17bf075eb648f0053901f299e8717990d2:/lib/dvb/radiotext.cpp diff --git a/lib/dvb/radiotext.cpp b/lib/dvb/radiotext.cpp index 0ac71751..87498da9 100644 --- a/lib/dvb/radiotext.cpp +++ b/lib/dvb/radiotext.cpp @@ -7,6 +7,7 @@ DEFINE_REF(eDVBRadioTextParser); eDVBRadioTextParser::eDVBRadioTextParser(iDVBDemux *demux) :bytesread(0), ptr(0), p1(-1), p2(-1), msgPtr(0), state(0) + ,m_abortTimer(eApp) { setStreamID(0xC0, 0xC0); @@ -14,6 +15,7 @@ eDVBRadioTextParser::eDVBRadioTextParser(iDVBDemux *demux) eDebug("failed to create PES reader!"); else m_pes_reader->connectRead(slot(*this, &eDVBRadioTextParser::processData), m_read_connection); + CONNECT(m_abortTimer.timeout, eDVBRadioTextParser::abortNonAvail); } #define SWAP(x) ((x<<8)|(x>>8)) @@ -82,6 +84,7 @@ void eDVBRadioTextParser::processPESPacket(__u8 *data, int len) int channel = mode == 3 ? 1 : 2; int id = (data[pos + 1] >> 3) & 1; int emphasis_bit = data[pos + 3] & 3; + int protection_bit = data[pos + 1] & 1; int rate = -1; int sample_freq = -1; int layer = -1; @@ -112,17 +115,19 @@ void eDVBRadioTextParser::processPESPacket(__u8 *data, int len) pos += frame_size; +#if 0 +// eDebug("protection_bit ? %d", protection_bit); +// int offs = protection_bit ? pos - 1 : pos - 3; +// if (data[offs] != 0xFD) +// offs += 2; +// eDebug("%02x %02x %02x %02x %02x", data[offs-2], data[offs-1], data[offs], data[offs+1], data[offs+2]); +#else int offs = pos - 1; - if (data[offs] != 0xFD) - { - offs -= 2; - if (data[offs] != 0xFD) - return; - else - eDebug("match 2"); - } - else +#endif + + if (data[offs] == 0xFD) { + m_abortTimer.stop(); int ancillary_len = 1 + data[offs - 1]; offs -= ancillary_len; while(offs < pos) @@ -131,7 +136,7 @@ void eDVBRadioTextParser::processPESPacket(__u8 *data, int len) } } -void eDVBRadioTextParser::gotAncillaryByte(__u8 data) +inline void eDVBRadioTextParser::gotAncillaryByte(__u8 data) { buf[bytesread]=data; bytesread+=1; @@ -257,9 +262,15 @@ void eDVBRadioTextParser::gotAncillaryByte(__u8 data) int eDVBRadioTextParser::start(int pid) { - if (m_pes_reader) - return m_pes_reader->start(pid); - else - return -1; + int ret = -1; + if (m_pes_reader && !(ret = m_pes_reader->start(pid))) + m_abortTimer.startLongTimer(20); + return ret; } +void eDVBRadioTextParser::abortNonAvail() +{ + eDebug("no ancillary data in audio stream... abort radiotext pes parser"); + if (m_pes_reader) + m_pes_reader->stop(); +}