Mercurial > mplayer.hg
comparison libao2/ao_sdl.c @ 29263:0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
author | diego |
---|---|
date | Wed, 13 May 2009 02:58:57 +0000 |
parents | f951680cfea2 |
children | 02dec439f717 |
comparison
equal
deleted
inserted
replaced
29262:7d545a6b8aff | 29263:0f1b5b68af32 |
---|---|
34 #include <SDL.h> | 34 #include <SDL.h> |
35 #include "osdep/timer.h" | 35 #include "osdep/timer.h" |
36 | 36 |
37 #include "libavutil/fifo.h" | 37 #include "libavutil/fifo.h" |
38 | 38 |
39 static const ao_info_t info = | 39 static const ao_info_t info = |
40 { | 40 { |
41 "SDLlib audio output", | 41 "SDLlib audio output", |
42 "sdl", | 42 "sdl", |
43 "Felix Buenemann <atmosfear@users.sourceforge.net>", | 43 "Felix Buenemann <atmosfear@users.sourceforge.net>", |
44 "" | 44 "" |
127 // return: 1=success 0=fail | 127 // return: 1=success 0=fail |
128 static int init(int rate,int channels,int format,int flags){ | 128 static int init(int rate,int channels,int format,int flags){ |
129 | 129 |
130 /* SDL Audio Specifications */ | 130 /* SDL Audio Specifications */ |
131 SDL_AudioSpec aspec, obtained; | 131 SDL_AudioSpec aspec, obtained; |
132 | 132 |
133 /* Allocate ring-buffer memory */ | 133 /* Allocate ring-buffer memory */ |
134 buffer = av_fifo_alloc(BUFFSIZE); | 134 buffer = av_fifo_alloc(BUFFSIZE); |
135 | 135 |
136 mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_INFO, rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format)); | 136 mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_INFO, rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format)); |
137 | 137 |
145 ao_data.format=format; | 145 ao_data.format=format; |
146 | 146 |
147 ao_data.bps=channels*rate; | 147 ao_data.bps=channels*rate; |
148 if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8) | 148 if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8) |
149 ao_data.bps*=2; | 149 ao_data.bps*=2; |
150 | 150 |
151 /* The desired audio format (see SDL_AudioSpec) */ | 151 /* The desired audio format (see SDL_AudioSpec) */ |
152 switch(format) { | 152 switch(format) { |
153 case AF_FORMAT_U8: | 153 case AF_FORMAT_U8: |
154 aspec.format = AUDIO_U8; | 154 aspec.format = AUDIO_U8; |
155 break; | 155 break; |
198 | 198 |
199 /* Open the audio device and start playing sound! */ | 199 /* Open the audio device and start playing sound! */ |
200 if(SDL_OpenAudio(&aspec, &obtained) < 0) { | 200 if(SDL_OpenAudio(&aspec, &obtained) < 0) { |
201 mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_SDL_CantOpenAudio, SDL_GetError()); | 201 mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_SDL_CantOpenAudio, SDL_GetError()); |
202 return 0; | 202 return 0; |
203 } | 203 } |
204 | 204 |
205 /* did we got what we wanted ? */ | 205 /* did we got what we wanted ? */ |
206 ao_data.channels=obtained.channels; | 206 ao_data.channels=obtained.channels; |
207 ao_data.samplerate=obtained.freq; | 207 ao_data.samplerate=obtained.freq; |
208 | 208 |
231 } | 231 } |
232 | 232 |
233 mp_msg(MSGT_AO,MSGL_V,"SDL: buf size = %d\n",obtained.size); | 233 mp_msg(MSGT_AO,MSGL_V,"SDL: buf size = %d\n",obtained.size); |
234 ao_data.buffersize=obtained.size; | 234 ao_data.buffersize=obtained.size; |
235 ao_data.outburst = CHUNK_SIZE; | 235 ao_data.outburst = CHUNK_SIZE; |
236 | 236 |
237 /* unsilence audio, if callback is ready */ | 237 /* unsilence audio, if callback is ready */ |
238 SDL_PauseAudio(0); | 238 SDL_PauseAudio(0); |
239 | 239 |
240 return 1; | 240 return 1; |
241 } | 241 } |
251 } | 251 } |
252 | 252 |
253 // stop playing and empty buffers (for seeking/pause) | 253 // stop playing and empty buffers (for seeking/pause) |
254 static void reset(void){ | 254 static void reset(void){ |
255 | 255 |
256 //printf("SDL: reset called!\n"); | 256 //printf("SDL: reset called!\n"); |
257 | 257 |
258 SDL_PauseAudio(1); | 258 SDL_PauseAudio(1); |
259 /* Reset ring-buffer state */ | 259 /* Reset ring-buffer state */ |
260 av_fifo_reset(buffer); | 260 av_fifo_reset(buffer); |
261 SDL_PauseAudio(0); | 261 SDL_PauseAudio(0); |
263 | 263 |
264 // stop playing, keep buffers (for pause) | 264 // stop playing, keep buffers (for pause) |
265 static void audio_pause(void) | 265 static void audio_pause(void) |
266 { | 266 { |
267 | 267 |
268 //printf("SDL: audio_pause called!\n"); | 268 //printf("SDL: audio_pause called!\n"); |
269 SDL_PauseAudio(1); | 269 SDL_PauseAudio(1); |
270 | 270 |
271 } | 271 } |
272 | 272 |
273 // resume playing, after audio_pause() | 273 // resume playing, after audio_pause() |
274 static void audio_resume(void) | 274 static void audio_resume(void) |
275 { | 275 { |
276 //printf("SDL: audio_resume called!\n"); | 276 //printf("SDL: audio_resume called!\n"); |
277 SDL_PauseAudio(0); | 277 SDL_PauseAudio(0); |
278 } | 278 } |
279 | 279 |
280 | 280 |
281 // return: how many bytes can be played without blocking | 281 // return: how many bytes can be played without blocking |
288 // return: number of bytes played | 288 // return: number of bytes played |
289 static int play(void* data,int len,int flags){ | 289 static int play(void* data,int len,int flags){ |
290 | 290 |
291 if (!(flags & AOPLAY_FINAL_CHUNK)) | 291 if (!(flags & AOPLAY_FINAL_CHUNK)) |
292 len = (len/ao_data.outburst)*ao_data.outburst; | 292 len = (len/ao_data.outburst)*ao_data.outburst; |
293 #if 0 | 293 #if 0 |
294 int ret; | 294 int ret; |
295 | 295 |
296 /* Audio locking prohibits call of outputaudio */ | 296 /* Audio locking prohibits call of outputaudio */ |
297 SDL_LockAudio(); | 297 SDL_LockAudio(); |
298 // copy audio stream into ring-buffer | 298 // copy audio stream into ring-buffer |
299 ret = write_buffer(data, len); | 299 ret = write_buffer(data, len); |
300 SDL_UnlockAudio(); | 300 SDL_UnlockAudio(); |
301 | 301 |
302 return ret; | 302 return ret; |
303 #else | 303 #else |