OLD | NEW |
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_AUDIO_NULL_AUDIO_SINK_H_ | 5 #ifndef MEDIA_AUDIO_NULL_AUDIO_SINK_H_ |
6 #define MEDIA_AUDIO_NULL_AUDIO_SINK_H_ | 6 #define MEDIA_AUDIO_NULL_AUDIO_SINK_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "media/base/audio_renderer_sink.h" | 11 #include "media/base/audio_renderer_sink.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class SingleThreadTaskRunner; | 14 class SingleThreadTaskRunner; |
15 } | 15 } |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 class AudioBus; | 18 class AudioBus; |
19 class AudioHash; | 19 class AudioHash; |
20 class FakeAudioConsumer; | 20 class FakeAudioWorker; |
21 | 21 |
22 class MEDIA_EXPORT NullAudioSink | 22 class MEDIA_EXPORT NullAudioSink |
23 : NON_EXPORTED_BASE(public AudioRendererSink) { | 23 : NON_EXPORTED_BASE(public AudioRendererSink) { |
24 public: | 24 public: |
25 NullAudioSink(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 25 NullAudioSink(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
26 | 26 |
27 // AudioRendererSink implementation. | 27 // AudioRendererSink implementation. |
28 void Initialize(const AudioParameters& params, | 28 void Initialize(const AudioParameters& params, |
29 RenderCallback* callback) override; | 29 RenderCallback* callback) override; |
30 void Start() override; | 30 void Start() override; |
31 void Stop() override; | 31 void Stop() override; |
32 void Pause() override; | 32 void Pause() override; |
33 void Play() override; | 33 void Play() override; |
34 bool SetVolume(double volume) override; | 34 bool SetVolume(double volume) override; |
35 | 35 |
36 // Enables audio frame hashing. Must be called prior to Initialize(). | 36 // Enables audio frame hashing. Must be called prior to Initialize(). |
37 void StartAudioHashForTesting(); | 37 void StartAudioHashForTesting(); |
38 | 38 |
39 // Returns the hash of all audio frames seen since construction. | 39 // Returns the hash of all audio frames seen since construction. |
40 std::string GetAudioHashForTesting(); | 40 std::string GetAudioHashForTesting(); |
41 | 41 |
42 protected: | 42 protected: |
43 ~NullAudioSink() override; | 43 ~NullAudioSink() override; |
44 | 44 |
45 private: | 45 private: |
46 // Task that periodically calls Render() to consume audio data. | 46 // Task that periodically calls Render() to consume audio data. |
47 void CallRender(AudioBus* audio_bus); | 47 void CallRender(); |
48 | 48 |
49 bool initialized_; | 49 bool initialized_; |
50 bool playing_; | 50 bool playing_; |
51 RenderCallback* callback_; | 51 RenderCallback* callback_; |
52 | 52 |
53 // Controls whether or not a running hash is computed for audio frames. | 53 // Controls whether or not a running hash is computed for audio frames. |
54 scoped_ptr<AudioHash> audio_hash_; | 54 scoped_ptr<AudioHash> audio_hash_; |
55 | 55 |
56 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 56 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
57 scoped_ptr<FakeAudioConsumer> fake_consumer_; | 57 scoped_ptr<FakeAudioWorker> fake_worker_; |
| 58 scoped_ptr<AudioBus> audio_bus_; |
58 | 59 |
59 DISALLOW_COPY_AND_ASSIGN(NullAudioSink); | 60 DISALLOW_COPY_AND_ASSIGN(NullAudioSink); |
60 }; | 61 }; |
61 | 62 |
62 } // namespace media | 63 } // namespace media |
63 | 64 |
64 #endif // MEDIA_AUDIO_NULL_AUDIO_SINK_H_ | 65 #endif // MEDIA_AUDIO_NULL_AUDIO_SINK_H_ |
OLD | NEW |