Chromium Code Reviews| Index: media/audio/linux/alsa_output.cc |
| diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc |
| index d8e502cf7699b60b49c794be0faa2c289f8b0408..f933c35ad4782356bbc16289c5bd627c74112557 100644 |
| --- a/media/audio/linux/alsa_output.cc |
| +++ b/media/audio/linux/alsa_output.cc |
| @@ -395,6 +395,10 @@ void AlsaPcmOutputStream::StartTask() { |
| return; |
| } |
| + // Before starting, the buffer might have audio from previous user of this |
| + // device. |
| + buffer_->Clear(); |
|
Sergey Ulanov
2011/03/31 22:04:46
Does this mean we cut the sound that was playing b
davejcool
2011/04/09 03:10:43
By this time, the previous stream's usage of this
|
| + |
| // When starting again, drop all packets in the device and prepare it again |
| // incase we are restarting from a pause state and need to flush old data. |
| int error = wrapper_->PcmDrop(playback_handle_); |
| @@ -579,6 +583,13 @@ void AlsaPcmOutputStream::WritePacket() { |
| // Seek forward in the buffer after we've written some data to ALSA. |
| buffer_->Seek(frames_written * bytes_per_output_frame_); |
| } |
| + } else { |
| + // If nothing left to write and playback hasn't started yet, start it now. |
| + // This ensures that shorter sounds will still play. |
| + if ((wrapper_->PcmState(playback_handle_) == SND_PCM_STATE_PREPARED) && |
| + GetCurrentDelay()) { |
|
scherkus (not reviewing)
2011/03/31 22:08:10
GetCurrentDelay() > 0 ?
davejcool
2011/04/09 03:10:43
Yes, >0 is better, thanks!
|
| + wrapper_->PcmStart(playback_handle_); |
| + } |
| } |
| } |