| 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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/process.h" | 9 #include "base/process.h" |
| 10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| 11 #include "content/browser/renderer_host/media/audio_common.h" | |
| 12 #include "content/browser/renderer_host/media/audio_input_device_manager.h" | 11 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| 13 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" | 12 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" |
| 14 #include "content/browser/renderer_host/media/media_stream_manager.h" | 13 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 15 #include "content/common/media/audio_messages.h" | 14 #include "content/common/media/audio_messages.h" |
| 15 #include "media/audio/audio_util.h" |
| 16 | 16 |
| 17 using content::BrowserMessageFilter; | 17 using content::BrowserMessageFilter; |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 | 19 |
| 20 AudioInputRendererHost::AudioEntry::AudioEntry() | 20 AudioInputRendererHost::AudioEntry::AudioEntry() |
| 21 : stream_id(0), | 21 : stream_id(0), |
| 22 pending_close(false) { | 22 pending_close(false) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 AudioInputRendererHost::AudioEntry::~AudioEntry() {} | 25 AudioInputRendererHost::AudioEntry::~AudioEntry() {} |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 const std::string& device_id) { | 204 const std::string& device_id) { |
| 205 VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id=" | 205 VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id=" |
| 206 << stream_id << ")"; | 206 << stream_id << ")"; |
| 207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 208 DCHECK(LookupById(stream_id) == NULL); | 208 DCHECK(LookupById(stream_id) == NULL); |
| 209 | 209 |
| 210 AudioParameters audio_params(params); | 210 AudioParameters audio_params(params); |
| 211 | 211 |
| 212 // Select the hardware packet size if not specified. | 212 // Select the hardware packet size if not specified. |
| 213 if (!audio_params.samples_per_packet) { | 213 if (!audio_params.samples_per_packet) { |
| 214 audio_params.samples_per_packet = SelectSamplesPerPacket(audio_params); | 214 audio_params.samples_per_packet = |
| 215 media::SelectSamplesPerPacket(audio_params.sample_rate); |
| 215 } | 216 } |
| 216 uint32 packet_size = audio_params.GetPacketSize(); | 217 uint32 packet_size = audio_params.GetPacketSize(); |
| 217 | 218 |
| 218 // Create a new AudioEntry structure. | 219 // Create a new AudioEntry structure. |
| 219 scoped_ptr<AudioEntry> entry(new AudioEntry()); | 220 scoped_ptr<AudioEntry> entry(new AudioEntry()); |
| 220 | 221 |
| 221 // Create the shared memory and share it with the renderer process | 222 // Create the shared memory and share it with the renderer process |
| 222 // using a new SyncWriter object. | 223 // using a new SyncWriter object. |
| 223 if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) { | 224 if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) { |
| 224 // If creation of shared memory failed then send an error message. | 225 // If creation of shared memory failed then send an error message. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 442 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 442 | 443 |
| 443 for (SessionEntryMap::iterator it = session_entries_.begin(); | 444 for (SessionEntryMap::iterator it = session_entries_.begin(); |
| 444 it != session_entries_.end(); ++it) { | 445 it != session_entries_.end(); ++it) { |
| 445 if (stream_id == it->second) { | 446 if (stream_id == it->second) { |
| 446 return it->first; | 447 return it->first; |
| 447 } | 448 } |
| 448 } | 449 } |
| 449 return 0; | 450 return 0; |
| 450 } | 451 } |
| OLD | NEW |