Add some debug info to MPDParseUtils
This commit is contained in:
19
README
19
README
@@ -458,22 +458,23 @@ Cantata. Therefore, its porobably better to start Cantata from the commandline.
|
||||
The following debug values may be used:
|
||||
|
||||
MPD communications 1
|
||||
Covers 2
|
||||
Wikipedia context info 4
|
||||
Last.fm context info 8
|
||||
Combined context info 16
|
||||
Context widget 32
|
||||
Context backdrop 64
|
||||
Dynamic 128
|
||||
MPD Parsing 2
|
||||
Covers 4
|
||||
Wikipedia context info 8
|
||||
Last.fm context info 16
|
||||
Combined context info 32
|
||||
Context widget 64
|
||||
Context backdrop 128
|
||||
Dynamic 256
|
||||
|
||||
These values may be combined to enable multipe output. e.g. to enable MPD and
|
||||
covers logging:
|
||||
|
||||
CANTATA_DEBUG=3 cantata
|
||||
CANTATA_DEBUG=5 cantata
|
||||
|
||||
for just covers logging:
|
||||
|
||||
CANTATA_DEBUG=2 cantata
|
||||
CANTATA_DEBUG=4 cantata
|
||||
|
||||
|
||||
Credits
|
||||
|
||||
19
gui/main.cpp
19
gui/main.cpp
@@ -42,6 +42,7 @@
|
||||
|
||||
// To enable debug...
|
||||
#include "mpdconnection.h"
|
||||
#include "mpdparseutils.h"
|
||||
#include "covers.h"
|
||||
#include "wikipediaengine.h"
|
||||
#include "lastfmengine.h"
|
||||
@@ -96,13 +97,14 @@ static void loadTranslation(const QString &prefix, const QString &path, const QS
|
||||
|
||||
enum Debug {
|
||||
Dbg_Mpd = 0x0001,
|
||||
Dbg_Covers = 0x0002,
|
||||
Dbg_Context_Wikipedia = 0x0004,
|
||||
Dbg_Context_LastFm = 0x0008,
|
||||
Dbg_Context_Meta = 0x0010,
|
||||
Dbg_Context_Widget = 0x0020,
|
||||
Dbg_Context_Backdrop = 0x0040,
|
||||
Dbg_Dynamic = 0x0080
|
||||
Dbg_MpdParse = 0x0002,
|
||||
Dbg_Covers = 0x0004,
|
||||
Dbg_Context_Wikipedia = 0x0008,
|
||||
Dbg_Context_LastFm = 0x0010,
|
||||
Dbg_Context_Meta = 0x0020,
|
||||
Dbg_Context_Widget = 0x0040,
|
||||
Dbg_Context_Backdrop = 0x0080,
|
||||
Dbg_Dynamic = 0x0100
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -113,6 +115,9 @@ int main(int argc, char *argv[])
|
||||
if (dbg&Dbg_Mpd) {
|
||||
MPDConnection::enableDebug();
|
||||
}
|
||||
if (dbg&Dbg_MpdParse) {
|
||||
MPDParseUtils::enableDebug();
|
||||
}
|
||||
if (dbg&Dbg_Covers) {
|
||||
Covers::enableDebug();
|
||||
}
|
||||
|
||||
@@ -51,6 +51,14 @@
|
||||
#include "cuefile.h"
|
||||
#include "mpdconnection.h"
|
||||
|
||||
#include <QDebug>
|
||||
static bool debugEnabled=false;
|
||||
#define DBUG if (debugEnabled) qWarning() << "MPDParseUtils"
|
||||
void MPDParseUtils::enableDebug()
|
||||
{
|
||||
debugEnabled=true;
|
||||
}
|
||||
|
||||
QList<Playlist> MPDParseUtils::parsePlaylists(const QByteArray &data)
|
||||
{
|
||||
QList<Playlist> playlists;
|
||||
@@ -398,8 +406,10 @@ MusicLibraryItemRoot * MPDParseUtils::parseLibraryItems(const QByteArray &data,
|
||||
QString prevSongFile=songItem ? songItem->file() : QString();
|
||||
ParsedCueFile cf;
|
||||
|
||||
DBUG << "Got playlist item" << currentSong.file << "prevFile:" << prevSongFile;
|
||||
if (canSplitCue && currentSong.file.endsWith(".cue", Qt::CaseInsensitive) && CueFile::parse(currentSong.file, mpdDir, cf.songs, cf.files) &&
|
||||
cf.files.count()<cf.songs.count()) {
|
||||
DBUG << "Parsed file, songs:" << cf.songs.count() << "files:" << cf.files.count();
|
||||
bool canUseCueFileTracks=false;
|
||||
ParsedCueFile fixed;
|
||||
|
||||
@@ -441,8 +451,8 @@ MusicLibraryItemRoot * MPDParseUtils::parseLibraryItems(const QByteArray &data,
|
||||
fixed.songs.append(s);
|
||||
}
|
||||
canUseCueFileTracks=true;
|
||||
}
|
||||
}
|
||||
} else DBUG << "ERROR: file count mismatch" << origFiles.size() << cf.files.size();
|
||||
} else DBUG << "ERROR: No album???";
|
||||
|
||||
if (!canUseCueFileTracks) {
|
||||
// No revious album, or album had a different number of source files to the CUE file. If so, then we need to ensure
|
||||
@@ -459,7 +469,7 @@ MusicLibraryItemRoot * MPDParseUtils::parseLibraryItems(const QByteArray &data,
|
||||
|
||||
if (fixed.songs.count()==cf.songs.count()) {
|
||||
canUseCueFileTracks=true;
|
||||
}
|
||||
} else DBUG << "ERROR: Not all cue tracks had meta data";
|
||||
}
|
||||
|
||||
if (canUseCueFileTracks) {
|
||||
@@ -472,6 +482,7 @@ MusicLibraryItemRoot * MPDParseUtils::parseLibraryItems(const QByteArray &data,
|
||||
if (!albumItem || s.year!=albumItem->year() || albumItem->parentItem()!=artistItem || s.album!=albumItem->data()) {
|
||||
albumItem = artistItem->album(s);
|
||||
}
|
||||
DBUG << "Create new track from cue" << s.file << s.title << s.albumArtist() << s.album;
|
||||
songItem = new MusicLibraryItemSong(s, albumItem);
|
||||
albumItem->append(songItem);
|
||||
albumItem->addGenre(s.genre);
|
||||
@@ -484,13 +495,15 @@ MusicLibraryItemRoot * MPDParseUtils::parseLibraryItems(const QByteArray &data,
|
||||
foreach (MusicLibraryItemAlbum *al, updatedAlbums) {
|
||||
al->removeAll(cf.files);
|
||||
if (prevAlbum && al!=prevAlbum) {
|
||||
DBUG << "Removing" << cf.files.count() << " files from " << prevAlbum->data();
|
||||
prevAlbum->removeAll(cf.files);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove alun artist/album that was create and is now empty.
|
||||
// Remove any artist/album that was created and is now empty.
|
||||
// This will happen if the source file (e.g. the flac file) does not have any metadata...
|
||||
if (prevAlbum && 0==prevAlbum->childCount()) {
|
||||
DBUG << "Removing empty previous album" << prevAlbum->data();
|
||||
MusicLibraryItemArtist *ar=static_cast<MusicLibraryItemArtist *>(prevAlbum->parentItem());
|
||||
ar->remove(prevAlbum);
|
||||
if (0==ar->childCount()) {
|
||||
@@ -505,6 +518,7 @@ MusicLibraryItemRoot * MPDParseUtils::parseLibraryItems(const QByteArray &data,
|
||||
if (!prevSongFile.isEmpty() && Utils::getDir(prevSongFile)==Utils::getDir(currentSong.file)) {
|
||||
currentSong.albumartist=currentSong.artist=artistItem->data();
|
||||
currentSong.album=albumItem->data();
|
||||
DBUG << "Adding playlist file to" << albumItem->parentItem()->data() << albumItem->data();
|
||||
songItem = new MusicLibraryItemSong(currentSong, albumItem);
|
||||
albumItem->append(songItem);
|
||||
}
|
||||
|
||||
@@ -37,9 +37,10 @@ class Output;
|
||||
class MPDStatsValues;
|
||||
class MPDStatusValues;
|
||||
|
||||
class MPDParseUtils
|
||||
namespace MPDParseUtils
|
||||
{
|
||||
public:
|
||||
extern void enableDebug();
|
||||
|
||||
struct IdPos {
|
||||
IdPos(qint32 i, quint32 p)
|
||||
: id(i)
|
||||
@@ -48,24 +49,24 @@ public:
|
||||
qint32 id;
|
||||
quint32 pos;
|
||||
};
|
||||
static QList<Playlist> parsePlaylists(const QByteArray &data);
|
||||
static MPDStatsValues parseStats(const QByteArray &data);
|
||||
static MPDStatusValues parseStatus(const QByteArray &data);
|
||||
static Song parseSong(const QByteArray &data, bool isPlayQueue);
|
||||
static QList<Song> parseSongs(const QByteArray &data);
|
||||
static QList<IdPos> parseChanges(const QByteArray &data);
|
||||
static QStringList parseUrlHandlers(const QByteArray &data);
|
||||
static bool groupSingle();
|
||||
static void setGroupSingle(bool g);
|
||||
static bool groupMultiple();
|
||||
static void setGroupMultiple(bool g);
|
||||
static MusicLibraryItemRoot * parseLibraryItems(const QByteArray &data, const QString &mpdDir, long mpdVersion);
|
||||
static DirViewItemRoot * parseDirViewItems(const QByteArray &data);
|
||||
static QList<Output> parseOuputs(const QByteArray &data);
|
||||
static QString formatDuration(const quint32 totalseconds);
|
||||
static QString addStreamName(const QString &url, const QString &name);
|
||||
static QString getStreamName(const QString &url);
|
||||
static QString getAndRemoveStreamName(QString &url);
|
||||
extern QList<Playlist> parsePlaylists(const QByteArray &data);
|
||||
extern MPDStatsValues parseStats(const QByteArray &data);
|
||||
extern MPDStatusValues parseStatus(const QByteArray &data);
|
||||
extern Song parseSong(const QByteArray &data, bool isPlayQueue);
|
||||
extern QList<Song> parseSongs(const QByteArray &data);
|
||||
extern QList<IdPos> parseChanges(const QByteArray &data);
|
||||
extern QStringList parseUrlHandlers(const QByteArray &data);
|
||||
extern bool groupSingle();
|
||||
extern void setGroupSingle(bool g);
|
||||
extern bool groupMultiple();
|
||||
extern void setGroupMultiple(bool g);
|
||||
extern MusicLibraryItemRoot * parseLibraryItems(const QByteArray &data, const QString &mpdDir, long mpdVersion);
|
||||
extern DirViewItemRoot * parseDirViewItems(const QByteArray &data);
|
||||
extern QList<Output> parseOuputs(const QByteArray &data);
|
||||
extern QString formatDuration(const quint32 totalseconds);
|
||||
extern QString addStreamName(const QString &url, const QString &name);
|
||||
extern QString getStreamName(const QString &url);
|
||||
extern QString getAndRemoveStreamName(QString &url);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user