Mercurial > mplayer.hg
comparison libao2/ao_alsa9.c @ 10514:760e12774430
better pause mechanism and faster uninit support by Vladimir I. Umnov <uvi@ezmail.ru>
author | alex |
---|---|
date | Sun, 03 Aug 2003 17:54:35 +0000 |
parents | faa09ea4ed6d |
children | 3136605e6cab |
comparison
equal
deleted
inserted
replaced
10513:b3f144efb724 | 10514:760e12774430 |
---|---|
68 int ao_noblock = 0; | 68 int ao_noblock = 0; |
69 int first = 1; | 69 int first = 1; |
70 | 70 |
71 static int open_mode; | 71 static int open_mode; |
72 static int set_block_mode; | 72 static int set_block_mode; |
73 static int alsa_can_pause = 0; | |
73 | 74 |
74 #define ALSA_DEVICE_SIZE 48 | 75 #define ALSA_DEVICE_SIZE 48 |
75 | 76 |
76 #undef BUFFERTIME | 77 #undef BUFFERTIME |
77 #define SET_CHUNKSIZE | 78 #define SET_CHUNKSIZE |
681 printf("alsa9: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n", | 682 printf("alsa9: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n", |
682 ao_data.samplerate, ao_data.channels, bytes_per_sample, ao_data.buffersize, | 683 ao_data.samplerate, ao_data.channels, bytes_per_sample, ao_data.buffersize, |
683 snd_pcm_format_description(alsa_format)); | 684 snd_pcm_format_description(alsa_format)); |
684 | 685 |
685 } // end switch alsa_handler (spdif) | 686 } // end switch alsa_handler (spdif) |
687 alsa_can_pause = snd_pcm_hw_params_can_pause(alsa_hwparams); | |
686 return(1); | 688 return(1); |
687 } // end init | 689 } // end init |
688 | 690 |
689 | 691 |
690 /* close audio device */ | 692 /* close audio device */ |
693 | 695 |
694 if (alsa_handler) { | 696 if (alsa_handler) { |
695 int err; | 697 int err; |
696 | 698 |
697 if (!ao_noblock) { | 699 if (!ao_noblock) { |
698 if ((err = snd_pcm_drain(alsa_handler)) < 0) | 700 if ((err = snd_pcm_drop(alsa_handler)) < 0) |
699 { | 701 { |
700 printf("alsa-uninit: pcm drain error: %s\n", snd_strerror(err)); | 702 printf("alsa-uninit: pcm drop error: %s\n", snd_strerror(err)); |
701 return; | 703 return; |
702 } | 704 } |
703 } | 705 } |
704 | 706 |
705 if ((err = snd_pcm_close(alsa_handler)) < 0) | 707 if ((err = snd_pcm_close(alsa_handler)) < 0) |
720 | 722 |
721 static void audio_pause() | 723 static void audio_pause() |
722 { | 724 { |
723 int err; | 725 int err; |
724 | 726 |
725 if (!ao_noblock) { | 727 if (alsa_can_pause) { |
726 //drain causes error in nonblock-mode! | 728 if ((err = snd_pcm_pause(alsa_handler, 1)) < 0) |
727 if ((err = snd_pcm_drain(alsa_handler)) < 0) | 729 { |
728 { | 730 printf("alsa-pause: pcm pause error: %s\n", snd_strerror(err)); |
729 printf("alsa-pause: pcm drain error: %s\n", snd_strerror(err)); | 731 return; |
730 return; | 732 } |
731 } | 733 if (verbose) |
732 } | 734 printf("alsa-pause: pause supported by hardware\n"); |
733 else { | 735 } else { |
734 if (verbose>0) | 736 if ((err = snd_pcm_drop(alsa_handler)) < 0) |
735 printf("alsa-pause: paused nonblock\n"); | 737 { |
736 | 738 printf("alsa-pause: pcm drop error: %s\n", snd_strerror(err)); |
737 return; | 739 return; |
740 } | |
738 } | 741 } |
739 } | 742 } |
740 | 743 |
741 static void audio_resume() | 744 static void audio_resume() |
742 { | 745 { |
743 int err; | 746 int err; |
744 | 747 |
745 if ((err = snd_pcm_prepare(alsa_handler)) < 0) | 748 if (alsa_can_pause) { |
746 { | 749 if ((err = snd_pcm_pause(alsa_handler, 0)) < 0) |
747 printf("alsa-resume: pcm prepare error: %s\n", snd_strerror(err)); | 750 { |
748 return; | 751 printf("alsa-resume: pcm resume error: %s\n", snd_strerror(err)); |
752 return; | |
753 } | |
754 if (verbose) | |
755 printf("alsa-resume: resume supported by hardware\n"); | |
756 } else { | |
757 if ((err = snd_pcm_prepare(alsa_handler)) < 0) | |
758 { | |
759 printf("alsa-resume: pcm prepare error: %s\n", snd_strerror(err)); | |
760 return; | |
761 } | |
749 } | 762 } |
750 } | 763 } |
751 | 764 |
752 /* stop playing and empty buffers (for seeking/pause) */ | 765 /* stop playing and empty buffers (for seeking/pause) */ |
753 static void reset() | 766 static void reset() |