Mercurial > mplayer.hg
comparison libao2/ao_alsa1x.c @ 8027:b9da278e4c92
verbose can be negative
author | arpi |
---|---|
date | Fri, 01 Nov 2002 17:46:45 +0000 |
parents | dda97c5190d7 |
children | de379e6d6ca9 |
comparison
equal
deleted
inserted
replaced
8026:b465ba5897a3 | 8027:b9da278e4c92 |
---|---|
210 printf("alsa-init: requested format: %d Hz, %d channels, %s\n", rate_hz, | 210 printf("alsa-init: requested format: %d Hz, %d channels, %s\n", rate_hz, |
211 channels, audio_out_format_name(format)); | 211 channels, audio_out_format_name(format)); |
212 | 212 |
213 alsa_handler = NULL; | 213 alsa_handler = NULL; |
214 | 214 |
215 if (verbose) | 215 if (verbose>0) |
216 printf("alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); | 216 printf("alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR); |
217 | 217 |
218 if ((err = snd_card_next(&cards)) < 0 || cards < 0) | 218 if ((err = snd_card_next(&cards)) < 0 || cards < 0) |
219 { | 219 { |
220 printf("alsa-init: no soundcards found: %s\n", snd_strerror(err)); | 220 printf("alsa-init: no soundcards found: %s\n", snd_strerror(err)); |
355 s[3] = IEC958_AES3_CON_FS_48000; | 355 s[3] = IEC958_AES3_CON_FS_48000; |
356 | 356 |
357 sprintf(devstr, "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", | 357 sprintf(devstr, "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", |
358 s[0], s[1], s[2], s[3]); | 358 s[0], s[1], s[2], s[3]); |
359 | 359 |
360 if (verbose) | 360 if (verbose>0) |
361 printf("alsa-spdif-init: playing AC3, %i channels\n", channels); | 361 printf("alsa-spdif-init: playing AC3, %i channels\n", channels); |
362 break; | 362 break; |
363 case 4: | 363 case 4: |
364 strcpy(devstr, "surround40"); | 364 strcpy(devstr, "surround40"); |
365 break; | 365 break; |
402 { | 402 { |
403 printf("alsa-init: cant get subdevice\n"); | 403 printf("alsa-init: cant get subdevice\n"); |
404 return(0); | 404 return(0); |
405 } | 405 } |
406 | 406 |
407 if (verbose) | 407 if (verbose>0) |
408 printf("alsa-init: got device=%i, subdevice=%i\n", tmp_device, tmp_subdevice); | 408 printf("alsa-init: got device=%i, subdevice=%i\n", tmp_device, tmp_subdevice); |
409 | 409 |
410 if ((err = snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%1d,%1d", tmp_device, tmp_subdevice)) <= 0) | 410 if ((err = snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%1d,%1d", tmp_device, tmp_subdevice)) <= 0) |
411 { | 411 { |
412 printf("alsa-init: cant wrote device-id\n"); | 412 printf("alsa-init: cant wrote device-id\n"); |
444 switch (ao_data.buffersize) | 444 switch (ao_data.buffersize) |
445 { | 445 { |
446 case 1: | 446 case 1: |
447 alsa_fragcount = 16; | 447 alsa_fragcount = 16; |
448 chunk_size = 512; | 448 chunk_size = 512; |
449 if (verbose) { | 449 if (verbose>0) { |
450 printf("alsa-init: buffersize set manually to 8192\n"); | 450 printf("alsa-init: buffersize set manually to 8192\n"); |
451 printf("alsa-init: chunksize set manually to 512\n"); | 451 printf("alsa-init: chunksize set manually to 512\n"); |
452 } | 452 } |
453 break; | 453 break; |
454 case 2: | 454 case 2: |
455 alsa_fragcount = 8; | 455 alsa_fragcount = 8; |
456 chunk_size = 1024; | 456 chunk_size = 1024; |
457 if (verbose) { | 457 if (verbose>0) { |
458 printf("alsa-init: buffersize set manually to 8192\n"); | 458 printf("alsa-init: buffersize set manually to 8192\n"); |
459 printf("alsa-init: chunksize set manually to 1024\n"); | 459 printf("alsa-init: chunksize set manually to 1024\n"); |
460 } | 460 } |
461 break; | 461 break; |
462 case 3: | 462 case 3: |
463 alsa_fragcount = 32; | 463 alsa_fragcount = 32; |
464 chunk_size = 512; | 464 chunk_size = 512; |
465 if (verbose) { | 465 if (verbose>0) { |
466 printf("alsa-init: buffersize set manually to 16384\n"); | 466 printf("alsa-init: buffersize set manually to 16384\n"); |
467 printf("alsa-init: chunksize set manually to 512\n"); | 467 printf("alsa-init: chunksize set manually to 512\n"); |
468 } | 468 } |
469 break; | 469 break; |
470 case 4: | 470 case 4: |
471 alsa_fragcount = 16; | 471 alsa_fragcount = 16; |
472 chunk_size = 1024; | 472 chunk_size = 1024; |
473 if (verbose) { | 473 if (verbose>0) { |
474 printf("alsa-init: buffersize set manually to 16384\n"); | 474 printf("alsa-init: buffersize set manually to 16384\n"); |
475 printf("alsa-init: chunksize set manually to 1024\n"); | 475 printf("alsa-init: chunksize set manually to 1024\n"); |
476 } | 476 } |
477 break; | 477 break; |
478 default: | 478 default: |
505 } | 505 } |
506 | 506 |
507 if ((err = snd_pcm_nonblock(alsa_handler, set_block_mode)) < 0) { | 507 if ((err = snd_pcm_nonblock(alsa_handler, set_block_mode)) < 0) { |
508 printf("alsa-init: error set block-mode %s\n", snd_strerror(err)); | 508 printf("alsa-init: error set block-mode %s\n", snd_strerror(err)); |
509 } | 509 } |
510 else if (verbose) { | 510 else if (verbose>0) { |
511 printf("alsa-init: pcm opend in %s\n", str_block_mode); | 511 printf("alsa-init: pcm opend in %s\n", str_block_mode); |
512 } | 512 } |
513 | 513 |
514 snd_pcm_hw_params_alloca(&alsa_hwparams); | 514 snd_pcm_hw_params_alloca(&alsa_hwparams); |
515 snd_pcm_sw_params_alloca(&alsa_swparams); | 515 snd_pcm_sw_params_alloca(&alsa_swparams); |
578 { | 578 { |
579 printf("alsa-init: unable to set period time: %s\n", | 579 printf("alsa-init: unable to set period time: %s\n", |
580 snd_strerror(err)); | 580 snd_strerror(err)); |
581 return(0); | 581 return(0); |
582 } | 582 } |
583 if (verbose) | 583 if (verbose>0) |
584 printf("alsa-init: buffer_time: %d, period_time :%d\n",alsa_buffer_time, err); | 584 printf("alsa-init: buffer_time: %d, period_time :%d\n",alsa_buffer_time, err); |
585 } | 585 } |
586 #endif | 586 #endif |
587 | 587 |
588 #ifdef SET_CHUNKSIZE | 588 #ifdef SET_CHUNKSIZE |
591 if ((err = snd_pcm_hw_params_set_period_size(alsa_handler, alsa_hwparams, chunk_size, 0)) < 0) | 591 if ((err = snd_pcm_hw_params_set_period_size(alsa_handler, alsa_hwparams, chunk_size, 0)) < 0) |
592 { | 592 { |
593 printf("alsa-init: unable to set periodsize: %s\n", snd_strerror(err)); | 593 printf("alsa-init: unable to set periodsize: %s\n", snd_strerror(err)); |
594 return(0); | 594 return(0); |
595 } | 595 } |
596 else if (verbose) { | 596 else if (verbose>0) { |
597 printf("alsa-init: chunksize set to %i\n", chunk_size); | 597 printf("alsa-init: chunksize set to %i\n", chunk_size); |
598 } | 598 } |
599 | 599 |
600 //set period_count | 600 //set period_count |
601 if ((period_val = snd_pcm_hw_params_get_periods_max(alsa_hwparams, 0)) < alsa_fragcount) { | 601 if ((period_val = snd_pcm_hw_params_get_periods_max(alsa_hwparams, 0)) < alsa_fragcount) { |
602 alsa_fragcount = period_val; | 602 alsa_fragcount = period_val; |
603 } | 603 } |
604 | 604 |
605 if (verbose) | 605 if (verbose>0) |
606 printf("alsa-init: current val=%i, fragcount=%i\n", period_val, alsa_fragcount); | 606 printf("alsa-init: current val=%i, fragcount=%i\n", period_val, alsa_fragcount); |
607 | 607 |
608 if ((err = snd_pcm_hw_params_set_periods(alsa_handler, alsa_hwparams, alsa_fragcount, 0)) < 0) { | 608 if ((err = snd_pcm_hw_params_set_periods(alsa_handler, alsa_hwparams, alsa_fragcount, 0)) < 0) { |
609 printf("alsa-init: unable to set periods: %s\n", snd_strerror(err)); | 609 printf("alsa-init: unable to set periods: %s\n", snd_strerror(err)); |
610 } | 610 } |
627 printf("alsa-init: unable to get buffersize: %s\n", snd_strerror(err)); | 627 printf("alsa-init: unable to get buffersize: %s\n", snd_strerror(err)); |
628 return(0); | 628 return(0); |
629 } | 629 } |
630 else { | 630 else { |
631 ao_data.buffersize = err; | 631 ao_data.buffersize = err; |
632 if (verbose) | 632 if (verbose>0) |
633 printf("alsa-init: got buffersize=%i\n", ao_data.buffersize); | 633 printf("alsa-init: got buffersize=%i\n", ao_data.buffersize); |
634 } | 634 } |
635 | 635 |
636 // setting sw-params (only avail-min) if noblocking mode was choosed | 636 // setting sw-params (only avail-min) if noblocking mode was choosed |
637 if (ao_noblock) | 637 if (ao_noblock) |
659 | 659 |
660 bits_per_sample = snd_pcm_format_physical_width(alsa_format); | 660 bits_per_sample = snd_pcm_format_physical_width(alsa_format); |
661 bits_per_frame = bits_per_sample * channels; | 661 bits_per_frame = bits_per_sample * channels; |
662 chunk_bytes = chunk_size * bits_per_frame / 8; | 662 chunk_bytes = chunk_size * bits_per_frame / 8; |
663 | 663 |
664 if (verbose) { | 664 if (verbose>0) { |
665 printf("alsa-init: bits per sample (bps)=%i, bits per frame (bpf)=%i, chunk_bytes=%i\n",bits_per_sample,bits_per_frame,chunk_bytes);} | 665 printf("alsa-init: bits per sample (bps)=%i, bits per frame (bpf)=%i, chunk_bytes=%i\n",bits_per_sample,bits_per_frame,chunk_bytes);} |
666 | 666 |
667 }//end swparams | 667 }//end swparams |
668 | 668 |
669 if ((err = snd_pcm_prepare(alsa_handler)) < 0) | 669 if ((err = snd_pcm_prepare(alsa_handler)) < 0) |
723 printf("alsa-pause: pcm drain error: %s\n", snd_strerror(err)); | 723 printf("alsa-pause: pcm drain error: %s\n", snd_strerror(err)); |
724 return; | 724 return; |
725 } | 725 } |
726 } | 726 } |
727 else { | 727 else { |
728 if (verbose) | 728 if (verbose>0) |
729 printf("alsa-pause: paused nonblock\n"); | 729 printf("alsa-pause: paused nonblock\n"); |
730 | 730 |
731 return; | 731 return; |
732 } | 732 } |
733 } | 733 } |
760 { | 760 { |
761 printf("alsa-reset: pcm prepare error: %s\n", snd_strerror(err)); | 761 printf("alsa-reset: pcm prepare error: %s\n", snd_strerror(err)); |
762 return; | 762 return; |
763 } | 763 } |
764 } else { | 764 } else { |
765 if (verbose) | 765 if (verbose>0) |
766 printf("alsa-reset: reset nonblocked"); | 766 printf("alsa-reset: reset nonblocked"); |
767 return; | 767 return; |
768 } | 768 } |
769 } | 769 } |
770 | 770 |
1049 //avail_frames = snd_pcm_avail_update(alsa_handler) * bytes_per_sample; | 1049 //avail_frames = snd_pcm_avail_update(alsa_handler) * bytes_per_sample; |
1050 if (str_status != "open" && str_status != "prepared") | 1050 if (str_status != "open" && str_status != "prepared") |
1051 str_status = "running"; | 1051 str_status = "running"; |
1052 break; | 1052 break; |
1053 case SND_PCM_STATE_PAUSED: | 1053 case SND_PCM_STATE_PAUSED: |
1054 if (verbose) printf("alsa-space: paused"); | 1054 if (verbose>0) printf("alsa-space: paused"); |
1055 str_status = "paused"; | 1055 str_status = "paused"; |
1056 ret = 0; | 1056 ret = 0; |
1057 break; | 1057 break; |
1058 case SND_PCM_STATE_XRUN: | 1058 case SND_PCM_STATE_XRUN: |
1059 xrun("space"); | 1059 xrun("space"); |
1067 if (ret <= 0) { | 1067 if (ret <= 0) { |
1068 xrun("space"); | 1068 xrun("space"); |
1069 } | 1069 } |
1070 } | 1070 } |
1071 | 1071 |
1072 if (verbose && str_status != "running") | 1072 if (verbose>0 && str_status != "running") |
1073 printf("alsa-space: free space = %i, status=%i, %s --\n", ret, status, str_status); | 1073 printf("alsa-space: free space = %i, status=%i, %s --\n", ret, status, str_status); |
1074 snd_pcm_status_free(status); | 1074 snd_pcm_status_free(status); |
1075 | 1075 |
1076 if (ret < 0) { | 1076 if (ret < 0) { |
1077 printf("negative value!!\n"); | 1077 printf("negative value!!\n"); |