Permalink
Browse files

Remove cuesheet table, store replaygain values in song table efficien…

…tly as string. Needed for playback of songs from both embedded and separate cuesheets, but will also store for ordinary music files.

Remove CueInfoLoader as now unused.

Skip attempt to load cuesheet item from library (fixes issue when playing cuesheet songs that are in library from fileview)
  • Loading branch information...
DaveTBlake committed Mar 29, 2017
1 parent a16588a commit 22bf1eaca518c4f8e4404506251128f057c518c6
@@ -194,9 +194,42 @@ void CCueDocument::GetSongs(VECSONGS &songs)
{
for (size_t i = 0; i < m_tracks.size(); ++i)
{
CSong song;
GetSong(i, song);
songs.push_back(song);
CSong aSong;
const CCueTrack& track = m_tracks[i];
//Pass artist to MusicInfoTag object by setting artist description string only.
//Artist credits not used during loading from cue sheet.
if (track.strArtist.empty() && !m_strArtist.empty())
aSong.strArtistDesc = m_strArtist;
else
aSong.strArtistDesc = track.strArtist;
//Pass album artist to MusicInfoTag object by setting album artist vector.
aSong.SetAlbumArtist(StringUtils::Split(m_strArtist, g_advancedSettings.m_musicItemSeparator));
aSong.strAlbum = m_strAlbum;
aSong.genre = StringUtils::Split(m_strGenre, g_advancedSettings.m_musicItemSeparator);
aSong.iYear = m_iYear;
aSong.iTrack = track.iTrackNumber;
if (m_iDiscNumber > 0)
aSong.iTrack |= (m_iDiscNumber << 16); // see CMusicInfoTag::GetDiscNumber()
if (track.strTitle.length() == 0) // No track information for this track!
aSong.strTitle = StringUtils::Format("Track {:2d}", track.iTrackNumber);
else
aSong.strTitle = track.strTitle;
aSong.strFileName = track.strFile;
aSong.iStartOffset = track.iStartTime;
aSong.iEndOffset = track.iEndTime;
if (aSong.iEndOffset)
// Convert offset in frames (75 per second) to duration in whole seconds with rounding
aSong.iDuration = (aSong.iEndOffset - aSong.iStartOffset + 37) / 75;
else
aSong.iDuration = 0;

if (m_albumReplayGain.Valid())
aSong.replayGain.Set(ReplayGain::ALBUM, m_albumReplayGain);

if (track.replayGain.Valid())
aSong.replayGain.Set(ReplayGain::TRACK, track.replayGain);

songs.push_back(aSong);
}
}

@@ -235,55 +268,6 @@ bool CCueDocument::IsOneFilePerTrack() const
return m_bOneFilePerTrack;
}

bool CCueDocument::GetSong(int aTrackIndex, CSong& aSong)
{
if (aTrackIndex < 0 || aTrackIndex >= static_cast<int>(m_tracks.size()))
return false;
const CCueTrack& track = m_tracks[aTrackIndex];
//Pass artist to MusicInfoTag object by setting artist description string only.
//Artist credits not used during loading from cue sheet.
if ((track.strArtist.length() == 0) && (m_strArtist.length() > 0))
aSong.strArtistDesc = m_strArtist;
else
aSong.strArtistDesc = track.strArtist;
//Pass album artist to MusicInfoTag object by setting album artist vector.
aSong.SetAlbumArtist(StringUtils::Split(m_strArtist, g_advancedSettings.m_musicItemSeparator));
aSong.strAlbum = m_strAlbum;
aSong.genre = StringUtils::Split(m_strGenre, g_advancedSettings.m_musicItemSeparator);
aSong.iYear = m_iYear;
aSong.iTrack = track.iTrackNumber;
if (m_iDiscNumber > 0)
aSong.iTrack |= (m_iDiscNumber << 16); // see CMusicInfoTag::GetDiscNumber()
if (track.strTitle.length() == 0) // No track information for this track!
aSong.strTitle = StringUtils::Format("Track %2d", track.iTrackNumber);
else
aSong.strTitle = track.strTitle;
aSong.strFileName = track.strFile;
aSong.iStartOffset = track.iStartTime;
aSong.iEndOffset = track.iEndTime;
if (aSong.iEndOffset)
aSong.iDuration = (aSong.iEndOffset - aSong.iStartOffset + 37) / 75;
else
aSong.iDuration = 0;

if (m_albumReplayGain.Valid())
aSong.replayGain.Set(ReplayGain::ALBUM, m_albumReplayGain);

if (track.replayGain.Valid())
aSong.replayGain.Set(ReplayGain::TRACK, track.replayGain);
return true;
}

bool CCueDocument::GetSongByTrack(int aTrackNumber, CSong & aSong)
{ //Find track with that tracknumber in the vector (position != track number)
for (size_t i = 0; i < m_tracks.size(); ++i)
{
if (m_tracks[i].iTrackNumber == aTrackNumber)
return GetSong(i, aSong);
}
return false;
}

// Private Functions start here

void CCueDocument::Clear()
@@ -55,8 +55,6 @@ class CCueDocument
bool ParseFile(const std::string &strFilePath);
bool ParseTag(const std::string &strContent);
void GetSongs(VECSONGS &songs);
bool GetSong(int aTrackNumber, CSong& aSong);
bool GetSongByTrack(int aTrackNumber, CSong& aSong);
std::string GetMediaPath();
std::string GetMediaTitle();
void GetMediaFiles(std::vector<std::string>& mediaFiles);
@@ -1736,6 +1736,8 @@ void CFileItem::LoadEmbeddedCue()
cuesheet->UpdateMediaFile(*itMedia, GetPath());
SetCueDocument(cuesheet);
}
// Clear cuesheet tag having added it to item
tag.SetCueSheet("");
}
}

@@ -348,7 +348,7 @@ JSONRPC_STATUS CAudioLibrary::GetSongs(const std::string &method, ITransportLaye
bool artistData = CheckForAdditionalProperties(parameterObject["properties"], checkProperties, additionalProperties);

CFileItemList items;
if (!musicdatabase.GetSongsFullByWhere(musicUrl.ToString(), CDatabase::Filter(), items, sorting, artistData, false))
if (!musicdatabase.GetSongsFullByWhere(musicUrl.ToString(), CDatabase::Filter(), items, sorting, artistData))
return InternalError;

JSONRPC_STATUS ret = GetAdditionalSongDetails(parameterObject, items, musicdatabase);
@@ -1,7 +1,6 @@
set(SOURCES Album.cpp
Artist.cpp
ContextMenus.cpp
CueInfoLoader.cpp
GUIViewStateMusic.cpp
MusicDatabase.cpp
MusicDbUrl.cpp
@@ -12,7 +11,6 @@ set(SOURCES Album.cpp
set(HEADERS Album.h
Artist.h
ContextMenus.h
CueInfoLoader.h
EmbeddedArt.h
GUIViewStateMusic.h
MusicDatabase.h

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 22bf1ea

Please sign in to comment.