annotate playercode/unix_drv/drv_aix.c @ 11:d5cb2cfc8eca

Initial revision
author darius
date Fri, 23 Jan 1998 16:05:11 +0000
parents b30908f9d9f9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1 /*
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
2
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
3 Name:
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
4 drv_aix.c
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
5
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
6 Description:
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
7 Mikmod driver for output to AIX series audio device
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
8
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
9 Portability:
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
10
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
11 AIX >= 3.25 with appropriate audio hardware.
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
12
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
13 Written by Lutz Vieweg <lkv@mania.robin.de>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
14 based on drv_raw.c
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
15
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
16 Feel free to distribute just as you like.
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
17 No warranties at all.
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
18
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
19 */
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
20
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
21 #include <stdio.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
22 #include <stdlib.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
23
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
24 #include <unistd.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
25 #include <fcntl.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
26 #include <errno.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
27 #include <sys/stat.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
28 #include <sys/audio.h>
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
29
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
30 #include "mikmod.h"
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
31
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
32 struct _track_info
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
33 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
34 unsigned short master_volume;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
35 unsigned short dither_percent;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
36 unsigned short reserved[3];
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
37 } t_info;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
38 audio_init a_init;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
39 audio_control a_control;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
40 audio_change a_change;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
41
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
42
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
43 static int fd;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
44 #define RAWBUFFERSIZE 32768
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
45 static char RAW_DMABUF[RAWBUFFERSIZE];
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
46
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
47 static BOOL AIX_IsThere(void)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
48 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
49 return 1;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
50 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
51
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
52 static BOOL AIX_Init(void)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
53 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
54 float volume = (float)1.0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
55 int flags;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
56
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
57 if (! (md_mode & DMODE_16BITS)) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
58 myerr = "sorry, this driver supports 16-bit linear output only";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
59 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
60 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
61
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
62 if ((fd = open ("/dev/acpa0/1", O_WRONLY)) < 3)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
63 if ((fd = open ("/dev/paud0/1", O_WRONLY)) < 3)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
64 if ((fd = open ("/dev/baud0/1", O_WRONLY)) < 3)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
65 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
66 myerr = "unable to open audio-device";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
67 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
68 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
69
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
70
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
71 t_info.master_volume=0x7fff;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
72 t_info.dither_percent=0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
73
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
74 a_init.srate=md_mixfreq;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
75 a_init.bits_per_sample=16;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
76 a_init.channels=(md_mode & DMODE_STEREO)? 2 : 1;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
77 a_init.mode=PCM;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
78 a_init.flags=FIXED | BIG_ENDIAN | TWOS_COMPLEMENT;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
79 a_init.operation=PLAY;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
80
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
81 a_change.balance=0x3fff0000;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
82 a_change.balance_delay=0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
83 a_change.volume=(long)(volume * (float)0x7FFFFFFF);
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
84 a_change.volume_delay=0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
85 a_change.monitor=AUDIO_IGNORE;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
86 a_change.input=AUDIO_IGNORE;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
87 a_change.output=OUTPUT_1;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
88 a_change.dev_info=&t_info;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
89
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
90 a_control.ioctl_request=AUDIO_CHANGE;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
91 a_control.position=0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
92 a_control.request_info=&a_change;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
93
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
94 if (ioctl(fd, AUDIO_INIT, &a_init) == -1 )
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
95 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
96 myerr = "configuration (init) of audio device failed";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
97 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
98 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
99 if (ioctl(fd, AUDIO_CONTROL, &a_control) == -1 )
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
100 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
101 myerr = "configuration (control) of audio device failed";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
102 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
103 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
104
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
105 a_control.ioctl_request=AUDIO_START;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
106 a_control.request_info=NULL;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
107 if (ioctl(fd, AUDIO_CONTROL, &a_control) == -1 )
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
108 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
109 myerr = "configuration (start) of audio device failed";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
110 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
111 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
112
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
113 #if 0
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
114 if ((flags = fcntl (fd, F_GETFL, 0)) < 0) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
115 myerr = "unable to set non-blocking mode for /dev/audio";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
116 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
117 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
118 flags |= O_NDELAY;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
119 if (fcntl (fd, F_SETFL, flags) < 0) {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
120 myerr = "unable to set non-blocking mode for /dev/audio";
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
121 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
122 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
123 #endif
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
124
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
125 if(!VC_Init()){
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
126 close(fd);
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
127 return 0;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
128 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
129
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
130 return 1;
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
131 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
132
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
133
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
134
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
135 static void AIX_Exit(void)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
136 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
137 VC_Exit();
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
138 close(fd);
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
139 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
140
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
141
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
142 static void AIX_Update(void)
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
143 {
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
144 VC_WriteBytes(RAW_DMABUF,RAWBUFFERSIZE);
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
145 write(fd, RAW_DMABUF, RAWBUFFERSIZE);
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
146 }
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
147
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
148
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
149 DRIVER drv_aix={
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
150 NULL,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
151 "AIX audio-device",
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
152 "MikMod AIX audio-device driver v1.10",
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
153 AIX_IsThere,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
154 VC_SampleLoad,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
155 VC_SampleUnload,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
156 VC_SampleSpace,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
157 VC_SampleLength,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
158 AIX_Init,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
159 AIX_Exit,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
160 VC_SetNumChannels,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
161 VC_PlayStart,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
162 VC_PlayStop,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
163 AIX_Update,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
164 VC_VoiceSetVolume,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
165 VC_VoiceSetFrequency,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
166 VC_VoiceSetPanning,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
167 VC_VoicePlay,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
168 VC_VoiceStop,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
169 VC_VoiceStopped,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
170 VC_VoiceReleaseSustain,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
171 VC_VoiceGetPosition,
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
172 VC_RealVolume
b30908f9d9f9 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
173 };