revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / AHI / Examples / Low-level / BestAudioID / BestAudioID.c
blob979c573831907ef2b1d5ed03a3d1598e211a8e71
1 /* Simple AHI_BestAudioID() example */
3 #include <devices/ahi.h>
4 #include <proto/exec.h>
5 #include <proto/dos.h>
6 #include <proto/ahi.h>
7 #include <stdlib.h>
8 #include <string.h>
10 struct Library *AHIBase;
11 struct MsgPort *AHImp=NULL;
12 struct AHIRequest *AHIio=NULL;
13 BYTE AHIDevice=-1;
15 void cleanup(LONG rc)
17 if(!AHIDevice)
18 CloseDevice((struct IORequest *)AHIio);
19 DeleteIORequest((struct IORequest *)AHIio);
20 DeleteMsgPort(AHImp);
21 exit(rc);
24 void printmode(ULONG id) {
25 char name[40];
27 if(id != AHI_INVALID_ID) {
28 name[0] = '\0';
29 AHI_GetAudioAttrs(id, NULL,
30 AHIDB_BufferLen, 40,
31 AHIDB_Name, (IPTR) name,
32 TAG_DONE);
34 else {
35 strncpy(name, "Non-existing mode!", 40);
38 Printf("\nMode 0x%08lx (%s):\n", id, name);
42 void main(void)
44 ULONG mainid, id;
46 if(AHImp=CreateMsgPort())
47 if(AHIio=(struct AHIRequest *)CreateIORequest(AHImp,sizeof(struct AHIRequest))) {
48 AHIio->ahir_Version = 4;
49 AHIDevice=OpenDevice(AHINAME,AHI_NO_UNIT,(struct IORequest *)AHIio,NULL);
52 if(AHIDevice) {
53 Printf("Unable to open %s version 4\n",AHINAME);
54 cleanup(RETURN_FAIL);
56 AHIBase=(struct Library *)AHIio->ahir_Std.io_Device;
58 mainid = AHI_BestAudioID(AHIDB_Stereo,TRUE,
59 AHIDB_Volume,TRUE,
60 AHIDB_Bits,8,
61 AHIDB_MaxChannels,4,
62 TAG_DONE);
63 printmode(mainid);
64 Printf("Stereo, Volume, >= 8 bits and >= 4 channels.\n");
67 struct TagItem tags[] = {
68 AHIDB_Bits, 12,
69 AHIDB_Panning, TRUE,
70 AHIDB_HiFi, TRUE,
71 TAG_DONE
73 id = AHI_BestAudioID(AHIDB_Stereo,TRUE,
74 AHIDB_Volume,TRUE,
75 AHIDB_Bits,8,
76 AHIDB_MaxChannels,4,
77 AHIB_Dizzy, (IPTR) &tags,
78 TAG_DONE);
79 printmode(id);
80 Printf("Same as 0x%08lx but also, if possible, "
81 ">= 12 bits, free stereo panning and HiFi mixing.\n", mainid);
85 struct TagItem tags[] = {
86 AHIDB_Bits, 16,
87 AHIDB_Stereo, FALSE,
88 TAG_DONE
91 id = AHI_BestAudioID(AHIDB_AudioID,id,
92 AHIB_Dizzy, (IPTR) &tags,
93 TAG_DONE);
95 printmode(id);
96 Printf("Using the same audio hardware at last mode, "
97 "this modes may have >= 16 bit resolution and be mono. But "
98 "I'm not sure.\n");
101 id = AHI_BestAudioID(AHIDB_Realtime, FALSE,
102 AHIDB_MaxChannels, 4,
103 TAG_DONE);
104 printmode(id);
105 Printf("A non-realtime mode with 4 channels.\n");
107 cleanup(0);