summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 17:50:25 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 17:50:25 +0000
commit613c37ff0448b7767006137f3ea396c94b895fdc (patch)
tree27cf1e853dbfc8739f3e0400431e066acf770ab3
parent272c3c15fa918060027b63a160d2e170c9088cf5 (diff)
downloadchromium_src-613c37ff0448b7767006137f3ea396c94b895fdc.zip
chromium_src-613c37ff0448b7767006137f3ea396c94b895fdc.tar.gz
chromium_src-613c37ff0448b7767006137f3ea396c94b895fdc.tar.bz2
Fix the issue with audio ended event on Ubuntu 10.10.
The problem is that snd_pcm_avail_update() returns (alsa_buffer_frames_ - 1) even when the buffer is empty. Here I removed snd_pcm_avail_update() from delay calculation, so that hardware_delay is just the delay returned by snd_pcm_delay() BUG=59585 TEST=http://jsfiddle.net/x5VRq/1/ on Ubuntu 10.10. Review URL: http://codereview.chromium.org/3854002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63066 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/audio/linux/alsa_output.cc11
-rw-r--r--media/audio/linux/alsa_output_unittest.cc4
2 files changed, 4 insertions, 11 deletions
diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc
index 09d9f79..3125775 100644
--- a/media/audio/linux/alsa_output.cc
+++ b/media/audio/linux/alsa_output.cc
@@ -471,15 +471,10 @@ 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.
- // Amount of data currently in the ALSA's buffer.
- uint32 alsa_buffered_frames = (alsa_buffer_frames_ - GetAvailableFrames());
+ uint32 buffer_delay = buffer_->forward_bytes() * bytes_per_frame_ /
+ bytes_per_output_frame_;
- // |buffer_delay| includes our buffer and ALSA's buffer.
- uint32 buffer_delay = alsa_buffered_frames * bytes_per_frame_ +
- buffer_->forward_bytes() * bytes_per_frame_ / bytes_per_output_frame_;
-
- uint32 hardware_delay = (GetCurrentDelay() - alsa_buffered_frames) *
- bytes_per_frame_;
+ uint32 hardware_delay = GetCurrentDelay() * bytes_per_frame_;
scoped_refptr<media::DataBuffer> packet =
new media::DataBuffer(packet_size_);
diff --git a/media/audio/linux/alsa_output_unittest.cc b/media/audio/linux/alsa_output_unittest.cc
index a37dadb..cd50919 100644
--- a/media/audio/linux/alsa_output_unittest.cc
+++ b/media/audio/linux/alsa_output_unittest.cc
@@ -458,11 +458,9 @@ TEST_F(AlsaPcmOutputStreamTest, StartStop) {
// Expect scheduling.
EXPECT_CALL(mock_alsa_wrapper_, PcmAvailUpdate(kFakeHandle))
- .Times(AtLeast(5))
+ .Times(AtLeast(3))
.WillOnce(Return(kTestFramesPerPacket)) // Buffer is empty.
.WillOnce(Return(kTestFramesPerPacket))
- .WillOnce(Return(kTestFramesPerPacket))
- .WillOnce(Return(kTestFramesPerPacket))
.WillRepeatedly(DoAll(InvokeWithoutArgs(&message_loop_,
&MessageLoop::QuitNow),
Return(0))); // Buffer is full.