whitespace fixes, fix infobar summary to include progressbar (patch by Sat_Man)
[enigma2.git] / lib / service / servicedvb.cpp
index 43a78bb434d56398488af43d47d7e74e2aab31f5..c66b3da15b235b46cee5b1318b29a97a4dac3c69 100644 (file)
@@ -1025,7 +1025,7 @@ eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *serv
        m_subtitle_widget = 0;
        
        m_tune_state = -1;
-       
+
        CONNECT(m_subtitle_sync_timer.timeout, eDVBServicePlay::checkSubtitleTiming);
 }
 
@@ -1345,6 +1345,9 @@ RESULT eDVBServicePlay::seekTo(pts_t to)
                return -1;
        
        m_cue->seekTo(0, to);
+       m_dvb_subtitle_pages.clear();
+       m_subtitle_pages.clear();
+
        return 0;
 }
 
@@ -1372,6 +1375,8 @@ RESULT eDVBServicePlay::seekRelative(int direction, pts_t to)
                return 0;
        
        m_cue->seekTo(mode, to);
+       m_dvb_subtitle_pages.clear();
+       m_subtitle_pages.clear();
        return 0;
 }
 
@@ -1694,6 +1699,8 @@ RESULT eDVBServicePlay::getTrackInfo(struct iAudioTrackInfo &info, unsigned int
        if (i >= program.audioStreams.size())
                return -2;
        
+       info.m_pid = program.audioStreams[i].pid;
+
        if (program.audioStreams[i].type == eDVBServicePMTHandler::audioStream::atMPEG)
                info.m_description = "MPEG";
        else if (program.audioStreams[i].type == eDVBServicePMTHandler::audioStream::atAC3)
@@ -1779,7 +1786,8 @@ int eDVBServicePlay::selectAudioStream(int i)
                                    anything in the best case, or destroy the default setting in
                                    case the real default is not yet available.)
                        */
-       if (m_dvb_service && !m_is_pvr && (i != -1))
+       if (m_dvb_service && !m_is_pvr && ((i != -1)
+               || ((m_dvb_service->getCacheEntry(eDVBService::cAPID) == -1) && (m_dvb_service->getCacheEntry(eDVBService::cAC3PID)==-1))))
        {
                if (apidtype == eDVBAudio::aMPEG)
                {
@@ -2768,6 +2776,10 @@ void eDVBServicePlay::newSubtitlePage(const eDVBTeletextSubtitlePage &page)
 {
        if (m_subtitle_widget)
        {
+               pts_t pos = 0;
+               if (m_decoder)
+                       m_decoder->getPTS(0, pos);
+               eDebug("got new subtitle page %lld %lld %d", pos, page.m_pts, page.m_have_pts);
                m_subtitle_pages.push_back(page);
                checkSubtitleTiming();
        }
@@ -2775,7 +2787,7 @@ void eDVBServicePlay::newSubtitlePage(const eDVBTeletextSubtitlePage &page)
 
 void eDVBServicePlay::checkSubtitleTiming()
 {
-//     eDebug("checkSubtitleTiming");
+       eDebug("checkSubtitleTiming");
        if (!m_subtitle_widget)
                return;
        while (1)
@@ -2804,36 +2816,36 @@ void eDVBServicePlay::checkSubtitleTiming()
                if (m_decoder)
                        m_decoder->getPTS(0, pos);
 
-//             eDebug("%lld %lld", pos, show_time);
+               eDebug("%lld %lld", pos, show_time);
                int diff =  show_time - pos;
                if (diff < 0)
                {
                        eDebug("[late (%d ms)]", -diff / 90);
                        diff = 0;
                }
-               if (diff > 900000)
-               {
-                       eDebug("[invalid]");
-                       diff = 0;
-               }
+//             if (diff > 900000)
+//             {
+//                     eDebug("[invalid]");
+//                     diff = 0;
+//             }
        
-               if (!diff)
+               if ((diff/90)<20)
                {
                        if (type == TELETEXT)
                        {
-                               eDebug("display teletext subtitle page");
+                               eDebug("display teletext subtitle page %lld", show_time);
                                m_subtitle_widget->setPage(page);
                                m_subtitle_pages.pop_front();
                        }
                        else
                        {
-                               eDebug("display dvb subtitle Page");
+                               eDebug("display dvb subtitle Page %lld", show_time);
                                m_subtitle_widget->setPage(dvb_page);
                                m_dvb_subtitle_pages.pop_front();
                        }
                } else
                {
-//                     eDebug("start subtitle delay %d", diff / 90);
+                       eDebug("start subtitle delay %d", diff / 90);
                        m_subtitle_sync_timer.start(diff / 90, 1);
                        break;
                }
@@ -2844,6 +2856,10 @@ void eDVBServicePlay::newDVBSubtitlePage(const eDVBSubtitlePage &p)
 {
        if (m_subtitle_widget)
        {
+               pts_t pos = 0;
+               if (m_decoder)
+                       m_decoder->getPTS(0, pos);
+               eDebug("got new subtitle page %lld %lld", pos, p.m_show_time);
                m_dvb_subtitle_pages.push_back(p);
                checkSubtitleTiming();
        }