Skip to content

Commit

Permalink
Deprecate SbMediaGetBuffer{Alignment|Padding} (#3222)
Browse files Browse the repository at this point in the history
Deprecate SbMediaGetBufferAlignment() and SbMediaGetBufferPadding().

Modified nplb tests to ensure that the alignment is always set to 1 and
padding to 0.

b/322027866

Change-Id: Ic6b5eac192d505b1b22309d3bd09d5d3291a4fed
  • Loading branch information
xiaomings committed May 13, 2024
1 parent be16915 commit eb58926
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
15 changes: 14 additions & 1 deletion starboard/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,20 @@ standard APIs `malloc`, `realloc`, `calloc`, `posix_memalign`, `free`
from `<stdlib.h>` and `strdup` from `<string.h>` should be used instead.

### Deprecated SbMediaGetBufferAlignment
The `SbMediaGetBufferAlignment` API was deprecated.
The `SbMediaGetBufferAlignment` API was deprecated, its return value is no
longer used when allocating media buffers and has to be always set to 1. This
is verified explicitly using nplb tests.
The app MAY take best effort to allocate media buffers aligned to an optimal
alignment for the platform, but not guaranteed.
An implementation that has specific alignment requirement should check the
alignment of the incoming buffer, and make a copy when necessary.

### Deprecated SbMediaGetBufferPadding
The SbMediaGetBufferPadding() API was deprecated, its return value is no longer
used when allocating media buffers and has to be always set to 0. This is
verified explicitly using nplb tests.
An implementation that has specific padding requirement should make a copy of
the incoming buffer when necessary.

### Removed SbUser from SbStorageOpenRecord and SbStorageDeleteRecord
The `SbStorageOpenRecord` and `SbStorageDeleteRecord` APIs defined in
Expand Down
24 changes: 24 additions & 0 deletions starboard/nplb/media_buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,21 @@ TEST(SbMediaBufferTest, Alignment) {
#else // SB_API_VERSION >= 14
int alignment = SbMediaGetBufferAlignment(type);
#endif // SB_API_VERSION >= 14

#if SB_API_VERSION >= 16
// SbMediaGetBufferAlignment() was deprecated in Starboard 16, its return
// value is no longer used when allocating media buffers. This is verified
// explicitly here by ensuring its return value is 1.
// The app MAY take best effort to allocate media buffers aligned to an
// optimal alignment for the platform, but not guaranteed.
// An implementation that has specific alignment requirement should check
// the alignment of the incoming buffer, and make a copy when necessary.
EXPECT_EQ(alignment, 1);
#else // SB_API_VERSION >= 16
EXPECT_GE(alignment, 1);
EXPECT_EQ(alignment & (alignment - 1), 0)
<< "Alignment must always be a power of 2";
#endif // SB_API_VERSION >= 16
}
}
#endif // SB_API_VERSION < 16
Expand Down Expand Up @@ -266,13 +278,25 @@ TEST(SbMediaBufferTest, MaxCapacity) {
}

TEST(SbMediaBufferTest, Padding) {
#if SB_API_VERSION >= 16
// SbMediaGetBufferPadding() was deprecated in Starboard 16, its return value
// is no longer used when allocating media buffers. This is verified
// explicitly here by ensuring its return value is 0.
// An implementation that has specific padding requirement should make a
// copy of the incoming buffer when necessary.
EXPECT_EQ(SbMediaGetBufferPadding(), 0);

#else // SB_API_VERSION >= 16

#if SB_API_VERSION >= 14
EXPECT_GE(SbMediaGetBufferPadding(), 0);
#else // SB_API_VERSION >= 14
for (auto type : kMediaTypes) {
EXPECT_GE(SbMediaGetBufferPadding(type), 0);
}
#endif // SB_API_VERSION >= 14

#endif // SB_API_VERSION >= 16
}

TEST(SbMediaBufferTest, PoolAllocateOnDemand) {
Expand Down

0 comments on commit eb58926

Please sign in to comment.