icons[n].action(client, icon_action_completed, 0);
}
+/** @brief Called when a volume command completes */
+static void volume_completed(void attribute((unused)) *v,
+ const char *error,
+ int attribute((unused)) l,
+ int attribute((unused)) r) {
+ if(error)
+ popup_protocol_error(0, error);
+ /* We don't set the UI's notion of the volume here, it is set from the log
+ * regardless of the reason it changed */
+}
+
/** @brief Called when the volume has been adjusted */
static void volume_adjusted(GtkAdjustment attribute((unused)) *a,
gpointer attribute((unused)) user_data) {
int l = nearbyint(left(v, b) * 100), r = nearbyint(right(v, b) * 100);
mixer_control(DEFAULT_BACKEND, &l, &r, 1);
} else
- /* We don't want a reply, we'll get the actual new volume from the log. */
- disorder_eclient_volume(client, 0,
+ disorder_eclient_volume(client, volume_completed,
nearbyint(left(v, b) * 100),
nearbyint(right(v, b) * 100),
0);
/* for volume */
static void volume_response_opcallback(disorder_eclient *c,
struct operation *op) {
+ disorder_eclient_volume_response *completed
+ = (disorder_eclient_volume_response *)op->completed;
int l, r;
D(("volume_response_callback"));
if(c->rc / 100 == 2) {
if(op->completed) {
if(sscanf(c->line + 4, "%d %d", &l, &r) != 2 || l < 0 || r < 0)
- /* TODO don't use protocol_error here */
- protocol_error(c, op, -1, "%s: invalid volume response: %s",
- c->ident, c->line);
+ completed(op->v, "cannot parse volume response", 0, 0);
else
- ((disorder_eclient_volume_response *)op->completed)(op->v, l, r);
+ completed(op->v, 0, l, r);
}
} else
- /* TODO don't use protocol_error here */
- protocol_error(c, op, c->rc, "%s: %s", c->ident, c->line);
+ completed(op->v, errorstring(c), 0, 0);
}
static int simple(disorder_eclient *c,
struct sink;
/* Completion callbacks. These provide the result of operations to the caller.
- * It is always allowed for these to be null pointers if you don't care about
- * the result. */
+ * Unlike in earlier releases, these are not allowed to be NULL. */
/** @brief Trivial completion callback
* @param v User data
typedef void disorder_eclient_integer_response(void *v,
const char *error,
long value);
-/* completion callback with a integer result */
-
-typedef void disorder_eclient_volume_response(void *v, int l, int r);
-/* completion callback with a pair of integer results */
+/** @brief Volume completion callback
+ * @param v User data
+ * @param error Error string or NULL on success
+ * @param l Left channel volume
+ * @param r Right channel volume
+ *
+ * @p error will be NULL on success. In this case @p l and @p r will be the
+ * result.
+ *
+ * @p error will be non-NULL on failure. In this case @p l and @p r are always
+ * 0.
+ */
+typedef void disorder_eclient_volume_response(void *v,
+ const char *error,
+ int l, int r);
typedef void disorder_eclient_queue_response(void *v, struct queue_entry *q);
/* completion callback for queue/recent listing */