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 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.
46 ~AudioRendererMixerInput() override
;
49 friend class AudioRendererMixerInputTest
;
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
);
82 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_