OLD | NEW |
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> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 ~FakeAudioInputStream() override; | 58 ~FakeAudioInputStream() override; |
59 | 59 |
60 void DoCallback(); | 60 void DoCallback(); |
61 | 61 |
62 // Opens this stream reading from a |wav_filename| rather than beeping. | 62 // Opens this stream reading from a |wav_filename| rather than beeping. |
63 void OpenInFileMode(const base::FilePath& wav_filename); | 63 void OpenInFileMode(const base::FilePath& wav_filename); |
64 | 64 |
65 // Returns true if the device is playing from a file; false if we're beeping. | 65 // Returns true if the device is playing from a file; false if we're beeping. |
66 bool PlayingFromFile(); | 66 bool PlayingFromFile(); |
67 | 67 |
68 void PlayFileLooping(); | 68 void PlayFile(); |
69 void PlayBeep(); | 69 void PlayBeep(); |
70 | 70 |
71 AudioManagerBase* audio_manager_; | 71 AudioManagerBase* audio_manager_; |
72 AudioInputCallback* callback_; | 72 AudioInputCallback* callback_; |
73 scoped_ptr<uint8[]> buffer_; | 73 scoped_ptr<uint8[]> buffer_; |
74 int buffer_size_; | 74 int buffer_size_; |
75 AudioParameters params_; | 75 AudioParameters params_; |
76 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 76 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
77 base::TimeTicks last_callback_time_; | 77 base::TimeTicks last_callback_time_; |
78 base::TimeDelta callback_interval_; | 78 base::TimeDelta callback_interval_; |
79 base::TimeDelta interval_from_last_beep_; | 79 base::TimeDelta interval_from_last_beep_; |
80 int beep_duration_in_buffers_; | 80 int beep_duration_in_buffers_; |
81 int beep_generated_in_buffers_; | 81 int beep_generated_in_buffers_; |
82 int beep_period_in_frames_; | 82 int beep_period_in_frames_; |
83 scoped_ptr<media::AudioBus> audio_bus_; | 83 scoped_ptr<media::AudioBus> audio_bus_; |
84 scoped_ptr<uint8[]> wav_file_data_; | 84 scoped_ptr<uint8[]> wav_file_data_; |
85 scoped_ptr<media::WavAudioHandler> wav_audio_handler_; | 85 scoped_ptr<media::WavAudioHandler> wav_audio_handler_; |
86 int wav_file_read_pos_; | 86 int wav_file_read_pos_; |
87 | 87 |
88 // Allows us to run tasks on the FakeAudioInputStream instance which are | 88 // Allows us to run tasks on the FakeAudioInputStream instance which are |
89 // bound by its lifetime. | 89 // bound by its lifetime. |
90 base::WeakPtrFactory<FakeAudioInputStream> weak_factory_; | 90 base::WeakPtrFactory<FakeAudioInputStream> weak_factory_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream); | 92 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream); |
93 }; | 93 }; |
94 | 94 |
95 } // namespace media | 95 } // namespace media |
96 | 96 |
97 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ | 97 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ |
OLD | NEW |