diff --git a/cobalt/site/docs/reference/starboard/configuration-public.md b/cobalt/site/docs/reference/starboard/configuration-public.md index 9c57bb9da38c..64605bb01580 100644 --- a/cobalt/site/docs/reference/starboard/configuration-public.md +++ b/cobalt/site/docs/reference/starboard/configuration-public.md @@ -3,13 +3,6 @@ Book: /youtube/cobalt/_book.yaml # Starboard Configuration Reference Guide -## Media Configuration - -| Properties | -| :--- | -| **`SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES`**

The implementation is allowed to support kSbMediaAudioSampleTypeInt16 only when this macro is defined.

By default, this property is undefined. | - - ## Memory Configuration | Properties | diff --git a/starboard/CHANGELOG.md b/starboard/CHANGELOG.md index fd5dfcc2cade..4caede81e09d 100644 --- a/starboard/CHANGELOG.md +++ b/starboard/CHANGELOG.md @@ -11,7 +11,9 @@ since the version previous to it. ## Removed configs for `SB_EXPORT_PLATFORM` and `SB_IMPORT_PLATFORM` These are auto-detected based on compilers, platforms can optionally override. - +## Quirk `SUPPORT_INT16_AUDIO_SAMPLES` is now a configuration constant +`SUPPORT_INT16_AUDIO_SAMPLES` is replaced by `kSbHas16BitAudioSamples` +configuration constant. ## Removed configs for `SB_C_FORCE_INLINE` This is now automatically defined based on compilers, platforms must not provide a definition. diff --git a/starboard/android/shared/configuration_constants.cc b/starboard/android/shared/configuration_constants.cc index 79d25f251ab2..9d2f34ccb5c2 100644 --- a/starboard/android/shared/configuration_constants.cc +++ b/starboard/android/shared/configuration_constants.cc @@ -137,3 +137,8 @@ const uint32_t kSbUserMaxSignedIn = 1; // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB #endif + +#if SB_API_VERSION > 15 +// Platform can use MediaAudioSampleTypeInt16 +SB_EXPORT extern const bool kSbHas16BitAudioSamples = false; +#endif diff --git a/starboard/configuration_constants.h b/starboard/configuration_constants.h index b552bd445d89..6bfa19f24f1d 100644 --- a/starboard/configuration_constants.h +++ b/starboard/configuration_constants.h @@ -153,4 +153,9 @@ SB_EXPORT extern const uint32_t kSbUserMaxSignedIn; SB_EXPORT extern const uint32_t kSbMaxSystemPathCacheDirectorySize; #endif +#if SB_API_VERSION > 15 +// Platform can use MediaAudioSampleTypeInt16 +SB_EXPORT extern const bool kSbHas16BitAudioSamples; +#endif + #endif // STARBOARD_CONFIGURATION_CONSTANTS_H_ diff --git a/starboard/linux/shared/configuration_constants.cc b/starboard/linux/shared/configuration_constants.cc index e7ba36c27df4..c7014a5dadbe 100644 --- a/starboard/linux/shared/configuration_constants.cc +++ b/starboard/linux/shared/configuration_constants.cc @@ -136,3 +136,8 @@ const uint32_t kSbUserMaxSignedIn = 1; // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB #endif + +#if SB_API_VERSION > 15 +// Platform can use MediaAudioSampleTypeInt16 +SB_EXPORT extern const bool kSbHas16BitAudioSamples = false; +#endif diff --git a/starboard/media.h b/starboard/media.h index c9b736936937..d9b6e69db5eb 100644 --- a/starboard/media.h +++ b/starboard/media.h @@ -135,9 +135,7 @@ typedef enum SbMediaAudioCodingType { typedef enum SbMediaAudioSampleType { kSbMediaAudioSampleTypeInt16Deprecated, kSbMediaAudioSampleTypeFloat32, -#if SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) kSbMediaAudioSampleTypeInt16 = kSbMediaAudioSampleTypeInt16Deprecated, -#endif // SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) } SbMediaAudioSampleType; // Possible audio frame storage types. diff --git a/starboard/raspi/shared/configuration_constants.cc b/starboard/raspi/shared/configuration_constants.cc index 0f2fb9eaa67a..b13680c551c1 100644 --- a/starboard/raspi/shared/configuration_constants.cc +++ b/starboard/raspi/shared/configuration_constants.cc @@ -138,3 +138,8 @@ const uint32_t kSbUserMaxSignedIn = 1; // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB #endif + +#if SB_API_VERSION > 15 +// Platform can use MediaAudioSampleTypeInt16 +SB_EXPORT extern const bool kSbHas16BitAudioSamples = false; +#endif diff --git a/starboard/shared/opus/opus_audio_decoder.cc b/starboard/shared/opus/opus_audio_decoder.cc index 85ba47e6eb1f..a1ccfb6226d3 100644 --- a/starboard/shared/opus/opus_audio_decoder.cc +++ b/starboard/shared/opus/opus_audio_decoder.cc @@ -18,6 +18,7 @@ #include "starboard/common/log.h" #include "starboard/common/string.h" +#include "starboard/configuration.h" namespace starboard { namespace shared { @@ -130,6 +131,26 @@ bool OpusAudioDecoder::DecodeInternal( audio_stream_info_.number_of_channels * frames_per_au_ * starboard::media::GetBytesPerSample(GetSampleType())); +#if SB_API_VERSION >= 16 + const char* kDecodeFunctionName = kSbHas16BitAudioSamples + ? "opus_multistream_decode" + : "opus_multistream_decode_float"; + int decoded_frames = + kSbHas16BitAudioSamples + ? opus_multistream_decode( + decoder_, + static_cast(input_buffer->data()), + input_buffer->size(), + reinterpret_cast(decoded_audio->data()), + frames_per_au_, 0) + : opus_multistream_decode_float( + decoder_, + static_cast(input_buffer->data()), + input_buffer->size(), + reinterpret_cast(decoded_audio->data()), frames_per_au_, + 0); +#else + #if SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) const char kDecodeFunctionName[] = "opus_multistream_decode"; int decoded_frames = opus_multistream_decode( @@ -143,6 +164,8 @@ bool OpusAudioDecoder::DecodeInternal( input_buffer->size(), reinterpret_cast(decoded_audio->data()), frames_per_au_, 0); #endif // SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) + +#endif if (decoded_frames == OPUS_BUFFER_TOO_SMALL && frames_per_au_ < kMaxOpusFramesPerAU) { frames_per_au_ = kMaxOpusFramesPerAU; @@ -260,11 +283,11 @@ bool OpusAudioDecoder::is_valid() const { SbMediaAudioSampleType OpusAudioDecoder::GetSampleType() const { SB_DCHECK(BelongsToCurrentThread()); -#if SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) - return kSbMediaAudioSampleTypeInt16; -#else // SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) - return kSbMediaAudioSampleTypeFloat32; -#endif // SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) + if (kSbHas16BitAudioSamples) { + return kSbMediaAudioSampleTypeInt16; + } else { + return kSbMediaAudioSampleTypeFloat32; + } } } // namespace opus diff --git a/starboard/shared/starboard/player/filter/testing/audio_renderer_internal_test.cc b/starboard/shared/starboard/player/filter/testing/audio_renderer_internal_test.cc index 7c6fbca5cd7c..76f77209ab7e 100644 --- a/starboard/shared/starboard/player/filter/testing/audio_renderer_internal_test.cc +++ b/starboard/shared/starboard/player/filter/testing/audio_renderer_internal_test.cc @@ -382,8 +382,12 @@ TEST_F(AudioRendererTest, SunnyDay) { EXPECT_TRUE(audio_renderer_->IsEndOfStreamPlayed()); } -#if SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) +#if SB_API_VERSION >= 16 || SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) TEST_F(AudioRendererTest, SunnyDayWithDoublePlaybackRateAndInt16Samples) { +#if SB_API_VERSION >= 16 + if (!kSbHas16BitAudioSamples) + return; +#endif if (HasAsyncAudioFramesReporting()) { SB_LOG(INFO) << "Platform has async audio frames reporting. Test skipped."; return; @@ -465,7 +469,7 @@ TEST_F(AudioRendererTest, SunnyDayWithDoublePlaybackRateAndInt16Samples) { EXPECT_TRUE(audio_renderer_->IsEndOfStreamPlayed()); } -#endif // SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) +#endif // SB_API_VERSION >= 16 || SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) TEST_F(AudioRendererTest, StartPlayBeforePreroll) { if (HasAsyncAudioFramesReporting()) { diff --git a/starboard/shared/win32/audio_decoder.cc b/starboard/shared/win32/audio_decoder.cc index 27d84e1e0c46..c81cbc0535ef 100644 --- a/starboard/shared/win32/audio_decoder.cc +++ b/starboard/shared/win32/audio_decoder.cc @@ -61,12 +61,7 @@ AudioDecoder::AudioDecoder(const AudioStreamInfo& audio_stream_info, drm_system_(drm_system), sample_type_((audio_stream_info.codec == kSbMediaAudioCodecAc3 || audio_stream_info.codec == kSbMediaAudioCodecEac3) - ? -#if SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) - kSbMediaAudioSampleTypeInt16 -#else - kSbMediaAudioSampleTypeInt16Deprecated -#endif // SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) + ? kSbMediaAudioSampleTypeInt16 : kSbMediaAudioSampleTypeFloat32), stream_ended_(false) { SB_DCHECK(audio_stream_info.codec == kSbMediaAudioCodecAac || diff --git a/starboard/shared/win32/audio_sink.cc b/starboard/shared/win32/audio_sink.cc index db8e671f758b..6f4c88d2d2ef 100644 --- a/starboard/shared/win32/audio_sink.cc +++ b/starboard/shared/win32/audio_sink.cc @@ -47,10 +47,8 @@ void CHECK_HRESULT_OK(HRESULT hr) { WORD SampleTypeToFormatTag(SbMediaAudioSampleType type) { switch (type) { -#if SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) case kSbMediaAudioSampleTypeInt16: return WAVE_FORMAT_PCM; -#endif // SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) case kSbMediaAudioSampleTypeFloat32: return WAVE_FORMAT_IEEE_FLOAT; default: @@ -61,10 +59,8 @@ WORD SampleTypeToFormatTag(SbMediaAudioSampleType type) { WORD SampleTypeToBitsPerSample(SbMediaAudioSampleType type) { switch (type) { -#if SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) case kSbMediaAudioSampleTypeInt16: return 16; -#endif // SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) case kSbMediaAudioSampleTypeFloat32: return 32; default: diff --git a/starboard/shared/win32/audio_sink_is_audio_sample_type_supported.cc b/starboard/shared/win32/audio_sink_is_audio_sample_type_supported.cc index ccba8400209c..af7c9a4f0885 100644 --- a/starboard/shared/win32/audio_sink_is_audio_sample_type_supported.cc +++ b/starboard/shared/win32/audio_sink_is_audio_sample_type_supported.cc @@ -19,10 +19,8 @@ bool SbAudioSinkIsAudioSampleTypeSupported( SbMediaAudioSampleType audio_sample_type) { switch (audio_sample_type) { -#if SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) case kSbMediaAudioSampleTypeInt16: return true; -#endif // SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) case kSbMediaAudioSampleTypeFloat32: return true; default: diff --git a/starboard/stub/configuration_constants.cc b/starboard/stub/configuration_constants.cc index 80bbb4326dde..481d2cd3f15b 100644 --- a/starboard/stub/configuration_constants.cc +++ b/starboard/stub/configuration_constants.cc @@ -135,3 +135,6 @@ const uint32_t kSbUserMaxSignedIn = 1; // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB #endif + +// Platform can use MediaAudioSampleTypeInt16 +SB_EXPORT extern const bool kSbHas16BitAudioSamples = false; diff --git a/starboard/stub/configuration_public.h b/starboard/stub/configuration_public.h index 62c2915073df..4bfb2ad91a2c 100644 --- a/starboard/stub/configuration_public.h +++ b/starboard/stub/configuration_public.h @@ -48,12 +48,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Media Configuration --------------------------------------------------- - -// The implementation is allowed to support kSbMediaAudioSampleTypeInt16 only -// when this macro is defined. -#undef SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES - // --- Memory Configuration -------------------------------------------------- // Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is diff --git a/starboard/win/shared/configuration_constants.cc b/starboard/win/shared/configuration_constants.cc index d4e4dd39b56f..127ec80d80b3 100644 --- a/starboard/win/shared/configuration_constants.cc +++ b/starboard/win/shared/configuration_constants.cc @@ -144,3 +144,8 @@ const uint32_t kSbUserMaxSignedIn = 1; // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB #endif + +#if SB_API_VERSION > 15 +// Platform can use MediaAudioSampleTypeInt16 +SB_EXPORT extern const bool kSbHas16BitAudioSamples = false; +#endif diff --git a/starboard/xb1/shared/configuration_constants.cc b/starboard/xb1/shared/configuration_constants.cc index 05d2f5a912d8..0cc302dc2e45 100644 --- a/starboard/xb1/shared/configuration_constants.cc +++ b/starboard/xb1/shared/configuration_constants.cc @@ -141,3 +141,6 @@ const uint32_t kSbUserMaxSignedIn = 1; // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB #endif + +// Platform can use MediaAudioSampleTypeInt16 +SB_EXPORT extern const bool kSbHas16BitAudioSamples = true; diff --git a/starboard/xb1/shared/configuration_public.h b/starboard/xb1/shared/configuration_public.h index 38ecb4c6e5b6..438c49a13e74 100644 --- a/starboard/xb1/shared/configuration_public.h +++ b/starboard/xb1/shared/configuration_public.h @@ -62,8 +62,4 @@ // --- Platform Specific Quirks ---------------------------------------------- -// The implementation is allowed to support kSbMediaAudioSampleTypeInt16 only -// when this macro is defined. -#define SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES 1 - #endif // STARBOARD_XB1_SHARED_CONFIGURATION_PUBLIC_H_