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