OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 int32_t ActiveAudioLayer( | 54 int32_t ActiveAudioLayer( |
55 AudioDeviceModule::AudioLayer& audioLayer) const override { | 55 AudioDeviceModule::AudioLayer& audioLayer) const override { |
56 audioLayer = audio_layer_; | 56 audioLayer = audio_layer_; |
57 return 0; | 57 return 0; |
58 } | 58 } |
59 | 59 |
60 int32_t Init() override { | 60 int32_t Init() override { |
61 DCHECK(thread_checker_.CalledOnValidThread()); | 61 DCHECK(thread_checker_.CalledOnValidThread()); |
62 DCHECK(!initialized_); | 62 DCHECK(!initialized_); |
63 initialized_ = audio_manager_->Init() || output_.Init() || input_.Init(); | 63 if (!audio_manager_->Init()) |
64 return initialized_ ? 0 : -1; | 64 return -1; |
| 65 if (output_.Init() != 0) { |
| 66 audio_manager_->Close(); |
| 67 return -1; |
| 68 } |
| 69 if (input_.Init() != 0) { |
| 70 output_.Terminate(); |
| 71 audio_manager_->Close(); |
| 72 return -1; |
| 73 } |
| 74 initialized_ = true; |
| 75 return 0; |
65 } | 76 } |
66 | 77 |
67 int32_t Terminate() override { | 78 int32_t Terminate() override { |
68 DCHECK(thread_checker_.CalledOnValidThread()); | 79 DCHECK(thread_checker_.CalledOnValidThread()); |
69 initialized_ = | 80 int32_t err = input_.Terminate(); |
70 !(output_.Terminate() || input_.Terminate() || audio_manager_->Close()); | 81 err |= output_.Terminate(); |
71 return !initialized_ ? 0 : -1; | 82 err |= !audio_manager_->Close(); |
| 83 initialized_ = false; |
| 84 DCHECK_EQ(err, 0); |
| 85 return err; |
72 } | 86 } |
73 | 87 |
74 bool Initialized() const override { | 88 bool Initialized() const override { |
75 DCHECK(thread_checker_.CalledOnValidThread()); | 89 DCHECK(thread_checker_.CalledOnValidThread()); |
76 return initialized_; | 90 return initialized_; |
77 } | 91 } |
78 | 92 |
79 int16_t PlayoutDevices() override { | 93 int16_t PlayoutDevices() override { |
80 return 1; | 94 return 1; |
81 } | 95 } |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 OutputType output_; | 476 OutputType output_; |
463 | 477 |
464 InputType input_; | 478 InputType input_; |
465 | 479 |
466 bool initialized_; | 480 bool initialized_; |
467 }; | 481 }; |
468 | 482 |
469 } // namespace webrtc | 483 } // namespace webrtc |
470 | 484 |
471 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_ | 485 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_ |
OLD | NEW |