+ int ret;
+ struct afs_max_size_handler_data *amshd = pb->private_data;
+
+ if (pb->buf && pb->size > 0) {
+ ret = pass_buffer_as_shm(amshd->fd, amshd->band, pb->buf,
+ pb->offset);
+ if (ret < 0)
+ PARA_ERROR_LOG("%s\n", para_strerror(-ret));
+ }
+ free(pb->buf);
+}
+
+static int com_select_callback(struct afs_callback_arg *aca)
+{
+ const struct lls_command *cmd = SERVER_CMD_CMD_PTR(SELECT);
+ const char *arg;
+ int num_admissible, ret;
+ char *errmsg;
+
+ ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
+ assert(ret >= 0);
+ arg = lls_input(0, aca->lpr);
+ ret = clear_score_table();
+ if (ret < 0) {
+ para_printf(&aca->pbout, "could not clear score table\n");
+ goto free_lpr;
+ }
+ if (current_play_mode == PLAY_MODE_MOOD)
+ close_current_mood();
+ else
+ playlist_close();
+ ret = activate_mood_or_playlist(arg, &num_admissible, &errmsg);
+ if (ret >= 0)
+ goto out;
+ /* ignore subsequent errors (but log them) */
+ para_printf(&aca->pbout, "%s\n", errmsg);
+ free(errmsg);
+ para_printf(&aca->pbout, "could not activate %s\n", arg);
+ if (current_mop && strcmp(current_mop, arg) != 0) {
+ int ret2;
+ para_printf(&aca->pbout, "switching back to %s\n", current_mop);
+ ret2 = activate_mood_or_playlist(current_mop, &num_admissible,
+ &errmsg);
+ if (ret2 >= 0)
+ goto out;
+ para_printf(&aca->pbout, "%s\n", errmsg);
+ free(errmsg);
+ para_printf(&aca->pbout, "could not reactivate %s: %s\n",
+ current_mop, para_strerror(-ret2));
+ }
+ para_printf(&aca->pbout, "activating dummy mood\n");
+ activate_mood_or_playlist(NULL, &num_admissible, NULL);
+out:
+ para_printf(&aca->pbout, "activated %s (%d admissible files)\n",
+ current_mop? current_mop : "dummy mood", num_admissible);
+free_lpr:
+ lls_free_parse_result(aca->lpr, cmd);
+ return ret;
+}