Browse files

restored: optional crossfade for consecutive albumtracks functionality.

  • Loading branch information...
1 parent 9bdf021 commit 261fc93597041490c9c4b0e7541ee9e9d0b1432e @chadoe chadoe committed May 19, 2012
Showing with 33 additions and 1 deletion.
  1. +30 −1 xbmc/cores/paplayer/PAPlayer.cpp
  2. +3 −0 xbmc/cores/paplayer/PAPlayer.h
View
31 xbmc/cores/paplayer/PAPlayer.cpp
@@ -51,7 +51,8 @@ PAPlayer::PAPlayer(IPlayerCallback& callback) :
m_isPaused (false),
m_isFinished (false),
m_currentStream (NULL ),
- m_audioCallback (NULL )
+ m_audioCallback (NULL ),
+ m_FileItem (new CFileItem() )
{
}
@@ -63,6 +64,7 @@ PAPlayer::~PAPlayer()
/* wait for the thread to terminate */
StopThread(true);//true - wait for end of thread
+ delete m_FileItem;
}
bool PAPlayer::HandlesType(const CStdString &type)
@@ -234,13 +236,38 @@ bool PAPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options)
return true;
}
+void PAPlayer::UpdateCrossFadingTime(const CFileItem& file)
+{
+ if ((m_crossFadeTime = g_guiSettings.GetInt("musicplayer.crossfade") * 1000))
+ {
+ if (
+ m_streams.size() == 0 ||
+ (
+ file.HasMusicInfoTag() && !g_guiSettings.GetBool("musicplayer.crossfadealbumtracks") &&
+ m_FileItem->HasMusicInfoTag() &&
+ (m_FileItem->GetMusicInfoTag()->GetAlbum() != "") &&
+ (m_FileItem->GetMusicInfoTag()->GetAlbum() == file.GetMusicInfoTag()->GetAlbum()) &&
+ (m_FileItem->GetMusicInfoTag()->GetDiscNumber() == file.GetMusicInfoTag()->GetDiscNumber()) &&
+ (m_FileItem->GetMusicInfoTag()->GetTrackNumber() == file.GetMusicInfoTag()->GetTrackNumber() - 1)
+ )
+ )
+ {
+ //do not crossfade when playing consecutive albumtracks
+ m_crossFadeTime = 0;
+ }
+ }
+}
+
bool PAPlayer::QueueNextFile(const CFileItem &file)
{
return QueueNextFileEx(file);
}
bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn/* = true */)
{
+ //set crossfade time for the file being queued
+ UpdateCrossFadingTime(file);
+
StreamInfo *si = new StreamInfo();
if (!si->m_decoder.Create(file, (file.m_lStartOffset * 1000) / 75))
@@ -307,6 +334,8 @@ bool PAPlayer::QueueNextFileEx(const CFileItem &file, bool fadeIn/* = true */)
CExclusiveLock lock(m_streamsLock);
m_streams.push_back(si);
+ *m_FileItem = file;
+
return true;
}
View
3 xbmc/cores/paplayer/PAPlayer.h
@@ -119,6 +119,8 @@ class PAPlayer : public IPlayer, public CThread
StreamInfo* m_currentStream; /* the current playing stream */
IAudioCallback* m_audioCallback; /* the viz audio callback */
+ CFileItem* m_FileItem; /* our queued file or current file if no file is queued */
+
CSharedSection m_streamsLock; /* lock for the stream list */
StreamList m_streams; /* playing streams */
StreamList m_finishing; /* finishing streams */
@@ -131,6 +133,7 @@ class PAPlayer : public IPlayer, public CThread
bool PrepareStream(StreamInfo *si);
bool ProcessStream(StreamInfo *si, double &delay, double &buffer);
bool QueueData(StreamInfo *si);
+ void UpdateCrossFadingTime(const CFileItem& file);
int64_t GetTotalTime64();
};

0 comments on commit 261fc93

Please sign in to comment.