libsndfile: update to 1.0.19 (LBSNDF-7)

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0186
http://www.mega-nerd.com/libsndfile/libsndfile-1.0.19.tar.gz

This will likely require a fresh boostrap to updated source checkouts.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13415 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2009-05-21 21:09:30 +00:00
parent d875d23de5
commit 77fab7603a
252 changed files with 28081 additions and 6032 deletions

View File

@@ -1,5 +1,5 @@
/*
** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 1999-2009 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@ static int truncate (const char *filename, int ignored) ;
#include <sndfile.h>
#include "utils.h"
#include "generate.h"
#define SAMPLE_RATE 11025
#define DATA_LENGTH (1<<12)
@@ -85,6 +86,8 @@ main (int argc, char **argv)
printf (" voc - Create Voice file functions\n") ;
printf (" w64 - Sonic Foundry's W64 file functions\n") ;
printf (" flac - test FLAC file functions\n") ;
printf (" mpc2k - test MPC 2000 file functions\n") ;
printf (" rf64 - test RF64 file functions\n") ;
printf (" all - perform all tests\n") ;
exit (1) ;
} ;
@@ -313,6 +316,11 @@ main (int argc, char **argv)
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "mpc2k"))
{ pcm_test_short ("short.mpc", SF_FORMAT_MPC2K | SF_FORMAT_PCM_16, SF_FALSE) ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "avr"))
{ pcm_test_char ("char_u8.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_U8, SF_FALSE) ;
pcm_test_char ("char_s8.avr" , SF_FORMAT_AVR | SF_FORMAT_PCM_S8, SF_FALSE) ;
@@ -342,6 +350,10 @@ main (int argc, char **argv)
{ pcm_test_char ("char.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_S8, SF_TRUE) ;
pcm_test_short ("short.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_16, SF_TRUE) ;
pcm_test_24bit ("24bit.sds" , SF_FORMAT_SDS | SF_FORMAT_PCM_24, SF_TRUE) ;
empty_file_test ("empty_char.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_S8) ;
empty_file_test ("empty_short.sds", SF_FORMAT_SDS | SF_FORMAT_PCM_16) ;
test_count++ ;
} ;
@@ -353,14 +365,30 @@ main (int argc, char **argv)
} ;
if (do_all || ! strcmp (argv [1], "flac"))
{
#ifdef HAVE_FLAC_ALL_H
pcm_test_char ("char.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, SF_TRUE) ;
pcm_test_short ("short.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_16, SF_TRUE) ;
pcm_test_24bit ("24bit.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_24, SF_TRUE) ;
#else
printf (" **** flac not supported in this binary. ****\n") ;
#endif
{ if (HAVE_EXTERNAL_LIBS)
{ pcm_test_char ("char.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_S8, SF_TRUE) ;
pcm_test_short ("short.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_16, SF_TRUE) ;
pcm_test_24bit ("24bit.flac" , SF_FORMAT_FLAC | SF_FORMAT_PCM_24, SF_TRUE) ;
}
else
puts (" No FLAC tests because FLAC support was not compiled in.") ;
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "rf64"))
{ pcm_test_char ("char.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_U8, SF_FALSE) ;
pcm_test_short ("short.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_16, SF_FALSE) ;
pcm_test_24bit ("24bit.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_24, SF_FALSE) ;
pcm_test_int ("int.rf64" , SF_FORMAT_RF64 | SF_FORMAT_PCM_32, SF_FALSE) ;
/* Lite remove start */
pcm_test_float ("float.rf64" , SF_FORMAT_RF64 | SF_FORMAT_FLOAT , SF_FALSE) ;
pcm_test_double ("double.rf64" , SF_FORMAT_RF64 | SF_FORMAT_DOUBLE, SF_FALSE) ;
empty_file_test ("empty_char.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_U8) ;
empty_file_test ("empty_short.rf64", SF_FORMAT_RF64 | SF_FORMAT_PCM_16) ;
empty_file_test ("empty_float.rf64", SF_FORMAT_RF64 | SF_FORMAT_FLOAT) ;
/* Lite remove end */
test_count++ ;
} ;
@@ -401,6 +429,8 @@ static void mono_char_test (const char *filename, int format, int long_file_ok,
static void stereo_char_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_char_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_char_test (const char *filename, int format, int allow_fd) ;
static void multi_seek_test (const char * filename, int format) ;
static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_char (const char *filename, int format, int long_file_ok)
@@ -531,6 +561,7 @@ mono_char_test (const char *filename, int format, int long_file_ok, int allow_fd
for (k = 0 ; k < items ; k++)
if (CHAR_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : 0x%X => 0x%X).\n", __LINE__, k, orig [k], test [k]) ;
oct_save_short (orig, test, items) ;
exit (1) ;
} ;
@@ -606,6 +637,9 @@ mono_char_test (const char *filename, int format, int long_file_ok, int allow_fd
sf_close (file) ;
multi_seek_test (filename, format) ;
write_seek_extend_test (filename, format) ;
} /* mono_char_test */
static void
@@ -807,7 +841,7 @@ mono_rdwr_char_test (const char *filename, int format, int long_file_ok, int all
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (CHAR_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) A : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_short (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -856,7 +890,7 @@ mono_rdwr_char_test (const char *filename, int format, int long_file_ok, int all
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (CHAR_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) B : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_short (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -893,7 +927,7 @@ new_rdwr_char_test (const char *filename, int format, int allow_fd)
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -914,6 +948,8 @@ static void mono_short_test (const char *filename, int format, int long_file_ok,
static void stereo_short_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_short_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_short_test (const char *filename, int format, int allow_fd) ;
static void multi_seek_test (const char * filename, int format) ;
static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_short (const char *filename, int format, int long_file_ok)
@@ -1044,6 +1080,7 @@ mono_short_test (const char *filename, int format, int long_file_ok, int allow_f
for (k = 0 ; k < items ; k++)
if (INT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : 0x%X => 0x%X).\n", __LINE__, k, orig [k], test [k]) ;
oct_save_short (orig, test, items) ;
exit (1) ;
} ;
@@ -1119,6 +1156,9 @@ mono_short_test (const char *filename, int format, int long_file_ok, int allow_f
sf_close (file) ;
multi_seek_test (filename, format) ;
write_seek_extend_test (filename, format) ;
} /* mono_short_test */
static void
@@ -1320,7 +1360,7 @@ mono_rdwr_short_test (const char *filename, int format, int long_file_ok, int al
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (INT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) A : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_short (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -1369,7 +1409,7 @@ mono_rdwr_short_test (const char *filename, int format, int long_file_ok, int al
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (INT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) B : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_short (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -1406,7 +1446,7 @@ new_rdwr_short_test (const char *filename, int format, int allow_fd)
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -1427,6 +1467,8 @@ static void mono_24bit_test (const char *filename, int format, int long_file_ok,
static void stereo_24bit_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_24bit_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_24bit_test (const char *filename, int format, int allow_fd) ;
static void multi_seek_test (const char * filename, int format) ;
static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_24bit (const char *filename, int format, int long_file_ok)
@@ -1557,6 +1599,7 @@ mono_24bit_test (const char *filename, int format, int long_file_ok, int allow_f
for (k = 0 ; k < items ; k++)
if (TRIBYTE_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : 0x%X => 0x%X).\n", __LINE__, k, orig [k], test [k]) ;
oct_save_int (orig, test, items) ;
exit (1) ;
} ;
@@ -1632,6 +1675,9 @@ mono_24bit_test (const char *filename, int format, int long_file_ok, int allow_f
sf_close (file) ;
multi_seek_test (filename, format) ;
write_seek_extend_test (filename, format) ;
} /* mono_24bit_test */
static void
@@ -1833,7 +1879,7 @@ mono_rdwr_24bit_test (const char *filename, int format, int long_file_ok, int al
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (TRIBYTE_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) A : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_int (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -1882,7 +1928,7 @@ mono_rdwr_24bit_test (const char *filename, int format, int long_file_ok, int al
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (TRIBYTE_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) B : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_int (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -1919,7 +1965,7 @@ new_rdwr_24bit_test (const char *filename, int format, int allow_fd)
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -1940,6 +1986,8 @@ static void mono_int_test (const char *filename, int format, int long_file_ok, i
static void stereo_int_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_int_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_int_test (const char *filename, int format, int allow_fd) ;
static void multi_seek_test (const char * filename, int format) ;
static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_int (const char *filename, int format, int long_file_ok)
@@ -2070,6 +2118,7 @@ mono_int_test (const char *filename, int format, int long_file_ok, int allow_fd)
for (k = 0 ; k < items ; k++)
if (INT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : 0x%X => 0x%X).\n", __LINE__, k, orig [k], test [k]) ;
oct_save_int (orig, test, items) ;
exit (1) ;
} ;
@@ -2145,6 +2194,9 @@ mono_int_test (const char *filename, int format, int long_file_ok, int allow_fd)
sf_close (file) ;
multi_seek_test (filename, format) ;
write_seek_extend_test (filename, format) ;
} /* mono_int_test */
static void
@@ -2346,7 +2398,7 @@ mono_rdwr_int_test (const char *filename, int format, int long_file_ok, int allo
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (INT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) A : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_int (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -2395,7 +2447,7 @@ mono_rdwr_int_test (const char *filename, int format, int long_file_ok, int allo
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (INT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) B : Error at sample %d (0x%X => 0x%X).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_int (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -2432,7 +2484,7 @@ new_rdwr_int_test (const char *filename, int format, int allow_fd)
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -2453,6 +2505,8 @@ static void mono_float_test (const char *filename, int format, int long_file_ok,
static void stereo_float_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_float_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_float_test (const char *filename, int format, int allow_fd) ;
static void multi_seek_test (const char * filename, int format) ;
static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_float (const char *filename, int format, int long_file_ok)
@@ -2583,6 +2637,7 @@ mono_float_test (const char *filename, int format, int long_file_ok, int allow_f
for (k = 0 ; k < items ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : %g => %g).\n", __LINE__, k, orig [k], test [k]) ;
oct_save_float (orig, test, items) ;
exit (1) ;
} ;
@@ -2658,6 +2713,9 @@ mono_float_test (const char *filename, int format, int long_file_ok, int allow_f
sf_close (file) ;
multi_seek_test (filename, format) ;
write_seek_extend_test (filename, format) ;
} /* mono_float_test */
static void
@@ -2859,7 +2917,7 @@ mono_rdwr_float_test (const char *filename, int format, int long_file_ok, int al
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) A : Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_float (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -2908,7 +2966,7 @@ mono_rdwr_float_test (const char *filename, int format, int long_file_ok, int al
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) B : Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_float (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -2945,7 +3003,7 @@ new_rdwr_float_test (const char *filename, int format, int allow_fd)
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -2966,6 +3024,8 @@ static void mono_double_test (const char *filename, int format, int long_file_ok
static void stereo_double_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void mono_rdwr_double_test (const char *filename, int format, int long_file_ok, int allow_fd) ;
static void new_rdwr_double_test (const char *filename, int format, int allow_fd) ;
static void multi_seek_test (const char * filename, int format) ;
static void write_seek_extend_test (const char * filename, int format) ;
static void
pcm_test_double (const char *filename, int format, int long_file_ok)
@@ -3096,6 +3156,7 @@ mono_double_test (const char *filename, int format, int long_file_ok, int allow_
for (k = 0 ; k < items ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d: Mono : Incorrect sample A (#%d : %g => %g).\n", __LINE__, k, orig [k], test [k]) ;
oct_save_double (orig, test, items) ;
exit (1) ;
} ;
@@ -3171,6 +3232,9 @@ mono_double_test (const char *filename, int format, int long_file_ok, int allow_
sf_close (file) ;
multi_seek_test (filename, format) ;
write_seek_extend_test (filename, format) ;
} /* mono_double_test */
static void
@@ -3372,7 +3436,7 @@ mono_rdwr_double_test (const char *filename, int format, int long_file_ok, int a
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) A : Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_double (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -3421,7 +3485,7 @@ mono_rdwr_double_test (const char *filename, int format, int long_file_ok, int a
/* Check the data. */
for (k = 0 ; k < DATA_LENGTH ; k++)
if (FLOAT_ERROR (orig [k], test [k]))
{ printf ("\n\nLine %d (pass %d): Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
{ printf ("\n\nLine %d (pass %d) B : Error at sample %d (%g => %g).\n", __LINE__, pass, k, orig [k], test [k]) ;
oct_save_double (orig, test, DATA_LENGTH) ;
exit (1) ;
} ;
@@ -3458,7 +3522,7 @@ new_rdwr_double_test (const char *filename, int format, int allow_fd)
rwfile = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, allow_fd, __LINE__) ;
if (sfinfo.frames != 2 * frames)
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld shold be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), frames) ;
{ printf ("\n\nLine %d : incorrect number of frames in file (%ld should be %d)\n\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * frames) ;
exit (1) ;
} ;
@@ -3586,4 +3650,100 @@ truncate (const char *filename, int ignored)
#endif
static void
multi_seek_test (const char * filename, int format)
{ SNDFILE * file ;
SF_INFO info ;
sf_count_t pos ;
int k ;
/* This test doesn't work on the following. */
switch (format & SF_FORMAT_TYPEMASK)
{ case SF_FORMAT_RAW :
return ;
default :
break ;
} ;
memset (&info, 0, sizeof (info)) ;
generate_file (filename, format, 88200) ;
file = test_open_file_or_die (filename, SFM_READ, &info, SF_FALSE, __LINE__) ;
for (k = 0 ; k < 10 ; k++)
{ pos = info.frames / (k + 2) ;
test_seek_or_die (file, pos, SEEK_SET, pos, info.channels, __LINE__) ;
} ;
sf_close (file) ;
} /* multi_seek_test */
static void
write_seek_extend_test (const char * filename, int format)
{ SNDFILE * file ;
SF_INFO info ;
short *orig, *test ;
unsigned items, k ;
/* This test doesn't work on the following. */
switch (format & SF_FORMAT_TYPEMASK)
{ case SF_FORMAT_FLAC :
case SF_FORMAT_HTK :
case SF_FORMAT_PAF :
case SF_FORMAT_SDS :
case SF_FORMAT_SVX :
return ;
default :
break ;
} ;
memset (&info, 0, sizeof (info)) ;
info.samplerate = 48000 ;
info.channels = 1 ;
info.format = format ;
items = 512 ;
exit_if_true (items > ARRAY_LEN (orig_data.s), "Line %d : Bad assumption.\n", __LINE__) ;
orig = orig_data.s ;
test = test_data.s ;
for (k = 0 ; k < ARRAY_LEN (orig_data.s) ; k++)
orig [k] = 0x3fff ;
file = test_open_file_or_die (filename, SFM_WRITE, &info, SF_FALSE, __LINE__) ;
test_write_short_or_die (file, 0, orig, items, __LINE__) ;
/* Extend the file using a seek. */
test_seek_or_die (file, 2 * items, SEEK_SET, 2 * items, info.channels, __LINE__) ;
test_writef_short_or_die (file, 0, orig, items, __LINE__) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_READ, &info, SF_FALSE, __LINE__) ;
test_read_short_or_die (file, 0, test, 3 * items, __LINE__) ;
sf_close (file) ;
/* Can't do these formats due to scaling. */
switch (format & SF_FORMAT_SUBMASK)
{ case SF_FORMAT_PCM_S8 :
case SF_FORMAT_PCM_U8 :
return ;
default :
break ;
} ;
for (k = 0 ; k < items ; k++)
{ exit_if_true (test [k] != 0x3fff, "Line %d : test [%d] == %d, should be 0x3fff.\n", __LINE__, k, test [k]) ;
exit_if_true (test [items + k] != 0, "Line %d : test [%d] == %d, should be 0.\n", __LINE__, items + k, test [items + k]) ;
exit_if_true (test [2 * items + k] != 0x3fff, "Line %d : test [%d] == %d, should be 0x3fff.\n", __LINE__, 2 * items + k, test [2 * items + k]) ;
} ;
return ;
} /* write_seek_extend_test */