Chromium Code Reviews| 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_input_device_manager.h" | 11 #include "content/browser/renderer_host/media/audio_input_device_manager.h" |
| 12 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" | 12 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" |
| 13 #include "content/browser/renderer_host/media/media_stream_manager.h" | 13 #include "content/browser/renderer_host/media/media_stream_manager.h" |
| 14 #include "content/common/media/audio_messages.h" | 14 #include "content/common/media/audio_messages.h" |
| 15 #include "content/public/browser/resource_context.h" | 15 #include "content/public/browser/resource_context.h" |
| 16 #include "media/audio/audio_util.h" | |
| 17 | 16 |
| 18 using content::BrowserMessageFilter; | 17 using content::BrowserMessageFilter; |
| 19 using content::BrowserThread; | 18 using content::BrowserThread; |
| 20 | 19 |
| 21 AudioInputRendererHost::AudioEntry::AudioEntry() | 20 AudioInputRendererHost::AudioEntry::AudioEntry() |
| 22 : stream_id(0), | 21 : stream_id(0), |
| 23 pending_close(false) { | 22 pending_close(false) { |
| 24 } | 23 } |
| 25 | 24 |
| 26 AudioInputRendererHost::AudioEntry::~AudioEntry() {} | 25 AudioInputRendererHost::AudioEntry::~AudioEntry() {} |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 void AudioInputRendererHost::OnCreateStream(int stream_id, | 199 void AudioInputRendererHost::OnCreateStream(int stream_id, |
| 201 const AudioParameters& params, | 200 const AudioParameters& params, |
| 202 const std::string& device_id) { | 201 const std::string& device_id) { |
| 203 VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id=" | 202 VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id=" |
| 204 << stream_id << ")"; | 203 << stream_id << ")"; |
| 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 206 DCHECK(LookupById(stream_id) == NULL); | 205 DCHECK(LookupById(stream_id) == NULL); |
| 207 | 206 |
| 208 AudioParameters audio_params(params); | 207 AudioParameters audio_params(params); |
| 209 | 208 |
| 210 // Select the hardware packet size if not specified. | 209 DCHECK_GT(audio_params.samples_per_packet, 0); |
|
henrika (OOO until Aug 14)
2012/02/23 08:45:35
Nice. Thanks.
| |
| 211 if (!audio_params.samples_per_packet) { | |
| 212 audio_params.samples_per_packet = | |
| 213 media::SelectSamplesPerPacket(audio_params.sample_rate); | |
| 214 } | |
| 215 uint32 packet_size = audio_params.GetPacketSize(); | 210 uint32 packet_size = audio_params.GetPacketSize(); |
| 216 | 211 |
| 217 // Create a new AudioEntry structure. | 212 // Create a new AudioEntry structure. |
| 218 scoped_ptr<AudioEntry> entry(new AudioEntry()); | 213 scoped_ptr<AudioEntry> entry(new AudioEntry()); |
| 219 | 214 |
| 220 // Create the shared memory and share it with the renderer process | 215 // Create the shared memory and share it with the renderer process |
| 221 // using a new SyncWriter object. | 216 // using a new SyncWriter object. |
| 222 if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) { | 217 if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) { |
| 223 // If creation of shared memory failed then send an error message. | 218 // If creation of shared memory failed then send an error message. |
| 224 SendErrorMessage(stream_id); | 219 SendErrorMessage(stream_id); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 434 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 440 | 435 |
| 441 for (SessionEntryMap::iterator it = session_entries_.begin(); | 436 for (SessionEntryMap::iterator it = session_entries_.begin(); |
| 442 it != session_entries_.end(); ++it) { | 437 it != session_entries_.end(); ++it) { |
| 443 if (stream_id == it->second) { | 438 if (stream_id == it->second) { |
| 444 return it->first; | 439 return it->first; |
| 445 } | 440 } |
| 446 } | 441 } |
| 447 return 0; | 442 return 0; |
| 448 } | 443 } |
| OLD | NEW |