Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(892)

Side by Side Diff: media/base/audio_renderer_mixer_input.h

Issue 11410012: Collapse AudioRendererMixer and OnMoreDataResampler into AudioTransform. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First draft. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ 6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "media/base/audio_renderer_sink.h" 11 #include "media/base/audio_renderer_sink.h"
12 #include "media/base/audio_transform.h"
12 13
13 namespace media { 14 namespace media {
14 15
15 class AudioRendererMixer; 16 class AudioRendererMixer;
16 17
17 class MEDIA_EXPORT AudioRendererMixerInput 18 class MEDIA_EXPORT AudioRendererMixerInput
18 : NON_EXPORTED_BASE(public AudioRendererSink) { 19 : NON_EXPORTED_BASE(public AudioRendererSink),
20 public AudioTransform::AudioTransformInput {
19 public: 21 public:
20 typedef base::Callback<AudioRendererMixer*( 22 typedef base::Callback<AudioRendererMixer*(
21 const AudioParameters& params)> GetMixerCB; 23 const AudioParameters& params)> GetMixerCB;
22 typedef base::Callback<void(const AudioParameters& params)> RemoveMixerCB; 24 typedef base::Callback<void(const AudioParameters& params)> RemoveMixerCB;
23 25
24 AudioRendererMixerInput( 26 AudioRendererMixerInput(
25 const GetMixerCB& get_mixer_cb, const RemoveMixerCB& remove_mixer_cb); 27 const GetMixerCB& get_mixer_cb, const RemoveMixerCB& remove_mixer_cb);
26 28
27 AudioRendererSink::RenderCallback* callback() { return callback_; }
28 bool playing() { return playing_; }
29
30 // AudioRendererSink implementation. 29 // AudioRendererSink implementation.
31 virtual void Start() OVERRIDE; 30 virtual void Start() OVERRIDE;
32 virtual void Stop() OVERRIDE; 31 virtual void Stop() OVERRIDE;
33 virtual void Play() OVERRIDE; 32 virtual void Play() OVERRIDE;
34 virtual void Pause(bool flush) OVERRIDE; 33 virtual void Pause(bool flush) OVERRIDE;
35 virtual bool SetVolume(double volume) OVERRIDE; 34 virtual bool SetVolume(double volume) OVERRIDE;
36 virtual void Initialize(const AudioParameters& params, 35 virtual void Initialize(const AudioParameters& params,
37 AudioRendererSink::RenderCallback* renderer) OVERRIDE; 36 AudioRendererSink::RenderCallback* renderer) OVERRIDE;
38 37
39 void GetVolume(double* volume); 38 // Called by AudioRendererMixer when new delay information is available.
39 void set_audio_delay_milliseconds(int audio_delay_milliseconds) {
40 current_audio_delay_milliseconds_ = audio_delay_milliseconds;
41 }
42
43 // Called by AudioRendererMixer when an error occurs.
44 void OnRenderError();
40 45
41 protected: 46 protected:
42 virtual ~AudioRendererMixerInput(); 47 virtual ~AudioRendererMixerInput();
43 48
44 private: 49 private:
50 friend class AudioRendererMixerInputTest;
51
45 bool playing_; 52 bool playing_;
46 bool initialized_; 53 bool initialized_;
47 bool started_; 54 bool started_;
48 double volume_; 55 double volume_;
49 56
57 // AudioTransform::ProvideAudioTransformInput implementation.
58 virtual float ProvideAudioTransformInput(
59 AudioBus* audio_bus, base::TimeDelta buffer_delay) OVERRIDE;
60
50 // Callbacks provided during construction which allow AudioRendererMixerInput 61 // Callbacks provided during construction which allow AudioRendererMixerInput
51 // to retrieve a mixer during Initialize() and notify when it's done with it. 62 // to retrieve a mixer during Initialize() and notify when it's done with it.
52 GetMixerCB get_mixer_cb_; 63 GetMixerCB get_mixer_cb_;
53 RemoveMixerCB remove_mixer_cb_; 64 RemoveMixerCB remove_mixer_cb_;
54 65
55 // AudioParameters received during Initialize(). 66 // AudioParameters received during Initialize().
56 AudioParameters params_; 67 AudioParameters params_;
57 68
58 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(), 69 // AudioRendererMixer provided through |get_mixer_cb_| during Initialize(),
59 // guaranteed to live (at least) until |remove_mixer_cb_| is called. 70 // guaranteed to live (at least) until |remove_mixer_cb_| is called.
60 AudioRendererMixer* mixer_; 71 AudioRendererMixer* mixer_;
61 72
62 // Source of audio data which is provided to the mixer. 73 // Source of audio data which is provided to the mixer.
63 AudioRendererSink::RenderCallback* callback_; 74 AudioRendererSink::RenderCallback* callback_;
64 75
76 // The current audio delay as last provided by AudioRendererMixer. Updated on
77 // each ProvideInput() call using |ms_per_frame_|.
78 int current_audio_delay_milliseconds_;
79
65 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput); 80 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput);
66 }; 81 };
67 82
68 } // namespace media 83 } // namespace media
69 84
70 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_ 85 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698