From: Andre Noll Date: Sun, 31 Jul 2011 22:39:54 +0000 (+0200) Subject: Initial support for FLAC (the free lossless audio codec). X-Git-Tag: v0.4.9~2^2~3 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=c9a877508a65ae272980383682aa5338f87cd2dd;p=paraslash.git Initial support for FLAC (the free lossless audio codec). This adds tests for flac headers and libraries to configure.ac and adds configure options to override the default location of these files. Moreover, a (non-working) implementation of the flac audio format handler and the flac decoder are introduced. All new functions are defined as empty dummies to be filled with content in subsequent commits. --- diff --git a/afh_common.c b/afh_common.c index 44a6fd62..1228c0d8 100644 --- a/afh_common.c +++ b/afh_common.c @@ -28,6 +28,9 @@ void mp3_init(struct audio_format_handler *); #ifdef HAVE_SPEEX void spx_afh_init(struct audio_format_handler *); #endif +#ifdef HAVE_FLAC + void flac_afh_init(struct audio_format_handler *); +#endif void wma_afh_init(struct audio_format_handler *); /** @@ -67,6 +70,12 @@ static struct audio_format_handler afl[] = { .name = "spx", #ifdef HAVE_SPEEX .init = spx_afh_init, +#endif + }, + { + .name = "flac", +#ifdef HAVE_FLAC + .init = flac_afh_init, #endif }, { diff --git a/configure.ac b/configure.ac index 6415668b..a2e5fed1 100644 --- a/configure.ac +++ b/configure.ac @@ -729,6 +729,47 @@ if test ${have_libid3tag} = yes; then else AC_MSG_WARN([no support for id3v2 tags]) fi +########################################################################### flac +OLD_CPPFLAGS="$CPPFLAGS" +OLD_LD_FLAGS="$LDFLAGS" +OLD_LIBS="$LIBS" + +have_flac="yes" +AC_ARG_WITH(flac_headers, [AC_HELP_STRING(--with-flac-headers=dir, + [look for flac headers also in dir])]) +if test -n "$with_flac_headers"; then + flac_cppflags="-I$with_flac_headers" + CPPFLAGS="$CPPFLAGS $flac_cppflags" +fi +AC_ARG_WITH(flac_libs, [AC_HELP_STRING(--with-flac-libs=dir, + [look for flac libs also in dir])]) +if test -n "$with_flac_libs"; then + flac_libs="-L$with_flac_libs" + LDFLAGS="$LDFLAGS $flac_libs" +fi +AC_CHECK_HEADER(FLAC/stream_decoder.h, [], have_flac=no) +AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], have_flac=no) +if test "$have_flac" = "yes"; then + AC_DEFINE(HAVE_FLAC, 1, define to 1 if you want to build the flacdec filter) + all_errlist_objs="$all_errlist_objs flacdec_filter flac_afh" + filter_errlist_objs="$filter_errlist_objs flacdec_filter" + audiod_errlist_objs="$audiod_errlist_objs flacdec_filter" + afh_errlist_objs="$afh_errlist_objs flac_afh" + server_errlist_objs="$server_errlist_objs flac_afh" + filter_ldflags="$filter_ldflags $flac_libs -lFLAC" + audiod_ldflags="$audiod_ldflags $flac_libs -lFLAC" + server_ldflags="$server_ldflags $flac_libs -lFLAC" + afh_ldflags="$afh_ldflags $flac_libs -lFLAC" + filters="$filters flacdec" + server_audio_formats="$server_audio_formats flac" + audiod_audio_formats="$audiod_audio_formats flac" + AC_SUBST(flac_cppflags) +else + AC_MSG_WARN([no flac support in para_audiod/para_filter]) +fi +CPPFLAGS="$OLD_CPPFLAGS" +LDFLAGS="$OLD_LDFLAGS" +LIBS="$OLD_LIBS" ########################################################################### oss OLD_CPPFLAGS="$CPPFLAGS" OLD_LD_FLAGS="$LDFLAGS" diff --git a/error.h b/error.h index b3eb7e6e..e2e245c9 100644 --- a/error.h +++ b/error.h @@ -35,6 +35,8 @@ DEFINE_ERRLIST_OBJECT_ENUM; #define FILE_WRITE_ERRORS #define STDIN_ERRORS #define WRITE_ERRORS +#define FLACDEC_FILTER_ERRORS +#define FLAC_AFH_ERRORS extern const char **para_errlist[]; diff --git a/flac_afh.c b/flac_afh.c new file mode 100644 index 00000000..4ac68cdc --- /dev/null +++ b/flac_afh.c @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2011 Andre Noll + * + * Licensed under the GPL v2. For licencing details see COPYING. + */ + +/** \file flac_afh.c Audio format handler for flac files. */ + +#include + +#include "para.h" +#include "error.h" +#include "afh.h" + +static int flac_get_file_info(char *map, size_t numbytes, __a_unused int fd, + struct afh_info *afhi) +{ + return 0; +} + +static const char* flac_suffixes[] = {"flac", NULL}; + +/** + * The init function of the flac audio format handler. + * + * \param afh pointer to the struct to initialize + */ +void flac_afh_init(struct audio_format_handler *afh) +{ + afh->get_file_info = flac_get_file_info, + afh->suffixes = flac_suffixes; +} diff --git a/flacdec_filter.c b/flacdec_filter.c new file mode 100644 index 00000000..40795023 --- /dev/null +++ b/flacdec_filter.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2011 Andre Noll + * + * Licensed under the GPL v2. For licencing details see COPYING. + */ + +/** \file flacdec_filter.c The flac decoder. */ + +#include +#include + +#include "para.h" +#include "list.h" +#include "sched.h" +#include "ggo.h" +#include "buffer_tree.h" +#include "filter.h" +#include "error.h" +#include "string.h" +static int flacdec_execute(struct btr_node *btrn, const char *cmd, + char **result) +{ + return 0; +} + +static void flacdec_post_select(__a_unused struct sched *s, struct task *t) +{ + +} + +static void flacdec_close(struct filter_node *fn) +{ + +} + +static void flacdec_open(struct filter_node *fn) +{ + +} +/** + * The init function of the flacdec filter. + * + * \param f Pointer to the filter struct to initialize. + * + * \sa filter::init. + */ +void flacdec_filter_init(struct filter *f) +{ + f->open = flacdec_open; + f->close = flacdec_close; + f->pre_select = generic_filter_pre_select; + f->post_select = flacdec_post_select; + f->execute = flacdec_execute; +}