comparison libao2/ao_alsa1x.c @ 7050:a5b2b377ab50

changed spdif default from "hw:0,2" to general alias "iec958" based on a patch by Benedikt Hunz <hunz@hunz.org> corrected typo in ugly spdif-warning message added 32/20bit modes for 'high-end'-soundcards disabled hw-mixer-access for big-endian machines (mplayer seems to screw up hw-mixer on LinuxPPC running ALSA needs more testing, but its safer to disable it for now.)
author joyping
date Tue, 20 Aug 2002 14:15:25 +0000
parents 7f619a5d6eb8
children a24f91c247cd
comparison
equal deleted inserted replaced
7049:0caeda287ff9 7050:a5b2b377ab50
138 fprintf(stderr, "Unable to open the control interface '%s': %s\n", ctl_name, snd_strerror(err)); 138 fprintf(stderr, "Unable to open the control interface '%s': %s\n", ctl_name, snd_strerror(err));
139 goto __diga_end; 139 goto __diga_end;
140 } 140 }
141 if ((err = snd_ctl_elem_write(ctl_handler, ctl)) < 0) { 141 if ((err = snd_ctl_elem_write(ctl_handler, ctl)) < 0) {
142 //fprintf(stderr, "Unable to update the IEC958 control: %s\n", snd_strerror(err)); 142 //fprintf(stderr, "Unable to update the IEC958 control: %s\n", snd_strerror(err));
143 printf("alsa-spdif-init: cant set spdif-trough automatically\n"); 143 printf("alsa-spdif-init: cant set spdif-through automatically\n");
144 goto __diga_end; 144 goto __diga_end;
145 } 145 }
146 //test area
147 /* elem_device = snd_ctl_elem_id_get_device(elem_id); */
148 /* elem_name = snd_ctl_elem_value_get_name(ctl); */
149 /* snd_ctl_elem_value_get_iec958(ctl, &spdif); */
150 /* printf("spdif = %i, device = %i\n", &spdif, elem_device); */
151 /* printf("name = %s\n", elem_name); */
152 //end test area
153
154 146
155 snd_ctl_close(ctl_handler); 147 snd_ctl_close(ctl_handler);
156 __diga_end: 148 __diga_end:
157 149
158 } 150 }
209 switch(cmd) { 201 switch(cmd) {
210 case AOCONTROL_QUERY_FORMAT: 202 case AOCONTROL_QUERY_FORMAT:
211 return CONTROL_TRUE; 203 return CONTROL_TRUE;
212 case AOCONTROL_GET_VOLUME: 204 case AOCONTROL_GET_VOLUME:
213 case AOCONTROL_SET_VOLUME: 205 case AOCONTROL_SET_VOLUME:
206 #ifndef WORDS_BIGENDIAN
207 { //seems to be a problem on macs?
214 { 208 {
215 ao_control_vol_t *vol = (ao_control_vol_t *)arg; 209 ao_control_vol_t *vol = (ao_control_vol_t *)arg;
216 210
217 int err; 211 int err;
218 snd_mixer_t *handle; 212 snd_mixer_t *handle;
301 //printf("get_vol = %i, calc=%i\n",get_vol, calc_vol); 295 //printf("get_vol = %i, calc=%i\n",get_vol, calc_vol);
302 } 296 }
303 snd_mixer_close(handle); 297 snd_mixer_close(handle);
304 return CONTROL_OK; 298 return CONTROL_OK;
305 } 299 }
300 }// end big-endian
301 #endif
302 #ifdef WORDS_BIGENDIAN
303 {
304 {
305 return (CONTROL_UNKNOWN);
306 } 306 }
307 }
308 #endif
309
310 } //end witch
307 return(CONTROL_UNKNOWN); 311 return(CONTROL_UNKNOWN);
308 } 312 }
309 313
310 314
311 /* 315 /*
342 ao_data.channels = channels; 346 ao_data.channels = channels;
343 ao_data.outburst = OUTBURST; 347 ao_data.outburst = OUTBURST;
344 //ao_data.buffersize = MAX_OUTBURST; // was 16384 348 //ao_data.buffersize = MAX_OUTBURST; // was 16384
345 349
346 switch (format) 350 switch (format)
347 { 351 {
348 case AFMT_S8: 352 case AFMT_S8:
349 alsa_format = SND_PCM_FORMAT_S8; 353 alsa_format = SND_PCM_FORMAT_S8;
350 break; 354 break;
351 case AFMT_U8: 355 case AFMT_U8:
352 alsa_format = SND_PCM_FORMAT_U8; 356 alsa_format = SND_PCM_FORMAT_U8;
353 break; 357 break;
354 case AFMT_U16_LE: 358 case AFMT_U16_LE:
355 alsa_format = SND_PCM_FORMAT_U16_LE; 359 alsa_format = SND_PCM_FORMAT_U16_LE;
356 break; 360 break;
357 case AFMT_U16_BE: 361 case AFMT_U16_BE:
358 alsa_format = SND_PCM_FORMAT_U16_BE; 362 alsa_format = SND_PCM_FORMAT_U16_BE;
359 break; 363 break;
360 #ifndef WORDS_BIGENDIAN 364 #ifndef WORDS_BIGENDIAN
361 case AFMT_AC3: 365 case AFMT_AC3:
362 #endif 366 #endif
363 case AFMT_S16_LE: 367 case AFMT_S16_LE:
364 alsa_format = SND_PCM_FORMAT_S16_LE; 368 alsa_format = SND_PCM_FORMAT_S16_LE;
365 break; 369 break;
366 #ifdef WORDS_BIGENDIAN 370 #ifdef WORDS_BIGENDIAN
367 case AFMT_AC3: 371 case AFMT_AC3:
368 #endif 372 #endif
369 case AFMT_S16_BE: 373 case AFMT_S16_BE:
370 alsa_format = SND_PCM_FORMAT_S16_BE; 374 alsa_format = SND_PCM_FORMAT_S16_BE;
371 break; 375 break;
372 default: 376 case AFMT_S32_LE:
373 alsa_format = SND_PCM_FORMAT_MPEG; 377 alsa_format = SND_PCM_FORMAT_S32_LE;
374 break; 378 break;
375 } 379 case AFMT_S32_BE:
380 alsa_format = SND_PCM_FORMAT_S32_BE;
381 break;
382
383 default:
384 alsa_format = SND_PCM_FORMAT_MPEG;
385 break;
386 }
376 387
377 switch(alsa_format) 388 switch(alsa_format)
378 { 389 {
379 case SND_PCM_FORMAT_S16_LE: 390 case SND_PCM_FORMAT_S16_LE:
380 case SND_PCM_FORMAT_U16_LE: 391 case SND_PCM_FORMAT_U16_LE:
381 ao_data.bps *= 2; 392 ao_data.bps *= 2;
382 break; 393 break;
383 case -1: 394 case SND_PCM_FORMAT_S32_LE:
384 printf("alsa-init: invalid format (%s) requested - output disabled\n", 395 case SND_PCM_FORMAT_S32_BE:
385 audio_out_format_name(format)); 396 ao_data.bps *= 4;
386 return(0); 397 break;
387 default: 398 case -1:
388 break; 399 printf("alsa-init: invalid format (%s) requested - output disabled\n",
389 } 400 audio_out_format_name(format));
401 return(0);
402 default:
403 break;
404 }
390 405
391 if (ao_subdevice) { 406 if (ao_subdevice) {
392 //start parsing ao_subdevice, ugly and not thread safe! 407 //start parsing ao_subdevice, ugly and not thread safe!
393 //maybe there's a better way? 408 //maybe there's a better way?
394 int i2 = 1; 409 int i2 = 1;
496 // Try to initialize the SPDIF interface 511 // Try to initialize the SPDIF interface
497 if (format == AFMT_AC3) { 512 if (format == AFMT_AC3) {
498 if (device_set) 513 if (device_set)
499 alsa_handler = spdif_init(alsa_device); 514 alsa_handler = spdif_init(alsa_device);
500 else 515 else
501 alsa_handler = spdif_init("hw:0,2"); 516 alsa_handler = spdif_init("iec958");
502 } 517 }
503 518
504 //setting modes for block or nonblock-mode 519 //setting modes for block or nonblock-mode
505 if (ao_noblock) { 520 if (ao_noblock) {
506 open_mode = SND_PCM_NONBLOCK; 521 open_mode = SND_PCM_NONBLOCK;
510 else { 525 else {
511 open_mode = 0; 526 open_mode = 0;
512 set_block_mode = 0; 527 set_block_mode = 0;
513 str_block_mode = "block-mode"; 528 str_block_mode = "block-mode";
514 } 529 }
515 //cvs cosmetics fix 530
516 //sets buff/chunksize if its set manually 531 //sets buff/chunksize if its set manually
517 if (ao_data.buffersize) { 532 if (ao_data.buffersize) {
518 switch (ao_data.buffersize) 533 switch (ao_data.buffersize)
519 { 534 {
520 case 1: 535 case 1: