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_
10 #include "base/callback.h"
11 #include "media/base/audio_converter.h"
12 #include "media/base/audio_renderer_sink.h"
16 class AudioRendererMixer
;
18 class MEDIA_EXPORT AudioRendererMixerInput
19 : NON_EXPORTED_BASE(public AudioRendererSink
),
20 public AudioConverter::InputCallback
{
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
;
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.
42 ~AudioRendererMixerInput() override
;
45 friend class AudioRendererMixerInputTest
;
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
);
78 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_