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