Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: media/audio/fake_audio_input_stream.h

Issue 655713003: Standardize usage of virtual/override/final in media/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/clockless_audio_sink.cc ('k') | media/audio/fake_audio_log_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // A fake implementation of AudioInputStream, useful for testing purpose. 5 // A fake implementation of AudioInputStream, useful for testing purpose.
6 6
7 #ifndef MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ 7 #ifndef MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_
8 #define MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ 8 #define MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "media/audio/audio_io.h" 16 #include "media/audio/audio_io.h"
17 #include "media/audio/audio_parameters.h" 17 #include "media/audio/audio_parameters.h"
18 18
19 namespace media { 19 namespace media {
20 20
21 class AudioBus; 21 class AudioBus;
22 class AudioManagerBase; 22 class AudioManagerBase;
23 23
24 class MEDIA_EXPORT FakeAudioInputStream 24 class MEDIA_EXPORT FakeAudioInputStream
25 : public AudioInputStream { 25 : public AudioInputStream {
26 public: 26 public:
27 static AudioInputStream* MakeFakeStream(AudioManagerBase* manager, 27 static AudioInputStream* MakeFakeStream(AudioManagerBase* manager,
28 const AudioParameters& params); 28 const AudioParameters& params);
29 29
30 virtual bool Open() override; 30 bool Open() override;
31 virtual void Start(AudioInputCallback* callback) override; 31 void Start(AudioInputCallback* callback) override;
32 virtual void Stop() override; 32 void Stop() override;
33 virtual void Close() override; 33 void Close() override;
34 virtual double GetMaxVolume() override; 34 double GetMaxVolume() override;
35 virtual void SetVolume(double volume) override; 35 void SetVolume(double volume) override;
36 virtual double GetVolume() override; 36 double GetVolume() override;
37 virtual bool IsMuted() override; 37 bool IsMuted() override;
38 virtual void SetAutomaticGainControl(bool enabled) override; 38 void SetAutomaticGainControl(bool enabled) override;
39 virtual bool GetAutomaticGainControl() override; 39 bool GetAutomaticGainControl() override;
40 40
41 // Generate one beep sound. This method is called by 41 // Generate one beep sound. This method is called by
42 // FakeVideoCaptureDevice to test audio/video synchronization. 42 // FakeVideoCaptureDevice to test audio/video synchronization.
43 // This is a static method because FakeVideoCaptureDevice is 43 // This is a static method because FakeVideoCaptureDevice is
44 // disconnected from an audio device. This means only one instance of 44 // disconnected from an audio device. This means only one instance of
45 // this class gets to respond, which is okay because we assume there's 45 // this class gets to respond, which is okay because we assume there's
46 // only one stream for this testing purpose. 46 // only one stream for this testing purpose.
47 // TODO(hclam): Make this non-static. To do this we'll need to fix 47 // TODO(hclam): Make this non-static. To do this we'll need to fix
48 // crbug.com/159053 such that video capture device is aware of audio 48 // crbug.com/159053 such that video capture device is aware of audio
49 // input stream. 49 // input stream.
50 static void BeepOnce(); 50 static void BeepOnce();
51 51
52 private: 52 private:
53 FakeAudioInputStream(AudioManagerBase* manager, 53 FakeAudioInputStream(AudioManagerBase* manager,
54 const AudioParameters& params); 54 const AudioParameters& params);
55 55
56 virtual ~FakeAudioInputStream(); 56 ~FakeAudioInputStream() override;
57 57
58 void DoCallback(); 58 void DoCallback();
59 59
60 AudioManagerBase* audio_manager_; 60 AudioManagerBase* audio_manager_;
61 AudioInputCallback* callback_; 61 AudioInputCallback* callback_;
62 scoped_ptr<uint8[]> buffer_; 62 scoped_ptr<uint8[]> buffer_;
63 int buffer_size_; 63 int buffer_size_;
64 AudioParameters params_; 64 AudioParameters params_;
65 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 65 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
66 base::TimeTicks last_callback_time_; 66 base::TimeTicks last_callback_time_;
67 base::TimeDelta callback_interval_; 67 base::TimeDelta callback_interval_;
68 base::TimeDelta interval_from_last_beep_; 68 base::TimeDelta interval_from_last_beep_;
69 int beep_duration_in_buffers_; 69 int beep_duration_in_buffers_;
70 int beep_generated_in_buffers_; 70 int beep_generated_in_buffers_;
71 int beep_period_in_frames_; 71 int beep_period_in_frames_;
72 int frames_elapsed_; 72 int frames_elapsed_;
73 scoped_ptr<media::AudioBus> audio_bus_; 73 scoped_ptr<media::AudioBus> audio_bus_;
74 74
75 // Allows us to run tasks on the FakeAudioInputStream instance which are 75 // Allows us to run tasks on the FakeAudioInputStream instance which are
76 // bound by its lifetime. 76 // bound by its lifetime.
77 base::WeakPtrFactory<FakeAudioInputStream> weak_factory_; 77 base::WeakPtrFactory<FakeAudioInputStream> weak_factory_;
78 78
79 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream); 79 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream);
80 }; 80 };
81 81
82 } // namespace media 82 } // namespace media
83 83
84 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ 84 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_
OLDNEW
« no previous file with comments | « media/audio/clockless_audio_sink.cc ('k') | media/audio/fake_audio_log_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698