Make build less noisy

And fix cobalt-plugin build with Thunder R4.

Change-Id: I7f9cd07d325b171f2181da5dcb693d4adc3e9b60
diff --git a/plugin/CobaltJsonRpc.cpp b/plugin/CobaltJsonRpc.cpp
index 2125e64..6a70cd7 100644
--- a/plugin/CobaltJsonRpc.cpp
+++ b/plugin/CobaltJsonRpc.cpp
@@ -23,10 +23,6 @@
 #include "Cobalt.h"
 #include "Module.h"
 
-#ifndef SYSLOG_GLOBAL
-#define SYSLOG_GLOBAL(CATEGORY, PARAMETERS) SYSLOG(CATEGORY, PARAMETERS)
-#endif /* SYSLOG_GLOBAL */
-
 namespace WPEFramework {
 namespace Plugin {
 
@@ -210,14 +206,14 @@
   Exchange::IDictionary *dict(
     _cobalt->QueryInterface<Exchange::IDictionary>());
   if (dict == nullptr) {
-    SYSLOG_GLOBAL(Logging::Error, (_T("IDictionary is not implemented")));
+    SYSLOG(Logging::Error, (_T("IDictionary is not implemented")));
   } else {
     std::string json;
     if (!dict->Get("settings", "accessibility", json)) {
-      SYSLOG_GLOBAL(Logging::Error, (_T("Cannot get 'accessibility' setting")));
+      SYSLOG(Logging::Error, (_T("Cannot get 'accessibility' setting")));
     }
     else if (!response.FromString(json)) {
-      SYSLOG_GLOBAL(Logging::Error, (_T("Cannot convert to JSON object")));
+      SYSLOG(Logging::Error, (_T("Cannot convert to JSON object")));
     }
     else {
       result = Core::ERROR_NONE;
@@ -243,14 +239,14 @@
     Exchange::IDictionary *dict(
       _cobalt->QueryInterface<Exchange::IDictionary>());
     if (dict == nullptr) {
-      SYSLOG_GLOBAL(Logging::Error, (_T("IDictionary is not implemented")));
+      SYSLOG(Logging::Error, (_T("IDictionary is not implemented")));
     } else {
       std::string json;
       if (!param.ToString(json)) {
-        SYSLOG_GLOBAL(Logging::Error, (_T("Cannot convert to string")));
+        SYSLOG(Logging::Error, (_T("Cannot convert to string")));
       }
       else if (!dict->Set("settings", "accessibility", json)) {
-        SYSLOG_GLOBAL(Logging::Error, (_T("Cannot set 'accessibility' setting")));
+        SYSLOG(Logging::Error, (_T("Cannot set 'accessibility' setting")));
       }
       else {
         result = Core::ERROR_NONE;
diff --git a/plugin/Module.h b/plugin/Module.h
index f0d8629..ec9c6d5 100644
--- a/plugin/Module.h
+++ b/plugin/Module.h
@@ -24,5 +24,9 @@
 #include <core/core.h>
 #include <plugins/plugins.h>
 
+#if !defined(THUNDER_VERSION) && defined(THUNDER_VERSION_MAJOR)
+#define THUNDER_VERSION THUNDER_VERSION_MAJOR
+#endif
+
 #undef EXTERNAL
 #define EXTERNAL
diff --git a/src/third_party/starboard/rdk/shared/BUILD.gn b/src/third_party/starboard/rdk/shared/BUILD.gn
index 5b65b86..0f8d33e 100644
--- a/src/third_party/starboard/rdk/shared/BUILD.gn
+++ b/src/third_party/starboard/rdk/shared/BUILD.gn
@@ -85,6 +85,8 @@
 static_library("starboard_platform") {
   check_includes = false
 
+  # has_pedantic_warnings = true
+
   defines = []
 
   sources = [
diff --git a/src/third_party/starboard/rdk/shared/audio_sink/gstreamer_audio_sink_type.cc b/src/third_party/starboard/rdk/shared/audio_sink/gstreamer_audio_sink_type.cc
index e1b5787..c78d6b1 100644
--- a/src/third_party/starboard/rdk/shared/audio_sink/gstreamer_audio_sink_type.cc
+++ b/src/third_party/starboard/rdk/shared/audio_sink/gstreamer_audio_sink_type.cc
@@ -128,7 +128,7 @@
   GstElement* audiosink_{nullptr};
   GMainLoop* mainloop_{nullptr};
   GMainContext* main_loop_context_{nullptr};
-  guint source_id_{0};
+  int source_id_{-1};
   bool destroying_{false};
   bool enough_data_{false};
   std::string file_name_;
@@ -193,7 +193,7 @@
   appsrc_ = gst_element_factory_make("appsrc", "source");
   GstAppSrcCallbacks callbacks = {&GStreamerAudioSink::AppSrcNeedData,
                                   &GStreamerAudioSink::AppSrcEnoughData,
-                                  nullptr};
+                                  nullptr, nullptr};
   gst_app_src_set_callbacks(GST_APP_SRC(appsrc_), &callbacks, this, nullptr);
   gst_app_src_set_max_bytes(GST_APP_SRC(appsrc_),
                             kFramesPerRequest * GetBytesPerFrame());
diff --git a/src/third_party/starboard/rdk/shared/configuration.cc b/src/third_party/starboard/rdk/shared/configuration.cc
index e92f732..070344c 100644
--- a/src/third_party/starboard/rdk/shared/configuration.cc
+++ b/src/third_party/starboard/rdk/shared/configuration.cc
@@ -76,6 +76,7 @@
     &::starboard::common::CobaltRasterizerTypeDefault,
     &::starboard::common::CobaltEnableJitDefault,
     &::starboard::common::CobaltFallbackSplashScreenTopicsDefault,
+    &::starboard::common::CobaltCanStoreCompiledJavascriptDefault,
 };
 
 }  // namespace
diff --git a/src/third_party/starboard/rdk/shared/drm/gst_decryptor_ocdm.cc b/src/third_party/starboard/rdk/shared/drm/gst_decryptor_ocdm.cc
index b81e294..3c4642a 100644
--- a/src/third_party/starboard/rdk/shared/drm/gst_decryptor_ocdm.cc
+++ b/src/third_party/starboard/rdk/shared/drm/gst_decryptor_ocdm.cc
@@ -248,7 +248,7 @@
     }
 
     if ( rc != 0 ) {
-      if ( rc == ERROR_INVALID_SESSION ) {
+      if ( rc == (int)ERROR_INVALID_SESSION ) {
         GST_DEBUG_OBJECT(self, "Invalid session. Probably due to player shutdown.");
         return GST_BASE_TRANSFORM_FLOW_DROPPED;
       }
diff --git a/src/third_party/starboard/rdk/shared/hang_detector.cc b/src/third_party/starboard/rdk/shared/hang_detector.cc
index 3112a9a..c3a5130 100644
--- a/src/third_party/starboard/rdk/shared/hang_detector.cc
+++ b/src/third_party/starboard/rdk/shared/hang_detector.cc
@@ -40,9 +40,9 @@
 namespace {
 
 #if defined(COBALT_BUILD_TYPE_GOLD)
-const uint32_t kMaxExpirationCount = 6;
+const int32_t kMaxExpirationCount = 6;
 #else
-const uint32_t kMaxExpirationCount = 18;
+const int32_t kMaxExpirationCount = 18;
 #endif
 
 pid_t get_tid() {
diff --git a/src/third_party/starboard/rdk/shared/main_rdk.cc b/src/third_party/starboard/rdk/shared/main_rdk.cc
index f34c9fd..8333a6c 100644
--- a/src/third_party/starboard/rdk/shared/main_rdk.cc
+++ b/src/third_party/starboard/rdk/shared/main_rdk.cc
@@ -60,7 +60,8 @@
 }
 
 static void InstallStopSignalHandlers() {
-  struct sigaction action = {0};
+  struct sigaction action;
+  memset (&action, 0, sizeof (action));
   action.sa_handler = RequestStop;
   action.sa_flags = 0;
   ::sigemptyset(&action.sa_mask);
diff --git a/src/third_party/starboard/rdk/shared/platform_configuration/BUILD.gn b/src/third_party/starboard/rdk/shared/platform_configuration/BUILD.gn
index db89e5e..1727d9d 100644
--- a/src/third_party/starboard/rdk/shared/platform_configuration/BUILD.gn
+++ b/src/third_party/starboard/rdk/shared/platform_configuration/BUILD.gn
@@ -60,6 +60,9 @@
 
     cflags_cc += [
       "-std=gnu++14",
+      "-Wno-literal-suffix",
+      # Generated by Audio Renderer and Audio Sink implementations.
+      "-Wno-reorder",
     ]
 
     if (is_qa || is_gold) {
@@ -131,15 +134,31 @@
     "-Wextra",
     "-Wunreachable-code",
   ]
+  if (!is_clang) {
+    cflags += [
+      "-Wno-expansion-to-defined",
+    ]
+  }
 }
 
 config("no_pedantic_warnings") {
   if (!is_clang) {
+    cflags = [
+      "-Wno-conversion",
+      "-Wno-deprecated-declarations",
+      "-Wno-ignored-qualifiers",
+      "-Wno-multichar",
+      "-Wno-sign-conversion",
+      "-Wno-unused-function",
+      "-Wno-unused-local-typedefs",
+      "-Wno-unused-parameter",
+      "-Wno-unused-variable",
+      "-Wno-unused-but-set-variable",
+    ]
     cflags_cc = [
-      "-Wno-literal-suffix",
       "-Wno-deprecated-copy",
       "-Wno-invalid-offsetof",
-      "-Wno-ignored-qualifiers",
+      "-Wno-literal-suffix",
       "-Wno-pessimizing-move",
     ]
   } else {
diff --git a/src/third_party/starboard/rdk/shared/platform_configuration/configuration.gni b/src/third_party/starboard/rdk/shared/platform_configuration/configuration.gni
index d9a3062..a1885b8 100644
--- a/src/third_party/starboard/rdk/shared/platform_configuration/configuration.gni
+++ b/src/third_party/starboard/rdk/shared/platform_configuration/configuration.gni
@@ -44,6 +44,9 @@
 no_pedantic_warnings_config_path =
   "//third_party/starboard/rdk/shared/platform_configuration:no_pedantic_warnings"
 
+pedantic_warnings_config_path =
+  "//third_party/starboard/rdk/shared/platform_configuration:pedantic_warnings"
+
 speed_config_path =
   "//third_party/starboard/rdk/shared/platform_configuration:speed"
 
diff --git a/src/third_party/starboard/rdk/shared/player/player_internal.cc b/src/third_party/starboard/rdk/shared/player/player_internal.cc
index 016a8b3..c90bc26 100644
--- a/src/third_party/starboard/rdk/shared/player/player_internal.cc
+++ b/src/third_party/starboard/rdk/shared/player/player_internal.cc
@@ -1134,6 +1134,7 @@
         CASE(State::kInitialPreroll);
         CASE(State::kPrerollAfterSeek);
         CASE(State::kPresenting);
+        CASE(State::kEnded);
     }
 #undef CASE
     return "unknown";
@@ -1260,7 +1261,7 @@
 
     int need_data = static_cast<int>(media) & ~decoder_state_data_;
     if (need_data == 0) {
-      GST_LOG_OBJECT(pipeline_, "Already sent 'kSbPlayerDecoderStateNeedsData' for media type: %d, ignoring new request", media);
+      GST_LOG_OBJECT(pipeline_, "Already sent 'kSbPlayerDecoderStateNeedsData' for media type: %d, ignoring new request", static_cast<int>(media));
       return;
     }
     if ((eos_data_ & need_data) == need_data) {
@@ -1953,8 +1954,8 @@
 {
   GST_WARNING_OBJECT(self->pipeline_,
     "Decoder need data state = 0x%x,"
-    " video appsrc level = %lld kb,"
-    " audio appsrc level = %lld kb",
+    " video appsrc level = %" G_GUINT64_FORMAT " kb,"
+    " audio appsrc level = %" G_GUINT64_FORMAT " kb",
     self->decoder_state_data_,
     gst_app_src_get_current_level_bytes(GST_APP_SRC(self->video_appsrc_)) / 1024,
     gst_app_src_get_current_level_bytes(GST_APP_SRC(self->audio_appsrc_)) / 1024);
@@ -2130,9 +2131,10 @@
         delete &info;
       });
 #else
+  G_GNUC_UNUSED gsize sz;
   GstBuffer* buffer =
       gst_buffer_new_allocate(nullptr, sample_infos[0].buffer_size, nullptr);
-  gsize sz = gst_buffer_fill(buffer, 0, sample_infos[0].buffer, sample_infos[0].buffer_size);
+  sz = gst_buffer_fill(buffer, 0, sample_infos[0].buffer, sample_infos[0].buffer_size);
   SB_DCHECK(sz == sample_infos[0].buffer_size);
   sample_deallocate_func_(player_, context_, sample_infos[0].buffer);
 #endif
@@ -2305,7 +2307,7 @@
         seek_pos_ns =  seek_position_ * kSbTimeNanosecondsPerMicrosecond;
   }
 
-  if (GST_CLOCK_TIME_IS_VALID(seek_pos_ns) && seek_pos_ns > GST_BUFFER_TIMESTAMP(buffer)) {
+  if (GST_CLOCK_TIME_IS_VALID(seek_pos_ns) && GstClockTime(seek_pos_ns) > GST_BUFFER_TIMESTAMP(buffer)) {
     // Set dummy duration to let sink drop out-of-segment samples
     GST_BUFFER_DURATION (buffer) = GST_SECOND / 60;
     GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DECODE_ONLY);
@@ -2666,7 +2668,7 @@
         GST_INFO_OBJECT(pipeline_, "Ignore state change to playing: invalid min sample ts");
         return false;
       }
-      else if (seek_pos_ns > min_ts) {
+      else if (seek_pos_ns > GstClockTime(min_ts)) {
         GST_INFO_OBJECT(
           pipeline_,
           "Ignore state change to playing: no samples for seek time yet"
diff --git a/src/third_party/starboard/rdk/shared/rdkservices.cc b/src/third_party/starboard/rdk/shared/rdkservices.cc
index 9baf609..6355fe5 100644
--- a/src/third_party/starboard/rdk/shared/rdkservices.cc
+++ b/src/third_party/starboard/rdk/shared/rdkservices.cc
@@ -1419,11 +1419,12 @@
   Refresh();
 
   ::starboard::ScopedLock lock(mutex_);
-  if (output_index < audio_configurations_.size()) {
-    *out_configuration = audio_configurations_[output_index];
+  size_t index = output_index;
+  if (index < audio_configurations_.size()) {
+    *out_configuration = audio_configurations_[index];
     return true;
   }
-  else if (output_index == 0) {
+  else if (index == 0) {
     InitAudioConfigurationForAudioPort("", out_configuration);
     return true;
   }
diff --git a/src/third_party/starboard/rdk/shared/rdkservices.h b/src/third_party/starboard/rdk/shared/rdkservices.h
index 43721a0..e317ebe 100644
--- a/src/third_party/starboard/rdk/shared/rdkservices.h
+++ b/src/third_party/starboard/rdk/shared/rdkservices.h
@@ -34,10 +34,10 @@
 
 struct ResolutionInfo {
   ResolutionInfo() {}
-  ResolutionInfo(uint32_t w, uint32_t h)
+  ResolutionInfo(int32_t w, int32_t h)
     : Width(w), Height(h) {}
-  uint32_t Width { 1920 };
-  uint32_t Height { 1080 };
+  int32_t Width { 1920 };
+  int32_t Height { 1080 };
 };
 
 class DisplayInfo {
diff --git a/src/third_party/starboard/rdk/shared/system/system_get_path.cc b/src/third_party/starboard/rdk/shared/system/system_get_path.cc
index f323d08..ec57651 100644
--- a/src/third_party/starboard/rdk/shared/system/system_get_path.cc
+++ b/src/third_party/starboard/rdk/shared/system/system_get_path.cc
@@ -210,26 +210,27 @@
     return false;
   }
 
-  char path[kSbFileMaxPath];
+  const int kPathSize = kSbFileMaxPath;
+  char path[kPathSize];
   path[0] = '\0';
 
   switch (path_id) {
     case kSbSystemPathContentDirectory:
-      if (!GetContentDirectory(path, kSbFileMaxPath)){
+      if (!GetContentDirectory(path, kPathSize)){
         return false;
       }
 #if SB_IS(EVERGREEN_COMPATIBLE)
-      if (!GetEvergreenContentPathOverride(path, kSbFileMaxPath)) {
+      if (!GetEvergreenContentPathOverride(path, kPathSize)) {
         return false;
       }
 #endif
       break;
 
     case kSbSystemPathCacheDirectory:
-      if (!GetCacheDirectory(path, kSbFileMaxPath)) {
+      if (!GetCacheDirectory(path, kPathSize)) {
         return false;
       }
-      if (starboard::strlcat<char>(path, "/cobalt", kSbFileMaxPath) >= kSbFileMaxPath) {
+      if (starboard::strlcat<char>(path, "/cobalt", kPathSize) >= kPathSize) {
         return false;
       }
       if (!SbDirectoryCreate(path)) {
@@ -238,17 +239,17 @@
       break;
 
     case kSbSystemPathDebugOutputDirectory:
-      if (!SbSystemGetPath(kSbSystemPathTempDirectory, path, kSbFileMaxPath)) {
+      if (!SbSystemGetPath(kSbSystemPathTempDirectory, path, kPathSize)) {
         return false;
       }
-      if (starboard::strlcat<char>(path, "/log", kSbFileMaxPath) >= kSbFileMaxPath) {
+      if (starboard::strlcat<char>(path, "/log", kPathSize) >= kPathSize) {
         return false;
       }
       SbDirectoryCreate(path);
       break;
 
     case kSbSystemPathTempDirectory:
-      if (!GetTemporaryDirectory(path, kSbFileMaxPath)) {
+      if (!GetTemporaryDirectory(path, kPathSize)) {
         return false;
       }
       SbDirectoryCreate(path);
@@ -260,10 +261,10 @@
     case kSbSystemPathFontConfigurationDirectory:
     case kSbSystemPathFontDirectory:
 #if SB_IS(EVERGREEN_COMPATIBLE)
-      if (!GetContentDirectory(path, kSbFileMaxPath)) {
+      if (!GetContentDirectory(path, kPathSize)) {
         return false;
       }
-      if (starboard::strlcat(path, "/fonts", kSbFileMaxPath) >= kSbFileMaxPath) {
+      if (starboard::strlcat(path, "/fonts", kPathSize) >= kPathSize) {
         return false;
       }
       break;
@@ -272,7 +273,7 @@
 #endif
 
     case kSbSystemPathStorageDirectory:
-      if (!GetStorageDirectory(path, kSbFileMaxPath)) {
+      if (!GetStorageDirectory(path, kPathSize)) {
           return false;
       }
       break;
diff --git a/src/third_party/starboard/rdk/shared/system/system_get_property.cc b/src/third_party/starboard/rdk/shared/system/system_get_property.cc
index 2ba20ce..6207ec2 100644
--- a/src/third_party/starboard/rdk/shared/system/system_get_property.cc
+++ b/src/third_party/starboard/rdk/shared/system/system_get_property.cc
@@ -51,7 +51,7 @@
 const char kPlatformName[] = "Linux";
 
 bool CopyStringAndTestIfSuccess(char* out_value,
-                                int value_length,
+                                size_t value_length,
                                 const char* from_value) {
   if (strlen(from_value) + 1 > value_length)
     return false;
@@ -59,7 +59,7 @@
   return true;
 }
 
-bool TryReadFromPropertiesFile(const char* prefix, size_t prefix_len, char* out_value, int value_length) {
+bool TryReadFromPropertiesFile(const char* prefix, size_t prefix_len, char* out_value, size_t value_length) {
   FILE* properties = fopen("/etc/device.properties", "r");
   if (!properties) {
     return false;