diff options
author | Rainer Hochecker <fernetmenta@online.de> | 2018-01-14 17:24:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-14 17:24:09 +0100 |
commit | 732be44bd71ce587c641ec68248cf4183d596904 (patch) | |
tree | 395e4bfaedb83b6b7813c1308328e32a2d2c1a41 | |
parent | cbd6f1b98cecf8ec61c5af41347236e3025da37d (diff) | |
parent | 948537138d203b52312b395b847319644c4d22ee (diff) |
Merge pull request #13363 from FernetMenta/paplayer
paplayer: fix player times for cue sheets
-rw-r--r-- | xbmc/cores/paplayer/PAPlayer.cpp | 32 | ||||
-rw-r--r-- | xbmc/cores/paplayer/PAPlayer.h | 8 |
2 files changed, 19 insertions, 21 deletions
diff --git a/xbmc/cores/paplayer/PAPlayer.cpp b/xbmc/cores/paplayer/PAPlayer.cpp index f00be739f6..e3ff3697ed 100644 --- a/xbmc/cores/paplayer/PAPlayer.cpp +++ b/xbmc/cores/paplayer/PAPlayer.cpp @@ -53,10 +53,8 @@ PAPlayer::PAPlayer(IPlayerCallback& callback) : m_isFinished(false), m_defaultCrossfadeMS (0), m_upcomingCrossfadeMS(0), - m_currentStream(NULL ), m_audioCallback(NULL ), m_jobCounter(0), - m_continueStream(false), m_newForcedPlayerTime(-1), m_newForcedTotalTime (-1) { @@ -318,22 +316,20 @@ bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn) { // check if we advance a track of a CUE sheet // if this is the case we don't need to open a new stream - std::string newURL = file.GetMusicInfoTag() ? file.GetMusicInfoTag()->GetURL() : file.GetPath(); - std::string oldURL = m_currentStream->m_fileItem.GetMusicInfoTag() ? - m_currentStream->m_fileItem.GetMusicInfoTag()->GetURL() : m_currentStream->m_fileItem.GetPath(); + std::string newURL = file.GetDynURL().GetFileName(); + std::string oldURL = m_currentStream->m_fileItem.GetDynURL().GetFileName(); if (newURL.compare(oldURL) == 0 && file.m_lStartOffset && file.m_lStartOffset == m_currentStream->m_fileItem.m_lEndOffset && m_currentStream && m_currentStream->m_prepareTriggered) { - m_continueStream = true; + m_currentStream->m_nextFileItem.reset(new CFileItem(file)); m_upcomingCrossfadeMS = 0; return true; } + m_currentStream->m_nextFileItem.reset(); } - m_continueStream = false; - StreamInfo *si = new StreamInfo(); si->m_fileItem = file; if (!si->m_decoder.Create(file, si->m_fileItem.m_lStartOffset)) @@ -471,7 +467,7 @@ inline bool PAPlayer::PrepareStream(StreamInfo *si) return false; } - si->m_stream->SetVolume (si->m_volume); + si->m_stream->SetVolume(si->m_volume); float peak = 1.0; float gain = si->m_decoder.GetReplayGain(peak); if (peak * gain <= 1.0) @@ -676,15 +672,15 @@ inline void PAPlayer::ProcessStreams(double &freeBufferTime) if (!si->m_started) continue; - /* is it time to prepare the next stream? */ + // is it time to prepare the next stream? if (si->m_prepareNextAtFrame > 0 && !si->m_prepareTriggered && si->m_framesSent >= si->m_prepareNextAtFrame) { si->m_prepareTriggered = true; m_callback.OnQueueNextItem(); } - /* it is time to start playing the next stream? */ - if (si->m_playNextAtFrame > 0 && !si->m_playNextTriggered && !m_continueStream && si->m_framesSent >= si->m_playNextAtFrame) + // it is time to start playing the next stream? + if (si->m_playNextAtFrame > 0 && !si->m_playNextTriggered && !si->m_nextFileItem && si->m_framesSent >= si->m_playNextAtFrame) { if (!si->m_prepareTriggered) { @@ -768,16 +764,19 @@ inline bool PAPlayer::ProcessStream(StreamInfo *si, double &freeBufferTime) si->m_decoder.ReadSamples(PACKET_SIZE) == RET_ERROR || ((si->m_endOffset) && (si->m_framesSent / si->m_audioFormat.m_sampleRate >= (si->m_endOffset - si->m_startOffset) / 1000))) { - if (si == m_currentStream && m_continueStream) + if (si == m_currentStream && si->m_nextFileItem) { // update current stream with info of next track - si->m_startOffset = si->m_fileItem.m_lStartOffset; - if (si->m_fileItem.m_lEndOffset) - si->m_endOffset = si->m_fileItem.m_lEndOffset; + si->m_startOffset = si->m_nextFileItem->m_lStartOffset; + if (si->m_nextFileItem->m_lEndOffset) + si->m_endOffset = si->m_nextFileItem->m_lEndOffset; else si->m_endOffset = 0; si->m_framesSent = 0; + si->m_fileItem = *si->m_nextFileItem; + si->m_nextFileItem.reset(); + int64_t streamTotalTime = si->m_decoder.TotalTime() - si->m_startOffset; if (si->m_endOffset) streamTotalTime = si->m_endOffset - si->m_startOffset; @@ -797,7 +796,6 @@ inline bool PAPlayer::ProcessStream(StreamInfo *si, double &freeBufferTime) UpdateGUIData(si); m_callback.OnPlayBackStarted(si->m_fileItem); - m_continueStream = false; } else { diff --git a/xbmc/cores/paplayer/PAPlayer.h b/xbmc/cores/paplayer/PAPlayer.h index 43b643c619..51e3683cb6 100644 --- a/xbmc/cores/paplayer/PAPlayer.h +++ b/xbmc/cores/paplayer/PAPlayer.h @@ -92,9 +92,10 @@ protected: float GetPercentage(); private: - typedef struct + struct StreamInfo { CFileItem m_fileItem; + std::unique_ptr<CFileItem> m_nextFileItem; CAudioDecoder m_decoder; /* the stream decoder */ int64_t m_startOffset; /* the stream start offset */ int64_t m_endOffset; /* the stream end offset */ @@ -118,7 +119,7 @@ private: bool m_isSlaved; /* true if the stream has been slaved to another */ bool m_waitOnDrain; /* wait for stream being drained in AE */ - } StreamInfo; + }; typedef std::list<StreamInfo*> StreamList; @@ -130,7 +131,7 @@ private: unsigned int m_defaultCrossfadeMS; /* how long the default crossfade is in ms */ unsigned int m_upcomingCrossfadeMS; /* how long the upcoming crossfade is in ms */ CEvent m_startEvent; /* event for playback start */ - StreamInfo* m_currentStream; /* the current playing stream */ + StreamInfo* m_currentStream = nullptr; IAudioCallback* m_audioCallback; /* the viz audio callback */ CCriticalSection m_streamsLock; /* lock for the stream list */ @@ -138,7 +139,6 @@ private: StreamList m_finishing; /* finishing streams */ int m_jobCounter; CEvent m_jobEvent; - bool m_continueStream; int64_t m_newForcedPlayerTime; int64_t m_newForcedTotalTime; std::unique_ptr<CProcessInfo> m_processInfo; |