2 /* Demo of AHI's Audio mode requester */
4 #include <devices/ahi.h>
6 #include <proto/exec.h>
12 struct Library
*AHIBase
;
13 struct MsgPort
*AHImp
=NULL
;
14 struct AHIRequest
*AHIio
=NULL
;
17 struct TagItem ReqFilterTags
[] = {
18 // {AHIDB_Realtime, TRUE}, // Remove the FILESAVE modes (among others?)
25 CloseDevice((struct IORequest
*)AHIio
);
26 DeleteIORequest((struct IORequest
*)AHIio
);
33 struct AHIAudioModeRequester
*req
;
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
);
43 Printf("Unable to open %s version 2\n",AHINAME
);
46 AHIBase
=(struct Library
*)AHIio
->ahir_Std
.io_Device
;
48 req
=AHI_AllocAudioRequest(
49 AHIR_SleepWindow
,TRUE
,
51 AHIR_PubScreenName
,NULL
,
54 res
=AHI_AudioRequest(req
,
55 AHIR_TitleText
, "Select a mode or cancel",
56 AHIR_NegativeText
, "Abort",
58 AHIR_DoDefaultMode
, TRUE
,
59 AHIR_InitialAudioID
, 0x20003,
60 AHIR_InitialMixFreq
, 30000,
61 AHIR_FilterTags
, ReqFilterTags
,
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");
71 Printf("Requester cancelled!\n");
74 Printf("Selected AudioMode: 0x%08lx, %ld Hz\n",req
->ahiam_AudioID
,req
->ahiam_MixFreq
);
76 AHI_FreeAudioRequest(req
);