annotate libao2/ao_sgi.c @ 15140:0b29b871f5b4

credits for Jeff Clagg
author diego
date Wed, 13 Apr 2005 01:56:53 +0000
parents d313f591d1a4
children 27a2bc4aad72
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"
14123
a92101a7eb49 Make include paths consistent.
diego
parents: 13549
diff changeset
14 #include "mp_msg.h"
a92101a7eb49 Make include paths consistent.
diego
parents: 13549
diff changeset
15 #include "help_mp.h"
2451
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 static ao_info_t info =
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
18 {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
19 "sgi audio output",
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
20 "sgi",
13549
4604fc855b3a fixing authors
alex
parents: 13383
diff changeset
21 "Oliver Schoenbrunner",
2451
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 };
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 LIBAO_EXTERN(sgi)
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
26
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
27
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
28 static ALconfig ao_config;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
29 static ALport ao_port;
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
30 static int sample_rate;
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
31 static int queue_size;
2451
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 // to set/get/query special features/parameters
9633
12b1790038b0 64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents: 3095
diff changeset
34 static int control(int cmd, void *arg){
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
35
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
36 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_INFO);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
37
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
38 return -1;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
39 }
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 // open & setup audio device
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
42 // return: 1=success 0=fail
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
43 static int init(int rate, int channels, int format, int flags) {
14249
8f59f661f317 hopefully final fix
alex
parents: 14123
diff changeset
44
14264
cb5fbade8a5c af_fmt2str_short
alex
parents: 14255
diff changeset
45 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_InitInfo, rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format));
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
46
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
47 { /* from /usr/share/src/dmedia/audio/setrate.c */
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
48
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
49 int fd;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
50 int rv;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
51 double frate;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
52 ALpv x[2];
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
53
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
54 rv = alGetResourceByName(AL_SYSTEM, "out.analog", AL_DEVICE_TYPE);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
55 if (!rv) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
56 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InvalidDevice);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
57 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
58 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
59
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
60 frate = rate;
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
61
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
62 x[0].param = AL_RATE;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
63 x[0].value.ll = alDoubleToFixed(rate);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
64 x[1].param = AL_MASTER_CLOCK;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
65 x[1].value.i = AL_CRYSTAL_MCLK_TYPE;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
66
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
67 if (alSetParams(rv,x, 2)<0) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
68 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantSetParms_Samplerate, alGetErrorString(oserror()));
2451
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
71 if (x[0].sizeOut < 0) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
72 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantSetAlRate);
2451
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 (alGetParams(rv,x, 1)<0) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
76 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantGetParms, alGetErrorString(oserror()));
2451
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 (frate != alFixedToDouble(x[0].value.ll)) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
80 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_SampleRateInfo, alFixedToDouble(x[0].value.ll), frate);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
81 }
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
82 sample_rate = (int)frate;
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
83 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
84
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
85 ao_data.buffersize=131072;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
86 ao_data.outburst = ao_data.buffersize/16;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
87 ao_data.channels = channels;
2451
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_config = alNewConfig();
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
90
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
91 if (!ao_config) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
92 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitConfigError, alGetErrorString(oserror()));
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
93 return 0;
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
96 if(channels == 2) alSetChannels(ao_config, AL_STEREO);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
97 else alSetChannels(ao_config, AL_MONO);
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 alSetWidth(ao_config, AL_SAMPLE_16);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
100 alSetSampFmt(ao_config, AL_SAMPFMT_TWOSCOMP);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
101 alSetQueueSize(ao_config, 48000);
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 if (alSetDevice(ao_config, AL_DEFAULT_OUTPUT) < 0) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
104 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitConfigError, alGetErrorString(oserror()));
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
105 return 0;
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
108 ao_port = alOpenPort("mplayer", "w", ao_config);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
109
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
110 if (!ao_port) {
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
111 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitOpenAudioFailed, alGetErrorString(oserror()));
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
112 return 0;
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
115 // printf("ao_sgi, init: port %d config %d\n", ao_port, ao_config);
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
116 queue_size = alGetQueueSize(ao_config);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
117 return 1;
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 }
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 // close audio device
12145
99798c3cdb93 uninit immed flag
alex
parents: 11323
diff changeset
122 static void uninit(int immed) {
2451
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 /* 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
125
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
126 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Uninit);
2451
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 if (ao_port) {
14849
d313f591d1a4 aos should respect the immed uninit flag (quit immediatly vs waiting till file
reimar
parents: 14264
diff changeset
129 if (!immed)
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
130 while(alGetFilled(ao_port) > 0) sginap(1);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
131 alClosePort(ao_port);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
132 alFreeConfig(ao_config);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
133 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
134
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
135 }
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 // stop playing and empty buffers (for seeking/pause)
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
138 static void reset() {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
139
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
140 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Reset);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
141
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
144 // stop playing, keep buffers (for pause)
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
145 static void audio_pause() {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
146
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
147 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_PauseInfo);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
148
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
151 // resume playing, after audio_pause()
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
152 static void audio_resume() {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
153
13383
c1955840883d mp_msg transition of unmaintained audio output drivers.
ivo
parents: 12145
diff changeset
154 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_ResumeInfo);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
155
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
158 // return: how many bytes can be played without blocking
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
159 static int get_space() {
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 // printf("ao_sgi, get_space: (ao_outburst %d)\n", ao_outburst);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
162 // printf("ao_sgi, get_space: alGetFillable [%d] \n", alGetFillable(ao_port));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
163
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
164 return alGetFillable(ao_port)*(2*ao_data.channels);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
165
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
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 // plays 'len' bytes of 'data'
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
170 // it should round it down to outburst*n
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
171 // return: number of bytes played
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
172 static int play(void* data, int len, int flags) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
173
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
174 // 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
175 // printf("channels %d\n", ao_channels);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
176
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
177 alWriteFrames(ao_port, data, len/(2*ao_data.channels));
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
178
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
179 return len;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
180
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
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
183 // return: delay in seconds between first and last sample in buffer
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
184 static float get_delay(){
2451
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 // printf("ao_sgi, get_delay: (ao_buffersize %d)\n", ao_buffersize);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
187
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
188 //return 0;
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
189 return (float)queue_size/((float)sample_rate);
2451
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
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