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