b2b1cd2002
- Fix libflac decoder with FLAC < 1.1.3 (#220961). - Apply upstream patch for FLAC >= 1.1.3.
150 lines
4.4 KiB
Diff
150 lines
4.4 KiB
Diff
Index: xine-lib/src/libflac/decoder_flac.c
|
|
diff -u xine-lib/src/libflac/decoder_flac.c:1.21 xine-lib/src/libflac/decoder_flac.c:1.22
|
|
--- xine-lib/src/libflac/decoder_flac.c:1.21 Sat Aug 5 13:34:42 2006
|
|
+++ xine-lib/src/libflac/decoder_flac.c Mon Dec 25 19:22:00 2006
|
|
@@ -30,6 +30,13 @@
|
|
|
|
#include <FLAC/stream_decoder.h>
|
|
|
|
+#if !defined FLAC_API_VERSION_CURRENT || FLAC_API_VERSION_CURRENT < 8
|
|
+#include <FLAC/seekable_stream_decoder.h>
|
|
+#define LEGACY_FLAC
|
|
+#else
|
|
+#undef LEGACY_FLAC
|
|
+#endif
|
|
+
|
|
#define LOG_MODULE "flac_decoder"
|
|
#define LOG_VERBOSE
|
|
|
|
@@ -344,6 +351,7 @@
|
|
|
|
this->flac_decoder = FLAC__stream_decoder_new();
|
|
|
|
+#ifdef LEGACY_FLAC
|
|
FLAC__stream_decoder_set_read_callback (this->flac_decoder,
|
|
flac_read_callback);
|
|
FLAC__stream_decoder_set_write_callback (this->flac_decoder,
|
|
@@ -359,6 +367,22 @@
|
|
free (this);
|
|
return NULL;
|
|
}
|
|
+#else
|
|
+ if ( FLAC__stream_decoder_init_stream (this->flac_decoder,
|
|
+ flac_read_callback,
|
|
+ NULL, /* seek */
|
|
+ NULL, /* tell */
|
|
+ NULL, /* length */
|
|
+ NULL, /* eof */
|
|
+ flac_write_callback,
|
|
+ NULL, /* metadata */
|
|
+ flac_error_callback,
|
|
+ this
|
|
+ ) != FLAC__STREAM_DECODER_INIT_STATUS_OK ) {
|
|
+ free (this);
|
|
+ return NULL;
|
|
+ }
|
|
+#endif
|
|
|
|
return (audio_decoder_t *) this;
|
|
}
|
|
Index: xine-lib/src/libflac/demux_flac.c
|
|
diff -u xine-lib/src/libflac/demux_flac.c:1.24 xine-lib/src/libflac/demux_flac.c:1.25
|
|
--- xine-lib/src/libflac/demux_flac.c:1.24 Sat Oct 21 18:50:41 2006
|
|
+++ xine-lib/src/libflac/demux_flac.c Mon Dec 25 19:22:00 2006
|
|
@@ -441,7 +441,11 @@
|
|
lprintf("demux_flac_dispose\n");
|
|
|
|
if (this->flac_decoder)
|
|
+#ifdef LEGACY_FLAC
|
|
FLAC__seekable_stream_decoder_delete (this->flac_decoder);
|
|
+#else
|
|
+ FLAC__stream_decoder_delete (this->flac_decoder);
|
|
+#endif
|
|
|
|
free(this);
|
|
return;
|
|
@@ -494,8 +498,13 @@
|
|
}
|
|
target_sample = (uint64_t)(distance * this->total_samples);
|
|
|
|
+#ifdef LEGACY_FLAC
|
|
s = FLAC__seekable_stream_decoder_seek_absolute (this->flac_decoder,
|
|
target_sample);
|
|
+#else
|
|
+ s = FLAC__stream_decoder_seek_absolute (this->flac_decoder,
|
|
+ target_sample);
|
|
+#endif
|
|
|
|
if (s) {
|
|
lprintf ("Seek to: %d successfull!\n", start_time);
|
|
@@ -618,9 +627,6 @@
|
|
/* Get a new FLAC decoder and hook up callbacks */
|
|
#ifdef LEGACY_FLAC
|
|
this->flac_decoder = FLAC__seekable_stream_decoder_new();
|
|
-#else
|
|
- this->flac_decoder = FLAC__stream_decoder_new();
|
|
-#endif
|
|
lprintf("this->flac_decoder: %p\n", this->flac_decoder);
|
|
|
|
FLAC__seekable_stream_decoder_set_md5_checking (this->flac_decoder, false);
|
|
@@ -644,6 +650,37 @@
|
|
this);
|
|
|
|
FLAC__seekable_stream_decoder_init (this->flac_decoder);
|
|
+#else
|
|
+ this->flac_decoder = FLAC__stream_decoder_new();
|
|
+ lprintf("this->flac_decoder: %p\n", this->flac_decoder);
|
|
+
|
|
+ if ( ! this->flac_decoder ) {
|
|
+ free(this);
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ FLAC__stream_decoder_set_md5_checking (this->flac_decoder, false);
|
|
+
|
|
+ if ( FLAC__stream_decoder_init_stream(this->flac_decoder,
|
|
+ flac_read_callback,
|
|
+ flac_seek_callback,
|
|
+ flac_tell_callback,
|
|
+ flac_length_callback,
|
|
+ flac_eof_callback,
|
|
+ flac_write_callback,
|
|
+ flac_metadata_callback,
|
|
+ flac_error_callback,
|
|
+ this
|
|
+ ) != FLAC__STREAM_DECODER_INIT_STATUS_OK ) {
|
|
+#ifdef LEGACY_FLAC
|
|
+ FLAC__seekable_stream_decoder_delete (this->flac_decoder);
|
|
+#else
|
|
+ FLAC__stream_decoder_delete (this->flac_decoder);
|
|
+#endif
|
|
+ free(this);
|
|
+ return NULL;
|
|
+ }
|
|
+#endif
|
|
|
|
/* Get some stream info */
|
|
this->data_size = this->input->get_length (this->input);
|
|
@@ -653,13 +690,21 @@
|
|
* this flac stream
|
|
*/
|
|
this->status = DEMUX_OK;
|
|
+#ifdef LEGACY_FLAC
|
|
FLAC__seekable_stream_decoder_process_until_end_of_metadata (this->flac_decoder);
|
|
+#else
|
|
+ FLAC__stream_decoder_process_until_end_of_metadata (this->flac_decoder);
|
|
+#endif
|
|
|
|
lprintf("Processed file until end of metadata: %s\n",
|
|
this->status == DEMUX_OK ? "success" : "failure");
|
|
|
|
if (this->status != DEMUX_OK) {
|
|
+#ifdef LEGACY_FLAC
|
|
FLAC__seekable_stream_decoder_delete (this->flac_decoder);
|
|
+#else
|
|
+ FLAC__stream_decoder_delete (this->flac_decoder);
|
|
+#endif
|
|
free (this);
|
|
return NULL;
|
|
}
|