summaryrefslogtreecommitdiffstats
path: root/media/audio/linux/alsa_output.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-14 21:40:57 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-14 21:40:57 +0000
commitd794caf24c8a31c855b979fca24fbb785be58acf (patch)
tree99ac9ceb54625f35eb516da58f9990d27eb8c93f /media/audio/linux/alsa_output.cc
parente354d2cd1de0bb9c6bdda169d67e8f484f4012df (diff)
downloadchromium_src-d794caf24c8a31c855b979fca24fbb785be58acf.zip
chromium_src-d794caf24c8a31c855b979fca24fbb785be58acf.tar.gz
chromium_src-d794caf24c8a31c855b979fca24fbb785be58acf.tar.bz2
Fixed ended event when playing audio on linux.
AudioRendererBase::FillBuffers() sends ended event only when playback_delay == 0, but with ALSA output the delay was never set to 0 because it includes hardware delay. Changed ALSA output to include only internal buffers in the delay value: this matches windows and mac versions. BUG=45074 TEST=<audio> fires ended event when necessary Review URL: http://codereview.chromium.org/2978005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/linux/alsa_output.cc')
-rw-r--r--media/audio/linux/alsa_output.cc27
1 files changed, 2 insertions, 25 deletions
diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc
index 0440ecf..1358dc3 100644
--- a/media/audio/linux/alsa_output.cc
+++ b/media/audio/linux/alsa_output.cc
@@ -486,7 +486,7 @@ void AlsaPcmOutputStream::BufferPacket(bool* source_exhausted) {
// Before making a request to source for data. We need to determine the
// delay (in bytes) for the requested data to be played.
snd_pcm_sframes_t delay = buffer_->forward_bytes() * bytes_per_frame_ /
- bytes_per_output_frame_ + GetCurrentDelay() * bytes_per_output_frame_;
+ bytes_per_output_frame_;
scoped_refptr<media::DataBuffer> packet =
new media::DataBuffer(packet_size_);
@@ -496,7 +496,7 @@ void AlsaPcmOutputStream::BufferPacket(bool* source_exhausted) {
CHECK(packet_size <= packet->GetBufferSize()) <<
"Data source overran buffer.";
- // This should not happen, but incase it does, drop any trailing bytes
+ // This should not happen, but in case it does, drop any trailing bytes
// that aren't large enough to make a frame. Without this, packet writing
// may stall because the last few bytes in the packet may never get used by
// WritePacket.
@@ -801,29 +801,6 @@ snd_pcm_sframes_t AlsaPcmOutputStream::GetAvailableFrames() {
return available_frames;
}
-snd_pcm_sframes_t AlsaPcmOutputStream::GetCurrentDelay() {
- snd_pcm_sframes_t delay = 0;
-
- // Don't query ALSA's delay if we have underrun since it'll be jammed at
- // some non-zero value and potentially even negative!
- if (wrapper_->PcmState(playback_handle_) != SND_PCM_STATE_XRUN) {
- int error = wrapper_->PcmDelay(playback_handle_, &delay);
- if (error < 0) {
- // Assume a delay of zero and attempt to recover the device.
- delay = 0;
- error = wrapper_->PcmRecover(playback_handle_,
- error,
- kPcmRecoverIsSilent);
- if (error < 0) {
- LOG(ERROR) << "Failed querying delay: " << wrapper_->StrError(error);
- }
- }
- if (delay < 0)
- delay = 0;
- }
- return delay;
-}
-
snd_pcm_t* AlsaPcmOutputStream::AutoSelectDevice(unsigned int latency) {
// For auto-selection:
// 1) Attempt to open a device that best matches the number of channels