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 "content/browser/renderer_host/media/audio_input_sync_writer.h" | 5 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 25 matching lines...) Expand all Loading... |
36 // Audio buffer parameters. | 36 // Audio buffer parameters. |
37 const int channels = 1; | 37 const int channels = 1; |
38 const int sampling_frequency_hz = 16000; | 38 const int sampling_frequency_hz = 16000; |
39 const int frames = sampling_frequency_hz / 100; // 10 ms | 39 const int frames = sampling_frequency_hz / 100; // 10 ms |
40 const int bits_per_sample = 16; | 40 const int bits_per_sample = 16; |
41 | 41 |
42 // Faked ring buffer. Must be aligned. | 42 // Faked ring buffer. Must be aligned. |
43 #define DATA_ALIGNMENT 16 | 43 #define DATA_ALIGNMENT 16 |
44 static_assert(AudioBus::kChannelAlignment == DATA_ALIGNMENT, | 44 static_assert(AudioBus::kChannelAlignment == DATA_ALIGNMENT, |
45 "Data alignment not same as AudioBus"); | 45 "Data alignment not same as AudioBus"); |
46 ALIGNAS(DATA_ALIGNMENT) | 46 alignas(DATA_ALIGNMENT) |
47 uint8_t data[kSegments * (sizeof(media::AudioInputBufferParameters) + | 47 uint8_t data[kSegments * (sizeof(media::AudioInputBufferParameters) + |
48 frames * channels * sizeof(float))]; | 48 frames * channels * sizeof(float))]; |
49 | 49 |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 // Mocked out sockets used for Send/ReceiveWithTimeout. Counts the number of | 52 // Mocked out sockets used for Send/ReceiveWithTimeout. Counts the number of |
53 // outstanding reads, i.e. the diff between send and receive calls. | 53 // outstanding reads, i.e. the diff between send and receive calls. |
54 class MockCancelableSyncSocket : public base::CancelableSyncSocket { | 54 class MockCancelableSyncSocket : public base::CancelableSyncSocket { |
55 public: | 55 public: |
56 MockCancelableSyncSocket(int buffer_size) | 56 MockCancelableSyncSocket(int buffer_size) |
57 : in_failure_mode_(false), | 57 : in_failure_mode_(false), |
58 writes_(0), | 58 writes_(0), |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 EXPECT_TRUE(TestSocketAndFifoExpectations(kSegments, 0, 2)); | 359 EXPECT_TRUE(TestSocketAndFifoExpectations(kSegments, 0, 2)); |
360 | 360 |
361 // Empty both. Should render a log call for emptying the fifo. | 361 // Empty both. Should render a log call for emptying the fifo. |
362 socket_->Read(kSegments); | 362 socket_->Read(kSegments); |
363 writer_->Write(audio_bus_.get(), 0, false, 0); | 363 writer_->Write(audio_bus_.get(), 0, false, 0); |
364 socket_->Read(3); | 364 socket_->Read(3); |
365 EXPECT_TRUE(TestSocketAndFifoExpectations(0, 3 * sizeof(uint32_t), 0)); | 365 EXPECT_TRUE(TestSocketAndFifoExpectations(0, 3 * sizeof(uint32_t), 0)); |
366 } | 366 } |
367 | 367 |
368 } // namespace content | 368 } // namespace content |
OLD | NEW |