1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-21 16:37:12 +01:00

Update libsndfile to 1.0.29pre2+git

This pulls in MANY (over 890) changes compared to our
from our current 1.0.24 version.
This commit is contained in:
Leland Lucius
2020-03-16 22:41:09 -05:00
parent 4ac45bb5f8
commit b749a16943
370 changed files with 39029 additions and 81333 deletions

View File

@@ -1,6 +1,6 @@
[+ AutoGen5 template c +]
/*
** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2001-2017 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
@@ -22,9 +22,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <math.h>
#include <sys/stat.h>
#include <math.h>
#if HAVE_UNISTD_H
#include <unistd.h>
@@ -43,10 +44,11 @@
#include "utils.h"
#define BUFFER_LEN (1<<10)
#define BUFFER_LEN (1 << 10)
#define LOG_BUFFER_SIZE 1024
static void update_header_test (const char *filename, int typemajor) ;
static void update_header_before_write_test (const char *filename, int typemajor) ;
[+ FOR data_type
+]static void update_seek_[+ (get "name") +]_test (const char *filename, int filetype) ;
@@ -77,7 +79,7 @@ main (int argc, char *argv [])
exit (1) ;
} ;
do_all=!strcmp (argv [1], "all") ;
do_all= !strcmp (argv [1], "all") ;
if (do_all || ! strcmp (argv [1], "wav"))
{ update_header_test ("header.wav", SF_FORMAT_WAV) ;
@@ -225,6 +227,14 @@ main (int argc, char *argv [])
test_count++ ;
} ;
if (do_all || ! strcmp (argv [1], "flac"))
{ if (HAVE_EXTERNAL_XIPH_LIBS)
update_header_before_write_test ("header.flac", SF_FORMAT_FLAC) ;
else
puts (" No FLAC tests because FLAC support was not compiled in.") ;
test_count++ ;
} ;
if (test_count == 0)
{ printf ("Mono : ************************************\n") ;
printf ("Mono : * No '%s' test defined.\n", argv [1]) ;
@@ -244,14 +254,12 @@ static void
update_header_sub (const char *filename, int typemajor, int write_mode)
{ SNDFILE *outfile, *infile ;
SF_INFO sfinfo ;
int k, frames ;
int k ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
sfinfo.samplerate = 44100 ;
sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ;
sfinfo.channels = 1 ;
sfinfo.frames = 0 ;
frames = BUFFER_LEN / sfinfo.channels ;
outfile = test_open_file_or_die (filename, write_mode, &sfinfo, SF_TRUE, __LINE__) ;
@@ -275,7 +283,7 @@ update_header_sub (const char *filename, int typemajor, int write_mode)
check_log_buffer_or_die (infile, __LINE__) ;
if (sfinfo.frames < BUFFER_LEN || sfinfo.frames > BUFFER_LEN + 50)
{ printf ("\n\nLine %d : Incorrect sample count (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), BUFFER_LEN) ;
{ printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, BUFFER_LEN) ;
dump_log_buffer (infile) ;
exit (1) ;
} ;
@@ -300,7 +308,7 @@ update_header_sub (const char *filename, int typemajor, int write_mode)
check_log_buffer_or_die (infile, __LINE__) ;
if (sfinfo.frames < 2 * BUFFER_LEN || sfinfo.frames > 2 * BUFFER_LEN + 50)
{ printf ("\n\nLine %d : Incorrect sample count (%ld should be %d)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), 2 * BUFFER_LEN) ;
{ printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, 2 * BUFFER_LEN) ;
dump_log_buffer (infile) ;
exit (1) ;
} ;
@@ -324,6 +332,36 @@ update_header_test (const char *filename, int typemajor)
puts ("ok") ;
} /* update_header_test */
static void
update_header_before_write_test (const char *filename, int typemajor)
{
SNDFILE *outfile ;
SF_INFO sfinfo ;
int k ;
print_test_name ("update_header_before_write", filename) ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
sfinfo.samplerate = 44100 ;
sfinfo.format = (typemajor | SF_FORMAT_PCM_16) ;
sfinfo.channels = 1 ;
outfile = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
/* FLAC can only write the header once; if the first call to sf_write() will
** also attempt to write the header, it fails. FLAC-specific regression
*/
sf_command (outfile, SFC_UPDATE_HEADER_NOW, NULL, 0) ;
for (k = 0 ; k < BUFFER_LEN ; k++)
data_out [k] = k + 1 ;
test_write_int_or_die (outfile, 0, data_out, BUFFER_LEN, __LINE__) ;
sf_close (outfile) ;
unlink (filename) ;
puts ("ok") ;
} /* update_header_before_write_test */
/*==============================================================================
*/
@@ -332,8 +370,8 @@ update_header_test (const char *filename, int typemajor)
update_seek_[+ (get "name") +]_test (const char *filename, int filetype)
{ SNDFILE *outfile, *infile ;
SF_INFO sfinfo ;
sf_count_t frames ;
[+ (get "name") +] buffer [8] ;
sf_count_t frames ;
[+ (get "name") +] buffer [8] ;
int k ;
print_test_name ("update_seek_[+ (get "name") +]_test", filename) ;
@@ -341,6 +379,7 @@ update_seek_[+ (get "name") +]_test (const char *filename, int filetype)
memset (buffer, 0, sizeof (buffer)) ;
/* Create sound outfile with no data. */
memset (&sfinfo, 0, sizeof (sfinfo)) ;
sfinfo.format = filetype | [+ (get "format") +] ;
sfinfo.samplerate = 48000 ;
sfinfo.channels = 2 ;
@@ -356,11 +395,11 @@ update_seek_[+ (get "name") +]_test (const char *filename, int filetype)
/*
** In auto header update mode, seeking to the end of the file with
** SEEK_SET will fail from the 2nd seek on. seeking to 0, SEEK_END
** SEEK_SET will fail from the 2nd seek on. seeking to 0, SEEK_END
** will seek to 0 anyway
*/
if (sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) == 0)
{ printf ("\n\nError : sf_command (SFC_SET_UPDATE_HEADER_AUTO) return error : %s\n\n", sf_strerror (outfile)) ;
{ printf ("\n\nError : sf_command (SFC_SET_UPDATE_HEADER_AUTO) return error : %s\n\n", sf_strerror (outfile)) ;
exit (1) ;
} ;
@@ -377,7 +416,7 @@ update_seek_[+ (get "name") +]_test (const char *filename, int filetype)
sf_close (infile) ;
if (sfinfo.frames != k * frames)
{ printf ("\n\nLine %d : Incorrect sample count (%ld should be %ld)\n", __LINE__, SF_COUNT_TO_LONG (sfinfo.frames), SF_COUNT_TO_LONG (k + frames)) ;
{ printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %" PRId64 ")\n", __LINE__, sfinfo.frames, k + frames) ;
dump_log_buffer (infile) ;
exit (1) ;
} ;
@@ -445,12 +484,13 @@ static void
extra_header_test (const char *filename, int filetype)
{ SNDFILE *outfile, *infile ;
SF_INFO sfinfo ;
sf_count_t frames ;
short buffer [8] ;
sf_count_t frames ;
short buffer [8] ;
int k = 0 ;
print_test_name ("extra_header_test", filename) ;
memset (&sfinfo, 0, sizeof (sfinfo)) ;
sfinfo.samplerate = 44100 ;
sfinfo.format = (filetype | SF_FORMAT_PCM_16) ;
sfinfo.channels = 1 ;
@@ -494,11 +534,11 @@ extra_header_test (const char *filename, int filetype)
/*
** In auto header update mode, seeking to the end of the file with
** SEEK_SET will fail from the 2nd seek on. seeking to 0, SEEK_END
** SEEK_SET will fail from the 2nd seek on. seeking to 0, SEEK_END
** will seek to 0 anyway
*/
if (sf_command (outfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) == 0)
{ printf ("\n\nError : sf_command (SFC_SET_UPDATE_HEADER_AUTO) return error : %s\n\n", sf_strerror (outfile)) ;
{ printf ("\n\nError : sf_command (SFC_SET_UPDATE_HEADER_AUTO) return error : %s\n\n", sf_strerror (outfile)) ;
exit (1) ;
} ;
@@ -522,7 +562,7 @@ extra_header_test (const char *filename, int filetype)
} ;
if (sfinfo.frames != k * frames)
{ printf ("\n\nLine %d : Incorrect sample count (%ld should be %ld)\n", [+ (tpl-file-line "%2$d") +], SF_COUNT_TO_LONG (sfinfo.frames), SF_COUNT_TO_LONG (k + frames)) ;
{ printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %" PRId64 ")\n", [+ (tpl-file-line "%2$d") +], sfinfo.frames, k + frames) ;
dump_log_buffer (infile) ;
exit (1) ;
} ;
@@ -541,4 +581,3 @@ extra_header_test (const char *filename, int filetype)
return ;
#endif
} /* extra_header_test */