bug 1323382 remove static FFmpegLibWrapper constructor and destructors r?jya
The libraries are no longer closed, which works around
bug 1304156.
The MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS name seems a little odd here
but it ensures the desired class behaviour and usage, and is consistent with
changes for
bug 1226376.
MozReview-Commit-ID: JLO4HEvNrff
--- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp
@@ -9,26 +9,16 @@
#include "mozilla/Types.h"
#include "prlink.h"
#define AV_LOG_DEBUG 48
namespace mozilla
{
-FFmpegLibWrapper::FFmpegLibWrapper()
-{
- PodZero(this);
-}
-
-FFmpegLibWrapper::~FFmpegLibWrapper()
-{
- Unlink();
-}
-
FFmpegLibWrapper::LinkResult
FFmpegLibWrapper::Link()
{
if (!mAVCodecLib || !mAVUtilLib) {
Unlink();
return LinkResult::NoProvidedLib;
}
@@ -170,9 +160,9 @@ FFmpegLibWrapper::Unlink()
PR_UnloadLibrary(mAVUtilLib);
}
if (mAVCodecLib) {
PR_UnloadLibrary(mAVCodecLib);
}
PodZero(this);
}
-} // namespace mozilla
\ No newline at end of file
+} // namespace mozilla
--- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
+++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h
@@ -13,20 +13,25 @@ struct AVFrame;
struct AVPacket;
struct AVDictionary;
struct AVCodecParserContext;
struct PRLibrary;
namespace mozilla
{
-struct FFmpegLibWrapper
+struct MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS FFmpegLibWrapper
{
- FFmpegLibWrapper();
- ~FFmpegLibWrapper();
+ // The class is used only in static storage and so is zero initialized.
+ FFmpegLibWrapper() = default;
+ // The libraries are not unloaded in the destructor, because doing so would
+ // require a static constructor to register the static destructor. As the
+ // class is in static storage, the destructor would only run on shutdown
+ // anyway.
+ ~FFmpegLibWrapper() = default;
enum class LinkResult
{
Success,
NoProvidedLib,
NoAVCodecVersion,
CannotUseLibAV57,
BlockedOldLibAVVersion,
@@ -86,9 +91,9 @@ struct FFmpegLibWrapper
PRLibrary* mAVCodecLib;
PRLibrary* mAVUtilLib;
private:
};
} // namespace mozilla
-#endif // FFmpegLibWrapper
\ No newline at end of file
+#endif // FFmpegLibWrapper