revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / AHI / Examples / Low-level / ScanAudioModes / ScanAudioModes.c
blobe1f7d08c4761e11d043bfcfb51c82309aed6a9c0
2 /* Shows the current Audio database in memory */
4 #include <dos/dos.h>
5 #include <devices/ahi.h>
6 #include <utility/tagitem.h>
7 #include <proto/exec.h>
8 #include <proto/dos.h>
9 #include <proto/ahi.h>
11 #define LEN 80
13 LONG __OSlibversion=37;
15 UBYTE vers[] = "\0$VER: ScanAudioModes 1.1 (28.4.96)";
17 struct Library *AHIBase;
18 struct MsgPort *AHImp=NULL;
19 struct AHIRequest *AHIio=NULL;
20 BYTE AHIDevice=-1;
22 void cleanup(LONG rc)
24 if(!AHIDevice)
25 CloseDevice((struct IORequest *)AHIio);
26 DeleteIORequest((struct IORequest *)AHIio);
27 DeleteMsgPort(AHImp);
28 exit(rc);
31 int main(void)
33 ULONG id=AHI_INVALID_ID;
34 LONG volume,stereo,panning,hifi,pingpong,record,realtime,fullduplex,
35 bits,channels,minmix,maxmix,freqs,inputs,outputs;
36 Fixed minmon,maxmon,mingain,maxgain,minout,maxout;
37 UBYTE name[LEN],driver[LEN],author[LEN],copyright[LEN],version[LEN],anno[LEN],
38 inputdesc[LEN],outputdesc[LEN];
39 LONG i;
41 if((AHImp=CreateMsgPort()))
42 if((AHIio=(struct AHIRequest *)CreateIORequest(AHImp,sizeof(struct AHIRequest)))) {
43 AHIio->ahir_Version=1;
44 AHIDevice=OpenDevice(AHINAME,AHI_NO_UNIT,(struct IORequest *)AHIio,NULL);
47 if(AHIDevice) {
48 Printf("Unable to open %s version 1\n",(IPTR) AHINAME);
49 cleanup(RETURN_FAIL);
51 AHIBase=(struct Library *)AHIio->ahir_Std.io_Device;
53 while ((id=AHI_NextAudioID(id)) != AHI_INVALID_ID) {
54 if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
56 Printf("***Break\n");
57 break;
60 // Clear all
61 volume=0;stereo=0;panning=0;hifi=0;pingpong=0;record=0;realtime=0;fullduplex=0;
62 bits=0;channels=0;minmix=0;maxmix=0;freqs=0;inputs=0;outputs=0;
63 name[0]='\0'; driver[0]='\0'; author[0]='\0'; copyright[0]='\0'; version[0]='\0';
64 anno[0]='\0'; inputdesc[0]='\0'; outputdesc[0]='\0';
66 Printf("\x1b[2mMode 0x%08lx\x1b[0m\n",id);
67 AHI_GetAudioAttrs(id, NULL,
68 AHIDB_BufferLen,LEN,
69 AHIDB_Frequencies,(IPTR) &freqs,
70 AHIDB_Volume, (IPTR) &volume,
71 AHIDB_Stereo, (IPTR) &stereo,
72 AHIDB_Panning, (IPTR) &panning,
73 AHIDB_HiFi,(IPTR) &hifi,
74 AHIDB_PingPong,(IPTR) &pingpong,
75 AHIDB_Record,(IPTR) &record,
76 AHIDB_FullDuplex,(IPTR) &fullduplex,
77 AHIDB_Realtime,(IPTR) &realtime,
78 AHIDB_Name,(IPTR) &name,
79 AHIDB_Driver,(IPTR) &driver,
80 AHIDB_Bits,(IPTR) &bits,
81 AHIDB_MaxChannels,(IPTR) &channels,
82 AHIDB_MinMixFreq,(IPTR) &minmix,
83 AHIDB_MaxMixFreq,(IPTR) &maxmix,
84 AHIDB_Author,(IPTR) &author,
85 AHIDB_Copyright,(IPTR) &copyright,
86 AHIDB_Version,(IPTR) &version,
87 AHIDB_Annotation,(IPTR) &anno,
88 AHIDB_MinMonitorVolume,(IPTR) &minmon,
89 AHIDB_MaxMonitorVolume,(IPTR) &maxmon,
90 AHIDB_MinInputGain,(IPTR) &mingain,
91 AHIDB_MaxInputGain,(IPTR) &maxgain,
92 AHIDB_MinOutputVolume,(IPTR) &minout,
93 AHIDB_MaxOutputVolume,(IPTR) &maxout,
94 AHIDB_Inputs,(IPTR) &inputs,
95 AHIDB_Outputs,(IPTR) &outputs,
96 TAG_DONE);
97 Printf(" Name: \"%s\" Driver: \"DEVS:AHI/%s.audio\"\n",
98 (IPTR) name, (IPTR) driver);
99 if(author[0])
100 Printf(" Driver programmed by: %s\n",(IPTR) author);
101 if(copyright[0])
102 Printf(" Copyright: %s\n",(IPTR) copyright);
103 for(i=0;i<LEN;i++)
104 if(version[i]=='\n' || version[i]=='\r')
105 version[i]='\0';
106 if(version[0])
107 Printf(" Version: %s\n",(IPTR) version);
108 if(anno[0])
109 Printf(" %s\n",(IPTR) anno);
110 Printf(" The hardware has %ld output(s)",outputs);
111 if(outputs>0)
113 Printf(":");
114 for(i=0;i<outputs;i++)
116 AHI_GetAudioAttrs(id, NULL,
117 AHIDB_BufferLen,LEN,
118 AHIDB_OutputArg,i,
119 AHIDB_Output,(IPTR) &outputdesc,
120 TAG_DONE);
121 Printf(" %s",(IPTR) &outputdesc);
124 Printf("\n and %ld input(s)",inputs);
125 if(inputs>0)
127 Printf(":");
128 for(i=0;i<inputs;i++)
130 AHI_GetAudioAttrs(id, NULL,
131 AHIDB_BufferLen,LEN,
132 AHIDB_InputArg,i,
133 AHIDB_Input,(IPTR) &inputdesc,
134 TAG_DONE);
135 Printf(" %s",(IPTR) &inputdesc);
138 Printf(".\n");
139 if(minmon==maxmon)
140 Printf(" No input monitor.\n");
141 else
142 Printf(" Input monitor volume range: %ld-%ld%%.\n",minmon*100>>16,maxmon*100>>16);
143 if(mingain==maxgain)
144 Printf(" No input gain.\n");
145 else
146 Printf(" Input gain range: %ld-%ld%%.\n",mingain*100>>16,maxgain*100>>16);
147 if(minout==maxout)
148 Printf(" No volume control.\n");
149 else
150 Printf(" Output volume range: %ld-%ld%%.\n",minout*100>>16,maxout*100>>16);
152 Printf("\n %s output%s in %ld bits.\n", (IPTR) (stereo ? "Stereo" : "Mono"),
153 (IPTR) (stereo ? (panning ? " (with panning)" : "" ) : ""),
154 bits);
155 Printf(" Can play samples on max %ld channels at %s, %s.\n", channels,
156 (IPTR) (volume ? "any volume" : "full volume only"),
157 (IPTR) (pingpong ? "both forwards and backwards" : "forwards only"));
158 Printf(" The mixing %sdestructive.\n", (IPTR) (hifi ? "is non-" : "may be "));
159 Printf(" %ld mixing frequencies between %ld and %ld are available.\n",freqs,minmix,maxmix);
160 Printf(" Recording is %ssupported", (IPTR) (record ? "" : "not "));
161 if(record)
162 Printf(" (%s duplex)", (IPTR) (fullduplex ? "Full" : "Half"));
163 Printf(".\n");
164 Printf(" This is a %srealtime mode.\n", (IPTR) (realtime ? "" : "non-"));
166 Printf("\n");
169 Printf("No more modes in the audio database.\n");
170 cleanup(RETURN_OK);
171 return RETURN_OK; // Make compiler happy