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

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

Issue 243263002: Revert 264647 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1847/src/
Patch Set: Created 6 years, 8 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 | no next file » | 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/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/numerics/safe_math.h"
11 #include "base/process/process.h" 10 #include "base/process/process.h"
12 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
13 #include "content/browser/media/media_internals.h" 12 #include "content/browser/media/media_internals.h"
14 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 13 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
15 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" 14 #include "content/browser/renderer_host/media/audio_input_sync_writer.h"
16 #include "content/browser/renderer_host/media/media_stream_manager.h" 15 #include "content/browser/renderer_host/media/media_stream_manager.h"
17 #include "content/browser/renderer_host/media/web_contents_audio_input_stream.h" 16 #include "content/browser/renderer_host/media/web_contents_audio_input_stream.h"
18 #include "content/browser/renderer_host/media/web_contents_capture_util.h" 17 #include "content/browser/renderer_host/media/web_contents_capture_util.h"
19 #include "media/audio/audio_manager_base.h" 18 #include "media/audio/audio_manager_base.h"
20 19
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 251
253 // Create a new AudioEntry structure. 252 // Create a new AudioEntry structure.
254 scoped_ptr<AudioEntry> entry(new AudioEntry()); 253 scoped_ptr<AudioEntry> entry(new AudioEntry());
255 254
256 const uint32 segment_size = (sizeof(media::AudioInputBufferParameters) + 255 const uint32 segment_size = (sizeof(media::AudioInputBufferParameters) +
257 audio_params.GetBytesPerBuffer()); 256 audio_params.GetBytesPerBuffer());
258 entry->shared_memory_segment_count = config.shared_memory_count; 257 entry->shared_memory_segment_count = config.shared_memory_count;
259 258
260 // Create the shared memory and share it with the renderer process 259 // Create the shared memory and share it with the renderer process
261 // using a new SyncWriter object. 260 // using a new SyncWriter object.
262 base::CheckedNumeric<uint32> size = segment_size; 261 if (!entry->shared_memory.CreateAndMapAnonymous(
263 size *= entry->shared_memory_segment_count; 262 segment_size * entry->shared_memory_segment_count)) {
264 if (!size.IsValid() ||
265 !entry->shared_memory.CreateAndMapAnonymous(size.ValueOrDie())) {
266 // If creation of shared memory failed then send an error message. 263 // If creation of shared memory failed then send an error message.
267 SendErrorMessage(stream_id, SHARED_MEMORY_CREATE_FAILED); 264 SendErrorMessage(stream_id, SHARED_MEMORY_CREATE_FAILED);
268 return; 265 return;
269 } 266 }
270 267
271 scoped_ptr<AudioInputSyncWriter> writer( 268 scoped_ptr<AudioInputSyncWriter> writer(
272 new AudioInputSyncWriter(&entry->shared_memory, 269 new AudioInputSyncWriter(&entry->shared_memory,
273 entry->shared_memory_segment_count)); 270 entry->shared_memory_segment_count));
274 271
275 if (!writer->Init()) { 272 if (!writer->Init()) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // TODO(hclam): Implement a faster look up method. 422 // TODO(hclam): Implement a faster look up method.
426 for (AudioEntryMap::iterator i = audio_entries_.begin(); 423 for (AudioEntryMap::iterator i = audio_entries_.begin();
427 i != audio_entries_.end(); ++i) { 424 i != audio_entries_.end(); ++i) {
428 if (controller == i->second->controller.get()) 425 if (controller == i->second->controller.get())
429 return i->second; 426 return i->second;
430 } 427 }
431 return NULL; 428 return NULL;
432 } 429 }
433 430
434 } // namespace content 431 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698