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

Side by Side Diff: content/renderer/media/audio_device_thread.cc

Issue 10802005: Add SSE optimizations to AudioRendererMixer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments! 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') | media/base/audio_renderer_mixer.h » ('J')
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/renderer/media/audio_device_thread.h" 5 #include "content/renderer/media/audio_device_thread.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/aligned_memory.h"
Ami GONE FROM CHROMIUM 2012/07/27 17:33:11 CL description says "without the hassle of 32-byte
DaleCurtis 2012/07/27 21:23:42 There I'm specifically referring to versus FFMpeg'
9 #include "base/message_loop.h" 10 #include "base/message_loop.h"
10 #include "base/threading/platform_thread.h" 11 #include "base/threading/platform_thread.h"
11 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
12 #include "media/audio/audio_util.h" 13 #include "media/audio/audio_util.h"
13 14
14 using base::PlatformThread; 15 using base::PlatformThread;
15 16
16 // The actual worker thread implementation. It's very bare bones and much 17 // The actual worker thread implementation. It's very bare bones and much
17 // simpler than SimpleThread (no synchronization in Start, etc) and supports 18 // simpler than SimpleThread (no synchronization in Start, etc) and supports
18 // joining the thread handle asynchronously via a provided message loop even 19 // joining the thread handle asynchronously via a provided message loop even
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 (audio_parameters_.bits_per_sample() / 8) * 179 (audio_parameters_.bits_per_sample() / 8) *
179 samples_per_ms_), 180 samples_per_ms_),
180 shared_memory_(memory, false), 181 shared_memory_(memory, false),
181 memory_length_(memory_length) { 182 memory_length_(memory_length) {
182 CHECK_NE(bytes_per_ms_, 0); // Catch division by zero early. 183 CHECK_NE(bytes_per_ms_, 0); // Catch division by zero early.
183 CHECK_NE(samples_per_ms_, 0); 184 CHECK_NE(samples_per_ms_, 0);
184 } 185 }
185 186
186 AudioDeviceThread::Callback::~Callback() { 187 AudioDeviceThread::Callback::~Callback() {
187 for (size_t i = 0; i < audio_data_.size(); ++i) 188 for (size_t i = 0; i < audio_data_.size(); ++i)
188 delete [] audio_data_[i]; 189 base::AlignedFree(audio_data_[i]);
189 } 190 }
190 191
191 void AudioDeviceThread::Callback::InitializeOnAudioThread() { 192 void AudioDeviceThread::Callback::InitializeOnAudioThread() {
192 DCHECK(audio_data_.empty()); 193 DCHECK(audio_data_.empty());
193 194
194 MapSharedMemory(); 195 MapSharedMemory();
195 DCHECK(shared_memory_.memory() != NULL); 196 DCHECK(shared_memory_.memory() != NULL);
196 197
198 // Allocate buffer with a 16-byte alignment to allow SSE optimizations.
197 audio_data_.reserve(audio_parameters_.channels()); 199 audio_data_.reserve(audio_parameters_.channels());
198 for (int i = 0; i < audio_parameters_.channels(); ++i) { 200 for (int i = 0; i < audio_parameters_.channels(); ++i) {
199 float* channel_data = new float[audio_parameters_.frames_per_buffer()]; 201 audio_data_.push_back(static_cast<float*>(base::AlignedAlloc(
200 audio_data_.push_back(channel_data); 202 sizeof(float) * audio_parameters_.frames_per_buffer(), 16)));
201 } 203 }
202 } 204 }
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_renderer_mixer.h » ('j') | media/base/audio_renderer_mixer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698