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_
11 #include "base/callback.h"
12 #include "media/base/audio_converter.h"
13 #include "media/base/audio_renderer_sink.h"
17 class AudioRendererMixer
;
19 class MEDIA_EXPORT AudioRendererMixerInput
20 : NON_EXPORTED_BASE(public AudioRendererSink
),
21 public AudioConverter::InputCallback
{
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
;
34 void Pause() override
;
35 bool SetVolume(double volume
) override
;
36 OutputDevice
* GetOutputDevice() override
;
37 void Initialize(const AudioParameters
& params
,
38 AudioRendererSink::RenderCallback
* renderer
) override
;
40 // Called by AudioRendererMixer when an error occurs.
44 ~AudioRendererMixerInput() override
;
47 friend class AudioRendererMixerInputTest
;
53 // AudioConverter::InputCallback implementation.
54 double ProvideInput(AudioBus
* audio_bus
,
55 base::TimeDelta buffer_delay
) override
;
57 // Callbacks provided during construction which allow AudioRendererMixerInput
58 // to retrieve a mixer during Initialize() and notify when it's done with it.
59 GetMixerCB get_mixer_cb_
;
60 RemoveMixerCB remove_mixer_cb_
;
62 // AudioParameters received during Initialize().
63 AudioParameters params_
;
65 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(),
66 // guaranteed to live (at least) until |remove_mixer_cb_| is called.
67 AudioRendererMixer
* mixer_
;
69 // Source of audio data which is provided to the mixer.
70 AudioRendererSink::RenderCallback
* callback_
;
72 // Error callback for handing to AudioRendererMixer.
73 const base::Closure error_cb_
;
75 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput
);
80 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_