| 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 "base/message_loop_proxy.h" |
| 11 #include "media/base/audio_converter.h" | 12 #include "media/base/audio_converter.h" |
| 12 #include "media/base/audio_renderer_sink.h" | 13 #include "media/base/audio_renderer_sink.h" |
| 13 | 14 |
| 14 namespace media { | 15 namespace media { |
| 15 | 16 |
| 16 class AudioRendererMixer; | 17 class AudioRendererMixer; |
| 17 | 18 |
| 18 class MEDIA_EXPORT AudioRendererMixerInput | 19 class MEDIA_EXPORT AudioRendererMixerInput |
| 19 : NON_EXPORTED_BASE(public AudioRendererSink), | 20 : NON_EXPORTED_BASE(public AudioRendererSink), |
| 20 public AudioConverter::InputCallback { | 21 public AudioConverter::InputCallback { |
| 21 public: | 22 public: |
| 22 typedef base::Callback<AudioRendererMixer*( | 23 typedef base::Callback<AudioRendererMixer*( |
| 23 const AudioParameters& params)> GetMixerCB; | 24 const AudioParameters& params)> GetMixerCB; |
| 24 typedef base::Callback<void(const AudioParameters& params)> RemoveMixerCB; | 25 typedef base::Callback<void(AudioRendererMixer*)> RemoveMixerCB; |
| 25 | 26 |
| 26 AudioRendererMixerInput( | 27 AudioRendererMixerInput( |
| 27 const GetMixerCB& get_mixer_cb, const RemoveMixerCB& remove_mixer_cb); | 28 const GetMixerCB& get_mixer_cb, const RemoveMixerCB& remove_mixer_cb); |
| 28 | 29 |
| 29 // AudioRendererSink implementation. | 30 // AudioRendererSink implementation. |
| 30 virtual void Start() OVERRIDE; | 31 virtual void Start() OVERRIDE; |
| 31 virtual void Stop() OVERRIDE; | 32 virtual void Stop() OVERRIDE; |
| 32 virtual void Play() OVERRIDE; | 33 virtual void Play() OVERRIDE; |
| 33 virtual void Pause(bool flush) OVERRIDE; | 34 virtual void Pause(bool flush) OVERRIDE; |
| 34 virtual bool SetVolume(double volume) OVERRIDE; | 35 virtual bool SetVolume(double volume) OVERRIDE; |
| 35 virtual void Initialize(const AudioParameters& params, | 36 virtual void Initialize(const AudioParameters& params, |
| 36 AudioRendererSink::RenderCallback* renderer) OVERRIDE; | 37 AudioRendererSink::RenderCallback* renderer) OVERRIDE; |
| 37 | 38 |
| 38 // Called by AudioRendererMixer when new delay information is available. | 39 // Called by AudioRendererMixer when new delay information is available. |
| 39 void set_audio_delay_milliseconds(int audio_delay_milliseconds) { | 40 void set_audio_delay_milliseconds(int audio_delay_milliseconds) { |
| 40 current_audio_delay_milliseconds_ = audio_delay_milliseconds; | 41 current_audio_delay_milliseconds_ = audio_delay_milliseconds; |
| 41 } | 42 } |
| 42 | 43 |
| 43 // Called by AudioRendererMixer when an error occurs. | 44 // Called by AudioRendererMixer when an error occurs. |
| 44 void OnRenderError(); | 45 void OnRenderError(); |
| 45 | 46 |
| 47 // Called by AudioRendererMixer when a device change occurs. |
| 48 void OnDeviceChange(); |
| 49 |
| 46 protected: | 50 protected: |
| 47 virtual ~AudioRendererMixerInput(); | 51 virtual ~AudioRendererMixerInput(); |
| 48 | 52 |
| 49 private: | 53 private: |
| 50 friend class AudioRendererMixerInputTest; | 54 friend class AudioRendererMixerInputTest; |
| 51 | 55 |
| 52 bool playing_; | 56 bool playing_; |
| 53 bool initialized_; | 57 bool initialized_; |
| 54 double volume_; | 58 double volume_; |
| 55 | 59 |
| 60 void UpdateMixer(); |
| 61 |
| 56 // AudioConverter::InputCallback implementation. | 62 // AudioConverter::InputCallback implementation. |
| 57 virtual double ProvideInput(AudioBus* audio_bus, | 63 virtual double ProvideInput(AudioBus* audio_bus, |
| 58 base::TimeDelta buffer_delay) OVERRIDE; | 64 base::TimeDelta buffer_delay) OVERRIDE; |
| 59 | 65 |
| 60 // Callbacks provided during construction which allow AudioRendererMixerInput | 66 // Callbacks provided during construction which allow AudioRendererMixerInput |
| 61 // to retrieve a mixer during Initialize() and notify when it's done with it. | 67 // to retrieve a mixer during Initialize() and notify when it's done with it. |
| 62 GetMixerCB get_mixer_cb_; | 68 GetMixerCB get_mixer_cb_; |
| 63 RemoveMixerCB remove_mixer_cb_; | 69 RemoveMixerCB remove_mixer_cb_; |
| 64 | 70 |
| 65 // AudioParameters received during Initialize(). | 71 // AudioParameters received during Initialize(). |
| 66 AudioParameters params_; | 72 AudioParameters params_; |
| 67 | 73 |
| 68 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(), | 74 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(), |
| 69 // guaranteed to live (at least) until |remove_mixer_cb_| is called. | 75 // guaranteed to live (at least) until |remove_mixer_cb_| is called. |
| 70 AudioRendererMixer* mixer_; | 76 AudioRendererMixer* mixer_; |
| 71 | 77 |
| 72 // Source of audio data which is provided to the mixer. | 78 // Source of audio data which is provided to the mixer. |
| 73 AudioRendererSink::RenderCallback* callback_; | 79 AudioRendererSink::RenderCallback* callback_; |
| 74 | 80 |
| 75 // The current audio delay as last provided by AudioRendererMixer. | 81 // The current audio delay as last provided by AudioRendererMixer. |
| 76 int current_audio_delay_milliseconds_; | 82 int current_audio_delay_milliseconds_; |
| 77 | 83 |
| 84 // The message loop of pipeline thread which started this input. |
| 85 scoped_refptr<base::MessageLoopProxy> started_on_message_loop_; |
| 86 |
| 78 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput); | 87 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput); |
| 79 }; | 88 }; |
| 80 | 89 |
| 81 } // namespace media | 90 } // namespace media |
| 82 | 91 |
| 83 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ | 92 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ |
| OLD | NEW |