X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write.h;h=cb0beff812121b338e3749e80f63ad2cb99999db;hp=102f1b25cb3c4bdaea12d0820e0e3b4af4175db8;hb=f14e5c15c82d4bf3b7ea611eab6bce95d4767b61;hpb=24495e62d3896d98d6c27f9665edfe6492ddd757 diff --git a/write.h b/write.h index 102f1b25..cb0beff8 100644 --- a/write.h +++ b/write.h @@ -1,50 +1,72 @@ -/* - * 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. - */ - -/** \file write.h writer-related structures */ +/* 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 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; -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); +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);