Bugs item #3592482, was opened at 2012-12-04 10:12
Message generated for change (Settings changed) made by robs
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=110706&aid=3592482&group_id=10706

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: MrMod (tschmula)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug in rate effect

Initial Comment:
Sox hangs when the rate effect causes the number of samples to go past 2^31.  
To reproduce:
Sox -V -S -r 48000 -b 24 -n -n synth 3:10:00 pinknoise rate 96000 rate 192000

I located the problem in rate_flush function in rate.c.  The 'size_t remaining' 
variable is cast improperly to (int), which doesn't work at the 2^31 boundary 
for integers.  To fix, simply change the if statement from:
if ((int)remaining > 0) {
to
if(samples_out > p->samples_out) {

Here is a patch file with the fix:
diff -cr sox-14.4.0/src/rate.c sox-14.4.0/src-update/rate.c
*** sox-14.4.0/src/rate.c       Tue Dec 27 22:15:32 2011
--- sox-14.4.0/src-update/rate.c        Tue Dec  4 11:04:47 2012
***************
*** 397,403 ****
    size_t remaining = samples_out - p->samples_out;
    sample_t * buff = calloc(1024, sizeof(*buff));
  
!   if ((int)remaining > 0) {
      while ((size_t)fifo_occupancy(fifo) < remaining) {
        rate_input(p, buff, (size_t) 1024);
        rate_process(p);
--- 397,403 ----
    size_t remaining = samples_out - p->samples_out;
    sample_t * buff = calloc(1024, sizeof(*buff));
  
!   if (samples_out > p->samples_out) {
      while ((size_t)fifo_occupancy(fifo) < remaining) {
        rate_input(p, buff, (size_t) 1024);
        rate_process(p);

Sincerely,
MrMod

----------------------------------------------------------------------

Comment By: robs (robs)
Date: 2012-12-05 22:34

Message:
Now in git. Good catch—thanks!

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=110706&aid=3592482&group_id=10706

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

Reply via email to