summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2010-06-17 16:41:49 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2010-06-17 16:41:49 +0200
commit9c02bbf596ecabe00fb8280f953265560012ff36 (patch)
tree5df2d3fdb53f7204548e580a0c56267a13d9edb2 /src
parent10cea746e9da0027b6b9fef0a111fcdccb03cc03 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/media_library.cpp7
-rw-r--r--src/mpdpp.cpp9
-rw-r--r--src/mpdpp.h2
-rw-r--r--src/tag_editor.cpp2
4 files changed, 17 insertions, 3 deletions
diff --git a/src/media_library.cpp b/src/media_library.cpp
index 97d95b0b..d4cc92d3 100644
--- a/src/media_library.cpp
+++ b/src/media_library.cpp
@@ -201,6 +201,10 @@ void MediaLibrary::Update()
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();
MPD::TagList list;
locale_to_utf(Artists->Current());
@@ -239,6 +243,7 @@ void MediaLibrary::Update()
Albums->AddOption(SearchConstraints("", AllTracksMarker));
}
Albums->Refresh();
+ Mpd.BlockIdle(0);
}
else if (hasTwoColumns && Albums->Empty())
{
@@ -246,6 +251,7 @@ void MediaLibrary::Update()
MPD::TagList artists;
*Albums << XY(0, 0) << "Fetching albums...";
Albums->Window::Refresh();
+ Mpd.BlockIdle(1);
Mpd.GetList(artists, Config.media_lib_primary_tag);
for (MPD::TagList::iterator i = artists.begin(); i != artists.end(); ++i)
{
@@ -289,6 +295,7 @@ void MediaLibrary::Update()
}
}
}
+ Mpd.BlockIdle(0);
if (!Albums->Empty())
Albums->Sort<SearchConstraintsSorting>();
Albums->Refresh();
diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp
index 4e1b06c2..f215115e 100644
--- a/src/mpdpp.cpp
+++ b/src/mpdpp.cpp
@@ -142,18 +142,21 @@ void MPD::Connection::SetErrorHandler(ErrorHandler handler, void *data)
void MPD::Connection::GoIdle()
{
- if (supportsIdle && !isIdle && mpd_send_idle(itsConnection))
+ if (supportsIdle && !itsIdleBlocked && !isIdle && mpd_send_idle(itsConnection))
isIdle = 1;
}
int MPD::Connection::GoBusy()
{
+ int flags = 0;
if (isIdle && mpd_send_noidle(itsConnection))
{
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()
diff --git a/src/mpdpp.h b/src/mpdpp.h
index dec867e3..b9c0512d 100644
--- a/src/mpdpp.h
+++ b/src/mpdpp.h
@@ -95,6 +95,7 @@ namespace MPD
unsigned Version() const;
void SetIdleEnabled(bool val) { isIdleEnabled = val; }
+ void BlockIdle(bool val) { itsIdleBlocked = val; }
bool SupportsIdle() const { return supportsIdle; }
void OrderDataFetching() { hasData = 1; }
int GetFD() const { return itsFD; }
@@ -227,6 +228,7 @@ namespace MPD
int itsFD;
bool isIdle;
bool isIdleEnabled;
+ bool itsIdleBlocked;
bool supportsIdle;
bool hasData;
diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp
index 25ba9737..a2099c6d 100644
--- a/src/tag_editor.cpp
+++ b/src/tag_editor.cpp
@@ -232,6 +232,7 @@ void TagEditor::Update()
{
*Albums << XY(0, 0) << "Fetching albums...";
Albums->Window::Refresh();
+ Mpd.BlockIdle(1); // for the same reason as in media library
Mpd.GetList(list, MPD_TAG_ALBUM);
for (MPD::TagList::const_iterator it = list.begin(); it != list.end(); ++it)
{
@@ -246,6 +247,7 @@ void TagEditor::Update()
}
MPD::FreeSongList(l);
}
+ Mpd.BlockIdle(0);
Albums->Sort<CaseInsensitiveSorting>();
}
else