Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / media / audio / clockless_audio_sink.h
blob2251b007c56bfaa1cd327d3afde3258ed9eb8e3f
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;
22 // Implementation of an AudioRendererSink that consumes the audio as fast as
23 // possible. This class does not support multiple Play()/Pause() events.
24 class MEDIA_EXPORT ClocklessAudioSink
25 : NON_EXPORTED_BASE(public AudioRendererSink) {
26 public:
27 ClocklessAudioSink();
29 // AudioRendererSink implementation.
30 void Initialize(const AudioParameters& params,
31 RenderCallback* callback) override;
32 void Start() override;
33 void Stop() override;
34 void Pause() override;
35 void Play() override;
36 bool SetVolume(double volume) override;
37 void SwitchOutputDevice(const std::string& device_id,
38 const GURL& security_origin,
39 const SwitchOutputDeviceCB& callback) override;
41 // Returns the time taken to consume all the audio.
42 base::TimeDelta render_time() { return playback_time_; }
44 protected:
45 ~ClocklessAudioSink() override;
47 private:
48 scoped_ptr<ClocklessAudioSinkThread> thread_;
49 bool initialized_;
50 bool playing_;
52 // Time taken in last set of Render() calls.
53 base::TimeDelta playback_time_;
55 DISALLOW_COPY_AND_ASSIGN(ClocklessAudioSink);
58 } // namespace media
60 #endif // MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_