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