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