OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 TEST(AudioProcessingImplTest, AudioParameterChangeTriggersInit) { | 35 TEST(AudioProcessingImplTest, AudioParameterChangeTriggersInit) { |
36 Config config; | 36 Config config; |
37 MockInitialize mock(config); | 37 MockInitialize mock(config); |
38 ON_CALL(mock, InitializeLocked()) | 38 ON_CALL(mock, InitializeLocked()) |
39 .WillByDefault(Invoke(&mock, &MockInitialize::RealInitializeLocked)); | 39 .WillByDefault(Invoke(&mock, &MockInitialize::RealInitializeLocked)); |
40 | 40 |
41 EXPECT_CALL(mock, InitializeLocked()).Times(1); | 41 EXPECT_CALL(mock, InitializeLocked()).Times(1); |
42 mock.Initialize(); | 42 mock.Initialize(); |
43 | 43 |
44 AudioFrame frame; | 44 AudioFrame frame; |
45 // Call with the default parameters; there should be no init. | 45 // Call with the default parameters; there should be an init. |
46 frame.num_channels_ = 1; | 46 frame.num_channels_ = 1; |
47 SetFrameSampleRate(&frame, 16000); | 47 SetFrameSampleRate(&frame, 16000); |
48 EXPECT_CALL(mock, InitializeLocked()) | 48 EXPECT_CALL(mock, InitializeLocked()) |
49 .Times(0); | 49 .Times(1); |
50 EXPECT_NOERR(mock.ProcessStream(&frame)); | 50 EXPECT_NOERR(mock.ProcessStream(&frame)); |
51 EXPECT_NOERR(mock.ProcessReverseStream(&frame)); | 51 EXPECT_NOERR(mock.ProcessReverseStream(&frame)); |
52 | 52 |
53 // New sample rate. (Only impacts ProcessStream). | 53 // New sample rate. (Only impacts ProcessStream). |
54 SetFrameSampleRate(&frame, 32000); | 54 SetFrameSampleRate(&frame, 32000); |
55 EXPECT_CALL(mock, InitializeLocked()) | 55 EXPECT_CALL(mock, InitializeLocked()) |
56 .Times(1); | 56 .Times(1); |
57 EXPECT_NOERR(mock.ProcessStream(&frame)); | 57 EXPECT_NOERR(mock.ProcessStream(&frame)); |
58 | 58 |
59 // New number of channels. | 59 // New number of channels. |
| 60 // TODO(peah): Investigate why this causes 2 inits. |
60 frame.num_channels_ = 2; | 61 frame.num_channels_ = 2; |
61 EXPECT_CALL(mock, InitializeLocked()) | 62 EXPECT_CALL(mock, InitializeLocked()) |
62 .Times(2); | 63 .Times(2); |
63 EXPECT_NOERR(mock.ProcessStream(&frame)); | 64 EXPECT_NOERR(mock.ProcessStream(&frame)); |
64 // ProcessStream sets num_channels_ == num_output_channels. | 65 // ProcessStream sets num_channels_ == num_output_channels. |
65 frame.num_channels_ = 2; | 66 frame.num_channels_ = 2; |
66 EXPECT_NOERR(mock.ProcessReverseStream(&frame)); | 67 EXPECT_NOERR(mock.ProcessReverseStream(&frame)); |
67 | 68 |
68 // A new sample rate passed to ProcessReverseStream should cause an init. | 69 // A new sample rate passed to ProcessReverseStream should cause an init. |
69 SetFrameSampleRate(&frame, 16000); | 70 SetFrameSampleRate(&frame, 16000); |
70 EXPECT_CALL(mock, InitializeLocked()).Times(1); | 71 EXPECT_CALL(mock, InitializeLocked()).Times(1); |
71 EXPECT_NOERR(mock.ProcessReverseStream(&frame)); | 72 EXPECT_NOERR(mock.ProcessReverseStream(&frame)); |
72 } | 73 } |
73 | 74 |
74 } // namespace webrtc | 75 } // namespace webrtc |
OLD | NEW |