annotate src/libsndfile-1.0.25/examples/list_formats.c @ 169:223a55898ab9 tip default

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