2 ** Copyright (C) 2008-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
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.
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.
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.
30 static void major_format_test (void) ;
31 static void subtype_format_test (void) ;
32 static void simple_format_test (void) ;
37 major_format_test () ;
38 subtype_format_test () ;
39 simple_format_test () ;
45 major_format_test (void)
46 { SF_FORMAT_INFO info
;
47 int have_ogg
= 0, have_flac
= 0 ;
50 print_test_name (__func__
, NULL
) ;
52 sf_command (NULL
, SFC_GET_FORMAT_MAJOR_COUNT
, &major_count
, sizeof (int)) ;
54 for (m
= 0 ; m
< major_count
; m
++)
56 sf_command (NULL
, SFC_GET_FORMAT_MAJOR
, &info
, sizeof (info
)) ;
58 have_flac
= info
.format
== SF_FORMAT_FLAC
? 1 : have_flac
;
59 have_ogg
= info
.format
== SF_FORMAT_OGG
? 1 : have_ogg
;
62 if (HAVE_EXTERNAL_LIBS
)
63 { exit_if_true (have_flac
== 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__
) ;
64 exit_if_true (have_ogg
== 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__
) ;
67 { exit_if_true (have_flac
, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__
) ;
68 exit_if_true (have_ogg
, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__
) ;
72 } /* major_format_test */
75 subtype_format_test (void)
76 { SF_FORMAT_INFO info
;
78 int s
, subtype_count
;
80 print_test_name (__func__
, NULL
) ;
82 sf_command (NULL
, SFC_GET_FORMAT_SUBTYPE_COUNT
, &subtype_count
, sizeof (int)) ;
84 for (s
= 0 ; s
< subtype_count
; s
++)
86 sf_command (NULL
, SFC_GET_FORMAT_SUBTYPE
, &info
, sizeof (info
)) ;
88 have_vorbis
= info
.format
== SF_FORMAT_VORBIS
? 1 : have_vorbis
;
91 if (HAVE_EXTERNAL_LIBS
)
92 exit_if_true (have_vorbis
== 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__
) ;
94 exit_if_true (have_vorbis
, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__
) ;
97 } /* subtype_format_test */
100 simple_format_test (void)
101 { SF_FORMAT_INFO info
;
102 int have_flac
= 0, have_ogg
= 0, have_vorbis
= 0 ;
103 int s
, simple_count
;
105 print_test_name (__func__
, NULL
) ;
107 sf_command (NULL
, SFC_GET_SIMPLE_FORMAT_COUNT
, &simple_count
, sizeof (int)) ;
109 for (s
= 0 ; s
< simple_count
; s
++)
111 sf_command (NULL
, SFC_GET_SIMPLE_FORMAT
, &info
, sizeof (info
)) ;
113 switch (info
.format
& SF_FORMAT_TYPEMASK
)
114 { case SF_FORMAT_FLAC
:
126 switch (info
.format
& SF_FORMAT_SUBMASK
)
127 { case SF_FORMAT_VORBIS
:
137 if (HAVE_EXTERNAL_LIBS
)
138 { exit_if_true (have_flac
== 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__
) ;
139 exit_if_true (have_ogg
== 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__
) ;
140 exit_if_true (have_vorbis
== 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__
) ;
143 { exit_if_true (have_flac
, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__
) ;
144 exit_if_true (have_ogg
, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__
) ;
145 exit_if_true (have_vorbis
, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__
) ;
149 } /* simple_format_test */