song info: do not use TagLib if mpd_music_dir is unset
Trying to do use TagLib with mpd_music_dir unset resulted in a segfault in TagLib when trying to open the file - its path was just the filename.
This commit is contained in:
committed by
Andrzej Rybczak
parent
759322d00c
commit
1e1aba121d
@@ -93,25 +93,25 @@ void SongInfo::switchTo()
|
||||
|
||||
void SongInfo::PrepareSong(MPD::Song &s)
|
||||
{
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
std::string path_to_file;
|
||||
if (s.isFromDatabase())
|
||||
path_to_file += Config.mpd_music_dir;
|
||||
path_to_file += s.getURI();
|
||||
TagLib::FileRef f(path_to_file.c_str());
|
||||
# endif // HAVE_TAGLIB_H
|
||||
|
||||
w << NC::Format::Bold << Config.color1 << "Filename: " << NC::Format::NoBold << Config.color2 << s.getName() << '\n' << NC::Color::End;
|
||||
w << NC::Format::Bold << "Directory: " << NC::Format::NoBold << Config.color2;
|
||||
ShowTag(w, s.getDirectory());
|
||||
w << "\n\n" << NC::Color::End;
|
||||
w << NC::Format::Bold << "Length: " << NC::Format::NoBold << Config.color2 << s.getLength() << '\n' << NC::Color::End;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (!f.isNull())
|
||||
if (!Config.mpd_music_dir.empty())
|
||||
{
|
||||
w << NC::Format::Bold << "Bitrate: " << NC::Format::NoBold << Config.color2 << f.audioProperties()->bitrate() << " kbps\n" << NC::Color::End;
|
||||
w << NC::Format::Bold << "Sample rate: " << NC::Format::NoBold << Config.color2 << f.audioProperties()->sampleRate() << " Hz\n" << NC::Color::End;
|
||||
w << NC::Format::Bold << "Channels: " << NC::Format::NoBold << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << '\n' << NC::Color::Default;
|
||||
std::string path_to_file;
|
||||
if (s.isFromDatabase())
|
||||
path_to_file += Config.mpd_music_dir;
|
||||
path_to_file += s.getURI();
|
||||
TagLib::FileRef f(path_to_file.c_str());
|
||||
if (!f.isNull())
|
||||
{
|
||||
w << NC::Format::Bold << "Bitrate: " << NC::Format::NoBold << Config.color2 << f.audioProperties()->bitrate() << " kbps\n" << NC::Color::End;
|
||||
w << NC::Format::Bold << "Sample rate: " << NC::Format::NoBold << Config.color2 << f.audioProperties()->sampleRate() << " Hz\n" << NC::Color::End;
|
||||
w << NC::Format::Bold << "Channels: " << NC::Format::NoBold << Config.color2 << (f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") << '\n' << NC::Color::Default;
|
||||
}
|
||||
}
|
||||
# endif // HAVE_TAGLIB_H
|
||||
w << NC::Color::Default;
|
||||
|
||||
Reference in New Issue
Block a user