changeset 1247:ce4c57c2fa8d

Branch merge
author Ralf Ertzinger <ralf@skytale.net>
date Thu, 12 Jul 2007 19:36:09 +0200
parents 626f78ff2439 (diff) a18b7cdc505d (current diff)
children 0e0f73fed025
files
diffstat 10 files changed, 90 insertions(+), 95 deletions(-) [+]
line wrap: on
line diff
--- a/src/flacng/Makefile	Thu Jul 12 19:42:32 2007 +0300
+++ b/src/flacng/Makefile	Thu Jul 12 19:36:09 2007 +0200
@@ -7,7 +7,7 @@
 
 LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(FLAC_LIBS)
 
-SOURCES = plugin.c tools.c seekable_stream_callbacks.c
+SOURCES = plugin.c tools.c seekable_stream_callbacks.c flac_compat112.c
 
 OBJECTS = ${SOURCES:.c=.o}
 
--- a/src/flacng/debug.h	Thu Jul 12 19:42:32 2007 +0300
+++ b/src/flacng/debug.h	Thu Jul 12 19:36:09 2007 +0200
@@ -19,6 +19,8 @@
 #ifndef DEBUG_H
 #define DEBUG_H
 
+#include <stdio.h>
+
 #define _ENTER _DEBUG("enter")
 #define _LEAVE _DEBUG("leave"); return
 #define _MESSAGE(tag, string, ...) do { fprintf(stderr, "%s: libflacng.so: %s:%d (%s): " string "\n", \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/flacng/flac_compat.h	Thu Jul 12 19:36:09 2007 +0200
@@ -0,0 +1,3 @@
+#include "flac_compat112.h"
+#include "flac_compat113.h"
+#include "flac_compat114.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/flacng/flac_compat112.c	Thu Jul 12 19:36:09 2007 +0200
@@ -0,0 +1,57 @@
+/*
+ *  A FLAC decoder plugin for the Audacious Media Player
+ *  Copyright (C) 2005 Ralf Ertzinger
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <FLAC/all.h>
+#include "flac_compat112.h"
+#include "debug.h"
+
+#if !defined(FLAC_API_VERSION_CURRENT)
+
+FLAC__SeekableStreamDecoderState FLAC__stream_decoder_init_stream(
+        FLAC__SeekableStreamDecoder*  decoder,
+        FLAC__SeekableStreamDecoderReadCallback read_callback,
+        FLAC__SeekableStreamDecoderSeekCallback     seek_callback,
+        FLAC__SeekableStreamDecoderTellCallback     tell_callback,
+        FLAC__SeekableStreamDecoderLengthCallback   length_callback,
+        FLAC__SeekableStreamDecoderEofCallback      eof_callback,
+        FLAC__SeekableStreamDecoderWriteCallback    write_callback,
+        FLAC__SeekableStreamDecoderMetadataCallback     metadata_callback,
+        FLAC__SeekableStreamDecoderErrorCallback    error_callback,
+        void *      client_data) {
+
+        FLAC__SeekableStreamDecoderState ret;
+
+        _ENTER;
+
+        FLAC__seekable_stream_decoder_set_read_callback(decoder, read_callback);
+        FLAC__seekable_stream_decoder_set_seek_callback(decoder, seek_callback);
+        FLAC__seekable_stream_decoder_set_tell_callback(decoder, tell_callback);
+        FLAC__seekable_stream_decoder_set_length_callback(decoder, length_callback);
+        FLAC__seekable_stream_decoder_set_eof_callback(decoder, eof_callback);
+        FLAC__seekable_stream_decoder_set_write_callback(decoder, write_callback);
+        FLAC__seekable_stream_decoder_set_metadata_callback(decoder, metadata_callback);
+        FLAC__seekable_stream_decoder_set_error_callback(decoder, error_callback);
+        FLAC__seekable_stream_decoder_set_client_data(decoder, client_data);
+
+        ret = FLAC__seekable_stream_decoder_init(decoder);
+
+        _LEAVE ret;
+}
+
+#endif
--- a/src/flacng/flac_compat112.h	Thu Jul 12 19:42:32 2007 +0300
+++ b/src/flacng/flac_compat112.h	Thu Jul 12 19:36:09 2007 +0200
@@ -3,22 +3,37 @@
 
 #if !defined(FLAC_API_VERSION_CURRENT)
 
+/* Basic stream decoder type */
 #define FLAC__StreamDecoder FLAC__SeekableStreamDecoder
 
+/* Stream decoder functions */
 #define FLAC__StreamDecoderReadStatus FLAC__SeekableStreamDecoderReadStatus 
 #define FLAC__StreamDecoderSeekStatus FLAC__SeekableStreamDecoderSeekStatus
 #define FLAC__StreamDecoderTellStatus FLAC__SeekableStreamDecoderTellStatus
 #define FLAC__StreamDecoderLengthStatus FLAC__SeekableStreamDecoderLengthStatus
 #define FLAC__stream_decoder_new FLAC__seekable_stream_decoder_new
+#define FLAC__stream_decoder_set_metadata_respond FLAC__seekable_stream_decoder_set_metadata_respond
+#define FLAC__stream_decoder_process_single FLAC__seekable_stream_decoder_process_single
+#define FLAC__stream_decoder_seek_absolute FLAC__seekable_stream_decoder_seek_absolute
+#define FLAC__stream_decoder_get_state FLAC__seekable_stream_decoder_get_state
+#define FLAC__stream_decoder_flush FLAC__seekable_stream_decoder_flush
+#define FLAC__stream_decoder_reset FLAC__seekable_stream_decoder_reset
+#define FLAC__stream_decoder_process_until_end_of_metadata FLAC__seekable_stream_decoder_process_until_end_of_metadata
+#define FLAC__StreamDecoderInitStatusString FLAC__SeekableStreamDecoderStateString
+#define FLAC__StreamDecoderStateString FLAC__SeekableStreamDecoderStateString
 
+/* Constants and types */
+#define FLAC__StreamDecoderInitStatus FLAC__SeekableStreamDecoderState
 #define FLAC__STREAM_DECODER_SEEK_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
 #define FLAC__STREAM_DECODER_SEEK_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK
 #define FLAC__STREAM_DECODER_TELL_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR
 #define FLAC__STREAM_DECODER_TELL_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK
 #define FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR
 #define FLAC__STREAM_DECODER_LENGTH_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK
+#define FLAC__STREAM_DECODER_INIT_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_OK
+#define FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK
 
-FLAC__stream_decoder_init_stream(
+FLAC__SeekableStreamDecoderState FLAC__stream_decoder_init_stream(
     FLAC__SeekableStreamDecoder*  decoder,
     FLAC__SeekableStreamDecoderReadCallback read_callback,
     FLAC__SeekableStreamDecoderSeekCallback     seek_callback,
--- a/src/flacng/plugin.c	Thu Jul 12 19:42:32 2007 +0300
+++ b/src/flacng/plugin.c	Thu Jul 12 19:36:09 2007 +0200
@@ -142,7 +142,8 @@
             metadata_callback,
             error_callback,
             test_info))) {
-        _ERROR("Could not initialize test FLAC decoder: %s(%d)", StreamDecoderInitState(ret), ret);
+        _ERROR("Could not initialize test FLAC decoder: %s(%d)",
+                FLAC__StreamDecoderInitStatusString[ret], ret);
         _LEAVE;
      }
 
@@ -157,7 +158,8 @@
             metadata_callback,
             error_callback,
             main_info))) {
-        _ERROR("Could not initialize main FLAC decoder: %s(%d)", StreamDecoderInitState(ret), ret);
+        _ERROR("Could not initialize main FLAC decoder: %s(%d)",
+                FLAC__StreamDecoderInitStatusString[ret], ret);
         _LEAVE;
      }
 
--- a/src/flacng/seekable_stream_callbacks.c	Thu Jul 12 19:42:32 2007 +0300
+++ b/src/flacng/seekable_stream_callbacks.c	Thu Jul 12 19:36:09 2007 +0200
@@ -47,7 +47,7 @@
 
     if (0 <= info->read_max) {
         to_read = MIN(*bytes, info->read_max);
-        _DEBUG("Reading restricted to %d bytes", info->read_max);
+        _DEBUG("Reading restricted to %ld bytes", info->read_max);
     } else {
         to_read = *bytes;
     }
@@ -119,7 +119,7 @@
         return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
     }
 
-    _DEBUG("Current position: %d", position);
+    _DEBUG("Current position: %ld", position);
 
     *absolute_byte_offset = position;
 
@@ -166,7 +166,7 @@
         _LEAVE FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
     }
 
-    _DEBUG("Stream length is %d bytes", size);
+    _DEBUG("Stream length is %ld bytes", size);
     *stream_length = size;
 
     _LEAVE FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
--- a/src/flacng/seekable_stream_callbacks.h	Thu Jul 12 19:42:32 2007 +0300
+++ b/src/flacng/seekable_stream_callbacks.h	Thu Jul 12 19:36:09 2007 +0200
@@ -19,9 +19,7 @@
 #ifndef CALLBACKS_H
 #define CALLBACKS_H
 
-#include "flac_compat112.h"
-#include "flac_compat113.h"
-#include "flac_compat114.h"
+#include "flac_compat.h"
 
 FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
 FLAC__StreamDecoderSeekStatus seek_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
--- a/src/flacng/tools.c	Thu Jul 12 19:42:32 2007 +0300
+++ b/src/flacng/tools.c	Thu Jul 12 19:36:09 2007 +0200
@@ -172,89 +172,6 @@
 
 /* --- */
 
-gchar* StreamDecoderInitState(FLAC__StreamDecoderInitStatus state) {
-
-    _ENTER;
-
-    switch(state) {
-        case FLAC__STREAM_DECODER_INIT_STATUS_OK:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_OK";
-            break;
-
-        case FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER";
-            break;
-
-        case FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS";
-            break;
-
-        case FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR";
-            break;
-
-        case FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE";
-            break;
-
-        case FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED";
-            break;
-    }
-
-    _LEAVE "Unknown state";
-}
-
-/* --- */
-
-gchar* StreamDecoderState(FLAC__StreamDecoderState state) {
-
-    _ENTER;
-
-    switch(state) {
-
-        case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
-            _LEAVE "FLAC__STREAM_DECODER_SEARCH_FOR_METADATA";
-            break;
-
-        case FLAC__STREAM_DECODER_READ_METADATA:
-            _LEAVE "FLAC__STREAM_DECODER_READ_METADATA";
-            break;
-
-        case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
-            _LEAVE "FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC";
-            break;
-
-        case FLAC__STREAM_DECODER_READ_FRAME:
-            _LEAVE "FLAC__STREAM_DECODER_READ_FRAME";
-            break;
-
-        case FLAC__STREAM_DECODER_END_OF_STREAM:
-            _LEAVE "FLAC__STREAM_DECODER_END_OF_STREAM";
-            break;
-
-        case FLAC__STREAM_DECODER_ABORTED:
-            _LEAVE "FLAC__STREAM_DECODER_ABORTED";
-            break;
-
-        case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
-            _LEAVE "FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR";
-            break;
-
-        case FLAC__STREAM_DECODER_UNINITIALIZED:
-            _LEAVE "FLAC__STREAM_DECODER_UNINITIALIZED";
-            break;
-
-        default:
-            break;
-
-    }
-
-    _LEAVE "";
-}
-
-/* --- */
-
 gboolean read_metadata(gchar* filename, FLAC__StreamDecoder* decoder, callback_info* info) {
 
     FLAC__StreamDecoderState ret;
@@ -300,7 +217,8 @@
      */
     if (false == FLAC__stream_decoder_process_until_end_of_metadata(decoder)) {
         ret = FLAC__stream_decoder_get_state(decoder);
-        _DEBUG("Could not read the metadata: %s(%d)!", StreamDecoderState(ret), ret);
+        _DEBUG("Could not read the metadata: %s(%d)!",
+                FLAC__StreamDecoderStateString[ret], ret);
         reset_info(info);
         _LEAVE FALSE;
     }
--- a/src/flacng/tools.h	Thu Jul 12 19:42:32 2007 +0300
+++ b/src/flacng/tools.h	Thu Jul 12 19:36:09 2007 +0200
@@ -22,13 +22,13 @@
 #include <glib.h>
 #include <FLAC/all.h>
 #include "flacng.h"
+#include "flac_compat.h"
 
 callback_info* init_callback_info(gchar* name);
 void reset_info(callback_info* info);
 gchar* get_title(const gchar* filename, callback_info* info);
 TitleInput *get_tuple(const gchar *filename, callback_info* info);
 void add_comment(callback_info* info, gchar* key, gchar* value);
-gchar* StreamDecoderInitState(FLAC__StreamDecoderInitStatus);
 gboolean read_metadata(gchar* filename, FLAC__StreamDecoder* decoder, callback_info* info);
 
 #endif