It seems the root of the bug is some misunderstanding between the parsing and the decoding code about samples/frames per block. What is parsed as "samplesPerBlock" in the .wav file is a _frame_ count in reality, if we follow what seem to be libaudiofile's conventions. If you just decode less samples as in the proposed patch you'll always skip the second half of each buffer. The appended patch works better for me. It still doesn't protect against buffer overflows.
best regards Matthias ------------------------------------------------------------------- ------------------------------------------------------------------- Forschungszentrum Juelich GmbH 52425 Juelich Sitz der Gesellschaft: Juelich Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498 Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender), Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt, Dr. Sebastian M. Schmidt ------------------------------------------------------------------- -------------------------------------------------------------------
$NetBSD$ --- ./libaudiofile/wave.c.orig 2004-03-06 07:39:23.000000000 +0100 +++ ./libaudiofile/wave.c @@ -220,7 +220,8 @@ static status ParseFormat (AFfilehandle extraByteCount = LENDIAN_TO_HOST_INT16(extraByteCount); af_fread(&samplesPerBlock, 1, 2, fp); - samplesPerBlock = LENDIAN_TO_HOST_INT16(samplesPerBlock); + samplesPerBlock = LENDIAN_TO_HOST_INT16(samplesPerBlock) + * track->f.channelCount; af_fread(&numCoefficients, 1, 2, fp); numCoefficients = LENDIAN_TO_HOST_INT16(numCoefficients);