| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 // OnCreateStream() must have been called and we should have a valid | 167 // OnCreateStream() must have been called and we should have a valid |
| 168 // stream id. | 168 // stream id. |
| 169 ASSERT_NE(stream_id_, -1); | 169 ASSERT_NE(stream_id_, -1); |
| 170 | 170 |
| 171 // This is where it gets a bit hacky. The shared memory contract between | 171 // This is where it gets a bit hacky. The shared memory contract between |
| 172 // AudioOutputDevice and its browser side counter part includes a bit more | 172 // AudioOutputDevice and its browser side counter part includes a bit more |
| 173 // than just the audio data, so we must call TotalSharedMemorySizeInBytes() | 173 // than just the audio data, so we must call TotalSharedMemorySizeInBytes() |
| 174 // to get the actual size needed to fit the audio data plus the extra data. | 174 // to get the actual size needed to fit the audio data plus the extra data. |
| 175 int memory_size = TotalSharedMemorySizeInBytes( | 175 int memory_size = TotalSharedMemorySizeInBytes( |
| 176 default_audio_parameters_.GetBytesPerBuffer()); | 176 AudioBus::CalculateMemorySize(default_audio_parameters_)); |
| 177 SharedMemory shared_memory; | 177 SharedMemory shared_memory; |
| 178 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(memory_size)); | 178 ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(memory_size)); |
| 179 memset(shared_memory.memory(), 0xff, memory_size); | 179 memset(shared_memory.memory(), 0xff, memory_size); |
| 180 | 180 |
| 181 CancelableSyncSocket browser_socket, renderer_socket; | 181 CancelableSyncSocket browser_socket, renderer_socket; |
| 182 ASSERT_TRUE(CancelableSyncSocket::CreatePair(&browser_socket, | 182 ASSERT_TRUE(CancelableSyncSocket::CreatePair(&browser_socket, |
| 183 &renderer_socket)); | 183 &renderer_socket)); |
| 184 | 184 |
| 185 // Create duplicates of the handles we pass to AudioOutputDevice since | 185 // Create duplicates of the handles we pass to AudioOutputDevice since |
| 186 // ownership will be transferred and AudioOutputDevice is responsible for | 186 // ownership will be transferred and AudioOutputDevice is responsible for |
| (...skipping 21 matching lines...) Expand all Loading... |
| 208 // of success and quit the loop. | 208 // of success and quit the loop. |
| 209 | 209 |
| 210 const int kNumberOfFramesToProcess = 0; | 210 const int kNumberOfFramesToProcess = 0; |
| 211 | 211 |
| 212 EXPECT_CALL(callback_, Render(_, _)) | 212 EXPECT_CALL(callback_, Render(_, _)) |
| 213 .WillOnce(DoAll( | 213 .WillOnce(DoAll( |
| 214 QuitLoop(io_loop_.message_loop_proxy()), | 214 QuitLoop(io_loop_.message_loop_proxy()), |
| 215 Return(kNumberOfFramesToProcess))); | 215 Return(kNumberOfFramesToProcess))); |
| 216 | 216 |
| 217 audio_device->OnStreamCreated(duplicated_memory_handle, audio_device_socket, | 217 audio_device->OnStreamCreated(duplicated_memory_handle, audio_device_socket, |
| 218 memory_size); | 218 PacketSizeInBytes(memory_size)); |
| 219 | 219 |
| 220 io_loop_.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), | 220 io_loop_.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), |
| 221 TestTimeouts::action_timeout()); | 221 TestTimeouts::action_timeout()); |
| 222 io_loop_.Run(); | 222 io_loop_.Run(); |
| 223 | 223 |
| 224 // Close the stream sequence. | 224 // Close the stream sequence. |
| 225 EXPECT_CALL(audio_output_ipc_, CloseStream(stream_id_)); | 225 EXPECT_CALL(audio_output_ipc_, CloseStream(stream_id_)); |
| 226 | 226 |
| 227 audio_device->Stop(); | 227 audio_device->Stop(); |
| 228 io_loop_.RunAllPending(); | 228 io_loop_.RunAllPending(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace media. | 231 } // namespace media. |
| OLD | NEW |