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

Unified Diff: webrtc/modules/audio_device/android/audio_track_jni.cc

Issue 1858213002: Improves error handling for playout initialization on Android (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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
Index: webrtc/modules/audio_device/android/audio_track_jni.cc
diff --git a/webrtc/modules/audio_device/android/audio_track_jni.cc b/webrtc/modules/audio_device/android/audio_track_jni.cc
index 5bf3a5b8d7d9e576c812a322d6c49fad7be61699..67837f51fb067229138cc2cd39063a4f62d9938c 100644
--- a/webrtc/modules/audio_device/android/audio_track_jni.cc
+++ b/webrtc/modules/audio_device/android/audio_track_jni.cc
@@ -33,7 +33,7 @@ AudioTrackJni::JavaAudioTrack::JavaAudioTrack(
NativeRegistration* native_reg,
std::unique_ptr<GlobalRef> audio_track)
: audio_track_(std::move(audio_track)),
- init_playout_(native_reg->GetMethodId("initPlayout", "(II)V")),
+ init_playout_(native_reg->GetMethodId("initPlayout", "(II)Z")),
start_playout_(native_reg->GetMethodId("startPlayout", "()Z")),
stop_playout_(native_reg->GetMethodId("stopPlayout", "()Z")),
set_stream_volume_(native_reg->GetMethodId("setStreamVolume", "(I)Z")),
@@ -43,8 +43,8 @@ AudioTrackJni::JavaAudioTrack::JavaAudioTrack(
AudioTrackJni::JavaAudioTrack::~JavaAudioTrack() {}
-void AudioTrackJni::JavaAudioTrack::InitPlayout(int sample_rate, int channels) {
- audio_track_->CallVoidMethod(init_playout_, sample_rate, channels);
+bool AudioTrackJni::JavaAudioTrack::InitPlayout(int sample_rate, int channels) {
+ return audio_track_->CallBooleanMethod(init_playout_, sample_rate, channels);
}
bool AudioTrackJni::JavaAudioTrack::StartPlayout() {
@@ -123,8 +123,11 @@ int32_t AudioTrackJni::InitPlayout() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(!initialized_);
RTC_DCHECK(!playing_);
- j_audio_track_->InitPlayout(
- audio_parameters_.sample_rate(), audio_parameters_.channels());
+ if (!j_audio_track_->InitPlayout(
+ audio_parameters_.sample_rate(), audio_parameters_.channels())) {
+ ALOGE("InitPlayout failed!");
+ return -1;
+ }
initialized_ = true;
return 0;
}

Powered by Google App Engine
This is Rietveld 408576698