diff --git a/src/screen_outputs.c b/src/screen_outputs.c
index 4e55df9fe131fa8927ba89e6114a9f7fe6488404..a91f634b1d499641ec021c82e2fe24f9f7878dfd 100644 (file)
--- a/src/screen_outputs.c
+++ b/src/screen_outputs.c
#include "i18n.h"
#include "screen.h"
#include "list_window.h"
+#include "mpdclient.h"
+
+#include <mpd/client.h>
#include <glib.h>
+#include <assert.h>
static list_window_t *lw = NULL;
}
static int
-toggle_output(mpdclient_t *c, unsigned int output_index)
+toggle_output(struct mpdclient *c, unsigned int output_index)
{
- int return_value;
- mpd_OutputEntity *output;
+ struct mpd_output *output;
assert(mpd_outputs != NULL);
output = g_ptr_array_index(mpd_outputs, output_index);
- if (output->enabled == 0) {
- mpd_sendEnableOutputCommand(c->connection, output->id);
+ if (!mpd_output_get_enabled(output)) {
+ if (!mpd_run_enable_output(c->connection,
+ mpd_output_get_id(output))) {
+ mpdclient_handle_error(c);
+ return -1;
+ }
- output->enabled = 1;
+ /* XXX reload */
- screen_status_printf(_("Output '%s' enabled"), output->name);
+ screen_status_printf(_("Output '%s' enabled"),
+ mpd_output_get_name(output));
} else {
- mpd_sendDisableOutputCommand(c->connection, output->id);
+ if (!mpd_run_disable_output(c->connection,
+ mpd_output_get_id(output))) {
+ mpdclient_handle_error(c);
+ return -1;
+ }
- output->enabled = 0;
+ /* XXX reload */
- screen_status_printf(_("Output '%s' disabled"), output->name);
+ screen_status_printf(_("Output '%s' disabled"),
+ mpd_output_get_name(output));
}
- return_value = mpdclient_finish_command(c);
-
outputs_repaint();
- return return_value;
+ return 0;
}
static void
clear_output_element(gpointer data, G_GNUC_UNUSED gpointer user_data)
{
- mpd_freeOutputElement(data);
+ mpd_output_free(data);
}
static void
}
static void
-fill_outputs_list(mpdclient_t *c)
+fill_outputs_list(struct mpdclient *c)
{
- mpd_OutputEntity *output;
+ struct mpd_output *output;
assert(mpd_outputs != NULL);
if (c->connection == NULL)
return;
- mpd_sendOutputsCommand(c->connection);
- while ((output = mpd_getNextOutput(c->connection)) != NULL) {
+ mpd_send_outputs(c->connection);
+ while ((output = mpd_recv_output(c->connection)) != NULL) {
g_ptr_array_add(mpd_outputs, output);
}
}
outputs_list_callback(unsigned int output_index, bool *highlight,
G_GNUC_UNUSED char **sc, G_GNUC_UNUSED void *data)
{
- mpd_OutputEntity *output;
+ struct mpd_output *output;
assert(mpd_outputs != NULL);
output = g_ptr_array_index(mpd_outputs, output_index);
- if (output->enabled)
+ if (mpd_output_get_enabled(output))
*highlight = true;
- return output->name;
+ return mpd_output_get_name(output);
}
static void
}
static void
-outputs_open(mpdclient_t *c)
+outputs_open(struct mpdclient *c)
{
fill_outputs_list(c);
}
}
static bool
-outputs_cmd(mpdclient_t *c, command_t cmd)
+outputs_cmd(struct mpdclient *c, command_t cmd)
{
assert(mpd_outputs != NULL);