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

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

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright years 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
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"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void AudioInputRendererHost::OnCreateStream(int stream_id, 201 void AudioInputRendererHost::OnCreateStream(int stream_id,
202 const AudioParameters& params, 202 const AudioParameters& params,
203 const std::string& device_id) { 203 const std::string& device_id) {
204 VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id=" 204 VLOG(1) << "AudioInputRendererHost::OnCreateStream(stream_id="
205 << stream_id << ")"; 205 << stream_id << ")";
206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
207 DCHECK(LookupById(stream_id) == NULL); 207 DCHECK(LookupById(stream_id) == NULL);
208 208
209 AudioParameters audio_params(params); 209 AudioParameters audio_params(params);
210 210
211 DCHECK_GT(audio_params.samples_per_packet, 0); 211 DCHECK_GT(audio_params.frames_per_buffer(), 0);
212 uint32 packet_size = audio_params.GetPacketSize(); 212 uint32 buffer_size = audio_params.GetBytesPerBuffer();
213 213
214 // Create a new AudioEntry structure. 214 // Create a new AudioEntry structure.
215 scoped_ptr<AudioEntry> entry(new AudioEntry()); 215 scoped_ptr<AudioEntry> entry(new AudioEntry());
216 216
217 // Create the shared memory and share it with the renderer process 217 // Create the shared memory and share it with the renderer process
218 // using a new SyncWriter object. 218 // using a new SyncWriter object.
219 if (!entry->shared_memory.CreateAndMapAnonymous(packet_size)) { 219 if (!entry->shared_memory.CreateAndMapAnonymous(buffer_size)) {
220 // If creation of shared memory failed then send an error message. 220 // If creation of shared memory failed then send an error message.
221 SendErrorMessage(stream_id); 221 SendErrorMessage(stream_id);
222 return; 222 return;
223 } 223 }
224 224
225 scoped_ptr<AudioInputSyncWriter> writer( 225 scoped_ptr<AudioInputSyncWriter> writer(
226 new AudioInputSyncWriter(&entry->shared_memory)); 226 new AudioInputSyncWriter(&entry->shared_memory));
227 227
228 if (!writer->Init()) { 228 if (!writer->Init()) {
229 SendErrorMessage(stream_id); 229 SendErrorMessage(stream_id);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 437 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
438 438
439 for (SessionEntryMap::iterator it = session_entries_.begin(); 439 for (SessionEntryMap::iterator it = session_entries_.begin();
440 it != session_entries_.end(); ++it) { 440 it != session_entries_.end(); ++it) {
441 if (stream_id == it->second) { 441 if (stream_id == it->second) {
442 return it->first; 442 return it->first;
443 } 443 }
444 } 444 }
445 return 0; 445 return 0;
446 } 446 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698