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

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

Issue 12537014: Make SharedMemory track the size that was actually mapped (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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
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_sync_reader.h" 5 #include "content/browser/renderer_host/media/audio_sync_reader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "base/shared_memory.h" 11 #include "base/shared_memory.h"
12 #include "media/audio/audio_buffers_state.h" 12 #include "media/audio/audio_buffers_state.h"
13 #include "media/audio/audio_parameters.h" 13 #include "media/audio/audio_parameters.h"
14 #include "media/audio/shared_memory_util.h" 14 #include "media/audio/shared_memory_util.h"
15 15
16 using media::AudioBus; 16 using media::AudioBus;
17 17
18 namespace content { 18 namespace content {
19 19
20 AudioSyncReader::AudioSyncReader(base::SharedMemory* shared_memory, 20 AudioSyncReader::AudioSyncReader(base::SharedMemory* shared_memory,
21 const media::AudioParameters& params, 21 const media::AudioParameters& params,
22 int input_channels) 22 int input_channels)
23 : shared_memory_(shared_memory), 23 : shared_memory_(shared_memory),
24 input_channels_(input_channels), 24 input_channels_(input_channels),
25 renderer_callback_count_(0), 25 renderer_callback_count_(0),
26 renderer_missed_callback_count_(0) { 26 renderer_missed_callback_count_(0) {
27 packet_size_ = media::PacketSizeInBytes(shared_memory_->created_size()); 27 packet_size_ = media::PacketSizeInBytes(shared_memory_->requested_size());
28 int input_memory_size = 0; 28 int input_memory_size = 0;
29 int output_memory_size = AudioBus::CalculateMemorySize(params); 29 int output_memory_size = AudioBus::CalculateMemorySize(params);
30 if (input_channels_ > 0) { 30 if (input_channels_ > 0) {
31 // The input storage is after the output storage. 31 // The input storage is after the output storage.
32 int frames = params.frames_per_buffer(); 32 int frames = params.frames_per_buffer();
33 input_memory_size = AudioBus::CalculateMemorySize(input_channels_, frames); 33 input_memory_size = AudioBus::CalculateMemorySize(input_channels_, frames);
34 char* input_data = 34 char* input_data =
35 static_cast<char*>(shared_memory_->memory()) + output_memory_size; 35 static_cast<char*>(shared_memory_->memory()) + output_memory_size;
36 input_bus_ = AudioBus::WrapMemory(input_channels_, frames, input_data); 36 input_bus_ = AudioBus::WrapMemory(input_channels_, frames, input_data);
37 } 37 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 base::FileDescriptor* foreign_handle) { 148 base::FileDescriptor* foreign_handle) {
149 foreign_handle->fd = foreign_socket_->handle(); 149 foreign_handle->fd = foreign_socket_->handle();
150 foreign_handle->auto_close = false; 150 foreign_handle->auto_close = false;
151 if (foreign_handle->fd != -1) 151 if (foreign_handle->fd != -1)
152 return true; 152 return true;
153 return false; 153 return false;
154 } 154 }
155 #endif 155 #endif
156 156
157 } // namespace content 157 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698