| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/filters/audio_clock.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 5 #include "base/macros.h" | 9 #include "base/macros.h" |
| 6 #include "base/memory/scoped_ptr.h" | |
| 7 #include "media/base/audio_timestamp_helper.h" | 10 #include "media/base/audio_timestamp_helper.h" |
| 8 #include "media/filters/audio_clock.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 12 |
| 11 namespace media { | 13 namespace media { |
| 12 | 14 |
| 13 class AudioClockTest : public testing::Test { | 15 class AudioClockTest : public testing::Test { |
| 14 public: | 16 public: |
| 15 AudioClockTest() { SetupClock(base::TimeDelta(), 10); } | 17 AudioClockTest() { SetupClock(base::TimeDelta(), 10); } |
| 16 | 18 |
| 17 ~AudioClockTest() override {} | 19 ~AudioClockTest() override {} |
| 18 | 20 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return total.InMilliseconds(); | 59 return total.InMilliseconds(); |
| 58 } | 60 } |
| 59 | 61 |
| 60 int ContiguousAudioDataBufferedAtSameRateInMilliseconds() { | 62 int ContiguousAudioDataBufferedAtSameRateInMilliseconds() { |
| 61 base::TimeDelta total, same_rate_total; | 63 base::TimeDelta total, same_rate_total; |
| 62 clock_->ContiguousAudioDataBufferedForTesting(&total, &same_rate_total); | 64 clock_->ContiguousAudioDataBufferedForTesting(&total, &same_rate_total); |
| 63 return same_rate_total.InMilliseconds(); | 65 return same_rate_total.InMilliseconds(); |
| 64 } | 66 } |
| 65 | 67 |
| 66 int sample_rate_; | 68 int sample_rate_; |
| 67 scoped_ptr<AudioClock> clock_; | 69 std::unique_ptr<AudioClock> clock_; |
| 68 | 70 |
| 69 private: | 71 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(AudioClockTest); | 72 DISALLOW_COPY_AND_ASSIGN(AudioClockTest); |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 TEST_F(AudioClockTest, FrontTimestampStartsAtStartTimestamp) { | 75 TEST_F(AudioClockTest, FrontTimestampStartsAtStartTimestamp) { |
| 74 base::TimeDelta expected = base::TimeDelta::FromSeconds(123); | 76 base::TimeDelta expected = base::TimeDelta::FromSeconds(123); |
| 75 AudioClock clock(expected, sample_rate_); | 77 AudioClock clock(expected, sample_rate_); |
| 76 | 78 |
| 77 EXPECT_EQ(expected, clock.front_timestamp()); | 79 EXPECT_EQ(expected, clock.front_timestamp()); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 frames_written += 1024; | 371 frames_written += 1024; |
| 370 WroteAudio(1024, 1024, 0, 1); | 372 WroteAudio(1024, 1024, 0, 1); |
| 371 } | 373 } |
| 372 | 374 |
| 373 // Verify no error accumulated. | 375 // Verify no error accumulated. |
| 374 EXPECT_EQ(std::round(frames_written * micros_per_frame), | 376 EXPECT_EQ(std::round(frames_written * micros_per_frame), |
| 375 clock_->back_timestamp().InMicroseconds()); | 377 clock_->back_timestamp().InMicroseconds()); |
| 376 } | 378 } |
| 377 | 379 |
| 378 } // namespace media | 380 } // namespace media |
| OLD | NEW |