Reporting audio device underrun counter

Bug: webrtc:10884
Change-Id: I35636fcbc1e2a19a89242379cdff6ec5c12fd21a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149200
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Commit-Queue: Alex Narest <alexnarest@google.com>
Cr-Commit-Position: refs/heads/master@{#28874}
This commit is contained in:
Alex Narest
2019-08-16 11:49:04 +02:00
committed by Commit Bot
parent 9b29d69650
commit bbeb10925e
24 changed files with 96 additions and 0 deletions

View File

@ -342,6 +342,19 @@ class WebRtcAudioTrack {
return audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
}
@CalledByNative
private int GetPlayoutUnderrunCount() {
if (Build.VERSION.SDK_INT >= 24) {
if (audioTrack != null) {
return audioTrack.getUnderrunCount();
} else {
return -1;
}
} else {
return -2;
}
}
private void logMainParameters() {
Logging.d(TAG,
"AudioTrack: "

View File

@ -584,6 +584,12 @@ class AndroidAudioDeviceModule : public AudioDeviceModule {
return result;
}
int32_t GetPlayoutUnderrunCount() const override {
if (!initialized_)
return -1;
return output_->GetPlayoutUnderrunCount();
}
int32_t AttachAudioBuffer() {
RTC_LOG(INFO) << __FUNCTION__;
output_->AttachAudioBuffer(audio_device_buffer_.get());

View File

@ -65,6 +65,7 @@ class AudioOutput {
virtual absl::optional<uint32_t> MaxSpeakerVolume() const = 0;
virtual absl::optional<uint32_t> MinSpeakerVolume() const = 0;
virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) = 0;
virtual int GetPlayoutUnderrunCount() = 0;
};
// Extract an android.media.AudioManager from an android.content.Context.

View File

@ -169,6 +169,10 @@ absl::optional<uint32_t> AudioTrackJni::SpeakerVolume() const {
return volume;
}
int AudioTrackJni::GetPlayoutUnderrunCount() {
return Java_WebRtcAudioTrack_GetPlayoutUnderrunCount(env_, j_audio_track_);
}
// TODO(henrika): possibly add stereo support.
void AudioTrackJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
RTC_LOG(INFO) << "AttachAudioBuffer";

View File

@ -65,6 +65,7 @@ class AudioTrackJni : public AudioOutput {
absl::optional<uint32_t> SpeakerVolume() const override;
absl::optional<uint32_t> MaxSpeakerVolume() const override;
absl::optional<uint32_t> MinSpeakerVolume() const override;
int GetPlayoutUnderrunCount() override;
void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;

View File

@ -82,6 +82,8 @@ class OpenSLESPlayer : public AudioOutput {
void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
int GetPlayoutUnderrunCount() override { return -1; }
private:
// These callback methods are called when data is required for playout.
// They are both called from an internal "OpenSL ES thread" which is not