From cb87efd7d3f88d5f173c00b996aa886970ccba37 Mon Sep 17 00:00:00 2001 From: henrika Date: Thu, 8 Feb 2018 15:20:07 +0100 Subject: [PATCH] Avoids issues with start of audio when audio was not initialized on Android Bug: b/72444507 Change-Id: I44d6e03c13a49033682f8f0bdc10256f724068d3 Reviewed-on: https://webrtc-review.googlesource.com/48020 Commit-Queue: Henrik Andreassson Reviewed-by: Fredrik Solenberg Reviewed-by: Alex Glaznev Cr-Commit-Position: refs/heads/master@{#21959} --- modules/audio_device/android/audio_record_jni.cc | 6 +++++- modules/audio_device/android/audio_track_jni.cc | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/audio_device/android/audio_record_jni.cc b/modules/audio_device/android/audio_record_jni.cc index 0d5d32ed8f..7e4654ecdd 100644 --- a/modules/audio_device/android/audio_record_jni.cc +++ b/modules/audio_device/android/audio_record_jni.cc @@ -159,8 +159,12 @@ int32_t AudioRecordJni::InitRecording() { int32_t AudioRecordJni::StartRecording() { RTC_LOG(INFO) << "StartRecording"; RTC_DCHECK(thread_checker_.CalledOnValidThread()); - RTC_DCHECK(initialized_); RTC_DCHECK(!recording_); + if (!initialized_) { + RTC_DLOG(LS_WARNING) + << "Recording can not start since InitRecording must succeed first"; + return 0; + } ScopedHistogramTimer timer("WebRTC.Audio.StartRecordingDurationMs"); if (!j_audio_record_->StartRecording()) { RTC_LOG(LS_ERROR) << "StartRecording failed"; diff --git a/modules/audio_device/android/audio_track_jni.cc b/modules/audio_device/android/audio_track_jni.cc index 04ca35a7c0..4469450a9a 100644 --- a/modules/audio_device/android/audio_track_jni.cc +++ b/modules/audio_device/android/audio_track_jni.cc @@ -127,8 +127,12 @@ int32_t AudioTrackJni::InitPlayout() { int32_t AudioTrackJni::StartPlayout() { RTC_LOG(INFO) << "StartPlayout"; RTC_DCHECK(thread_checker_.CalledOnValidThread()); - RTC_DCHECK(initialized_); RTC_DCHECK(!playing_); + if (!initialized_) { + RTC_DLOG(LS_WARNING) + << "Playout can not start since InitPlayout must succeed first"; + return 0; + } if (!j_audio_track_->StartPlayout()) { RTC_LOG(LS_ERROR) << "StartPlayout failed"; return -1;