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_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "media/base/audio_renderer_sink.h"
15 class SingleThreadTaskRunner
;
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
) {
29 // AudioRendererSink implementation.
30 void Initialize(const AudioParameters
& params
,
31 RenderCallback
* callback
) override
;
32 void Start() override
;
34 void Pause() 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_
; }
45 ~ClocklessAudioSink() override
;
48 scoped_ptr
<ClocklessAudioSinkThread
> thread_
;
52 // Time taken in last set of Render() calls.
53 base::TimeDelta playback_time_
;
55 DISALLOW_COPY_AND_ASSIGN(ClocklessAudioSink
);
60 #endif // MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_