aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-09-06 21:48:27 +0200
committerPřemysl Eric Janouch <p@janouch.name>2021-09-06 21:48:27 +0200
commitfba1210e9fc3fd0259e18b16cc63a0af8974126d (patch)
tree851ed74e27ddcd82db2cccf9e254597602bdf1bb
parent30777e8fd305f322b4ddd197ebeab894a63b3a8a (diff)
downloadnncmpp-fba1210e9fc3fd0259e18b16cc63a0af8974126d.tar.gz
nncmpp-fba1210e9fc3fd0259e18b16cc63a0af8974126d.tar.xz
nncmpp-fba1210e9fc3fd0259e18b16cc63a0af8974126d.zip
Clean up connection initialisation
Also, do not set up the spectrum visualiser before a password is sent. It would look a bit weird to have it run but display "Disconnected", even though technically, it would probably work.
-rw-r--r--nncmpp.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/nncmpp.c b/nncmpp.c
index 7b141c0..e0c0409 100644
--- a/nncmpp.c
+++ b/nncmpp.c
@@ -4187,6 +4187,14 @@ mpd_queue_reconnect (void)
}
static void
+mpd_on_ready (struct mpd_client *c)
+{
+ mpd_request_info ();
+ library_tab_reload (NULL);
+ spectrum_setup_fifo ();
+}
+
+static void
mpd_on_password_response (const struct mpd_response *response,
const struct strv *data, void *user_data)
{
@@ -4195,10 +4203,7 @@ mpd_on_password_response (const struct mpd_response *response,
struct mpd_client *c = &g.client;
if (response->success)
- {
- mpd_request_info ();
- library_tab_reload (NULL);
- }
+ mpd_on_ready (c);
else
{
print_error ("%s: %s",
@@ -4221,12 +4226,7 @@ mpd_on_connected (void *user_data)
mpd_client_add_task (c, mpd_on_password_response, NULL);
}
else
- {
- mpd_request_info ();
- library_tab_reload (NULL);
- }
-
- spectrum_setup_fifo ();
+ mpd_on_ready (c);
}
static void