media library/tag editor: block idle while doing hierarchical searches
idle should be blocked in such cases since it would be enabled and disabled a few times by each mpd command, which makes no sense and slows down the whole process.
This commit is contained in:
@@ -201,6 +201,10 @@ void MediaLibrary::Update()
|
|||||||
|
|
||||||
if (!hasTwoColumns && !Artists->Empty() && Albums->Empty() && Songs->Empty())
|
if (!hasTwoColumns && !Artists->Empty() && Albums->Empty() && Songs->Empty())
|
||||||
{
|
{
|
||||||
|
// idle has to be blocked for now since it would be enabled and
|
||||||
|
// disabled a few times by each mpd command, which makes no sense
|
||||||
|
// and slows down the whole process.
|
||||||
|
Mpd.BlockIdle(1);
|
||||||
Albums->Reset();
|
Albums->Reset();
|
||||||
MPD::TagList list;
|
MPD::TagList list;
|
||||||
locale_to_utf(Artists->Current());
|
locale_to_utf(Artists->Current());
|
||||||
@@ -239,6 +243,7 @@ void MediaLibrary::Update()
|
|||||||
Albums->AddOption(SearchConstraints("", AllTracksMarker));
|
Albums->AddOption(SearchConstraints("", AllTracksMarker));
|
||||||
}
|
}
|
||||||
Albums->Refresh();
|
Albums->Refresh();
|
||||||
|
Mpd.BlockIdle(0);
|
||||||
}
|
}
|
||||||
else if (hasTwoColumns && Albums->Empty())
|
else if (hasTwoColumns && Albums->Empty())
|
||||||
{
|
{
|
||||||
@@ -246,6 +251,7 @@ void MediaLibrary::Update()
|
|||||||
MPD::TagList artists;
|
MPD::TagList artists;
|
||||||
*Albums << XY(0, 0) << "Fetching albums...";
|
*Albums << XY(0, 0) << "Fetching albums...";
|
||||||
Albums->Window::Refresh();
|
Albums->Window::Refresh();
|
||||||
|
Mpd.BlockIdle(1);
|
||||||
Mpd.GetList(artists, Config.media_lib_primary_tag);
|
Mpd.GetList(artists, Config.media_lib_primary_tag);
|
||||||
for (MPD::TagList::iterator i = artists.begin(); i != artists.end(); ++i)
|
for (MPD::TagList::iterator i = artists.begin(); i != artists.end(); ++i)
|
||||||
{
|
{
|
||||||
@@ -289,6 +295,7 @@ void MediaLibrary::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Mpd.BlockIdle(0);
|
||||||
if (!Albums->Empty())
|
if (!Albums->Empty())
|
||||||
Albums->Sort<SearchConstraintsSorting>();
|
Albums->Sort<SearchConstraintsSorting>();
|
||||||
Albums->Refresh();
|
Albums->Refresh();
|
||||||
|
|||||||
@@ -142,18 +142,21 @@ void MPD::Connection::SetErrorHandler(ErrorHandler handler, void *data)
|
|||||||
|
|
||||||
void MPD::Connection::GoIdle()
|
void MPD::Connection::GoIdle()
|
||||||
{
|
{
|
||||||
if (supportsIdle && !isIdle && mpd_send_idle(itsConnection))
|
if (supportsIdle && !itsIdleBlocked && !isIdle && mpd_send_idle(itsConnection))
|
||||||
isIdle = 1;
|
isIdle = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MPD::Connection::GoBusy()
|
int MPD::Connection::GoBusy()
|
||||||
{
|
{
|
||||||
|
int flags = 0;
|
||||||
if (isIdle && mpd_send_noidle(itsConnection))
|
if (isIdle && mpd_send_noidle(itsConnection))
|
||||||
{
|
{
|
||||||
isIdle = 0;
|
isIdle = 0;
|
||||||
return mpd_recv_idle(itsConnection, 1);
|
if (hasData)
|
||||||
|
flags = mpd_recv_idle(itsConnection, 1);
|
||||||
|
mpd_response_finish(itsConnection);
|
||||||
}
|
}
|
||||||
return 0;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MPD::Connection::UpdateStatus()
|
void MPD::Connection::UpdateStatus()
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ namespace MPD
|
|||||||
unsigned Version() const;
|
unsigned Version() const;
|
||||||
|
|
||||||
void SetIdleEnabled(bool val) { isIdleEnabled = val; }
|
void SetIdleEnabled(bool val) { isIdleEnabled = val; }
|
||||||
|
void BlockIdle(bool val) { itsIdleBlocked = val; }
|
||||||
bool SupportsIdle() const { return supportsIdle; }
|
bool SupportsIdle() const { return supportsIdle; }
|
||||||
void OrderDataFetching() { hasData = 1; }
|
void OrderDataFetching() { hasData = 1; }
|
||||||
int GetFD() const { return itsFD; }
|
int GetFD() const { return itsFD; }
|
||||||
@@ -227,6 +228,7 @@ namespace MPD
|
|||||||
int itsFD;
|
int itsFD;
|
||||||
bool isIdle;
|
bool isIdle;
|
||||||
bool isIdleEnabled;
|
bool isIdleEnabled;
|
||||||
|
bool itsIdleBlocked;
|
||||||
bool supportsIdle;
|
bool supportsIdle;
|
||||||
bool hasData;
|
bool hasData;
|
||||||
|
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ void TagEditor::Update()
|
|||||||
{
|
{
|
||||||
*Albums << XY(0, 0) << "Fetching albums...";
|
*Albums << XY(0, 0) << "Fetching albums...";
|
||||||
Albums->Window::Refresh();
|
Albums->Window::Refresh();
|
||||||
|
Mpd.BlockIdle(1); // for the same reason as in media library
|
||||||
Mpd.GetList(list, MPD_TAG_ALBUM);
|
Mpd.GetList(list, MPD_TAG_ALBUM);
|
||||||
for (MPD::TagList::const_iterator it = list.begin(); it != list.end(); ++it)
|
for (MPD::TagList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||||
{
|
{
|
||||||
@@ -246,6 +247,7 @@ void TagEditor::Update()
|
|||||||
}
|
}
|
||||||
MPD::FreeSongList(l);
|
MPD::FreeSongList(l);
|
||||||
}
|
}
|
||||||
|
Mpd.BlockIdle(0);
|
||||||
Albums->Sort<CaseInsensitiveSorting>();
|
Albums->Sort<CaseInsensitiveSorting>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user