annotate libao2/ao_sgi.c @ 12334:eeddcef4fb08

"hard" frame duplication for mencoder. this finally makes it possible to generate valid mpeg output from avi's that have duplicate frames in them, or when using inverse telecine filters. to use it, put the "harddup" filter at the end of your filter chain.
author rfelker
date Wed, 28 Apr 2004 04:02:46 +0000
parents 99798c3cdb93
children c1955840883d
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
26 static ALconfig ao_config;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
27 static ALport ao_port;
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
28 static int sample_rate;
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
29 static int queue_size;
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
30
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
31 // to set/get/query special features/parameters
9633
12b1790038b0 64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents: 3095
diff changeset
32 static int control(int cmd, void *arg){
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
33
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
34 printf("ao_sgi, control\n");
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 return -1;
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
39 // open & setup audio device
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
40 // return: 1=success 0=fail
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
41 static int init(int rate, int channels, int format, int flags) {
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 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
44
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
45 { /* from /usr/share/src/dmedia/audio/setrate.c */
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 int fd;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
48 int rv;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
49 double frate;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
50 ALpv x[2];
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 rv = alGetResourceByName(AL_SYSTEM, "out.analog", AL_DEVICE_TYPE);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
53 if (!rv) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
54 printf("ao_sgi, play: invalid device\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
55 return 0;
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
58 frate = rate;
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
59
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
60 x[0].param = AL_RATE;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
61 x[0].value.ll = alDoubleToFixed(rate);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
62 x[1].param = AL_MASTER_CLOCK;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
63 x[1].value.i = AL_CRYSTAL_MCLK_TYPE;
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 if (alSetParams(rv,x, 2)<0) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
66 printf("ao_sgi, init: setparams failed: %s\n", alGetErrorString(oserror()));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
67 printf("ao_sgi, init: could not set desired samplerate\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
68 }
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 (x[0].sizeOut < 0) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
71 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
72 }
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 if (alGetParams(rv,x, 1)<0) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
75 printf("ao_sgi, init: getparams failed: %s\n", alGetErrorString(oserror()));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
76 }
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 if (frate != alFixedToDouble(x[0].value.ll)) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
79 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
80 }
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
81 sample_rate = (int)frate;
2451
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
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
84 ao_data.buffersize=131072;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
85 ao_data.outburst = ao_data.buffersize/16;
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
86 ao_data.channels = channels;
2451
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 ao_config = alNewConfig();
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
89
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
90 if (!ao_config) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
91 printf("ao_sgi, init: %s\n", alGetErrorString(oserror()));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
92 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
93 }
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(channels == 2) alSetChannels(ao_config, AL_STEREO);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
96 else alSetChannels(ao_config, AL_MONO);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
97
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
98 alSetWidth(ao_config, AL_SAMPLE_16);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
99 alSetSampFmt(ao_config, AL_SAMPFMT_TWOSCOMP);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
100 alSetQueueSize(ao_config, 48000);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
101
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
102 if (alSetDevice(ao_config, AL_DEFAULT_OUTPUT) < 0) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
103 printf("ao_sgi, init: %s\n", alGetErrorString(oserror()));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
104 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
105 }
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 ao_port = alOpenPort("mplayer", "w", ao_config);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
108
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
109 if (!ao_port) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
110 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
111 return 0;
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
112 }
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 // 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
115 queue_size = alGetQueueSize(ao_config);
2451
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
116 return 1;
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
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
120 // close audio device
12145
99798c3cdb93 uninit immed flag
alex
parents: 11323
diff changeset
121 static void uninit(int immed) {
2451
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 /* 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
124
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
125 printf("ao_sgi, uninit: ...\n");
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
126
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
127 if (ao_port) {
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
128 while(alGetFilled(ao_port) > 0) sginap(1);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
129 alClosePort(ao_port);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
130 alFreeConfig(ao_config);
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
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 // stop playing and empty buffers (for seeking/pause)
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
136 static void reset() {
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 printf("ao_sgi, reset: ...\n");
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 }
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 // stop playing, keep buffers (for pause)
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
143 static void audio_pause() {
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 printf("ao_sgi, audio_pause: ...\n");
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 }
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 // resume playing, after audio_pause()
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
150 static void audio_resume() {
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 printf("ao_sgi, audio_resume: ...\n");
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 }
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 // return: how many bytes can be played without blocking
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
157 static int get_space() {
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 // printf("ao_sgi, get_space: (ao_outburst %d)\n", ao_outburst);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
160 // printf("ao_sgi, get_space: alGetFillable [%d] \n", alGetFillable(ao_port));
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
161
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
162 return alGetFillable(ao_port)*(2*ao_data.channels);
2451
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 }
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 // plays 'len' bytes of 'data'
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
168 // it should round it down to outburst*n
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
169 // return: number of bytes played
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
170 static int play(void* data, int len, int flags) {
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 // 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
173 // printf("channels %d\n", ao_channels);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
174
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
175 alWriteFrames(ao_port, data, len/(2*ao_data.channels));
2451
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 return len;
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 }
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
180
3095
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
181 // return: delay in seconds between first and last sample in buffer
981a9e5118ce interface to libao2 changed ao_plugin added
anders
parents: 2451
diff changeset
182 static float get_delay(){
2451
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 // printf("ao_sgi, get_delay: (ao_buffersize %d)\n", ao_buffersize);
a56bf9c0e76f SGI audio driver by oliver.schoenbrunner@jku.at
arpi
parents:
diff changeset
185
11323
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
186 //return 0;
c6758363a238 A-V sync fix by Timo Kanera <timo@kanera.de>.
diego
parents: 9633
diff changeset
187 return (float)queue_size/((float)sample_rate);
2451
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
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