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

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

Issue 1122393004: Add support for switching the audio output device for HTMLMediaElements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to MediaPlayers so that they invoke callbacks in the correct threads. First complete implem… Created 5 years, 6 months 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
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_H_ 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ 6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string>
9 10
10 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "media/base/audio_converter.h" 13 #include "media/base/audio_converter.h"
13 #include "media/base/audio_renderer_sink.h" 14 #include "media/base/audio_renderer_sink.h"
15 #include "url/gurl.h"
14 16
15 namespace media { 17 namespace media {
16 18
17 // Mixes a set of AudioConverter::InputCallbacks into a single output stream 19 // Mixes a set of AudioConverter::InputCallbacks into a single output stream
18 // which is funneled into a single shared AudioRendererSink; saving a bundle 20 // which is funneled into a single shared AudioRendererSink; saving a bundle
19 // on renderer side resources. 21 // on renderer side resources.
20 class MEDIA_EXPORT AudioRendererMixer 22 class MEDIA_EXPORT AudioRendererMixer
21 : NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { 23 : NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) {
22 public: 24 public:
23 AudioRendererMixer(const AudioParameters& input_params, 25 AudioRendererMixer(const AudioParameters& input_params,
24 const AudioParameters& output_params, 26 const AudioParameters& output_params,
25 const scoped_refptr<AudioRendererSink>& sink); 27 const scoped_refptr<AudioRendererSink>& sink);
26 ~AudioRendererMixer() override; 28 ~AudioRendererMixer() override;
27 29
28 // Add or remove a mixer input from mixing; called by AudioRendererMixerInput. 30 // Add or remove a mixer input from mixing; called by AudioRendererMixerInput.
29 void AddMixerInput(AudioConverter::InputCallback* input); 31 void AddMixerInput(AudioConverter::InputCallback* input);
30 void RemoveMixerInput(AudioConverter::InputCallback* input); 32 void RemoveMixerInput(AudioConverter::InputCallback* input);
31 33
32 // Since errors may occur even when no inputs are playing, an error callback 34 // Since errors may occur even when no inputs are playing, an error callback
33 // must be registered separately from adding a mixer input. The same callback 35 // must be registered separately from adding a mixer input. The same callback
34 // must be given to both the functions. 36 // must be given to both the functions.
35 void AddErrorCallback(const base::Closure& error_cb); 37 void AddErrorCallback(const base::Closure& error_cb);
36 void RemoveErrorCallback(const base::Closure& error_cb); 38 void RemoveErrorCallback(const base::Closure& error_cb);
37 39
38 void set_pause_delay_for_testing(base::TimeDelta delay) { 40 void set_pause_delay_for_testing(base::TimeDelta delay) {
39 pause_delay_ = delay; 41 pause_delay_ = delay;
40 } 42 }
41 43
44 void SwitchOutputDevice(const std::string& device_id,
45 const GURL& security_origin,
46 const base::Callback<void(int)>& callback);
47
42 private: 48 private:
43 // AudioRendererSink::RenderCallback implementation. 49 // AudioRendererSink::RenderCallback implementation.
44 int Render(AudioBus* audio_bus, int audio_delay_milliseconds) override; 50 int Render(AudioBus* audio_bus, int audio_delay_milliseconds) override;
45 void OnRenderError() override; 51 void OnRenderError() override;
46 52
47 // Output sink for this mixer. 53 // Output sink for this mixer.
48 scoped_refptr<AudioRendererSink> audio_sink_; 54 scoped_refptr<AudioRendererSink> audio_sink_;
49 55
50 // ---------------[ All variables below protected by |lock_| ]--------------- 56 // ---------------[ All variables below protected by |lock_| ]---------------
51 base::Lock lock_; 57 base::Lock lock_;
(...skipping 10 matching lines...) Expand all
62 base::TimeDelta pause_delay_; 68 base::TimeDelta pause_delay_;
63 base::TimeTicks last_play_time_; 69 base::TimeTicks last_play_time_;
64 bool playing_; 70 bool playing_;
65 71
66 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer); 72 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer);
67 }; 73 };
68 74
69 } // namespace media 75 } // namespace media
70 76
71 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ 77 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698