media library: fix infinite loop if listallinfo fails
This commit is contained in:
@@ -40,6 +40,27 @@ const MPD::Song *currentSong(const BaseScreen *screen)
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MPD::SongIterator getDatabaseIterator(MPD::Connection &mpd)
|
||||||
|
{
|
||||||
|
MPD::SongIterator result;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = mpd.GetDirectoryRecursive("/");
|
||||||
|
}
|
||||||
|
catch (MPD::ClientError &e)
|
||||||
|
{
|
||||||
|
if (e.code() == MPD_ERROR_CLOSED)
|
||||||
|
{
|
||||||
|
// If we can't get the database, display appropriate
|
||||||
|
// error message and reconnect with the MPD server.
|
||||||
|
Statusbar::print("Unable to fetch the data, increase max_buffer_output_size in your MPD configuration file");
|
||||||
|
mpd.Disconnect();
|
||||||
|
mpd.Connect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
typedef std::vector<MPD::Song>::const_iterator VectorSongIterator;
|
typedef std::vector<MPD::Song>::const_iterator VectorSongIterator;
|
||||||
bool addSongsToPlaylist(VectorSongIterator first, VectorSongIterator last, bool play, int position)
|
bool addSongsToPlaylist(VectorSongIterator first, VectorSongIterator last, bool play, int position)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -394,6 +394,8 @@ bool addSongToPlaylist(const MPD::Song &s, bool play, int position = -1);
|
|||||||
|
|
||||||
const MPD::Song *currentSong(const BaseScreen *screen);
|
const MPD::Song *currentSong(const BaseScreen *screen);
|
||||||
|
|
||||||
|
MPD::SongIterator getDatabaseIterator(MPD::Connection &mpd);
|
||||||
|
|
||||||
std::string timeFormat(const char *format, time_t t);
|
std::string timeFormat(const char *format, time_t t);
|
||||||
|
|
||||||
std::string Timestamp(time_t t);
|
std::string Timestamp(time_t t);
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ void MediaLibrary::update()
|
|||||||
{
|
{
|
||||||
m_albums_update_request = false;
|
m_albums_update_request = false;
|
||||||
std::map<std::tuple<std::string, std::string, std::string>, time_t> albums;
|
std::map<std::tuple<std::string, std::string, std::string>, time_t> albums;
|
||||||
for (MPD::SongIterator s = Mpd.GetDirectoryRecursive("/"), end; s != end; ++s)
|
for (MPD::SongIterator s = getDatabaseIterator(Mpd), end; s != end; ++s)
|
||||||
{
|
{
|
||||||
std::string tag;
|
std::string tag;
|
||||||
unsigned idx = 0;
|
unsigned idx = 0;
|
||||||
@@ -326,7 +326,7 @@ void MediaLibrary::update()
|
|||||||
std::map<std::string, time_t> tags;
|
std::map<std::string, time_t> tags;
|
||||||
if (Config.media_library_sort_by_mtime)
|
if (Config.media_library_sort_by_mtime)
|
||||||
{
|
{
|
||||||
for (MPD::SongIterator s = Mpd.GetDirectoryRecursive("/"), end; s != end; ++s)
|
for (MPD::SongIterator s = getDatabaseIterator(Mpd), end; s != end; ++s)
|
||||||
{
|
{
|
||||||
std::string tag;
|
std::string tag;
|
||||||
unsigned idx = 0;
|
unsigned idx = 0;
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ void SearchEngine::Search()
|
|||||||
input_song_iterator s, end;
|
input_song_iterator s, end;
|
||||||
if (Config.search_in_db)
|
if (Config.search_in_db)
|
||||||
{
|
{
|
||||||
s = input_song_iterator(Mpd.GetDirectoryRecursive("/"));
|
s = input_song_iterator(getDatabaseIterator(Mpd));
|
||||||
end = input_song_iterator(MPD::SongIterator());
|
end = input_song_iterator(MPD::SongIterator());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user