annotate src/libsndfile-1.0.25/tests/rdwr_test.tpl @ 56:af97cad61ff0

Add updated build of PortAudio for OSX
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 03 Jan 2017 15:10:52 +0000
parents c7265573341e
children
rev   line source
Chris@0 1 [+ AutoGen5 template c +]
Chris@0 2 /*
Chris@0 3 ** Copyright (C) 2010-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
Chris@0 4 **
Chris@0 5 ** This program is free software ; you can redistribute it and/or modify
Chris@0 6 ** it under the terms of the GNU General Public License as published by
Chris@0 7 ** the Free Software Foundation ; either version 2 of the License, or
Chris@0 8 ** (at your option) any later version.
Chris@0 9 **
Chris@0 10 ** This program is distributed in the hope that it will be useful,
Chris@0 11 ** but WITHOUT ANY WARRANTY ; without even the implied warranty of
Chris@0 12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 13 ** GNU General Public License for more details.
Chris@0 14 **
Chris@0 15 ** You should have received a copy of the GNU General Public License
Chris@0 16 ** along with this program ; if not, write to the Free Software
Chris@0 17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Chris@0 18 */
Chris@0 19
Chris@0 20 #include "sfconfig.h"
Chris@0 21
Chris@0 22 #include <stdio.h>
Chris@0 23 #include <stdlib.h>
Chris@0 24 #include <string.h>
Chris@0 25
Chris@0 26 #include <sys/stat.h>
Chris@0 27 #include <math.h>
Chris@0 28
Chris@0 29 #if HAVE_UNISTD_H
Chris@0 30 #include <unistd.h>
Chris@0 31 #endif
Chris@0 32
Chris@0 33 #if (HAVE_DECL_S_IRGRP == 0)
Chris@0 34 #include <sf_unistd.h>
Chris@0 35 #endif
Chris@0 36
Chris@0 37 #if (defined (WIN32) || defined (_WIN32))
Chris@0 38 #include <io.h>
Chris@0 39 #include <direct.h>
Chris@0 40 #endif
Chris@0 41
Chris@0 42 #include <sndfile.h>
Chris@0 43
Chris@0 44 #include "utils.h"
Chris@0 45
Chris@0 46 [+ FOR data_type
Chris@0 47 +]static void rdwr_[+ (get "name") +]_test (const char *filename) ;
Chris@0 48 [+ ENDFOR data_type
Chris@0 49 +]
Chris@0 50
Chris@0 51 int
Chris@0 52 main (void)
Chris@0 53 {
Chris@0 54 rdwr_short_test ("rdwr_short.wav") ;
Chris@0 55 rdwr_int_test ("rdwr_int.wav") ;
Chris@0 56 rdwr_float_test ("rdwr_float.wav") ;
Chris@0 57 rdwr_double_test ("rdwr_double.wav") ;
Chris@0 58 rdwr_raw_test ("rdwr_raw.wav") ;
Chris@0 59
Chris@0 60 return 0 ;
Chris@0 61 } /* main */
Chris@0 62
Chris@0 63
Chris@0 64 /*============================================================================================
Chris@0 65 ** Here are the test functions.
Chris@0 66 */
Chris@0 67
Chris@0 68 [+ FOR data_type
Chris@0 69 +]static void
Chris@0 70 rdwr_[+ (get "name") +]_test (const char *filename)
Chris@0 71 { SNDFILE *file ;
Chris@0 72 SF_INFO sfinfo ;
Chris@0 73 sf_count_t frames ;
Chris@0 74 [+ (get "type") +] buffer [160] ;
Chris@0 75
Chris@0 76 print_test_name ("rdwr_[+ (get "name") +]_test", filename) ;
Chris@0 77
Chris@0 78 memset (buffer, 0, sizeof (buffer)) ;
Chris@0 79
Chris@0 80 /* Create sound file with no data. */
Chris@0 81 sfinfo.format = SF_FORMAT_WAV | [+ (get "format") +] ;
Chris@0 82 sfinfo.samplerate = 16000 ;
Chris@0 83 sfinfo.channels = 1 ;
Chris@0 84
Chris@0 85 unlink (filename) ;
Chris@0 86
Chris@0 87 frames = ARRAY_LEN (buffer) ;
Chris@0 88
Chris@0 89 /* Open again for read/write. */
Chris@0 90 file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ;
Chris@0 91
Chris@0 92 test_write_[+ (get "name") +]_or_die (file, 0, buffer, frames, __LINE__) ;
Chris@0 93
Chris@0 94 test_read_[+ (get "name") +]_or_die (file, 0, buffer, frames, __LINE__) ;
Chris@0 95
Chris@0 96 sf_close (file) ;
Chris@0 97 unlink (filename) ;
Chris@0 98
Chris@0 99 puts ("ok") ;
Chris@0 100 return ;
Chris@0 101 } /* rdwr_[+ (get "name") +]_test */
Chris@0 102
Chris@0 103 [+ ENDFOR data_type
Chris@0 104 +]
Chris@0 105