Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1395)

Side by Side Diff: content/browser/renderer_host/media/audio_input_renderer_host.cc

Issue 9442005: Clean up audio-related utility functions to compute buffer sizes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase ToT Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_renderer_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/audio/audio_util.h"
16 15
17 using content::BrowserMessageFilter; 16 using content::BrowserMessageFilter;
18 using content::BrowserThread; 17 using content::BrowserThread;
19 18
20 AudioInputRendererHost::AudioEntry::AudioEntry() 19 AudioInputRendererHost::AudioEntry::AudioEntry()
21 : stream_id(0), 20 : stream_id(0),
22 pending_close(false) { 21 pending_close(false) {
23 } 22 }
24 23
25 AudioInputRendererHost::AudioEntry::~AudioEntry() {} 24 AudioInputRendererHost::AudioEntry::~AudioEntry() {}
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void AudioInputRendererHost::OnCreateStream(int stream_id, 201 void AudioInputRendererHost::OnCreateStream(int stream_id,
203 const AudioParameters& params, 202 const AudioParameters& params,
204 const std::string& device_id) { 203 const std::string& device_id) {
205 VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id=" 204 VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id="
206 << stream_id << ")"; 205 << stream_id << ")";
207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
208 DCHECK(LookupById(stream_id) == NULL); 207 DCHECK(LookupById(stream_id) == NULL);
209 208
210 AudioParameters audio_params(params); 209 AudioParameters audio_params(params);
211 210
212 // Select the hardware packet size if not specified. 211 DCHECK_GT(audio_params.samples_per_packet, 0);
213 if (!audio_params.samples_per_packet) {
214 audio_params.samples_per_packet =
215 media::SelectSamplesPerPacket(audio_params.sample_rate);
216 }
217 uint32 packet_size = audio_params.GetPacketSize(); 212 uint32 packet_size = audio_params.GetPacketSize();
218 213
219 // Create a new AudioEntry structure. 214 // Create a new AudioEntry structure.
220 scoped_ptr<AudioEntry> entry(new AudioEntry()); 215 scoped_ptr<AudioEntry> entry(new AudioEntry());
221 216
222 // Create the shared memory and share it with the renderer process 217 // Create the shared memory and share it with the renderer process
223 // using a new SyncWriter object. 218 // using a new SyncWriter object.
224 if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) { 219 if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) {
225 // If creation of shared memory failed then send an error message. 220 // If creation of shared memory failed then send an error message.
226 SendErrorMessage(stream_id); 221 SendErrorMessage(stream_id);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
443 438
444 for (SessionEntryMap::iterator it = session_entries_.begin(); 439 for (SessionEntryMap::iterator it = session_entries_.begin();
445 it != session_entries_.end(); ++it) { 440 it != session_entries_.end(); ++it) {
446 if (stream_id == it->second) { 441 if (stream_id == it->second) {
447 return it->first; 442 return it->first;
448 } 443 }
449 } 444 }
450 return 0; 445 return 0;
451 } 446 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_renderer_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698