| 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. | |
| 362 uint32 shared_memory_size = AudioBus::CalculateMemorySize(params); | 360 uint32 shared_memory_size = AudioBus::CalculateMemorySize(params); |
| 363 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); | 361 scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); |
| 364 if (!shared_memory->CreateAndMapAnonymous(shared_memory_size)) { | 362 if (!shared_memory->CreateAndMapAnonymous(shared_memory_size)) { |
| 365 SendErrorMessage(stream_id); | 363 SendErrorMessage(stream_id); |
| 366 return; | 364 return; |
| 367 } | 365 } |
| 368 | 366 |
| 369 scoped_ptr<AudioSyncReader> reader( | 367 scoped_ptr<AudioSyncReader> reader( |
| 370 new AudioSyncReader(shared_memory.get(), params)); | 368 new AudioSyncReader(shared_memory.get(), params)); |
| 371 if (!reader->Init()) { | 369 if (!reader->Init()) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 496 |
| 499 AudioEntryMap::const_iterator i = audio_entries_.find(stream_id); | 497 AudioEntryMap::const_iterator i = audio_entries_.find(stream_id); |
| 500 return i != audio_entries_.end() ? i->second : NULL; | 498 return i != audio_entries_.end() ? i->second : NULL; |
| 501 } | 499 } |
| 502 | 500 |
| 503 bool AudioRendererHost::HasActiveAudio() { | 501 bool AudioRendererHost::HasActiveAudio() { |
| 504 return !base::AtomicRefCountIsZero(&num_playing_streams_); | 502 return !base::AtomicRefCountIsZero(&num_playing_streams_); |
| 505 } | 503 } |
| 506 | 504 |
| 507 } // namespace content | 505 } // namespace content |
| OLD | NEW |