shithub: sox

Download patch

ref: 28aa893ed1c280992d6fadb949db5d2221d91a48
parent: bf53127e168fffb7718c61000d2da7984e0ec229
author: cbagwell <cbagwell>
date: Thu Sep 8 21:17:07 EDT 2005

Fixing seeking in AIFF, SMP, and WAV.  Would incorrectly calc
remaining samples based on bytes and not samples.

--- a/Changelog
+++ b/Changelog
@@ -11,6 +11,8 @@
   o Declare st_signalinfo_t to specifically be signed in case
     platform does not default ot signed chars.  This
     is required for NetBSD/powerpc.
+  o When seek()ing in AIFF, SMP, and WAV handlers, remaining samples were
+    incorrectly computed based on bytes and not samples.  Jukka
 
 sox-12.17.8
 -----------
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -91,7 +91,7 @@
     ft->st_errno = st_seek(ft, new_offset, SEEK_SET);
 
     if (ft->st_errno == ST_SUCCESS)
-        aiff->nsamples = ft->length - new_offset;
+        aiff->nsamples = ft->length - (new_offset / ft->info.size);
 
     return(ft->st_errno);
 }
--- a/src/smp.c
+++ b/src/smp.c
@@ -191,7 +191,7 @@
     ft->st_errno = st_seek(ft, new_offset, SEEK_SET);
 
     if( ft->st_errno == ST_SUCCESS )
-        smp->NoOfSamps = ft->length - new_offset;
+        smp->NoOfSamps = ft->length - (new_offset / ft->info.size);
 
     return(ft->st_errno);
 }
--- a/src/wav.c
+++ b/src/wav.c
@@ -1769,7 +1769,7 @@
             ft->st_errno = st_seek(ft, new_offset, SEEK_SET);
 
             if( ft->st_errno == ST_SUCCESS )
-                wav->numSamples = ft->length - new_offset;
+                wav->numSamples = ft->length - (new_offset / ft->info.size);
     }
 
     return(ft->st_errno);