SOURCES: vorbis-tools-flac.patch - replaced by changeset (modified...

sls sls at pld-linux.org
Wed Jan 3 23:04:26 CET 2007


Author: sls                          Date: Wed Jan  3 22:04:26 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- replaced by changeset (modified) from svn.xiph.org; with older version
  ogg123 crashes when playing flac files

---- Files affected:
SOURCES:
   vorbis-tools-flac.patch (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/vorbis-tools-flac.patch
diff -u SOURCES/vorbis-tools-flac.patch:1.1 SOURCES/vorbis-tools-flac.patch:1.2
--- SOURCES/vorbis-tools-flac.patch:1.1	Sun Dec 31 21:20:37 2006
+++ SOURCES/vorbis-tools-flac.patch	Wed Jan  3 23:04:21 2007
@@ -1,59 +1,109 @@
---- vorbis-tools-1.1.1/configure.ac.orig	2006-12-31 15:14:32.873133000 +0100
-+++ vorbis-tools-1.1.1/configure.ac	2006-12-31 15:29:42.540972076 +0100
-@@ -122,9 +122,9 @@
-     AC_MSG_WARN([libFLAC missing])
-     have_libFLAC=no, [$FLAC_LIBS]
-   )
+Index: trunk/vorbis-tools/configure.ac
+===================================================================
+--- trunk/vorbis-tools/configure.ac (revision 12197)
++++ trunk/vorbis-tools/configure.ac (revision 12199)
+@@ -173,17 +173,33 @@
+ 
+ FLAC_LIBS=""
+ if test "x$build_flac" = xyes; then
++
+   AC_CHECK_LIB(m,log,FLAC_LIBS="-lm")
+-  AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_process_single],
+-    [have_libFLAC=yes; FLAC_LIBS="-lFLAC $FLAC_LIBS"],
+-    AC_MSG_WARN([libFLAC missing])
+-    have_libFLAC=no, [$FLAC_LIBS]
+-  )
 -  AC_CHECK_LIB(OggFLAC, [OggFLAC__stream_decoder_new],
 -    [FLAC_LIBS="-lOggFLAC $FLAC_LIBS $OGG_LIBS"],
 -    AC_MSG_WARN([libOggFLAC missing])
+-    have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS]
+-  )
++
++  dnl First check for libFLAC-1.1.3 or later. As of libFLAC 1.1.3,
++  dnl OggFLAC functionality has been rolled into libFLAC rather
++  dnl than being in a separate libOggFLAC library.
++
 +  AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_init_ogg_stream],
-+    [true],
-+    AC_MSG_WARN([Ogg support in libFLAC missing])
-     have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS]
-   )
++    have_libFLAC=yes, have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS])
++
++  if test "x$have_libFLAC" = xyes; then
++    FLAC_LIBS="-lFLAC $FLAC_LIBS $OGG_LIBS"
++  else
++    dnl Check for libFLAC prior to 1.1.3
++    AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_process_single],
++      [have_libFLAC=yes; FLAC_LIBS="-lFLAC $FLAC_LIBS"],
++      AC_MSG_WARN([libFLAC missing])
++      have_libFLAC=no, [$FLAC_LIBS]
++    )
++
++    AC_CHECK_LIB(OggFLAC, [OggFLAC__stream_decoder_new],
++      [FLAC_LIBS="-lOggFLAC $FLAC_LIBS $OGG_LIBS"],
++      AC_MSG_WARN([libOggFLAC missing])
++      have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS]
++    )
++  fi
++
    AC_CHECK_HEADER(FLAC/stream_decoder.h,,
---- vorbis-tools-1.1.1/ogg123/Makefile.am.orig	2005-06-13 15:11:44.000000000 +0200
-+++ vorbis-tools-1.1.1/ogg123/Makefile.am	2006-12-31 20:59:20.128032533 +0100
-@@ -1,6 +1,6 @@
- ## Process this file with automake to produce Makefile.in
- if HAVE_LIBFLAC
--flac_sources = flac_format.c easyflac.c easyflac.h 
-+flac_sources = flac_format.c
- else
- flac_sources =
- endif
---- vorbis-tools-1.1.1/ogg123/flac_format.c.orig	2005-06-03 12:15:09.000000000 +0200
-+++ vorbis-tools-1.1.1/ogg123/flac_format.c	2006-12-31 21:13:50.193614744 +0100
-@@ -21,17 +21,17 @@
+     AC_MSG_WARN(libFLAC headers missing)
+     have_libFLAC=no,[ ])
+Index: trunk/vorbis-tools/ogg123/easyflac.c
+===================================================================
+--- trunk/vorbis-tools/ogg123/easyflac.c (revision 12185)
++++ trunk/vorbis-tools/ogg123/easyflac.c (revision 12199)
+@@ -37,9 +37,11 @@
+ #include <config.h>
+ #endif
+ 
++#include <FLAC/export.h>
++#if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8)
++
+ #include <stdlib.h>
+ #include "easyflac.h"
+-
+ 
+ FLAC__bool EasyFLAC__is_oggflac(EasyFLAC__StreamDecoder *decoder)
+ {
+@@ -377,3 +379,5 @@
+ 	else
+ 		return FLAC__stream_decoder_process_until_end_of_stream(decoder->flac);
+ }
++
++#endif
+Index: trunk/vorbis-tools/ogg123/flac_format.c
+===================================================================
+--- trunk/vorbis-tools/ogg123/flac_format.c (revision 12185)
++++ trunk/vorbis-tools/ogg123/flac_format.c (revision 12199)
+@@ -24,18 +24,26 @@
+ #include <string.h>
  #include <sys/types.h>
  #include <math.h>
- #include <FLAC/metadata.h>
-+#include <FLAC/stream_decoder.h>
+-#include <FLAC/metadata.h>
++#include <FLAC/all.h>
  #include <ao/ao.h>
  #include "audio.h"
  #include "format.h"
  #include "i18n.h"
--#include "easyflac.h"
++#if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8)
++#define NEED_EASYFLAC 1
++#endif
++#if NEED_EASYFLAC
+ #include "easyflac.h"
++#endif
  #include "vorbis_comments.h"
  
- #define DEFAULT_FLAC_FRAME_SIZE 4608
- 
+-#define DEFAULT_FLAC_FRAME_SIZE 4608
+-
  typedef struct {
--  EasyFLAC__StreamDecoder *decoder;
++#if NEED_EASYFLAC
+   EasyFLAC__StreamDecoder *decoder;
++#else
 +  FLAC__StreamDecoder *decoder;
++  int is_oggflac;
++#endif
    short channels;
    int rate;
    int bits_per_sample;
-@@ -58,6 +58,7 @@
-   int buf_fill; /* Number of bytes of audio data in buffer */
- 
-   decoder_stats_t stats;
-+  format_t *format;
-   
- } flac_private_t;
- 
-@@ -67,10 +68,10 @@
+@@ -71,10 +79,18 @@
  
  
  /* Private functions declarations */
@@ -61,293 +111,419 @@
 -FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
 -void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
 -void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-+FLAC__StreamDecoderReadStatus flac_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
-+FLAC__StreamDecoderWriteStatus flac_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-+void flac_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
-+void flac_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
++#if NEED_EASYFLAC
++static FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
++static FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
++static void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
++static void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
++#else
++static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
++static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
++static void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
++static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
++static FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data);
++#endif
  
  void resize_buffer(flac_private_t *flac, int newchannels, int newsamples);
  /*void copy_comments (vorbis_comment *v_comments, FLAC__StreamMetadata_VorbisComment *f_comments);*/
-@@ -154,31 +155,42 @@
-   private->buf_fill = 0;
+@@ -170,6 +186,7 @@
    private->buf_start = 0;
    
+   /* Setup FLAC decoder */
++#if NEED_EASYFLAC
+   if (oggflac_can_decode(source)) {
+     decoder->format = &oggflac_format;
+     private->decoder = EasyFLAC__stream_decoder_new(1);
+@@ -187,13 +204,40 @@
+   EasyFLAC__set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_STREAMINFO);
+   EasyFLAC__set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
+   EasyFLAC__init(private->decoder);
++#else
++  if (oggflac_can_decode(source)) {
++    private->is_oggflac = 1;
++    decoder->format = &oggflac_format;
++  } else {
++    private->is_oggflac = 0;
++    decoder->format = &flac_format;
++  }
 +  private->decoder = FLAC__stream_decoder_new();
++
++  FLAC__stream_decoder_set_md5_checking(private->decoder, false);
 +  FLAC__stream_decoder_set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_STREAMINFO);
 +  FLAC__stream_decoder_set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
-   /* Setup FLAC decoder */
-   if (oggflac_can_decode(source)) {
--    decoder->format = &oggflac_format;
--    private->decoder = EasyFLAC__stream_decoder_new(1);
-+    private->format = &oggflac_format;
-+    FLAC__stream_decoder_init_ogg_stream(private->decoder,
-+      flac_read_callback,
-+      NULL,
-+      NULL,
-+      NULL,
-+      NULL,
-+      flac_write_callback,
-+      flac_metadata_callback,
-+      flac_error_callback,
-+      private);
-   } else {
--    decoder->format = &flac_format;
--    private->decoder = EasyFLAC__stream_decoder_new(0);
-+    private->format = &flac_format;
-+    FLAC__stream_decoder_init_stream(private->decoder,
-+      flac_read_callback,
-+      NULL,
-+      NULL,
-+      NULL,
-+      NULL,
-+      flac_write_callback,
-+      flac_metadata_callback,
-+      flac_error_callback,
-+      private);
-   }
- 
--
--  EasyFLAC__set_client_data(private->decoder, decoder);
--  EasyFLAC__set_read_callback(private->decoder, &easyflac_read_callback);
--  EasyFLAC__set_write_callback(private->decoder, &easyflac_write_callback);
--  EasyFLAC__set_metadata_callback(private->decoder, &easyflac_metadata_callback);
--  EasyFLAC__set_error_callback(private->decoder, &easyflac_error_callback);
--  EasyFLAC__set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_STREAMINFO);
--  EasyFLAC__set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
--  EasyFLAC__init(private->decoder);
--  
++  /*FLAC__stream_decoder_init(private->decoder);*/
++  if(private->is_oggflac)
++    FLAC__stream_decoder_init_ogg_stream(private->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, decoder);
++  else
++    FLAC__stream_decoder_init_stream(private->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, decoder);
++#endif
+   
    /* Callback will set the total samples and sample rate */
--  EasyFLAC__process_until_end_of_metadata(private->decoder);
++#if NEED_EASYFLAC
+   EasyFLAC__process_until_end_of_metadata(private->decoder);
++#else
 +  FLAC__stream_decoder_process_until_end_of_metadata(private->decoder);
++#endif
  
    /* Callback will set the number of channels and resize the 
       audio buffer */
--  EasyFLAC__process_single(private->decoder);
++#if NEED_EASYFLAC
+   EasyFLAC__process_single(private->decoder);
++#else
 +  FLAC__stream_decoder_process_single(private->decoder);
++#endif
  
    /* FLAC API returns signed samples on all streams */
    decoder->actual_fmt.signed_sample = 1;
-@@ -241,9 +253,9 @@
+@@ -288,11 +288,11 @@
+       if (audio_fmt->word_size == 1) {
+ 	for (i = 0; i < priv->channels; i++)
+ 	  for (j = 0; j < copy; j++)
+-	    buf8[(j+realsamples)*2+i] = (FLAC__int8) (0xFF & priv->buf[i][j+priv->buf_start]);
++           buf8[(j+realsamples)*audio_fmt->channels+i] = (FLAC__int8) (0xFF & priv->buf[i][j+priv->buf_start]);
+       } else if (audio_fmt->word_size == 2) {
+ 	for (i = 0; i < priv->channels; i++)
+ 	  for (j = 0; j < copy; j++)
+-	    buf16[(j+realsamples)*2+i] = (FLAC__int16) (0xFFFF & priv->buf[i][j+priv->buf_start]);
++           buf16[(j+realsamples)*audio_fmt->channels+i] = (FLAC__int16) (0xFFFF & priv->buf[i][j+priv->buf_start]);
+       }	
+ 
+       priv->buf_start += copy;
+@@ -256,11 +300,19 @@
        realsamples += copy;
      }
      else if (!priv->eos) {
--      ret = EasyFLAC__process_single(priv->decoder);
-+      ret = FLAC__stream_decoder_process_single(priv->decoder);
++#if NEED_EASYFLAC
+       ret = EasyFLAC__process_single(priv->decoder);
        if (!ret ||
--	  EasyFLAC__get_state(priv->decoder)
-+	  FLAC__stream_decoder_get_state(priv->decoder)
+ 	  EasyFLAC__get_state(priv->decoder)
  	  == FLAC__STREAM_DECODER_END_OF_STREAM)
  	priv->eos = 1;  /* Bail out! */
++#else
++      ret = FLAC__stream_decoder_process_single(priv->decoder);
++      if (!ret ||
++	  FLAC__stream_decoder_get_state(priv->decoder)
++	  == FLAC__STREAM_DECODER_END_OF_STREAM)
++	priv->eos = 1;  /* Bail out! */
++#endif
      } else
-@@ -311,8 +323,8 @@
+       break;
+   }
+@@ -326,8 +378,13 @@
      free(priv->buf[i]);
    
    free(priv->buf);
--  EasyFLAC__finish(priv->decoder);
--  EasyFLAC__stream_decoder_delete(priv->decoder);
++#if NEED_EASYFLAC
+   EasyFLAC__finish(priv->decoder);
+   EasyFLAC__stream_decoder_delete(priv->decoder);
++#else
 +  FLAC__stream_decoder_finish(priv->decoder);
 +  FLAC__stream_decoder_delete(priv->decoder);
++#endif
  
    free(decoder->private);
    free(decoder);
-@@ -342,7 +354,7 @@
+@@ -357,7 +414,11 @@
  
  
  
--FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data)
-+FLAC__StreamDecoderReadStatus flac_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data)
++#if NEED_EASYFLAC
+ FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data)
++#else
++FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
++#endif
  {
    decoder_t *e_decoder = client_data;
    flac_private_t *priv = e_decoder->private;
-@@ -363,7 +375,7 @@
+@@ -378,7 +439,11 @@
  }
  
  
--FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
-+FLAC__StreamDecoderWriteStatus flac_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
++#if NEED_EASYFLAC
+ FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
++#else
++FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
++#endif
  {
    decoder_t *e_decoder = client_data;
    flac_private_t *priv = e_decoder->private;
-@@ -389,7 +401,7 @@
+@@ -404,7 +469,11 @@
  }
  
  
--void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
-+void flac_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
++#if NEED_EASYFLAC
+ void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
++#else
++void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
++#endif
  {
    decoder_t *e_decoder = client_data;
    flac_private_t *priv = e_decoder->private;
-@@ -409,7 +421,7 @@
+@@ -424,11 +493,25 @@
  }
  
  
--void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
-+void flac_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
- {
++#if NEED_EASYFLAC
+ void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
+-{
+-
+-
+-}
++#else
++void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
++#endif
++{
++
++
++}
++
++#if !NEED_EASYFLAC
++FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data)
++{
++  decoder_t *e_decoder = client_data;
++  flac_private_t *priv = e_decoder->private;
++
++  return priv->eos;
++}
++#endif
  
  
-@@ -457,7 +469,7 @@
+ void resize_buffer(flac_private_t *flac, int newchannels, int newsamples)
+@@ -472,7 +555,11 @@
      
  
    
--  if (EasyFLAC__is_oggflac(priv->decoder))
-+  if (priv->format == &oggflac_format)
++#if NEED_EASYFLAC
+   if (EasyFLAC__is_oggflac(priv->decoder))
++#else
++  if (priv->is_oggflac)
++#endif
      cb->printf_metadata(decoder->callback_arg, 2,
  			_("Ogg FLAC stream: %d bits, %d channel, %ld Hz"),
  			priv->bits_per_sample,
---- vorbis-tools-1.1.1/oggenc/Makefile.am.orig	2005-06-13 15:11:44.000000000 +0200
-+++ vorbis-tools-1.1.1/oggenc/Makefile.am	2006-12-31 21:11:27.609489338 +0100
-@@ -1,6 +1,6 @@
- ## Process this file with automake to produce Makefile.in
- if HAVE_LIBFLAC
--flac_sources = flac.c flac.h easyflac.c easyflac.h
-+flac_sources = flac.c flac.h
- else
- flac_sources =
- endif
---- vorbis-tools-1.1.1/oggenc/flac.h.orig	2005-06-03 12:15:10.000000000 +0200
-+++ vorbis-tools-1.1.1/oggenc/flac.h	2006-12-31 21:12:11.824008980 +0100
-@@ -5,10 +5,10 @@
- #include "encode.h"
- #include "audio.h"
- #include <stdio.h>
--#include "easyflac.h"
-+#include <FLAC/stream_decoder.h>
- 
- typedef struct {
--	EasyFLAC__StreamDecoder *decoder;
-+	FLAC__StreamDecoder *decoder;
- 	short channels;
- 	int rate;
- 	long totalsamples; /* per channel, of course */
---- vorbis-tools-1.1.1/oggenc/flac.c.orig	2005-06-03 12:15:10.000000000 +0200
-+++ vorbis-tools-1.1.1/oggenc/flac.c	2006-12-31 21:11:12.388621950 +0100
-@@ -14,6 +14,7 @@
- #include <sys/types.h>
- #include <math.h>
- #include <FLAC/metadata.h>
-+#include <FLAC/stream_decoder.h>
- #include "audio.h"
- #include "flac.h"
- #include "i18n.h"
-@@ -22,10 +23,10 @@
- 
- #define DEFAULT_FLAC_FRAME_SIZE 4608
+Index: trunk/vorbis-tools/oggenc/easyflac.c
+===================================================================
+--- trunk/vorbis-tools/oggenc/easyflac.c (revision 12185)
++++ trunk/vorbis-tools/oggenc/easyflac.c (revision 12199)
+@@ -37,6 +37,9 @@
+ #include <config.h>
+ #endif
+ 
++#include <FLAC/export.h>
++#if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8)
++
+ #include <stdlib.h>
+ #include "easyflac.h"
+ 
+@@ -377,3 +380,5 @@
+     else
+         return FLAC__stream_decoder_process_until_end_of_stream(decoder->flac);
+ }
++
++#endif
+Index: trunk/vorbis-tools/oggenc/flac.c
+===================================================================
+--- trunk/vorbis-tools/oggenc/flac.c (revision 12198)
++++ trunk/vorbis-tools/oggenc/flac.c (revision 12199)
+@@ -20,15 +20,25 @@
+ #include "platform.h"
+ #include "resample.h"
+ 
+-#define DEFAULT_FLAC_FRAME_SIZE 4608
++#if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8)
++#define NEED_EASYFLAC 1
++#endif
++
++#if NEED_EASYFLAC
++static FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
++static FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
++static void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
++static void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
++#else
++static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
++static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
++static void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
++static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
++static FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data);
++#endif
  
 -FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
 -FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
 -void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
 -void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-+FLAC__StreamDecoderReadStatus flac_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
-+FLAC__StreamDecoderWriteStatus flac_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-+void flac_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
-+void flac_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
- 
- void resize_buffer(flacfile *flac, int newchannels, int newsamples);
- void copy_comments (vorbis_comment *v_comments, FLAC__StreamMetadata_VorbisComment *f_comments);
-@@ -76,22 +77,38 @@
+-
+-void resize_buffer(flacfile *flac, int newchannels, int newsamples);
+-void copy_comments (vorbis_comment *v_comments, FLAC__StreamMetadata_VorbisComment *f_comments);
++static void resize_buffer(flacfile *flac, int newchannels, int newsamples);
++static void copy_comments (vorbis_comment *v_comments, FLAC__StreamMetadata_VorbisComment *f_comments);
+ 
+ 
+ int flac_id(unsigned char *buf, int len)
+@@ -43,7 +53,8 @@
+ {
+ 	if (len < 32) return 0;
+ 
+-	return memcmp(buf, "OggS", 4) == 0 && flac_id(buf+28, len - 28);
++    return memcmp(buf, "OggS", 4) == 0 &&
++	   (memcmp (buf+28, "\177FLAC", 5) || flac_id(buf+28, len - 28));
+ }
+ 
+ 
+@@ -76,6 +87,7 @@
  	flac->in = in;
  
  	/* Setup FLAC decoder */
--	flac->decoder = EasyFLAC__stream_decoder_new(oggflac_id(oldbuf, buflen));
--	EasyFLAC__set_client_data(flac->decoder, flac);
--	EasyFLAC__set_read_callback(flac->decoder, &easyflac_read_callback);
--	EasyFLAC__set_write_callback(flac->decoder, &easyflac_write_callback);
--	EasyFLAC__set_metadata_callback(flac->decoder, &easyflac_metadata_callback);
--	EasyFLAC__set_error_callback(flac->decoder, &easyflac_error_callback);
--	EasyFLAC__set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_STREAMINFO);
--	EasyFLAC__set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
--	EasyFLAC__init(flac->decoder);
-+	flac->decoder = FLAC__stream_decoder_new();
-+	FLAC__stream_decoder_set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_STREAMINFO);
-+	FLAC__stream_decoder_set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
-+	if(oggflac_id(oldbuf, buflen))
-+		FLAC__stream_decoder_init_ogg_stream(flac->decoder,
-+			flac_read_callback,
-+			NULL,
-+			NULL,
-+			NULL,
-+			NULL,
-+			flac_write_callback,
-+			flac_metadata_callback,
-+			flac_error_callback,
-+			flac);
-+	else
-+		FLAC__stream_decoder_init_stream(flac->decoder,
-+			flac_read_callback,
-+			NULL,
-+			NULL,
-+			NULL,
-+			NULL,
-+			flac_write_callback,
-+			flac_metadata_callback,
-+			flac_error_callback,
-+			flac);
++#if NEED_EASYFLAC
+ 	flac->decoder = EasyFLAC__stream_decoder_new(oggflac_id(oldbuf, buflen));
+ 	EasyFLAC__set_client_data(flac->decoder, flac);
+ 	EasyFLAC__set_read_callback(flac->decoder, &easyflac_read_callback);
+@@ -85,13 +97,31 @@
+ 	EasyFLAC__set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_STREAMINFO);
+ 	EasyFLAC__set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
+ 	EasyFLAC__init(flac->decoder);
++#else
++    flac->decoder = FLAC__stream_decoder_new();
++    FLAC__stream_decoder_set_md5_checking(flac->decoder, false);
++    FLAC__stream_decoder_set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_STREAMINFO);
++    FLAC__stream_decoder_set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
++    if(oggflac_id(oldbuf, buflen))
++        FLAC__stream_decoder_init_ogg_stream(flac->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, flac);
++    else
++        FLAC__stream_decoder_init_stream(flac->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, flac);
++#endif
  	
  	/* Callback will set the total samples and sample rate */
--	EasyFLAC__process_until_end_of_metadata(flac->decoder);
-+	FLAC__stream_decoder_process_until_end_of_metadata(flac->decoder);
++#if NEED_EASYFLAC
+ 	EasyFLAC__process_until_end_of_metadata(flac->decoder);
++#else
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/vorbis-tools-flac.patch?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list