X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=write.h;h=d5834b4c436eafae77cb7a086c045c4bf6f0a81b;hb=HEAD;hp=3ef691a3a65b884a329f1119065e05e1a96a554f;hpb=91f94e5e9dc29f17a380853234f600977b57a273;p=paraslash.git diff --git a/write.h b/write.h index 3ef691a3..35a8d29f 100644 --- a/write.h +++ b/write.h @@ -1,48 +1,74 @@ -/* - * Copyright (C) 2006 Andre Noll - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - */ +/* Copyright (C) 2006 Andre Noll , see file COPYING. */ -enum writer_enum {WRITER_ENUM}; +/** \file write.h Writer-related structures. */ +/** + * Describes one running instance of a writer. + */ struct writer_node { - struct writer *writer; + /** The ID of this writer. */ + int wid; + /** Writer-specific data. */ void *private_data; - int chunk_bytes; + /** The parsed command line, merged with options given in the config file. */ + struct lls_parse_result *lpr; + /** The buffer tree node associated with this writer node. */ + struct btr_node *btrn; + /** The task of this writer node. */ + struct task *task; + /** The minimal input queue size (size of one audio sample). */ + size_t min_iqs; }; +/** + * Describes a data sink for audio streams. + * + * A paraslash writer obtains data via the buffer tree mechanism from its + * parent node. It consumes data without producing output on its own. + * + * This structure contains the methods which have to be implemented by each + * writer. + * + * \sa struct \ref writer_node, struct \ref receiver, struct \ref filter, + * struct \ref sched. + */ struct writer { - void (*init)(struct writer *w); - int (*open)(struct writer_node *); - int (*write)(char *data, size_t nbytes, struct writer_node *); + /** Ask the scheduler to check whether data can be written. */ + void (*pre_monitor)(struct sched *s, void *context); + /** Write audio data. */ + int (*post_monitor)(struct sched *s, void *context); + /** + * Close one instance of the writer. + * + * This function is assumed to succeed. + */ void (*close)(struct writer_node *); - void (*shutdown)(struct writer_node *); + /** + * The callback handler. + * + * Each writer may provide an ->execute callback which can be used for + * inter-node communication. + */ + btr_command_handler execute; }; -struct writer_node_group { - unsigned num_writers; - struct writer_node *writer_nodes; - int *written; - size_t max_chunk_bytes; - int eof; -}; +#define WRITE_CMD(_num) (lls_cmd(_num, write_cmd_suite)) -#define FOR_EACH_WRITER_NODE(i, wng) for (i = 0; i < (wng)->num_writers; i++) -#define FOR_EACH_WRITER(i) for (i = 0; i < NUM_SUPPORTED_WRITERS; i++) +#define WRITE_CMD_OPT_RESULT(_cmd, _opt, _lpr) \ + (lls_opt_result(LSG_WRITE_CMD_ ## _cmd ## _OPT_ ## _opt, _lpr)) +#define WRITE_CMD_OPT_GIVEN(_cmd, _opt, _lpr) \ + (lls_opt_given(WRITE_CMD_OPT_RESULT(_cmd, _opt, _lpr))) +#define WRITE_CMD_OPT_UINT32_VAL(_cmd, _opt, _lpr) \ + (lls_uint32_val(0, WRITE_CMD_OPT_RESULT(_cmd, _opt, (_lpr)))) +#define WRITE_CMD_OPT_STRING_VAL(_cmd, _opt, _lpr) \ + (lls_string_val(0, WRITE_CMD_OPT_RESULT(_cmd, _opt, (_lpr)))) -DECLARE_WRITER_INITS; -extern const char *writer_names[]; -extern struct writer writers[NUM_SUPPORTED_WRITERS]; +int check_writer_arg_or_die(const char *wa, struct lls_parse_result **lprp); +const struct writer *writer_get(int wid); +const char *writer_name(int wid); +void register_writer_node(struct writer_node *wn, struct btr_node *parent, + struct sched *s); +int get_btr_sample_rate(struct btr_node *btrn, int32_t *result); +int get_btr_channels(struct btr_node *btrn, int32_t *result); +int get_btr_sample_format(struct btr_node *btrn, int32_t *result); +void print_writer_helps(bool detailed);