Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "media/mojo/services/mojo_audio_output_stream.h" | 5 #include "media/mojo/services/mojo_audio_output_stream.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 DCHECK(shared_memory); | 64 DCHECK(shared_memory); |
| 65 DCHECK(foreign_socket); | 65 DCHECK(foreign_socket); |
| 66 | 66 |
| 67 base::SharedMemoryHandle foreign_memory_handle = | 67 base::SharedMemoryHandle foreign_memory_handle = |
| 68 base::SharedMemory::DuplicateHandle(shared_memory->handle()); | 68 base::SharedMemory::DuplicateHandle(shared_memory->handle()); |
| 69 DCHECK(base::SharedMemory::IsHandleValid(foreign_memory_handle)); | 69 DCHECK(base::SharedMemory::IsHandleValid(foreign_memory_handle)); |
| 70 | 70 |
| 71 mojo::ScopedSharedBufferHandle buffer_handle = mojo::WrapSharedMemoryHandle( | 71 mojo::ScopedSharedBufferHandle buffer_handle = mojo::WrapSharedMemoryHandle( |
| 72 foreign_memory_handle, shared_memory->requested_size(), false); | 72 foreign_memory_handle, shared_memory->requested_size(), false); |
| 73 mojo::ScopedHandle socket_handle = | 73 mojo::ScopedHandle socket_handle = |
| 74 mojo::WrapPlatformFile(foreign_socket->handle()); | 74 mojo::WrapPlatformFile(foreign_socket->Release()); |
|
Nico
2017/04/10 15:29:35
Should WrapPltformFile take an rvalue of some kind
Max Morin
2017/04/10 15:44:20
It should probably take a ScopedPlatformHandle (an
Nico
2017/04/10 15:50:37
Maybe at least file a bug.
Max Morin
2017/04/11 09:11:11
I filed crbug.com/710376 and also added checks for
| |
| 75 | 75 |
| 76 DCHECK(buffer_handle.is_valid()); | 76 DCHECK(buffer_handle.is_valid()); |
| 77 DCHECK(socket_handle.is_valid()); | 77 DCHECK(socket_handle.is_valid()); |
| 78 | 78 |
| 79 base::ResetAndReturn(&stream_created_callback_) | 79 base::ResetAndReturn(&stream_created_callback_) |
| 80 .Run(std::move(buffer_handle), std::move(socket_handle)); | 80 .Run(std::move(buffer_handle), std::move(socket_handle)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void MojoAudioOutputStream::OnStreamError(int stream_id) { | 83 void MojoAudioOutputStream::OnStreamError(int stream_id) { |
| 84 DCHECK(thread_checker_.CalledOnValidThread()); | 84 DCHECK(thread_checker_.CalledOnValidThread()); |
| 85 OnError(); | 85 OnError(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void MojoAudioOutputStream::OnError() { | 88 void MojoAudioOutputStream::OnError() { |
| 89 DCHECK(thread_checker_.CalledOnValidThread()); | 89 DCHECK(thread_checker_.CalledOnValidThread()); |
| 90 DCHECK(deleter_callback_); | 90 DCHECK(deleter_callback_); |
| 91 std::move(deleter_callback_).Run(); // Deletes |this|. | 91 std::move(deleter_callback_).Run(); // Deletes |this|. |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace media | 94 } // namespace media |
| OLD | NEW |