Commit 75e07df7 authored by conrad's avatar conrad
Browse files

add libFLAC 1.1.3 support. Adapted from patch by Michel Salim


git-svn-id: http://svn.annodex.net/libfishsound/branches/1.0-stable@3372 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 4c5a3eb2
......@@ -4,6 +4,9 @@ Conrad Parker <conrad@metadecks.org>
Tobias Gehrig
- FLAC support
Michel Salim
- libFLAC 1.1.3 support
Silvia Pfeiffer <silvia@annodex.net>
- MS Windows porting, general packaging.
......
......@@ -18,6 +18,9 @@
/* Define to 1 if you have libFLAC 1.1.2 */
#undef HAVE_FLAC_1_1_2
/* Define to 1 if you have libFLAC 1.1.3 */
#undef HAVE_FLAC_1_1_3
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
......
......@@ -249,6 +249,7 @@ dnl
HAVE_FLAC=no
HAVE_FLAC_1_1_2=no
HAVE_FLAC_1_1_3=no
FLAC_SUPPORT=no
ac_enable_flac=yes
......@@ -274,12 +275,20 @@ if test "x${ac_enable_flac}" = xyes ; then
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $FLAC_CFLAGS"
dnl Test for libFLAC 1.1.2
AC_CHECK_LIB(FLAC, FLAC__stream_decoder_init, HAVE_FLAC_1_1_2="yes",
HAVE_FLAC_1_1_2="no", [$FLAC_LIBS])
if test "x$HAVE_FLAC_1_1_2" = xyes ; then
AC_DEFINE(HAVE_FLAC_1_1_2, [1], [Define to 1 if you have libFLAC 1.1.2])
FLAC_SUPPORT="yes (1.1.2)"
dnl Test for libFLAC 1.1.3
AC_CHECK_LIB(FLAC, FLAC__stream_decoder_init_stream, HAVE_FLAC_1_1_3="yes",
HAVE_FLAC_1_1_3="no", [$FLAC_LIBS])
if test "x$HAVE_FLAC_1_1_3" = xyes ; then
AC_DEFINE(HAVE_FLAC_1_1_3, [1], [Define to 1 if you have libFLAC 1.1.3])
FLAC_SUPPORT="yes (1.1.3)"
else
dnl Test for libFLAC 1.1.2
AC_CHECK_LIB(FLAC, FLAC__stream_decoder_init, HAVE_FLAC_1_1_2="yes",
HAVE_FLAC_1_1_2="no", [$FLAC_LIBS])
if test "x$HAVE_FLAC_1_1_2" = xyes ; then
AC_DEFINE(HAVE_FLAC_1_1_2, [1], [Define to 1 if you have libFLAC 1.1.2])
FLAC_SUPPORT="yes (1.1.2)"
fi
fi
CFLAGS="$saved_CFLAGS"
......
......@@ -252,6 +252,7 @@ fs_flac_decode_header (FishSound * fsound, unsigned char *buf, long bytes)
return NULL;
}
#if defined (HAVE_FLAC_1_1_2)
FLAC__stream_decoder_set_read_callback(fi->fsd, fs_flac_read_callback);
FLAC__stream_decoder_set_write_callback(fi->fsd, fs_flac_write_callback);
FLAC__stream_decoder_set_metadata_callback(fi->fsd, fs_flac_meta_callback);
......@@ -260,6 +261,21 @@ fs_flac_decode_header (FishSound * fsound, unsigned char *buf, long bytes)
if (FLAC__stream_decoder_init(fi->fsd) != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA)
return NULL;
#elif defined (HAVE_FLAC_1_1_3)
if (FLAC__stream_decoder_init_stream
(fi->fsd,
fs_flac_read_callback,
NULL, /* seek callback */
NULL, /* tell callback */
NULL, /* length callback */
NULL, /* EOF callback */
fs_flac_write_callback,
fs_flac_meta_callback,
fs_flac_error_callback,
fsound
) != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA)
return NULL;
#endif
return fi->fsd;
}
......@@ -539,17 +555,34 @@ fs_flac_enc_headers (FishSound * fsound)
FLAC__stream_encoder_set_channels(fi->fse, fsound->info.channels);
FLAC__stream_encoder_set_sample_rate(fi->fse, fsound->info.samplerate);
FLAC__stream_encoder_set_bits_per_sample(fi->fse, BITS_PER_SAMPLE);
#if defined (HAVE_FLAC_1_1_2)
FLAC__stream_encoder_set_write_callback(fi->fse, fs_flac_enc_write_callback);
FLAC__stream_encoder_set_metadata_callback(fi->fse, fs_flac_enc_meta_callback);
FLAC__stream_encoder_set_client_data(fi->fse, fsound);
#endif
metadata = fs_flac_encode_vorbiscomments (fsound);
if (metadata != NULL)
FLAC__stream_encoder_set_metadata (fi->fse, &metadata, 1);
/* FLAC__stream_encoder_set_total_samples_estimate(fi->fse, ...);*/
#if defined (HAVE_FLAC_1_1_2)
if (FLAC__stream_encoder_init(fi->fse) != FLAC__STREAM_ENCODER_OK)
return NULL;
#elif defined (HAVE_FLAC_1_1_3)
if (FLAC__stream_encoder_init_stream
(fi->fse,
fs_flac_enc_write_callback,
NULL, /* seek callback */
NULL, /* tell callback */
fs_flac_enc_meta_callback,
fsound
) != FLAC__STREAM_ENCODER_OK)
return NULL;
#endif
return fsound;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment