OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
12 #define WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 12 #define WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
13 | 13 |
14 #include <AudioUnit/AudioUnit.h> | 14 #include <AudioUnit/AudioUnit.h> |
15 | 15 |
| 16 #include "webrtc/base/atomicops.h" |
16 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
17 #include "webrtc/base/thread_checker.h" | 18 #include "webrtc/base/thread_checker.h" |
18 #include "webrtc/modules/audio_device/audio_device_generic.h" | 19 #include "webrtc/modules/audio_device/audio_device_generic.h" |
19 | 20 |
20 namespace webrtc { | 21 namespace webrtc { |
21 | 22 |
22 class FineAudioBuffer; | 23 class FineAudioBuffer; |
23 | 24 |
24 // Implements full duplex 16-bit mono PCM audio support for iOS using a | 25 // Implements full duplex 16-bit mono PCM audio support for iOS using a |
25 // Voice-Processing (VP) I/O audio unit in Core Audio. The VP I/O audio unit | 26 // Voice-Processing (VP) I/O audio unit in Core Audio. The VP I/O audio unit |
(...skipping 20 matching lines...) Expand all Loading... |
46 bool Initialized() const override { return initialized_; } | 47 bool Initialized() const override { return initialized_; } |
47 | 48 |
48 int32_t InitPlayout() override; | 49 int32_t InitPlayout() override; |
49 bool PlayoutIsInitialized() const override { return play_is_initialized_; } | 50 bool PlayoutIsInitialized() const override { return play_is_initialized_; } |
50 | 51 |
51 int32_t InitRecording() override; | 52 int32_t InitRecording() override; |
52 bool RecordingIsInitialized() const override { return rec_is_initialized_; } | 53 bool RecordingIsInitialized() const override { return rec_is_initialized_; } |
53 | 54 |
54 int32_t StartPlayout() override; | 55 int32_t StartPlayout() override; |
55 int32_t StopPlayout() override; | 56 int32_t StopPlayout() override; |
56 bool Playing() const override { return playing_; } | 57 bool Playing() const override { |
| 58 return rtc::AtomicInt::AcquireLoad(&playing_) != 0; |
| 59 } |
57 | 60 |
58 int32_t StartRecording() override; | 61 int32_t StartRecording() override; |
59 int32_t StopRecording() override; | 62 int32_t StopRecording() override; |
60 bool Recording() const override { return recording_; } | 63 bool Recording() const override { |
| 64 return rtc::AtomicInt::AcquireLoad(&recording_) != 0; |
| 65 } |
61 | 66 |
62 int32_t SetLoudspeakerStatus(bool enable) override; | 67 int32_t SetLoudspeakerStatus(bool enable) override; |
63 int32_t GetLoudspeakerStatus(bool& enabled) const override; | 68 int32_t GetLoudspeakerStatus(bool& enabled) const override; |
64 | 69 |
65 // These methods returns hard-coded delay values and not dynamic delay | 70 // These methods returns hard-coded delay values and not dynamic delay |
66 // estimates. The reason is that iOS supports a built-in AEC and the WebRTC | 71 // estimates. The reason is that iOS supports a built-in AEC and the WebRTC |
67 // AEC will always be disabled in the Libjingle layer to avoid running two | 72 // AEC will always be disabled in the Libjingle layer to avoid running two |
68 // AEC implementations at the same time. And, it saves resources to avoid | 73 // AEC implementations at the same time. And, it saves resources to avoid |
69 // updating these delay values continuously. | 74 // updating these delay values continuously. |
70 // TODO(henrika): it would be possible to mark these two methods as not | 75 // TODO(henrika): it would be possible to mark these two methods as not |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 266 |
262 // Provides a mechanism for encapsulating one or more buffers of audio data. | 267 // Provides a mechanism for encapsulating one or more buffers of audio data. |
263 // Only used on the recording side. | 268 // Only used on the recording side. |
264 AudioBufferList audio_record_buffer_list_; | 269 AudioBufferList audio_record_buffer_list_; |
265 | 270 |
266 // Temporary storage for recorded data. AudioUnitRender() renders into this | 271 // Temporary storage for recorded data. AudioUnitRender() renders into this |
267 // array as soon as a frame of the desired buffer size has been recorded. | 272 // array as soon as a frame of the desired buffer size has been recorded. |
268 rtc::scoped_ptr<SInt8[]> record_audio_buffer_; | 273 rtc::scoped_ptr<SInt8[]> record_audio_buffer_; |
269 | 274 |
270 // Set to 1 when recording is active and 0 otherwise. | 275 // Set to 1 when recording is active and 0 otherwise. |
271 volatile int recording_; | 276 rtc::AtomicInt recording_; |
272 | 277 |
273 // Set to 1 when playout is active and 0 otherwise. | 278 // Set to 1 when playout is active and 0 otherwise. |
274 volatile int playing_; | 279 rtc::AtomicInt playing_; |
275 | 280 |
276 // Set to true after successful call to Init(), false otherwise. | 281 // Set to true after successful call to Init(), false otherwise. |
277 bool initialized_; | 282 bool initialized_; |
278 | 283 |
279 // Set to true after successful call to InitRecording(), false otherwise. | 284 // Set to true after successful call to InitRecording(), false otherwise. |
280 bool rec_is_initialized_; | 285 bool rec_is_initialized_; |
281 | 286 |
282 // Set to true after successful call to InitPlayout(), false otherwise. | 287 // Set to true after successful call to InitPlayout(), false otherwise. |
283 bool play_is_initialized_; | 288 bool play_is_initialized_; |
284 | 289 |
285 // Audio interruption observer instance. | 290 // Audio interruption observer instance. |
286 void* audio_interruption_observer_; | 291 void* audio_interruption_observer_; |
287 void* route_change_observer_; | 292 void* route_change_observer_; |
288 | 293 |
289 // Contains the audio data format specification for a stream of audio. | 294 // Contains the audio data format specification for a stream of audio. |
290 AudioStreamBasicDescription application_format_; | 295 AudioStreamBasicDescription application_format_; |
291 }; | 296 }; |
292 | 297 |
293 } // namespace webrtc | 298 } // namespace webrtc |
294 | 299 |
295 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ | 300 #endif // WEBRTC_MODULES_AUDIO_DEVICE_IOS_AUDIO_DEVICE_IOS_H_ |
OLD | NEW |