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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 virtual ~FakeAudioInputStream(); | 55 virtual ~FakeAudioInputStream(); |
56 | 56 |
57 void DoCallback(); | 57 void DoCallback(); |
58 | 58 |
59 AudioManagerBase* audio_manager_; | 59 AudioManagerBase* audio_manager_; |
60 AudioInputCallback* callback_; | 60 AudioInputCallback* callback_; |
61 scoped_ptr<uint8[]> buffer_; | 61 scoped_ptr<uint8[]> buffer_; |
62 int buffer_size_; | 62 int buffer_size_; |
63 AudioParameters params_; | 63 AudioParameters params_; |
64 base::Thread thread_; | 64 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
65 base::TimeTicks last_callback_time_; | 65 base::TimeTicks last_callback_time_; |
66 base::TimeDelta callback_interval_; | 66 base::TimeDelta callback_interval_; |
67 base::TimeDelta interval_from_last_beep_; | 67 base::TimeDelta interval_from_last_beep_; |
68 int beep_duration_in_buffers_; | 68 int beep_duration_in_buffers_; |
69 int beep_generated_in_buffers_; | 69 int beep_generated_in_buffers_; |
70 int beep_period_in_frames_; | 70 int beep_period_in_frames_; |
71 int frames_elapsed_; | 71 int frames_elapsed_; |
72 scoped_ptr<media::AudioBus> audio_bus_; | 72 scoped_ptr<media::AudioBus> audio_bus_; |
73 | 73 |
| 74 // Allows us to run tasks on the FakeAudioInputStream instance which are |
| 75 // bound by its lifetime. |
| 76 base::WeakPtrFactory<FakeAudioInputStream> weak_factory_; |
| 77 |
74 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream); | 78 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream); |
75 }; | 79 }; |
76 | 80 |
77 } // namespace media | 81 } // namespace media |
78 | 82 |
79 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ | 83 #endif // MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_ |
OLD | NEW |