Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / media / base / audio_renderer_mixer_input.h
blob06a0de1b037c460e28635527a377c2e053417334
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 <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "media/base/audio_converter.h"
13 #include "media/base/audio_renderer_sink.h"
15 namespace media {
17 class AudioRendererMixer;
19 class MEDIA_EXPORT AudioRendererMixerInput
20 : NON_EXPORTED_BASE(public AudioRendererSink),
21 public AudioConverter::InputCallback {
22 public:
23 typedef base::Callback<AudioRendererMixer*(
24 const AudioParameters& params)> GetMixerCB;
25 typedef base::Callback<void(const AudioParameters& params)> RemoveMixerCB;
27 AudioRendererMixerInput(
28 const GetMixerCB& get_mixer_cb, const RemoveMixerCB& remove_mixer_cb);
30 // AudioRendererSink implementation.
31 void Start() override;
32 void Stop() override;
33 void Play() override;
34 void Pause() override;
35 bool SetVolume(double volume) override;
36 void SwitchOutputDevice(const std::string& device_id,
37 const GURL& security_origin,
38 const SwitchOutputDeviceCB& callback) override;
39 void Initialize(const AudioParameters& params,
40 AudioRendererSink::RenderCallback* renderer) override;
42 // Called by AudioRendererMixer when an error occurs.
43 void OnRenderError();
45 protected:
46 ~AudioRendererMixerInput() override;
48 private:
49 friend class AudioRendererMixerInputTest;
51 bool playing_;
52 bool initialized_;
53 double volume_;
55 // AudioConverter::InputCallback implementation.
56 double ProvideInput(AudioBus* audio_bus,
57 base::TimeDelta buffer_delay) override;
59 // Callbacks provided during construction which allow AudioRendererMixerInput
60 // to retrieve a mixer during Initialize() and notify when it's done with it.
61 GetMixerCB get_mixer_cb_;
62 RemoveMixerCB remove_mixer_cb_;
64 // AudioParameters received during Initialize().
65 AudioParameters params_;
67 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(),
68 // guaranteed to live (at least) until |remove_mixer_cb_| is called.
69 AudioRendererMixer* mixer_;
71 // Source of audio data which is provided to the mixer.
72 AudioRendererSink::RenderCallback* callback_;
74 // Error callback for handing to AudioRendererMixer.
75 const base::Closure error_cb_;
77 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput);
80 } // namespace media
82 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_