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