FS-4657 --resolve update libsndfile to its latest master

This commit is contained in:
Jeff Lenk
2014-02-21 16:09:43 -06:00
parent 0c1f6ef2ed
commit 199a64bf6a
291 changed files with 25966 additions and 5745 deletions

View File

@@ -1,5 +1,5 @@
/*
** Copyright (C) 2006 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2006-2012 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
@@ -29,6 +29,41 @@ static int ibuffer [100] ;
static float fbuffer [100] ;
static double dbuffer [100] ;
static void
ceeplusplus_wchar_test (void)
{
#if 0
LPCWSTR filename = L"wchar_test.wav" ;
print_test_name (__func__, "ceeplusplus_wchar_test.wav") ;
/* Use this scope to make sure the created file is closed. */
{
SndfileHandle file (filename, SFM_WRITE, SF_FORMAT_WAV | SF_FORMAT_PCM_16, 2, 44100) ;
if (file.refCount () != 1)
{ printf ("\n\n%s %d : Error : Reference count (%d) should be 1.\n\n", __func__, __LINE__, file.refCount ()) ;
exit (1) ;
} ;
/* This should check that the file did in fact get created with a
** wchar_t * filename.
*/
exit_if_true (
GetFileAttributesW (filename) == INVALID_FILE_ATTRIBUTES,
"\n\nLine %d : GetFileAttributes failed.\n\n", __LINE__
) ;
}
/* Use this because the file was created with CreateFileW. */
DeleteFileW (filename) ;
puts ("ok") ;
#endif
} /* ceeplusplus_wchar_test */
static void
create_file (const char * filename, int format)
{ SndfileHandle file ;
@@ -124,7 +159,7 @@ read_file (const char * filename, int format)
if (file.frames () != ARRAY_LEN (sbuffer) * 4)
{ printf ("\n\n%s %d : Error : frames %ld should be %lu.\n\n", __func__, __LINE__,
SF_COUNT_TO_LONG (file.frames ()), (long unsigned int) ARRAY_LEN (sbuffer) * 4 / 2) ;
(long) file.frames (), (long) ARRAY_LEN (sbuffer) * 4 / 2) ;
exit (1) ;
} ;
@@ -152,14 +187,14 @@ read_file (const char * filename, int format)
count = file.seek (file.frames () - 10, SEEK_SET) ;
if (count != file.frames () - 10)
{ printf ("\n\n%s %d : Error : offset (%ld) should be %ld\n\n", __func__, __LINE__,
SF_COUNT_TO_LONG (count), SF_COUNT_TO_LONG (file.frames () - 10)) ;
(long) count, (long) (file.frames () - 10)) ;
exit (1) ;
} ;
count = file.read (sbuffer, ARRAY_LEN (sbuffer)) ;
if (count != 10 * file.channels ())
{ printf ("\n\n%s %d : Error : count (%ld) should be %ld\n\n", __func__, __LINE__,
SF_COUNT_TO_LONG (count), SF_COUNT_TO_LONG (10 * file.channels ())) ;
(long) count, (long) (10 * file.channels ())) ;
exit (1) ;
} ;
@@ -190,7 +225,7 @@ ceeplusplus_extra_test (void)
error = file.error () ;
if (error == 0)
{ printf ("\n\n%s %d : error should be zero.\n\n", __func__, __LINE__) ;
{ printf ("\n\n%s %d : error should not be zero.\n\n", __func__, __LINE__) ;
exit (1) ;
} ;
@@ -207,6 +242,60 @@ ceeplusplus_extra_test (void)
puts ("ok") ;
} /* ceeplusplus_extra_test */
static void
ceeplusplus_rawhandle_test (const char *filename)
{
SNDFILE* handle ;
{
SndfileHandle file (filename) ;
handle = file.rawHandle () ;
sf_read_float (handle, fbuffer, ARRAY_LEN (fbuffer)) ;
}
} /* ceeplusplus_rawhandle_test */
static void
ceeplusplus_takeOwnership_test (const char *filename)
{
SNDFILE* handle ;
{
SndfileHandle file (filename) ;
handle = file.takeOwnership () ;
}
if (sf_read_float (handle, fbuffer, ARRAY_LEN (fbuffer)) <= 0)
{ printf ("\n\n%s %d : error when taking ownership of handle.\n\n", __func__, __LINE__) ;
exit (1) ;
}
if (sf_close (handle) != 0)
{ printf ("\n\n%s %d : cannot close file.\n\n", __func__, __LINE__) ;
exit (1) ;
}
SndfileHandle file (filename) ;
SndfileHandle file2 (file) ;
if (file2.takeOwnership ())
{ printf ("\n\n%s %d : taking ownership of shared handle is not allowed.\n\n", __func__, __LINE__) ;
exit (1) ;
}
} /* ceeplusplus_takeOwnership_test */
static void
ceeplusplus_handle_test (const char *filename, int format)
{
print_test_name ("ceeplusplus_handle_test", filename) ;
create_file (filename, format) ;
if (0) ceeplusplus_rawhandle_test (filename) ;
ceeplusplus_takeOwnership_test (filename) ;
remove (filename) ;
puts ("ok") ;
} /* ceeplusplus_test */
int
main (void)
{
@@ -215,6 +304,9 @@ main (void)
ceeplusplus_test ("cpp_test.au", SF_FORMAT_AU | SF_FORMAT_FLOAT) ;
ceeplusplus_extra_test () ;
ceeplusplus_handle_test ("cpp_test.wav", SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
ceeplusplus_wchar_test () ;
return 0 ;
} /* main */