Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / media / audio / null_audio_sink.h
blob85c7731acfcc3ea11b63ebce72b968c99cd97f0c
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_AUDIO_NULL_AUDIO_SINK_H_
6 #define MEDIA_AUDIO_NULL_AUDIO_SINK_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "media/base/audio_renderer_sink.h"
13 namespace base {
14 class SingleThreadTaskRunner;
17 namespace media {
18 class AudioBus;
19 class AudioHash;
20 class FakeAudioWorker;
21 class OutputDevice;
23 class MEDIA_EXPORT NullAudioSink
24 : NON_EXPORTED_BASE(public AudioRendererSink) {
25 public:
26 NullAudioSink(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
28 // AudioRendererSink implementation.
29 void Initialize(const AudioParameters& params,
30 RenderCallback* callback) override;
31 void Start() override;
32 void Stop() override;
33 void Pause() override;
34 void Play() override;
35 bool SetVolume(double volume) override;
36 OutputDevice* GetOutputDevice() override;
38 // Enables audio frame hashing. Must be called prior to Initialize().
39 void StartAudioHashForTesting();
41 // Returns the hash of all audio frames seen since construction.
42 std::string GetAudioHashForTesting();
44 protected:
45 ~NullAudioSink() override;
47 private:
48 // Task that periodically calls Render() to consume audio data.
49 void CallRender();
51 bool initialized_;
52 bool playing_;
53 RenderCallback* callback_;
55 // Controls whether or not a running hash is computed for audio frames.
56 scoped_ptr<AudioHash> audio_hash_;
58 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
59 scoped_ptr<FakeAudioWorker> fake_worker_;
60 scoped_ptr<AudioBus> audio_bus_;
62 DISALLOW_COPY_AND_ASSIGN(NullAudioSink);
65 } // namespace media
67 #endif // MEDIA_AUDIO_NULL_AUDIO_SINK_H_