| Index: media/audio/linux/alsa_output.cc
|
| diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc
|
| index 96a2e4ba432926ef1f624b3097a687b0438f8759..9f3498e7dd2a32fca1f99aa35e04d78c596f50af 100644
|
| --- a/media/audio/linux/alsa_output.cc
|
| +++ b/media/audio/linux/alsa_output.cc
|
| @@ -88,6 +88,11 @@
|
| // busy looping.
|
| static const int kNoDataSleepMilliseconds = 10;
|
|
|
| +// According to the linux nanosleep manpage, nanosleep on linux can miss the
|
| +// deadline by up to 10ms because the kernel timeslice is 10ms. Give a 2x
|
| +// buffer to compensate for the timeslice, and any additional slowdowns.
|
| +static const int kSleepErrorMilliseconds = 20;
|
| +
|
| // Set to 0 during debugging if you want error messages due to underrun
|
| // events or other recoverable errors.
|
| #if defined(NDEBUG)
|
| @@ -500,6 +505,11 @@ void AlsaPcmOutputStream::ScheduleNextWrite(Packet* current_packet) {
|
| int next_fill_time_ms =
|
| FramesToMillis(frames_until_empty_enough, sample_rate_);
|
|
|
| + // Adjust for timer resolution issues.
|
| + if (next_fill_time_ms > kSleepErrorMilliseconds) {
|
| + next_fill_time_ms -= kSleepErrorMilliseconds;
|
| + }
|
| +
|
| // Avoid busy looping if the data source is exhausted.
|
| if (current_packet->size == 0) {
|
| next_fill_time_ms = std::max(next_fill_time_ms, kNoDataSleepMilliseconds);
|
|
|