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