Chris@40: /* Chris@40: ** Copyright (C) 2008-2016 Erik de Castro Lopo Chris@40: ** Chris@40: ** This program is free software ; you can redistribute it and/or modify Chris@40: ** it under the terms of the GNU General Public License as published by Chris@40: ** the Free Software Foundation ; either version 2 of the License, or Chris@40: ** (at your option) any later version. Chris@40: ** Chris@40: ** This program is distributed in the hope that it will be useful, Chris@40: ** but WITHOUT ANY WARRANTY ; without even the implied warranty of Chris@40: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@40: ** GNU General Public License for more details. Chris@40: ** Chris@40: ** You should have received a copy of the GNU General Public License Chris@40: ** along with this program ; if not, write to the Free Software Chris@40: ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Chris@40: */ Chris@40: Chris@40: #include "sfconfig.h" Chris@40: Chris@40: #include Chris@40: #include Chris@40: #include Chris@40: #include Chris@40: Chris@40: #include Chris@40: Chris@40: #include "utils.h" Chris@40: Chris@40: static void major_format_test (void) ; Chris@40: static void subtype_format_test (void) ; Chris@40: static void simple_format_test (void) ; Chris@40: Chris@40: int Chris@40: main (void) Chris@40: { Chris@40: major_format_test () ; Chris@40: subtype_format_test () ; Chris@40: simple_format_test () ; Chris@40: Chris@40: return 0 ; Chris@40: } /* main */ Chris@40: Chris@40: static void Chris@40: major_format_test (void) Chris@40: { SF_FORMAT_INFO info ; Chris@40: int have_ogg = 0, have_flac = 0 ; Chris@40: int m, major_count ; Chris@40: Chris@40: print_test_name (__func__, NULL) ; Chris@40: Chris@40: sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ; Chris@40: Chris@40: for (m = 0 ; m < major_count ; m++) Chris@40: { info.format = m ; Chris@40: sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ; Chris@40: Chris@40: have_flac = info.format == SF_FORMAT_FLAC ? 1 : have_flac ; Chris@40: have_ogg = info.format == SF_FORMAT_OGG ? 1 : have_ogg ; Chris@40: } ; Chris@40: Chris@40: if (HAVE_EXTERNAL_XIPH_LIBS) Chris@40: { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ; Chris@40: exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ; Chris@40: } Chris@40: else Chris@40: { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ; Chris@40: exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ; Chris@40: } ; Chris@40: Chris@40: puts ("ok") ; Chris@40: } /* major_format_test */ Chris@40: Chris@40: static void Chris@40: subtype_format_test (void) Chris@40: { SF_FORMAT_INFO info ; Chris@40: int have_vorbis = 0 ; Chris@40: int s, subtype_count ; Chris@40: Chris@40: print_test_name (__func__, NULL) ; Chris@40: Chris@40: sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ; Chris@40: Chris@40: for (s = 0 ; s < subtype_count ; s++) Chris@40: { info.format = s ; Chris@40: sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ; Chris@40: Chris@40: have_vorbis = info.format == SF_FORMAT_VORBIS ? 1 : have_vorbis ; Chris@40: } ; Chris@40: Chris@40: if (HAVE_EXTERNAL_XIPH_LIBS) Chris@40: exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ; Chris@40: else Chris@40: exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ; Chris@40: Chris@40: puts ("ok") ; Chris@40: } /* subtype_format_test */ Chris@40: Chris@40: static void Chris@40: simple_format_test (void) Chris@40: { SF_FORMAT_INFO info ; Chris@40: int have_flac = 0, have_ogg = 0, have_vorbis = 0 ; Chris@40: int s, simple_count ; Chris@40: Chris@40: print_test_name (__func__, NULL) ; Chris@40: Chris@40: sf_command (NULL, SFC_GET_SIMPLE_FORMAT_COUNT, &simple_count, sizeof (int)) ; Chris@40: Chris@40: for (s = 0 ; s < simple_count ; s++) Chris@40: { info.format = s ; Chris@40: sf_command (NULL, SFC_GET_SIMPLE_FORMAT, &info, sizeof (info)) ; Chris@40: Chris@40: switch (info.format & SF_FORMAT_TYPEMASK) Chris@40: { case SF_FORMAT_FLAC : Chris@40: have_flac = 1 ; Chris@40: break ; Chris@40: Chris@40: case SF_FORMAT_OGG : Chris@40: have_ogg = 1 ; Chris@40: break ; Chris@40: Chris@40: default : Chris@40: break ; Chris@40: } ; Chris@40: Chris@40: switch (info.format & SF_FORMAT_SUBMASK) Chris@40: { case SF_FORMAT_VORBIS : Chris@40: have_vorbis = 1 ; Chris@40: break ; Chris@40: Chris@40: default : Chris@40: break ; Chris@40: } ; Chris@40: Chris@40: } ; Chris@40: Chris@40: if (HAVE_EXTERNAL_XIPH_LIBS) Chris@40: { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ; Chris@40: exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ; Chris@40: exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ; Chris@40: } Chris@40: else Chris@40: { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ; Chris@40: exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ; Chris@40: exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ; Chris@40: } ; Chris@40: Chris@40: puts ("ok") ; Chris@40: } /* simple_format_test */