From: Andre Noll Date: Mon, 19 Feb 2007 21:19:20 +0000 (+0100) Subject: simplify setup_default_wng() X-Git-Tag: v0.2.16~76^2~8 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=199a80d5b07348e8eee1ec1a6339c4d68e85434e;p=paraslash.git simplify setup_default_wng() The default writer is known at compile time, so replace the code that computes it at runtime by a #define in configure.ac. --- diff --git a/configure.ac b/configure.ac index 1fa5ac4f..cb7ad163 100644 --- a/configure.ac +++ b/configure.ac @@ -93,6 +93,7 @@ write_cmdline_objs="write.cmdline file_write.cmdline" write_errlist_objs="write write_common file_write time fd string sched stdin" write_ldflags="" writers=" file" +default_writer="FILE_WRITE" client_cmdline_objs="client.cmdline" client_errlist_objs="client net string crypt fd sched stdin stdout client_common" @@ -184,6 +185,7 @@ if test ${have_core_audio} = yes; then write_cmdline_objs="$write_cmdline_objs osx_write.cmdline" write_ldflags="$write_ldflags $f" writers="$writers osx" + default_writer="OSX_WRITE" AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X) fi ########################################################################### gtk2 @@ -405,6 +407,7 @@ if test "$have_alsa" = "yes"; then write_cmdline_objs="$write_cmdline_objs alsa_write.cmdline" write_ldflags="$write_ldflags -lasound" writers="$writers alsa" + default_writer="ALSA_WRITE" fi CPPFLAGS="$OLD_CPPFLAGS" LDFLAGS="$OLD_LDFLAGS" @@ -532,6 +535,7 @@ AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS, enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)" AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS, enum of supported writers) +AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified) names="$(for i in $writers; do printf \"$i\",' ' ; done)" AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names) inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)" diff --git a/write_common.c b/write_common.c index ac92bc1a..78d1523e 100644 --- a/write_common.c +++ b/write_common.c @@ -236,15 +236,9 @@ void *check_writer_arg(const char *wa, int *writer_num) struct writer_node_group *setup_default_wng(void) { struct writer_node_group *wng = wng_new(1); - enum writer_enum default_writer; - - if (NUM_SUPPORTED_WRITERS == 1) - default_writer = FILE_WRITE; - else - default_writer = 1; - wng->writer_nodes[0].writer = &writers[default_writer]; + wng->writer_nodes[0].writer = &writers[DEFAULT_WRITER]; PARA_INFO_LOG("using default writer: %s %p\n", - writer_names[default_writer], writers[default_writer].parse_config); - wng->writer_nodes[0].conf = writers[default_writer].parse_config(""); + writer_names[DEFAULT_WRITER], writers[DEFAULT_WRITER].parse_config); + wng->writer_nodes[0].conf = writers[DEFAULT_WRITER].parse_config(""); return wng; }