annotate libao2/ao_sgi.c @ 2566:a350d8bed636

bugfixes small speedup for the non x86 stuff
author michael
date Tue, 30 Oct 2001 20:30:24 +0000
parents a56bf9c0e76f
children 981a9e5118ce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
1 /*
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
2 ao_sgi - sgi/irix output plugin for MPlayer
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
3
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
4 22oct2001 oliver.schoenbrunner@jku.at
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
5
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
6 */
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
7
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
8 #include <stdio.h>
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
9 #include <stdlib.h>
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
10 #include <dmedia/audio.h>
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
11
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
12 #include "audio_out.h"
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
13 #include "audio_out_internal.h"
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
14
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
15 static ao_info_t info =
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
16 {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
17 "sgi audio output",
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
18 "sgi",
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
19 "kopflos",
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
20 ""
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
21 };
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
22
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
23 LIBAO_EXTERN(sgi)
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
24
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
25 // there are some globals:
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
26 // ao_samplerate
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
27 // ao_channels
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
28 // ao_format
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
29 // ao_bps
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
30 // ao_outburst
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
31 // ao_buffersize
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
32
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
33 static ALconfig ao_config;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
34 static ALport ao_port;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
35
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
36 // to set/get/query special features/parameters
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
37 static int control(int cmd, int arg){
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
38
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
39 printf("ao_sgi, control\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
40
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
41 return -1;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
42 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
43
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
44 // open & setup audio device
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
45 // return: 1=success 0=fail
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
46 static int init(int rate, int channels, int format, int flags) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
47
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
48 printf("ao_sgi, init: Samplerate: %iHz Channels: %s Format %s\n", rate, (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
49
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
50 { /* from /usr/share/src/dmedia/audio/setrate.c */
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
51
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
52 int fd;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
53 int rv;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
54 double frate;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
55 ALpv x[2];
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
56
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
57 rv = alGetResourceByName(AL_SYSTEM, "out.analog", AL_DEVICE_TYPE);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
58 if (!rv) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
59 printf("ao_sgi, play: invalid device\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
60 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
61 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
62
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
63 frate = rate;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
64
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
65 x[0].param = AL_RATE;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
66 x[0].value.ll = alDoubleToFixed(rate);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
67 x[1].param = AL_MASTER_CLOCK;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
68 x[1].value.i = AL_CRYSTAL_MCLK_TYPE;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
69
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
70 if (alSetParams(rv,x, 2)<0) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
71 printf("ao_sgi, init: setparams failed: %s\n", alGetErrorString(oserror()));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
72 printf("ao_sgi, init: could not set desired samplerate\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
73 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
74
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
75 if (x[0].sizeOut < 0) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
76 printf("ao_sgi, init: AL_RATE was not accepted on the given resource\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
77 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
78
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
79 if (alGetParams(rv,x, 1)<0) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
80 printf("ao_sgi, init: getparams failed: %s\n", alGetErrorString(oserror()));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
81 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
82
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
83 if (frate != alFixedToDouble(x[0].value.ll)) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
84 printf("ao_sgi, init: samplerate is now %lf (desired rate is %lf)\n", alFixedToDouble(x[0].value.ll), frate);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
85 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
86
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
87 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
88
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
89 ao_buffersize=131072;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
90 ao_outburst = ao_buffersize/16;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
91 ao_channels = channels;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
92
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
93 ao_config = alNewConfig();
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
94
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
95 if (!ao_config) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
96 printf("ao_sgi, init: %s\n", alGetErrorString(oserror()));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
97 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
98 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
99
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
100 if(channels == 2) alSetChannels(ao_config, AL_STEREO);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
101 else alSetChannels(ao_config, AL_MONO);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
102
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
103 alSetWidth(ao_config, AL_SAMPLE_16);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
104 alSetSampFmt(ao_config, AL_SAMPFMT_TWOSCOMP);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
105 alSetQueueSize(ao_config, 48000);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
106
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
107 if (alSetDevice(ao_config, AL_DEFAULT_OUTPUT) < 0) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
108 printf("ao_sgi, init: %s\n", alGetErrorString(oserror()));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
109 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
110 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
111
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
112 ao_port = alOpenPort("mplayer", "w", ao_config);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
113
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
114 if (!ao_port) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
115 printf("ao_sgi, init: Unable to open audio channel: %s\n", alGetErrorString(oserror()));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
116 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
117 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
118
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
119 // printf("ao_sgi, init: port %d config %d\n", ao_port, ao_config);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
120
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
121 return 1;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
122
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
123 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
124
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
125 // close audio device
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
126 static void uninit() {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
127
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
128 /* TODO: samplerate should be set back to the value before mplayer was started! */
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
129
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
130 printf("ao_sgi, uninit: ...\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
131
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
132 if (ao_port) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
133 while(alGetFilled(ao_port) > 0) sginap(1);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
134 alClosePort(ao_port);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
135 alFreeConfig(ao_config);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
136 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
137
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
138 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
139
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
140 // stop playing and empty buffers (for seeking/pause)
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
141 static void reset() {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
142
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
143 printf("ao_sgi, reset: ...\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
144
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
145 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
146
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
147 // stop playing, keep buffers (for pause)
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
148 static void audio_pause() {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
149
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
150 printf("ao_sgi, audio_pause: ...\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
151
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
152 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
153
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
154 // resume playing, after audio_pause()
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
155 static void audio_resume() {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
156
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
157 printf("ao_sgi, audio_resume: ...\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
158
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
159 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
160
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
161 // return: how many bytes can be played without blocking
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
162 static int get_space() {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
163
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
164 // printf("ao_sgi, get_space: (ao_outburst %d)\n", ao_outburst);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
165 // printf("ao_sgi, get_space: alGetFillable [%d] \n", alGetFillable(ao_port));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
166
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
167 return alGetFillable(ao_port)*(2*ao_channels);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
168
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
169 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
170
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
171
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
172 // plays 'len' bytes of 'data'
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
173 // it should round it down to outburst*n
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
174 // return: number of bytes played
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
175 static int play(void* data, int len, int flags) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
176
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
177 // printf("ao_sgi, play: len %d flags %d (%d %d)\n", len, flags, ao_port, ao_config);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
178 // printf("channels %d\n", ao_channels);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
179
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
180 alWriteFrames(ao_port, data, len/(2*ao_channels));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
181
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
182 return len;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
183
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
184 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
185
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
186 // return: how many unplayed bytes are in the buffer
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
187 static int get_delay(){
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
188
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
189 // printf("ao_sgi, get_delay: (ao_buffersize %d)\n", ao_buffersize);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
190
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
191 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
192
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
193 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
194
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
195
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
196
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
197
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
198
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
199