[Easytag-mailing] [patch] flac simplifications



Increasing the flac requirement from 1.1.0 to 1.1.4 allows the following 
simplifications:
- remove all the #ifdef's for flac <= 1.1.2
- use the pkgconfig file provided by flac >= 1.1.4

It also seems that whatever bugs caused old versions of libFLAC not 
being properly linked with libm and libogg are now fixed.


 acconfig.h        |    4 --
 configure.in      |   82 +++++-----------------------------------------
 src/easytag.c     |   31 -----------------
 src/flac_header.c |   66 -------------------------------------
 src/flac_tag.c    |   18 ----------
 5 files changed, 10 insertions(+), 191 deletions(-)

diff --git a/acconfig.h b/acconfig.h
index 7847613..0772ecd 100755
--- a/acconfig.h
+++ b/acconfig.h
@@ -2,10 +2,6 @@
 #define ID3LIB_MINOR 0
 #define ID3LIB_PATCH 0
 
-#define LIBFLAC_MAJOR 0
-#define LIBFLAC_MINOR 0
-#define LIBFLAC_PATCH 0
-
 #undef PACKAGE
 #undef VERSION
 #undef HAVE_LIBSM
diff --git a/configure.in b/configure.in
index 247aae7..8c30996 100644
--- a/configure.in
+++ b/configure.in
@@ -86,11 +86,11 @@ AC_CHECK_LIB(socket, recv)
 
 
 dnl ################################################
-dnl # Ogg Vorbis librairies (rq : needed also for libFLAC)
+dnl # Ogg Vorbis librairies
 dnl ################################################
 dnl XIPH_PATH_OGG(enable_ogg="yes",enable_ogg="no")
 
-if test "x$enable_ogg" = "xyes" -o "x$enable_flac" = "xyes"; then
+if test "x$enable_ogg" = "xyes"; then
     PKG_CHECK_MODULES(OGG, ogg >= 1.0, , ogg_available=no)
     if test "x$ogg_available" = "xno"; then
         echo "***"
@@ -174,79 +174,15 @@ dnl ################################################
 dnl # libFLAC library
 dnl ################################################
 dnl check for system libflac
-dnl Note that libvorbis is required for flac support, even if the user chooses --disable-ogg
-
-if test "x$enable_flac" = "xyes"; then
-    dnl Library required for flac files, if not found 'enable_flac' is disabled
-    AC_CHECK_LIB(m, cos) dnl Patch from Christian Weisgerber
-    AC_CHECK_LIB(FLAC, FLAC__metadata_simple_iterator_new, , flac_available=no)
-
-    AC_MSG_CHECKING(for FLAC file support)
-    if test "x$flac_available" = "xno"; then
-        AC_MSG_RESULT(no)
-        enable_flac="no"
-        echo "***"
-        echo "*** Warning: FLAC file support disabled, libflac missing"
-        echo "*** (Install libflac, libogg and libvorbis libraries to enable it)"
-        echo "***"
-    elif test "x$ogg_available" = "xno"; then
-        AC_MSG_RESULT(no)
-        enable_flac="no"
-        echo "***"
-        echo "*** Warning: FLAC file support disabled, libvorbis missing"
-        echo "*** (Install libflac, libogg and libvorbis libraries to enable it)"
-        echo "***"
-    else
-        AC_MSG_RESULT(yes)
-        AC_DEFINE(ENABLE_FLAC,1,[Define for FLAC support])
-    fi
-else
-    AC_MSG_CHECKING(for FLAC file support)
-    AC_MSG_RESULT(no)
-    echo "***"
-    echo "*** FLAC file support disabled on commandline"
-    echo "*** (Install libflac, libogg and libvorbis libraries, and use --enable-flac to enable it)"
-    echo "***"
-fi
 
-dnl Check version of libFLAC installed
-dnl version of libFLAC must be at least 1.1.0
 if test "x$enable_flac" = "xyes"; then
-    LIBS_SAVE="$LIBS"
-    CFLAGS_SAVE="$CFLAGS"
-    LIBS="$LIBS $LIBFLAC_LIBS"
-    CFLAGS="$CFLAGS $LIBFLAC_CFLAGS"
-    AC_MSG_CHECKING(for libFLAC version)
-        AC_TRY_RUN([
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <FLAC/format.h>
-int 
-main (void)
-{
-    FILE *output;
-    char tmp[16];
-    int libflac_major, libflac_minor, libflac_patch;
-
-    sprintf(tmp,"%s",FLAC__VERSION_STRING);
-    libflac_major = atoi( (char *)strtok(tmp,".") );
-    libflac_minor = atoi( (char *)strtok(NULL,".") );
-    libflac_patch = atoi( (char *)strtok(NULL,".") );
-    output=fopen("conftest.flac","w");
-    fprintf(output,"LIBFLAC_MAJOR=%d\nLIBFLAC_MINOR=%d\nLIBFLAC_PATCH=%d\n",libflac_major,libflac_minor,libflac_patch);
-    fclose(output);
-    exit(0);
-}
-], . ./conftest.flac; echo "${LIBFLAC_MAJOR}.${LIBFLAC_MINOR}.${LIBFLAC_PATCH}", AC_MSG_WARN(could not determine libFLAC version),[echo $ac_n "cross compiling; assuming ${LIBFLAC_MAJOR}.${LIBFLAC_MINOR}.${LIBFLAC_PATCH} $ac_c"])
-    LIBS="$LIBS_SAVE"
-    CFLAGS="$CFLAGS_SAVE"
-    LIBFLAC_VERSION="(flac-$LIBFLAC_MAJOR.$LIBFLAC_MINOR.$LIBFLAC_PATCH)"
+  PKG_CHECK_MODULES(FLAC, flac >= 1.1.4,, [enable_flac=no])
+  if test "x$enable_flac" = "xyes"; then
+    AC_DEFINE(ENABLE_FLAC, 1, [Define for FLAC support])
+    CFLAGS="$CFLAGS $FLAC_CFLAGS"
+    LIBS="$LIBS $FLAC_LIBS"
+  fi
 fi
-AC_DEFINE_UNQUOTED(LIBFLAC_MAJOR, $LIBFLAC_MAJOR, [libflac major version])
-AC_DEFINE_UNQUOTED(LIBFLAC_MINOR, $LIBFLAC_MINOR, [libflac minor version])
-AC_DEFINE_UNQUOTED(LIBFLAC_PATCH, $LIBFLAC_PATCH, [libflac patch version])
-
 
 dnl ################################################
 dnl # libid3tag and Id3lib libraries
@@ -491,7 +427,7 @@ echo MP3 file support ........: $enable_mp3
 echo ID3v2.3 tags support ....: $enable_id3v23 $ID3LIB_VERSION
 echo Ogg Vorbis file support .: $enable_ogg
 echo Speex file support ......: $enable_speex
-echo FLAC file support .......: $enable_flac $LIBFLAC_VERSION
+echo FLAC file support .......: $enable_flac
 echo MP4 file support ........: $enable_mp4 $LIBMP4V2_VERSION
 echo WavPack support .........: $enable_wavpack
 echo NLS/gettext .............: $USE_NLS
diff --git a/src/easytag.c b/src/easytag.c
index ebf50eb..6da3e05 100755
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -86,15 +86,6 @@ gint     SF_ButtonPressed_Delete_File;
 
 #ifdef ENABLE_FLAC
     #include <FLAC/metadata.h>
-
-    /* Patch from Josh Coalson
-     * FLAC 1.1.3 has FLAC_API_VERSION_CURRENT == 8 *
-     * by LEGACY_FLAC we mean pre-FLAC 1.1.3; in FLAC 1.1.3 the FLAC__FileDecoder was merged into the FLAC__StreamDecoder */
-    #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
-    #define LEGACY_FLAC // For FLAC version < 1.1.3
-    #else
-    #undef LEGACY_FLAC
-    #endif
 #endif
 
 
@@ -4214,7 +4205,6 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
             gtk_widget_show(GTK_WIDGET(EncodedByLabel));
             gtk_widget_show(GTK_WIDGET(EncodedByEntry));
             gtk_widget_show(GTK_WIDGET(EncodedByMButton));
-            #ifndef LEGACY_FLAC // Picture supported for FLAC >= 1.1.3...
             gtk_widget_show(GTK_WIDGET(PictureLabel));
             gtk_widget_show(GTK_WIDGET(PictureScrollWindow));
             gtk_widget_show(GTK_WIDGET(PictureMButton));
@@ -4222,27 +4212,6 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
             gtk_widget_show(GTK_WIDGET(PictureAddButton));
             gtk_widget_show(GTK_WIDGET(PictureSaveButton));
             gtk_widget_show(GTK_WIDGET(PicturePropertiesButton));
-            #else
-            if (WRITE_ID3_TAGS_IN_FLAC_FILE)
-            {
-                gtk_widget_show(GTK_WIDGET(PictureLabel));
-                gtk_widget_show(GTK_WIDGET(PictureScrollWindow));
-                gtk_widget_show(GTK_WIDGET(PictureMButton));
-                gtk_widget_show(GTK_WIDGET(PictureClearButton));
-                gtk_widget_show(GTK_WIDGET(PictureAddButton));
-                gtk_widget_show(GTK_WIDGET(PictureSaveButton));
-                gtk_widget_show(GTK_WIDGET(PicturePropertiesButton));
-            }else
-            {
-                gtk_widget_hide(GTK_WIDGET(PictureLabel));
-                gtk_widget_hide(GTK_WIDGET(PictureScrollWindow));
-                gtk_widget_hide(GTK_WIDGET(PictureMButton));
-                gtk_widget_hide(GTK_WIDGET(PictureClearButton));
-                gtk_widget_hide(GTK_WIDGET(PictureAddButton));
-                gtk_widget_hide(GTK_WIDGET(PictureSaveButton));
-                gtk_widget_hide(GTK_WIDGET(PicturePropertiesButton));
-            }
-            #endif
             break;
 #endif
 
diff --git a/src/flac_header.c b/src/flac_header.c
index acdf628..a7eca76 100755
--- a/src/flac_header.c
+++ b/src/flac_header.c
@@ -42,15 +42,6 @@
 #include "misc.h"
 #include "charset.h"
 
-/* Patch from Josh Coalson
- * FLAC 1.1.3 has FLAC_API_VERSION_CURRENT == 8 *
- * by LEGACY_FLAC we mean pre-FLAC 1.1.3; in FLAC 1.1.3 the FLAC__FileDecoder was merged into the FLAC__StreamDecoder */
-#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
-#define LEGACY_FLAC // For FLAC version < 1.1.3
-#else
-#undef LEGACY_FLAC
-#endif
-
 
 /****************
  * Declarations *
@@ -84,15 +75,9 @@ static unsigned reservoir_samples_ = 0;
 /**************
  * Prototypes *
  **************/
-#ifdef LEGACY_FLAC
-static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-static void metadata_callback_(const FLAC__FileDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
-static void error_callback_   (const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-#else
 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);
-#endif
 
 
 
@@ -110,11 +95,7 @@ gboolean Flac_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo)
     gdouble duration = 0;
     gulong filesize;
 
-#ifdef LEGACY_FLAC
-    FLAC__FileDecoder *tmp_decoder;
-#else
     FLAC__StreamDecoder *tmp_decoder;
-#endif
     file_info_struct tmp_file_info;
 
     if (!filename || !ETFileInfo)
@@ -130,57 +111,24 @@ gboolean Flac_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo)
     fclose(file);
 
     /* Decoding FLAC file */
-#ifdef LEGACY_FLAC
-    tmp_decoder = FLAC__file_decoder_new();
-#else
     tmp_decoder = FLAC__stream_decoder_new();
-#endif
     if (tmp_decoder == 0)
     {
         return FALSE;
     }
 
     tmp_file_info.abort_flag = false;
-#ifdef LEGACY_FLAC
-    FLAC__file_decoder_set_md5_checking     (tmp_decoder, false);
-    FLAC__file_decoder_set_filename         (tmp_decoder, filename);
-    FLAC__file_decoder_set_write_callback   (tmp_decoder, write_callback_);
-    FLAC__file_decoder_set_metadata_callback(tmp_decoder, metadata_callback_);
-    FLAC__file_decoder_set_error_callback   (tmp_decoder, error_callback_);
-    FLAC__file_decoder_set_client_data      (tmp_decoder, &tmp_file_info);
-    if (FLAC__file_decoder_init(tmp_decoder) != FLAC__FILE_DECODER_OK)
-    {
-        return FALSE;
-    }
-
-#else
     FLAC__stream_decoder_set_md5_checking     (tmp_decoder, false);
     if(FLAC__stream_decoder_init_file(tmp_decoder, filename, write_callback_, metadata_callback_, error_callback_, &tmp_file_info) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
         return FALSE;
-#endif
-
-#ifdef LEGACY_FLAC
-    // In FLAC 1.0.3, is used : FLAC__file_decoder_process_metadata
-    // In FLAC 1.0.4, is used : FLAC__file_decoder_process_until_end_of_metadata
-#if ( (LIBFLAC_MAJOR <= 1) && (LIBFLAC_MINOR <= 0) && (LIBFLAC_PATCH <= 3) )
-    if (!FLAC__file_decoder_process_metadata(tmp_decoder)) // FLAC 1.0.3
-#else
-    if (!FLAC__file_decoder_process_until_end_of_metadata(tmp_decoder)) // FLAC 1.0.4 (Bastian Kleineidam)
-#endif
-#else
+
     if(!FLAC__stream_decoder_process_until_end_of_metadata(tmp_decoder))
-#endif
     {
         return FALSE;
     }
 
-#ifdef LEGACY_FLAC
-    FLAC__file_decoder_finish(tmp_decoder);
-    FLAC__file_decoder_delete(tmp_decoder);
-#else
     FLAC__stream_decoder_finish(tmp_decoder);
     FLAC__stream_decoder_delete(tmp_decoder);
-#endif
     /* End of decoding FLAC file */
 
 
@@ -200,11 +148,7 @@ gboolean Flac_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo)
 
 
 
-#ifdef LEGACY_FLAC
-FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *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
 {
     file_info_struct *file_info = (file_info_struct *)client_data;
     const unsigned bps = file_info->bits_per_sample, channels = file_info->channels, wide_samples = frame->header.blocksize;
@@ -237,11 +181,7 @@ FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decode
     return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
 }
 
-#ifdef LEGACY_FLAC
-void metadata_callback_(const FLAC__FileDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
-#else
 void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
-#endif
 {
     file_info_struct *file_info = (file_info_struct *)client_data;
     (void)decoder;
@@ -269,11 +209,7 @@ void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMe
     }
 }
 
-#ifdef LEGACY_FLAC
-void error_callback_(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
-#else
 void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
-#endif
 {
     file_info_struct *file_info = (file_info_struct *)client_data;
     (void)decoder;
diff --git a/src/flac_tag.c b/src/flac_tag.c
index 7c7906e..1731c04 100755
--- a/src/flac_tag.c
+++ b/src/flac_tag.c
@@ -50,15 +50,6 @@
 
 #define MULTIFIELD_SEPARATOR " - "
 
-/* Patch from Josh Coalson
- * FLAC 1.1.3 has FLAC_API_VERSION_CURRENT == 8 *
- * by LEGACY_FLAC we mean pre-FLAC 1.1.3; in FLAC 1.1.3 the FLAC__FileDecoder was merged into the FLAC__StreamDecoder */
-#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
-#define LEGACY_FLAC // For FLAC version < 1.1.3
-#else
-#undef LEGACY_FLAC
-#endif
-
 
 /* FLAC uses Ogg Vorbis comments
  * Ogg Vorbis fields names :
@@ -108,9 +99,7 @@ gboolean Flac_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
     gchar *string = NULL;
     gchar *filename_utf8 = filename_to_display(filename);
     guint i;
-#ifndef LEGACY_FLAC // For FLAC >= 1.1.3
     Picture *prev_pic = NULL;
-#endif
     //gint j = 1;
 
     
@@ -620,7 +609,6 @@ gboolean Flac_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
             //
             // Read the PICTURE block (severals can exist)
             //
-#ifndef LEGACY_FLAC // For FLAC >= 1.1.3
             case FLAC__METADATA_TYPE_PICTURE: 
             {
                 
@@ -653,7 +641,6 @@ gboolean Flac_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
 
                 break;
             }
-#endif
                 
             default:
                 break;
@@ -857,13 +844,11 @@ gboolean Flac_Tag_Write_File_Tag (ET_File *ETFile)
             //
             // Delete all the PICTURE blocks, and convert to padding
             //
-#ifndef LEGACY_FLAC // For FLAC >= 1.1.3
             case FLAC__METADATA_TYPE_PICTURE: 
             {
                 FLAC__metadata_iterator_delete_block(iter,true);
                 break;
             }
-#endif
             
             default:
                 break;
@@ -1060,8 +1045,6 @@ gboolean Flac_Tag_Write_File_Tag (ET_File *ETFile)
     /***********
      * Picture *
      ***********/
-    // For FLAC >= 1.1.3
-    #ifndef LEGACY_FLAC
     {
         Picture *pic = FileTag->picture;
         while (pic)
@@ -1107,7 +1090,6 @@ gboolean Flac_Tag_Write_File_Tag (ET_File *ETFile)
             pic = pic->next;
         }
     }
-    #endif
     
     // Free iter
     FLAC__metadata_iterator_delete(iter);




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]