OLD | NEW |
---|---|
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" |
11 #include "content/browser/renderer_host/media/audio_common.h" | |
12 #include "content/browser/renderer_host/media/audio_sync_reader.h" | 11 #include "content/browser/renderer_host/media/audio_sync_reader.h" |
13 #include "content/browser/renderer_host/media/media_observer.h" | 12 #include "content/browser/renderer_host/media/media_observer.h" |
14 #include "content/common/media/audio_messages.h" | 13 #include "content/common/media/audio_messages.h" |
15 #include "content/public/browser/resource_context.h" | 14 #include "content/public/browser/resource_context.h" |
16 #include "media/audio/audio_util.h" | 15 #include "media/audio/audio_util.h" |
17 | 16 |
18 using content::BrowserMessageFilter; | 17 using content::BrowserMessageFilter; |
19 using content::BrowserThread; | 18 using content::BrowserThread; |
20 | 19 |
21 AudioRendererHost::AudioEntry::AudioEntry() | 20 AudioRendererHost::AudioEntry::AudioEntry() |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 | 192 |
194 void AudioRendererHost::OnCreateStream( | 193 void AudioRendererHost::OnCreateStream( |
195 int stream_id, const AudioParameters& params) { | 194 int stream_id, const AudioParameters& params) { |
196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
197 DCHECK(LookupById(stream_id) == NULL); | 196 DCHECK(LookupById(stream_id) == NULL); |
198 | 197 |
199 AudioParameters audio_params(params); | 198 AudioParameters audio_params(params); |
200 | 199 |
201 // Select the hardware packet size if not specified. | 200 // Select the hardware packet size if not specified. |
202 if (!audio_params.samples_per_packet) { | 201 if (!audio_params.samples_per_packet) { |
203 audio_params.samples_per_packet = SelectSamplesPerPacket(audio_params); | 202 audio_params.samples_per_packet = |
203 media::SelectSamplesPerPacket(audio_params.sample_rate); | |
204 } | 204 } |
Chris Rogers
2012/02/22 23:08:53
Do we need to handle the case where packet size is
| |
205 uint32 packet_size = audio_params.GetPacketSize(); | 205 uint32 packet_size = audio_params.GetPacketSize(); |
206 | 206 |
207 scoped_ptr<AudioEntry> entry(new AudioEntry()); | 207 scoped_ptr<AudioEntry> entry(new AudioEntry()); |
208 | 208 |
209 // Create the shared memory and share with the renderer process. | 209 // Create the shared memory and share with the renderer process. |
210 uint32 shared_memory_size = | 210 uint32 shared_memory_size = |
211 media::TotalSharedMemorySizeInBytes(packet_size); | 211 media::TotalSharedMemorySizeInBytes(packet_size); |
212 if (!entry->shared_memory.CreateAndMapAnonymous(shared_memory_size)) { | 212 if (!entry->shared_memory.CreateAndMapAnonymous(shared_memory_size)) { |
213 // If creation of shared memory failed then send an error message. | 213 // If creation of shared memory failed then send an error message. |
214 SendErrorMessage(stream_id); | 214 SendErrorMessage(stream_id); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 } | 386 } |
387 return NULL; | 387 return NULL; |
388 } | 388 } |
389 | 389 |
390 MediaObserver* AudioRendererHost::media_observer() { | 390 MediaObserver* AudioRendererHost::media_observer() { |
391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
392 if (!media_observer_) | 392 if (!media_observer_) |
393 media_observer_ = resource_context_->GetMediaObserver(); | 393 media_observer_ = resource_context_->GetMediaObserver(); |
394 return media_observer_; | 394 return media_observer_; |
395 } | 395 } |
OLD | NEW |