Initial support for FLAC (the free lossless audio codec).
authorAndre Noll <maan@systemlinux.org>
Sun, 31 Jul 2011 22:39:54 +0000 (00:39 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 13 Nov 2011 13:40:48 +0000 (14:40 +0100)
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.

afh_common.c
configure.ac
error.h
flac_afh.c [new file with mode: 0644]
flacdec_filter.c [new file with mode: 0644]

index 44a6fd6..1228c0d 100644 (file)
@@ -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
        },
        {
index 6415668..a2e5fed 100644 (file)
@@ -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 b3eb7e6..e2e245c 100644 (file)
--- 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 (file)
index 0000000..4ac68cd
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011 Andre Noll <maan@systemlinux.org>
+ *
+ * Licensed under the GPL v2. For licencing details see COPYING.
+ */
+
+/** \file flac_afh.c Audio format handler for flac files. */
+
+#include <regex.h>
+
+#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 (file)
index 0000000..4079502
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 Andre Noll <maan@systemlinux.org>
+ *
+ * Licensed under the GPL v2. For licencing details see COPYING.
+ */
+
+/** \file flacdec_filter.c The flac decoder. */
+
+#include <regex.h>
+#include <stdbool.h>
+
+#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;
+}