1 /*
2 ** Copyright (C) 2006-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
3 **
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2 of the License, or
7 ** (at your option) any later version.
8 **
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU General Public License for more details.
13 **
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #include "sfconfig.h"
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24
25 #if HAVE_UNISTD_H
26 #include <unistd.h>
27 #else
28 #include "sf_unistd.h"
29 #endif
30
31 #include <sndfile.h>
32
33 #include "utils.h"
34
35 #define BUFFER_LEN (1024 * 1024)
36 #define BUFFER_COUNT (768)
37
38 static void largefile_test (int filetype, const char * filename) ;
39
40 int
main(void)41 main (void)
42 {
43 largefile_test (SF_FORMAT_WAV, "largefile.wav") ;
44 largefile_test (SF_FORMAT_AIFF, "largefile.aiff") ;
45
46 return 0 ;
47 } /* main */
48
49 static void
largefile_test(int filetype,const char * filename)50 largefile_test (int filetype, const char * filename)
51 { static float data [BUFFER_LEN] ;
52 SNDFILE *file ;
53 SF_INFO sfinfo ;
54 int k ;
55
56 print_test_name ("largefile_test", filename) ;
57
58 sfinfo.samplerate = 44100 ;
59 sfinfo.channels = 2 ;
60 sfinfo.frames = 0 ;
61 sfinfo.format = (filetype | SF_FORMAT_PCM_32) ;
62
63 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
64
65 for (k = 0 ; k < BUFFER_COUNT ; k++)
66 test_write_float_or_die (file, k, data, BUFFER_LEN, __LINE__) ;
67
68 sf_close (file) ;
69
70 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
71
72 if ((sfinfo.frames * sfinfo.channels) / BUFFER_LEN != BUFFER_COUNT)
73 { printf ("\n\nLine %d : bad frame count.\n", __LINE__) ;
74 exit (1) ;
75 } ;
76
77 sf_close (file) ;
78
79 unlink (filename) ;
80 puts ("ok") ;
81
82
83 return ;
84 } /* largefile_test */
85
86