Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick PR #1776: [android] Handle error in MinRequiredFramesTester #1851

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions starboard/android/shared/audio_sink_min_required_frames_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void MinRequiredFramesTester::TesterThreadFunc() {
frame_buffers[0] = silence_buffer.data();

// Set default values.
has_error_ = false;
min_required_frames_ = task.default_required_frames;
total_consumed_frames_ = 0;
last_underrun_count_ = -1;
Expand Down Expand Up @@ -148,6 +149,13 @@ void MinRequiredFramesTester::TesterThreadFunc() {
min_required_frames_ = max_required_frames_;
}

if (has_error_) {
SB_LOG(ERROR) << "There's an error while running the test. Fallback to "
"max required frames "
<< max_required_frames_ << ".";
min_required_frames_ = max_required_frames_;
}

if (start_threshold > min_required_frames_) {
SB_LOG(INFO) << "Audio sink min required frames is overwritten from "
<< min_required_frames_ << " to audio track start threshold "
Expand Down Expand Up @@ -197,9 +205,10 @@ void MinRequiredFramesTester::ErrorFunc(bool capability_changed,
const std::string& error_message,
void* context) {
SB_LOG(ERROR) << "Error occurred while writing frames: " << error_message;
// TODO: Handle errors during minimum frames test, maybe by terminating the
// test earlier.
SB_NOTREACHED();

MinRequiredFramesTester* tester =
static_cast<MinRequiredFramesTester*>(context);
tester->has_error_ = true;
}

void MinRequiredFramesTester::UpdateSourceStatus(int* frames_in_buffer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class MinRequiredFramesTester {
std::vector<const TestTask> test_tasks_;
AudioTrackAudioSink* audio_sink_ = nullptr;
int min_required_frames_;
std::atomic_bool has_error_;

// Used only by audio sink thread.
int total_consumed_frames_;
Expand Down