Mercurial > mplayer.hg
comparison libao2/ao_sdl.c @ 13383:c1955840883d
mp_msg transition of unmaintained audio output drivers.
Patch by Reynaldo H. Verdejo Pinochet <reynaldo at opendot dot cl>
author | ivo |
---|---|
date | Sat, 18 Sep 2004 20:31:28 +0000 |
parents | 7b9b4f07d2c4 |
children | 2f8cfe66dbfd |
comparison
equal
deleted
inserted
replaced
13382:e20fbb99d7f9 | 13383:c1955840883d |
---|---|
14 #include <stdlib.h> | 14 #include <stdlib.h> |
15 #include <string.h> | 15 #include <string.h> |
16 | 16 |
17 #include "../config.h" | 17 #include "../config.h" |
18 #include "../mp_msg.h" | 18 #include "../mp_msg.h" |
19 #include "../help_mp.h" | |
19 | 20 |
20 #include "audio_out.h" | 21 #include "audio_out.h" |
21 #include "audio_out_internal.h" | 22 #include "audio_out_internal.h" |
22 #include "afmt.h" | 23 #include "afmt.h" |
23 #include <SDL.h> | 24 #include <SDL.h> |
169 | 170 |
170 int i; | 171 int i; |
171 /* Allocate ring-buffer memory */ | 172 /* Allocate ring-buffer memory */ |
172 for(i=0;i<NUM_BUFS;i++) buffer[i]=(unsigned char *) malloc(BUFFSIZE); | 173 for(i=0;i<NUM_BUFS;i++) buffer[i]=(unsigned char *) malloc(BUFFSIZE); |
173 | 174 |
174 mp_msg(MSGT_AO,MSGL_INFO,"SDL: Samplerate: %iHz Channels: %s Format %s\n", rate, (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format)); | 175 mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_INFO, rate, (channels > 1) ? "Stereo" : "Mono", audio_out_format_name(format)); |
175 | 176 |
176 if(ao_subdevice) { | 177 if(ao_subdevice) { |
177 setenv("SDL_AUDIODRIVER", ao_subdevice, 1); | 178 setenv("SDL_AUDIODRIVER", ao_subdevice, 1); |
178 mp_msg(MSGT_AO,MSGL_INFO,"SDL: using %s audio driver\n", ao_subdevice); | 179 mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_DriverInfo, ao_subdevice); |
179 } | 180 } |
180 | 181 |
181 ao_data.channels=channels; | 182 ao_data.channels=channels; |
182 ao_data.samplerate=rate; | 183 ao_data.samplerate=rate; |
183 ao_data.format=format; | 184 ao_data.format=format; |
207 aspec.format = AUDIO_U16MSB; | 208 aspec.format = AUDIO_U16MSB; |
208 break; | 209 break; |
209 default: | 210 default: |
210 aspec.format = AUDIO_S16LSB; | 211 aspec.format = AUDIO_S16LSB; |
211 ao_data.format = AFMT_S16_LE; | 212 ao_data.format = AFMT_S16_LE; |
212 mp_msg(MSGT_AO,MSGL_WARN,"SDL: Unsupported audio format: 0x%x.\n", format); | 213 mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_SDL_UnsupportedAudioFmt, format); |
213 } | 214 } |
214 | 215 |
215 /* The desired audio frequency in samples-per-second. */ | 216 /* The desired audio frequency in samples-per-second. */ |
216 aspec.freq = rate; | 217 aspec.freq = rate; |
217 | 218 |
228 /* This pointer is passed as the first parameter to the callback function. */ | 229 /* This pointer is passed as the first parameter to the callback function. */ |
229 aspec.userdata = NULL; | 230 aspec.userdata = NULL; |
230 | 231 |
231 /* initialize the SDL Audio system */ | 232 /* initialize the SDL Audio system */ |
232 if (SDL_Init (SDL_INIT_AUDIO/*|SDL_INIT_NOPARACHUTE*/)) { | 233 if (SDL_Init (SDL_INIT_AUDIO/*|SDL_INIT_NOPARACHUTE*/)) { |
233 mp_msg(MSGT_AO,MSGL_ERR,"SDL: Initializing of SDL Audio failed: %s.\n", SDL_GetError()); | 234 mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_SDL_CantInit, SDL_GetError()); |
234 return 0; | 235 return 0; |
235 } | 236 } |
236 | 237 |
237 /* Open the audio device and start playing sound! */ | 238 /* Open the audio device and start playing sound! */ |
238 if(SDL_OpenAudio(&aspec, &obtained) < 0) { | 239 if(SDL_OpenAudio(&aspec, &obtained) < 0) { |
239 mp_msg(MSGT_AO,MSGL_ERR,"SDL: Unable to open audio: %s\n", SDL_GetError()); | 240 mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_SDL_CantOpenAudio, SDL_GetError()); |
240 return(0); | 241 return(0); |
241 } | 242 } |
242 | 243 |
243 /* did we got what we wanted ? */ | 244 /* did we got what we wanted ? */ |
244 ao_data.channels=obtained.channels; | 245 ao_data.channels=obtained.channels; |
262 break; | 263 break; |
263 case AUDIO_U16MSB : | 264 case AUDIO_U16MSB : |
264 ao_data.format = AFMT_U16_BE; | 265 ao_data.format = AFMT_U16_BE; |
265 break; | 266 break; |
266 default: | 267 default: |
267 mp_msg(MSGT_AO,MSGL_WARN,"SDL: Unsupported SDL audio format: 0x%x.\n", obtained.format); | 268 mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_SDL_UnsupportedAudioFmt, obtained.format); |
268 return 0; | 269 return 0; |
269 } | 270 } |
270 | 271 |
271 mp_msg(MSGT_AO,MSGL_V,"SDL: buf size = %d\n",obtained.size); | 272 mp_msg(MSGT_AO,MSGL_V,"SDL: buf size = %d\n",obtained.size); |
272 ao_data.buffersize=obtained.size; | 273 ao_data.buffersize=obtained.size; |