Skip to content

Commit

Permalink
[android] Fix failing WriteSingleBatch tests
Browse files Browse the repository at this point in the history
This PR (youtube#3325) changes SbPlayerGetMaximumNumberOfSamplesPerWrite() to 256 on ATV as Cobalt supports multiple samples per write to SbPlayer (b/227837774), but current testing files for SbPlayerWriteSampleTest.WriteSingleBatch tests are not long enough for the modification.

1. Set upper bounds for WriteSingleBatch tests (15 audio samples per write, 60 video samples per write) when SbPlayerGetMaximumNumberOfSamplesPerWrite() > 1.
2. Revisit the upper bounds when the requirement is changed (b/347728473).

b/347097484

Test-On-Device: true
  • Loading branch information
borongc committed Jun 17, 2024
1 parent 5c2aec2 commit 7cc7e56
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 0 additions & 3 deletions starboard/android/shared/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@

# TODO: b/280432564 Make this test work on lab devices consistently.
'SbAudioSinkTest.ContinuousAppend',

## TODO: b/347097484 This test failed/crashed with SbPlayerGetMaximumNumberOfSamplesPerWrite() of 256.
'SbPlayerWriteSampleTests/SbPlayerWriteSampleTest.WriteSingleBatch/*',
],
}
# pylint: enable=line-too-long
Expand Down
19 changes: 15 additions & 4 deletions starboard/nplb/player_write_sample_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ TEST_P(SbPlayerWriteSampleTest, NoInput) {
}

TEST_P(SbPlayerWriteSampleTest, WriteSingleBatch) {
// TODO: b/347728473 When the platform supports multiple
// samples per write to SbPlayer, the following numbers are
// sufficient to allow SbPlayer to play 60fps video.
// Revisit the maximum numbers if the requirement is changed.
const int kMaxAudioSamplesPerWrite = 15;
const int kMaxVideoSamplesPerWrite = 60;

SbPlayerTestFixture player_fixture(GetParam(),
&fake_graphics_context_provider_);
if (HasFatalFailure()) {
Expand All @@ -73,14 +80,18 @@ TEST_P(SbPlayerWriteSampleTest, WriteSingleBatch) {

GroupedSamples samples;
if (player_fixture.HasAudio()) {
int samples_to_write = SbPlayerGetMaximumNumberOfSamplesPerWrite(
player_fixture.GetPlayer(), kSbMediaTypeAudio);
int samples_to_write =
std::min(SbPlayerGetMaximumNumberOfSamplesPerWrite(
player_fixture.GetPlayer(), kSbMediaTypeAudio),
kMaxAudioSamplesPerWrite);
samples.AddAudioSamples(0, samples_to_write);
samples.AddAudioEOS();
}
if (player_fixture.HasVideo()) {
int samples_to_write = SbPlayerGetMaximumNumberOfSamplesPerWrite(
player_fixture.GetPlayer(), kSbMediaTypeVideo);
int samples_to_write =
std::min(SbPlayerGetMaximumNumberOfSamplesPerWrite(
player_fixture.GetPlayer(), kSbMediaTypeVideo),
kMaxVideoSamplesPerWrite);
samples.AddVideoSamples(0, samples_to_write);
samples.AddVideoEOS();
}
Expand Down

0 comments on commit 7cc7e56

Please sign in to comment.