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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 | 220 |
221 ASSERT_TRUE(CancelableSyncSocket::CreatePair(&browser_socket_, | 221 ASSERT_TRUE(CancelableSyncSocket::CreatePair(&browser_socket_, |
222 &renderer_socket_)); | 222 &renderer_socket_)); |
223 | 223 |
224 // Create duplicates of the handles we pass to AudioOutputDevice since | 224 // Create duplicates of the handles we pass to AudioOutputDevice since |
225 // ownership will be transferred and AudioOutputDevice is responsible for | 225 // ownership will be transferred and AudioOutputDevice is responsible for |
226 // freeing. | 226 // freeing. |
227 SyncSocket::TransitDescriptor audio_device_socket_descriptor; | 227 SyncSocket::TransitDescriptor audio_device_socket_descriptor; |
228 ASSERT_TRUE(renderer_socket_.PrepareTransitDescriptor( | 228 ASSERT_TRUE(renderer_socket_.PrepareTransitDescriptor( |
229 base::GetCurrentProcessHandle(), &audio_device_socket_descriptor)); | 229 base::GetCurrentProcessHandle(), &audio_device_socket_descriptor)); |
230 base::SharedMemoryHandle duplicated_memory_handle; | 230 base::SharedMemoryHandle duplicated_memory_handle = |
231 ASSERT_TRUE(shared_memory_.ShareToProcess(base::GetCurrentProcessHandle(), | 231 shared_memory_.handle().Duplicate(); |
232 &duplicated_memory_handle)); | 232 ASSERT_TRUE(duplicated_memory_handle.IsValid()); |
233 | 233 |
234 audio_device_->OnStreamCreated( | 234 audio_device_->OnStreamCreated( |
235 duplicated_memory_handle, | 235 duplicated_memory_handle, |
Nico
2017/05/02 20:08:01
Didn't verify that this one assumes ownership.
erikchen
2017/05/02 21:33:10
I looked at real use cases of OnStreamCreated, and
| |
236 SyncSocket::UnwrapHandle(audio_device_socket_descriptor), kMemorySize); | 236 SyncSocket::UnwrapHandle(audio_device_socket_descriptor), kMemorySize); |
237 base::RunLoop().RunUntilIdle(); | 237 base::RunLoop().RunUntilIdle(); |
238 } | 238 } |
239 | 239 |
240 void AudioOutputDeviceTest::ExpectRenderCallback() { | 240 void AudioOutputDeviceTest::ExpectRenderCallback() { |
241 // We should get a 'play' notification when we call OnStreamCreated(). | 241 // We should get a 'play' notification when we call OnStreamCreated(). |
242 // Respond by asking for some audio data. This should ask our callback | 242 // Respond by asking for some audio data. This should ask our callback |
243 // to provide some audio data that AudioOutputDevice then writes into the | 243 // to provide some audio data that AudioOutputDevice then writes into the |
244 // shared memory section. | 244 // shared memory section. |
245 EXPECT_CALL(*audio_output_ipc_, PlayStream()) | 245 EXPECT_CALL(*audio_output_ipc_, PlayStream()) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 // Runs the loop and waits for |thread| to call event's closure. | 378 // Runs the loop and waits for |thread| to call event's closure. |
379 event.RunAndWait(); | 379 event.RunAndWait(); |
380 | 380 |
381 audio_device_->Stop(); | 381 audio_device_->Stop(); |
382 base::RunLoop().RunUntilIdle(); | 382 base::RunLoop().RunUntilIdle(); |
383 } | 383 } |
384 | 384 |
385 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); | 385 INSTANTIATE_TEST_CASE_P(Render, AudioOutputDeviceTest, Values(false)); |
386 | 386 |
387 } // namespace media. | 387 } // namespace media. |
OLD | NEW |