X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=write.h;h=fd3983ddf262f1edec986680c856c1d7f7c9c511;hb=34be2cc6668b2297566de312250f6c0104796f65;hp=68730bf152a4e49923b7c1ca886c1cdb3ea432f5;hpb=780f86d5f849308b5100b087c6b223a6deef1dd7;p=paraslash.git diff --git a/write.h b/write.h index 68730bf1..fd3983dd 100644 --- a/write.h +++ b/write.h @@ -1,48 +1,76 @@ /* - * Copyright (C) 2006 Andre Noll + * 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. + * Licensed under the GPL v2. For licencing details see 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 one supported writer. */ struct writer { - void (*init)(struct writer *w); - int (*open)(struct writer_node *); - int (*write)(char *data, size_t nbytes, struct writer_node *); + /** + * Prepare the fd sets for select. + * + * This is called from scheduler. It may use the sched pointer to add + * any file descriptors or to decrease the select timeout. + */ + void (*pre_select)(struct sched *s, void *context); + /** + * Write audio data. + * + * Called from the post_select function of the writer node's task. + */ + int (*post_select)(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; -const char *writer_names[NUM_SUPPORTED_WRITERS]; -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); +void get_btr_sample_rate(struct btr_node *btrn, int32_t *result); +void get_btr_channels(struct btr_node *btrn, int32_t *result); +void get_btr_sample_format(struct btr_node *btrn, int32_t *result); +void print_writer_helps(bool detailed);