shithub: sox

Download patch

ref: 158fe58a780379917fd3c118cd0ed913df4a152e
parent: 4f128442d49e9f07699a06238230c1727b126d8c
author: Doug Cook <idigdoug@users.sourceforge.net>
date: Fri Mar 16 00:25:27 EDT 2012

Fix direct use of format->fp in 8svx, flac, sndfile, vorbis
Also update msvc10 projects for newer sndfile and zlib
Also clean up some old cruft in cmakefiles.

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -125,7 +125,6 @@
 endif (NOT HAVE_LAME_LAME_H)
 optional(HAVE_TWOLAME_H twolame.h twolame twolame_init mp3)
 optional(HAVE_MAGIC magic.h magic magic_open "")
-#optional(HAVE_OGG_SPEEX speex/speex.h speex speex_decoder_init speex)
 optional2(HAVE_PNG png.h png png_set_rows z uncompress spectrogram)
 if (HAVE_PNG)
   check_library_exists(z uncompress "" spectrogram1)
@@ -164,7 +163,6 @@
 
 set(CMAKE_REQUIRED_LIBRARIES mp3lame m)
 check_function_exists("lame_set_VBR_quality" HAVE_LAME_SET_VBR_QUALITY)
-check_function_exists("id3tag_set_fieldvalue" HAVE_ID3TAG_SET_FIELDVALUE)
 
 if (HAVE_SUN_AUDIOIO_H OR HAVE_SYS_AUDIOIO_H)
   set(HAVE_SUN_AUDIO 1)
--- a/msvc10/.gitignore
+++ b/msvc10/.gitignore
@@ -7,4 +7,4 @@
 Sox.ncb
 Sox.opensdf
 Sox.sdf
-Sox.suo
+*.suo
--- a/msvc10/LibSndFile.vcxproj
+++ b/msvc10/LibSndFile.vcxproj
@@ -138,6 +138,9 @@
     <ClCompile Include="..\..\libsndfile\src\ms_adpcm.c" />
     <ClCompile Include="..\..\libsndfile\src\nist.c" />
     <ClCompile Include="..\..\libsndfile\src\ogg.c" />
+    <ClCompile Include="..\..\libsndfile\src\ogg_pcm.c" />
+    <ClCompile Include="..\..\libsndfile\src\ogg_speex.c" />
+    <ClCompile Include="..\..\libsndfile\src\ogg_vorbis.c" />
     <ClCompile Include="..\..\libsndfile\src\paf.c" />
     <ClCompile Include="..\..\libsndfile\src\pcm.c" />
     <ClCompile Include="..\..\libsndfile\src\pvf.c" />
--- a/msvc10/LibZLib.vcxproj
+++ b/msvc10/LibZLib.vcxproj
@@ -51,7 +51,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;Z_SOLO;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <MinimalRebuild>true</MinimalRebuild>
       <ExceptionHandling>
@@ -68,6 +68,7 @@
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <CallingConvention>Cdecl</CallingConvention>
+      <DisableSpecificWarnings>4142</DisableSpecificWarnings>
     </ClCompile>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -74,7 +75,7 @@
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>WIN32;Z_SOLO;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <ExceptionHandling>
       </ExceptionHandling>
@@ -89,6 +90,7 @@
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
       <CallingConvention>Cdecl</CallingConvention>
+      <DisableSpecificWarnings>4142</DisableSpecificWarnings>
     </ClCompile>
   </ItemDefinitionGroup>
   <ItemGroup>
--- a/msvc10/SoX/soxconfig.h
+++ b/msvc10/SoX/soxconfig.h
@@ -81,10 +81,7 @@
 #define HAVE_PNG 1
 
 #define HAVE_SNDFILE 1
-#define HAVE_SNDFILE_1_0_12 1
 #define HAVE_SNDFILE_1_0_18 1
-#define HAVE_SNDFILE_H 1
-#define HAVE_SFC_SET_SCALE_FLOAT_INT_READ 1
 #define HAVE_SFC_SET_SCALE_INT_FLOAT_WRITE 1
 #define STATIC_SNDFILE 1
 #define DL_SNDFILE 1
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -7,10 +7,15 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#define BUFLEN 512
+
 /* Private data used by writer */
 typedef struct{
   uint32_t nsamples;
-  FILE * ch[4];
+  uint32_t left;
+  off_t ch0_pos;
+  sox_uint8_t buf[4][BUFLEN];
+  FILE* tmp[4];
 } priv_t;
 
 static void svxwriteheader(sox_format_t *, size_t);
@@ -29,11 +34,9 @@
         uint32_t totalsize;
         uint32_t chunksize;
 
-        uint32_t channels, i;
+        uint32_t channels;
         unsigned short rate;
 
-        off_t chan1_pos;
-
         if (! ft->seekable)
         {
                 lsx_fail_errno(ft,SOX_EINVAL,"8svx input file must be a file, not a pipe");
@@ -149,6 +152,8 @@
                 return(SOX_EOF);
         }
         lsx_readdw(ft, &(p->nsamples));
+        p->left = p->nsamples;
+        p->ch0_pos = lsx_tell(ft);
 
         ft->signal.length = p->nsamples;
         ft->signal.channels = channels;
@@ -156,30 +161,6 @@
         ft->encoding.encoding = SOX_ENCODING_SIGN2;
         ft->encoding.bits_per_sample = 8;
 
-        /* open files to channels */
-        p->ch[0] = ft->fp;
-        chan1_pos = lsx_tell(ft);
-
-        for (i = 1; i < channels; i++) {
-                if ((p->ch[i] = fopen(ft->filename, "rb")) == NULL)
-                {
-                        lsx_fail_errno(ft,errno,"Can't open channel file '%s'",
-                                ft->filename);
-                        return(SOX_EOF);
-                }
-
-                /* position channel files */
-                if (fseeko(p->ch[i],chan1_pos,SEEK_SET))
-                {
-                    lsx_fail_errno (ft,errno,"Can't position channel %d",i);
-                    return(SOX_EOF);
-                }
-                if (fseeko(p->ch[i],(off_t)(p->nsamples/channels*i),SEEK_CUR))
-                {
-                    lsx_fail_errno (ft,errno,"Can't seek channel %d",i);
-                    return(SOX_EOF);
-                }
-        }
         return(SOX_SUCCESS);
 }
 
@@ -188,39 +169,41 @@
 /*======================================================================*/
 static size_t read_samples(sox_format_t * ft, sox_sample_t *buf, size_t nsamp)
 {
-        unsigned char datum;
-        size_t done = 0, i;
+    size_t done = 0;
 
-        priv_t * p = (priv_t * ) ft->priv;
+    priv_t * p = (priv_t * ) ft->priv;
+    size_t frames = nsamp / ft->signal.channels;
+    unsigned width = p->nsamples / ft->signal.channels;
 
-        while (done < nsamp) {
-                for (i = 0; i < ft->signal.channels; i++) {
-                        /* FIXME: don't pass FILE pointers! */
-                        datum = getc(p->ch[i]);
-                        if (feof(p->ch[i]))
-                                return done;
-                        /* scale signed up to long's range */
-                        *buf++ = SOX_SIGNED_8BIT_TO_SAMPLE(datum,);
-                }
-                done += ft->signal.channels;
-        }
-        return done;
-}
+    if (p->left < frames)
+        frames = p->left;
 
-/*======================================================================*/
-/*                         8SVXSTOPREAD                                 */
-/*======================================================================*/
-static int stopread(sox_format_t * ft)
-{
+    while (done != frames) {
+        size_t chunk = frames - done;
         size_t i;
+        unsigned ch;
 
-        priv_t * p = (priv_t * ) ft->priv;
+        if (chunk > BUFLEN)
+            chunk = BUFLEN;
 
-        /* close channel files */
-        for (i = 1; i < ft->signal.channels; i++) {
-                fclose (p->ch[i]);
+        for (ch = 0; ch != ft->signal.channels; ch++) {
+            if (lsx_seeki(ft, p->ch0_pos + ch * width, SEEK_SET) ||
+                chunk != lsx_readbuf(ft, p->buf[ch], chunk))
+                return done * ft->signal.channels;
         }
-        return(SOX_SUCCESS);
+
+        for (i = 0; i != chunk; i++) {
+            for (ch = 0; ch != ft->signal.channels; ch++) {
+                /* scale signed up to long's range */
+                *buf++ = SOX_SIGNED_8BIT_TO_SAMPLE(p->buf[ch][i], dummy);
+            }
+        }
+
+        done += chunk;
+        p->left -= chunk * ft->signal.channels;
+        p->ch0_pos += chunk;
+    }
+    return done * ft->signal.channels;
 }
 
 /*======================================================================*/
@@ -232,9 +215,8 @@
         size_t i;
 
         /* open channel output files */
-        p->ch[0] = ft->fp;
-        for (i = 1; i < ft->signal.channels; i++) {
-                if ((p->ch[i] = lsx_tmpfile()) == NULL)
+        for (i = 0; i < ft->signal.channels; i++) {
+                if ((p->tmp[i] = lsx_tmpfile()) == NULL)
                 {
                         lsx_fail_errno(ft,errno,"Can't open channel output file");
                         return(SOX_EOF);
@@ -241,9 +223,7 @@
                 }
         }
 
-        /* write header (channel 0) */
         p->nsamples = 0;
-        svxwriteheader(ft, (size_t) p->nsamples);
         return(SOX_SUCCESS);
 }
 
@@ -264,8 +244,7 @@
         while(done < len) {
                 for (i = 0; i < ft->signal.channels; i++) {
                         datum = SOX_SAMPLE_TO_SIGNED_8BIT(*buf++, ft->clips);
-                        /* FIXME: Needs to pass ft struct and not FILE */
-                        putc(datum, p->ch[i]);
+                        putc(datum, p->tmp[i]);
                 }
                 done += ft->signal.channels;
         }
@@ -283,22 +262,24 @@
         size_t i, len;
         char svxbuf[512];
 
+        svxwriteheader(ft, (size_t) p->nsamples);
+
         /* append all channel pieces to channel 0 */
         /* close temp files */
-        for (i = 1; i < ft->signal.channels; i++) {
-                if (fseeko(p->ch[i], (off_t)0, 0))
+        for (i = 0; i < ft->signal.channels; i++) {
+                if (fseeko(p->tmp[i], (off_t)0, 0))
                 {
                         lsx_fail_errno (ft,errno,"Can't rewind channel output file %lu",(unsigned long)i);
                         return(SOX_EOF);
                 }
-                while (!feof(p->ch[i])) {
-                        len = fread(svxbuf, (size_t) 1, (size_t) 512, p->ch[i]);
-                        if (fwrite (svxbuf, (size_t) 1, len, p->ch[0]) != len) {
+                while (!feof(p->tmp[i])) {
+                        len = fread(svxbuf, (size_t) 1, (size_t) 512, p->tmp[i]);
+                        if (lsx_writebuf(ft, svxbuf, len) != len) {
                           lsx_fail_errno (ft,errno,"Can't write channel output file %lu",(unsigned long)i);
                           return SOX_EOF;
                         }
                 }
-                fclose (p->ch[i]);
+                fclose (p->tmp[i]);
         }
 
         /* add a pad byte if BODY size is odd */
@@ -305,13 +286,6 @@
         if(p->nsamples % 2 != 0)
             lsx_writeb(ft, '\0');
 
-        /* fixup file sizes in header */
-        if (lsx_seeki(ft, (off_t)0, 0) != 0)
-        {
-                lsx_fail_errno(ft,errno,"can't rewind output file to rewrite 8SVX header");
-                return(SOX_EOF);
-        }
-        svxwriteheader(ft, (size_t) p->nsamples);
         return(SOX_SUCCESS);
 }
 
@@ -360,7 +334,7 @@
   static sox_format_handler_t const handler = {SOX_LIB_VERSION_CODE,
     "Amiga audio format (a subformat of the Interchange File Format)",
     names, SOX_FILE_BIG_END|SOX_FILE_MONO|SOX_FILE_STEREO|SOX_FILE_QUAD,
-    startread, read_samples, stopread,
+    startread, read_samples, NULL,
     startwrite, write_samples, stopwrite,
     NULL, write_encodings, NULL, sizeof(priv_t)
   };
--- a/src/flac.c
+++ b/src/flac.c
@@ -62,9 +62,58 @@
 }
 #endif
 
+static FLAC__StreamDecoderReadStatus decoder_read_callback(FLAC__StreamDecoder const* decoder, FLAC__byte buffer[], size_t* bytes, void* ft_data)
+{
+  sox_format_t* ft = (sox_format_t*)ft_data;
+  if(*bytes > 0) {
+    *bytes = lsx_readbuf(ft, buffer, *bytes);
+    if(lsx_error(ft))
+      return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
+    else if(*bytes == 0)
+      return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
+    else
+      return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
+  }
+  else
+    return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
+}
 
-static void FLAC__decoder_metadata_callback(FLAC__StreamDecoder const * const flac, FLAC__StreamMetadata const * const metadata, void * const client_data)
+static FLAC__StreamDecoderSeekStatus decoder_seek_callback(FLAC__StreamDecoder const* decoder, FLAC__uint64 absolute_byte_offset, void* ft_data)
 {
+  sox_format_t* ft = (sox_format_t*)ft_data;
+  if(lsx_seeki(ft, (off_t)absolute_byte_offset, SEEK_SET) < 0)
+    return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
+  else
+    return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
+}
+
+static FLAC__StreamDecoderTellStatus decoder_tell_callback(FLAC__StreamDecoder const* decoder, FLAC__uint64* absolute_byte_offset, void* ft_data)
+{
+  sox_format_t* ft = (sox_format_t*)ft_data;
+  off_t pos;
+  if((pos = lsx_tell(ft)) < 0)
+    return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
+  else {
+    *absolute_byte_offset = (FLAC__uint64)pos;
+    return FLAC__STREAM_DECODER_TELL_STATUS_OK;
+  }
+}
+
+static FLAC__StreamDecoderLengthStatus decoder_length_callback(FLAC__StreamDecoder const* decoder, FLAC__uint64* stream_length, void* ft_data)
+{
+  sox_format_t* ft = (sox_format_t*)ft_data;
+  *stream_length = lsx_filelength(ft);
+  return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
+}
+
+static FLAC__bool decoder_eof_callback(FLAC__StreamDecoder const* decoder, void* ft_data)
+{
+  sox_format_t* ft = (sox_format_t*)ft_data;
+  return lsx_eof(ft) ? 1 : 0;
+}
+
+static void decoder_metadata_callback(FLAC__StreamDecoder const * const flac, FLAC__StreamMetadata const * const metadata, void * const client_data)
+{
   sox_format_t * ft = (sox_format_t *) client_data;
   priv_t * p = (priv_t *)ft->priv;
 
@@ -94,7 +143,7 @@
 
 
 
-static void FLAC__decoder_error_callback(FLAC__StreamDecoder const * const flac, FLAC__StreamDecoderErrorStatus const status, void * const client_data)
+static void decoder_error_callback(FLAC__StreamDecoder const * const flac, FLAC__StreamDecoderErrorStatus const status, void * const client_data)
 {
   sox_format_t * ft = (sox_format_t *) client_data;
 
@@ -105,7 +154,7 @@
 
 
 
-static FLAC__StreamDecoderWriteStatus FLAC__frame_decode_callback(FLAC__StreamDecoder const * const flac, FLAC__Frame const * const frame, FLAC__int32 const * const buffer[], void * const client_data)
+static FLAC__StreamDecoderWriteStatus decoder_write_callback(FLAC__StreamDecoder const * const flac, FLAC__Frame const * const frame, FLAC__int32 const * const buffer[], void * const client_data)
 {
   sox_format_t * ft = (sox_format_t *) client_data;
   priv_t * p = (priv_t *)ft->priv;
@@ -138,13 +187,20 @@
 
   FLAC__stream_decoder_set_md5_checking(p->decoder, sox_true);
   FLAC__stream_decoder_set_metadata_respond_all(p->decoder);
-  if (FLAC__stream_decoder_init_FILE(p->decoder, ft->fp, /* Not using SoX IO */
-      FLAC__frame_decode_callback, FLAC__decoder_metadata_callback,
-      FLAC__decoder_error_callback, ft) != FLAC__STREAM_DECODER_INIT_STATUS_OK){
+  if (FLAC__stream_decoder_init_stream(
+      p->decoder,
+      decoder_read_callback,
+      ft->seekable ? decoder_seek_callback : NULL,
+      ft->seekable ? decoder_tell_callback : NULL,
+      ft->seekable ? decoder_length_callback : NULL,
+      ft->seekable ? decoder_eof_callback : NULL,
+      decoder_write_callback,
+      decoder_metadata_callback,
+      decoder_error_callback,
+      ft) != FLAC__STREAM_DECODER_INIT_STATUS_OK){
     lsx_fail_errno(ft, SOX_EHDR, "FLAC ERROR initialising decoder");
     return SOX_EOF;
   }
-  ft->fp = NULL; /* Transfer ownership of fp to FLAC */
 
   if (!FLAC__stream_decoder_process_until_end_of_metadata(p->decoder)) {
     lsx_fail_errno(ft, SOX_EHDR, "FLAC ERROR whilst decoding metadata");
@@ -250,7 +306,7 @@
   (void) encoder;
   if (!ft->seekable)
     return FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED;
-  else if ((pos = ftello(ft->fp)) < 0)
+  else if ((pos = lsx_tell(ft)) < 0)
     return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR;
   else {
     *absolute_byte_offset = (FLAC__uint64)pos;
--- a/src/sndfile.c
+++ b/src/sndfile.c
@@ -222,7 +222,7 @@
   sox_format_t *ft = (sox_format_t *)user_data;
 
   /* lsf excepts unbuffered I/O behavior for get_filelen() so force that */
-  fflush(ft->fp);
+  lsx_flush(ft);
 
   return (sf_count_t)lsx_filelength((sox_format_t *)user_data);
 }
--- a/src/sox.c
+++ b/src/sox.c
@@ -235,7 +235,7 @@
 
   if (file_count) {
     if (ofile->ft) {
-      if (!success && ofile->ft->fp) {   /* If we failed part way through */
+      if (!success && ofile->ft->io_type == lsx_io_file) {   /* If we failed part way through */
         struct stat st;                  /* writing a normal file, remove it. */
         if (!stat(ofile->ft->filename, &st) &&
             (st.st_mode & S_IFMT) == S_IFREG)
--- a/src/sox.h
+++ b/src/sox.h
@@ -1118,10 +1118,10 @@
 used by sox_globals_t.output_message_handler.
 */
 typedef void (LSX_API * sox_output_message_handler_t)(
-    unsigned level,                       /* 1 = FAIL, 2 = WARN, 3 = INFO, 4 = DEBUG, 5 = DEBUG_MORE, 6 = DEBUG_MOST. */
-    LSX_PARAM_IN_Z char const * filename, /* Source code __FILENAME__ from which message originates. */
-    LSX_PARAM_IN_PRINTF char const * fmt, /* Message format string. */
-    LSX_PARAM_IN va_list ap               /* Message format parameters. */
+    unsigned level,                       /**< 1 = FAIL, 2 = WARN, 3 = INFO, 4 = DEBUG, 5 = DEBUG_MORE, 6 = DEBUG_MOST. */
+    LSX_PARAM_IN_Z char const * filename, /**< Source code __FILENAME__ from which message originates. */
+    LSX_PARAM_IN_PRINTF char const * fmt, /**< Message format string. */
+    LSX_PARAM_IN va_list ap               /**< Message format parameters. */
     );
 
 /**
--- a/src/soxconfig.h.cmake
+++ b/src/soxconfig.h.cmake
@@ -16,7 +16,6 @@
 #cmakedefine HAVE_GLOB_H              1
 #define HAVE_GSM                      1
 #cmakedefine HAVE_ID3TAG              1
-#cmakedefine HAVE_ID3TAG_SET_FIELDVALUE 1
 #cmakedefine HAVE_INTTYPES_H          1
 #cmakedefine HAVE_IO_H                1
 #cmakedefine HAVE_LAME_LAME_H         1
@@ -28,7 +27,6 @@
 #cmakedefine HAVE_MAGIC               1
 #cmakedefine HAVE_MKSTEMP             1
 #cmakedefine HAVE_MP3                 1
-#cmakedefine HAVE_OGG_SPEEX           1
 #cmakedefine HAVE_OGG_VORBIS          1
 #cmakedefine HAVE_OPENMP              1
 #cmakedefine HAVE_OSS                 1
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -61,15 +61,18 @@
 } priv_t;
 
 /******** Callback functions used in ov_open_callbacks ************/
-static int myclose(void *datasource UNUSED)
+
+static size_t callback_read(void* ptr, size_t size, size_t nmemb, void* ft_data)
 {
-  /* Do nothing so sox can close the file for us */
-  return 0;
+  sox_format_t* ft = (sox_format_t*)ft_data;
+  size_t ret = lsx_readbuf(ft, ptr, size * nmemb);
+  return ret / size;
 }
 
-static int _fseeko64_wrap(FILE * f, ogg_int64_t off, int whence)
+static int callback_seek(void* ft_data, ogg_int64_t off, int whence)
 {
-  int ret = fseeko(f, (off_t)off, whence);
+  sox_format_t* ft = (sox_format_t*)ft_data;
+  int ret = ft->seekable ? lsx_seeki(ft, off, whence) : -1;
 
   if (ret == EBADF)
     ret = -1;
@@ -76,6 +79,18 @@
   return ret;
 }
 
+static int callback_close(void* ft_data UNUSED)
+{
+  /* Do nothing so sox can close the file for us */
+  return 0;
+}
+
+static long callback_tell(void* ft_data)
+{
+  sox_format_t* ft = (sox_format_t*)ft_data;
+  return lsx_tell(ft);
+}
+
 /********************* End callbacks *****************************/
 
 
@@ -94,10 +109,10 @@
   int i;
 
   ov_callbacks callbacks = {
-    (size_t(*)(void *, size_t, size_t, void *)) fread,
-    (int (*)(void *, ogg_int64_t, int)) _fseeko64_wrap,
-    (int (*)(void *)) myclose,
-    (long (*)(void *)) ftell
+    callback_read,
+    callback_seek,
+    callback_close,
+    callback_tell
   };
 
   /* Allocate space for decoding structure */
@@ -104,7 +119,7 @@
   vb->vf = lsx_malloc(sizeof(OggVorbis_File));
 
   /* Init the decoder */
-  if (ov_open_callbacks(ft->fp, vb->vf, NULL, (size_t) 0, callbacks) < 0) {
+  if (ov_open_callbacks(ft, vb->vf, NULL, (size_t) 0, callbacks) < 0) {
     lsx_fail_errno(ft, SOX_EHDR, "Input not an Ogg Vorbis audio stream");
     return (SOX_EOF);
   }