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 // AudioOutputMixer is a class that implements browser-side audio mixer. | 5 // AudioOutputMixer is a class that implements browser-side audio mixer. |
6 // AudioOutputMixer implements both AudioOutputDispatcher and | 6 // AudioOutputMixer implements both AudioOutputDispatcher and |
7 // AudioSourceCallback interfaces. | 7 // AudioSourceCallback interfaces. |
8 | 8 |
9 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_ | 9 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_ |
10 #define MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_ | 10 #define MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_ |
11 | 11 |
12 #include <map> | 12 #include <map> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
19 #include "base/timer.h" | 19 #include "base/timer.h" |
20 #include "media/audio/audio_io.h" | 20 #include "media/audio/audio_io.h" |
21 #include "media/audio/audio_manager.h" | 21 #include "media/audio/audio_manager.h" |
22 #include "media/audio/audio_output_dispatcher.h" | 22 #include "media/audio/audio_output_dispatcher.h" |
23 #include "media/audio/audio_parameters.h" | 23 #include "media/audio/audio_parameters.h" |
| 24 #include "media/base/decoder_buffer.h" |
24 | 25 |
25 namespace media { | 26 namespace media { |
26 | 27 |
27 class MEDIA_EXPORT AudioOutputMixer | 28 class MEDIA_EXPORT AudioOutputMixer |
28 : public AudioOutputDispatcher, | 29 : public AudioOutputDispatcher, |
29 public AudioOutputStream::AudioSourceCallback { | 30 public AudioOutputStream::AudioSourceCallback { |
30 public: | 31 public: |
31 AudioOutputMixer(AudioManager* audio_manager, | 32 AudioOutputMixer(AudioManager* audio_manager, |
32 const AudioParameters& params, | 33 const AudioParameters& params, |
33 const base::TimeDelta& close_delay); | 34 const base::TimeDelta& close_delay); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 int pending_bytes; | 71 int pending_bytes; |
71 }; | 72 }; |
72 typedef std::map<AudioOutputProxy*, ProxyData> ProxyMap; | 73 typedef std::map<AudioOutputProxy*, ProxyData> ProxyMap; |
73 ProxyMap proxies_; | 74 ProxyMap proxies_; |
74 | 75 |
75 // Physical stream for this mixer. | 76 // Physical stream for this mixer. |
76 scoped_ptr<AudioOutputStream> physical_stream_; | 77 scoped_ptr<AudioOutputStream> physical_stream_; |
77 | 78 |
78 // Temporary buffer used when mixing. Allocated in the constructor | 79 // Temporary buffer used when mixing. Allocated in the constructor |
79 // to avoid constant allocation/deallocation in the callback. | 80 // to avoid constant allocation/deallocation in the callback. |
80 scoped_array<uint8> mixer_data_; | 81 scoped_refptr<DecoderBuffer> mixer_data_; |
81 | 82 |
82 // Used to post delayed tasks to ourselves that we cancel inside Shutdown(). | 83 // Used to post delayed tasks to ourselves that we cancel inside Shutdown(). |
83 base::WeakPtrFactory<AudioOutputMixer> weak_this_; | 84 base::WeakPtrFactory<AudioOutputMixer> weak_this_; |
84 base::DelayTimer<AudioOutputMixer> close_timer_; | 85 base::DelayTimer<AudioOutputMixer> close_timer_; |
85 | 86 |
86 // Size of data in all in-flight buffers. | 87 // Size of data in all in-flight buffers. |
87 int pending_bytes_; | 88 int pending_bytes_; |
88 | 89 |
89 DISALLOW_COPY_AND_ASSIGN(AudioOutputMixer); | 90 DISALLOW_COPY_AND_ASSIGN(AudioOutputMixer); |
90 }; | 91 }; |
91 | 92 |
92 } // namespace media | 93 } // namespace media |
93 | 94 |
94 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_ | 95 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_ |
OLD | NEW |