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