Fixed example in MessageLoop::ReleaseSoon comment
[chromium-blink-merge.git] / media / audio / clockless_audio_sink.h
blobbf68896c7aa470e462aff3e0eb3363ccd70aebfe
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 "base/memory/scoped_ptr.h"
9 #include "base/time/time.h"
10 #include "media/base/audio_renderer_sink.h"
12 namespace base {
13 class SingleThreadTaskRunner;
16 namespace media {
17 class AudioBus;
18 class ClocklessAudioSinkThread;
20 // Implementation of an AudioRendererSink that consumes the audio as fast as
21 // possible. This class does not support multiple Play()/Pause() events.
22 class MEDIA_EXPORT ClocklessAudioSink
23 : NON_EXPORTED_BASE(public AudioRendererSink) {
24 public:
25 ClocklessAudioSink();
27 // AudioRendererSink implementation.
28 virtual void Initialize(const AudioParameters& params,
29 RenderCallback* callback) OVERRIDE;
30 virtual void Start() OVERRIDE;
31 virtual void Stop() OVERRIDE;
32 virtual void Pause() OVERRIDE;
33 virtual void Play() OVERRIDE;
34 virtual bool SetVolume(double volume) OVERRIDE;
36 // Returns the time taken to consume all the audio.
37 base::TimeDelta render_time() { return playback_time_; }
39 protected:
40 virtual ~ClocklessAudioSink();
42 private:
43 scoped_ptr<ClocklessAudioSinkThread> thread_;
44 bool initialized_;
45 bool playing_;
47 // Time taken in last set of Render() calls.
48 base::TimeDelta playback_time_;
50 DISALLOW_COPY_AND_ASSIGN(ClocklessAudioSink);
53 } // namespace media
55 #endif // MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_