+ switch (band) {
+ case SBD_OUTPUT:
+ case SBD_DEBUG_LOG:
+ case SBD_INFO_LOG:
+ case SBD_NOTICE_LOG:
+ case SBD_WARNING_LOG:
+ case SBD_ERROR_LOG:
+ case SBD_CRIT_LOG:
+ case SBD_EMERG_LOG:
+ assert(result->size > 0);
+ return send_sb(&cc->scc, result->data, result->size, band, true);
+ case SBD_AFS_CB_FAILURE:
+ return *(int *)(result->data);
+ default:
+ return -E_BAD_BAND;
+ }
+}
+
+static void flush_and_free_pb(struct para_buffer *pb)
+{
+ 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)
+{
+ char *arg = aca->query.data;
+ int num_admissible, ret;
+
+ ret = clear_score_table();
+ if (ret < 0) {
+ para_printf(&aca->pbout, "could not clear score table: %s\n",
+ para_strerror(-ret));
+ return ret;
+ }
+ if (current_play_mode == PLAY_MODE_MOOD)
+ close_current_mood();
+ else
+ playlist_close();
+ ret = activate_mood_or_playlist(arg, &num_admissible);
+ if (ret >= 0)
+ goto out;
+ /* ignore subsequent errors (but log them) */
+ para_printf(&aca->pbout, "could not activate %s: %s\n"
+ "switching back to %s\n",
+ arg, para_strerror(-ret), current_mop? current_mop : "dummy");
+ ret = activate_mood_or_playlist(current_mop, &num_admissible);
+ if (ret >= 0)
+ goto out;
+ para_printf(&aca->pbout, "could not activate %s: %s\nswitching to dummy\n",
+ current_mop, para_strerror(-ret));
+ activate_mood_or_playlist(NULL, &num_admissible);
+out:
+ para_printf(&aca->pbout, "activated %s (%d admissible files)\n",
+ current_mop? current_mop : "dummy mood", num_admissible);
+ return ret;