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