diff --git a/ext/flac/Makefile.am b/ext/flac/Makefile.am index 31922cfa01..01bfb3f209 100644 --- a/ext/flac/Makefile.am +++ b/ext/flac/Makefile.am @@ -7,4 +7,4 @@ libgstflac_la_CFLAGS = $(GST_CFLAGS) libgstflac_la_LIBADD = $(FLAC_LIBS) libgstflac_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -noinst_HEADERS = gstflacenc.h gstflacdec.h +noinst_HEADERS = gstflacenc.h gstflacdec.h flac_compat.h diff --git a/ext/flac/flac_compat.h b/ext/flac/flac_compat.h new file mode 100644 index 0000000000..ca3e4d9684 --- /dev/null +++ b/ext/flac/flac_compat.h @@ -0,0 +1,42 @@ + +/* This file is an attempt to hack compatibility between the + * FLAC API version used in the code in this directory + * (currently 1.0.3) and older versions of FLAC, particularly + * 1.0.2. + */ + +#ifndef _FLAC_COMPAT_H_ +#define _FLAC_COMPAT_H_ + +#include + +/* FIXME when there's a autoconf symbol */ +#ifndef FLAC_VERSION + +#ifdef FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE +#define FLAC_VERSION 0x010003 +#else +#define FLAC_VERSION 0x010002 +#endif + +#endif /* !defined(FLAC_VERSION) */ + +#if FLAC_VERSION < 0x010003 + +#define FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC \ + FLAC__STREAM_DECODER_ERROR_LOST_SYNC +#define FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER \ + FLAC__STREAM_DECODER_ERROR_BAD_HEADER +#define FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH \ + FLAC__STREAM_DECODER_ERROR_FRAME_CRC_MISMATCH +#define FLAC__STREAM_DECODER_WRITE_STATUS_ABORT \ + FLAC__STREAM_DECODER_WRITE_ABORT +#define FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE \ + FLAC__STREAM_DECODER_WRITE_CONTINUE + +#define FLAC__StreamMetadata FLAC__StreamMetaData + +#endif /* FLAC_VERSION < 0x010003 */ + +#endif + diff --git a/ext/flac/gstflac.c b/ext/flac/gstflac.c index efd184774d..4d75caf17e 100644 --- a/ext/flac/gstflac.c +++ b/ext/flac/gstflac.c @@ -21,6 +21,8 @@ #include "gstflacenc.h" #include "gstflacdec.h" +#include "flac_compat.h" + extern GstElementDetails flacenc_details; extern GstElementDetails flacdec_details; diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index 6d1ec06732..09e53041df 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -23,6 +23,7 @@ /*#define DEBUG_ENABLED */ #include "gstflacdec.h" +#include "flac_compat.h" extern GstPadTemplate *gst_flacdec_src_template, *gst_flacdec_sink_template; @@ -155,7 +156,17 @@ gst_flacdec_init (FlacDec *flacdec) FLAC__seekable_stream_decoder_set_tell_callback (flacdec->decoder, gst_flacdec_tell); FLAC__seekable_stream_decoder_set_length_callback (flacdec->decoder, gst_flacdec_length); FLAC__seekable_stream_decoder_set_eof_callback (flacdec->decoder, gst_flacdec_eof); +#if FLAC_VERSION >= 0x010003 FLAC__seekable_stream_decoder_set_write_callback (flacdec->decoder, gst_flacdec_write); +#else + FLAC__seekable_stream_decoder_set_write_callback (flacdec->decoder, + (FLAC__StreamDecoderWriteStatus (*) + (const FLAC__SeekableStreamDecoder *decoder, + const FLAC__Frame *frame, + const FLAC__int32 *buffer[], + void *client_data)) + (gst_flacdec_write)); +#endif FLAC__seekable_stream_decoder_set_metadata_callback (flacdec->decoder, gst_flacdec_metadata_callback); FLAC__seekable_stream_decoder_set_error_callback (flacdec->decoder, gst_flacdec_error_callback); FLAC__seekable_stream_decoder_set_client_data (flacdec->decoder, flacdec); diff --git a/ext/flac/gstflacenc.c b/ext/flac/gstflacenc.c index 448bcdc475..a4681f2de0 100644 --- a/ext/flac/gstflacenc.c +++ b/ext/flac/gstflacenc.c @@ -23,6 +23,8 @@ #include +#include "flac_compat.h" + extern GstPadTemplate *gst_flacenc_src_template, *gst_flacenc_sink_template; /* elementfactory information */