| 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_INPUT_H_ | 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ |
| 6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ | 6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "media/base/audio_converter.h" | 11 #include "media/base/audio_converter.h" |
| 12 #include "media/base/audio_renderer_sink.h" | 12 #include "media/base/audio_renderer_sink.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 class AudioRendererMixer; | 16 class AudioRendererMixer; |
| 17 | 17 |
| 18 class MEDIA_EXPORT AudioRendererMixerInput | 18 class MEDIA_EXPORT AudioRendererMixerInput |
| 19 : NON_EXPORTED_BASE(public AudioRendererSink), | 19 : NON_EXPORTED_BASE(public AudioRendererSink), |
| 20 public AudioConverter::InputCallback { | 20 public AudioConverter::InputCallback { |
| 21 public: | 21 public: |
| 22 typedef base::Callback<AudioRendererMixer*( | 22 typedef base::Callback<AudioRendererMixer*( |
| 23 const AudioParameters& params)> GetMixerCB; | 23 const AudioParameters& params)> GetMixerCB; |
| 24 typedef base::Callback<void(const AudioParameters& params)> RemoveMixerCB; | 24 typedef base::Callback<void(const AudioParameters& params)> RemoveMixerCB; |
| 25 | 25 |
| 26 AudioRendererMixerInput( | 26 AudioRendererMixerInput( |
| 27 const GetMixerCB& get_mixer_cb, const RemoveMixerCB& remove_mixer_cb); | 27 const GetMixerCB& get_mixer_cb, const RemoveMixerCB& remove_mixer_cb); |
| 28 | 28 |
| 29 // AudioRendererSink implementation. | 29 // AudioRendererSink implementation. |
| 30 virtual void Start() OVERRIDE; | 30 virtual void Start() override; |
| 31 virtual void Stop() OVERRIDE; | 31 virtual void Stop() override; |
| 32 virtual void Play() OVERRIDE; | 32 virtual void Play() override; |
| 33 virtual void Pause() OVERRIDE; | 33 virtual void Pause() override; |
| 34 virtual bool SetVolume(double volume) OVERRIDE; | 34 virtual bool SetVolume(double volume) override; |
| 35 virtual void Initialize(const AudioParameters& params, | 35 virtual void Initialize(const AudioParameters& params, |
| 36 AudioRendererSink::RenderCallback* renderer) OVERRIDE; | 36 AudioRendererSink::RenderCallback* renderer) override; |
| 37 | 37 |
| 38 // Called by AudioRendererMixer when an error occurs. | 38 // Called by AudioRendererMixer when an error occurs. |
| 39 void OnRenderError(); | 39 void OnRenderError(); |
| 40 | 40 |
| 41 protected: | 41 protected: |
| 42 virtual ~AudioRendererMixerInput(); | 42 virtual ~AudioRendererMixerInput(); |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 friend class AudioRendererMixerInputTest; | 45 friend class AudioRendererMixerInputTest; |
| 46 | 46 |
| 47 bool playing_; | 47 bool playing_; |
| 48 bool initialized_; | 48 bool initialized_; |
| 49 double volume_; | 49 double volume_; |
| 50 | 50 |
| 51 // AudioConverter::InputCallback implementation. | 51 // AudioConverter::InputCallback implementation. |
| 52 virtual double ProvideInput(AudioBus* audio_bus, | 52 virtual double ProvideInput(AudioBus* audio_bus, |
| 53 base::TimeDelta buffer_delay) OVERRIDE; | 53 base::TimeDelta buffer_delay) override; |
| 54 | 54 |
| 55 // Callbacks provided during construction which allow AudioRendererMixerInput | 55 // Callbacks provided during construction which allow AudioRendererMixerInput |
| 56 // to retrieve a mixer during Initialize() and notify when it's done with it. | 56 // to retrieve a mixer during Initialize() and notify when it's done with it. |
| 57 GetMixerCB get_mixer_cb_; | 57 GetMixerCB get_mixer_cb_; |
| 58 RemoveMixerCB remove_mixer_cb_; | 58 RemoveMixerCB remove_mixer_cb_; |
| 59 | 59 |
| 60 // AudioParameters received during Initialize(). | 60 // AudioParameters received during Initialize(). |
| 61 AudioParameters params_; | 61 AudioParameters params_; |
| 62 | 62 |
| 63 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(), | 63 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(), |
| 64 // guaranteed to live (at least) until |remove_mixer_cb_| is called. | 64 // guaranteed to live (at least) until |remove_mixer_cb_| is called. |
| 65 AudioRendererMixer* mixer_; | 65 AudioRendererMixer* mixer_; |
| 66 | 66 |
| 67 // Source of audio data which is provided to the mixer. | 67 // Source of audio data which is provided to the mixer. |
| 68 AudioRendererSink::RenderCallback* callback_; | 68 AudioRendererSink::RenderCallback* callback_; |
| 69 | 69 |
| 70 // Error callback for handing to AudioRendererMixer. | 70 // Error callback for handing to AudioRendererMixer. |
| 71 const base::Closure error_cb_; | 71 const base::Closure error_cb_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput); | 73 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // namespace media | 76 } // namespace media |
| 77 | 77 |
| 78 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ | 78 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ |
| OLD | NEW |