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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 // Initialize the |output_device_id| to an empty string which indicates that | 350 // Initialize the |output_device_id| to an empty string which indicates that |
351 // the default device should be used. If a StreamDeviceInfo instance was found | 351 // the default device should be used. If a StreamDeviceInfo instance was found |
352 // though, then we use the matched output device. | 352 // though, then we use the matched output device. |
353 std::string output_device_id; | 353 std::string output_device_id; |
354 const StreamDeviceInfo* info = media_stream_manager_-> | 354 const StreamDeviceInfo* info = media_stream_manager_-> |
355 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); | 355 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); |
356 if (info) | 356 if (info) |
357 output_device_id = info->device.matched_output_device_id; | 357 output_device_id = info->device.matched_output_device_id; |
358 | 358 |
359 // Create the shared memory and share with the renderer process. | 359 // Create the shared memory and share with the renderer process. |
| 360 // For synchronized I/O (if input_channels > 0) then we allocate |
| 361 // extra memory after the output data for the input data. |
360 uint32 shared_memory_size = AudioBus::CalculateMemorySize(params); | 362 uint32 shared_memory_size = AudioBus::CalculateMemorySize(params); |
361 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); | 363 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); |
362 if (!shared_memory->CreateAndMapAnonymous(shared_memory_size)) { | 364 if (!shared_memory->CreateAndMapAnonymous(shared_memory_size)) { |
363 SendErrorMessage(stream_id); | 365 SendErrorMessage(stream_id); |
364 return; | 366 return; |
365 } | 367 } |
366 | 368 |
367 scoped_ptr<AudioSyncReader> reader( | 369 scoped_ptr<AudioSyncReader> reader( |
368 new AudioSyncReader(shared_memory.get(), params)); | 370 new AudioSyncReader(shared_memory.get(), params)); |
369 if (!reader->Init()) { | 371 if (!reader->Init()) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 498 |
497 AudioEntryMap::const_iterator i = audio_entries_.find(stream_id); | 499 AudioEntryMap::const_iterator i = audio_entries_.find(stream_id); |
498 return i != audio_entries_.end() ? i->second : NULL; | 500 return i != audio_entries_.end() ? i->second : NULL; |
499 } | 501 } |
500 | 502 |
501 bool AudioRendererHost::HasActiveAudio() { | 503 bool AudioRendererHost::HasActiveAudio() { |
502 return !base::AtomicRefCountIsZero(&num_playing_streams_); | 504 return !base::AtomicRefCountIsZero(&num_playing_streams_); |
503 } | 505 } |
504 | 506 |
505 } // namespace content | 507 } // namespace content |
OLD | NEW |