Bug 1619543 Don't log missing va-api symbols, r=jya
authorMartin Stransky <stransky@redhat.com>
Tue, 07 Apr 2020 18:48:24 +0000
changeset 522752 8ba0167147a881aadb49b12832f3b1bce7ed1997
parent 522751 5564cc4543945c62f1e1cdc6faa98f21bf0a0e62
child 522753 fe126e3e069833834054feae0b82878cc82b602b
push id37294
push userapavel@mozilla.com
push dateWed, 08 Apr 2020 03:36:50 +0000
treeherdermozilla-central@6663d3dc883b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1619543
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1619543 Don't log missing va-api symbols, r=jya Differential Revision: https://phabricator.services.mozilla.com/D68756
dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp
dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
--- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
@@ -96,27 +96,32 @@ FFmpegLibWrapper::LinkResult FFmpegLibWr
       Unlink();
       return isFFMpeg ? ((macro > 57) ? LinkResult::UnknownFutureFFMpegVersion
                                       : LinkResult::UnknownOlderFFMpegVersion)
                       // All LibAV versions<54.35.1 are blocked, therefore we
                       // must be dealing with a later one.
                       : LinkResult::UnknownFutureLibAVVersion;
   }
 
-#define AV_FUNC_OPTION(func, ver)                                     \
+#define AV_FUNC_OPTION_SILENT(func, ver)                              \
   if ((ver)&version) {                                                \
     if (!(func = (decltype(func))PR_FindSymbol(                       \
               ((ver)&AV_FUNC_AVUTIL_MASK) ? mAVUtilLib : mAVCodecLib, \
               #func))) {                                              \
-      FFMPEG_LOG("Couldn't load function " #func);                    \
     }                                                                 \
   } else {                                                            \
     func = (decltype(func)) nullptr;                                  \
   }
 
+#define AV_FUNC_OPTION(func, ver)                            \
+  AV_FUNC_OPTION_SILENT(func, ver)                           \
+  if ((ver)&version && (func) == (decltype(func)) nullptr) { \
+    FFMPEG_LOG("Couldn't load function " #func);             \
+  }
+
 #define AV_FUNC(func, ver)                              \
   AV_FUNC_OPTION(func, ver)                             \
   if ((ver)&version && !func) {                         \
     Unlink();                                           \
     return isFFMpeg ? LinkResult::MissingFFMpegFunction \
                     : LinkResult::MissingLibAVFunction; \
   }
 
@@ -148,40 +153,39 @@ FFmpegLibWrapper::LinkResult FFmpegLibWr
                            AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
   AV_FUNC(av_frame_free, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 |
                           AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
   AV_FUNC(av_frame_unref, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 |
                            AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58))
   AV_FUNC_OPTION(av_frame_get_colorspace, AV_FUNC_AVUTIL_ALL)
   AV_FUNC_OPTION(av_frame_get_color_range, AV_FUNC_AVUTIL_ALL)
 #ifdef MOZ_WAYLAND
-  AV_FUNC_OPTION(avcodec_get_hw_config, AV_FUNC_58)
-  AV_FUNC_OPTION(av_hwdevice_ctx_create, AV_FUNC_58)
-  AV_FUNC_OPTION(av_buffer_ref, AV_FUNC_AVUTIL_58)
-  AV_FUNC_OPTION(av_buffer_unref, AV_FUNC_AVUTIL_58)
-  AV_FUNC_OPTION(av_hwframe_transfer_get_formats, AV_FUNC_58)
-  AV_FUNC_OPTION(av_hwdevice_ctx_create_derived, AV_FUNC_58)
-  AV_FUNC_OPTION(av_hwframe_ctx_alloc, AV_FUNC_58)
-  AV_FUNC_OPTION(av_dict_set, AV_FUNC_58)
-  AV_FUNC_OPTION(av_dict_free, AV_FUNC_58)
+  AV_FUNC_OPTION_SILENT(avcodec_get_hw_config, AV_FUNC_58)
+  AV_FUNC_OPTION_SILENT(av_hwdevice_ctx_create, AV_FUNC_58)
+  AV_FUNC_OPTION_SILENT(av_buffer_ref, AV_FUNC_AVUTIL_58)
+  AV_FUNC_OPTION_SILENT(av_buffer_unref, AV_FUNC_AVUTIL_58)
+  AV_FUNC_OPTION_SILENT(av_hwframe_transfer_get_formats, AV_FUNC_58)
+  AV_FUNC_OPTION_SILENT(av_hwdevice_ctx_create_derived, AV_FUNC_58)
+  AV_FUNC_OPTION_SILENT(av_hwframe_ctx_alloc, AV_FUNC_58)
+  AV_FUNC_OPTION_SILENT(av_dict_set, AV_FUNC_58)
+  AV_FUNC_OPTION_SILENT(av_dict_free, AV_FUNC_58)
 #endif
 #undef AV_FUNC
 #undef AV_FUNC_OPTION
 
 #ifdef MOZ_WAYLAND
-#  define VA_FUNC_OPTION(func)                                    \
+#  define VA_FUNC_OPTION_SILENT(func)                             \
     if (!(func = (decltype(func))PR_FindSymbol(mVALib, #func))) { \
-      FFMPEG_LOG("Couldn't load function " #func);                \
       func = (decltype(func)) nullptr;                            \
     }
 
   // mVALib is optional and may not be present.
   if (mVALib) {
-    VA_FUNC_OPTION(vaExportSurfaceHandle)
-    VA_FUNC_OPTION(vaSyncSurface)
+    VA_FUNC_OPTION_SILENT(vaExportSurfaceHandle)
+    VA_FUNC_OPTION_SILENT(vaSyncSurface)
   }
 #  undef VA_FUNC_OPTION
 #endif
 
   avcodec_register_all();
   if (MOZ_LOG_TEST(sPDMLog, LogLevel::Debug)) {
     av_log_set_level(AV_LOG_DEBUG);
   } else if (MOZ_LOG_TEST(sPDMLog, LogLevel::Info)) {
--- a/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp
@@ -61,16 +61,19 @@ bool FFmpegRuntimeLinker::Init() {
     lspec.value.pathname = lib;
     sLibAV.mVALib = PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
     // Don't use libva when it's missing vaExportSurfaceHandle.
     if (sLibAV.mVALib &&
         !PR_FindSymbol(sLibAV.mVALib, "vaExportSurfaceHandle")) {
       PR_UnloadLibrary(sLibAV.mVALib);
       sLibAV.mVALib = nullptr;
     }
+    if (!sLibAV.mVALib) {
+      FFMPEG_LOG("VA-API support: Missing or old %s library.\n", lib);
+    }
   }
 #endif
 
   // While going through all possible libs, this status will be updated with a
   // more precise error if possible.
   sLinkStatus = LinkStatus_NOT_FOUND;
 
   for (size_t i = 0; i < ArrayLength(sLibs); i++) {
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -168,17 +168,17 @@ bool FFmpegVideoDecoder<LIBAV_VER>::Crea
   mCodecContext->hw_device_ctx = mLib->av_buffer_ref(mVAAPIDeviceContext);
   return true;
 }
 
 MediaResult FFmpegVideoDecoder<LIBAV_VER>::InitVAAPIDecoder() {
   FFMPEG_LOG("Initialising VA-API FFmpeg decoder");
 
   if (!mLib->IsVAAPIAvailable()) {
-    FFMPEG_LOG("libva library is missing");
+    FFMPEG_LOG("libva library or symbols are missing.");
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   if (!gfxPlatformGtk::GetPlatform()->UseWaylandHardwareVideoDecoding()) {
     FFMPEG_LOG("VA-API FFmpeg is disabled by platform");
     return NS_ERROR_NOT_AVAILABLE;
   }