| 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 #ifndef MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_ | 5 #ifndef MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_ |
| 6 #define MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_ | 6 #define MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_ |
| 7 | 7 |
| 8 #include <AudioToolbox/AudioQueue.h> | 8 #include <AudioToolbox/AudioQueue.h> |
| 9 #include <AudioToolbox/AudioFormat.h> | 9 #include <AudioToolbox/AudioFormat.h> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/time.h" | |
| 13 #include "media/audio/audio_io.h" | 12 #include "media/audio/audio_io.h" |
| 14 #include "media/audio/audio_parameters.h" | 13 #include "media/audio/audio_parameters.h" |
| 15 | 14 |
| 16 namespace media { | 15 namespace media { |
| 17 | 16 |
| 18 class AudioManagerBase; | 17 class AudioManagerBase; |
| 19 | 18 |
| 20 // Implementation of AudioInputStream for Mac OS X using the audio queue service | 19 // Implementation of AudioInputStream for Mac OS X using the audio queue service |
| 21 // present in OS 10.5 and later. Design reflects PCMQueueOutAudioOutputStream. | 20 // present in OS 10.5 and later. Design reflects PCMQueueOutAudioOutputStream. |
| 22 class PCMQueueInAudioInputStream : public AudioInputStream { | 21 class PCMQueueInAudioInputStream : public AudioInputStream { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 UInt32 num_packets, | 55 UInt32 num_packets, |
| 57 const AudioStreamPacketDescription* desc); | 56 const AudioStreamPacketDescription* desc); |
| 58 | 57 |
| 59 // Handles callback from OS. Will be called on OS internal thread. | 58 // Handles callback from OS. Will be called on OS internal thread. |
| 60 void HandleInputBuffer(AudioQueueRef audio_queue, | 59 void HandleInputBuffer(AudioQueueRef audio_queue, |
| 61 AudioQueueBufferRef audio_buffer, | 60 AudioQueueBufferRef audio_buffer, |
| 62 const AudioTimeStamp* start_time, | 61 const AudioTimeStamp* start_time, |
| 63 UInt32 num_packets, | 62 UInt32 num_packets, |
| 64 const AudioStreamPacketDescription* packet_desc); | 63 const AudioStreamPacketDescription* packet_desc); |
| 65 | 64 |
| 66 static const int kNumberBuffers = 3; | 65 static const int kNumberBuffers = 1; |
| 67 | 66 |
| 68 // Manager that owns this stream, used for closing down. | 67 // Manager that owns this stream, used for closing down. |
| 69 AudioManagerBase* manager_; | 68 AudioManagerBase* manager_; |
| 70 // We use the callback mostly to periodically supply the recorded audio data. | 69 // We use the callback mostly to periodically supply the recorded audio data. |
| 71 AudioInputCallback* callback_; | 70 AudioInputCallback* callback_; |
| 72 // Structure that holds the stream format details such as bitrate. | 71 // Structure that holds the stream format details such as bitrate. |
| 73 AudioStreamBasicDescription format_; | 72 AudioStreamBasicDescription format_; |
| 74 // Handle to the OS audio queue object. | 73 // Handle to the OS audio queue object. |
| 75 AudioQueueRef audio_queue_; | 74 AudioQueueRef audio_queue_; |
| 76 // Size of each of the buffers in |audio_buffers_| | 75 // Size of each of the buffers in |audio_buffers_| |
| 77 uint32 buffer_size_bytes_; | 76 uint32 buffer_size_bytes_; |
| 78 // True iff Start() has been called successfully. | 77 // True iff Start() has been called successfully. |
| 79 bool started_; | 78 bool started_; |
| 80 // Used to determine if we need to slow down |callback_| calls. | |
| 81 base::Time last_fill_; | |
| 82 | 79 |
| 83 DISALLOW_COPY_AND_ASSIGN(PCMQueueInAudioInputStream); | 80 DISALLOW_COPY_AND_ASSIGN(PCMQueueInAudioInputStream); |
| 84 }; | 81 }; |
| 85 | 82 |
| 86 } // namespace media | 83 } // namespace media |
| 87 | 84 |
| 88 #endif // MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_ | 85 #endif // MEDIA_AUDIO_MAC_AUDIO_INPUT_MAC_H_ |
| OLD | NEW |