| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/sync_socket.h" | 7 #include "base/sync_socket.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" | 9 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" |
| 10 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 const int kSegments = 10; | 27 const int kSegments = 10; |
| 28 | 28 |
| 29 // Audio buffer parameters. | 29 // Audio buffer parameters. |
| 30 const int channels = 1; | 30 const int channels = 1; |
| 31 const int sampling_frequency_hz = 16000; | 31 const int sampling_frequency_hz = 16000; |
| 32 const int frames = sampling_frequency_hz / 100; // 10 ms | 32 const int frames = sampling_frequency_hz / 100; // 10 ms |
| 33 const int bits_per_sample = 16; | 33 const int bits_per_sample = 16; |
| 34 | 34 |
| 35 // Faked ring buffer. Must be aligned. | 35 // Faked ring buffer. Must be aligned. |
| 36 #define DATA_ALIGNMENT 16 | 36 #define DATA_ALIGNMENT 16 |
| 37 COMPILE_ASSERT(AudioBus::kChannelAlignment == DATA_ALIGNMENT, | 37 static_assert(AudioBus::kChannelAlignment == DATA_ALIGNMENT, |
| 38 Data_alignment_not_same_as_AudioBus); | 38 "Data alignment not same as AudioBus"); |
| 39 ALIGNAS(DATA_ALIGNMENT) uint8 data[kSegments * | 39 ALIGNAS(DATA_ALIGNMENT) uint8 data[kSegments * |
| 40 (sizeof(media::AudioInputBufferParameters) + frames * channels * | 40 (sizeof(media::AudioInputBufferParameters) + frames * channels * |
| 41 sizeof(float))]; | 41 sizeof(float))]; |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 // Mocked out sockets used for Send/ReceiveWithTimeout. Counts the number of | 45 // Mocked out sockets used for Send/ReceiveWithTimeout. Counts the number of |
| 46 // outstanding reads, i.e. the diff between send and receive calls. | 46 // outstanding reads, i.e. the diff between send and receive calls. |
| 47 class MockCancelableSyncSocket : public base::CancelableSyncSocket { | 47 class MockCancelableSyncSocket : public base::CancelableSyncSocket { |
| 48 public: | 48 public: |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 EXPECT_TRUE(TestSocketAndFifoExpectations(kSegments, 0, 2)); | 353 EXPECT_TRUE(TestSocketAndFifoExpectations(kSegments, 0, 2)); |
| 354 | 354 |
| 355 // Empty both. Should render a log call for emptying the fifo. | 355 // Empty both. Should render a log call for emptying the fifo. |
| 356 socket_->Read(kSegments); | 356 socket_->Read(kSegments); |
| 357 writer_->Write(audio_bus_.get(), 0, false, 0); | 357 writer_->Write(audio_bus_.get(), 0, false, 0); |
| 358 socket_->Read(3); | 358 socket_->Read(3); |
| 359 EXPECT_TRUE(TestSocketAndFifoExpectations(0, 3 * sizeof(uint32_t), 0)); | 359 EXPECT_TRUE(TestSocketAndFifoExpectations(0, 3 * sizeof(uint32_t), 0)); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace content | 362 } // namespace content |
| OLD | NEW |