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 #include "media/audio/mac/audio_input_mac.h" | 5 #include "media/audio/mac/audio_input_mac.h" |
6 | 6 |
7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 void PCMQueueInAudioInputStream::SetVolume(double volume) { | 121 void PCMQueueInAudioInputStream::SetVolume(double volume) { |
122 NOTREACHED() << "Only supported for low-latency mode."; | 122 NOTREACHED() << "Only supported for low-latency mode."; |
123 } | 123 } |
124 | 124 |
125 double PCMQueueInAudioInputStream::GetVolume() { | 125 double PCMQueueInAudioInputStream::GetVolume() { |
126 NOTREACHED() << "Only supported for low-latency mode."; | 126 NOTREACHED() << "Only supported for low-latency mode."; |
127 return 0.0; | 127 return 0.0; |
128 } | 128 } |
129 | 129 |
| 130 void PCMQueueInAudioInputStream::SetAutomaticGainControl(bool enabled) { |
| 131 NOTREACHED() << "Only supported for low-latency mode."; |
| 132 } |
| 133 |
| 134 bool PCMQueueInAudioInputStream::GetAutomaticGainControl() { |
| 135 NOTREACHED() << "Only supported for low-latency mode."; |
| 136 return false; |
| 137 } |
| 138 |
130 void PCMQueueInAudioInputStream::HandleError(OSStatus err) { | 139 void PCMQueueInAudioInputStream::HandleError(OSStatus err) { |
131 if (callback_) | 140 if (callback_) |
132 callback_->OnError(this, static_cast<int>(err)); | 141 callback_->OnError(this, static_cast<int>(err)); |
133 NOTREACHED() << "error " << GetMacOSStatusErrorString(err) | 142 NOTREACHED() << "error " << GetMacOSStatusErrorString(err) |
134 << " (" << err << ")"; | 143 << " (" << err << ")"; |
135 } | 144 } |
136 | 145 |
137 bool PCMQueueInAudioInputStream::SetupBuffers() { | 146 bool PCMQueueInAudioInputStream::SetupBuffers() { |
138 DCHECK(buffer_size_bytes_); | 147 DCHECK(buffer_size_bytes_); |
139 for (int i = 0; i < kNumberBuffers; ++i) { | 148 for (int i = 0; i < kNumberBuffers; ++i) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 if (!callback_) { | 191 if (!callback_) { |
183 // This can happen if Stop() was called without start. | 192 // This can happen if Stop() was called without start. |
184 DCHECK_EQ(0U, audio_buffer->mAudioDataByteSize); | 193 DCHECK_EQ(0U, audio_buffer->mAudioDataByteSize); |
185 return; | 194 return; |
186 } | 195 } |
187 | 196 |
188 if (audio_buffer->mAudioDataByteSize) | 197 if (audio_buffer->mAudioDataByteSize) |
189 callback_->OnData(this, | 198 callback_->OnData(this, |
190 reinterpret_cast<const uint8*>(audio_buffer->mAudioData), | 199 reinterpret_cast<const uint8*>(audio_buffer->mAudioData), |
191 audio_buffer->mAudioDataByteSize, | 200 audio_buffer->mAudioDataByteSize, |
192 audio_buffer->mAudioDataByteSize); | 201 audio_buffer->mAudioDataByteSize, |
| 202 0.0); |
193 // Recycle the buffer. | 203 // Recycle the buffer. |
194 OSStatus err = QueueNextBuffer(audio_buffer); | 204 OSStatus err = QueueNextBuffer(audio_buffer); |
195 if (err != noErr) { | 205 if (err != noErr) { |
196 if (err == kAudioQueueErr_EnqueueDuringReset) { | 206 if (err == kAudioQueueErr_EnqueueDuringReset) { |
197 // This is the error you get if you try to enqueue a buffer and the | 207 // This is the error you get if you try to enqueue a buffer and the |
198 // queue has been closed. Not really a problem if indeed the queue | 208 // queue has been closed. Not really a problem if indeed the queue |
199 // has been closed. | 209 // has been closed. |
200 // TODO(joth): PCMQueueOutAudioOutputStream uses callback_ to provide an | 210 // TODO(joth): PCMQueueOutAudioOutputStream uses callback_ to provide an |
201 // extra guard for this situation, but it seems to introduce more | 211 // extra guard for this situation, but it seems to introduce more |
202 // complications than it solves (memory barrier issues accessing it from | 212 // complications than it solves (memory barrier issues accessing it from |
203 // multiple threads, looses the means to indicate OnClosed to client). | 213 // multiple threads, looses the means to indicate OnClosed to client). |
204 // Should determine if we need to do something equivalent here. | 214 // Should determine if we need to do something equivalent here. |
205 return; | 215 return; |
206 } | 216 } |
207 HandleError(err); | 217 HandleError(err); |
208 } | 218 } |
209 } | 219 } |
OLD | NEW |