Skip to content

Commit

Permalink
Remove SB_API_VERSION < 17 checks from cobalt/
Browse files Browse the repository at this point in the history
b/362374622

Change-Id: I4384ba5a2bc5cf6a6f1b37e1b0933901aaf80073
  • Loading branch information
madhurajayaraman committed Sep 11, 2024
1 parent e462633 commit de3a92c
Show file tree
Hide file tree
Showing 16 changed files with 1 addition and 158 deletions.
2 changes: 0 additions & 2 deletions base/strings/string_util_starboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#define BASE_STRING_UTIL_STARBOARD_H_

#include <stdarg.h>
#if SB_API_VERSION >= 16
#include <stdio.h>
#endif

#include "base/basictypes.h"
#include "base/logging.h"
Expand Down
26 changes: 0 additions & 26 deletions base/threading/platform_thread_starboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ void* ThreadFunc(void* params) {
ThreadParams* thread_params = static_cast<ThreadParams*>(params);
PlatformThread::Delegate* delegate = thread_params->delegate;

#if SB_API_VERSION >= 16
if (kSbHasThreadPrioritySupport) {
SbThreadSetPriority(thread_params->thread_priority);
}
#endif // SB_API_VERSION >= 16
pthread_setname_np(pthread_self(), thread_params->thread_name.c_str());

absl::optional<ScopedDisallowSingleton> disallow_singleton;
Expand All @@ -66,7 +64,6 @@ void* ThreadFunc(void* params) {
return NULL;
}

#if SB_API_VERSION >= 16
bool CreateThread(size_t stack_size,
SbThreadPriority priority,
bool joinable,
Expand Down Expand Up @@ -106,30 +103,7 @@ bool CreateThread(size_t stack_size,

return false;
}
#else
bool CreateThread(size_t stack_size,
SbThreadPriority priority,
bool joinable,
const char* name,
PlatformThread::Delegate* delegate,
PlatformThreadHandle* thread_handle) {
ThreadParams* params = new ThreadParams;
params->delegate = delegate;
params->joinable = joinable;

SbThread thread = SbThreadCreate(stack_size, priority, kSbThreadNoAffinity, joinable,
name, ThreadFunc, params);
if (SbThreadIsValid(thread)) {
if (thread_handle) {
*thread_handle = PlatformThreadHandle(thread);
}

return true;
}

return false;
}
#endif // SB_API_VERSION >= 16

inline SbThreadPriority toSbPriority(ThreadType priority) {
switch (priority) {
Expand Down
11 changes: 0 additions & 11 deletions cobalt/audio/audio_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,8 @@ inline size_t GetSampleTypeSize(SampleType sample_type) {
// an internal SampleType. If we are not running on starboard or using the
// starboard media pipeline, then the preferred sample type is always float32.
inline SampleType GetPreferredOutputSampleType() {
#if SB_API_VERSION >= 16
DCHECK(SbAudioSinkIsAudioSampleTypeSupported(kSbMediaAudioSampleTypeFloat32));
return kSampleTypeFloat32;
#else // SB_API_VERSION >= 16
if (SbAudioSinkIsAudioSampleTypeSupported(kSbMediaAudioSampleTypeFloat32)) {
return kSampleTypeFloat32;
}
DCHECK(SbAudioSinkIsAudioSampleTypeSupported(
kSbMediaAudioSampleTypeInt16Deprecated))
<< "At least one starboard audio sample type must be supported if using "
"starboard media pipeline.";
return kSampleTypeInt16;
#endif // SB_API_VERSION >= 16
}

#if defined(STARBOARD)
Expand Down
4 changes: 0 additions & 4 deletions cobalt/base/wrap_main_starboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,7 @@ void BaseEventHandler(const SbEvent* event) {
case kSbEventTypeOsNetworkDisconnected:
case kSbEventTypeOsNetworkConnected:
case kSbEventDateTimeConfigurationChanged:
#if SB_API_VERSION >= 16
case kSbEventTypeReserved1:
#else
case kSbEventTypeOnScreenKeyboardSuggestionsUpdated:
#endif // SB_API_VERSION >= 16
event_function(event);
break;
}
Expand Down
15 changes: 0 additions & 15 deletions cobalt/browser/application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,10 @@ std::string GetDevServersListenIp() {
// Default to INADDR_ANY
std::string listen_ip(ip_v6 ? "::" : "0.0.0.0");

#if SB_API_VERSION < 15
// Desktop PCs default to loopback.
if (SbSystemGetDeviceType() == kSbSystemDeviceTypeDesktopPC) {
listen_ip = ip_v6 ? "::1" : "127.0.0.1";
}
#else
if (starboard::GetSystemPropertyString(kSbSystemPropertyDeviceType) ==
starboard::kSystemDeviceTypeDesktopPC) {
listen_ip = ip_v6 ? "::1" : "127.0.0.1";
}
#endif

#if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
Expand Down Expand Up @@ -1176,11 +1169,7 @@ void Application::HandleStarboardEvent(const SbEvent* starboard_event) {
case kSbEventTypeStop:
case kSbEventTypeUser:
case kSbEventTypeVerticalSync:
#if SB_API_VERSION >= 16
case kSbEventTypeReserved1:
#else
case kSbEventTypeOnScreenKeyboardSuggestionsUpdated:
#endif // SB_API_VERSION >= 16
DLOG(WARNING) << "Unhandled Starboard event of type: "
<< starboard_event->type;
}
Expand Down Expand Up @@ -1267,11 +1256,7 @@ void Application::OnApplicationEvent(SbEventType event_type,
case kSbEventTypeOsNetworkDisconnected:
case kSbEventTypeOsNetworkConnected:
case kSbEventDateTimeConfigurationChanged:
#if SB_API_VERSION >= 16
case kSbEventTypeReserved1:
#else
case kSbEventTypeOnScreenKeyboardSuggestionsUpdated:
#endif // SB_API_VERSION >= 16
NOTREACHED() << "Unexpected event type: " << event_type;
return;
}
Expand Down
56 changes: 0 additions & 56 deletions cobalt/browser/user_agent_platform_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,47 +110,6 @@ void GetUserAgentInputMap(

namespace {

#if SB_API_VERSION < 15

struct DeviceTypeName {
SbSystemDeviceType device_type;
char device_type_string[10];
};

const DeviceTypeName kDeviceTypeStrings[] = {
{kSbSystemDeviceTypeBlueRayDiskPlayer, "BDP"},
{kSbSystemDeviceTypeGameConsole, "GAME"},
{kSbSystemDeviceTypeOverTheTopBox, "OTT"},
{kSbSystemDeviceTypeSetTopBox, "STB"},
{kSbSystemDeviceTypeTV, "TV"},
{kSbSystemDeviceTypeAndroidTV, "ATV"},
{kSbSystemDeviceTypeDesktopPC, "DESKTOP"},
{kSbSystemDeviceTypeVideoProjector, "PROJECTOR"},
{kSbSystemDeviceTypeUnknown, "UNKNOWN"}};

std::string CreateDeviceTypeString(SbSystemDeviceType device_type) {
for (auto& map : kDeviceTypeStrings) {
if (map.device_type == device_type) {
return std::string(map.device_type_string);
}
}
NOTREACHED();
return "UNKNOWN";
}

#if !defined(COBALT_BUILD_TYPE_GOLD)
SbSystemDeviceType GetDeviceType(std::string device_type_string) {
for (auto& map : kDeviceTypeStrings) {
if (!SbStringCompareNoCase(map.device_type_string,
device_type_string.c_str())) {
return map.device_type;
}
}
return kSbSystemDeviceTypeUnknown;
}
#endif
#endif // SB_API_VERSION < 15

static bool isAsciiAlphaDigit(int c) {
return base::IsAsciiAlpha(c) || base::IsAsciiDigit(c);
}
Expand Down Expand Up @@ -320,15 +279,10 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) {
info.set_aux_field(value);
}

#if SB_API_VERSION >= 15
result = SbSystemGetProperty(kSbSystemPropertyDeviceType, value,
kSystemPropertyMaxLength);
SB_DCHECK(result);
info.set_device_type(value);
#else
// Fill platform info if it is a hardware TV device.
info.set_device_type(SbSystemGetDeviceType());
#endif

// Chipset model number
result = SbSystemGetProperty(kSbSystemPropertyChipsetModelNumber, value,
Expand Down Expand Up @@ -395,11 +349,7 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) {
info.set_original_design_manufacturer(input.second);
LOG(INFO) << "Set original design manufacturer to " << input.second;
} else if (!input.first.compare("device_type")) {
#if SB_API_VERSION < 15
info.set_device_type(GetDeviceType(input.second));
#else
info.set_device_type(input.second);
#endif
LOG(INFO) << "Set device type to " << input.second;
} else if (!input.first.compare("chipset_model_number")) {
info.set_chipset_model_number(input.second);
Expand Down Expand Up @@ -485,12 +435,6 @@ void UserAgentPlatformInfo::set_original_design_manufacturer(
}
}

#if SB_API_VERSION < 15
void UserAgentPlatformInfo::set_device_type(SbSystemDeviceType device_type) {
device_type_ = device_type;
device_type_string_ = CreateDeviceTypeString(device_type_);
}
#endif
void UserAgentPlatformInfo::set_device_type(const std::string& device_type) {
device_type_string_ = device_type;
}
Expand Down
3 changes: 0 additions & 3 deletions cobalt/browser/user_agent_platform_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ class UserAgentPlatformInfo : public web::UserAgentPlatformInfo {
void set_os_name_and_version(const std::string& os_name_and_version);
void set_original_design_manufacturer(
base::Optional<std::string> original_design_manufacturer);
#if SB_API_VERSION < 15
void set_device_type(SbSystemDeviceType device_type);
#endif
void set_device_type(const std::string& device_type);
void set_chipset_model_number(
base::Optional<std::string> chipset_model_number);
Expand Down
8 changes: 0 additions & 8 deletions cobalt/dom/captions/system_caption_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ bool SystemCaptionSettings::is_enabled() {

void SystemCaptionSettings::set_is_enabled(bool active) {
DCHECK(supports_set_enabled());
#if SB_API_VERSION >= 16
auto accessibility_api =
static_cast<const StarboardExtensionAccessibilityApi*>(
SbSystemGetExtension(kStarboardExtensionAccessibilityName));
Expand All @@ -483,9 +482,6 @@ void SystemCaptionSettings::set_is_enabled(bool active) {
accessibility_api->version >= 1) {
accessibility_api->SetCaptionsEnabled(active);
}
#else // SB_API_VERSION >= 16
SbAccessibilitySetCaptionsEnabled(active);
#endif // SB_API_VERSION >= 16
}

bool SystemCaptionSettings::supports_is_enabled() {
Expand Down Expand Up @@ -643,7 +639,6 @@ const char* SystemCaptionSettings::CaptionOpacityPercentageToString(

bool SystemCaptionSettings::GetCaptionSettings(
SbAccessibilityCaptionSettings* caption_settings) {
#if SB_API_VERSION >= 16
auto accessibility_api =
static_cast<const StarboardExtensionAccessibilityApi*>(
SbSystemGetExtension(kStarboardExtensionAccessibilityName));
Expand All @@ -655,9 +650,6 @@ bool SystemCaptionSettings::GetCaptionSettings(
} else {
return false;
}
#else // SB_API_VERSION >= 16
return SbAccessibilityGetCaptionSettings(caption_settings);
#endif // SB_API_VERSION >= 16
}

} // namespace captions
Expand Down
4 changes: 0 additions & 4 deletions cobalt/dom/html_media_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -708,16 +708,12 @@ void HTMLMediaElement::ScheduleEvent(const scoped_refptr<web::Event>& event) {
}

std::string HTMLMediaElement::h5vcc_audio_connectors() const {
#if SB_API_VERSION >= 15
if (!player_) {
return "";
}

std::vector<std::string> configs = player_->GetAudioConnectors();
return base::JoinString(configs, ";");
#else // SB_API_VERSION >= 15
return "";
#endif // SB_API_VERSION >= 15
}

void HTMLMediaElement::CreateMediaPlayer() {
Expand Down
2 changes: 0 additions & 2 deletions cobalt/dom/keyboard_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,8 @@ std::string KeyboardEvent::NonPrintableKey(int32_t key_code) const {
return "MediaStop";
case keycode::kMediaPlayPause:
return "MediaPlayPause";
#if SB_API_VERSION >= 15
case keycode::kMediaRecord:
return "MediaRecord";
#endif
case keycode::kMediaLaunchMail:
return "LaunchMail";
case keycode::kMediaLaunchMediaSelect:
Expand Down
2 changes: 0 additions & 2 deletions cobalt/dom/keyboard_event_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,12 @@ TEST_F(KeyboardEventTest, CanGetKeyIdentifierAndKeyAndCode) {
EXPECT_EQ(keyboard_event_space->key(), " ");
EXPECT_EQ(keyboard_event_space->code(), "Space");

#if SB_API_VERSION >= 15
init.set_key_code(keycode::kMediaRecord);
scoped_refptr<KeyboardEvent> keyboard_event_record =
new KeyboardEvent("keydown", init);
EXPECT_EQ(keyboard_event_record->key_identifier(), "MediaRecord");
EXPECT_EQ(keyboard_event_record->key(), "MediaRecord");
EXPECT_EQ(keyboard_event_record->code(), "MediaRecord");
#endif
}

TEST_F(KeyboardEventTest, CanGetAltKey) {
Expand Down
2 changes: 0 additions & 2 deletions cobalt/dom/keycode.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ enum {
// Not present in Windows virtual key codes, but would be used by the client.
kMediaRewind = 0xE3,
kMediaFastForward = 0xE4,
#if SB_API_VERSION >= 15
kMediaRecord = 0x1A0,
#endif
};

} // namespace keycode
Expand Down
12 changes: 0 additions & 12 deletions cobalt/h5vcc/h5vcc_accessibility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ void H5vccAccessibility::set_built_in_screen_reader(bool value) {
bool H5vccAccessibility::high_contrast_text() const {
SbAccessibilityDisplaySettings settings;
memset(&settings, 0, sizeof(settings));
#if SB_API_VERSION >= 16
auto accessibility_api =
static_cast<const StarboardExtensionAccessibilityApi*>(
SbSystemGetExtension(kStarboardExtensionAccessibilityName));
Expand All @@ -88,11 +87,6 @@ bool H5vccAccessibility::high_contrast_text() const {
} else {
return false;
}
#else // SB_API_VERSION >= 16
if (!SbAccessibilityGetDisplaySettings(&settings)) {
return false;
}
#endif // SB_API_VERSION >= 16
return settings.is_high_contrast_text_enabled;
}

Expand All @@ -103,7 +97,6 @@ bool H5vccAccessibility::text_to_speech() const {
}
SbAccessibilityTextToSpeechSettings settings;
memset(&settings, 0, sizeof(settings));
#if SB_API_VERSION >= 16
auto accessibility_api =
static_cast<const StarboardExtensionAccessibilityApi*>(
SbSystemGetExtension(kStarboardExtensionAccessibilityName));
Expand All @@ -117,11 +110,6 @@ bool H5vccAccessibility::text_to_speech() const {
} else {
return false;
}
#else // SB_API_VERSION >= 16
if (!SbAccessibilityGetTextToSpeechSettings(&settings)) {
return false;
}
#endif // SB_API_VERSION >= 16
return settings.has_text_to_speech_setting &&
settings.is_text_to_speech_enabled;
}
Expand Down
4 changes: 1 addition & 3 deletions cobalt/ui_navigation/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@

#include "cobalt/ui_navigation/interface.h"

#include "starboard/common/spin_lock.h"
#if SB_API_VERSION >= 16
#include <string.h>

#include "starboard/common/spin_lock.h"
#include "starboard/system.h"
#endif // SB_API_VERSION

namespace cobalt {
namespace ui_navigation {
Expand Down
5 changes: 0 additions & 5 deletions cobalt/web/testing/mock_user_agent_platform_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ class MockUserAgentPlatformInfo : public web::UserAgentPlatformInfo {
base::Optional<std::string> original_design_manufacturer() const override {
return optional_empty_string_;
}
#if SB_API_VERSION < 15
SbSystemDeviceType device_type() const override {
return kSbSystemDeviceTypeUnknown;
}
#endif
const std::string& device_type_string() const override {
return empty_string_;
}
Expand Down
3 changes: 0 additions & 3 deletions cobalt/web/user_agent_platform_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class UserAgentPlatformInfo {
virtual const std::string& starboard_version() const = 0;
virtual const std::string& os_name_and_version() const = 0;
virtual base::Optional<std::string> original_design_manufacturer() const = 0;
#if SB_API_VERSION < 15
virtual SbSystemDeviceType device_type() const = 0;
#endif
virtual const std::string& device_type_string() const = 0;
virtual base::Optional<std::string> chipset_model_number() const = 0;
virtual base::Optional<std::string> model_year() const = 0;
Expand Down

0 comments on commit de3a92c

Please sign in to comment.