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_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 if (!entry->shared_memory()->ShareToProcess(PeerHandle(), | 231 if (!entry->shared_memory()->ShareToProcess(PeerHandle(), |
232 &foreign_memory_handle)) { | 232 &foreign_memory_handle)) { |
233 // If we failed to map and share the shared memory then close the audio | 233 // If we failed to map and share the shared memory then close the audio |
234 // stream and send an error message. | 234 // stream and send an error message. |
235 ReportErrorAndClose(entry->stream_id()); | 235 ReportErrorAndClose(entry->stream_id()); |
236 return; | 236 return; |
237 } | 237 } |
238 | 238 |
239 AudioSyncReader* reader = static_cast<AudioSyncReader*>(entry->reader()); | 239 AudioSyncReader* reader = static_cast<AudioSyncReader*>(entry->reader()); |
240 | 240 |
241 #if defined(OS_WIN) | 241 base::SyncSocket::TransitDescriptor socket_descriptor; |
242 base::SyncSocket::Handle foreign_socket_handle; | |
243 #else | |
244 base::FileDescriptor foreign_socket_handle; | |
245 #endif | |
246 | 242 |
247 // If we failed to prepare the sync socket for the renderer then we fail | 243 // If we failed to prepare the sync socket for the renderer then we fail |
248 // the construction of audio stream. | 244 // the construction of audio stream. |
249 if (!reader->PrepareForeignSocketHandle(PeerHandle(), | 245 if (!reader->PrepareForeignSocket(PeerHandle(), &socket_descriptor)) { |
250 &foreign_socket_handle)) { | |
251 ReportErrorAndClose(entry->stream_id()); | 246 ReportErrorAndClose(entry->stream_id()); |
252 return; | 247 return; |
253 } | 248 } |
254 | 249 |
255 Send(new AudioMsg_NotifyStreamCreated( | 250 Send(new AudioMsg_NotifyStreamCreated( |
256 entry->stream_id(), | 251 entry->stream_id(), foreign_memory_handle, socket_descriptor, |
257 foreign_memory_handle, | |
258 foreign_socket_handle, | |
259 entry->shared_memory()->requested_size())); | 252 entry->shared_memory()->requested_size())); |
260 } | 253 } |
261 | 254 |
262 void AudioRendererHost::DoNotifyStreamStateChanged(int stream_id, | 255 void AudioRendererHost::DoNotifyStreamStateChanged(int stream_id, |
263 bool is_playing) { | 256 bool is_playing) { |
264 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 257 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
265 | 258 |
266 AudioEntry* const entry = LookupById(stream_id); | 259 AudioEntry* const entry = LookupById(stream_id); |
267 if (!entry) | 260 if (!entry) |
268 return; | 261 return; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 489 |
497 AudioEntryMap::const_iterator i = audio_entries_.find(stream_id); | 490 AudioEntryMap::const_iterator i = audio_entries_.find(stream_id); |
498 return i != audio_entries_.end() ? i->second : NULL; | 491 return i != audio_entries_.end() ? i->second : NULL; |
499 } | 492 } |
500 | 493 |
501 bool AudioRendererHost::HasActiveAudio() { | 494 bool AudioRendererHost::HasActiveAudio() { |
502 return !base::AtomicRefCountIsZero(&num_playing_streams_); | 495 return !base::AtomicRefCountIsZero(&num_playing_streams_); |
503 } | 496 } |
504 | 497 |
505 } // namespace content | 498 } // namespace content |
OLD | NEW |