Merge branch 't/old_gcc_fixes'
authorAndre Noll <maan@systemlinux.org>
Sun, 15 Jul 2012 19:57:33 +0000 (21:57 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 15 Jul 2012 19:57:33 +0000 (21:57 +0200)
82d304 buffer_tree.h: Fix gcc warning.
5535f6 alsa: Fix gcc warning.

Simple enough and well tested with no regressions found.

27 files changed:
.gitignore
Doxyfile
Makefile.in
NEWS
afs.cmd
aft.c
alsa_write.c
ao_write.c
audiod.c
audiod.cmd
audiod_command.c
client.c
command.c
command_util.sh
configure.ac
error.h
file_write.c
flacdec_filter.c
gcrypt.c
mood.c
mp3dec_filter.c
oggdec_filter.c
oss_write.c
osx_write.c
server.cmd
wmadec_filter.c
write.h

index d337367..141424f 100644 (file)
@@ -18,7 +18,6 @@ Makefile.deps
 TODO
 NONE
 aclocal.m4
-*_command_list.c
 *_command_list.h
 *_command_list.man
 paraslash-git.tar.bz2
index 83973cf..3fed0c2 100644 (file)
--- a/Doxyfile
+++ b/Doxyfile
@@ -623,7 +623,7 @@ EXCLUDE_PATTERNS       = *.cmdline.* \
                          gcc-compat.h \
                          fade.c \
                          config.h \
-                       *_command_list.[ch] \
+                       *_command_list.h \
                        *_completion.h
 
 # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
index 30a5c01..868cfea 100644 (file)
@@ -119,20 +119,21 @@ $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
 $(subst z,Z,$1))))))))))))))))))))))))))
 
-%_command_list.c: %.cmd
-       @[ -z "$(Q)" ] || echo 'GEN $@'
-       $(Q) ./command_util.sh c < $< >$@
-%_command_list.h: %.cmd
+%_command_list.h: %.cmd %.c
        @[ -z "$(Q)" ] || echo 'GEN $@'
        $(Q) ./command_util.sh h < $< >$@
-%_command_list.man: %.cmd
+%_command_list.man: %.cmd %.c
        @[ -z "$(Q)" ] || echo 'GEN $@'
        $(Q) ./command_util.sh man < $< > $@
-%_completion.h: %.cmd
+%_completion.h: %.cmd %.c
        @[ -z "$(Q)" ] || echo 'GEN $@'
        $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
                $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
 
+server_command_list.h server_command_list.man server_completion.h: command.c
+afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c
+audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c
+
 server_command_lists_man = server_command_list.man afs_command_list.man
 man/man1/para_server.1: para_server $(server_command_lists_man) | $(man_dir)
        @[ -z "$(Q)" ] || echo 'MAN $<'
diff --git a/NEWS b/NEWS
index fa8e024..7fcf7f9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,12 @@
          support this feature, data is sent as a multiplexed stream.
        - The --no_default_filters option of para_filter has been
          removed.
+       - Several fixes and latency improvements to various decoders.
+       - The alsa writer now limits the prebuffer time to 500ms.
        - Documentation improvements.
+       - Overhaul of the command_util.sh script.
+       - Fixes for some minor problems found by the clang analyzer.
+       - Compiles (almost) without warnings on gcc-3.
 
 ------------------------------------------
 0.4.10 (2012-03-30) "heterogeneous vacuum"
diff --git a/afs.cmd b/afs.cmd
index 11b1631..f0bd26f 100644 (file)
--- a/afs.cmd
+++ b/afs.cmd
@@ -1,10 +1,5 @@
-OF: afs_command_list
+BN: afs
 SF: afs.c aft.c attribute.c
-HC: Prototypes for the commands of the audio file selector.
-CC: Array of commands for the audio file selector.
-AT: server_command
-SI: osl regex
-IN: para error crypt sideband command string afh afs server list user_list
 SN: list of afs commands
 TM: mood lyr img pl
 ---
diff --git a/aft.c b/aft.c
index 2732790..f01f186 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -1277,8 +1277,10 @@ static int prepare_ls_row(struct osl_row *row, void *ls_opts)
                ret = get_score_and_aft_row(row, &score, &aft_row);
                if (ret < 0)
                        return ret;
-       } else
+       } else {
                aft_row = row;
+               score = 0;
+       }
        ret = get_audio_file_path_of_row(aft_row, &path);
        if (ret < 0)
                return ret;
index 528463d..8c12c72 100644 (file)
@@ -113,6 +113,8 @@ static int alsa_init(struct private_alsa_write_data *pad,
                NULL);
        if (ret < 0 || buffer_time == 0)
                goto fail;
+       /* buffer at most 500 milliseconds */
+       buffer_time = PARA_MIN(buffer_time, 500U * 1000U);
        msg = "could not set buffer time";
        ret = snd_pcm_hw_params_set_buffer_time_near(pad->handle, hwparams,
                &buffer_time, NULL);
@@ -356,7 +358,6 @@ void alsa_write_init(struct writer *w)
        w->pre_select = alsa_write_pre_select;
        w->post_select = alsa_write_post_select;
        w->parse_config_or_die = alsa_parse_config_or_die;
-       w->shutdown = NULL; /* nothing to do */
        w->free_config = alsa_free_config;
        w->help = (struct ggo_help) {
                .short_help = alsa_write_args_info_help,
index 6dc3192..93861ab 100644 (file)
@@ -375,7 +375,6 @@ void ao_write_init(struct writer *w)
        w->post_select = aow_post_select;
        w->parse_config_or_die = aow_parse_config_or_die;
        w->free_config = aow_free_config;
-       w->shutdown = NULL;
        w->help = (struct ggo_help) {
                .short_help = ao_write_args_info_help,
        };
index 40603c4..93bc8da 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1199,8 +1199,6 @@ static void status_post_select(struct sched *s, struct task *t)
                        kill_btrn(st->ct->btrn, &st->ct->task, -E_AUDIOD_OFF);
                        goto out;
                }
-               if (st->ct->task.error >= 0)
-                       goto out;
                close_stat_pipe();
                st->clock_diff_count = conf.clock_diff_count_arg;
                goto out;
@@ -1210,8 +1208,6 @@ static void status_post_select(struct sched *s, struct task *t)
                size_t sz;
                int ret;
                if (st->ct->task.error < 0) {
-                       if (st->ct->task.error >= 0)
-                               goto out;
                        close_stat_pipe();
                        goto out;
                }
index c589074..6c99d4c 100644 (file)
@@ -1,9 +1,5 @@
-OF: audiod_command_list
+BN: audiod
 SF: audiod_command.c
-HC: prototypes for the audiod command handlers
-CC: array of audiod commands
-AT: audiod_command
-IN: list para sched audiod
 SN: list of audiod commands
 ---
 N: cycle
index 9d92d1c..35b76b5 100644 (file)
@@ -29,6 +29,9 @@
 extern struct sched sched;
 extern char *stat_item_values[NUM_STAT_ITEMS];
 
+
+struct audiod_command audiod_cmds[] = {DEFINE_AUDIOD_CMD_ARRAY};
+
 /** Iterate over the array of all audiod commands. */
 #define FOR_EACH_COMMAND(c) for (c = 0; audiod_cmds[c].name; c++)
 
@@ -249,7 +252,7 @@ static int dump_commands(int fd)
  * to each individual command to close the fd if necessary.
  */
 
-int com_help(int fd, int argc, char **argv)
+static int com_help(int fd, int argc, char **argv)
 {
        int i, ret;
        char *buf;
@@ -284,7 +287,7 @@ out:
        return ret;
 }
 
-int com_tasks(int fd, __a_unused int argc, __a_unused char **argv)
+static int com_tasks(int fd, __a_unused int argc, __a_unused char **argv)
 {
        char *tl = get_task_list(&sched);
        int ret = 1;
@@ -296,7 +299,7 @@ int com_tasks(int fd, __a_unused int argc, __a_unused char **argv)
        return ret;
 }
 
-int com_stat(int fd, int argc, char **argv)
+static int com_stat(int fd, int argc, char **argv)
 {
        int i, ret, parser_friendly = 0;
        uint64_t mask = 0;
@@ -342,39 +345,39 @@ int com_stat(int fd, int argc, char **argv)
        return ret;
 }
 
-int com_grab(int fd, int argc, char **argv)
+static int com_grab(int fd, int argc, char **argv)
 {
        return grab_client_new(fd, argc, argv, &sched);
 }
 
-__noreturn int com_term(int fd, __a_unused int argc, __a_unused char **argv)
+__noreturn static int com_term(int fd, __a_unused int argc, __a_unused char **argv)
 {
        close(fd);
        clean_exit(EXIT_SUCCESS, "terminating on user request");
 }
 
-int com_on(int fd, __a_unused int argc, __a_unused char **argv)
+static int com_on(int fd, __a_unused int argc, __a_unused char **argv)
 {
        audiod_status = AUDIOD_ON;
        close(fd);
        return 1;
 }
 
-int com_off(int fd, __a_unused int argc, __a_unused char **argv)
+static int com_off(int fd, __a_unused int argc, __a_unused char **argv)
 {
        audiod_status = AUDIOD_OFF;
        close(fd);
        return 1;
 }
 
-int com_sb(int fd, __a_unused int argc, __a_unused char **argv)
+static int com_sb(int fd, __a_unused int argc, __a_unused char **argv)
 {
        audiod_status = AUDIOD_STANDBY;
        close(fd);
        return 1;
 }
 
-int com_cycle(int fd, int argc, char **argv)
+static int com_cycle(int fd, int argc, char **argv)
 {
        switch (audiod_status) {
                case  AUDIOD_ON:
index c194e19..f0f3b26 100644 (file)
--- a/client.c
+++ b/client.c
@@ -307,7 +307,7 @@ static void setatt_completer(struct i9e_completion_info *ci,
                free(orig);
        }
        sl[2 * num_atts] = NULL;
-       ret = i9e_extract_completions(ci->word, sl, &cr->matches);
+       i9e_extract_completions(ci->word, sl, &cr->matches);
 out:
        free(buf);
        free_argv(sl);
index 2cac57f..f9bace3 100644 (file)
--- a/command.c
+++ b/command.c
@@ -36,6 +36,9 @@
 #include "signal.h"
 #include "version.h"
 
+struct server_command afs_cmds[] = {DEFINE_AFS_CMD_ARRAY};
+struct server_command server_cmds[] = {DEFINE_SERVER_CMD_ARRAY};
+
 /** Commands including options must be shorter than this. */
 #define MAX_COMMAND_LEN 32768
 
@@ -314,7 +317,7 @@ fail:
        return ret;
 }
 
-int com_sender(struct command_context *cc)
+static int com_sender(struct command_context *cc)
 {
        int i, ret = 0;
        char *msg = NULL;
@@ -371,7 +374,7 @@ int com_sender(struct command_context *cc)
 }
 
 /* server info */
-int com_si(struct command_context *cc)
+static int com_si(struct command_context *cc)
 {
        int i, ret;
        char *msg, *ut, *sender_info = NULL;
@@ -414,7 +417,7 @@ int com_si(struct command_context *cc)
 }
 
 /* version */
-int com_version(struct command_context *cc)
+static int com_version(struct command_context *cc)
 {
        char *msg;
        size_t len;
@@ -495,7 +498,7 @@ out:
 #undef EMPTY_STATUS_ITEMS
 
 /* stat */
-int com_stat(struct command_context *cc)
+static int com_stat(struct command_context *cc)
 {
        int i, ret;
        struct misc_meta_data tmp, *nmmd = &tmp;
@@ -605,7 +608,7 @@ static struct server_command *get_cmd_ptr(const char *name, char **handler)
 }
 
 /* help */
-int com_help(struct command_context *cc)
+static int com_help(struct command_context *cc)
 {
        struct server_command *cmd;
        char *perms, *handler, *buf;
@@ -644,7 +647,7 @@ int com_help(struct command_context *cc)
 }
 
 /* hup */
-int com_hup(struct command_context *cc)
+static int com_hup(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -653,7 +656,7 @@ int com_hup(struct command_context *cc)
 }
 
 /* term */
-int com_term(struct command_context *cc)
+static int com_term(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -661,7 +664,7 @@ int com_term(struct command_context *cc)
        return 1;
 }
 
-int com_play(struct command_context *cc)
+static int com_play(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -673,7 +676,7 @@ int com_play(struct command_context *cc)
 }
 
 /* stop */
-int com_stop(struct command_context *cc)
+static int com_stop(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -686,7 +689,7 @@ int com_stop(struct command_context *cc)
 }
 
 /* pause */
-int com_pause(struct command_context *cc)
+static int com_pause(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -701,7 +704,7 @@ int com_pause(struct command_context *cc)
 }
 
 /* next */
-int com_next(struct command_context *cc)
+static int com_next(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -713,7 +716,7 @@ int com_next(struct command_context *cc)
 }
 
 /* nomore */
-int com_nomore(struct command_context *cc)
+static int com_nomore(struct command_context *cc)
 {
        if (cc->argc != 1)
                return -E_COMMAND_SYNTAX;
@@ -725,7 +728,7 @@ int com_nomore(struct command_context *cc)
 }
 
 /* ff */
-int com_ff(struct command_context *cc)
+static int com_ff(struct command_context *cc)
 {
        long promille;
        int ret, backwards = 0;
@@ -764,7 +767,7 @@ out:
 }
 
 /* jmp */
-int com_jmp(struct command_context *cc)
+static int com_jmp(struct command_context *cc)
 {
        long unsigned int i;
        int ret;
@@ -1107,19 +1110,17 @@ net_err:
 out:
        free(buf);
        free(command);
-       sc_free(cc->scc.recv);
-       sc_free(cc->scc.send);
        mutex_lock(mmd_mutex);
        if (cc->cmd && (cc->cmd->perms & AFS_WRITE) && ret >= 0)
                mmd->events++;
        mmd->active_connections--;
        mutex_unlock(mmd_mutex);
-       if (ret < 0)
-               exit(EXIT_FAILURE);
-       if (!cc->use_sideband)
-               exit(EXIT_SUCCESS);
-       ret = send_sb(&cc->scc, NULL, 0, SBD_EXIT__SUCCESS, true);
-       if (ret < 0)
-               PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
+       if (ret >= 0 && cc->use_sideband) {
+               ret = send_sb(&cc->scc, NULL, 0, SBD_EXIT__SUCCESS, true);
+               if (ret < 0)
+                       PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
+       }
+       sc_free(cc->scc.recv);
+       sc_free(cc->scc.send);
        exit(ret < 0? EXIT_FAILURE : EXIT_SUCCESS);
 }
index 76b3445..b37c5b0 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/env bash
 
-
 read_header()
 {
        local key value i
@@ -10,36 +9,12 @@ read_header()
                ---)
                        break
                        ;;
-               HC:)
-                       header_comment="$value"
-                       ;;
-               CC:)
-                       c_file_comment="$value"
-                       ;;
-               OF:)
-                       output_file="$value"
-                       array_name=${value%command_list}cmds
+               BN:)
+                       base_name="$value"
                        ;;
                SF:)
                        source_files="$value"
                        ;;
-               AT:)
-                       array_type="$value"
-                       ;;
-               SI:)
-                       for i in $value; do
-                               system_includes="$system_includes
-#include <$i.h>"
-                       done
-                       ;;
-               IN:)
-                       for i in $value; do
-                               includes="$includes
-#include \"$i.h\""
-                       done
-                       includes="$includes
-#include \"$output_file.h\""
-                       ;;
                SN:)
                        section_name="$value"
                        ;;
@@ -47,11 +22,6 @@ read_header()
                        template_members="$value"
                esac
        done
-       if test -z "$header_comment" -o -z "$c_file_comment" \
-                       -o -z "$output_file"; then
-               echo "header error" 1&>2
-               exit 1
-       fi
 }
 
 read_one_command()
@@ -193,56 +163,53 @@ com_man()
        done
 }
 
-dump_proto()
+make_proto()
 {
-       local source_file match=""
-
-       echo '/**'
-       echo " * $desc_txt"
-       echo ' *'
-       echo " * Usage: $usage_txt"
-       echo ' * '
-       echo "$help_txt" | sed -e 's/^/ * /g'
-       echo ' */'
+       local regex='\(__noreturn \)*\(static \)*int com_'
+       local source_file match="" all_commands CR='
+'
        if test -n "$prototype"; then
-               echo "$prototype"
-               echo
+               result="$prototype$CR"
                return
        fi
+       all_commands="$(cat $source_files | grep "$regex")"
+       result=
        for source_file in $source_files; do
-               match=$(grep "^\(__noreturn \)*int com_$name_txt(" $source_file | head -n 1 | sed -e 's/$/;/1')
+               match=$(grep "$regex$name_txt(" <<< "$all_commands" | head -n 1 | sed -e 's/$/;/1')
                if test -n "$match"; then
-                       echo "$match"
+                       result="$result$match$CR"
                        break
                fi
        done
-       echo
 }
 
-dump_array_member()
+make_array_member()
 {
-       local TAB='     '
-       echo '{'
-       echo ".name = \"$name_txt\","
-       echo ".handler = com_$name_txt,"
+       local TAB='     ' CR='
+'
+       local tmp
+
+       result="{.name = \"$name_txt\", .handler = com_$name_txt, "
        if test -n "$perms_txt"; then
-               echo ".perms = $perms_txt,"
+               result="$result .perms = $perms_txt,"
        fi
-       echo ".description = \"$desc_txt\","
-       echo ".usage = \"$usage_txt\","
-       echo ".help = "
-       printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \
-               -e "s/$TAB/\\\t/g"
-       echo '},'
+       result="$result.description = \"$desc_txt\", .usage = \"$usage_txt\", \\$CR .help = "
+       tmp="$(printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \
+               -e "s/$TAB/\\\t/g" -e's/$/\\/g')"
+       result="$result$tmp$CR}, \\$CR"
 }
 
-dump_completion()
+make_completion()
 {
-       echo "  {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\"
+       local CR='
+'
+       result="  {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\$CR"
 }
 
 template_loop()
 {
+       local loop_result=
+
        local t_name="$name_txt"
        local t_perms="$perms_txt"
        local t_desc="$desc_txt"
@@ -251,48 +218,31 @@ template_loop()
        local t_source_files="$source_files"
        local member
        for member in $template_members; do
-               local sed_cmd="sed -e s/@member@/$member/g"
-               #echo "sed_cmd: $sed_cmd"
-               name_txt=$(echo "$t_name" | $sed_cmd)
-               #name_txt="$tname"
-               perms_txt=$(echo "$t_perms" | $sed_cmd)
-               desc_txt=$(echo "$t_desc" | $sed_cmd)
-               usage_txt=$(echo "$t_usage" | $sed_cmd)
-               help_txt=$(printf "%s\n" "$t_help" | $sed_cmd)
-               prototype=$(echo "$template_prototype" | $sed_cmd)
+               name_txt="${t_name//@member@/$member}"
+               perms_txt="${t_perms//@member@/$member}"
+               desc_txt="${t_desc//@member@/$member}"
+               usage_txt="${t_usage//@member@/$member}"
+               help_txt="${t_help//@member@/$member}"
+               prototype="${template_prototype//@member@/$member}"
+               result=
                $1
+               loop_result="$loop_result$result"
        done
-
-}
-
-com_c_file()
-{
-       echo "/** \file $output_file.c $c_file_comment */"
-       echo "$system_includes"
-       echo "$includes"
-       echo "struct $array_type $array_name[] = {"
-       while : ; do
-               read_one_command
-               if test $ret -lt 0; then
-                       exit 1
-               fi
-               if test $ret -eq 0; then
-                       break
-               fi
-               if test $template -eq 0; then
-                       dump_array_member
-                       continue
-               fi
-               template_loop dump_array_member
-       done
-       echo '{.name = NULL}};'
+       result="$loop_result"
+       # reset global variables
+       name_txt="$t_name"
+       perms_txt="$t_perms"
+       desc_txt="$t_desc"
+       usage_txt="$t_usage"
+       help_txt="$t_help"
+       source_files="$t_source_files"
 }
 
 com_header()
 {
-       echo "/** \file $output_file.h $header_comment */"
-       echo
-       echo "extern struct $array_type $array_name[];"
+       local array_members CR='
+'
+
        while : ; do
                read_one_command
                if test $ret -lt 0; then
@@ -302,11 +252,19 @@ com_header()
                        break
                fi
                if test $template -eq 0; then
-                       dump_proto
+                       make_proto
+                       printf "%s" "$result"
+                       make_array_member
+                       array_members="$array_members$result"
                        continue
                fi
-               template_loop dump_proto
+               template_loop make_proto
+               printf "%s" "$result"
+               template_loop make_array_member
+               array_members="$array_members$result"
        done
+       array_members="$array_members{.name = NULL} \\$CR"
+       echo "#define DEFINE_$(tr 'a-z' 'A-Z' <<< "$base_name")_CMD_ARRAY $array_members"
 }
 
 com_completion()
@@ -322,10 +280,12 @@ com_completion()
                        break
                fi
                if test $template -eq 0; then
-                       dump_completion
+                       make_completion
+                       printf "%s" "$result"
                        continue
                fi
-               template_loop dump_completion
+               template_loop make_completion
+               printf "%s" "$result"
        done
        echo
 }
@@ -334,9 +294,6 @@ read_header
 arg="$1"
 shift
 case "$arg" in
-       "c")
-               com_c_file
-               ;;
        "h")
                com_header
                ;;
index c616b0a..90521df 100644 (file)
@@ -98,7 +98,7 @@ all_errlist_objs="mp3_afh afh_common net string signal time daemon
        dccp_recv recv_common write_common file_write audiod_command
        client_common recv stdout filter stdin audioc write client
        exec send_common ggo udp_recv color fec fecdec_filter
-       prebuffer_filter audiod_command_list bitstream imdct
+       prebuffer_filter bitstream imdct
        wma_afh wma_common wmadec_filter buffer_tree crypt_common
        gui gui_theme sideband"
 
@@ -125,7 +125,7 @@ audiod_cmdline_objs="add_cmdline(audiod compress_filter http_recv dccp_recv file
 audiod_errlist_objs="audiod signal string daemon stat net crypt_common sideband
        time grab_client filter_common wav_filter compress_filter amp_filter http_recv dccp_recv
        recv_common fd sched write_common file_write audiod_command fecdec_filter
-       client_common ggo udp_recv color fec prebuffer_filter audiod_command_list
+       client_common ggo udp_recv color fec prebuffer_filter
        bitstream imdct wma_common wmadec_filter buffer_tree"
 audiod_ldflags="-lm"
 audiod_audio_formats="wma"
@@ -269,13 +269,11 @@ else
                string signal time daemon http_send close_on_fork mm
                crypt_common ipc dccp_send fd user_list chunk_queue
                afs aft mood score attribute blob playlist sched acl
-               send_common udp_send color fec server_command_list
-               afs_command_list wma_afh wma_common sideband"
-
+               send_common udp_send color fec wma_afh wma_common sideband"
        all_errlist_objs="$all_errlist_objs server vss command
                http_send close_on_fork mm ipc dccp_send user_list
                chunk_queue afs aft mood score attribute blob playlist
-               acl udp_send server_command_list afs_command_list"
+               acl udp_send"
 
        server_ldflags=""
        server_audio_formats="mp3 wma"
diff --git a/error.h b/error.h
index 3100b31..2474e0a 100644 (file)
--- a/error.h
+++ b/error.h
@@ -29,9 +29,6 @@ DEFINE_ERRLIST_OBJECT_ENUM;
 #define COLOR_ERRORS
 #define SIGNAL_ERRORS
 #define FADE_ERRORS
-#define SERVER_COMMAND_LIST_ERRORS
-#define AFS_COMMAND_LIST_ERRORS
-#define AUDIOD_COMMAND_LIST_ERRORS
 #define STDOUT_ERRORS
 #define FILE_WRITE_ERRORS
 #define STDIN_ERRORS
index 458c7f3..5c5c514 100644 (file)
@@ -158,7 +158,6 @@ void file_write_init(struct writer *w)
        w->parse_config_or_die = file_write_parse_config_or_die;
        w->free_config = file_write_free_config;
        w->close = file_write_close;
-       w->shutdown = NULL; /* nothing to do */
        w->help = (struct ggo_help) {
                .short_help = file_write_args_info_help,
                .detailed_help = file_write_args_info_detailed_help
index 40246f2..e8baa6b 100644 (file)
@@ -234,27 +234,25 @@ static void flacdec_post_select(__a_unused struct sched *s, struct task *t)
                ret = flacdec_init(fn);
                goto out;
        }
-       pfd->unconsumed = 0;
-       for (;;) {
-               if (output_queue_full(btrn)) {
-                       pfd->have_more = true;
-                       break;
-               }
-               pfd->have_more = false;
-               FLAC__StreamDecoderState state;
-               FLAC__stream_decoder_process_single(pfd->decoder);
-               state = FLAC__stream_decoder_get_state(pfd->decoder);
-               //PARA_CRIT_LOG("state: %s\n", FLAC__stream_decoder_get_resolved_state_string(pfd->decoder));
-               ret = -E_FLACDEC_EOF;
-               if (state == FLAC__STREAM_DECODER_END_OF_STREAM)
-                       goto out;
-               if (state == FLAC__STREAM_DECODER_ABORTED) {
-                       FLAC__stream_decoder_flush(pfd->decoder);
-                       fn->min_iqs = pfd->unconsumed + 1;
-                       break;
-               }
-               fn->min_iqs = 0;
+       if (output_queue_full(btrn)) {
+               pfd->have_more = true;
+               ret = 1;
+               goto out;
        }
+       pfd->have_more = false;
+       FLAC__StreamDecoderState state;
+       FLAC__stream_decoder_process_single(pfd->decoder);
+       state = FLAC__stream_decoder_get_state(pfd->decoder);
+       ret = -E_FLACDEC_EOF;
+       if (state == FLAC__STREAM_DECODER_END_OF_STREAM)
+               goto out;
+       if (state == FLAC__STREAM_DECODER_ABORTED) {
+               FLAC__stream_decoder_flush(pfd->decoder);
+               fn->min_iqs = pfd->unconsumed + 1;
+               ret = 1;
+               goto out;
+       }
+       fn->min_iqs = 0;
        ret = 1;
 out:
        t->error = ret;
@@ -264,10 +262,17 @@ out:
 
 static void flacdec_close(struct filter_node *fn)
 {
-       struct private_flacdec_data *pfd = fn->private_data;
+       struct private_flacdec_data *pfd;
 
-       FLAC__stream_decoder_finish(pfd->decoder);
-       FLAC__stream_decoder_delete(pfd->decoder);
+       if (!fn)
+               return;
+       pfd = fn->private_data;
+       if (!pfd)
+               return;
+       if (pfd->decoder) {
+               FLAC__stream_decoder_finish(pfd->decoder);
+               FLAC__stream_decoder_delete(pfd->decoder);
+       }
        free(pfd);
        fn->private_data = NULL;
 }
index 926eb15..aaf97d4 100644 (file)
--- a/gcrypt.c
+++ b/gcrypt.c
@@ -499,7 +499,6 @@ static int get_private_key(const char *key_file, struct asymmetric_key **result)
        ret = read_bignum(cp, end, &u, NULL);
        if (ret < 0)
                goto release_q;
-       cp += ret;
        /*
         * OpenSSL uses slightly different parameters than gcrypt. To use these
         * parameters we need to swap the values of p and q and recompute u.
@@ -574,7 +573,6 @@ static int get_asn_public_key(const char *key_file, struct asymmetric_key **resu
        ret = read_bignum(cp, end, &e, NULL);
        if (ret < 0)
                goto release_n;
-       cp += ret;
 
        gret = gcry_sexp_build(&sexp, &erroff, RSA_PUBKEY_SEXP, n, e);
        if (gret) {
@@ -697,7 +695,6 @@ int get_asymmetric_key(const char *key_file, int private,
        key->num_bytes = ret;
        key->sexp = sexp;
        *result = key;
-       ret = key->num_bytes;
 unmap:
        ret2 = para_munmap(map, map_size);
        if (ret >= 0 && ret2 < 0)
diff --git a/mood.c b/mood.c
index bafe710..e905f92 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -108,12 +108,16 @@ __a_const static uint64_t int_sqrt(uint64_t x)
        return res;
 }
 
-/* returns 1 if row matches score item, 0 if not. */
-static int get_item_score(struct mood_item *item, const struct afs_info *afsi,
+/*
+ * Returns true if row matches, false if it does not match. In any case score
+ * and score_arg_sum are set/increased accordingly.
+ */
+static bool get_item_score(struct mood_item *item, const struct afs_info *afsi,
                const struct afh_info *afhi, const char *path, long *score,
                long *score_arg_sum)
 {
-       int ret, match = 1;
+       int ret;
+       bool match = true;
 
        *score_arg_sum += item->random_score? 100 : PARA_ABS(item->score_arg);
        ret = 100;
@@ -121,7 +125,7 @@ static int get_item_score(struct mood_item *item, const struct afs_info *afsi,
                ret = item->method->score_function(path, afsi, afhi,
                        item->parser_data);
                if ((ret < 0 && !item->logical_not) || (ret >= 0 && item->logical_not))
-                       match = 0; /* no match */
+                       match = false;
        }
        if (item->random_score)
                *score = PARA_ABS(ret) * para_random(100);
@@ -135,7 +139,8 @@ static int compute_mood_score(const struct osl_row *aft_row, struct mood *m,
                long *result)
 {
        struct mood_item *item;
-       int ret, match = 0;
+       int ret;
+       bool match;
        long score_arg_sum = 0, score = 0, item_score;
        struct afs_info afsi;
        struct afh_info afhi;
@@ -154,27 +159,29 @@ static int compute_mood_score(const struct osl_row *aft_row, struct mood *m,
                return ret;
        /* reject audio file if it matches any entry in the deny list */
        list_for_each_entry(item, &m->deny_list, mood_item_node) {
-               ret = get_item_score(item, &afsi, &afhi, path, &item_score,
+               match = get_item_score(item, &afsi, &afhi, path, &item_score,
                        &score_arg_sum);
-               if (ret > 0) /* not admissible */
+               if (match) /* not admissible */
                        return 0;
                score += item_score;
        }
+       match = false;
        list_for_each_entry(item, &m->accept_list, mood_item_node) {
                ret = get_item_score(item, &afsi, &afhi, path, &item_score,
                        &score_arg_sum);
                if (ret == 0)
                        continue;
-               match = 1;
+               match = true;
                score += item_score;
        }
        /* reject if there is no matching entry in the accept list */
        if (!match && !list_empty(&m->accept_list))
                return 0;
        list_for_each_entry(item, &m->score_list, mood_item_node) {
-               ret = get_item_score(item, &afsi, &afhi, path, &item_score,
+               match = get_item_score(item, &afsi, &afhi, path, &item_score,
                        &score_arg_sum);
-               score += item_score;
+               if (match)
+                       score += item_score;
        }
        if (score_arg_sum)
                score /= score_arg_sum;
index 4bdbc6f..6955a74 100644 (file)
@@ -130,7 +130,7 @@ decode:
                ret = handle_decode_error(pmd);
                if (ret < 0)
                        goto err;
-               ret = mad_stream_sync(&pmd->stream);
+               mad_stream_sync(&pmd->stream);
                if (pmd->stream.error == MAD_ERROR_BUFLEN) {
                        ret = -E_MP3DEC_EOF;
                        if (len == iqs && btr_no_parent(btrn))
index 79716a3..9498313 100644 (file)
@@ -208,10 +208,16 @@ static void ogg_post_select(__a_unused struct sched *s, struct task *t)
        char *buf;
 
        ret = btr_node_status(btrn, fn->min_iqs, BTR_NT_INTERNAL);
-       if (ret < 0 && ret != -E_BTR_EOF) /* fatal error */
-               goto out;
-       if (ret <= 0 && !pod->have_more) /* nothing to do */
+       if (ret < 0) {
+               if (ret != -E_BTR_EOF) /* fatal error */
+                       goto out;
+               if (fn->min_iqs == 0 && !pod->have_more) /* EOF */
+                       goto out;
+               /* last ov_read() returned OV_HOLE */
+       } else if (ret == 0 && !pod->have_more) /* nothing to do */
                goto out;
+       if (btr_get_output_queue_size(btrn) > OGGDEC_MAX_OUTPUT_SIZE)
+               return;
        if (!pod->vf) {
                if (ret <= 0)
                        goto out;
@@ -239,9 +245,11 @@ static void ogg_post_select(__a_unused struct sched *s, struct task *t)
                have = 0;
        }
        pod->have_more = (ret > 0);
-       if (have > 0)
+       if (have > 0) {
+               if (have < OGGDEC_OUTPUT_CHUNK_SIZE)
+                       buf = para_realloc(buf, have);
                btr_add_output(buf, have, btrn);
-       else
+       else
                free(buf);
        if (ret == OV_HOLE) /* avoid buffer underruns */
                fn->min_iqs = 9000;
index f1e9019..eae4167 100644 (file)
@@ -233,7 +233,6 @@ void oss_write_init(struct writer *w)
        w->post_select = oss_post_select;
        w->parse_config_or_die = oss_parse_config_or_die;
        w->free_config = oss_free_config;
-       w->shutdown = NULL;
        w->help = (struct ggo_help) {
                .short_help = oss_write_args_info_help,
                .detailed_help = oss_write_args_info_detailed_help
index edb9f92..0f9d960 100644 (file)
@@ -333,7 +333,6 @@ void osx_write_init(struct writer *w)
        w->post_select = osx_write_post_select;
        w->parse_config_or_die = osx_write_parse_config_or_die;
        w->free_config = osx_free_config;
-       w->shutdown = NULL; /* nothing to do */
        w->help = (struct ggo_help) {
                .short_help = osx_write_args_info_help,
                .detailed_help = osx_write_args_info_detailed_help
index d0e8f27..83097f1 100644 (file)
@@ -1,10 +1,5 @@
-OF: server_command_list
+BN: server
 SF: command.c
-HC: prototypes for the server command handlers
-CC: array of server commands
-AT: server_command
-SI: osl regex
-IN: para error crypt sideband command string afh afs server list user_list
 SN: list of server commands
 ---
 N: ff
index be72610..e58754f 100644 (file)
@@ -1214,11 +1214,11 @@ static int wmadec_execute(struct btr_node *btrn, const char *cmd, char **result)
 static void wmadec_post_select(__a_unused struct sched *s, struct task *t)
 {
        struct filter_node *fn = container_of(t, struct filter_node, task);
-       int ret, converted;
+       int ret, converted, out_size;
        struct private_wmadec_data *pwd = fn->private_data;
        struct btr_node *btrn = fn->btrn;
        size_t len;
-       char *in;
+       char *in, *out;
 
 next_buffer:
        converted = 0;
@@ -1247,22 +1247,20 @@ next_buffer:
                goto success;
        }
        fn->min_iqs = WMA_FRAME_SKIP + pwd->ahi.block_align;
-       for (;;) {
-               char *out;
-               int out_size = WMA_OUTPUT_BUFFER_SIZE;
-               if (converted + fn->min_iqs > len)
-                       break;
-               out = para_malloc(WMA_OUTPUT_BUFFER_SIZE);
-               ret = wma_decode_superframe(pwd, out,
-                       &out_size, (uint8_t *)in + converted + WMA_FRAME_SKIP,
-                       len - WMA_FRAME_SKIP);
-               if (ret < 0) {
-                       free(out);
-                       goto err;
-               }
-               btr_add_output(out, out_size, btrn);
-               converted += ret + WMA_FRAME_SKIP;
+       if (fn->min_iqs > len)
+               goto success;
+       out_size = WMA_OUTPUT_BUFFER_SIZE;
+       out = para_malloc(out_size);
+       ret = wma_decode_superframe(pwd, out, &out_size,
+               (uint8_t *)in + WMA_FRAME_SKIP, len - WMA_FRAME_SKIP);
+       if (ret < 0) {
+               free(out);
+               goto err;
        }
+       out = para_realloc(out, out_size);
+       if (out_size > 0)
+               btr_add_output(out, out_size, btrn);
+       converted += ret + WMA_FRAME_SKIP;
 success:
        btr_consume(btrn, converted);
        return;
diff --git a/write.h b/write.h
index 56a9711..ddf43b6 100644 (file)
--- a/write.h
+++ b/write.h
@@ -72,12 +72,6 @@ struct writer {
         * This function is assumed to succeed.
         */
        void (*close)(struct writer_node *);
-       /**
-        * Shutdown the writer.
-        *
-        * This is a optional function pointer used for cleaning up.
-        */
-       void (*shutdown)(struct writer_node *);
        /** The short and the log help text of this writer. */
        struct ggo_help help;
        /**