Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / AHI / Examples / Low-level / Req-test / req-test.c
blob3a2a9b477e93341d5ffa5a4835018d282401927d
2 /* Demo of AHI's Audio mode requester */
4 #include <devices/ahi.h>
5 #include <dos/dos.h>
6 #include <proto/exec.h>
7 #include <proto/dos.h>
8 #include <proto/ahi.h>
9 //#include <stdio.h>
10 #include <stdlib.h>
12 struct Library *AHIBase;
13 struct MsgPort *AHImp=NULL;
14 struct AHIRequest *AHIio=NULL;
15 BYTE AHIDevice=-1;
17 struct TagItem ReqFilterTags[] = {
18 // {AHIDB_Realtime, TRUE}, // Remove the FILESAVE modes (among others?)
19 {TAG_DONE,}
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 void main(void)
33 struct AHIAudioModeRequester *req;
34 BOOL res;
36 if(AHImp=CreateMsgPort())
37 if(AHIio=(struct AHIRequest *)CreateIORequest(AHImp,sizeof(struct AHIRequest))) {
38 AHIio->ahir_Version = 2;
39 AHIDevice=OpenDevice(AHINAME,AHI_NO_UNIT,(struct IORequest *)AHIio,NULL);
42 if(AHIDevice) {
43 Printf("Unable to open %s version 2\n",AHINAME);
44 cleanup(RETURN_FAIL);
46 AHIBase=(struct Library *)AHIio->ahir_Std.io_Device;
48 req=AHI_AllocAudioRequest(
49 AHIR_SleepWindow,TRUE,
50 AHIR_UserData,999,
51 AHIR_PubScreenName,NULL,
52 TAG_DONE);
54 res=AHI_AudioRequest(req,
55 AHIR_TitleText, "Select a mode or cancel",
56 AHIR_NegativeText, "Abort",
57 AHIR_DoMixFreq, TRUE,
58 AHIR_DoDefaultMode, TRUE,
59 AHIR_InitialAudioID, 0x20003,
60 AHIR_InitialMixFreq, 30000,
61 AHIR_FilterTags, ReqFilterTags,
62 TAG_DONE);
64 if(!res)
66 if(IoErr() == ERROR_NO_FREE_STORE)
67 Printf("AHI ran out of memory!\n");
68 else if(IoErr() == ERROR_NO_MORE_ENTRIES)
69 Printf("No available modes!\n");
70 else
71 Printf("Requester cancelled!\n");
73 else
74 Printf("Selected AudioMode: 0x%08lx, %ld Hz\n",req->ahiam_AudioID,req->ahiam_MixFreq);
76 AHI_FreeAudioRequest(req);
78 cleanup(RETURN_OK);