]> git.tuebingen.mpg.de Git - paraslash.git/blob - write.h
Rename ->{pre,post}_select methods to ->{pre,post}_monitor.
[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 /**
24  * Describes a data sink for audio streams.
25  *
26  * A paraslash writer obtains data via the buffer tree mechanism from its
27  * parent node. It consumes data without producing output on its own.
28  *
29  * This structure contains the methods which have to be implemented by each
30  * writer.
31  *
32  * \sa struct \ref writer_node, struct \ref receiver, struct \ref filter,
33  * struct \ref sched.
34  */
35 struct writer {
36         /** Ask the scheduler to check whether data can be written. */
37         void (*pre_monitor)(struct sched *s, void *context);
38         /** Write audio data. */
39         int (*post_monitor)(struct sched *s, void *context);
40         /**
41          * Close one instance of the writer.
42          *
43          * This function is assumed to succeed.
44          */
45         void (*close)(struct writer_node *);
46         /**
47          * The callback handler.
48          *
49          * Each writer may provide an ->execute callback which can be used for
50          * inter-node communication.
51          */
52         btr_command_handler execute;
53 };
54
55 #define WRITE_CMD(_num) (lls_cmd(_num, write_cmd_suite))
56
57 #define WRITE_CMD_OPT_RESULT(_cmd, _opt, _lpr) \
58         (lls_opt_result(LSG_WRITE_CMD_ ## _cmd ## _OPT_ ## _opt, _lpr))
59 #define WRITE_CMD_OPT_GIVEN(_cmd, _opt, _lpr) \
60         (lls_opt_given(WRITE_CMD_OPT_RESULT(_cmd, _opt, _lpr)))
61 #define WRITE_CMD_OPT_UINT32_VAL(_cmd, _opt, _lpr) \
62         (lls_uint32_val(0, WRITE_CMD_OPT_RESULT(_cmd, _opt, (_lpr))))
63 #define WRITE_CMD_OPT_STRING_VAL(_cmd, _opt, _lpr) \
64         (lls_string_val(0, WRITE_CMD_OPT_RESULT(_cmd, _opt, (_lpr))))
65
66 int check_writer_arg_or_die(const char *wa, struct lls_parse_result **lprp);
67 const struct writer *writer_get(int wid);
68 const char *writer_name(int wid);
69 void register_writer_node(struct writer_node *wn, struct btr_node *parent,
70                 struct sched *s);
71 int get_btr_sample_rate(struct btr_node *btrn, int32_t *result);
72 int get_btr_channels(struct btr_node *btrn, int32_t *result);
73 int get_btr_sample_format(struct btr_node *btrn, int32_t *result);
74 void print_writer_helps(bool detailed);