Permalink
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
@@ -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;
}
@@ -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 */
@elupus
elupus May 19, 2012 Member

use a shared_ptr ie CFileItemPtr.

@chadoe
chadoe May 19, 2012 Member

eh why? It's not shared, the fileitem is created and destroyed in PAPlayer and values assigned through CFileItem's assignment operator, it's the only pointer that ever points to this object. The only reasons I made it a pointer instead of a regular member is to not pull in FileItem.h in PAPlayer.h

@elupus
elupus via email May 19, 2012 Member
+
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();
};

1 comment on commit 261fc93

@DDDamian
Contributor

Nice - you beat me to it ;)

Please sign in to comment.