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
;
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
) {
30 // AudioRendererSink implementation.
31 void Initialize(const AudioParameters
& params
,
32 RenderCallback
* callback
) override
;
33 void Start() override
;
35 void Pause() 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();
50 ~ClocklessAudioSink() override
;
53 scoped_ptr
<ClocklessAudioSinkThread
> thread_
;
58 // Time taken in last set of Render() calls.
59 base::TimeDelta playback_time_
;
61 DISALLOW_COPY_AND_ASSIGN(ClocklessAudioSink
);
66 #endif // MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_