| 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 "content/browser/renderer_host/media/audio_input_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/numerics/safe_math.h" | 10 #include "base/numerics/safe_math.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 &foreign_memory_handle)) { | 171 &foreign_memory_handle)) { |
| 172 // If we failed to map and share the shared memory then close the audio | 172 // If we failed to map and share the shared memory then close the audio |
| 173 // stream and send an error message. | 173 // stream and send an error message. |
| 174 DeleteEntryOnError(entry, MEMORY_SHARING_FAILED); | 174 DeleteEntryOnError(entry, MEMORY_SHARING_FAILED); |
| 175 return; | 175 return; |
| 176 } | 176 } |
| 177 | 177 |
| 178 AudioInputSyncWriter* writer = | 178 AudioInputSyncWriter* writer = |
| 179 static_cast<AudioInputSyncWriter*>(entry->writer.get()); | 179 static_cast<AudioInputSyncWriter*>(entry->writer.get()); |
| 180 | 180 |
| 181 #if defined(OS_WIN) | 181 base::SyncSocket::TransitDescriptor socket_transit_descriptor; |
| 182 base::SyncSocket::Handle foreign_socket_handle; | |
| 183 #else | |
| 184 base::FileDescriptor foreign_socket_handle; | |
| 185 #endif | |
| 186 | 182 |
| 187 // If we failed to prepare the sync socket for the renderer then we fail | 183 // If we failed to prepare the sync socket for the renderer then we fail |
| 188 // the construction of audio input stream. | 184 // the construction of audio input stream. |
| 189 if (!writer->PrepareForeignSocketHandle(PeerHandle(), | 185 if (!writer->PrepareForeignSocket(PeerHandle(), &socket_transit_descriptor)) { |
| 190 &foreign_socket_handle)) { | |
| 191 DeleteEntryOnError(entry, SYNC_SOCKET_ERROR); | 186 DeleteEntryOnError(entry, SYNC_SOCKET_ERROR); |
| 192 return; | 187 return; |
| 193 } | 188 } |
| 194 | 189 |
| 195 LogMessage(entry->stream_id, | 190 LogMessage(entry->stream_id, |
| 196 "DoCompleteCreation => IPC channel and stream are now open", | 191 "DoCompleteCreation => IPC channel and stream are now open", |
| 197 true); | 192 true); |
| 198 | 193 |
| 199 Send(new AudioInputMsg_NotifyStreamCreated(entry->stream_id, | 194 Send(new AudioInputMsg_NotifyStreamCreated(entry->stream_id, |
| 200 foreign_memory_handle, foreign_socket_handle, | 195 foreign_memory_handle, socket_transit_descriptor, |
| 201 entry->shared_memory.requested_size(), | 196 entry->shared_memory.requested_size(), |
| 202 entry->shared_memory_segment_count)); | 197 entry->shared_memory_segment_count)); |
| 203 } | 198 } |
| 204 | 199 |
| 205 void AudioInputRendererHost::DoSendRecordingMessage( | 200 void AudioInputRendererHost::DoSendRecordingMessage( |
| 206 media::AudioInputController* controller) { | 201 media::AudioInputController* controller) { |
| 207 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 202 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 208 // TODO(henrika): See crbug.com/115262 for details on why this method | 203 // TODO(henrika): See crbug.com/115262 for details on why this method |
| 209 // should be implemented. | 204 // should be implemented. |
| 210 AudioEntry* entry = LookupByController(controller); | 205 AudioEntry* entry = LookupByController(controller); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // TODO(hclam): Implement a faster look up method. | 497 // TODO(hclam): Implement a faster look up method. |
| 503 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 498 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
| 504 i != audio_entries_.end(); ++i) { | 499 i != audio_entries_.end(); ++i) { |
| 505 if (controller == i->second->controller.get()) | 500 if (controller == i->second->controller.get()) |
| 506 return i->second; | 501 return i->second; |
| 507 } | 502 } |
| 508 return NULL; | 503 return NULL; |
| 509 } | 504 } |
| 510 | 505 |
| 511 } // namespace content | 506 } // namespace content |
| OLD | NEW |