Diffstat (limited to 'core/multimedia/opieplayer/libmad/decoder.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/decoder.c | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/core/multimedia/opieplayer/libmad/decoder.c b/core/multimedia/opieplayer/libmad/decoder.c index dcf7cf3..b2b6cbb 100644 --- a/core/multimedia/opieplayer/libmad/decoder.c +++ b/core/multimedia/opieplayer/libmad/decoder.c @@ -1,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -21,17 +21,12 @@ # ifdef HAVE_CONFIG_H -# include "libmad_config.h" -# else -# ifndef WEXITSTATUS -# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) -# endif -# ifndef WIFEXITED -# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) -# endif +# include "libmad_config.h" # endif # include "libmad_global.h" -# include <sys/types.h> +# ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +# endif # ifdef HAVE_SYS_WAIT_H @@ -43,7 +38,13 @@ # endif -# include <fcntl.h> +# ifdef HAVE_FCNTL_H +# include <fcntl.h> +# endif + # include <stdlib.h> -# include <errno.h> + +# ifdef HAVE_ERRNO_H +# include <errno.h> +# endif # include "stream.h" @@ -53,12 +54,16 @@ void mad_decoder_init(struct mad_decoder *decoder, void *data, - enum mad_flow (*input_func)(void *, struct mad_stream *), + enum mad_flow (*input_func)(void *, + struct mad_stream *), enum mad_flow (*header_func)(void *, struct mad_header const *), - enum mad_flow (*filter_func)(void *, struct mad_frame *), + enum mad_flow (*filter_func)(void *, + struct mad_stream const *, + struct mad_frame *), enum mad_flow (*output_func)(void *, struct mad_header const *, struct mad_pcm *), - enum mad_flow (*error_func)(void *, struct mad_stream *, + enum mad_flow (*error_func)(void *, + struct mad_stream *, struct mad_frame *), enum mad_flow (*message_func)(void *, @@ -87,4 +92,5 @@ void mad_decoder_init(struct mad_decoder *decoder, void *data, int mad_decoder_finish(struct mad_decoder *decoder) { +# if defined(USE_ASYNC) if (decoder->mode == MAD_DECODER_MODE_ASYNC && decoder->async.pid) { pid_t pid; @@ -93,7 +99,6 @@ int mad_decoder_finish(struct mad_decoder *decoder) close(decoder->async.in); - do { + do pid = waitpid(decoder->async.pid, &status, 0); - } while (pid == -1 && errno == EINTR); @@ -111,8 +116,10 @@ int mad_decoder_finish(struct mad_decoder *decoder) return (!WIFEXITED(status) || WEXITSTATUS(status)) ? -1 : 0; } +# endif return 0; } +# if defined(USE_ASYNC) static enum mad_flow send_io(int fd, void const *data, size_t len) @@ -122,7 +129,6 @@ enum mad_flow send_io(int fd, void const *data, size_t len) while (len) { - do { + do count = write(fd, ptr, len); - } while (count == -1 && errno == EINTR); @@ -144,7 +150,6 @@ enum mad_flow receive_io(int fd, void *buffer, size_t len) while (len) { - do { + do count = read(fd, ptr, len); - } while (count == -1 && errno == EINTR); @@ -282,4 +287,5 @@ enum mad_flow check_message(struct mad_decoder *decoder) return result; } +# endif static @@ -349,4 +355,5 @@ int run_sync(struct mad_decoder *decoder) while (1) { +# if defined(USE_ASYNC) if (decoder->mode == MAD_DECODER_MODE_ASYNC) { switch (check_message(decoder)) { @@ -360,4 +367,5 @@ int run_sync(struct mad_decoder *decoder) } } +# endif if (decoder->header_func) { @@ -410,5 +418,5 @@ int run_sync(struct mad_decoder *decoder) if (decoder->filter_func) { - switch (decoder->filter_func(decoder->cb_data, frame)) { + switch (decoder->filter_func(decoder->cb_data, stream, frame)) { case MAD_FLOW_STOP: goto done; @@ -451,4 +459,5 @@ int run_sync(struct mad_decoder *decoder) } +# if defined(USE_ASYNC) static int run_async(struct mad_decoder *decoder) @@ -512,4 +521,5 @@ int run_async(struct mad_decoder *decoder) return -1; } +# endif int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) @@ -524,5 +534,7 @@ int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) case MAD_DECODER_MODE_ASYNC: +# if defined(USE_ASYNC) run = run_async; +# endif break; } @@ -546,4 +558,5 @@ int mad_decoder_message(struct mad_decoder *decoder, void *message, unsigned int *len) { +# if defined(USE_ASYNC) if (decoder->mode != MAD_DECODER_MODE_ASYNC || send(decoder->async.out, message, *len) != MAD_FLOW_CONTINUE || @@ -552,3 +565,6 @@ int mad_decoder_message(struct mad_decoder *decoder, return 0; +# else + return -1; +# endif } |