Chromium Code Reviews| 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 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ |
| 6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ | 6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "media/base/audio_converter.h" | 17 #include "media/base/audio_converter.h" |
| 18 #include "media/base/audio_renderer_sink.h" | 18 #include "media/base/audio_renderer_sink.h" |
| 19 #include "media/base/loopback_audio_converter.h" | 19 #include "media/base/loopback_audio_converter.h" |
| 20 | 20 |
| 21 namespace media { | 21 namespace media { |
| 22 | 22 |
| 23 // Mixes a set of AudioConverter::InputCallbacks into a single output stream | 23 // Mixes a set of AudioConverter::InputCallbacks into a single output stream |
| 24 // which is funneled into a single shared AudioRendererSink; saving a bundle | 24 // which is funneled into a single shared AudioRendererSink; saving a bundle |
| 25 // on renderer side resources. | 25 // on renderer side resources. |
| 26 class MEDIA_EXPORT AudioRendererMixer | 26 class MEDIA_EXPORT AudioRendererMixer |
| 27 : NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { | 27 : NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { |
| 28 public: | 28 public: |
| 29 typedef base::Callback<void(AudioRendererSink* sink)> ReleaseSinkCallback; | |
| 30 | |
| 29 AudioRendererMixer(const AudioParameters& output_params, | 31 AudioRendererMixer(const AudioParameters& output_params, |
| 30 const scoped_refptr<AudioRendererSink>& sink); | 32 AudioRendererSink* sink, |
| 33 const ReleaseSinkCallback& release_sink_cb); | |
| 31 ~AudioRendererMixer() override; | 34 ~AudioRendererMixer() override; |
| 32 | 35 |
| 33 // Add or remove a mixer input from mixing; called by AudioRendererMixerInput. | 36 // Add or remove a mixer input from mixing; called by AudioRendererMixerInput. |
| 34 void AddMixerInput(const AudioParameters& input_params, | 37 void AddMixerInput(const AudioParameters& input_params, |
| 35 AudioConverter::InputCallback* input); | 38 AudioConverter::InputCallback* input); |
| 36 void RemoveMixerInput(const AudioParameters& input_params, | 39 void RemoveMixerInput(const AudioParameters& input_params, |
| 37 AudioConverter::InputCallback* input); | 40 AudioConverter::InputCallback* input); |
| 38 | 41 |
| 39 // Since errors may occur even when no inputs are playing, an error callback | 42 // Since errors may occur even when no inputs are playing, an error callback |
| 40 // must be registered separately from adding a mixer input. The same callback | 43 // must be registered separately from adding a mixer input. The same callback |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 57 int Render(AudioBus* audio_bus, | 60 int Render(AudioBus* audio_bus, |
| 58 uint32_t frames_delayed, | 61 uint32_t frames_delayed, |
| 59 uint32_t frames_skipped) override; | 62 uint32_t frames_skipped) override; |
| 60 void OnRenderError() override; | 63 void OnRenderError() override; |
| 61 | 64 |
| 62 bool is_master_sample_rate(int sample_rate) { | 65 bool is_master_sample_rate(int sample_rate) { |
| 63 return sample_rate == output_params_.sample_rate(); | 66 return sample_rate == output_params_.sample_rate(); |
| 64 } | 67 } |
| 65 | 68 |
| 66 // Output sink for this mixer. | 69 // Output sink for this mixer. |
| 67 scoped_refptr<AudioRendererSink> audio_sink_; | 70 AudioRendererSink* audio_sink_; |
|
miu
2016/05/12 21:53:06
Please make this const: AudioRendererSink* const a
o1ka
2016/05/17 17:17:24
Done.
| |
| 71 | |
| 72 // Callback to release the sink on mixer destruction. | |
| 73 const ReleaseSinkCallback release_sink_cb_; | |
| 68 | 74 |
| 69 // Output parameters for this mixer. | 75 // Output parameters for this mixer. |
| 70 AudioParameters output_params_; | 76 AudioParameters output_params_; |
| 71 | 77 |
| 72 // ---------------[ All variables below protected by |lock_| ]--------------- | 78 // ---------------[ All variables below protected by |lock_| ]--------------- |
| 73 base::Lock lock_; | 79 base::Lock lock_; |
| 74 | 80 |
| 75 // List of error callbacks used by this mixer. | 81 // List of error callbacks used by this mixer. |
| 76 typedef std::list<base::Closure> ErrorCallbackList; | 82 typedef std::list<base::Closure> ErrorCallbackList; |
| 77 ErrorCallbackList error_callbacks_; | 83 ErrorCallbackList error_callbacks_; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 90 base::TimeDelta pause_delay_; | 96 base::TimeDelta pause_delay_; |
| 91 base::TimeTicks last_play_time_; | 97 base::TimeTicks last_play_time_; |
| 92 bool playing_; | 98 bool playing_; |
| 93 | 99 |
| 94 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer); | 100 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer); |
| 95 }; | 101 }; |
| 96 | 102 |
| 97 } // namespace media | 103 } // namespace media |
| 98 | 104 |
| 99 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ | 105 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ |
| OLD | NEW |