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

Side by Side Diff: media/audio/clockless_audio_sink.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_AUDIO_CLOCKLESS_AUDIO_SINK_H_ 5 #ifndef MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_
6 #define MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_ 6 #define MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_
7 7
8 #include <string>
9
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "base/time/time.h" 11 #include "base/time/time.h"
10 #include "media/base/audio_renderer_sink.h" 12 #include "media/base/audio_renderer_sink.h"
13 #include "url/gurl.h"
11 14
12 namespace base { 15 namespace base {
13 class SingleThreadTaskRunner; 16 class SingleThreadTaskRunner;
14 } 17 }
15 18
16 namespace media { 19 namespace media {
17 class AudioBus; 20 class AudioBus;
18 class ClocklessAudioSinkThread; 21 class ClocklessAudioSinkThread;
19 22
20 // Implementation of an AudioRendererSink that consumes the audio as fast as 23 // Implementation of an AudioRendererSink that consumes the audio as fast as
21 // possible. This class does not support multiple Play()/Pause() events. 24 // possible. This class does not support multiple Play()/Pause() events.
22 class MEDIA_EXPORT ClocklessAudioSink 25 class MEDIA_EXPORT ClocklessAudioSink
23 : NON_EXPORTED_BASE(public AudioRendererSink) { 26 : NON_EXPORTED_BASE(public AudioRendererSink) {
24 public: 27 public:
25 ClocklessAudioSink(); 28 ClocklessAudioSink();
26 29
27 // AudioRendererSink implementation. 30 // AudioRendererSink implementation.
28 void Initialize(const AudioParameters& params, 31 void Initialize(const AudioParameters& params,
29 RenderCallback* callback) override; 32 RenderCallback* callback) override;
30 void Start() override; 33 void Start() override;
31 void Stop() override; 34 void Stop() override;
32 void Pause() override; 35 void Pause() override;
33 void Play() override; 36 void Play() override;
34 bool SetVolume(double volume) override; 37 bool SetVolume(double volume) override;
38 void SwitchOutputDevice(const std::string& device_id,
39 const GURL& security_origin,
40 const base::Callback<void(int)>& callback) override;
35 41
36 // Returns the time taken to consume all the audio. 42 // Returns the time taken to consume all the audio.
37 base::TimeDelta render_time() { return playback_time_; } 43 base::TimeDelta render_time() { return playback_time_; }
38 44
39 protected: 45 protected:
40 ~ClocklessAudioSink() override; 46 ~ClocklessAudioSink() override;
41 47
42 private: 48 private:
43 scoped_ptr<ClocklessAudioSinkThread> thread_; 49 scoped_ptr<ClocklessAudioSinkThread> thread_;
44 bool initialized_; 50 bool initialized_;
45 bool playing_; 51 bool playing_;
46 52
47 // Time taken in last set of Render() calls. 53 // Time taken in last set of Render() calls.
48 base::TimeDelta playback_time_; 54 base::TimeDelta playback_time_;
49 55
50 DISALLOW_COPY_AND_ASSIGN(ClocklessAudioSink); 56 DISALLOW_COPY_AND_ASSIGN(ClocklessAudioSink);
51 }; 57 };
52 58
53 } // namespace media 59 } // namespace media
54 60
55 #endif // MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_ 61 #endif // MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698