external_libs_test.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. ** Copyright (C) 2008-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
  3. **
  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.
  8. **
  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.
  13. **
  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.
  17. */
  18. #include "sfconfig.h"
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include <errno.h>
  23. #include <sndfile.h>
  24. #include "utils.h"
  25. static void major_format_test (void) ;
  26. static void subtype_format_test (void) ;
  27. static void simple_format_test (void) ;
  28. int
  29. main (void)
  30. {
  31. major_format_test () ;
  32. subtype_format_test () ;
  33. simple_format_test () ;
  34. return 0 ;
  35. } /* main */
  36. static void
  37. major_format_test (void)
  38. { SF_FORMAT_INFO info ;
  39. int have_ogg = 0, have_flac = 0 ;
  40. int m, major_count ;
  41. print_test_name (__func__, NULL) ;
  42. sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ;
  43. for (m = 0 ; m < major_count ; m++)
  44. { info.format = m ;
  45. sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ;
  46. have_flac = info.format == SF_FORMAT_FLAC ? 1 : have_flac ;
  47. have_ogg = info.format == SF_FORMAT_OGG ? 1 : have_ogg ;
  48. } ;
  49. if (HAVE_EXTERNAL_LIBS)
  50. { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ;
  51. exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
  52. }
  53. else
  54. { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ;
  55. exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
  56. } ;
  57. puts ("ok") ;
  58. } /* major_format_test */
  59. static void
  60. subtype_format_test (void)
  61. { SF_FORMAT_INFO info ;
  62. int have_vorbis = 0 ;
  63. int s, subtype_count ;
  64. print_test_name (__func__, NULL) ;
  65. sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ;
  66. for (s = 0 ; s < subtype_count ; s++)
  67. { info.format = s ;
  68. sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ;
  69. have_vorbis = info.format == SF_FORMAT_VORBIS ? 1 : have_vorbis ;
  70. } ;
  71. if (HAVE_EXTERNAL_LIBS)
  72. exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
  73. else
  74. exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
  75. puts ("ok") ;
  76. } /* subtype_format_test */
  77. static void
  78. simple_format_test (void)
  79. { SF_FORMAT_INFO info ;
  80. int have_flac = 0, have_ogg = 0, have_vorbis = 0 ;
  81. int s, simple_count ;
  82. print_test_name (__func__, NULL) ;
  83. sf_command (NULL, SFC_GET_SIMPLE_FORMAT_COUNT, &simple_count, sizeof (int)) ;
  84. for (s = 0 ; s < simple_count ; s++)
  85. { info.format = s ;
  86. sf_command (NULL, SFC_GET_SIMPLE_FORMAT, &info, sizeof (info)) ;
  87. switch (info.format & SF_FORMAT_TYPEMASK)
  88. { case SF_FORMAT_FLAC :
  89. have_flac = 1 ;
  90. break ;
  91. case SF_FORMAT_OGG :
  92. have_ogg = 1 ;
  93. break ;
  94. default :
  95. break ;
  96. } ;
  97. switch (info.format & SF_FORMAT_SUBMASK)
  98. { case SF_FORMAT_VORBIS :
  99. have_vorbis = 1 ;
  100. break ;
  101. default :
  102. break ;
  103. } ;
  104. } ;
  105. if (HAVE_EXTERNAL_LIBS)
  106. { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ;
  107. exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
  108. exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
  109. }
  110. else
  111. { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ;
  112. exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
  113. exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
  114. } ;
  115. puts ("ok") ;
  116. } /* simple_format_test */