Mercurial > mplayer.hg
annotate libao2/ao_sdl.c @ 12078:62705b2298ff
svgalib 1.9.18 compile fix, still wont work for me though...
author | atmos4 |
---|---|
date | Sun, 28 Mar 2004 16:30:08 +0000 |
parents | 210e474436d3 |
children | f54d02f6ddbf |
rev | line source |
---|---|
972 | 1 /* |
2 * ao_sdl.c - libao2 SDLlib Audio Output Driver for MPlayer | |
3 * | |
4 * This driver is under the same license as MPlayer. | |
11750 | 5 * (http://www.mplayerhq.hu) |
972 | 6 * |
7 * Copyleft 2001 by Felix Bünemann (atmosfear@users.sf.net) | |
8 * | |
9 * Thanks to Arpi for nice ringbuffer-code! | |
10 * | |
11 */ | |
12 | |
966 | 13 #include <stdio.h> |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
14 #include <stdlib.h> |
966 | 15 |
8027 | 16 #include "../config.h" |
17 #include "../mp_msg.h" | |
18 | |
966 | 19 #include "audio_out.h" |
20 #include "audio_out_internal.h" | |
1066 | 21 #include "afmt.h" |
6184 | 22 #include <SDL.h> |
966 | 23 |
972 | 24 #include "../libvo/fastmemcpy.h" |
25 | |
966 | 26 static ao_info_t info = |
27 { | |
28 "SDLlib audio output", | |
29 "sdl", | |
30 "Felix Buenemann <atmosfear@users.sourceforge.net>", | |
31 "" | |
32 }; | |
33 | |
34 LIBAO_EXTERN(sdl) | |
35 | |
972 | 36 // Samplesize used by the SDLlib AudioSpec struct |
12019
6ede5366bc47
fix compilation with sdl on mingw patch by Nehal <nehalmistry at gmx.net>
faust3
parents:
11750
diff
changeset
|
37 #ifdef WIN32 |
6ede5366bc47
fix compilation with sdl on mingw patch by Nehal <nehalmistry at gmx.net>
faust3
parents:
11750
diff
changeset
|
38 #define SAMPLESIZE 2048 |
6ede5366bc47
fix compilation with sdl on mingw patch by Nehal <nehalmistry at gmx.net>
faust3
parents:
11750
diff
changeset
|
39 #else |
993
dfa641c44d4a
Increased sample size to solve sound problems one some systems.
atmosfear
parents:
985
diff
changeset
|
40 #define SAMPLESIZE 1024 |
12019
6ede5366bc47
fix compilation with sdl on mingw patch by Nehal <nehalmistry at gmx.net>
faust3
parents:
11750
diff
changeset
|
41 #endif |
972 | 42 |
43 // General purpose Ring-buffering routines | |
44 | |
974 | 45 #define BUFFSIZE 4096 |
1066 | 46 #define NUM_BUFS 16 |
972 | 47 |
48 static unsigned char *buffer[NUM_BUFS]; | |
49 | |
50 static unsigned int buf_read=0; | |
51 static unsigned int buf_write=0; | |
52 static unsigned int buf_read_pos=0; | |
53 static unsigned int buf_write_pos=0; | |
6184 | 54 static unsigned int volume=127; |
972 | 55 static int full_buffers=0; |
56 static int buffered_bytes=0; | |
57 | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
58 |
972 | 59 static int write_buffer(unsigned char* data,int len){ |
60 int len2=0; | |
61 int x; | |
62 while(len>0){ | |
63 if(full_buffers==NUM_BUFS) break; | |
64 x=BUFFSIZE-buf_write_pos; | |
65 if(x>len) x=len; | |
66 memcpy(buffer[buf_write]+buf_write_pos,data+len2,x); | |
67 len2+=x; len-=x; | |
68 buffered_bytes+=x; buf_write_pos+=x; | |
69 if(buf_write_pos>=BUFFSIZE){ | |
70 // block is full, find next! | |
71 buf_write=(buf_write+1)%NUM_BUFS; | |
72 ++full_buffers; | |
73 buf_write_pos=0; | |
74 } | |
75 } | |
76 return len2; | |
77 } | |
78 | |
79 static int read_buffer(unsigned char* data,int len){ | |
80 int len2=0; | |
81 int x; | |
82 while(len>0){ | |
83 if(full_buffers==0) break; // no more data buffered! | |
84 x=BUFFSIZE-buf_read_pos; | |
85 if(x>len) x=len; | |
86 memcpy(data+len2,buffer[buf_read]+buf_read_pos,x); | |
6184 | 87 SDL_MixAudio(data+len2, data+len2, x, volume); |
972 | 88 len2+=x; len-=x; |
89 buffered_bytes-=x; buf_read_pos+=x; | |
90 if(buf_read_pos>=BUFFSIZE){ | |
91 // block is empty, find next! | |
92 buf_read=(buf_read+1)%NUM_BUFS; | |
93 --full_buffers; | |
94 buf_read_pos=0; | |
95 } | |
96 } | |
97 return len2; | |
98 } | |
99 | |
100 // end ring buffer stuff | |
966 | 101 |
12027
210e474436d3
Cygwin provides setenv. Fixes compilation on Cygwin.
diego
parents:
12019
diff
changeset
|
102 #if defined(__MINGW32__) || defined(HPUX) || defined(sgi) || (defined(sun) && defined(__svr4__)) |
12019
6ede5366bc47
fix compilation with sdl on mingw patch by Nehal <nehalmistry at gmx.net>
faust3
parents:
11750
diff
changeset
|
103 /* setenv is missing on win32, solaris, IRIX and HPUX */ |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
104 static void setenv(const char *name, const char *val, int _xx) |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
105 { |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
106 int len = strlen(name) + strlen(val) + 2; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
107 char *env = malloc(len); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
108 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
109 if (env != NULL) { |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
110 strcpy(env, name); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
111 strcat(env, "="); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
112 strcat(env, val); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
113 putenv(env); |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
114 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
115 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
116 #endif |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
117 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
118 |
966 | 119 // to set/get/query special features/parameters |
9633
12b1790038b0
64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents:
8027
diff
changeset
|
120 static int control(int cmd,void *arg){ |
6184 | 121 switch (cmd) { |
122 case AOCONTROL_GET_VOLUME: | |
123 { | |
124 ao_control_vol_t* vol = (ao_control_vol_t*)arg; | |
125 vol->left = vol->right = (float)((volume + 127)/2.55); | |
126 return CONTROL_OK; | |
127 } | |
128 case AOCONTROL_SET_VOLUME: | |
129 { | |
130 float diff; | |
131 ao_control_vol_t* vol = (ao_control_vol_t*)arg; | |
132 diff = (vol->left+vol->right) / 2; | |
133 volume = (int)(diff * 2.55) - 127; | |
134 return CONTROL_OK; | |
135 } | |
136 } | |
137 return -1; | |
966 | 138 } |
139 | |
972 | 140 // SDL Callback function |
141 void outputaudio(void *unused, Uint8 *stream, int len) { | |
142 //SDL_MixAudio(stream, read_buffer(buffers, len), len, SDL_MIX_MAXVOLUME); | |
1066 | 143 //if(!full_buffers) printf("SDL: Buffer underrun!\n"); |
144 | |
972 | 145 read_buffer(stream, len); |
1066 | 146 //printf("SDL: Full Buffers: %i\n", full_buffers); |
966 | 147 } |
148 | |
149 // open & setup audio device | |
150 // return: 1=success 0=fail | |
151 static int init(int rate,int channels,int format,int flags){ | |
152 | |
972 | 153 /* SDL Audio Specifications */ |
7908
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
154 SDL_AudioSpec aspec, obtained; |
972 | 155 |
156 int i; | |
157 /* Allocate ring-buffer memory */ | |
983 | 158 for(i=0;i<NUM_BUFS;i++) buffer[i]=(unsigned char *) malloc(BUFFSIZE); |
972 | 159 |
8027 | 160 mp_msg(MSGT_AO,MSGL_INFO,"SDL: Samplerate: %iHz Channels: %s Format %s\n", rate, (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format)); |
983 | 161 |
1189 | 162 if(ao_subdevice) { |
163 setenv("SDL_AUDIODRIVER", ao_subdevice, 1); | |
8027 | 164 mp_msg(MSGT_AO,MSGL_INFO,"SDL: using %s audio driver\n", ao_subdevice); |
1189 | 165 } |
3095 | 166 |
7660 | 167 ao_data.channels=channels; |
168 ao_data.samplerate=rate; | |
169 ao_data.format=format; | |
170 | |
3137 | 171 ao_data.bps=channels*rate; |
3095 | 172 if(format != AFMT_U8 && format != AFMT_S8) |
173 ao_data.bps*=2; | |
966 | 174 |
1066 | 175 /* The desired audio format (see SDL_AudioSpec) */ |
176 switch(format) { | |
177 case AFMT_U8: | |
178 aspec.format = AUDIO_U8; | |
179 break; | |
180 case AFMT_S16_LE: | |
181 aspec.format = AUDIO_S16LSB; | |
182 break; | |
183 case AFMT_S16_BE: | |
184 aspec.format = AUDIO_S16MSB; | |
185 break; | |
186 case AFMT_S8: | |
187 aspec.format = AUDIO_S8; | |
188 break; | |
189 case AFMT_U16_LE: | |
190 aspec.format = AUDIO_U16LSB; | |
191 break; | |
192 case AFMT_U16_BE: | |
193 aspec.format = AUDIO_U16MSB; | |
194 break; | |
195 default: | |
8027 | 196 mp_msg(MSGT_AO,MSGL_WARN,"SDL: Unsupported audio format: 0x%x.\n", format); |
1066 | 197 return 0; |
198 } | |
199 | |
966 | 200 /* The desired audio frequency in samples-per-second. */ |
201 aspec.freq = rate; | |
202 | |
203 /* Number of channels (mono/stereo) */ | |
204 aspec.channels = channels; | |
205 | |
206 /* The desired size of the audio buffer in samples. This number should be a power of two, and may be adjusted by the audio driver to a value more suitable for the hardware. Good values seem to range between 512 and 8192 inclusive, depending on the application and CPU speed. Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio buffer in time. A stereo sample consists of both right and left channels in LR ordering. Note that the number of samples is directly related to time by the following formula: ms = (samples*1000)/freq */ | |
972 | 207 aspec.samples = SAMPLESIZE; |
966 | 208 |
209 /* This should be set to a function that will be called when the audio device is ready for more data. It is passed a pointer to the audio buffer, and the length in bytes of the audio buffer. This function usually runs in a separate thread, and so you should protect data structures that it accesses by calling SDL_LockAudio and SDL_UnlockAudio in your code. The callback prototype is: | |
210 void callback(void *userdata, Uint8 *stream, int len); userdata is the pointer stored in userdata field of the SDL_AudioSpec. stream is a pointer to the audio buffer you want to fill with information and len is the length of the audio buffer in bytes. */ | |
972 | 211 aspec.callback = outputaudio; |
966 | 212 |
213 /* This pointer is passed as the first parameter to the callback function. */ | |
214 aspec.userdata = NULL; | |
215 | |
972 | 216 /* initialize the SDL Audio system */ |
217 if (SDL_Init (SDL_INIT_AUDIO/*|SDL_INIT_NOPARACHUTE*/)) { | |
8027 | 218 mp_msg(MSGT_AO,MSGL_ERR,"SDL: Initializing of SDL Audio failed: %s.\n", SDL_GetError()); |
972 | 219 return 0; |
220 } | |
221 | |
966 | 222 /* Open the audio device and start playing sound! */ |
7908
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
223 if(SDL_OpenAudio(&aspec, &obtained) < 0) { |
8027 | 224 mp_msg(MSGT_AO,MSGL_ERR,"SDL: Unable to open audio: %s\n", SDL_GetError()); |
966 | 225 return(0); |
226 } | |
7908
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
227 |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
228 /* did we got what we wanted ? */ |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
229 ao_data.channels=obtained.channels; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
230 ao_data.samplerate=obtained.freq; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
231 |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
232 switch(obtained.format) { |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
233 case AUDIO_U8 : |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
234 ao_data.format = AFMT_U8; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
235 break; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
236 case AUDIO_S16LSB : |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
237 ao_data.format = AFMT_S16_LE; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
238 break; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
239 case AUDIO_S16MSB : |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
240 ao_data.format = AFMT_S16_BE; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
241 break; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
242 case AUDIO_S8 : |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
243 ao_data.format = AFMT_S8; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
244 break; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
245 case AUDIO_U16LSB : |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
246 ao_data.format = AFMT_U16_LE; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
247 break; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
248 case AUDIO_U16MSB : |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
249 ao_data.format = AFMT_U16_BE; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
250 break; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
251 default: |
8027 | 252 mp_msg(MSGT_AO,MSGL_WARN,"SDL: Unsupported SDL audio format: 0x%x.\n", obtained.format); |
7908
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
253 return 0; |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
254 } |
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
255 |
8027 | 256 mp_msg(MSGT_AO,MSGL_V,"SDL: buf size = %d\n",obtained.size); |
7908
dc96a3eb9fab
Check what we obtain in SDL_OpenAudio() - allows to build the
colin
parents:
7897
diff
changeset
|
257 ao_data.buffersize=obtained.size; |
974 | 258 |
966 | 259 /* unsilence audio, if callback is ready */ |
260 SDL_PauseAudio(0); | |
261 | |
262 return 1; | |
263 } | |
264 | |
265 // close audio device | |
266 static void uninit(){ | |
8027 | 267 mp_msg(MSGT_AO,MSGL_V,"SDL: Audio Subsystem shutting down!\n"); |
966 | 268 SDL_CloseAudio(); |
972 | 269 SDL_QuitSubSystem(SDL_INIT_AUDIO); |
966 | 270 } |
271 | |
272 // stop playing and empty buffers (for seeking/pause) | |
273 static void reset(){ | |
1066 | 274 |
1091 | 275 //printf("SDL: reset called!\n"); |
1066 | 276 |
972 | 277 /* Reset ring-buffer state */ |
278 buf_read=0; | |
279 buf_write=0; | |
280 buf_read_pos=0; | |
281 buf_write_pos=0; | |
282 | |
283 full_buffers=0; | |
284 buffered_bytes=0; | |
966 | 285 |
286 } | |
287 | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
288 // stop playing, keep buffers (for pause) |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
289 static void audio_pause() |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
290 { |
1070 | 291 |
1091 | 292 //printf("SDL: audio_pause called!\n"); |
7897
7674e94baff7
Change SDL_(Un)lockAudio to PauseAudio() (works better)
colin
parents:
7660
diff
changeset
|
293 SDL_PauseAudio(1); |
1070 | 294 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
295 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
296 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
297 // resume playing, after audio_pause() |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
298 static void audio_resume() |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
299 { |
1091 | 300 //printf("SDL: audio_resume called!\n"); |
7897
7674e94baff7
Change SDL_(Un)lockAudio to PauseAudio() (works better)
colin
parents:
7660
diff
changeset
|
301 SDL_PauseAudio(0); |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
302 } |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
303 |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
993
diff
changeset
|
304 |
966 | 305 // return: how many bytes can be played without blocking |
306 static int get_space(){ | |
972 | 307 return (NUM_BUFS-full_buffers)*BUFFSIZE - buf_write_pos; |
966 | 308 } |
309 | |
310 // plays 'len' bytes of 'data' | |
311 // it should round it down to outburst*n | |
312 // return: number of bytes played | |
313 static int play(void* data,int len,int flags){ | |
972 | 314 |
985 | 315 #if 0 |
972 | 316 int ret; |
966 | 317 |
972 | 318 /* Audio locking prohibits call of outputaudio */ |
966 | 319 SDL_LockAudio(); |
972 | 320 // copy audio stream into ring-buffer |
321 ret = write_buffer(data, len); | |
966 | 322 SDL_UnlockAudio(); |
323 | |
972 | 324 return ret; |
325 #else | |
326 return write_buffer(data, len); | |
327 #endif | |
966 | 328 } |
329 | |
3095 | 330 // return: delay in seconds between first and last sample in buffer |
331 static float get_delay(){ | |
332 return (float)(buffered_bytes + ao_data.buffersize)/(float)ao_data.bps; | |
966 | 333 } |
334 | |
335 | |
336 | |
337 | |
338 | |
339 |