From e88b753942b68d5c4abca45abb36bb5563588157 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Sat, 25 Aug 2007 00:01:27 +0000 Subject: [PATCH] use explicit default track instead of first one (as the default one isn't always the first one anymore), implement getCurrentTrack --- lib/service/servicedvb.cpp | 58 ++++++++++++++++++++++++++++++-------- lib/service/servicedvb.h | 4 ++- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 5a6999d3..790ca2f7 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -1656,6 +1656,23 @@ int eDVBServicePlay::getNumberOfTracks() 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); @@ -1712,30 +1729,46 @@ int eDVBServicePlay::selectAudioStream(int 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); } } @@ -2336,7 +2369,8 @@ void eDVBServicePlay::updateDecoder() 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); diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h index 4a40df12..789edbea 100644 --- a/lib/service/servicedvb.h +++ b/lib/service/servicedvb.h @@ -139,6 +139,7 @@ public: int getNumberOfTracks(); RESULT selectTrack(unsigned int i); RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n); + int getCurrentTrack(); // iAudioChannelSelection int getCurrentChannel(); @@ -194,6 +195,7 @@ private: /* 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); @@ -214,7 +216,7 @@ private: ePtr m_decode_demux; int m_current_audio_stream; - int selectAudioStream(int n); + int selectAudioStream(int n = -1); /* timeshift */ ePtr m_record; -- 2.30.2