Make prefetch-piped samples stop correctly.
[calfbox.git] / cmd.h
blobfa34cdb810e2571c8b4e3a477292079212c74207
1 /*
2 Calf Box, an open source musical instrument.
3 Copyright (C) 2010-2011 Krzysztof Foltman
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CBOX_CMD_H
20 #define CBOX_CMD_H
22 #include <glib.h>
23 #include <stdarg.h>
24 #include <stdint.h>
26 #define CBOX_ARG_I(cmd, idx) (*(int *)(cmd)->arg_values[(idx)])
27 #define CBOX_ARG_S(cmd, idx) ((const char *)(cmd)->arg_values[(idx)])
28 #define CBOX_ARG_B(cmd, idx) ((const struct cbox_blob *)(cmd)->arg_values[(idx)])
29 #define CBOX_ARG_F(cmd, idx) (*(double *)(cmd)->arg_values[(idx)])
30 #define CBOX_ARG_O(cmd, idx, src, class, error) cbox_document_get_object_by_text_uuid(CBOX_GET_DOCUMENT(src), (const char *)(cmd)->arg_values[(idx)], &CBOX_CLASS(class), (error))
31 #define CBOX_ARG_S_ISNULL(cmd, idx) (0 == (const char *)(cmd)->arg_values[(idx)])
33 struct cbox_command_target;
35 struct cbox_osc_command
37 const char *command;
38 const char *arg_types;
39 void **arg_values;
42 typedef gboolean (*cbox_process_cmd)(struct cbox_command_target *ct, struct cbox_command_target *fb, struct cbox_osc_command *cmd, GError **error);
44 struct cbox_command_target
46 void *user_data;
47 cbox_process_cmd process_cmd;
50 void cbox_command_target_init(struct cbox_command_target *ct, cbox_process_cmd cmd, void *user_data);
52 extern gboolean cbox_check_fb_channel(struct cbox_command_target *fb, const char *command, GError **error);
54 extern gboolean cbox_execute_sub(struct cbox_command_target *ct, struct cbox_command_target *fb, const struct cbox_osc_command *cmd, const char *new_command, GError **error);
55 extern gboolean cbox_execute_on(struct cbox_command_target *ct, struct cbox_command_target *fb, const char *cmd, const char *args, GError **error, ...);
56 extern gboolean cbox_execute_on_v(struct cbox_command_target *ct, struct cbox_command_target *fb, const char *cmd, const char *args, va_list va, GError **error);
58 extern gboolean cbox_osc_command_dump(const struct cbox_osc_command *cmd);
60 // Note: this sets *subcommand to NULL on parse error; requires "/path/" as path
61 extern gboolean cbox_parse_path_part_int(const struct cbox_osc_command *cmd, const char *path, const char **subcommand, int *index, int min_index, int max_index, GError **error);
62 extern gboolean cbox_parse_path_part_str(const struct cbox_osc_command *cmd, const char *path, const char **subcommand, char **path_element, GError **error);
64 #endif