summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-02 12:12:40 +0000
committerxians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-02 12:12:40 +0000
commit4276bc2128210bc33c098aaed1a4d0551e43e0ef (patch)
tree59d15cdc00fa32e2be4b55328a428faba68aae68 /media
parentd8eb898392b543c2c5fa8cadd4127dc19c34a23e (diff)
downloadchromium_src-4276bc2128210bc33c098aaed1a4d0551e43e0ef.zip
chromium_src-4276bc2128210bc33c098aaed1a4d0551e43e0ef.tar.gz
chromium_src-4276bc2128210bc33c098aaed1a4d0551e43e0ef.tar.bz2
It seems that snd_pcm_hw_params_set_* API does not work well any more in the latest ubuntu like 12.04. My tests show that it will freeze the pulseaudio for a while and get into underrun state. And it seems snd_pcm_set_params works better for the same purpose.
This patch also fixes the choppy audio issue for webrtc in ubuntu 12.04. BUG=152232,153505 TEST=use pepper flash (./out/Debug/chrome -ppapi-flash-path=/your/path/libpepflashplayer.so) open link http://www.youtube.com/watch?v=F7pYHN9iC9I&feature=youtu.be in two tabs, audio should be good. uses apprtc.appspot.com to make a loopback call and verify the audio is good on ubuntu 12.04 Review URL: https://chromiumcodereview.appspot.com/11019010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159680 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/audio/linux/alsa_wrapper.cc73
1 files changed, 7 insertions, 66 deletions
diff --git a/media/audio/linux/alsa_wrapper.cc b/media/audio/linux/alsa_wrapper.cc
index 67331b4..c1ce359 100644
--- a/media/audio/linux/alsa_wrapper.cc
+++ b/media/audio/linux/alsa_wrapper.cc
@@ -71,76 +71,17 @@ const char* AlsaWrapper::PcmName(snd_pcm_t* handle) {
return snd_pcm_name(handle);
}
-int AlsaWrapper::ConfigureHwParams(snd_pcm_t* handle,
- snd_pcm_hw_params_t* hw_params,
- snd_pcm_format_t format,
- snd_pcm_access_t access,
- unsigned int channels,
- unsigned int rate,
- int soft_resample,
- unsigned int latency) {
- int err = 0;
- if ((err = snd_pcm_hw_params_any(handle, hw_params)) < 0)
- return err;
-
- if ((err = snd_pcm_hw_params_set_rate_resample(handle, hw_params,
- soft_resample)) < 0) {
- return err;
- }
-
- if ((err = snd_pcm_hw_params_set_format(handle, hw_params, format)) < 0)
- return err;
-
- int dir = 0;
- unsigned new_rate = rate;
- if ((err = snd_pcm_hw_params_set_rate_near(handle, hw_params,
- &new_rate, &dir)) < 0) {
- return err;
- }
-
- if ((err = snd_pcm_hw_params_set_access(handle, hw_params, access)) < 0)
- return err;
-
- if ((err = snd_pcm_hw_params_set_channels(handle, hw_params, channels)) < 0)
- return err;
-
- unsigned buffer_time = latency;
- if (buffer_time == 0) {
- if ((err = snd_pcm_hw_params_get_buffer_time_max(hw_params,
- &buffer_time, 0)) < 0) {
- return err;
- }
- if (buffer_time > 500000)
- buffer_time = 500000;
- }
-
- unsigned period_time = buffer_time / 4;
- if ((err = snd_pcm_hw_params_set_period_time_near(handle, hw_params,
- &period_time, 0)) < 0) {
- return err;
- }
-
- err = snd_pcm_hw_params_set_buffer_time_near(handle, hw_params,
- &buffer_time, 0);
- return err;
-}
-
int AlsaWrapper::PcmSetParams(snd_pcm_t* handle, snd_pcm_format_t format,
snd_pcm_access_t access, unsigned int channels,
unsigned int rate, int soft_resample,
unsigned int latency) {
- int err = 0;
- snd_pcm_hw_params_t* hw_params;
- if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0)
- return err;
-
- if ((err = ConfigureHwParams(handle, hw_params, format, access, channels,
- rate, soft_resample, latency)) >= 0) {
- err = snd_pcm_hw_params(handle, hw_params);
- }
-
- snd_pcm_hw_params_free(hw_params);
- return err;
+ return snd_pcm_set_params(handle,
+ format,
+ access,
+ channels,
+ rate,
+ soft_resample,
+ latency);
}
int AlsaWrapper::PcmGetParams(snd_pcm_t* handle, snd_pcm_uframes_t* buffer_size,