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 <henrika@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Alex Glaznev <glaznev@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21959}
This commit is contained in:
henrika 2018-02-08 15:20:07 +01:00 committed by Commit Bot
parent f4d1134bdc
commit cb87efd7d3
2 changed files with 10 additions and 2 deletions

View File

@ -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";

View File

@ -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;