[Extensions Toolbar] Make the ExtensionToolbarModel icon count more stable
[chromium-blink-merge.git] / media / base / audio_renderer_mixer_input.h
blobd097aa874ad86e5d0c0847a2ce5ff957ba49308b
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
8 #include <vector>
10 #include "base/callback.h"
11 #include "media/base/audio_converter.h"
12 #include "media/base/audio_renderer_sink.h"
14 namespace media {
16 class AudioRendererMixer;
18 class MEDIA_EXPORT AudioRendererMixerInput
19 : NON_EXPORTED_BASE(public AudioRendererSink),
20 public AudioConverter::InputCallback {
21 public:
22 typedef base::Callback<AudioRendererMixer*(
23 const AudioParameters& params)> GetMixerCB;
24 typedef base::Callback<void(const AudioParameters& params)> RemoveMixerCB;
26 AudioRendererMixerInput(
27 const GetMixerCB& get_mixer_cb, const RemoveMixerCB& remove_mixer_cb);
29 // AudioRendererSink implementation.
30 void Start() override;
31 void Stop() override;
32 void Play() override;
33 void Pause() override;
34 bool SetVolume(double volume) override;
35 void Initialize(const AudioParameters& params,
36 AudioRendererSink::RenderCallback* renderer) override;
38 // Called by AudioRendererMixer when an error occurs.
39 void OnRenderError();
41 protected:
42 ~AudioRendererMixerInput() override;
44 private:
45 friend class AudioRendererMixerInputTest;
47 bool playing_;
48 bool initialized_;
49 double volume_;
51 // AudioConverter::InputCallback implementation.
52 double ProvideInput(AudioBus* audio_bus,
53 base::TimeDelta buffer_delay) override;
55 // Callbacks provided during construction which allow AudioRendererMixerInput
56 // to retrieve a mixer during Initialize() and notify when it's done with it.
57 GetMixerCB get_mixer_cb_;
58 RemoveMixerCB remove_mixer_cb_;
60 // AudioParameters received during Initialize().
61 AudioParameters params_;
63 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(),
64 // guaranteed to live (at least) until |remove_mixer_cb_| is called.
65 AudioRendererMixer* mixer_;
67 // Source of audio data which is provided to the mixer.
68 AudioRendererSink::RenderCallback* callback_;
70 // Error callback for handing to AudioRendererMixer.
71 const base::Closure error_cb_;
73 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput);
76 } // namespace media
78 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_