Examples Makefile.
[Faustine.git] / interpretor / lib / src / libsndfile-1.0.25 / tests / largefile_test.c
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 #endif
28
29 #include <sndfile.h>
30
31 #include "utils.h"
32
33 #define BUFFER_LEN (1024 * 1024)
34 #define BUFFER_COUNT (768)
35
36 static void largefile_test (int filetype, const char * filename) ;
37
38 int
39 main (void)
40 {
41 largefile_test (SF_FORMAT_WAV, "largefile.wav") ;
42 largefile_test (SF_FORMAT_AIFF, "largefile.aiff") ;
43
44 return 0 ;
45 } /* main */
46
47 static void
48 largefile_test (int filetype, const char * filename)
49 { static float data [BUFFER_LEN] ;
50 SNDFILE *file ;
51 SF_INFO sfinfo ;
52 int k ;
53
54 print_test_name ("largefile_test", filename) ;
55
56 sfinfo.samplerate = 44100 ;
57 sfinfo.channels = 2 ;
58 sfinfo.frames = 0 ;
59 sfinfo.format = (filetype | SF_FORMAT_PCM_32) ;
60
61 file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
62
63 for (k = 0 ; k < BUFFER_COUNT ; k++)
64 test_write_float_or_die (file, k, data, BUFFER_LEN, __LINE__) ;
65
66 sf_close (file) ;
67
68 file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
69
70 if ((sfinfo.frames * sfinfo.channels) / BUFFER_LEN != BUFFER_COUNT)
71 { printf ("\n\nLine %d : bad frame count.\n", __LINE__) ;
72 exit (1) ;
73 } ;
74
75 sf_close (file) ;
76
77 unlink (filename) ;
78 puts ("ok") ;
79
80
81 return ;
82 } /* largefile_test */
83