Delete unused downloads page asset.
[chromium-blink-merge.git] / media / audio / clockless_audio_sink.h
blob96745a51ed72ffd91864e5007464c3950c056353
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_
6 #define MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "media/base/audio_renderer_sink.h"
14 namespace base {
15 class SingleThreadTaskRunner;
18 namespace media {
19 class AudioBus;
20 class ClocklessAudioSinkThread;
21 class OutputDevice;
23 // Implementation of an AudioRendererSink that consumes the audio as fast as
24 // possible. This class does not support multiple Play()/Pause() events.
25 class MEDIA_EXPORT ClocklessAudioSink
26 : NON_EXPORTED_BASE(public AudioRendererSink) {
27 public:
28 ClocklessAudioSink();
30 // AudioRendererSink implementation.
31 void Initialize(const AudioParameters& params,
32 RenderCallback* callback) override;
33 void Start() override;
34 void Stop() override;
35 void Pause() override;
36 void Play() override;
37 bool SetVolume(double volume) override;
38 OutputDevice* GetOutputDevice() override;
40 // Returns the time taken to consume all the audio.
41 base::TimeDelta render_time() { return playback_time_; }
43 // Enables audio frame hashing. Must be called prior to Initialize().
44 void StartAudioHashForTesting();
46 // Returns the hash of all audio frames seen since construction.
47 std::string GetAudioHashForTesting();
49 protected:
50 ~ClocklessAudioSink() override;
52 private:
53 scoped_ptr<ClocklessAudioSinkThread> thread_;
54 bool initialized_;
55 bool playing_;
56 bool hashing_;
58 // Time taken in last set of Render() calls.
59 base::TimeDelta playback_time_;
61 DISALLOW_COPY_AND_ASSIGN(ClocklessAudioSink);
64 } // namespace media
66 #endif // MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_