Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(839)

Unified Diff: media/base/audio_buffer_queue_unittest.cc

Issue 516113002: Remove time getters from AudioBufferQueue and AudioRendererAlgorithm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/audio_buffer_queue.cc ('k') | media/filters/audio_renderer_algorithm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_buffer_queue_unittest.cc
diff --git a/media/base/audio_buffer_queue_unittest.cc b/media/base/audio_buffer_queue_unittest.cc
index dfb2098e1aa29bcec87bec6bf1705e5c16b192a0..d883189319bcf8b6649a4f904cf06569de18f4a8 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
« no previous file with comments | « media/base/audio_buffer_queue.cc ('k') | media/filters/audio_renderer_algorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698