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/browser_main_loop.h" |
11 #include "content/browser/renderer_host/media/audio_common.h" | 12 #include "content/browser/renderer_host/media/audio_common.h" |
12 #include "content/browser/renderer_host/media/audio_sync_reader.h" | 13 #include "content/browser/renderer_host/media/audio_sync_reader.h" |
13 #include "content/browser/renderer_host/media/media_observer.h" | 14 #include "content/browser/renderer_host/media/media_observer.h" |
14 #include "content/common/media/audio_messages.h" | 15 #include "content/common/media/audio_messages.h" |
15 #include "content/public/browser/resource_context.h" | 16 #include "content/public/browser/resource_context.h" |
16 #include "media/audio/audio_util.h" | 17 #include "media/audio/audio_util.h" |
17 | 18 |
18 using content::BrowserMessageFilter; | 19 using content::BrowserMessageFilter; |
19 using content::BrowserThread; | 20 using content::BrowserThread; |
20 | 21 |
21 AudioRendererHost::AudioEntry::AudioEntry() | 22 AudioRendererHost::AudioEntry::AudioEntry() |
22 : stream_id(0), | 23 : stream_id(0), |
23 pending_close(false) { | 24 pending_close(false) { |
24 } | 25 } |
25 | 26 |
26 AudioRendererHost::AudioEntry::~AudioEntry() {} | 27 AudioRendererHost::AudioEntry::~AudioEntry() {} |
27 | 28 |
28 /////////////////////////////////////////////////////////////////////////////// | 29 /////////////////////////////////////////////////////////////////////////////// |
29 // AudioRendererHost implementations. | 30 // AudioRendererHost implementations. |
30 AudioRendererHost::AudioRendererHost( | 31 AudioRendererHost::AudioRendererHost( |
31 content::ResourceContext* resource_context) | 32 content::ResourceContext* resource_context, |
| 33 AudioManager* audio_manager) |
32 : resource_context_(resource_context), | 34 : resource_context_(resource_context), |
| 35 audio_manager_(audio_manager), |
33 media_observer_(NULL) { | 36 media_observer_(NULL) { |
34 } | 37 } |
35 | 38 |
36 AudioRendererHost::~AudioRendererHost() { | 39 AudioRendererHost::~AudioRendererHost() { |
37 DCHECK(audio_entries_.empty()); | 40 DCHECK(audio_entries_.empty()); |
38 } | 41 } |
39 | 42 |
40 void AudioRendererHost::OnChannelClosing() { | 43 void AudioRendererHost::OnChannelClosing() { |
41 BrowserMessageFilter::OnChannelClosing(); | 44 BrowserMessageFilter::OnChannelClosing(); |
42 | 45 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 224 |
222 if (!reader->Init()) { | 225 if (!reader->Init()) { |
223 SendErrorMessage(stream_id); | 226 SendErrorMessage(stream_id); |
224 return; | 227 return; |
225 } | 228 } |
226 | 229 |
227 // If we have successfully created the SyncReader then assign it to the | 230 // If we have successfully created the SyncReader then assign it to the |
228 // entry and construct an AudioOutputController. | 231 // entry and construct an AudioOutputController. |
229 entry->reader.reset(reader.release()); | 232 entry->reader.reset(reader.release()); |
230 entry->controller = media::AudioOutputController::Create( | 233 entry->controller = media::AudioOutputController::Create( |
231 resource_context_->GetAudioManager(), this, audio_params, | 234 audio_manager_, this, audio_params, entry->reader.get()); |
232 entry->reader.get()); | |
233 | 235 |
234 if (!entry->controller) { | 236 if (!entry->controller) { |
235 SendErrorMessage(stream_id); | 237 SendErrorMessage(stream_id); |
236 return; | 238 return; |
237 } | 239 } |
238 | 240 |
239 // If we have created the controller successfully, create an entry and add it | 241 // If we have created the controller successfully, create an entry and add it |
240 // to the map. | 242 // to the map. |
241 entry->stream_id = stream_id; | 243 entry->stream_id = stream_id; |
242 audio_entries_.insert(std::make_pair(stream_id, entry.release())); | 244 audio_entries_.insert(std::make_pair(stream_id, entry.release())); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 } | 388 } |
387 return NULL; | 389 return NULL; |
388 } | 390 } |
389 | 391 |
390 MediaObserver* AudioRendererHost::media_observer() { | 392 MediaObserver* AudioRendererHost::media_observer() { |
391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
392 if (!media_observer_) | 394 if (!media_observer_) |
393 media_observer_ = resource_context_->GetMediaObserver(); | 395 media_observer_ = resource_context_->GetMediaObserver(); |
394 return media_observer_; | 396 return media_observer_; |
395 } | 397 } |
OLD | NEW |