Fix for browser_plugin_host_browsertest when embedder is not yet available.
[chromium-blink-merge.git] / media / base / audio_renderer_mixer_input.h
blob6b026cf9c29d62ca09c0900b7e4f9c8f1a73ba58
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 virtual void Start() OVERRIDE;
31 virtual void Stop() OVERRIDE;
32 virtual void Play() OVERRIDE;
33 virtual void Pause() OVERRIDE;
34 virtual bool SetVolume(double volume) OVERRIDE;
35 virtual void Initialize(const AudioParameters& params,
36 AudioRendererSink::RenderCallback* renderer) OVERRIDE;
38 // Called by AudioRendererMixer when an error occurs.
39 void OnRenderError();
41 protected:
42 virtual ~AudioRendererMixerInput();
44 private:
45 friend class AudioRendererMixerInputTest;
47 bool playing_;
48 bool initialized_;
49 double volume_;
51 // AudioConverter::InputCallback implementation.
52 virtual 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 base::Closure error_cb_;
73 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput);
76 } // namespace media
78 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_