Add hack to make the flac plugin compile with both flac-1.0.2 and 1.0.3
authorDavid Schleef <ds@schleef.org>
Wed, 18 Sep 2002 20:56:42 +0000 (20:56 +0000)
committerDavid Schleef <ds@schleef.org>
Wed, 18 Sep 2002 20:56:42 +0000 (20:56 +0000)
Original commit message from CVS:
Add hack to make the flac plugin compile with both flac-1.0.2 and
1.0.3

ext/flac/Makefile.am
ext/flac/flac_compat.h [new file with mode: 0644]
ext/flac/gstflac.c
ext/flac/gstflacdec.c
ext/flac/gstflacenc.c

index 31922cfa01d6c0842819f2f34984e5dff37f52b1..01bfb3f20940b855eb179d4dd2b56d4e511949de 100644 (file)
@@ -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 (file)
index 0000000..ca3e4d9
--- /dev/null
@@ -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 <FLAC/all.h>
+
+/* 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
+
index efd184774d22941a22ed70e2f945189a924e4809..4d75caf17e1bbab7b5b43576ec37c0e65240c27a 100644 (file)
@@ -21,6 +21,8 @@
 #include "gstflacenc.h"
 #include "gstflacdec.h"
 
+#include "flac_compat.h"
+
 extern GstElementDetails flacenc_details;
 extern GstElementDetails flacdec_details;
 
index 6d1ec06732d0e945072572bd37f520d49daa195d..09e53041df5c696b855c1f2aaf8be96b0214149c 100644 (file)
@@ -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);
index 448bcdc4756da75b9d3b3fe1ac0326229a3d4d38..a4681f2de041d788b3b41c95aea82d11a346acb1 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <gstflacenc.h>
 
+#include "flac_compat.h"
+
 extern GstPadTemplate *gst_flacenc_src_template, *gst_flacenc_sink_template;
 
 /* elementfactory information */