Chromium Code Reviews| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 | 28 |
| 29 namespace media { | 29 namespace media { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 class MockRenderCallback : public AudioRendererSink::RenderCallback { | 33 class MockRenderCallback : public AudioRendererSink::RenderCallback { |
| 34 public: | 34 public: |
| 35 MockRenderCallback() {} | 35 MockRenderCallback() {} |
| 36 virtual ~MockRenderCallback() {} | 36 virtual ~MockRenderCallback() {} |
| 37 | 37 |
| 38 MOCK_METHOD3(Render, int(const std::vector<float*>& audio_data, | 38 MOCK_METHOD3(Render, int(AudioBus* audio_bus, |
| 39 int number_of_frames, | 39 int number_of_frames, |
| 40 int audio_delay_milliseconds)); | 40 int audio_delay_milliseconds)); |
| 41 MOCK_METHOD0(OnRenderError, void()); | 41 MOCK_METHOD0(OnRenderError, void()); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 class MockAudioOutputIPC : public AudioOutputIPC { | 44 class MockAudioOutputIPC : public AudioOutputIPC { |
| 45 public: | 45 public: |
| 46 MockAudioOutputIPC() {} | 46 MockAudioOutputIPC() {} |
| 47 virtual ~MockAudioOutputIPC() {} | 47 virtual ~MockAudioOutputIPC() {} |
| 48 | 48 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Used to terminate a loop from a different thread than the loop belongs to. | 84 // Used to terminate a loop from a different thread than the loop belongs to. |
| 85 // |loop| should be a MessageLoopProxy. | 85 // |loop| should be a MessageLoopProxy. |
| 86 ACTION_P(QuitLoop, loop) { | 86 ACTION_P(QuitLoop, loop) { |
| 87 loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 87 loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Zeros out |number_of_frames| in all channel buffers pointed to by | 90 // Zeros out |number_of_frames| in all channel buffers pointed to by |
| 91 // the |audio_data| vector. | 91 // the |audio_data| vector. |
| 92 void ZeroAudioData(int number_of_frames, | 92 void ZeroAudioData(int number_of_frames, AudioBus* audio_bus) { |
|
scherkus (not reviewing)
2012/08/07 23:23:41
if this was an ACTION_P2() you can get rid of all
DaleCurtis
2012/08/08 00:17:58
Actually, I'm not sure I understand what that Zero
scherkus (not reviewing)
2012/08/08 00:49:01
Strange indeed! I'm not sure what's going on here
DaleCurtis
2012/08/08 01:26:07
tommi just added this file I think (git blame conf
| |
| 93 const std::vector<float*>& audio_data) { | 93 audio_bus->ZeroFrames(number_of_frames); |
| 94 std::vector<float*>::const_iterator it = audio_data.begin(); | |
| 95 for (; it != audio_data.end(); ++it) { | |
| 96 float* channel = *it; | |
| 97 for (int j = 0; j < number_of_frames; ++j) { | |
| 98 channel[j] = 0.0f; | |
| 99 } | |
| 100 } | |
| 101 } | 94 } |
| 102 | 95 |
| 103 } // namespace. | 96 } // namespace. |
| 104 | 97 |
| 105 class AudioOutputDeviceTest : public testing::Test { | 98 class AudioOutputDeviceTest : public testing::Test { |
| 106 public: | 99 public: |
| 107 AudioOutputDeviceTest() | 100 AudioOutputDeviceTest() |
| 108 : default_audio_parameters_(AudioParameters::AUDIO_PCM_LINEAR, | 101 : default_audio_parameters_(AudioParameters::AUDIO_PCM_LINEAR, |
| 109 CHANNEL_LAYOUT_STEREO, | 102 CHANNEL_LAYOUT_STEREO, |
| 110 48000, 16, 1024), | 103 48000, 16, 1024), |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 io_loop_.Run(); | 241 io_loop_.Run(); |
| 249 | 242 |
| 250 // Close the stream sequence. | 243 // Close the stream sequence. |
| 251 EXPECT_CALL(audio_output_ipc_, CloseStream(stream_id_)); | 244 EXPECT_CALL(audio_output_ipc_, CloseStream(stream_id_)); |
| 252 | 245 |
| 253 audio_device->Stop(); | 246 audio_device->Stop(); |
| 254 io_loop_.RunAllPending(); | 247 io_loop_.RunAllPending(); |
| 255 } | 248 } |
| 256 | 249 |
| 257 } // namespace media. | 250 } // namespace media. |
| OLD | NEW |