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

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

Issue 9442005: Clean up audio-related utility functions to compute buffer sizes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 return handled; 190 return handled;
191 } 191 }
192 192
193 void AudioRendererHost::OnCreateStream( 193 void AudioRendererHost::OnCreateStream(
194 int stream_id, const AudioParameters& params) { 194 int stream_id, const AudioParameters& params) {
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
196 DCHECK(LookupById(stream_id) == NULL); 196 DCHECK(LookupById(stream_id) == NULL);
197 197
198 AudioParameters audio_params(params); 198 AudioParameters audio_params(params);
199 DCHECK_GT(audio_params.samples_per_packet, 0);
scherkus (not reviewing) 2012/02/23 18:27:43 does it make sense to move this DCHECK into AudioP
Chris Rogers 2012/02/23 19:00:21 Is there any way to signal an error and return ear
vrk (LEFT CHROMIUM) 2012/02/23 22:33:18 Hmmmmmm! Well, so if the only change that was mad
vrk (LEFT CHROMIUM) 2012/02/23 22:33:18 So, we could add if (audio_params.samples_per_pa
scherkus (not reviewing) 2012/02/23 23:49:09 Sounds like something worth investigating post-com
199 200
200 // Select the hardware packet size if not specified.
201 if (!audio_params.samples_per_packet) {
202 audio_params.samples_per_packet =
203 media::SelectSamplesPerPacket(audio_params.sample_rate);
204 }
205 uint32 packet_size = audio_params.GetPacketSize(); 201 uint32 packet_size = audio_params.GetPacketSize();
206 202
207 scoped_ptr<AudioEntry> entry(new AudioEntry()); 203 scoped_ptr<AudioEntry> entry(new AudioEntry());
208 204
209 // Create the shared memory and share with the renderer process. 205 // Create the shared memory and share with the renderer process.
210 uint32 shared_memory_size = 206 uint32 shared_memory_size =
211 media::TotalSharedMemorySizeInBytes(packet_size); 207 media::TotalSharedMemorySizeInBytes(packet_size);
212 if (!entry->shared_memory.CreateAndMapAnonymous(shared_memory_size)) { 208 if (!entry->shared_memory.CreateAndMapAnonymous(shared_memory_size)) {
213 // If creation of shared memory failed then send an error message. 209 // If creation of shared memory failed then send an error message.
214 SendErrorMessage(stream_id); 210 SendErrorMessage(stream_id);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 382 }
387 return NULL; 383 return NULL;
388 } 384 }
389 385
390 MediaObserver* AudioRendererHost::media_observer() { 386 MediaObserver* AudioRendererHost::media_observer() {
391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 387 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
392 if (!media_observer_) 388 if (!media_observer_)
393 media_observer_ = resource_context_->GetMediaObserver(); 389 media_observer_ = resource_context_->GetMediaObserver();
394 return media_observer_; 390 return media_observer_;
395 } 391 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698