return program.audioStreams.size();
}
+int eDVBServicePlay::getCurrentTrack()
+{
+ eDVBServicePMTHandler::program program;
+ eDVBServicePMTHandler &h = m_timeshift_active ? m_service_handler_timeshift : m_service_handler;
+ if (h.getProgramInfo(program))
+ return 0;
+
+ int max = program.audioStreams.size();
+ int i;
+
+ for (i = 0; i < max; ++i)
+ if (program.audioStreams[i].pid == m_current_audio_pid)
+ return i;
+
+ return 0;
+}
+
RESULT eDVBServicePlay::selectTrack(unsigned int i)
{
int ret = selectAudioStream(i);
if (h.getProgramInfo(program))
return -1;
-
+
if ((unsigned int)i >= program.audioStreams.size())
return -2;
-
+
if (!m_decoder)
return -3;
-
- if (m_decoder->setAudioPID(program.audioStreams[i].pid, program.audioStreams[i].type))
- return -4;
- if (m_rds_decoder)
- m_rds_decoder->start(program.audioStreams[i].pid);
+ int stream = i;
+ if (stream == -1)
+ stream = program.defaultAudioStream;
- if (m_dvb_service && !m_is_pvr)
+ m_current_audio_pid = program.audioStreams[stream].pid;
+
+ if (m_decoder->setAudioPID(program.audioStreams[stream].pid, program.audioStreams[stream].type))
{
- if (program.audioStreams[i].type == eDVBAudio::aMPEG)
+ eDebug("set audio pid failed");
+ return -4;
+ }
+
+ if (m_rds_decoder)
+ m_rds_decoder->start(program.audioStreams[stream].pid);
+
+ /* store new pid as default only when:
+ a.) we have an entry in the service db for the current service,
+ b.) we are not playing back something,
+ c.) we are not selecting the default entry. (we wouldn't change
+ 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 (program.audioStreams[stream].type == eDVBAudio::aMPEG)
{
- m_dvb_service->setCacheEntry(eDVBService::cAPID, program.audioStreams[i].pid);
+ m_dvb_service->setCacheEntry(eDVBService::cAPID, program.audioStreams[stream].pid);
m_dvb_service->setCacheEntry(eDVBService::cAC3PID, -1);
}
else
{
m_dvb_service->setCacheEntry(eDVBService::cAPID, -1);
- m_dvb_service->setCacheEntry(eDVBService::cAC3PID, program.audioStreams[i].pid);
+ m_dvb_service->setCacheEntry(eDVBService::cAC3PID, program.audioStreams[stream].pid);
}
}
m_decoder->setPCMDelay(pcm_delay == -1 ? 0 : pcm_delay);
m_decoder->setVideoPID(vpid, vpidtype);
- m_decoder->setAudioPID(apid, apidtype);
+ selectAudioStream();
+
if (!(m_is_pvr || m_timeshift_active || !m_is_primary))
{
m_decoder->setSyncPCR(pcrpid);
int getNumberOfTracks();
RESULT selectTrack(unsigned int i);
RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
+ int getCurrentTrack();
// iAudioChannelSelection
int getCurrentChannel();
/* in timeshift mode, we essentially have two channels, and thus pmt handlers. */
eDVBServicePMTHandler m_service_handler_timeshift;
eDVBServiceEITHandler m_event_handler;
+ int m_current_audio_pid;
eDVBServicePlay(const eServiceReference &ref, eDVBService *service);
ePtr<iDVBDemux> m_decode_demux;
int m_current_audio_stream;
- int selectAudioStream(int n);
+ int selectAudioStream(int n = -1);
/* timeshift */
ePtr<iDVBTSRecorder> m_record;