I’ve found that the function getLength (in AmAudioFile), used to compute the
duration in ms of a file, returns a wrong value when the file size is “big”,
for example greater than 9-10 MB.
Analyzing the code, I think that there is a integer overflow issue in the
computation,
although<https://www.google.it/search?es_sm=122&q=although&spell=1&sa=X&ei=sPg7VZW-O8PvUs_VgOgL&ved=0CBsQvwUoAA>
the resulted length in ms is included in a 32 bit integer, because there is a
multiplication by 1000 before dividing by the rate.
The original code is:
return
fmt->bytes2samples(data_size)*1000
/ fmt->getRate();
I suggest the following change to avoid the int overflow:
float rate = fmt->getRate() / 1000;
return (int) (fmt->bytes2samples(data_size) / rate);
I’ve tried the change and now the result is right also when the file is greater
than 10Mb (for a WAV is about 10 min).
I hope you can apply this patch for everybody
Best regards
Alessandro Rovetto
------------------------------------------------------------------------
Alessandro Rovetto
Product Development Manager
ContaCT Center
Reitek
------------------------------------------------------------------------
Informativa Privacy - Ai sensi del D. Lgs n. 196/2003 (Codice Privacy)
precisiamo che le informazioni contenute in questo messaggio sono riservate e a
uso esclusivo del destinatario. Ogni uso, copia o distribuzione non autorizzata
è proibita e passibile di sanzioni ai termini di legge. Reitek non è
responsabile di eventuali copie o distribuzioni non autorizzate. Se questo
messaggio è stato ricevuto per errore, preghiamo gentilmente di eliminarlo e di
informare il mittente. Grazie.
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev