OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/resource_context.h" | 14 #include "content/browser/resource_context.h" |
16 #include "content/common/media/audio_messages.h" | 15 #include "content/common/media/audio_messages.h" |
17 #include "ipc/ipc_logging.h" | 16 #include "ipc/ipc_logging.h" |
| 17 #include "media/audio/audio_util.h" |
18 | 18 |
19 using content::BrowserMessageFilter; | 19 using content::BrowserMessageFilter; |
20 using content::BrowserThread; | 20 using content::BrowserThread; |
21 | 21 |
22 AudioInputRendererHost::AudioEntry::AudioEntry() | 22 AudioInputRendererHost::AudioEntry::AudioEntry() |
23 : stream_id(0), | 23 : stream_id(0), |
24 pending_close(false) { | 24 pending_close(false) { |
25 } | 25 } |
26 | 26 |
27 AudioInputRendererHost::AudioEntry::~AudioEntry() {} | 27 AudioInputRendererHost::AudioEntry::~AudioEntry() {} |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // input stream. | 214 // input stream. |
215 if (!low_latency) { | 215 if (!low_latency) { |
216 NOTREACHED() << "Current implementation only supports low-latency mode."; | 216 NOTREACHED() << "Current implementation only supports low-latency mode."; |
217 return; | 217 return; |
218 } | 218 } |
219 | 219 |
220 AudioParameters audio_params(params); | 220 AudioParameters audio_params(params); |
221 | 221 |
222 // Select the hardware packet size if not specified. | 222 // Select the hardware packet size if not specified. |
223 if (!audio_params.samples_per_packet) { | 223 if (!audio_params.samples_per_packet) { |
224 audio_params.samples_per_packet = SelectSamplesPerPacket(audio_params); | 224 audio_params.samples_per_packet = |
| 225 media::SelectSamplesPerPacket(audio_params.sample_rate); |
225 } | 226 } |
226 uint32 packet_size = audio_params.GetPacketSize(); | 227 uint32 packet_size = audio_params.GetPacketSize(); |
227 | 228 |
228 scoped_ptr<AudioEntry> entry(new AudioEntry()); | 229 scoped_ptr<AudioEntry> entry(new AudioEntry()); |
229 // Create the shared memory and share with the renderer process. | 230 // Create the shared memory and share with the renderer process. |
230 if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) { | 231 if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) { |
231 // If creation of shared memory failed then send an error message. | 232 // If creation of shared memory failed then send an error message. |
232 SendErrorMessage(stream_id); | 233 SendErrorMessage(stream_id); |
233 return; | 234 return; |
234 } | 235 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 446 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
446 | 447 |
447 for (SessionEntryMap::iterator it = session_entries_.begin(); | 448 for (SessionEntryMap::iterator it = session_entries_.begin(); |
448 it != session_entries_.end(); ++it) { | 449 it != session_entries_.end(); ++it) { |
449 if (stream_id == it->second) { | 450 if (stream_id == it->second) { |
450 return it->first; | 451 return it->first; |
451 } | 452 } |
452 } | 453 } |
453 return 0; | 454 return 0; |
454 } | 455 } |
OLD | NEW |