1b815c7f3Sopenharmony_ci/*
2b815c7f3Sopenharmony_ci** Copyright (C) 2001-2014 Erik de Castro Lopo <erikd@mega-nerd.com>
3b815c7f3Sopenharmony_ci**
4b815c7f3Sopenharmony_ci** All rights reserved.
5b815c7f3Sopenharmony_ci**
6b815c7f3Sopenharmony_ci** Redistribution and use in source and binary forms, with or without
7b815c7f3Sopenharmony_ci** modification, are permitted provided that the following conditions are
8b815c7f3Sopenharmony_ci** met:
9b815c7f3Sopenharmony_ci**
10b815c7f3Sopenharmony_ci**     * Redistributions of source code must retain the above copyright
11b815c7f3Sopenharmony_ci**       notice, this list of conditions and the following disclaimer.
12b815c7f3Sopenharmony_ci**     * Redistributions in binary form must reproduce the above copyright
13b815c7f3Sopenharmony_ci**       notice, this list of conditions and the following disclaimer in
14b815c7f3Sopenharmony_ci**       the documentation and/or other materials provided with the
15b815c7f3Sopenharmony_ci**       distribution.
16b815c7f3Sopenharmony_ci**     * Neither the author nor the names of any contributors may be used
17b815c7f3Sopenharmony_ci**       to endorse or promote products derived from this software without
18b815c7f3Sopenharmony_ci**       specific prior written permission.
19b815c7f3Sopenharmony_ci**
20b815c7f3Sopenharmony_ci** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21b815c7f3Sopenharmony_ci** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22b815c7f3Sopenharmony_ci** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23b815c7f3Sopenharmony_ci** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24b815c7f3Sopenharmony_ci** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25b815c7f3Sopenharmony_ci** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26b815c7f3Sopenharmony_ci** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27b815c7f3Sopenharmony_ci** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28b815c7f3Sopenharmony_ci** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29b815c7f3Sopenharmony_ci** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30b815c7f3Sopenharmony_ci** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31b815c7f3Sopenharmony_ci*/
32b815c7f3Sopenharmony_ci
33b815c7f3Sopenharmony_ci#include	<stdio.h>
34b815c7f3Sopenharmony_ci#include	<stdlib.h>
35b815c7f3Sopenharmony_ci#include	<string.h>
36b815c7f3Sopenharmony_ci#include	<math.h>
37b815c7f3Sopenharmony_ci
38b815c7f3Sopenharmony_ci#include	<sndfile.h>
39b815c7f3Sopenharmony_ci
40b815c7f3Sopenharmony_ciint
41b815c7f3Sopenharmony_cimain (void)
42b815c7f3Sopenharmony_ci{	SF_FORMAT_INFO	info ;
43b815c7f3Sopenharmony_ci	SF_INFO 		sfinfo ;
44b815c7f3Sopenharmony_ci	int format, major_count, subtype_count, m, s ;
45b815c7f3Sopenharmony_ci
46b815c7f3Sopenharmony_ci	memset (&sfinfo, 0, sizeof (sfinfo)) ;
47b815c7f3Sopenharmony_ci	printf ("Version : %s\n\n", sf_version_string ()) ;
48b815c7f3Sopenharmony_ci
49b815c7f3Sopenharmony_ci	sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ;
50b815c7f3Sopenharmony_ci	sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ;
51b815c7f3Sopenharmony_ci
52b815c7f3Sopenharmony_ci	sfinfo.channels = 1 ;
53b815c7f3Sopenharmony_ci	for (m = 0 ; m < major_count ; m++)
54b815c7f3Sopenharmony_ci	{	info.format = m ;
55b815c7f3Sopenharmony_ci		sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ;
56b815c7f3Sopenharmony_ci		printf ("%s  (extension \"%s\")\n", info.name, info.extension) ;
57b815c7f3Sopenharmony_ci
58b815c7f3Sopenharmony_ci		format = info.format ;
59b815c7f3Sopenharmony_ci
60b815c7f3Sopenharmony_ci		for (s = 0 ; s < subtype_count ; s++)
61b815c7f3Sopenharmony_ci		{	info.format = s ;
62b815c7f3Sopenharmony_ci			sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ;
63b815c7f3Sopenharmony_ci
64b815c7f3Sopenharmony_ci			format = (format & SF_FORMAT_TYPEMASK) | info.format ;
65b815c7f3Sopenharmony_ci
66b815c7f3Sopenharmony_ci			sfinfo.format = format ;
67b815c7f3Sopenharmony_ci			if (sf_format_check (&sfinfo))
68b815c7f3Sopenharmony_ci				printf ("   %s\n", info.name) ;
69b815c7f3Sopenharmony_ci			} ;
70b815c7f3Sopenharmony_ci		puts ("") ;
71b815c7f3Sopenharmony_ci		} ;
72b815c7f3Sopenharmony_ci	puts ("") ;
73b815c7f3Sopenharmony_ci
74b815c7f3Sopenharmony_ci	return 0 ;
75b815c7f3Sopenharmony_ci} /* main */
76b815c7f3Sopenharmony_ci
77