Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / media / audio / fake_audio_output_stream.h
blob712a6b92b054eb33bc719ed175f76dd4bd4d74f5
1 // Copyright (c) 2012 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_FAKE_AUDIO_OUTPUT_STREAM_H_
6 #define MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "media/audio/audio_io.h"
10 #include "media/audio/audio_parameters.h"
11 #include "media/audio/fake_audio_worker.h"
13 namespace media {
15 class AudioManagerBase;
17 // A fake implementation of AudioOutputStream. Used for testing and when a real
18 // audio output device is unavailable or refusing output (e.g. remote desktop).
19 // Callbacks are driven on the AudioManager's message loop.
20 class MEDIA_EXPORT FakeAudioOutputStream : public AudioOutputStream {
21 public:
22 static AudioOutputStream* MakeFakeStream(AudioManagerBase* manager,
23 const AudioParameters& params);
25 // AudioOutputStream implementation.
26 bool Open() override;
27 void Start(AudioSourceCallback* callback) override;
28 void Stop() override;
29 void SetVolume(double volume) override;
30 void GetVolume(double* volume) override;
31 void Close() override;
33 private:
34 FakeAudioOutputStream(AudioManagerBase* manager,
35 const AudioParameters& params);
36 ~FakeAudioOutputStream() override;
38 // Task that periodically calls OnMoreData() to consume audio data.
39 void CallOnMoreData();
41 AudioManagerBase* audio_manager_;
42 AudioSourceCallback* callback_;
43 FakeAudioWorker fake_worker_;
44 scoped_ptr<AudioBus> audio_bus_;
46 DISALLOW_COPY_AND_ASSIGN(FakeAudioOutputStream);
49 } // namespace media
51 #endif // MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_