Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Unified Diff: webrtc/modules/audio_device/android/audio_device_template.h

Issue 1296693003: Fix initialization/termination of AudioDeviceTemplate (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: address feedback from tommi (try to handle initialization failure) Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_device/android/audio_device_template.h
diff --git a/webrtc/modules/audio_device/android/audio_device_template.h b/webrtc/modules/audio_device/android/audio_device_template.h
index adc66fa6d44d4caaa3d4ce907d26ca183f49e17d..653ff11d02f2098bde879e445cae2f57d6590765 100644
--- a/webrtc/modules/audio_device/android/audio_device_template.h
+++ b/webrtc/modules/audio_device/android/audio_device_template.h
@@ -60,15 +60,29 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
int32_t Init() override {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!initialized_);
- initialized_ = audio_manager_->Init() || output_.Init() || input_.Init();
- return initialized_ ? 0 : -1;
+ if (!audio_manager_->Init())
+ return -1;
+ if (output_.Init() != 0) {
+ audio_manager_->Close();
+ return -1;
+ }
+ if (input_.Init() != 0) {
+ output_.Terminate();
+ audio_manager_->Close();
+ return -1;
+ }
+ initialized_ = true;
+ return 0;
}
int32_t Terminate() override {
DCHECK(thread_checker_.CalledOnValidThread());
- initialized_ =
- !(output_.Terminate() || input_.Terminate() || audio_manager_->Close());
- return !initialized_ ? 0 : -1;
+ int32_t err = input_.Terminate();
+ err |= output_.Terminate();
+ err |= !audio_manager_->Close();
+ initialized_ = false;
+ DCHECK_EQ(err, 0);
+ return err;
}
bool Initialized() const override {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698