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

Side by Side Diff: media/audio/audio_device_thread.cc

Issue 10802005: Add SSE optimizations to AudioRendererMixer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix cast truncation. Created 8 years, 4 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 | media/base/audio_renderer_mixer.h » ('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 "media/audio/audio_device_thread.h" 5 #include "media/audio/audio_device_thread.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/aligned_memory.h"
11 #include "base/message_loop.h" 12 #include "base/message_loop.h"
12 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
13 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
14 #include "media/audio/audio_util.h" 15 #include "media/audio/audio_util.h"
15 16
16 using base::PlatformThread; 17 using base::PlatformThread;
17 18
18 namespace media { 19 namespace media {
19 20
20 // The actual worker thread implementation. It's very bare bones and much 21 // The actual worker thread implementation. It's very bare bones and much
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 (audio_parameters_.bits_per_sample() / 8) * 183 (audio_parameters_.bits_per_sample() / 8) *
183 samples_per_ms_), 184 samples_per_ms_),
184 shared_memory_(memory, false), 185 shared_memory_(memory, false),
185 memory_length_(memory_length) { 186 memory_length_(memory_length) {
186 CHECK_NE(bytes_per_ms_, 0); // Catch division by zero early. 187 CHECK_NE(bytes_per_ms_, 0); // Catch division by zero early.
187 CHECK_NE(samples_per_ms_, 0); 188 CHECK_NE(samples_per_ms_, 0);
188 } 189 }
189 190
190 AudioDeviceThread::Callback::~Callback() { 191 AudioDeviceThread::Callback::~Callback() {
191 for (size_t i = 0; i < audio_data_.size(); ++i) 192 for (size_t i = 0; i < audio_data_.size(); ++i)
192 delete [] audio_data_[i]; 193 base::AlignedFree(audio_data_[i]);
193 } 194 }
194 195
195 void AudioDeviceThread::Callback::InitializeOnAudioThread() { 196 void AudioDeviceThread::Callback::InitializeOnAudioThread() {
196 DCHECK(audio_data_.empty()); 197 DCHECK(audio_data_.empty());
197 198
198 MapSharedMemory(); 199 MapSharedMemory();
199 DCHECK(shared_memory_.memory() != NULL); 200 DCHECK(shared_memory_.memory() != NULL);
200 201
202 // Allocate buffer with a 16-byte alignment to allow SSE optimizations.
201 audio_data_.reserve(audio_parameters_.channels()); 203 audio_data_.reserve(audio_parameters_.channels());
202 for (int i = 0; i < audio_parameters_.channels(); ++i) { 204 for (int i = 0; i < audio_parameters_.channels(); ++i) {
203 float* channel_data = new float[audio_parameters_.frames_per_buffer()]; 205 audio_data_.push_back(static_cast<float*>(base::AlignedAlloc(
204 audio_data_.push_back(channel_data); 206 sizeof(float) * audio_parameters_.frames_per_buffer(), 16)));
205 } 207 }
206 } 208 }
207 209
208 } // namespace media. 210 } // namespace media.
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_renderer_mixer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698