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 // Implementation of AudioInputStream for Mac OS X using the special AUHAL | 5 // Implementation of AudioInputStream for Mac OS X using the special AUHAL |
6 // input Audio Unit present in OS 10.4 and later. | 6 // input Audio Unit present in OS 10.4 and later. |
7 // The AUHAL input Audio Unit is for low-latency audio I/O. | 7 // The AUHAL input Audio Unit is for low-latency audio I/O. |
8 // | 8 // |
9 // Overview of operation: | 9 // Overview of operation: |
10 // | 10 // |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 #include "base/atomicops.h" | 46 #include "base/atomicops.h" |
47 #include "base/cancelable_callback.h" | 47 #include "base/cancelable_callback.h" |
48 #include "base/macros.h" | 48 #include "base/macros.h" |
49 #include "base/memory/weak_ptr.h" | 49 #include "base/memory/weak_ptr.h" |
50 #include "base/threading/thread_checker.h" | 50 #include "base/threading/thread_checker.h" |
51 #include "base/time/time.h" | 51 #include "base/time/time.h" |
52 #include "base/timer/timer.h" | 52 #include "base/timer/timer.h" |
53 #include "media/audio/agc_audio_stream.h" | 53 #include "media/audio/agc_audio_stream.h" |
54 #include "media/audio/audio_io.h" | 54 #include "media/audio/audio_io.h" |
| 55 #include "media/audio/audio_manager.h" |
55 #include "media/base/audio_block_fifo.h" | 56 #include "media/base/audio_block_fifo.h" |
56 #include "media/base/audio_parameters.h" | 57 #include "media/base/audio_parameters.h" |
57 | 58 |
58 namespace media { | 59 namespace media { |
59 | 60 |
60 class AudioBus; | 61 class AudioBus; |
61 class AudioManagerMac; | 62 class AudioManagerMac; |
62 class DataBuffer; | 63 class DataBuffer; |
63 | 64 |
64 class MEDIA_EXPORT AUAudioInputStream | 65 class MEDIA_EXPORT AUAudioInputStream |
65 : public AgcAudioStream<AudioInputStream> { | 66 : public AgcAudioStream<AudioInputStream> { |
66 public: | 67 public: |
67 // The ctor takes all the usual parameters, plus |manager| which is the | 68 // The ctor takes all the usual parameters, plus |manager| which is the |
68 // the audio manager who is creating this object. | 69 // the audio manager who is creating this object. |
69 AUAudioInputStream(AudioManagerMac* manager, | 70 AUAudioInputStream(AudioManagerMac* manager, |
70 const AudioParameters& input_params, | 71 const AudioParameters& input_params, |
71 AudioDeviceID audio_device_id); | 72 AudioDeviceID audio_device_id, |
| 73 const AudioManager::LogCallback& log_callback); |
72 // The dtor is typically called by the AudioManager only and it is usually | 74 // The dtor is typically called by the AudioManager only and it is usually |
73 // triggered by calling AudioInputStream::Close(). | 75 // triggered by calling AudioInputStream::Close(). |
74 ~AUAudioInputStream() override; | 76 ~AUAudioInputStream() override; |
75 | 77 |
76 // Implementation of AudioInputStream. | 78 // Implementation of AudioInputStream. |
77 bool Open() override; | 79 bool Open() override; |
78 void Start(AudioInputCallback* callback) override; | 80 void Start(AudioInputCallback* callback) override; |
79 void Stop() override; | 81 void Stop() override; |
80 void Close() override; | 82 void Close() override; |
81 double GetMaxVolume() override; | 83 double GetMaxVolume() override; |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 319 |
318 // Counts number of times RestartAudio() has been called. The max number of | 320 // Counts number of times RestartAudio() has been called. The max number of |
319 // attempts is restricted by |kMaxNumberOfRestartAttempts|. | 321 // attempts is restricted by |kMaxNumberOfRestartAttempts|. |
320 // Note that this counter is reset to zero after each successful restart. | 322 // Note that this counter is reset to zero after each successful restart. |
321 size_t number_of_restart_attempts_; | 323 size_t number_of_restart_attempts_; |
322 | 324 |
323 // Counts the total number of times RestartAudio() has been called. It is | 325 // Counts the total number of times RestartAudio() has been called. It is |
324 // set to zero once in the constructor and then never reset again. | 326 // set to zero once in the constructor and then never reset again. |
325 size_t total_number_of_restart_attempts_; | 327 size_t total_number_of_restart_attempts_; |
326 | 328 |
| 329 // Callback to send statistics info. |
| 330 AudioManager::LogCallback log_callback_; |
| 331 |
327 // Used to ensure DevicePropertyChangedOnMainThread() is not called when | 332 // Used to ensure DevicePropertyChangedOnMainThread() is not called when |
328 // this object is destroyed. | 333 // this object is destroyed. |
329 // Note that, all member variables should appear before the WeakPtrFactory. | 334 // Note that, all member variables should appear before the WeakPtrFactory. |
330 base::WeakPtrFactory<AUAudioInputStream> weak_factory_; | 335 base::WeakPtrFactory<AUAudioInputStream> weak_factory_; |
331 | 336 |
332 DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream); | 337 DISALLOW_COPY_AND_ASSIGN(AUAudioInputStream); |
333 }; | 338 }; |
334 | 339 |
335 } // namespace media | 340 } // namespace media |
336 | 341 |
337 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_ | 342 #endif // MEDIA_AUDIO_MAC_AUDIO_LOW_LATENCY_INPUT_MAC_H_ |
OLD | NEW |