Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3273 from FernetMenta/cuefile

paplayer fixes - all were tested by affected users in the testing thread
  • Loading branch information...
commit 92169a699b18a94b07d28e9d8a8aa5fd929c5f12 2 parents 0acee90 + 7093b1c
@fritsch fritsch authored
Showing with 66 additions and 6 deletions.
  1. +65 −6 xbmc/cores/paplayer/PAPlayer.cpp
  2. +1 −0  xbmc/cores/paplayer/PAPlayer.h
View
71 xbmc/cores/paplayer/PAPlayer.cpp
@@ -75,7 +75,8 @@ PAPlayer::PAPlayer(IPlayerCallback& callback) :
m_currentStream (NULL ),
m_audioCallback (NULL ),
m_FileItem (new CFileItem()),
- m_jobCounter (0)
+ m_jobCounter (0),
+ m_continueStream (false)
{
memset(&m_playerGUIData, 0, sizeof(m_playerGUIData));
}
@@ -276,7 +277,11 @@ bool PAPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options)
void PAPlayer::UpdateCrossfadeTime(const CFileItem& file)
{
- m_upcomingCrossfadeMS = m_defaultCrossfadeMS = CSettings::Get().GetInt("musicplayer.crossfade") * 1000;
+ // we explicitely disable crossfading for audio cds
+ if(file.IsCDDA())
+ m_upcomingCrossfadeMS = 0;
+ else
+ m_upcomingCrossfadeMS = m_defaultCrossfadeMS = CSettings::Get().GetInt("musicplayer.crossfade") * 1000;
if (m_upcomingCrossfadeMS)
{
if (m_streams.size() == 0 ||
@@ -310,6 +315,23 @@ bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn/* = true */, b
{
StreamInfo *si = new StreamInfo();
+ // check if we advance a track of a CUE sheet
+ // if this is the case we don't need to open a new stream
+ if (file.GetPath().Equals(m_FileItem->GetPath()) &&
+ file.m_lStartOffset &&
+ file.m_lStartOffset == m_FileItem->m_lEndOffset &&
+ m_currentStream && m_currentStream->m_prepareTriggered)
+ {
+ m_continueStream = true;
+ m_upcomingCrossfadeMS = 0;
+ *m_FileItem = file;
+ return true;
+ }
+ else
+ {
+ m_continueStream = false;
+ }
+
if (!si->m_decoder.Create(file, (file.m_lStartOffset * 1000) / 75))
{
CLog::Log(LOGWARNING, "PAPlayer::QueueNextFileEx - Failed to create the decoder");
@@ -369,8 +391,12 @@ bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn/* = true */, b
streamTotalTime = si->m_endOffset - si->m_startOffset;
si->m_prepareNextAtFrame = 0;
- if (streamTotalTime >= TIME_TO_CACHE_NEXT_FILE + m_defaultCrossfadeMS)
- si->m_prepareNextAtFrame = (int)((streamTotalTime - TIME_TO_CACHE_NEXT_FILE - m_defaultCrossfadeMS) * si->m_sampleRate / 1000.0f);
+ // cd drives don't really like it to be crossfaded or prepared
+ if(!file.IsCDDA())
+ {
+ if (streamTotalTime >= TIME_TO_CACHE_NEXT_FILE + m_defaultCrossfadeMS)
+ si->m_prepareNextAtFrame = (int)((streamTotalTime - TIME_TO_CACHE_NEXT_FILE - m_defaultCrossfadeMS) * si->m_sampleRate / 1000.0f);
+ }
si->m_prepareTriggered = false;
@@ -708,8 +734,41 @@ inline bool PAPlayer::ProcessStream(StreamInfo *si, double &delay, double &buffe
si->m_decoder.ReadSamples(PACKET_SIZE) == RET_ERROR ||
((si->m_endOffset) && (si->m_framesSent / si->m_sampleRate >= (si->m_endOffset - si->m_startOffset) / 1000)))
{
- CLog::Log(LOGINFO, "PAPlayer::ProcessStream - Stream Finished");
- return false;
+ if (si == m_currentStream && m_continueStream)
+ {
+ // update current stream with info of next track
+ si->m_startOffset = m_FileItem->m_lStartOffset * 1000 / 75;
+ if (m_FileItem->m_lEndOffset)
+ si->m_endOffset = m_FileItem->m_lEndOffset * 1000 / 75;
+ else
+ si->m_endOffset = 0;
+ si->m_framesSent = 0;
+
+ int64_t streamTotalTime = si->m_decoder.TotalTime() - si->m_startOffset;
+ if (si->m_endOffset)
+ streamTotalTime = si->m_endOffset - si->m_startOffset;
+
+ // calculate time when to prepare next stream
+ si->m_prepareNextAtFrame = 0;
+ if (streamTotalTime >= TIME_TO_CACHE_NEXT_FILE + m_defaultCrossfadeMS)
+ si->m_prepareNextAtFrame = (int)((streamTotalTime - TIME_TO_CACHE_NEXT_FILE - m_defaultCrossfadeMS) * si->m_sampleRate / 1000.0f);
+
+ si->m_prepareTriggered = false;
+ si->m_playNextAtFrame = 0;
+ si->m_playNextTriggered = false;
+
+ //update the current stream to start playing the next track at the correct frame.
+ UpdateStreamInfoPlayNextAtFrame(m_currentStream, m_upcomingCrossfadeMS);
+
+ UpdateGUIData(si);
+ m_callback.OnPlayBackStarted();
+ m_continueStream = false;
+ }
+ else
+ {
+ CLog::Log(LOGINFO, "PAPlayer::ProcessStream - Stream Finished");
+ return false;
+ }
}
if (!QueueData(si))
View
1  xbmc/cores/paplayer/PAPlayer.h
@@ -142,6 +142,7 @@ friend class CQueueNextFileJob;
StreamList m_finishing; /* finishing streams */
int m_jobCounter;
CEvent m_jobEvent;
+ bool m_continueStream;
bool QueueNextFileEx(const CFileItem &file, bool fadeIn = true, bool job = false);
void SoftStart(bool wait = false);
Please sign in to comment.
Something went wrong with that request. Please try again.