Merge branch 'maint'
[paraslash.git] / write.h
1 /* Copyright (C) 2006 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
2
3 /** \file write.h Writer-related structures. */
4
5 /**
6 * Describes one running instance of a writer.
7 */
8 struct writer_node {
9 /** The ID of this writer. */
10 int wid;
11 /** Writer-specific data. */
12 void *private_data;
13 /** The parsed command line, merged with options given in the config file. */
14 struct lls_parse_result *lpr;
15 /** The buffer tree node associated with this writer node. */
16 struct btr_node *btrn;
17 /** The task of this writer node. */
18 struct task *task;
19 /** The minimal input queue size (size of one audio sample). */
20 size_t min_iqs;
21 };
22
23 /** Describes one supported writer. */
24 struct writer {
25 /**
26 * Prepare the fd sets for select.
27 *
28 * This is called from scheduler. It may use the sched pointer to add
29 * any file descriptors or to decrease the select timeout.
30 */
31 void (*pre_select)(struct sched *s, void *context);
32 /**
33 * Write audio data.
34 *
35 * Called from the post_select function of the writer node's task.
36 */
37 int (*post_select)(struct sched *s, void *context);
38 /**
39 * Close one instance of the writer.
40 *
41 * This function is assumed to succeed.
42 */
43 void (*close)(struct writer_node *);
44 /**
45 * The callback handler.
46 *
47 * Each writer may provide an ->execute callback which can be used for
48 * inter-node communication.
49 */
50 btr_command_handler execute;
51 };
52
53 #define WRITE_CMD(_num) (lls_cmd(_num, write_cmd_suite))
54
55 #define WRITE_CMD_OPT_RESULT(_cmd, _opt, _lpr) \
56 (lls_opt_result(LSG_WRITE_CMD_ ## _cmd ## _OPT_ ## _opt, _lpr))
57 #define WRITE_CMD_OPT_GIVEN(_cmd, _opt, _lpr) \
58 (lls_opt_given(WRITE_CMD_OPT_RESULT(_cmd, _opt, _lpr)))
59 #define WRITE_CMD_OPT_UINT32_VAL(_cmd, _opt, _lpr) \
60 (lls_uint32_val(0, WRITE_CMD_OPT_RESULT(_cmd, _opt, (_lpr))))
61 #define WRITE_CMD_OPT_STRING_VAL(_cmd, _opt, _lpr) \
62 (lls_string_val(0, WRITE_CMD_OPT_RESULT(_cmd, _opt, (_lpr))))
63
64 int check_writer_arg_or_die(const char *wa, struct lls_parse_result **lprp);
65 const struct writer *writer_get(int wid);
66 const char *writer_name(int wid);
67 void register_writer_node(struct writer_node *wn, struct btr_node *parent,
68 struct sched *s);
69 void get_btr_sample_rate(struct btr_node *btrn, int32_t *result);
70 void get_btr_channels(struct btr_node *btrn, int32_t *result);
71 void get_btr_sample_format(struct btr_node *btrn, int32_t *result);
72 void print_writer_helps(bool detailed);