• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_
6 #define MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_
7 
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_consumer.h"
12 
13 namespace media {
14 
15 class AudioManagerBase;
16 
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);
24 
25   // AudioOutputStream implementation.
26   virtual bool Open() OVERRIDE;
27   virtual void Start(AudioSourceCallback* callback) OVERRIDE;
28   virtual void Stop() OVERRIDE;
29   virtual void SetVolume(double volume) OVERRIDE;
30   virtual void GetVolume(double* volume) OVERRIDE;
31   virtual void Close() OVERRIDE;
32 
33  private:
34   FakeAudioOutputStream(AudioManagerBase* manager,
35                         const AudioParameters& params);
36   virtual ~FakeAudioOutputStream();
37 
38   // Task that periodically calls OnMoreData() to consume audio data.
39   void CallOnMoreData(AudioBus* audio_bus);
40 
41   AudioManagerBase* audio_manager_;
42   AudioSourceCallback* callback_;
43   FakeAudioConsumer fake_consumer_;
44 
45   DISALLOW_COPY_AND_ASSIGN(FakeAudioOutputStream);
46 };
47 
48 }  // namespace media
49 
50 #endif  // MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_
51