Merge branch 'master' of git.opendreambox.org:/git/enigma2
authorFelix Domke <felix.domke@multimedia-labs.de>
Fri, 14 Aug 2009 11:23:54 +0000 (13:23 +0200)
committerFelix Domke <felix.domke@multimedia-labs.de>
Fri, 14 Aug 2009 11:23:54 +0000 (13:23 +0200)
1  2 
lib/service/servicedvb.cpp

@@@ -466,7 -466,6 +466,7 @@@ public
        
        RESULT deleteFromDisk(int simulate);
        RESULT getListOfFilenames(std::list<std::string> &);
 +      RESULT reindex();
  };
  
  DEFINE_REF(eDVBPVRServiceOfflineOperations);
@@@ -529,42 -528,6 +529,42 @@@ RESULT eDVBPVRServiceOfflineOperations:
        return 0;
  }
  
 +RESULT eDVBPVRServiceOfflineOperations::reindex()
 +{
 +      const char *filename = m_ref.path.c_str();
 +      eDebug("reindexing %s...", filename);
 +
 +      eMPEGStreamInformation info;
 +      eMPEGStreamParserTS parser(info);
 +      
 +      info.startSave(filename);
 +      
 +      eRawFile f;
 +      
 +      int err = f.open(m_ref.path.c_str(), 0);
 +      if (err < 0)
 +              return -1;
 +      
 +      off_t length = f.length();
 +      unsigned char buffer[188*256*4];
 +      while (1)
 +      {
 +              off_t offset = f.lseek(0, SEEK_CUR);
 +              eDebug("at %08llx / %08llx (%d %%)", offset, length, (int)(offset * 100 / length));
 +              int r = f.read(buffer, sizeof(buffer));
 +              if (!r)
 +                      break;
 +              if (r < 0)
 +                      return r;
 +              parser.parseData(offset, buffer, r);
 +      }
 +      
 +      info.stopSave();
 +      f.close();
 +      
 +      return 0;
 +}
 +
  DEFINE_REF(eServiceFactoryDVB)
  
  eServiceFactoryDVB::eServiceFactoryDVB()
@@@ -1795,21 -1758,26 +1795,26 @@@ int eDVBServicePlay::selectAudioStream(
                return -4;
        }
  
+       int rdsPid = apid;
                /* if we are not in PVR mode, timeshift is not active and we are not in pip mode, check if we need to enable the rds reader */
        if (!(m_is_pvr || m_timeshift_active || !m_is_primary))
-               if (!m_rds_decoder)
+       {
+               int different_pid = program.videoStreams.empty() && program.audioStreams.size() == 1 && program.audioStreams[stream].rdsPid != -1;
+               if (different_pid)
+                       rdsPid = program.audioStreams[stream].rdsPid;
+               if (!m_rds_decoder || m_rds_decoder->getPid() != rdsPid)
                {
+                       m_rds_decoder = 0;
                        ePtr<iDVBDemux> data_demux;
                        if (!h.getDataDemux(data_demux))
                        {
-                               m_rds_decoder = new eDVBRdsDecoder(data_demux);
+                               m_rds_decoder = new eDVBRdsDecoder(data_demux, different_pid);
                                m_rds_decoder->connectEvent(slot(*this, &eDVBServicePlay::rdsDecoderEvent), m_rds_decoder_event_connection);
+                               m_rds_decoder->start(rdsPid);
                        }
                }
-               /* if we decided that we need one, update the pid */
-       if (m_rds_decoder)
-               m_rds_decoder->start(apid);
+       }
  
                        /* store new pid as default only when:
                                a.) we have an entry in the service db for the current service,
@@@ -2391,7 -2359,6 +2396,7 @@@ void eDVBServicePlay::updateDecoder(
                }
                if (m_cue)
                        m_cue->setDecodingDemux(m_decode_demux, m_decoder);
 +              m_decoder->play(); /* pids will be set later. */
        }
  
        m_timeshift_changed = 0;