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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 virtual void OnError() OVERRIDE; | 67 virtual void OnError() OVERRIDE; |
68 virtual void OnDeviceChange(int new_buffer_size, int new_sample_rate) | 68 virtual void OnDeviceChange(int new_buffer_size, int new_sample_rate) |
69 OVERRIDE; | 69 OVERRIDE; |
70 | 70 |
71 AudioRendererHost* const host_; | 71 AudioRendererHost* const host_; |
72 const int stream_id_; | 72 const int stream_id_; |
73 | 73 |
74 // The routing ID of the source render view. | 74 // The routing ID of the source render view. |
75 const int render_view_id_; | 75 const int render_view_id_; |
76 | 76 |
| 77 // Shared memory for transmission of the audio data. Used by |reader_|. |
| 78 const scoped_ptr<base::SharedMemory> shared_memory_; |
| 79 |
| 80 // The synchronous reader to be used by |controller_|. |
| 81 const scoped_ptr<media::AudioOutputController::SyncReader> reader_; |
| 82 |
77 // The AudioOutputController that manages the audio stream. | 83 // The AudioOutputController that manages the audio stream. |
78 const scoped_refptr<media::AudioOutputController> controller_; | 84 const scoped_refptr<media::AudioOutputController> controller_; |
79 | |
80 // Shared memory for transmission of the audio data. | |
81 const scoped_ptr<base::SharedMemory> shared_memory_; | |
82 | |
83 // The synchronous reader to be used by the controller. | |
84 const scoped_ptr<media::AudioOutputController::SyncReader> reader_; | |
85 }; | 85 }; |
86 | 86 |
87 AudioRendererHost::AudioEntry::AudioEntry( | 87 AudioRendererHost::AudioEntry::AudioEntry( |
88 AudioRendererHost* host, int stream_id, int render_view_id, | 88 AudioRendererHost* host, |
| 89 int stream_id, |
| 90 int render_view_id, |
89 const media::AudioParameters& params, | 91 const media::AudioParameters& params, |
90 const std::string& output_device_id, | 92 const std::string& output_device_id, |
91 scoped_ptr<base::SharedMemory> shared_memory, | 93 scoped_ptr<base::SharedMemory> shared_memory, |
92 scoped_ptr<media::AudioOutputController::SyncReader> reader) | 94 scoped_ptr<media::AudioOutputController::SyncReader> reader) |
93 : host_(host), | 95 : host_(host), |
94 stream_id_(stream_id), | 96 stream_id_(stream_id), |
95 render_view_id_(render_view_id), | 97 render_view_id_(render_view_id), |
96 controller_(media::AudioOutputController::Create( | |
97 host->audio_manager_, this, params, output_device_id, reader.get())), | |
98 shared_memory_(shared_memory.Pass()), | 98 shared_memory_(shared_memory.Pass()), |
99 reader_(reader.Pass()) { | 99 reader_(reader.Pass()), |
| 100 controller_(media::AudioOutputController::Create(host->audio_manager_, |
| 101 this, |
| 102 params, |
| 103 output_device_id, |
| 104 reader_.get())) { |
100 DCHECK(controller_.get()); | 105 DCHECK(controller_.get()); |
101 } | 106 } |
102 | 107 |
103 AudioRendererHost::AudioEntry::~AudioEntry() {} | 108 AudioRendererHost::AudioEntry::~AudioEntry() {} |
104 | 109 |
105 /////////////////////////////////////////////////////////////////////////////// | 110 /////////////////////////////////////////////////////////////////////////////// |
106 // AudioRendererHost implementations. | 111 // AudioRendererHost implementations. |
107 | 112 |
108 AudioRendererHost::AudioRendererHost( | 113 AudioRendererHost::AudioRendererHost( |
109 int render_process_id, | 114 int render_process_id, |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 462 } |
458 | 463 |
459 AudioRendererHost::AudioEntry* AudioRendererHost::LookupById(int stream_id) { | 464 AudioRendererHost::AudioEntry* AudioRendererHost::LookupById(int stream_id) { |
460 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 465 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
461 | 466 |
462 AudioEntryMap::const_iterator i = audio_entries_.find(stream_id); | 467 AudioEntryMap::const_iterator i = audio_entries_.find(stream_id); |
463 return i != audio_entries_.end() ? i->second : NULL; | 468 return i != audio_entries_.end() ? i->second : NULL; |
464 } | 469 } |
465 | 470 |
466 } // namespace content | 471 } // namespace content |
OLD | NEW |