| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/client/audio_player.h" | 5 #include "remoting/client/audio_player.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 FakeAudioPlayer() { | 29 FakeAudioPlayer() { |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool ResetAudioPlayer(AudioPacket::SamplingRate) override { return true; } | 32 bool ResetAudioPlayer(AudioPacket::SamplingRate) override { return true; } |
| 33 | 33 |
| 34 uint32 GetSamplesPerFrame() override { return kAudioSamplesPerFrame; } | 34 uint32 GetSamplesPerFrame() override { return kAudioSamplesPerFrame; } |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class AudioPlayerTest : public ::testing::Test { | 37 class AudioPlayerTest : public ::testing::Test { |
| 38 protected: | 38 protected: |
| 39 virtual void SetUp() { | 39 void SetUp() override { |
| 40 audio_.reset(new FakeAudioPlayer()); | 40 audio_.reset(new FakeAudioPlayer()); |
| 41 buffer_.reset(new char[kAudioFrameBytes + kPaddingBytes]); | 41 buffer_.reset(new char[kAudioFrameBytes + kPaddingBytes]); |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual void TearDown() { | 44 void TearDown() override {} |
| 45 } | |
| 46 | 45 |
| 47 void ConsumeAudioFrame() { | 46 void ConsumeAudioFrame() { |
| 48 uint8* buffer = reinterpret_cast<uint8*>(buffer_.get()); | 47 uint8* buffer = reinterpret_cast<uint8*>(buffer_.get()); |
| 49 memset(buffer, kDefaultBufferData, kAudioFrameBytes + kPaddingBytes); | 48 memset(buffer, kDefaultBufferData, kAudioFrameBytes + kPaddingBytes); |
| 50 AudioPlayer::AudioPlayerCallback(reinterpret_cast<void*>(buffer_.get()), | 49 AudioPlayer::AudioPlayerCallback(reinterpret_cast<void*>(buffer_.get()), |
| 51 kAudioFrameBytes, | 50 kAudioFrameBytes, |
| 52 reinterpret_cast<void*>(audio_.get())); | 51 reinterpret_cast<void*>(audio_.get())); |
| 53 // Verify we haven't written beyond the end of the buffer. | 52 // Verify we haven't written beyond the end of the buffer. |
| 54 for (int i = 0; i < kPaddingBytes; i++) | 53 for (int i = 0; i < kPaddingBytes; i++) |
| 55 ASSERT_EQ(kDefaultBufferData, *(buffer + kAudioFrameBytes + i)); | 54 ASSERT_EQ(kDefaultBufferData, *(buffer + kAudioFrameBytes + i)); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 301 |
| 303 // Attempt to consume a frame of 25 samples. | 302 // Attempt to consume a frame of 25 samples. |
| 304 ConsumeAudioFrame(); | 303 ConsumeAudioFrame(); |
| 305 ASSERT_EQ(0, GetNumQueuedSamples()); | 304 ASSERT_EQ(0, GetNumQueuedSamples()); |
| 306 ASSERT_EQ(0, GetNumQueuedPackets()); | 305 ASSERT_EQ(0, GetNumQueuedPackets()); |
| 307 ASSERT_EQ(0, GetBytesConsumed()); | 306 ASSERT_EQ(0, GetBytesConsumed()); |
| 308 CheckAudioFrameBytes(packet1_samples * kAudioSampleBytes); | 307 CheckAudioFrameBytes(packet1_samples * kAudioSampleBytes); |
| 309 } | 308 } |
| 310 | 309 |
| 311 } // namespace remoting | 310 } // namespace remoting |
| OLD | NEW |