| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 FATAL() << "Should never be called"; | 118 FATAL() << "Should never be called"; |
| 119 return -1; | 119 return -1; |
| 120 } | 120 } |
| 121 | 121 |
| 122 int32_t PlayoutIsAvailable(bool& available) override { | 122 int32_t PlayoutIsAvailable(bool& available) override { |
| 123 available = true; | 123 available = true; |
| 124 return 0; | 124 return 0; |
| 125 } | 125 } |
| 126 | 126 |
| 127 int32_t InitPlayout() override { | 127 int32_t InitPlayout() override { |
| 128 // Switches the Android audio mode to MODE_IN_COMMUNICATION to ensure that | |
| 129 // audio routing, volume control and echo performance are the best possible | |
| 130 // for VoIP. InitRecording() does the same type of call but only the first | |
| 131 // call has any effect. | |
| 132 // This call does nothing if MODE_IN_COMMUNICATION was already set. | |
| 133 audio_manager_->SetCommunicationMode(true); | |
| 134 return output_.InitPlayout(); | 128 return output_.InitPlayout(); |
| 135 } | 129 } |
| 136 | 130 |
| 137 bool PlayoutIsInitialized() const override { | 131 bool PlayoutIsInitialized() const override { |
| 138 return output_.PlayoutIsInitialized(); | 132 return output_.PlayoutIsInitialized(); |
| 139 } | 133 } |
| 140 | 134 |
| 141 int32_t RecordingIsAvailable(bool& available) override { | 135 int32_t RecordingIsAvailable(bool& available) override { |
| 142 available = true; | 136 available = true; |
| 143 return 0; | 137 return 0; |
| 144 } | 138 } |
| 145 | 139 |
| 146 int32_t InitRecording() override { | 140 int32_t InitRecording() override { |
| 147 // Switches the Android audio mode to MODE_IN_COMMUNICATION to ensure that | |
| 148 // audio routing, volume control and echo performance are the best possible | |
| 149 // for VoIP. InitRecording() does the same type of call but only the first | |
| 150 // call has any effect. | |
| 151 // This call does nothing if MODE_IN_COMMUNICATION was already set. | |
| 152 audio_manager_->SetCommunicationMode(true); | |
| 153 return input_.InitRecording(); | 141 return input_.InitRecording(); |
| 154 } | 142 } |
| 155 | 143 |
| 156 bool RecordingIsInitialized() const override { | 144 bool RecordingIsInitialized() const override { |
| 157 return input_.RecordingIsInitialized(); | 145 return input_.RecordingIsInitialized(); |
| 158 } | 146 } |
| 159 | 147 |
| 160 int32_t StartPlayout() override { | 148 int32_t StartPlayout() override { |
| 149 DCHECK(audio_manager_->IsCommunicationModeEnabled()); |
| 161 return output_.StartPlayout(); | 150 return output_.StartPlayout(); |
| 162 } | 151 } |
| 163 | 152 |
| 164 int32_t StopPlayout() override { | 153 int32_t StopPlayout() override { |
| 165 // Avoid using audio manger (JNI/Java cost) if playout was inactive. | 154 // Avoid using audio manger (JNI/Java cost) if playout was inactive. |
| 166 if (!Playing()) | 155 if (!Playing()) |
| 167 return 0; | 156 return 0; |
| 168 int32_t err = output_.StopPlayout(); | 157 int32_t err = output_.StopPlayout(); |
| 169 if (!Recording()) { | |
| 170 // Restore initial audio mode since all audio streaming is disabled. | |
| 171 // The default mode was stored in Init(). | |
| 172 audio_manager_->SetCommunicationMode(false); | |
| 173 } | |
| 174 return err; | 158 return err; |
| 175 } | 159 } |
| 176 | 160 |
| 177 bool Playing() const override { | 161 bool Playing() const override { |
| 178 return output_.Playing(); | 162 return output_.Playing(); |
| 179 } | 163 } |
| 180 | 164 |
| 181 int32_t StartRecording() override { | 165 int32_t StartRecording() override { |
| 166 DCHECK(audio_manager_->IsCommunicationModeEnabled()); |
| 182 return input_.StartRecording(); | 167 return input_.StartRecording(); |
| 183 } | 168 } |
| 184 | 169 |
| 185 int32_t StopRecording() override { | 170 int32_t StopRecording() override { |
| 186 // Avoid using audio manger (JNI/Java cost) if recording was inactive. | 171 // Avoid using audio manger (JNI/Java cost) if recording was inactive. |
| 187 if (!Recording()) | 172 if (!Recording()) |
| 188 return 0; | 173 return 0; |
| 189 int32_t err = input_.StopRecording(); | 174 int32_t err = input_.StopRecording(); |
| 190 if (!Playing()) { | |
| 191 // Restore initial audio mode since all audio streaming is disabled. | |
| 192 // The default mode was is stored in Init(). | |
| 193 audio_manager_->SetCommunicationMode(false); | |
| 194 } | |
| 195 return err; | 175 return err; |
| 196 } | 176 } |
| 197 | 177 |
| 198 bool Recording() const override { | 178 bool Recording() const override { |
| 199 return input_.Recording() ; | 179 return input_.Recording() ; |
| 200 } | 180 } |
| 201 | 181 |
| 202 int32_t SetAGC(bool enable) override { | 182 int32_t SetAGC(bool enable) override { |
| 203 if (enable) { | 183 if (enable) { |
| 204 FATAL() << "Should never be called"; | 184 FATAL() << "Should never be called"; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 OutputType output_; | 453 OutputType output_; |
| 474 | 454 |
| 475 InputType input_; | 455 InputType input_; |
| 476 | 456 |
| 477 bool initialized_; | 457 bool initialized_; |
| 478 }; | 458 }; |
| 479 | 459 |
| 480 } // namespace webrtc | 460 } // namespace webrtc |
| 481 | 461 |
| 482 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_ | 462 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_ |
| OLD | NEW |