diff options
author | scherkus <scherkus@chromium.org> | 2014-08-28 19:57:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-29 02:58:38 +0000 |
commit | 50687650f80e74d4135f7002c1c1b30f94892b28 (patch) | |
tree | 005e3b0d7a9bb848082f0173c07793777d2ce741 | |
parent | 51d4852246362fc385663b932c2b0f6f1b4a6092 (diff) | |
download | chromium_src-50687650f80e74d4135f7002c1c1b30f94892b28.zip chromium_src-50687650f80e74d4135f7002c1c1b30f94892b28.tar.gz chromium_src-50687650f80e74d4135f7002c1c1b30f94892b28.tar.bz2 |
Remove time getters from AudioBufferQueue and AudioRendererAlgorithm.
With the switch to pure frame-based calculation of time in 5b6ce11,
these methods are no longer used.
BUG=370634
Review URL: https://codereview.chromium.org/516113002
Cr-Commit-Position: refs/heads/master@{#292560}
-rw-r--r-- | media/base/audio_buffer_queue.cc | 26 | ||||
-rw-r--r-- | media/base/audio_buffer_queue.h | 15 | ||||
-rw-r--r-- | media/base/audio_buffer_queue_unittest.cc | 121 | ||||
-rw-r--r-- | media/filters/audio_renderer_algorithm.cc | 4 | ||||
-rw-r--r-- | media/filters/audio_renderer_algorithm.h | 4 |
5 files changed, 0 insertions, 170 deletions
diff --git a/media/base/audio_buffer_queue.cc b/media/base/audio_buffer_queue.cc index abe8fce..299d44f 100644 --- a/media/base/audio_buffer_queue.cc +++ b/media/base/audio_buffer_queue.cc @@ -20,16 +20,9 @@ void AudioBufferQueue::Clear() { current_buffer_ = buffers_.begin(); current_buffer_offset_ = 0; frames_ = 0; - current_time_ = kNoTimestamp(); } void AudioBufferQueue::Append(const scoped_refptr<AudioBuffer>& buffer_in) { - // If we have just written the first buffer, update |current_time_| to be the - // start time. - if (buffers_.empty() && buffer_in->timestamp() != kNoTimestamp()) { - current_time_ = buffer_in->timestamp(); - } - // Add the buffer to the queue. Inserting into deque invalidates all // iterators, so point to the first buffer. buffers_.push_back(buffer_in); @@ -114,12 +107,6 @@ int AudioBufferQueue::InternalRead(int frames, // Has the buffer has been consumed? if (current_buffer_offset == buffer->frame_count()) { - if (advance_position) { - // Next buffer may not have timestamp, so we need to update current - // timestamp before switching to the next buffer. - UpdateCurrentTime(current_buffer, current_buffer_offset); - } - // If we are at the last buffer, no more data to be copied, so stop. BufferQueue::iterator next = current_buffer + 1; if (next == buffers_.end()) @@ -137,8 +124,6 @@ int AudioBufferQueue::InternalRead(int frames, DCHECK_GE(frames_, 0); DCHECK(current_buffer_ != buffers_.end() || frames_ == 0); - UpdateCurrentTime(current_buffer, current_buffer_offset); - // Remove any buffers before the current buffer as there is no going // backwards. buffers_.erase(buffers_.begin(), current_buffer); @@ -149,15 +134,4 @@ int AudioBufferQueue::InternalRead(int frames, return taken; } -void AudioBufferQueue::UpdateCurrentTime(BufferQueue::iterator buffer, - int offset) { - if (buffer != buffers_.end() && (*buffer)->timestamp() != kNoTimestamp()) { - double time_offset = ((*buffer)->duration().InMicroseconds() * offset) / - static_cast<double>((*buffer)->frame_count()); - current_time_ = - (*buffer)->timestamp() + base::TimeDelta::FromMicroseconds( - static_cast<int64>(time_offset + 0.5)); - } -} - } // namespace media diff --git a/media/base/audio_buffer_queue.h b/media/base/audio_buffer_queue.h index 58823f2..b5e16e08 100644 --- a/media/base/audio_buffer_queue.h +++ b/media/base/audio_buffer_queue.h @@ -57,13 +57,6 @@ class MEDIA_EXPORT AudioBufferQueue { // Returns the number of frames buffered beyond the current position. int frames() const { return frames_; } - // Returns the current timestamp, taking into account current offset. The - // value calculated based on the timestamp of the current buffer. If timestamp - // for the current buffer is set to 0, then returns value that corresponds to - // the last position in a buffer that had timestamp set. kNoTimestamp() is - // returned if no buffers we read from had timestamp set. - base::TimeDelta current_time() const { return current_time_; } - private: // Definition of the buffer queue. typedef std::deque<scoped_refptr<AudioBuffer> > BufferQueue; @@ -81,10 +74,6 @@ class MEDIA_EXPORT AudioBufferQueue { int dest_frame_offset, AudioBus* dest); - // Updates |current_time_| with the time that corresponds to the specified - // position in the buffer. - void UpdateCurrentTime(BufferQueue::iterator buffer, int offset); - BufferQueue::iterator current_buffer_; BufferQueue buffers_; int current_buffer_offset_; @@ -92,10 +81,6 @@ class MEDIA_EXPORT AudioBufferQueue { // Number of frames available to be read in the buffer. int frames_; - // Keeps track of the most recent time we've seen in case the |buffers_| is - // empty when our owner asks what time it is. - base::TimeDelta current_time_; - DISALLOW_COPY_AND_ASSIGN(AudioBufferQueue); }; diff --git a/media/base/audio_buffer_queue_unittest.cc b/media/base/audio_buffer_queue_unittest.cc index dfb2098..d883189 100644 --- a/media/base/audio_buffer_queue_unittest.cc +++ b/media/base/audio_buffer_queue_unittest.cc @@ -344,125 +344,4 @@ TEST(AudioBufferQueueTest, Peek) { EXPECT_EQ(30, buffer.PeekFrames(30, 0, 0, bus1.get())); } -TEST(AudioBufferQueueTest, Time) { - const ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; - const int channels = ChannelLayoutToChannelCount(channel_layout); - const base::TimeDelta start_time1; - const base::TimeDelta start_time2 = base::TimeDelta::FromSeconds(30); - AudioBufferQueue buffer; - scoped_ptr<AudioBus> bus = AudioBus::Create(channels, 100); - - scoped_refptr<AudioBuffer> audio_buffer = - MakeAudioBuffer<int16>(kSampleFormatS16, - channel_layout, - channels, - kSampleRate, - 1, - 1, - 10, - start_time1); - - // Add two buffers (second one added later): - // first: start=0s, duration=10s - // second: start=30s, duration=10s - buffer.Append(audio_buffer); - EXPECT_EQ(10, buffer.frames()); - - // Check starting time. - EXPECT_EQ(start_time1, buffer.current_time()); - - // Read 2 frames, should be 2s in (since duration is 1s per sample). - int frames_read = 2; - EXPECT_EQ(frames_read, buffer.ReadFrames(frames_read, 0, bus.get())); - EXPECT_EQ( - start_time1 + - frames_read * audio_buffer->duration() / audio_buffer->frame_count(), - buffer.current_time()); - - // Skip 2 frames. - buffer.SeekFrames(2); - frames_read += 2; - EXPECT_EQ( - start_time1 + - frames_read * audio_buffer->duration() / audio_buffer->frame_count(), - buffer.current_time()); - - // Add second buffer for more data. - buffer.Append(MakeAudioBuffer<int16>(kSampleFormatS16, - channel_layout, - channels, - kSampleRate, - 1, - 1, - 10, - start_time2)); - EXPECT_EQ(16, buffer.frames()); - - // Read until almost the end of buffer1. - frames_read += 5; - EXPECT_EQ(5, buffer.ReadFrames(5, 0, bus.get())); - EXPECT_EQ( - start_time1 + - frames_read * audio_buffer->duration() / audio_buffer->frame_count(), - buffer.current_time()); - - // Read 1 value, so time moved to buffer2. - EXPECT_EQ(1, buffer.ReadFrames(1, 0, bus.get())); - EXPECT_EQ(start_time2, buffer.current_time()); - - // Read all 10 frames in buffer2, timestamp should be last time from buffer2. - frames_read = 10; - EXPECT_EQ(10, buffer.ReadFrames(10, 0, bus.get())); - const base::TimeDelta expected_current_time = - start_time2 + - frames_read * audio_buffer->duration() / audio_buffer->frame_count(); - EXPECT_EQ(expected_current_time, buffer.current_time()); - - // Try to read more frames (which don't exist), timestamp should remain. - EXPECT_EQ(0, buffer.ReadFrames(5, 0, bus.get())); - EXPECT_EQ(expected_current_time, buffer.current_time()); -} - -TEST(AudioBufferQueueTest, NoTime) { - const ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; - const int channels = ChannelLayoutToChannelCount(channel_layout); - const base::TimeDelta kNoTime = kNoTimestamp(); - AudioBufferQueue buffer; - scoped_ptr<AudioBus> bus = AudioBus::Create(channels, 100); - - // Add two buffers with no timestamps. Time should always be unknown. - buffer.Append( - MakeTestBuffer<int16>(kSampleFormatS16, channel_layout, 1, 1, 10)); - buffer.Append( - MakeTestBuffer<int16>(kSampleFormatS16, channel_layout, 1, 1, 10)); - EXPECT_EQ(20, buffer.frames()); - - // Check starting time. - EXPECT_EQ(kNoTime, buffer.current_time()); - - // Read 2 frames. - EXPECT_EQ(2, buffer.ReadFrames(2, 0, bus.get())); - EXPECT_EQ(kNoTime, buffer.current_time()); - - // Skip 2 frames. - buffer.SeekFrames(2); - EXPECT_EQ(kNoTime, buffer.current_time()); - - // Read until almost the end of buffer1. - EXPECT_EQ(5, buffer.ReadFrames(5, 0, bus.get())); - EXPECT_EQ(kNoTime, buffer.current_time()); - - // Read 1 value, so time moved to buffer2. - EXPECT_EQ(1, buffer.ReadFrames(1, 0, bus.get())); - EXPECT_EQ(kNoTime, buffer.current_time()); - - // Read all 10 frames in buffer2. - EXPECT_EQ(10, buffer.ReadFrames(10, 0, bus.get())); - EXPECT_EQ(kNoTime, buffer.current_time()); - - // Try to read more frames (which don't exist), timestamp should remain. - EXPECT_EQ(0, buffer.ReadFrames(5, 0, bus.get())); - EXPECT_EQ(kNoTime, buffer.current_time()); -} - } // namespace media diff --git a/media/filters/audio_renderer_algorithm.cc b/media/filters/audio_renderer_algorithm.cc index fb5cf74..b604b9e 100644 --- a/media/filters/audio_renderer_algorithm.cc +++ b/media/filters/audio_renderer_algorithm.cc @@ -210,10 +210,6 @@ void AudioRendererAlgorithm::FlushBuffers() { capacity_ = kStartingBufferSizeInFrames; } -base::TimeDelta AudioRendererAlgorithm::GetTime() { - return audio_buffer_.current_time(); -} - void AudioRendererAlgorithm::EnqueueBuffer( const scoped_refptr<AudioBuffer>& buffer_in) { DCHECK(!buffer_in->end_of_stream()); diff --git a/media/filters/audio_renderer_algorithm.h b/media/filters/audio_renderer_algorithm.h index b36eb08..68b18a5 100644 --- a/media/filters/audio_renderer_algorithm.h +++ b/media/filters/audio_renderer_algorithm.h @@ -51,10 +51,6 @@ class MEDIA_EXPORT AudioRendererAlgorithm { // Clears |audio_buffer_|. void FlushBuffers(); - // Returns the time of the next byte in our data or kNoTimestamp() if current - // time is unknown. - base::TimeDelta GetTime(); - // Enqueues a buffer. It is called from the owner of the algorithm after a // read completes. void EnqueueBuffer(const scoped_refptr<AudioBuffer>& buffer_in); |