~ubuntu-branches/ubuntu/raring/siggen/raring

« back to all changes in this revision

Viewing changes to .pc/non-linux.diff/soundinfo.c

  • Committer: Package Import Robot
  • Author(s): Thorsten Alteholz
  • Date: 2012-03-13 18:51:09 UTC
  • mfrom: (4.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20120313185109-0zkxvq2vpwbjbkf2
Tags: 2.3.10-5
* new maintainer (closes: #628941)
* debian/rules: remove explicit patch targets
* debian/rules: replace dh_clean -k by dh_prep
* debian/rules: build-arch and build-indep introduced
* debian/rules: standard moved to 3.9.3 (no changes)
* debian/watch: added, but not working with upstreams website
* debian/control: dependency on quilt removed
* debian/control: no public vcs available
* debian/control: moved to dh 9
* debian/patches: add header
* debian/source/format: 3.0 (quilt) introduced

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* soundinfo.c
 
2
 * Describes the Linux Sound system support
 
3
 * Jim Jackson
 
4
 *
 
5
 *  Date     Vers   Comment
 
6
 *  -----    -----  ---------------
 
7
 *  27Oct96  1.0    Initial Program Built from generic filter.c
 
8
 *                  Reports mixer capabilities etc.
 
9
 *  18Nov96  1.1    Added DSP info
 
10
 */
 
11
 
 
12
/*
 
13
 * Copyright (C) 1997-2008 Jim Jackson                    jj@franjam.org.uk
 
14
 * 
 
15
 *  This program is free software; you can redistribute it and/or modify
 
16
 *  it under the terms of the GNU General Public License as published by
 
17
 *  the Free Software Foundation; either version 2 of the License, or
 
18
 *  (at your option) any later version.
 
19
 * 
 
20
 *  This program is distributed in the hope that it will be useful,
 
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
 *  GNU General Public License for more details.
 
24
 * 
 
25
 *  You should have received a copy of the GNU General Public License
 
26
 *  along with this program - see the file COPYING; if not, write to 
 
27
 *  the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
 
28
 *  MA 02139, USA.
 
29
 */
 
30
 
 
31
/***MANPAGE***/
 
32
/*
 
33
soundinfo: (version 1) 27Oct96
 
34
 
 
35
NAME:
 
36
        soundinfo  -  Describes the Linux Sound system support
 
37
 
 
38
SYNOPSIS:
 
39
        soundinfo [-v] [options]
 
40
 
 
41
DESCRIPTION:
 
42
 
 
43
Describes the Linux Sound system support on the system. Mixer devices,
 
44
DSP capabilities etc.
 
45
 
 
46
FLAGS:
 
47
 
 
48
-h       give usage
 
49
-v       verbose output
 
50
 
 
51
OPTIONS:
 
52
 
 
53
 
 
54
NOTES:
 
55
 
 
56
BUGS:
 
57
 
 
58
This program is covered by the GNU General Public License, see file
 
59
COPYING for further details.
 
60
 
 
61
Any questions, suggestions or problems, etc. should be sent to
 
62
 
 
63
Jim Jackson
 
64
 
 
65
Email Internet:  jj@franjam.org.uk
 
66
 
 
67
 */
 
68
 
 
69
/***INCLUDES***/
 
70
/* includes files 
 
71
 */
 
72
 
 
73
#include <stdio.h>
 
74
#include <stdlib.h>
 
75
#include <string.h>
 
76
#include <errno.h>
 
77
#include <fcntl.h>
 
78
#include <ctype.h>
 
79
#include <sys/types.h>
 
80
#include <sys/stat.h>
 
81
#include <sys/time.h>
 
82
#ifdef __FreeBSD__
 
83
#include <sys/soundcard.h>
 
84
#else
 
85
#include <linux/soundcard.h>
 
86
#endif
 
87
 
 
88
/***DEFINES***/
 
89
/* defines
 
90
 */
 
91
 
 
92
#define VERSION "2.3.10 (May 2008)"
 
93
#define MIXDEV "/dev/mixer"
 
94
#define DSPDEV "/dev/dsp"
 
95
 
 
96
#define EFAIL -1
 
97
 
 
98
#define TRUE 1
 
99
#define FALSE 0
 
100
#define nl puts("")
 
101
 
 
102
#define chkword(a,b) ((n>=a)&&(strncmp(p,b,n)==0))
 
103
 
 
104
/***GLOBALS***/
 
105
/* global variables
 
106
 */
 
107
 
 
108
char *sys;
 
109
short int debug;                       /* set if the -d flag is used */
 
110
short int vflg;                        /* set if -v flag used        */
 
111
 
 
112
/***DECLARATIONS***/
 
113
/* declare non-int functions 
 
114
 */
 
115
 
 
116
char *delnl(),*reads(),*sindex(),
 
117
     *sindex_nc(),*tab(),*ctime();
 
118
FILE *fopen(),*mfopen();
 
119
 
 
120
/***MAIN***/
 
121
/* main - for program  soundinfo
 
122
 *        Describes the Linux Sound system support
 
123
 */
 
124
 
 
125
main(argc,argv)
 
126
int argc;
 
127
char **argv;
 
128
 
 
129
 { int i,j,n,st;
 
130
   char fname[132],*fnm,*p;
 
131
   int fd;
 
132
    
 
133
   argv[argc]=NULL;
 
134
   sys=*argv++; argc--;
 
135
   if ((p=strrchr(sys,'/'))!=NULL) { sys=p+1; }
 
136
 
 
137
   debug=vflg=FALSE;
 
138
 
 
139
   printf("%s Ver. %s  (c) 1996-2008  Jim Jackson\n",sys,VERSION);
 
140
 
 
141
   while (argc && **argv=='-')            /* all flags and options must come */
 
142
    { n=strlen(p=(*argv++)+1); argc--;    /* before paramters                */
 
143
      if (*p==0) n=atoi(p+1);             /* e.g. num. option  -n23          */
 
144
      else                                /* check for single char. flags    */
 
145
        { for (; *p; p++)
 
146
            { if (*p=='h') exit(help(EFAIL));
 
147
              else if (*p=='d') debug=TRUE;
 
148
              else if (*p=='v') vflg=TRUE;
 
149
              else 
 
150
                { *fname='-'; *(fname+1)=*p; *(fname+2)=0;
 
151
                  exit(help(err_rpt(EINVAL,fname)));
 
152
                }
 
153
            }
 
154
        }
 
155
    }
 
156
 
 
157
   if ((fd = open(fnm=MIXDEV, O_RDONLY)) < 0) {
 
158
     err_rpt(errno,fnm);
 
159
   } else {
 
160
     do_mix(fd,fnm);
 
161
   }
 
162
 
 
163
   if ((fd = open(fnm=DSPDEV, O_RDWR)) < 0) {
 
164
     err_rpt(errno,fnm);
 
165
   } else {
 
166
     do_dsp(fd,fnm);
 
167
   }
 
168
 
 
169
   exit(st);
 
170
 }
 
171
 
 
172
/***HELP***/
 
173
/* help(e)  print brief help message - return parameter given
 
174
 */
 
175
 
 
176
help(e)
 
177
int e;
 
178
 
 
179
 {
 
180
   puts("\n\
 
181
Describes some features of the Linux Sound system support in the kernel.\n\
 
182
");
 
183
   printf("\
 
184
Usage:   %s\n\
 
185
",sys);
 
186
   return(e);
 
187
 }
 
188
 
 
189
do_dsp(fd,dev)
 
190
int fd;
 
191
char *dev;
 
192
{
 
193
   int i,n;
 
194
   int caps,fmts,blksize;
 
195
   char buf[130],*p;
 
196
   audio_buf_info auobf,auibf;
 
197
 
 
198
   if (ioctl(fd, SNDCTL_DSP_GETCAPS , &caps) < 0) {
 
199
      return(err_rpt(errno,"Reading DSP capabilities."));
 
200
   }
 
201
   if (ioctl(fd, SNDCTL_DSP_GETFMTS , &fmts) < 0) {
 
202
      return(err_rpt(errno,"Reading DSP formats."));
 
203
   }
 
204
   if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE , &blksize) < 0) {
 
205
      return(err_rpt(errno,"Reading blocksize."));
 
206
   }
 
207
   if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &auobf) < 0) {
 
208
      return(err_rpt(errno,"Reading output audio buffer info."));
 
209
   }
 
210
   if (ioctl(fd, SNDCTL_DSP_GETISPACE, &auibf) < 0) {
 
211
      return(err_rpt(errno,"Reading input audio buffer info."));
 
212
   }
 
213
 
 
214
   printf("\nDSP details ................\n");
 
215
   printf("     capabilities = 0x%09X\n        formats = 0x%09X\n",caps,fmts);
 
216
   printf("       blocksize = %d\n", blksize);
 
217
 
 
218
   printf("\nDSP Capability revision level %d\n",caps&255);
 
219
   printf("    %s duplex operation (simultaneous read/write)\n",
 
220
          (caps&DSP_CAP_DUPLEX)?"Supports":"Does not support");
 
221
   if (caps&DSP_CAP_REALTIME) 
 
222
     printf("    Supports RealTime capability.\n" );
 
223
   if (caps&DSP_CAP_BATCH)
 
224
     printf("    Has batch facilities (buffers) which may cause timing problems etc.\n");
 
225
   if (caps&DSP_CAP_COPROC)
 
226
     printf("    Has a Co-Processor\n");
 
227
   printf("    %s SETTRIGGER operation.\n",
 
228
          (caps&DSP_CAP_TRIGGER)?"Supports":"Does not support");
 
229
 
 
230
   printf("\nDSP Formats supported are :-\n");
 
231
   if (fmts&AFMT_MU_LAW) printf("  Mu_Law ");
 
232
   if (fmts&AFMT_A_LAW) printf("   A_Law ");
 
233
   if (fmts&AFMT_IMA_ADPCM) printf("   IMA_ADPCM ");
 
234
   if (fmts&AFMT_U8) printf("   U8 ");
 
235
   if (fmts&AFMT_S16_LE) printf("   S16_LE ");
 
236
   if (fmts&AFMT_S16_BE) printf("   S16_BE ");
 
237
   if (fmts&AFMT_S8) printf("   S8 ");
 
238
   if (fmts&AFMT_U16_LE) printf("   U16_LE ");
 
239
   if (fmts&AFMT_U16_BE) printf("   U16_BE ");
 
240
   if (fmts&AFMT_MPEG) printf("   MPEG ");
 
241
   printf("\n\n"); 
 
242
 
 
243
   printf("Fragment details    Output.. Input..\n");
 
244
   printf(" total fragments      %4d     %4d\n",
 
245
                  auobf.fragstotal,auibf.fragstotal);
 
246
   printf("       available      %4d     %4d\n",
 
247
                  auobf.fragments,auibf.fragments);
 
248
   printf("   fragment size     %5d    %5d\n",
 
249
                  auobf.fragsize,auibf.fragsize);
 
250
   printf(" bytes available    %6d   %6d\n\n",
 
251
                  auobf.bytes,auibf.bytes);
 
252
}
 
253
 
 
254
do_mix(fd,dev)
 
255
int fd;
 
256
char *dev;
 
257
{
 
258
   int devmask,recmask,sources,stereodevs,capabilities;
 
259
   int i,n;
 
260
   char buf[130];
 
261
   char *devname[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_LABELS;
 
262
   int level[SOUND_MIXER_NRDEVICES];
 
263
   struct mixer_info Mix_Info;
 
264
 
 
265
   if (ioctl(fd, SOUND_MIXER_INFO, &Mix_Info) < 0) {
 
266
      err_rpt(errno,"Getting mixer_info details.");
 
267
      Mix_Info.id[0]=Mix_Info.name[0]=0;
 
268
   }
 
269
   if (ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devmask) < 0) {
 
270
      return(err_rpt(errno,"Reading Mixer Channels."));
 
271
   }
 
272
   if (devmask==0) {
 
273
      return(err_rpt(ENODEV,"Mixer has no Channels!"));
 
274
   }
 
275
   if (ioctl(fd, SOUND_MIXER_READ_RECMASK, &recmask) < 0) {
 
276
      return(err_rpt(errno,"Reading Recording Mask."));
 
277
   }
 
278
   if (ioctl(fd, SOUND_MIXER_READ_RECSRC, &sources) < 0) {
 
279
      return(err_rpt(errno,"Reading Recording Devices."));
 
280
   }
 
281
   if (ioctl(fd, SOUND_MIXER_READ_STEREODEVS, &stereodevs) < 0) {
 
282
      return(err_rpt(errno,"Reading Stereo Devices."));
 
283
   }
 
284
   if (ioctl(fd, SOUND_MIXER_READ_CAPS, &capabilities) < 0) {
 
285
      return(err_rpt(errno,"Reading Mixer Capabilities."));
 
286
   }
 
287
 
 
288
   printf("MIXER DETAILS ......................\n");
 
289
   printf("           Mixer Id = %s\n               Name = %s\n",Mix_Info.id,Mix_Info.name);
 
290
   printf("           devmask  = 0x%09X\n           recmask  = 0x%09X\n",devmask,recmask);
 
291
   printf("           sources  = 0x%09X\n        stereodevs  = 0x%09X\n",sources,stereodevs);
 
292
   printf("MIXER capabilities  = 0x%09X\n",capabilities);
 
293
   if (capabilities & SOUND_CAP_EXCL_INPUT)
 
294
     printf("      Only one sound source can be selected at a time.\n"); 
 
295
   
 
296
   printf("\nMIXER (%s) has following channels, set as :-\n",dev);
 
297
   for (i=0; i<SOUND_MIXER_NRDEVICES; i++) {
 
298
      if (devmask & (1<<i)) {
 
299
         if (ioctl(fd, MIXER_READ(i), &n) < 0) {
 
300
            sprintf(buf,"Problem reading current level of mixer channel %s.",
 
301
                    devname[i]);
 
302
            err_rpt(ENODEV,buf);
 
303
         } else {
 
304
            printf("  [0x%08X] %2d  %-6s  %3d",1<<i,i,devname[i],n&255);
 
305
            if (stereodevs & (1<<i)) { printf("/%3d ",(n>>8)&255);
 
306
            } else { printf("     "); }
 
307
            printf("%9s ", (recmask & (1<<i))? "source":"");
 
308
            printf("%10s ", (sources & (1<<i))? "selected":"");
 
309
            puts(""); /* nl */
 
310
         }
 
311
      }
 
312
   }
 
313
}
 
314
    
 
315
/***ERR_RPT***/
 
316
/* err_rpt(err,msg)
 
317
 */
 
318
 
 
319
err_rpt(err,msg)
 
320
short int err;
 
321
char *msg;
 
322
 
 
323
 { 
 
324
   extern char *sys;
 
325
 
 
326
   if (err) fprintf(stderr,"[%s] %s : %s\n",sys,strerror(err),msg);
 
327
   return(err);
 
328
 }
 
329