annotate src/libsndfile-1.0.27/tests/external_libs_test.c @ 127:7867fa7e1b6b

Current fftw source
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 18 Oct 2016 13:40:26 +0100
parents cd6cdf86811e
children
rev   line source
cannam@125 1 /*
cannam@125 2 ** Copyright (C) 2008-2016 Erik de Castro Lopo <erikd@mega-nerd.com>
cannam@125 3 **
cannam@125 4 ** This program is free software ; you can redistribute it and/or modify
cannam@125 5 ** it under the terms of the GNU General Public License as published by
cannam@125 6 ** the Free Software Foundation ; either version 2 of the License, or
cannam@125 7 ** (at your option) any later version.
cannam@125 8 **
cannam@125 9 ** This program is distributed in the hope that it will be useful,
cannam@125 10 ** but WITHOUT ANY WARRANTY ; without even the implied warranty of
cannam@125 11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@125 12 ** GNU General Public License for more details.
cannam@125 13 **
cannam@125 14 ** You should have received a copy of the GNU General Public License
cannam@125 15 ** along with this program ; if not, write to the Free Software
cannam@125 16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cannam@125 17 */
cannam@125 18
cannam@125 19 #include "sfconfig.h"
cannam@125 20
cannam@125 21 #include <stdio.h>
cannam@125 22 #include <stdlib.h>
cannam@125 23 #include <string.h>
cannam@125 24 #include <errno.h>
cannam@125 25
cannam@125 26 #include <sndfile.h>
cannam@125 27
cannam@125 28 #include "utils.h"
cannam@125 29
cannam@125 30 static void major_format_test (void) ;
cannam@125 31 static void subtype_format_test (void) ;
cannam@125 32 static void simple_format_test (void) ;
cannam@125 33
cannam@125 34 int
cannam@125 35 main (void)
cannam@125 36 {
cannam@125 37 major_format_test () ;
cannam@125 38 subtype_format_test () ;
cannam@125 39 simple_format_test () ;
cannam@125 40
cannam@125 41 return 0 ;
cannam@125 42 } /* main */
cannam@125 43
cannam@125 44 static void
cannam@125 45 major_format_test (void)
cannam@125 46 { SF_FORMAT_INFO info ;
cannam@125 47 int have_ogg = 0, have_flac = 0 ;
cannam@125 48 int m, major_count ;
cannam@125 49
cannam@125 50 print_test_name (__func__, NULL) ;
cannam@125 51
cannam@125 52 sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ;
cannam@125 53
cannam@125 54 for (m = 0 ; m < major_count ; m++)
cannam@125 55 { info.format = m ;
cannam@125 56 sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ;
cannam@125 57
cannam@125 58 have_flac = info.format == SF_FORMAT_FLAC ? 1 : have_flac ;
cannam@125 59 have_ogg = info.format == SF_FORMAT_OGG ? 1 : have_ogg ;
cannam@125 60 } ;
cannam@125 61
cannam@125 62 if (HAVE_EXTERNAL_XIPH_LIBS)
cannam@125 63 { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ;
cannam@125 64 exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
cannam@125 65 }
cannam@125 66 else
cannam@125 67 { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ;
cannam@125 68 exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
cannam@125 69 } ;
cannam@125 70
cannam@125 71 puts ("ok") ;
cannam@125 72 } /* major_format_test */
cannam@125 73
cannam@125 74 static void
cannam@125 75 subtype_format_test (void)
cannam@125 76 { SF_FORMAT_INFO info ;
cannam@125 77 int have_vorbis = 0 ;
cannam@125 78 int s, subtype_count ;
cannam@125 79
cannam@125 80 print_test_name (__func__, NULL) ;
cannam@125 81
cannam@125 82 sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ;
cannam@125 83
cannam@125 84 for (s = 0 ; s < subtype_count ; s++)
cannam@125 85 { info.format = s ;
cannam@125 86 sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ;
cannam@125 87
cannam@125 88 have_vorbis = info.format == SF_FORMAT_VORBIS ? 1 : have_vorbis ;
cannam@125 89 } ;
cannam@125 90
cannam@125 91 if (HAVE_EXTERNAL_XIPH_LIBS)
cannam@125 92 exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
cannam@125 93 else
cannam@125 94 exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
cannam@125 95
cannam@125 96 puts ("ok") ;
cannam@125 97 } /* subtype_format_test */
cannam@125 98
cannam@125 99 static void
cannam@125 100 simple_format_test (void)
cannam@125 101 { SF_FORMAT_INFO info ;
cannam@125 102 int have_flac = 0, have_ogg = 0, have_vorbis = 0 ;
cannam@125 103 int s, simple_count ;
cannam@125 104
cannam@125 105 print_test_name (__func__, NULL) ;
cannam@125 106
cannam@125 107 sf_command (NULL, SFC_GET_SIMPLE_FORMAT_COUNT, &simple_count, sizeof (int)) ;
cannam@125 108
cannam@125 109 for (s = 0 ; s < simple_count ; s++)
cannam@125 110 { info.format = s ;
cannam@125 111 sf_command (NULL, SFC_GET_SIMPLE_FORMAT, &info, sizeof (info)) ;
cannam@125 112
cannam@125 113 switch (info.format & SF_FORMAT_TYPEMASK)
cannam@125 114 { case SF_FORMAT_FLAC :
cannam@125 115 have_flac = 1 ;
cannam@125 116 break ;
cannam@125 117
cannam@125 118 case SF_FORMAT_OGG :
cannam@125 119 have_ogg = 1 ;
cannam@125 120 break ;
cannam@125 121
cannam@125 122 default :
cannam@125 123 break ;
cannam@125 124 } ;
cannam@125 125
cannam@125 126 switch (info.format & SF_FORMAT_SUBMASK)
cannam@125 127 { case SF_FORMAT_VORBIS :
cannam@125 128 have_vorbis = 1 ;
cannam@125 129 break ;
cannam@125 130
cannam@125 131 default :
cannam@125 132 break ;
cannam@125 133 } ;
cannam@125 134
cannam@125 135 } ;
cannam@125 136
cannam@125 137 if (HAVE_EXTERNAL_XIPH_LIBS)
cannam@125 138 { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ;
cannam@125 139 exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
cannam@125 140 exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
cannam@125 141 }
cannam@125 142 else
cannam@125 143 { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ;
cannam@125 144 exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
cannam@125 145 exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
cannam@125 146 } ;
cannam@125 147
cannam@125 148 puts ("ok") ;
cannam@125 149 } /* simple_format_test */