From 3e8c88ca5ec808b2a05add9a4af7e82cb86e0006 Mon Sep 17 00:00:00 2001 From: Seungbae Shin Date: Thu, 15 Jun 2017 17:04:44 +0900 Subject: [PATCH] Sync with upstream Change-Id: I14d5d1e0538483b3d6bff9d3ce35adca1348e78f --- configure.ac | 106 +++++++++------------ examples/generate.c | 3 - packaging/libsndfile.spec | 4 +- src/flac.c | 233 ++++++++++++++++++++++++++++------------------ src/ogg_vorbis.c | 57 ------------ 5 files changed, 190 insertions(+), 213 deletions(-) diff --git a/configure.ac b/configure.ac index ef14780..f4ec6c4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,9 @@ -# Copyright (C) 1999-2015 Erik de Castro Lopo . +# Copyright (C) 1999-2017 Erik de Castro Lopo . dnl Require autoconf version AC_PREREQ(2.57) -AC_INIT([libsndfile],[1.0.26],[sndfile@mega-nerd.com], +AC_INIT([libsndfile],[1.0.28],[sndfile@mega-nerd.com], [libsndfile],[http://www.mega-nerd.com/libsndfile/]) # Put config stuff in Cfg. @@ -13,7 +13,6 @@ AC_CONFIG_MACRO_DIR([M4]) AC_CONFIG_SRCDIR([src/sndfile.c]) AC_CANONICAL_TARGET([]) -AC_CONFIG_MACRO_DIR([M4]) AC_CONFIG_HEADERS([src/config.h]) AM_INIT_AUTOMAKE @@ -30,11 +29,9 @@ MN_C_COMPILER_IS_CLANG MN_GCC_REALLY_IS_GCC AC_PROG_SED +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -# Do not check for F77. -define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl - -AM_PROG_LIBTOOL +LT_INIT LT_PROG_RC AC_PROG_INSTALL @@ -86,6 +83,8 @@ else AM_CONDITIONAL([LINUX_MINGW_CROSS_TEST], [test "$build_os:$target_os:$host_os:$HAVE_WINE" = "linux-gnu:mingw32msvc:mingw32msvc:yes"]) +gl_VISIBILITY + #==================================================================================== # Couple of initializations here. Fill in real values later. @@ -95,7 +94,7 @@ SHLIB_VERSION_ARG="" # Finished checking, handle options. AC_ARG_ENABLE(experimental, - AC_HELP_STRING([--enable-experimental], [enable experimental code])) + AS_HELP_STRING([--enable-experimental], [enable experimental code])) EXPERIMENTAL_CODE=0 if test x$enable_experimental = xyes ; then @@ -104,37 +103,41 @@ if test x$enable_experimental = xyes ; then AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_CODE],${EXPERIMENTAL_CODE}, [Set to 1 to enable experimental code.]) AC_ARG_ENABLE(werror, - AC_HELP_STRING([--enable-werror], [enable -Werror in all Makefiles])) + AS_HELP_STRING([--enable-werror], [enable -Werror in all Makefiles])) AC_ARG_ENABLE(stack-smash-protection, - AC_HELP_STRING([--enable-stack-smash-protection], [Enable GNU GCC stack smash protection])) + AS_HELP_STRING([--enable-stack-smash-protection], [Enable GNU GCC stack smash protection])) AC_ARG_ENABLE(gcc-pipe, - AC_HELP_STRING([--disable-gcc-pipe], [disable gcc -pipe option])) + AS_HELP_STRING([--disable-gcc-pipe], [disable gcc -pipe option])) AC_ARG_ENABLE(gcc-opt, - AC_HELP_STRING([--disable-gcc-opt], [disable gcc optimisations])) + AS_HELP_STRING([--disable-gcc-opt], [disable gcc optimisations])) AC_ARG_ENABLE(cpu-clip, - AC_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper])) + AS_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper])) AC_ARG_ENABLE(bow-docs, - AC_HELP_STRING([--enable-bow-docs], [enable black-on-white html docs])) + AS_HELP_STRING([--enable-bow-docs], [enable black-on-white html docs])) AC_ARG_ENABLE(sqlite, - AC_HELP_STRING([--disable-sqlite], [disable use of sqlite])) + AS_HELP_STRING([--disable-sqlite], [disable use of sqlite])) AC_ARG_ENABLE(alsa, - AC_HELP_STRING([--disable-alsa], [disable use of ALSA])) + AS_HELP_STRING([--disable-alsa], [disable use of ALSA])) AC_ARG_ENABLE(external-libs, - AC_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis [[default=no]]])) + AS_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis [[default=no]]])) AC_ARG_ENABLE(octave, - AC_HELP_STRING([--enable-octave], [disable building of GNU Octave module])) + AS_HELP_STRING([--enable-octave], [disable building of GNU Octave module])) + +AC_ARG_ENABLE([full-suite], + AS_HELP_STRING([--disable-full-suite], [disable building and installing programs, documentation, only build library [[default=no]]])) +AM_CONDITIONAL([FULL_SUITE], [test "x$enable_full_suite" != "xno"]) AC_ARG_ENABLE(test-coverage, - AC_HELP_STRING([--enable-test-coverage], [enable test coverage])) + AS_HELP_STRING([--enable-test-coverage], [enable test coverage])) AM_CONDITIONAL([ENABLE_TEST_COVERAGE], [test "$enable_test_coverage" = yes]) #==================================================================================== @@ -159,8 +162,6 @@ AC_CHECK_SIZEOF(long long,8) # Check for common 64 bit file offset types. AC_CHECK_SIZEOF(off_t,1) -AC_CHECK_SIZEOF(loff_t,1) -AC_CHECK_SIZEOF(off64_t,1) if test "$enable_largefile:$ac_cv_sizeof_off_t" = "no:8" ; then echo @@ -169,7 +170,6 @@ if test "$enable_largefile:$ac_cv_sizeof_off_t" = "no:8" ; then exit 1 fi - case "$host_os" in mingw32*) TYPEOF_SF_COUNT_T="__int64" @@ -184,14 +184,6 @@ case "$host_os" in TYPEOF_SF_COUNT_T="int64_t" SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL" SIZEOF_SF_COUNT_T=8 - elif test "x$ac_cv_sizeof_loff_t" = "x8" ; then - TYPEOF_SF_COUNT_T="int64_t" - SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL" - SIZEOF_SF_COUNT_T=8 - elif test "x$ac_cv_sizeof_off64_t" = "x8" ; then - TYPEOF_SF_COUNT_T="int64_t" - SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL" - SIZEOF_SF_COUNT_T=8 else # Save the old sizeof (off_t) value and then unset it to see if it # changes when Large File Support is enabled. @@ -199,7 +191,6 @@ case "$host_os" in unset ac_cv_sizeof_off_t AC_SYS_LARGEFILE - if test "x$ac_cv_sys_largefile_CFLAGS" = "xno" ; then ac_cv_sys_largefile_CFLAGS="" fi @@ -215,6 +206,7 @@ case "$host_os" in if test "x$ac_cv_sizeof_off_t" = "x8" ; then TYPEOF_SF_COUNT_T="int64_t" SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL" + SIZEOF_SF_COUNT_T=8 elif test "x$TYPEOF_SF_COUNT_T" = "xunknown" ; then echo echo "*** The configure process has determined that this system is capable" @@ -241,8 +233,7 @@ AC_SUBST(SIZEOF_SF_COUNT_T) AC_DEFINE_UNQUOTED([SF_COUNT_MAX],${SF_COUNT_MAX}, [Set to maximum allowed value of sf_count_t type.]) AC_SUBST(SF_COUNT_MAX) -AC_CHECK_TYPES(ssize_t) -AC_CHECK_SIZEOF(ssize_t,4) +AC_TYPE_SSIZE_T #==================================================================================== # Determine endian-ness of target processor. @@ -291,9 +282,9 @@ else #==================================================================================== # Check for Ogg, Vorbis and FLAC. -HAVE_EXTERNAL_LIBS=0 -EXTERNAL_CFLAGS="" -EXTERNAL_LIBS="" +HAVE_EXTERNAL_XIPH_LIBS=0 +EXTERNAL_XIPH_CFLAGS="" +EXTERNAL_XIPH_LIBS="" # Check for pkg-config outside the if statement. PKG_PROG_PKG_CONFIG @@ -326,11 +317,11 @@ if test -n "$PKG_CONFIG" ; then fi if test x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc = "xyesyesyesyes" ; then - HAVE_EXTERNAL_LIBS=1 + HAVE_EXTERNAL_XIPH_LIBS=1 enable_external_libs=yes - EXTERNAL_CFLAGS="$FLAC_CFLAGS $OGG_CFLAGS $VORBIS_CFLAGS $VORBISENC_CFLAGS $SPEEX_CFLAGS" - EXTERNAL_LIBS="$FLAC_LIBS $OGG_LIBS $VORBIS_LIBS $VORBISENC_LIBS $SPEEX_LIBS " + EXTERNAL_XIPH_CFLAGS="$FLAC_CFLAGS $OGG_CFLAGS $VORBIS_CFLAGS $VORBISENC_CFLAGS $SPEEX_CFLAGS" + EXTERNAL_XIPH_LIBS="$FLAC_LIBS $OGG_LIBS $VORBIS_LIBS $VORBISENC_LIBS $SPEEX_LIBS " else echo AC_MSG_WARN([[*** One or more of the external libraries (ie libflac, libogg and]]) @@ -344,7 +335,7 @@ if test -n "$PKG_CONFIG" ; then fi fi -AC_DEFINE_UNQUOTED([HAVE_EXTERNAL_LIBS], $HAVE_EXTERNAL_LIBS, [Will be set to 1 if flac, ogg and vorbis are available.]) +AC_DEFINE_UNQUOTED([HAVE_EXTERNAL_XIPH_LIBS], $HAVE_EXTERNAL_XIPH_LIBS, [Will be set to 1 if flac, ogg and vorbis are available.]) #==================================================================================== # Check for libsqlite3 (only used in regtest). @@ -361,6 +352,7 @@ else fi AC_DEFINE_UNQUOTED([HAVE_SQLITE3],$HAVE_SQLITE3,[Set to 1 if you have libsqlite3.]) +AM_CONDITIONAL([HAVE_SQLITE3], [test "x$ac_cv_sqlite3" = "xyes"]) #==================================================================================== # Determine if the processor can do clipping on float to int conversions. @@ -386,17 +378,13 @@ OS_SPECIFIC_LINKS="" os_is_win32=0 os_is_openbsd=0 use_windows_api=0 -osx_darwin_version=0 - case "$host_os" in darwin* | rhapsody*) - osx_darwin_version=$(echo "$host_os" | sed 's/\..*//;s/darwin//g') if test x$HAVE_XCODE_SELECT = xyes ; then developer_path=`xcode-select --print-path` else developer_path="/Developer" fi - OS_SPECIFIC_CFLAGS="-I${developer_path}/Headers/FlatCarbon" OS_SPECIFIC_LINKS="-framework CoreAudio -framework AudioToolbox -framework CoreFoundation" ;; mingw*) @@ -412,7 +400,6 @@ case "$host_os" in AC_DEFINE_UNQUOTED(OS_IS_WIN32, ${os_is_win32}, [Set to 1 if compiling for Win32]) AC_DEFINE_UNQUOTED(OS_IS_OPENBSD, ${os_is_openbsd}, [Set to 1 if compiling for OpenBSD]) AC_DEFINE_UNQUOTED(USE_WINDOWS_API, ${use_windows_api}, [Set to 1 to use the native windows API]) -AC_DEFINE_UNQUOTED(OSX_DARWIN_VERSION, ${osx_darwin_version}, [The darwin version, no-zero is valid]) AM_CONDITIONAL(USE_WIN_VERSION_FILE, test ${use_windows_api} -eq 1) #==================================================================================== @@ -517,17 +504,12 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then MN_ADD_CFLAGS([-Wextra]) MN_ADD_CFLAGS([-Wdeclaration-after-statement]) MN_ADD_CFLAGS([-Wpointer-arith]) - MN_ADD_CFLAGS([-funsigned-char]) AC_LANG_PUSH([C++]) MN_ADD_CXXFLAGS([-Wextra]) MN_ADD_CXXFLAGS([-Wpointer-arith]) - MN_ADD_CXXFLAGS([-funsigned-char]) AC_LANG_POP([C++]) - - MN_ADD_CFLAGS([-D_FORTIFY_SOURCE=2]) - if test x$enable_stack_smash_protection = "xyes" ; then XIPH_GCC_STACK_PROTECTOR XIPH_GXX_STACK_PROTECTOR @@ -538,9 +520,16 @@ if test x$ac_cv_c_compiler_gnu = xyes ; then MN_ADD_CFLAGS([-coverage]) fi - CFLAGS="$CFLAGS -Wcast-align -Wcast-qual -Wshadow -Wbad-function-cast -Wwrite-strings -Wundef -Wuninitialized -Winit-self -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return" - # -Winline -Wconversion -Wunreachable-code" - CXXFLAGS="$CXXFLAGS -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo -Wundef -Wuninitialized -Winit-self" + dnl some distributions (such as Gentoo) have _FORTIFY_SOURCE always + dnl enabled. We test for this situation in order to prevent polluting + dnl the console with messages of macro redefinitions. + AX_ADD_FORTIFY_SOURCE + + common_flags="-Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wundef -Wuninitialized -Winit-self" + + # -Winline -Wconversion " + CFLAGS="$CFLAGS $common_flags -Wbad-function-cast -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return -Wvla" + CXXFLAGS="$CXXFLAGS $common_flags -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo" if test "x$enable_gcc_opt" = "xno" ; then temp_CFLAGS=`echo $CFLAGS | $SED "s/O2/O0/"` @@ -630,14 +619,14 @@ AC_SUBST(SHARED_VERSION_INFO) AC_SUBST(CLEAN_VERSION) AC_SUBST(WIN_RC_VERSION) -AC_SUBST(HAVE_EXTERNAL_LIBS) +AC_SUBST(HAVE_EXTERNAL_XIPH_LIBS) AC_SUBST(OS_SPECIFIC_CFLAGS) AC_SUBST(OS_SPECIFIC_LINKS) AC_SUBST(ALSA_LIBS) AC_SUBST(SNDIO_LIBS) -AC_SUBST(EXTERNAL_CFLAGS) -AC_SUBST(EXTERNAL_LIBS) +AC_SUBST(EXTERNAL_XIPH_CFLAGS) +AC_SUBST(EXTERNAL_XIPH_LIBS) AC_SUBST(SRC_BINDIR) AC_SUBST(TEST_BINDIR) @@ -706,7 +695,4 @@ echo " Stack smash protection : .............. ${enable_stack_smash_protectio ./echo-install-dirs # Remove symlink created by Scripts/android-configure.sh. -test -h gdbclient && rm -f gdbclient - -(cd src && make genfiles) -(cd tests && make genfiles) +rm -f gdbclient diff --git a/examples/generate.c b/examples/generate.c index 44cb6f2..884e8d7 100644 --- a/examples/generate.c +++ b/examples/generate.c @@ -60,9 +60,6 @@ main (int argc, char **argv) encode_file (argv [1], "imaadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM) ; encode_file (argv [1], "msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM) ; encode_file (argv [1], "gsm610.wav" , SF_FORMAT_WAV | SF_FORMAT_GSM610) ; -#if 0 /* For temporal testing of encoding ogg/vorbis functionality */ - encode_file (argv [1], "pcm16.ogg" , SF_FORMAT_OGG | SF_FORMAT_VORBIS) ; -#endif /* Soundforge W64. */ encode_file (argv [1], "pcmu8.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_U8) ; diff --git a/packaging/libsndfile.spec b/packaging/libsndfile.spec index d15ed3e..b6f1ab7 100644 --- a/packaging/libsndfile.spec +++ b/packaging/libsndfile.spec @@ -1,6 +1,6 @@ Name: libsndfile -Version: 1.0.26 -Release: 2 +Version: 1.0.28 +Release: 0 License: LGPL-2.1+ Summary: C library for reading and writing sound files Group: Multimedia/Audio diff --git a/src/flac.c b/src/flac.c index 86b61ce..d2c5cdd 100644 --- a/src/flac.c +++ b/src/flac.c @@ -29,7 +29,7 @@ #include "sndfile.h" #include "common.h" -#if HAVE_EXTERNAL_LIBS +#if HAVE_EXTERNAL_XIPH_LIBS #include #include @@ -61,16 +61,16 @@ typedef struct FLAC__StreamMetadata *metadata ; - const FLAC__int32 * const * wbuffer ; - FLAC__int32 * rbuffer [FLAC__MAX_CHANNELS] ; + const int32_t * const * wbuffer ; + int32_t * rbuffer [FLAC__MAX_CHANNELS] ; - FLAC__int32* encbuffer ; + int32_t* encbuffer ; unsigned bufferpos ; const FLAC__Frame *frame ; - FLAC__bool bufferbackup ; unsigned compression ; + } FLAC_PRIVATE ; typedef struct @@ -95,18 +95,18 @@ static sf_count_t flac_write_i2flac (SF_PRIVATE *psf, const int *ptr, sf_count_t static sf_count_t flac_write_f2flac (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; static sf_count_t flac_write_d2flac (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; -static void f2flac8_array (const float *src, FLAC__int32 *dest, int count, int normalize) ; -static void f2flac16_array (const float *src, FLAC__int32 *dest, int count, int normalize) ; -static void f2flac24_array (const float *src, FLAC__int32 *dest, int count, int normalize) ; -static void f2flac8_clip_array (const float *src, FLAC__int32 *dest, int count, int normalize) ; -static void f2flac16_clip_array (const float *src, FLAC__int32 *dest, int count, int normalize) ; -static void f2flac24_clip_array (const float *src, FLAC__int32 *dest, int count, int normalize) ; -static void d2flac8_array (const double *src, FLAC__int32 *dest, int count, int normalize) ; -static void d2flac16_array (const double *src, FLAC__int32 *dest, int count, int normalize) ; -static void d2flac24_array (const double *src, FLAC__int32 *dest, int count, int normalize) ; -static void d2flac8_clip_array (const double *src, FLAC__int32 *dest, int count, int normalize) ; -static void d2flac16_clip_array (const double *src, FLAC__int32 *dest, int count, int normalize) ; -static void d2flac24_clip_array (const double *src, FLAC__int32 *dest, int count, int normalize) ; +static void f2flac8_array (const float *src, int32_t *dest, int count, int normalize) ; +static void f2flac16_array (const float *src, int32_t *dest, int count, int normalize) ; +static void f2flac24_array (const float *src, int32_t *dest, int count, int normalize) ; +static void f2flac8_clip_array (const float *src, int32_t *dest, int count, int normalize) ; +static void f2flac16_clip_array (const float *src, int32_t *dest, int count, int normalize) ; +static void f2flac24_clip_array (const float *src, int32_t *dest, int count, int normalize) ; +static void d2flac8_array (const double *src, int32_t *dest, int count, int normalize) ; +static void d2flac16_array (const double *src, int32_t *dest, int count, int normalize) ; +static void d2flac24_array (const double *src, int32_t *dest, int count, int normalize) ; +static void d2flac8_clip_array (const double *src, int32_t *dest, int count, int normalize) ; +static void d2flac16_clip_array (const double *src, int32_t *dest, int count, int normalize) ; +static void d2flac24_clip_array (const double *src, int32_t *dest, int count, int normalize) ; static int flac_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; @@ -116,7 +116,7 @@ static FLAC__StreamDecoderSeekStatus sf_flac_seek_callback (const FLAC__StreamDe static FLAC__StreamDecoderTellStatus sf_flac_tell_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) ; static FLAC__StreamDecoderLengthStatus sf_flac_length_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) ; static FLAC__bool sf_flac_eof_callback (const FLAC__StreamDecoder *decoder, void *client_data) ; -static FLAC__StreamDecoderWriteStatus sf_flac_write_callback (const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data) ; +static FLAC__StreamDecoderWriteStatus sf_flac_write_callback (const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const int32_t * const buffer [], void *client_data) ; static void sf_flac_meta_callback (const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) ; static void sf_flac_error_callback (const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) ; @@ -126,38 +126,38 @@ static FLAC__StreamEncoderTellStatus sf_flac_enc_tell_callback (const FLAC__Stre static FLAC__StreamEncoderWriteStatus sf_flac_enc_write_callback (const FLAC__StreamEncoder *encoder, const FLAC__byte buffer [], size_t bytes, unsigned samples, unsigned current_frame, void *client_data) ; static void -s2flac8_array (const short *src, FLAC__int32 *dest, int count) +s2flac8_array (const short *src, int32_t *dest, int count) { while (--count >= 0) dest [count] = src [count] >> 8 ; } /* s2flac8_array */ static void -s2flac16_array (const short *src, FLAC__int32 *dest, int count) +s2flac16_array (const short *src, int32_t *dest, int count) { while (--count >= 0) dest [count] = src [count] ; } /* s2flac16_array */ static void -s2flac24_array (const short *src, FLAC__int32 *dest, int count) +s2flac24_array (const short *src, int32_t *dest, int count) { while (--count >= 0) dest [count] = src [count] << 8 ; } /* s2flac24_array */ static void -i2flac8_array (const int *src, FLAC__int32 *dest, int count) +i2flac8_array (const int *src, int32_t *dest, int count) { while (--count >= 0) dest [count] = src [count] >> 24 ; } /* i2flac8_array */ static void -i2flac16_array (const int *src, FLAC__int32 *dest, int count) +i2flac16_array (const int *src, int32_t *dest, int count) { while (--count >= 0) dest [count] = src [count] >> 16 ; } /* i2flac16_array */ static void -i2flac24_array (const int *src, FLAC__int32 *dest, int count) +i2flac24_array (const int *src, int32_t *dest, int count) { while (--count >= 0) dest [count] = src [count] >> 8 ; } /* i2flac24_array */ @@ -166,8 +166,8 @@ static sf_count_t flac_buffer_copy (SF_PRIVATE *psf) { FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; const FLAC__Frame *frame = pflac->frame ; - const FLAC__int32* const *buffer = pflac->wbuffer ; - unsigned i = 0, j, offset ; + const int32_t* const *buffer = pflac->wbuffer ; + unsigned i = 0, j, offset, channels, len ; /* ** frame->header.blocksize is variable and we're using a constant blocksize @@ -180,21 +180,33 @@ flac_buffer_copy (SF_PRIVATE *psf) return 0 ; } ; + if (frame->header.channels > FLAC__MAX_CHANNELS) + psf_log_printf (psf, "Ooops : frame->header.channels (%d) > FLAC__MAX_BLOCK_SIZE (%d)\n", __func__, __LINE__, frame->header.channels, FLAC__MAX_CHANNELS) ; + + channels = SF_MIN (frame->header.channels, FLAC__MAX_CHANNELS) ; + if (pflac->ptr == NULL) { /* - ** Not sure why this code is here and not elsewhere. - ** Removing it causes valgrind errors. + ** This pointer is reset to NULL each time the current frame has been + ** decoded. Somehow its used during encoding and decoding. */ - pflac->bufferbackup = SF_TRUE ; - for (i = 0 ; i < frame->header.channels ; i++) + for (i = 0 ; i < channels ; i++) { if (pflac->rbuffer [i] == NULL) - pflac->rbuffer [i] = calloc (FLAC__MAX_BLOCK_SIZE, sizeof (FLAC__int32)) ; + pflac->rbuffer [i] = calloc (FLAC__MAX_BLOCK_SIZE, sizeof (int32_t)) ; - memcpy (pflac->rbuffer [i], buffer [i], frame->header.blocksize * sizeof (FLAC__int32)) ; + memcpy (pflac->rbuffer [i], buffer [i], frame->header.blocksize * sizeof (int32_t)) ; } ; - pflac->wbuffer = (const FLAC__int32* const*) pflac->rbuffer ; + pflac->wbuffer = (const int32_t* const*) pflac->rbuffer ; + + return 0 ; + } ; + + + len = SF_MIN (pflac->len, frame->header.blocksize) ; + if (pflac->remain % channels != 0) + { psf_log_printf (psf, "Error: pflac->remain %u channels %u\n", pflac->remain, channels) ; return 0 ; } ; @@ -204,29 +216,35 @@ flac_buffer_copy (SF_PRIVATE *psf) int shift = 16 - frame->header.bits_per_sample ; if (shift < 0) { shift = abs (shift) ; - for (i = 0 ; i < frame->header.blocksize && pflac->remain > 0 ; i++) - { offset = pflac->pos + i * frame->header.channels ; + for (i = 0 ; i < len && pflac->remain > 0 ; i++) + { offset = pflac->pos + i * channels ; if (pflac->bufferpos >= frame->header.blocksize) break ; - for (j = 0 ; j < frame->header.channels ; j++) + if (offset + channels > pflac->len) + break ; + + for (j = 0 ; j < channels ; j++) retpcm [offset + j] = buffer [j][pflac->bufferpos] >> shift ; - pflac->remain -= frame->header.channels ; + pflac->remain -= channels ; pflac->bufferpos++ ; } } else - { for (i = 0 ; i < frame->header.blocksize && pflac->remain > 0 ; i++) - { offset = pflac->pos + i * frame->header.channels ; + { for (i = 0 ; i < len && pflac->remain > 0 ; i++) + { offset = pflac->pos + i * channels ; if (pflac->bufferpos >= frame->header.blocksize) break ; - for (j = 0 ; j < frame->header.channels ; j++) + if (offset + channels > pflac->len) + break ; + + for (j = 0 ; j < channels ; j++) retpcm [offset + j] = ((uint16_t) buffer [j][pflac->bufferpos]) << shift ; - pflac->remain -= frame->header.channels ; + pflac->remain -= channels ; pflac->bufferpos++ ; } ; } ; @@ -236,15 +254,18 @@ flac_buffer_copy (SF_PRIVATE *psf) case PFLAC_PCM_INT : { int *retpcm = (int*) pflac->ptr ; int shift = 32 - frame->header.bits_per_sample ; - for (i = 0 ; i < frame->header.blocksize && pflac->remain > 0 ; i++) - { offset = pflac->pos + i * frame->header.channels ; + for (i = 0 ; i < len && pflac->remain > 0 ; i++) + { offset = pflac->pos + i * channels ; if (pflac->bufferpos >= frame->header.blocksize) break ; - for (j = 0 ; j < frame->header.channels ; j++) + if (offset + channels > pflac->len) + break ; + + for (j = 0 ; j < channels ; j++) retpcm [offset + j] = ((uint32_t) buffer [j][pflac->bufferpos]) << shift ; - pflac->remain -= frame->header.channels ; + pflac->remain -= channels ; pflac->bufferpos++ ; } ; } ; @@ -254,15 +275,18 @@ flac_buffer_copy (SF_PRIVATE *psf) { float *retpcm = (float*) pflac->ptr ; float norm = (psf->norm_float == SF_TRUE) ? 1.0 / (1 << (frame->header.bits_per_sample - 1)) : 1.0 ; - for (i = 0 ; i < frame->header.blocksize && pflac->remain > 0 ; i++) - { offset = pflac->pos + i * frame->header.channels ; + for (i = 0 ; i < len && pflac->remain > 0 ; i++) + { offset = pflac->pos + i * channels ; if (pflac->bufferpos >= frame->header.blocksize) break ; - for (j = 0 ; j < frame->header.channels ; j++) + if (offset + channels > pflac->len) + break ; + + for (j = 0 ; j < channels ; j++) retpcm [offset + j] = buffer [j][pflac->bufferpos] * norm ; - pflac->remain -= frame->header.channels ; + pflac->remain -= channels ; pflac->bufferpos++ ; } ; } ; @@ -272,15 +296,18 @@ flac_buffer_copy (SF_PRIVATE *psf) { double *retpcm = (double*) pflac->ptr ; double norm = (psf->norm_double == SF_TRUE) ? 1.0 / (1 << (frame->header.bits_per_sample - 1)) : 1.0 ; - for (i = 0 ; i < frame->header.blocksize && pflac->remain > 0 ; i++) - { offset = pflac->pos + i * frame->header.channels ; + for (i = 0 ; i < len && pflac->remain > 0 ; i++) + { offset = pflac->pos + i * channels ; if (pflac->bufferpos >= frame->header.blocksize) break ; - for (j = 0 ; j < frame->header.channels ; j++) + if (offset + channels > pflac->len) + break ; + + for (j = 0 ; j < channels ; j++) retpcm [offset + j] = buffer [j][pflac->bufferpos] * norm ; - pflac->remain -= frame->header.channels ; + pflac->remain -= channels ; pflac->bufferpos++ ; } ; } ; @@ -290,8 +317,8 @@ flac_buffer_copy (SF_PRIVATE *psf) return 0 ; } ; - offset = i * frame->header.channels ; - pflac->pos += i * frame->header.channels ; + offset = i * channels ; + pflac->pos += i * channels ; return offset ; } /* flac_buffer_copy */ @@ -351,14 +378,13 @@ sf_flac_eof_callback (const FLAC__StreamDecoder *UNUSED (decoder), void *client_ } /* sf_flac_eof_callback */ static FLAC__StreamDecoderWriteStatus -sf_flac_write_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__Frame *frame, const FLAC__int32 * const buffer [], void *client_data) +sf_flac_write_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__Frame *frame, const int32_t * const buffer [], void *client_data) { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; pflac->frame = frame ; pflac->bufferpos = 0 ; - pflac->bufferbackup = SF_FALSE ; pflac->wbuffer = buffer ; flac_buffer_copy (psf) ; @@ -368,7 +394,7 @@ sf_flac_write_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC static void sf_flac_meta_get_vorbiscomments (SF_PRIVATE *psf, const FLAC__StreamMetadata *metadata) -{ FLAC_TAG tags [] = +{ static FLAC_TAG tags [] = { { "title", SF_STR_TITLE }, { "copyright", SF_STR_COPYRIGHT }, { "software", SF_STR_SOFTWARE }, @@ -394,7 +420,7 @@ sf_flac_meta_get_vorbiscomments (SF_PRIVATE *psf, const FLAC__StreamMetadata *me if ((cptr = strchr (value, '=')) != NULL) value = cptr + 1 ; - psf_log_printf (psf, " %-10s : %s\n", tags [k].tag, value) ; + psf_log_printf (psf, " %-12s : %s\n", tags [k].tag, value) ; psf_store_string (psf, tags [k].type, value) ; } ; @@ -404,7 +430,8 @@ sf_flac_meta_get_vorbiscomments (SF_PRIVATE *psf, const FLAC__StreamMetadata *me static void sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__StreamMetadata *metadata, void *client_data) { SF_PRIVATE *psf = (SF_PRIVATE*) client_data ; - int bitwidth = 0 ; + FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; + int bitwidth = 0, i ; switch (metadata->type) { case FLAC__METADATA_TYPE_STREAMINFO : @@ -441,6 +468,12 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_ if (bitwidth > 0) psf_log_printf (psf, " Bit width : %d\n", bitwidth) ; + + + for (i = 0 ; i < psf->sf.channels ; i++) + pflac->rbuffer [i] = calloc (FLAC__MAX_BLOCK_SIZE, sizeof (int32_t)) ; + + pflac->wbuffer = (const int32_t* const*) pflac->rbuffer ; break ; case FLAC__METADATA_TYPE_VORBIS_COMMENT : @@ -617,7 +650,7 @@ flac_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) if (psf->error == 0) psf->dataoffset = psf_ftell (psf) ; - pflac->encbuffer = calloc (ENC_BUFFER_SIZE, sizeof (FLAC__int32)) ; + pflac->encbuffer = calloc (ENC_BUFFER_SIZE, sizeof (int32_t)) ; return psf->error ; } /* flac_write_header */ @@ -637,7 +670,6 @@ flac_open (SF_PRIVATE *psf) /* Set the default value here. Over-ridden later if necessary. */ pflac->compression = FLAC_DEFAULT_COMPRESSION_LEVEL ; - if (psf->file.mode == SFM_RDWR) return SFE_BAD_MODE_RW ; @@ -660,6 +692,10 @@ flac_open (SF_PRIVATE *psf) if ((error = flac_enc_init (psf))) return error ; + /* In an ideal world we would write the header at this point. Unfortunately + ** that would prevent string metadata being added so we have to hold off. + */ + psf->write_header = flac_write_header ; } ; @@ -702,9 +738,7 @@ flac_close (SF_PRIVATE *psf) if (psf->file.mode == SFM_WRITE) { FLAC__stream_encoder_finish (pflac->fse) ; FLAC__stream_encoder_delete (pflac->fse) ; - - if (pflac->encbuffer) - free (pflac->encbuffer) ; + free (pflac->encbuffer) ; } ; if (psf->file.mode == SFM_READ) @@ -876,18 +910,34 @@ flac_init (SF_PRIVATE *psf) static unsigned flac_read_loop (SF_PRIVATE *psf, unsigned len) { FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; + FLAC__StreamDecoderState state ; pflac->pos = 0 ; pflac->len = len ; pflac->remain = len ; + + state = FLAC__stream_decoder_get_state (pflac->fsd) ; + if (state > FLAC__STREAM_DECODER_END_OF_STREAM) + { psf_log_printf (psf, "FLAC__stream_decoder_get_state returned %s\n", FLAC__StreamDecoderStateString [state]) ; + /* Current frame is busted, so NULL the pointer. */ + pflac->frame = NULL ; + } ; + + /* First copy data that has already been decoded and buffered. */ if (pflac->frame != NULL && pflac->bufferpos < pflac->frame->header.blocksize) flac_buffer_copy (psf) ; + /* Decode some more. */ while (pflac->pos < pflac->len) { if (FLAC__stream_decoder_process_single (pflac->fsd) == 0) break ; - if (FLAC__stream_decoder_get_state (pflac->fsd) >= FLAC__STREAM_DECODER_END_OF_STREAM) + state = FLAC__stream_decoder_get_state (pflac->fsd) ; + if (state >= FLAC__STREAM_DECODER_END_OF_STREAM) + { psf_log_printf (psf, "FLAC__stream_decoder_get_state returned %s\n", FLAC__StreamDecoderStateString [state]) ; + /* Current frame is busted, so NULL the pointer. */ + pflac->frame = NULL ; break ; + } ; } ; pflac->ptr = NULL ; @@ -966,6 +1016,7 @@ flac_read_flac2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) while (total < len) { pflac->ptr = ptr + total ; readlen = (len - total > 0x1000000) ? 0x1000000 : (unsigned) (len - total) ; + current = flac_read_loop (psf, readlen) ; if (current == 0) break ; @@ -978,10 +1029,10 @@ flac_read_flac2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) static sf_count_t flac_write_s2flac (SF_PRIVATE *psf, const short *ptr, sf_count_t len) { FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - void (*convert) (const short *, FLAC__int32 *, int) ; + void (*convert) (const short *, int32_t *, int) ; int bufferlen, writecount, thiswrite ; sf_count_t total = 0 ; - FLAC__int32* buffer = pflac->encbuffer ; + int32_t* buffer = pflac->encbuffer ; switch (SF_CODEC (psf->sf.format)) { case SF_FORMAT_PCM_S8 : @@ -997,7 +1048,7 @@ flac_write_s2flac (SF_PRIVATE *psf, const short *ptr, sf_count_t len) return -1 ; } ; - bufferlen = ENC_BUFFER_SIZE / (sizeof (FLAC__int32) * psf->sf.channels) ; + bufferlen = ENC_BUFFER_SIZE / (sizeof (int32_t) * psf->sf.channels) ; bufferlen *= psf->sf.channels ; while (len > 0) @@ -1020,10 +1071,10 @@ flac_write_s2flac (SF_PRIVATE *psf, const short *ptr, sf_count_t len) static sf_count_t flac_write_i2flac (SF_PRIVATE *psf, const int *ptr, sf_count_t len) { FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - void (*convert) (const int *, FLAC__int32 *, int) ; + void (*convert) (const int *, int32_t *, int) ; int bufferlen, writecount, thiswrite ; sf_count_t total = 0 ; - FLAC__int32* buffer = pflac->encbuffer ; + int32_t* buffer = pflac->encbuffer ; switch (SF_CODEC (psf->sf.format)) { case SF_FORMAT_PCM_S8 : @@ -1039,7 +1090,7 @@ flac_write_i2flac (SF_PRIVATE *psf, const int *ptr, sf_count_t len) return -1 ; } ; - bufferlen = ENC_BUFFER_SIZE / (sizeof (FLAC__int32) * psf->sf.channels) ; + bufferlen = ENC_BUFFER_SIZE / (sizeof (int32_t) * psf->sf.channels) ; bufferlen *= psf->sf.channels ; while (len > 0) @@ -1062,10 +1113,10 @@ flac_write_i2flac (SF_PRIVATE *psf, const int *ptr, sf_count_t len) static sf_count_t flac_write_f2flac (SF_PRIVATE *psf, const float *ptr, sf_count_t len) { FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - void (*convert) (const float *, FLAC__int32 *, int, int) ; + void (*convert) (const float *, int32_t *, int, int) ; int bufferlen, writecount, thiswrite ; sf_count_t total = 0 ; - FLAC__int32* buffer = pflac->encbuffer ; + int32_t* buffer = pflac->encbuffer ; switch (SF_CODEC (psf->sf.format)) { case SF_FORMAT_PCM_S8 : @@ -1081,7 +1132,7 @@ flac_write_f2flac (SF_PRIVATE *psf, const float *ptr, sf_count_t len) return -1 ; } ; - bufferlen = ENC_BUFFER_SIZE / (sizeof (FLAC__int32) * psf->sf.channels) ; + bufferlen = ENC_BUFFER_SIZE / (sizeof (int32_t) * psf->sf.channels) ; bufferlen *= psf->sf.channels ; while (len > 0) @@ -1102,7 +1153,7 @@ flac_write_f2flac (SF_PRIVATE *psf, const float *ptr, sf_count_t len) } /* flac_write_f2flac */ static void -f2flac8_clip_array (const float *src, FLAC__int32 *dest, int count, int normalize) +f2flac8_clip_array (const float *src, int32_t *dest, int count, int normalize) { float normfact, scaled_value ; normfact = normalize ? (8.0 * 0x10) : 1.0 ; @@ -1124,7 +1175,7 @@ f2flac8_clip_array (const float *src, FLAC__int32 *dest, int count, int normaliz } /* f2flac8_clip_array */ static void -f2flac16_clip_array (const float *src, FLAC__int32 *dest, int count, int normalize) +f2flac16_clip_array (const float *src, int32_t *dest, int count, int normalize) { float normfact, scaled_value ; normfact = normalize ? (8.0 * 0x1000) : 1.0 ; @@ -1144,7 +1195,7 @@ f2flac16_clip_array (const float *src, FLAC__int32 *dest, int count, int normali } /* f2flac16_clip_array */ static void -f2flac24_clip_array (const float *src, FLAC__int32 *dest, int count, int normalize) +f2flac24_clip_array (const float *src, int32_t *dest, int count, int normalize) { float normfact, scaled_value ; normfact = normalize ? (8.0 * 0x100000) : 1.0 ; @@ -1167,7 +1218,7 @@ f2flac24_clip_array (const float *src, FLAC__int32 *dest, int count, int normali } /* f2flac24_clip_array */ static void -f2flac8_array (const float *src, FLAC__int32 *dest, int count, int normalize) +f2flac8_array (const float *src, int32_t *dest, int count, int normalize) { float normfact = normalize ? (1.0 * 0x7F) : 1.0 ; while (--count >= 0) @@ -1175,7 +1226,7 @@ f2flac8_array (const float *src, FLAC__int32 *dest, int count, int normalize) } /* f2flac8_array */ static void -f2flac16_array (const float *src, FLAC__int32 *dest, int count, int normalize) +f2flac16_array (const float *src, int32_t *dest, int count, int normalize) { float normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; while (--count >= 0) @@ -1183,7 +1234,7 @@ f2flac16_array (const float *src, FLAC__int32 *dest, int count, int normalize) } /* f2flac16_array */ static void -f2flac24_array (const float *src, FLAC__int32 *dest, int count, int normalize) +f2flac24_array (const float *src, int32_t *dest, int count, int normalize) { float normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ; while (--count >= 0) @@ -1193,10 +1244,10 @@ f2flac24_array (const float *src, FLAC__int32 *dest, int count, int normalize) static sf_count_t flac_write_d2flac (SF_PRIVATE *psf, const double *ptr, sf_count_t len) { FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ; - void (*convert) (const double *, FLAC__int32 *, int, int) ; + void (*convert) (const double *, int32_t *, int, int) ; int bufferlen, writecount, thiswrite ; sf_count_t total = 0 ; - FLAC__int32* buffer = pflac->encbuffer ; + int32_t* buffer = pflac->encbuffer ; switch (SF_CODEC (psf->sf.format)) { case SF_FORMAT_PCM_S8 : @@ -1212,7 +1263,7 @@ flac_write_d2flac (SF_PRIVATE *psf, const double *ptr, sf_count_t len) return -1 ; } ; - bufferlen = ENC_BUFFER_SIZE / (sizeof (FLAC__int32) * psf->sf.channels) ; + bufferlen = ENC_BUFFER_SIZE / (sizeof (int32_t) * psf->sf.channels) ; bufferlen *= psf->sf.channels ; while (len > 0) @@ -1233,7 +1284,7 @@ flac_write_d2flac (SF_PRIVATE *psf, const double *ptr, sf_count_t len) } /* flac_write_d2flac */ static void -d2flac8_clip_array (const double *src, FLAC__int32 *dest, int count, int normalize) +d2flac8_clip_array (const double *src, int32_t *dest, int count, int normalize) { double normfact, scaled_value ; normfact = normalize ? (8.0 * 0x10) : 1.0 ; @@ -1255,7 +1306,7 @@ d2flac8_clip_array (const double *src, FLAC__int32 *dest, int count, int normali } /* d2flac8_clip_array */ static void -d2flac16_clip_array (const double *src, FLAC__int32 *dest, int count, int normalize) +d2flac16_clip_array (const double *src, int32_t *dest, int count, int normalize) { double normfact, scaled_value ; normfact = normalize ? (8.0 * 0x1000) : 1.0 ; @@ -1277,7 +1328,7 @@ d2flac16_clip_array (const double *src, FLAC__int32 *dest, int count, int normal } /* d2flac16_clip_array */ static void -d2flac24_clip_array (const double *src, FLAC__int32 *dest, int count, int normalize) +d2flac24_clip_array (const double *src, int32_t *dest, int count, int normalize) { double normfact, scaled_value ; normfact = normalize ? (8.0 * 0x100000) : 1.0 ; @@ -1299,7 +1350,7 @@ d2flac24_clip_array (const double *src, FLAC__int32 *dest, int count, int normal } /* d2flac24_clip_array */ static void -d2flac8_array (const double *src, FLAC__int32 *dest, int count, int normalize) +d2flac8_array (const double *src, int32_t *dest, int count, int normalize) { double normfact = normalize ? (1.0 * 0x7F) : 1.0 ; while (--count >= 0) @@ -1307,7 +1358,7 @@ d2flac8_array (const double *src, FLAC__int32 *dest, int count, int normalize) } /* d2flac8_array */ static void -d2flac16_array (const double *src, FLAC__int32 *dest, int count, int normalize) +d2flac16_array (const double *src, int32_t *dest, int count, int normalize) { double normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ; while (--count >= 0) @@ -1315,7 +1366,7 @@ d2flac16_array (const double *src, FLAC__int32 *dest, int count, int normalize) } /* d2flac16_array */ static void -d2flac24_array (const double *src, FLAC__int32 *dest, int count, int normalize) +d2flac24_array (const double *src, int32_t *dest, int count, int normalize) { double normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ; while (--count >= 0) @@ -1369,7 +1420,7 @@ flac_byterate (SF_PRIVATE *psf) } /* flac_byterate */ -#else /* HAVE_EXTERNAL_LIBS */ +#else /* HAVE_EXTERNAL_XIPH_LIBS */ int flac_open (SF_PRIVATE *psf) diff --git a/src/ogg_vorbis.c b/src/ogg_vorbis.c index 2dad604..78acd38 100644 --- a/src/ogg_vorbis.c +++ b/src/ogg_vorbis.c @@ -70,15 +70,9 @@ #if HAVE_EXTERNAL_XIPH_LIBS - #include #include - -#ifdef __TIZEN__ -#include /* for dlopen */ -#else #include -#endif #include "ogg.h" @@ -133,11 +127,6 @@ typedef struct /* Encoding quality in range [0.0, 1.0]. */ double quality ; - -#ifdef __TIZEN__ - /* func ptr for encoder */ - void *dl; -#endif } VORBIS_PRIVATE ; static int @@ -349,41 +338,6 @@ vorbis_read_header (SF_PRIVATE *psf, int log_data) return 0 ; } /* vorbis_read_header */ - -#ifdef __TIZEN__ -#define VORBIS_ENC_SO_NAME "/usr/lib/libvorbisenc.so.2" /* FIXME : Any good way to avoid hardcoding? */ -#define VORBIS_ENC_INIT_VBR "vorbis_encode_init_vbr" - -static int -_vorbis_encode_init(SF_PRIVATE *psf) -{ - int (*fn) (vorbis_info *, long, long, float); - void *dl = NULL; - VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; - - /* load so */ - dl = dlopen(VORBIS_ENC_SO_NAME, RTLD_GLOBAL | RTLD_NOW); - if (!dl) { - psf_log_printf (psf, "failed to dlopen [%s], error [%s]\n", VORBIS_ENC_SO_NAME, dlerror()); - return -1; - } - dlerror(); - - vdata->dl = dl; - - /* load symbol */ - fn = dlsym(dl, VORBIS_ENC_INIT_VBR); - if (!fn) { - psf_log_printf (psf, "failed to dlsym [%s], error [%s]\n", VORBIS_ENC_INIT_VBR, dlerror()); - return -1; - } - dlerror(); - - /* call function */ - return fn(&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, vdata->quality); -} -#endif /* __TIZEN__ */ - static int vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) { @@ -394,11 +348,7 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) vorbis_info_init (&vdata->vinfo) ; /* The style of encoding should be selectable here, VBR quality mode. */ -#ifdef __TIZEN__ - ret = _vorbis_encode_init(psf); -#else ret = vorbis_encode_init_vbr (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, vdata->quality) ; -#endif #if 0 ret = vorbis_encode_init (&vdata->vinfo, psf->sf.channels, psf->sf.samplerate, -1, 128000, -1) ; /* average bitrate mode */ @@ -533,13 +483,6 @@ vorbis_close (SF_PRIVATE *psf) vorbis_comment_clear (&vdata->vcomment) ; vorbis_info_clear (&vdata->vinfo) ; -#ifdef __TIZEN__ - if (vdata->dl) { - dlclose(vdata->dl); - vdata->dl = NULL; - } -#endif - return 0 ; } /* vorbis_close */ -- 2.7.4