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
56
57
58
59
media / audio / fake_audio_output_stream.h [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_
#define MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "media/audio/android/muteable_audio_output_stream.h"
#include "media/audio/audio_io.h"
#include "media/base/audio_parameters.h"
#include "media/base/fake_audio_worker.h"
namespace media {
class AudioManagerBase;
// A fake implementation of AudioOutputStream. Used for testing and when a real
// audio output device is unavailable or refusing output (e.g. remote desktop).
// Callbacks are driven on the AudioManager's message loop.
class MEDIA_EXPORT FakeAudioOutputStream : public MuteableAudioOutputStream {
public:
static AudioOutputStream* MakeFakeStream(AudioManagerBase* manager,
const AudioParameters& params);
FakeAudioOutputStream(const FakeAudioOutputStream&) = delete;
FakeAudioOutputStream& operator=(const FakeAudioOutputStream&) = delete;
// AudioOutputStream implementation.
bool Open() override;
void Start(AudioSourceCallback* callback) override;
void Stop() override;
void SetVolume(double volume) override;
void GetVolume(double* volume) override;
void Close() override;
void Flush() override;
void SetMute(bool muted) override;
private:
FakeAudioOutputStream(AudioManagerBase* manager,
const AudioParameters& params);
~FakeAudioOutputStream() override;
// Task that periodically calls OnMoreData() to consume audio data.
void CallOnMoreData(base::TimeTicks ideal_time, base::TimeTicks now);
const raw_ptr<AudioManagerBase> audio_manager_;
const base::TimeDelta fixed_data_delay_;
raw_ptr<AudioSourceCallback> callback_;
FakeAudioWorker fake_worker_;
const std::unique_ptr<AudioBus> audio_bus_;
};
} // namespace media
#endif // MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_