Permalink
Browse files

Fix erroneous cuesheet handling, seekbar calc, eof calc and duplicate…

… messaging on select.
  • Loading branch information...
1 parent b1a21c3 commit dd02c0c6d7738d0f3c86417b3d99a9571e1aec10 @DDDamian DDDamian committed May 30, 2012
Showing with 15 additions and 26 deletions.
  1. +2 −16 xbmc/Application.cpp
  2. +1 −1 xbmc/CueDocument.cpp
  3. +12 −9 xbmc/cores/paplayer/PAPlayer.cpp
View
@@ -3945,15 +3945,8 @@ bool CApplication::PlayFile(const CFileItem& item, bool bRestart)
#endif
}
m_bPlaybackStarting = false;
- if(bResult)
- {
- // we must have started, otherwise player might send this later
- if(IsPlaying())
- OnPlayBackStarted();
- else
- OnPlayBackEnded();
- }
- else
+
+ if (!bResult)
{
// we send this if it isn't playlistplayer that is doing this
int next = g_playlistPlayer.GetNextSong();
@@ -5329,13 +5322,6 @@ float CApplication::GetPercentage() const
{
if (IsPlaying() && m_pPlayer)
{
- if (IsPlayingAudio() && m_itemCurrentFile->HasMusicInfoTag())
- {
- const CMusicInfoTag& tag = *m_itemCurrentFile->GetMusicInfoTag();
- if (tag.GetDuration() > 0)
- return (float)(GetTime() / tag.GetDuration() * 100);
- }
-
if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0)
return (float)(GetTime() / GetTotalTime() * 100);
else
View
@@ -103,7 +103,7 @@ bool CCueDocument::Parse(const CStdString &strFile)
{
if (!ReadNextLine(strLine))
break;
- if (strLine.Left(7) == "INDEX 0")
+ if (strLine.Left(8) == "INDEX 01")
{
if (bCurrentFileChanged)
{
@@ -556,26 +556,27 @@ inline bool PAPlayer::ProcessStream(StreamInfo *si, double &delay, double &buffe
/* see if it is time yet to FF/RW or a direct seek */
if (!si->m_playNextTriggered && ((m_playbackSpeed != 1 && si->m_framesSent >= si->m_seekNextAtFrame) || si->m_seekFrame > -1))
{
+ int64_t time = (int64_t)0;
/* if its a direct seek */
if (si->m_seekFrame > -1)
{
- si->m_framesSent = si->m_seekFrame;
+ time = (int64_t)((float)si->m_seekFrame / (float)si->m_sampleRate * 1000.0f);
+ si->m_framesSent = (int)(si->m_seekFrame - ((float)si->m_startOffset * (float)si->m_sampleRate) / 1000.0f);
si->m_seekFrame = -1;
}
/* if its FF/RW */
else
{
si->m_framesSent += si->m_sampleRate * (m_playbackSpeed - 1);
si->m_seekNextAtFrame = si->m_framesSent + si->m_sampleRate / 2;
+ time = (int64_t)(((float)si->m_framesSent / (float)si->m_sampleRate * 1000.0f) + (float)si->m_startOffset);
}
- int64_t time = (int64_t)(si->m_startOffset + ((float)si->m_framesSent / (float)si->m_sampleRate * 1000.0f));
-
/* if we are seeking back before the start of the track start normal playback */
if (time < si->m_startOffset || si->m_framesSent < 0)
{
time = si->m_startOffset;
- si->m_framesSent = 0;
+ si->m_framesSent = (int)(si->m_startOffset * si->m_sampleRate / 1000);
si->m_seekNextAtFrame = 0;
ToFFRW(1);
}
@@ -586,7 +587,8 @@ inline bool PAPlayer::ProcessStream(StreamInfo *si, double &delay, double &buffe
int status = si->m_decoder.GetStatus();
if (status == STATUS_ENDED ||
status == STATUS_NO_FILE ||
- si->m_decoder.ReadSamples(PACKET_SIZE) == RET_ERROR)
+ 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;
@@ -702,7 +704,8 @@ int64_t PAPlayer::GetTime()
if (!m_currentStream)
return 0;
- double time = (double)m_currentStream->m_framesSent / (double)m_currentStream->m_sampleRate;
+ double time = ((double)m_currentStream->m_framesSent / (double)m_currentStream->m_sampleRate)
+ /*- ((double)m_currentStream->m_startOffset / 1000.0)*/;
if (m_currentStream->m_stream)
time -= m_currentStream->m_stream->GetDelay();
@@ -812,13 +815,13 @@ void PAPlayer::SeekTime(int64_t iTime /*=0*/)
return;
int seekOffset = (int)(iTime - GetTime());
- if (m_currentStream->m_startOffset)
- iTime += m_currentStream->m_startOffset;
+ /*if (m_currentStream->m_startOffset)
+ iTime += m_currentStream->m_startOffset;*/
if (m_playbackSpeed != 1)
ToFFRW(1);
- m_currentStream->m_seekFrame = (int)(m_currentStream->m_sampleRate * (iTime / 1000));
+ m_currentStream->m_seekFrame = (int)((float)m_currentStream->m_sampleRate * ((float)iTime + (float)m_currentStream->m_startOffset) / 1000.0f);
m_callback.OnPlayBackSeek((int)iTime, seekOffset);
}

0 comments on commit dd02c0c

Please sign in to comment.