blob: 1c2bf69065982d69d6bc4012b346698d86d6cb75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_
#define MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "media/base/audio_renderer_sink.h"
namespace base {
class SingleThreadTaskRunner;
}
namespace media {
class AudioBus;
class ClocklessAudioSinkThread;
// Implementation of an AudioRendererSink that consumes the audio as fast as
// possible. This class does not support multiple Play()/Pause() events.
class MEDIA_EXPORT ClocklessAudioSink
: NON_EXPORTED_BASE(public AudioRendererSink) {
public:
ClocklessAudioSink();
// AudioRendererSink implementation.
virtual void Initialize(const AudioParameters& params,
RenderCallback* callback) override;
virtual void Start() override;
virtual void Stop() override;
virtual void Pause() override;
virtual void Play() override;
virtual bool SetVolume(double volume) override;
// Returns the time taken to consume all the audio.
base::TimeDelta render_time() { return playback_time_; }
protected:
virtual ~ClocklessAudioSink();
private:
scoped_ptr<ClocklessAudioSinkThread> thread_;
bool initialized_;
bool playing_;
// Time taken in last set of Render() calls.
base::TimeDelta playback_time_;
DISALLOW_COPY_AND_ASSIGN(ClocklessAudioSink);
};
} // namespace media
#endif // MEDIA_AUDIO_CLOCKLESS_AUDIO_SINK_H_
|