OLD | NEW |
1 // Copyright (c) 2011 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> |
| 8 |
7 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "media/audio/audio_util.h" | 11 #include "media/audio/audio_util.h" |
10 #include "media/audio/mac/audio_manager_mac.h" | 12 #include "media/audio/mac/audio_manager_mac.h" |
11 | 13 |
12 #if !defined(MAC_OS_X_VERSION_10_6) || \ | 14 #if !defined(MAC_OS_X_VERSION_10_6) || \ |
13 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 | 15 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 |
14 enum { | 16 enum { |
15 kAudioQueueErr_EnqueueDuringReset = -66632 | 17 kAudioQueueErr_EnqueueDuringReset = -66632 |
16 }; | 18 }; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 callback_->OnClose(this); | 109 callback_->OnClose(this); |
108 callback_ = NULL; | 110 callback_ = NULL; |
109 } | 111 } |
110 manager_->ReleaseInputStream(this); | 112 manager_->ReleaseInputStream(this); |
111 // CARE: This object may now be destroyed. | 113 // CARE: This object may now be destroyed. |
112 } | 114 } |
113 | 115 |
114 void PCMQueueInAudioInputStream::HandleError(OSStatus err) { | 116 void PCMQueueInAudioInputStream::HandleError(OSStatus err) { |
115 if (callback_) | 117 if (callback_) |
116 callback_->OnError(this, static_cast<int>(err)); | 118 callback_->OnError(this, static_cast<int>(err)); |
117 NOTREACHED() << "error code " << err; | 119 NOTREACHED() << "error " << GetMacOSStatusErrorString(err) |
| 120 << " (" << err << ")"; |
118 } | 121 } |
119 | 122 |
120 bool PCMQueueInAudioInputStream::SetupBuffers() { | 123 bool PCMQueueInAudioInputStream::SetupBuffers() { |
121 DCHECK(buffer_size_bytes_); | 124 DCHECK(buffer_size_bytes_); |
122 for (int i = 0; i < kNumberBuffers; ++i) { | 125 for (int i = 0; i < kNumberBuffers; ++i) { |
123 AudioQueueBufferRef buffer; | 126 AudioQueueBufferRef buffer; |
124 OSStatus err = AudioQueueAllocateBuffer(audio_queue_, | 127 OSStatus err = AudioQueueAllocateBuffer(audio_queue_, |
125 buffer_size_bytes_, | 128 buffer_size_bytes_, |
126 &buffer); | 129 &buffer); |
127 if (err == noErr) | 130 if (err == noErr) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // TODO(joth): PCMQueueOutAudioOutputStream uses callback_ to provide an | 186 // TODO(joth): PCMQueueOutAudioOutputStream uses callback_ to provide an |
184 // extra guard for this situation, but it seems to introduce more | 187 // extra guard for this situation, but it seems to introduce more |
185 // complications than it solves (memory barrier issues accessing it from | 188 // complications than it solves (memory barrier issues accessing it from |
186 // multiple threads, looses the means to indicate OnClosed to client). | 189 // multiple threads, looses the means to indicate OnClosed to client). |
187 // Should determine if we need to do something equivalent here. | 190 // Should determine if we need to do something equivalent here. |
188 return; | 191 return; |
189 } | 192 } |
190 HandleError(err); | 193 HandleError(err); |
191 } | 194 } |
192 } | 195 } |
OLD | NEW |