Permalink
Browse files

Fixed PAPlayer support for streams with multiply tracks. (CUE-sheeets)

  • Loading branch information...
1 parent 6214263 commit 5101668e8655a90550104ec8fce625d68d4a3717 psyton committed May 19, 2012
Showing with 21 additions and 8 deletions.
  1. +21 −8 xbmc/cores/paplayer/PAPlayer.cpp
@@ -316,16 +316,24 @@ bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn/* = true */)
si->m_fadeOutTriggered = false;
si->m_isSlaved = false;
- if (si->m_decoder.TotalTime() < TIME_TO_CACHE_NEXT_FILE + m_crossFadeTime)
- si->m_prepareNextAtFrame = 0;
- else
- si->m_prepareNextAtFrame = (int)((si->m_decoder.TotalTime() - TIME_TO_CACHE_NEXT_FILE - m_crossFadeTime) * si->m_sampleRate / 1000.0f);
+ int64_t streamTotalTime = si->m_decoder.TotalTime();
+ if (si->m_endOffset)
+ streamTotalTime = si->m_endOffset;
+
+ unsigned int firstFrame = 0;
+ firstFrame = (int)(si->m_startOffset * si->m_sampleRate / 1000.0f);
+
+ if (streamTotalTime >= TIME_TO_CACHE_NEXT_FILE + m_crossFadeTime)
+ si->m_prepareNextAtFrame = (int)((streamTotalTime - TIME_TO_CACHE_NEXT_FILE - m_crossFadeTime) * si->m_sampleRate / 1000.0f);
+ si->m_prepareNextAtFrame -= firstFrame;
+
si->m_prepareTriggered = false;
- if (si->m_decoder.TotalTime() < m_crossFadeTime)
- si->m_playNextAtFrame = (int)((si->m_decoder.TotalTime() / 2) * si->m_sampleRate / 1000.0f);
+ if (streamTotalTime < m_crossFadeTime)
+ si->m_playNextAtFrame = (int)((streamTotalTime / 2) * si->m_sampleRate / 1000.0f);
else
- si->m_playNextAtFrame = (int)((si->m_decoder.TotalTime() - m_crossFadeTime) * si->m_sampleRate / 1000.0f);
+ si->m_playNextAtFrame = (int)((streamTotalTime - m_crossFadeTime) * si->m_sampleRate / 1000.0f);
+ si->m_playNextAtFrame -= firstFrame;
si->m_playNextTriggered = false;
PrepareStream(si);
@@ -463,7 +471,7 @@ inline void PAPlayer::ProcessStreams(double &delay, double &buffer)
if (!m_currentStream && !si->m_started)
m_currentStream = si;
/* if the stream is finishing */
- if ((si->m_fadeOutTriggered && si->m_stream && !si->m_stream->IsFading()) || !ProcessStream(si, delay, buffer))
+ if ((si->m_playNextTriggered && si->m_stream && !si->m_stream->IsFading()) || !ProcessStream(si, delay, buffer))
{
if (!si->m_prepareTriggered)
{
@@ -523,7 +531,10 @@ inline void PAPlayer::ProcessStreams(double &delay, double &buffer)
if (!m_isFinished)
{
if (m_crossFadeTime)
+ {
si->m_stream->FadeVolume(1.0f, 0.0f, m_crossFadeTime);
+ si->m_fadeOutTriggered = true;
+ }
m_currentStream = NULL;
/* unregister the audio callback */
@@ -625,6 +636,8 @@ bool PAPlayer::QueueData(StreamInfo *si)
unsigned int added = si->m_stream->AddData(data, samples * si->m_bytesPerSample);
si->m_framesSent += added / si->m_bytesPerFrame;
+ CLog::Log(LOGDEBUG, "PAPlayer::QueueData - m_frame_set %d - %d", si->m_framesSent, si->m_prepareNextAtFrame);
+
return true;
}

0 comments on commit 5101668

Please sign in to comment.