summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--media/audio/linux/alsa_output.cc27
-rw-r--r--media/audio/linux/alsa_output.h1
-rw-r--r--media/audio/linux/alsa_output_unittest.cc18
3 files changed, 3 insertions, 43 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
diff --git a/media/audio/linux/alsa_output.h b/media/audio/linux/alsa_output.h
index eaea5a2..6bc7de9 100644
--- a/media/audio/linux/alsa_output.h
+++ b/media/audio/linux/alsa_output.h
@@ -146,7 +146,6 @@ class AlsaPcmOutputStream :
uint32 latency);
bool CloseDevice(snd_pcm_t* handle);
snd_pcm_sframes_t GetAvailableFrames();
- snd_pcm_sframes_t GetCurrentDelay();
// Attempts to find the best matching linux audio device for the given number
// of channels. This function will set |device_name_| and |should_downmix_|.
diff --git a/media/audio/linux/alsa_output_unittest.cc b/media/audio/linux/alsa_output_unittest.cc
index 922ecdd..f0aefe6 100644
--- a/media/audio/linux/alsa_output_unittest.cc
+++ b/media/audio/linux/alsa_output_unittest.cc
@@ -439,12 +439,6 @@ TEST_F(AlsaPcmOutputStreamTest, StartStop) {
// Expect the pre-roll.
MockAudioSourceCallback mock_callback;
- EXPECT_CALL(mock_alsa_wrapper_, PcmState(kFakeHandle))
- .Times(2)
- .WillRepeatedly(Return(SND_PCM_STATE_RUNNING));
- EXPECT_CALL(mock_alsa_wrapper_, PcmDelay(kFakeHandle, _))
- .Times(2)
- .WillRepeatedly(DoAll(SetArgumentPointee<1>(0), Return(0)));
EXPECT_CALL(mock_callback,
OnMoreData(test_stream_.get(), _, kTestPacketSize, 0))
.Times(2)
@@ -551,12 +545,8 @@ TEST_F(AlsaPcmOutputStreamTest, BufferPacket) {
// Return a partially filled packet.
MockAudioSourceCallback mock_callback;
- EXPECT_CALL(mock_alsa_wrapper_, PcmState(_))
- .WillOnce(Return(SND_PCM_STATE_RUNNING));
- EXPECT_CALL(mock_alsa_wrapper_, PcmDelay(_, _))
- .WillOnce(DoAll(SetArgumentPointee<1>(1), Return(0)));
EXPECT_CALL(mock_callback,
- OnMoreData(test_stream_.get(), _, _, kTestBytesPerFrame))
+ OnMoreData(test_stream_.get(), _, _, 0))
.WillOnce(Return(10));
bool source_exhausted;
@@ -574,10 +564,6 @@ TEST_F(AlsaPcmOutputStreamTest, BufferPacket_Negative) {
// Simulate where the underrun has occurred right after checking the delay.
MockAudioSourceCallback mock_callback;
- EXPECT_CALL(mock_alsa_wrapper_, PcmState(_))
- .WillOnce(Return(SND_PCM_STATE_RUNNING));
- EXPECT_CALL(mock_alsa_wrapper_, PcmDelay(_, _))
- .WillOnce(DoAll(SetArgumentPointee<1>(-1), Return(0)));
EXPECT_CALL(mock_callback,
OnMoreData(test_stream_.get(), _, _, 0))
.WillOnce(Return(10));
@@ -597,8 +583,6 @@ TEST_F(AlsaPcmOutputStreamTest, BufferPacket_Underrun) {
// If ALSA has underrun then we should assume a delay of zero.
MockAudioSourceCallback mock_callback;
- EXPECT_CALL(mock_alsa_wrapper_, PcmState(_))
- .WillOnce(Return(SND_PCM_STATE_XRUN));
EXPECT_CALL(mock_callback,
OnMoreData(test_stream_.get(), _, _, 0))
.WillOnce(Return(10));