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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/mac/mac_logging.h" | 9 #include "base/mac/mac_logging.h" |
10 #include "media/audio/audio_manager_base.h" | 10 #include "media/audio/audio_manager_base.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 DCHECK(callback); | 66 DCHECK(callback); |
67 DLOG_IF(ERROR, !audio_queue_) << "Open() has not been called successfully"; | 67 DLOG_IF(ERROR, !audio_queue_) << "Open() has not been called successfully"; |
68 if (callback_ || !audio_queue_) | 68 if (callback_ || !audio_queue_) |
69 return; | 69 return; |
70 callback_ = callback; | 70 callback_ = callback; |
71 OSStatus err = AudioQueueStart(audio_queue_, NULL); | 71 OSStatus err = AudioQueueStart(audio_queue_, NULL); |
72 if (err != noErr) { | 72 if (err != noErr) { |
73 HandleError(err); | 73 HandleError(err); |
74 } else { | 74 } else { |
75 started_ = true; | 75 started_ = true; |
76 manager_->IncreaseActiveInputStreamCount(); | |
77 } | 76 } |
78 } | 77 } |
79 | 78 |
80 void PCMQueueInAudioInputStream::Stop() { | 79 void PCMQueueInAudioInputStream::Stop() { |
81 if (!audio_queue_ || !started_) | 80 if (!audio_queue_ || !started_) |
82 return; | 81 return; |
83 | 82 |
84 // Stop is always called before Close. In case of error, this will be | |
85 // also called when closing the input controller. | |
86 manager_->DecreaseActiveInputStreamCount(); | |
87 | |
88 // We request a synchronous stop, so the next call can take some time. In | 83 // We request a synchronous stop, so the next call can take some time. In |
89 // the windows implementation we block here as well. | 84 // the windows implementation we block here as well. |
90 OSStatus err = AudioQueueStop(audio_queue_, true); | 85 OSStatus err = AudioQueueStop(audio_queue_, true); |
91 if (err != noErr) | 86 if (err != noErr) |
92 HandleError(err); | 87 HandleError(err); |
93 | 88 |
94 started_ = false; | 89 started_ = false; |
95 } | 90 } |
96 | 91 |
97 void PCMQueueInAudioInputStream::Close() { | 92 void PCMQueueInAudioInputStream::Close() { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // complications than it solves (memory barrier issues accessing it from | 222 // complications than it solves (memory barrier issues accessing it from |
228 // multiple threads, looses the means to indicate OnClosed to client). | 223 // multiple threads, looses the means to indicate OnClosed to client). |
229 // Should determine if we need to do something equivalent here. | 224 // Should determine if we need to do something equivalent here. |
230 return; | 225 return; |
231 } | 226 } |
232 HandleError(err); | 227 HandleError(err); |
233 } | 228 } |
234 } | 229 } |
235 | 230 |
236 } // namespace media | 231 } // namespace media |
OLD | NEW |