Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Unified Diff: content/common/gpu/media/vaapi_wrapper.h

Issue 1137483002: VAAPI Wrapper: refactor management of drm file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move va_lock_ into VADisplayState and ensure its validity for lifetime of VaapiWrapper. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/common/gpu/media/vaapi_wrapper.cc » ('j') | content/common/gpu/media/vaapi_wrapper.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/vaapi_wrapper.h
diff --git a/content/common/gpu/media/vaapi_wrapper.h b/content/common/gpu/media/vaapi_wrapper.h
index cd2d2a6d8fa14b8e54b348690c4522c115895307..8587044d47f642986930316069f92f2a48bca680 100644
--- a/content/common/gpu/media/vaapi_wrapper.h
+++ b/content/common/gpu/media/vaapi_wrapper.h
@@ -134,9 +134,6 @@ class CONTENT_EXPORT VaapiWrapper {
gfx::Size dest_size);
#endif // USE_X11
- // Returns true if the VAAPI version is less than the specified version.
- bool VAAPIVersionLessThan(int major, int minor);
-
// Get a VAImage from a VASurface and map it into memory. The size and format
// are derived from the surface. Use GetVaImage() instead if |format| or
// |size| are different from surface internal representation. The VAImage
@@ -191,6 +188,9 @@ class CONTENT_EXPORT VaapiWrapper {
VASurfaceID va_surface_id_dest,
const gfx::Size& dest_size);
+ // Initialize static data before sandbox is enabled.
+ static void PreSandboxInitialization();
+
private:
struct ProfileInfo {
VAProfile va_profile;
@@ -209,6 +209,52 @@ class CONTENT_EXPORT VaapiWrapper {
std::vector<ProfileInfo> supported_profiles_[kCodecModeMax];
};
+ class VADisplayState {
+ public:
+ VADisplayState();
+ ~VADisplayState();
+
+ // |va_lock_| must be held on entry.
+ bool Initialize(VAStatus* status);
+ void Deinitialize(VAStatus* status);
+
+ base::Lock* va_lock() { return &va_lock_; }
+ VADisplay GetVADisplay() const { return va_display_; }
+
+#if defined(USE_OZONE)
+ void SetDrmFd(base::PlatformFile fd);
+#endif // USE_OZONE
+
+ private:
+#if defined(USE_OZONE)
+ friend class base::LazyInstance<VADisplayState>;
+#endif // USE_OZONE
+
+ // Returns true if the VAAPI version is less than the specified version.
+ bool VAAPIVersionLessThan(int major, int minor);
+
+ int refcount_;
+
+ // Libva is not thread safe, so we have to do locking for it ourselves.
+ // This lock is to be taken for the duration of all VA-API calls and for
+ // the entire job submission sequence in ExecuteAndDestroyPendingBuffers().
+ base::Lock va_lock_;
+
+#if defined(USE_OZONE)
+ // Drm fd used to obtain access to the driver interface by VA.
+ base::ScopedFD drm_fd_;
+#endif // USE_OZONE
+
+ // The VADisplay handle.
+ VADisplay va_display_;
+
+ // The VAAPI version.
+ int major_version_, minor_version_;
+
+ // True if vaInitialize has been called successfully.
+ bool va_initialized_;
+ };
+
VaapiWrapper();
bool Initialize(CodecMode mode, VAProfile va_profile);
@@ -269,16 +315,20 @@ class CONTENT_EXPORT VaapiWrapper {
static VAProfile ProfileToVAProfile(media::VideoCodecProfile profile,
CodecMode mode);
- // Libva is not thread safe, so we have to do locking for it ourselves.
- // This lock is to be taken for the duration of all VA-API calls and for
- // the entire job submission sequence in ExecuteAndDestroyPendingBuffers().
- base::Lock va_lock_;
+ // Pointer to VADisplayState's member |va_lock_|. Guaranteed to be valid for
+ // the lifetime of VaapiWrapper.
+ base::Lock* va_lock_;
// Allocated ids for VASurfaces.
std::vector<VASurfaceID> va_surface_ids_;
- // The VAAPI version.
- int major_version_, minor_version_;
+#if defined(USE_X11)
+ // VADisplay and related state.
+ scoped_ptr<VADisplayState> va_display_state_;
piman 2015/05/11 21:54:07 Why does it have to be different between X11 and O
hshi1 2015/05/11 22:26:40 Done.
+#elif defined(USE_OZONE)
+ // Singleton instance of VADisplayState.
+ static base::LazyInstance<VADisplayState> g_va_display_state_;
+#endif // USE_X11
// VA handles.
// All valid after successful Initialize() and until Deinitialize().
@@ -287,8 +337,6 @@ class CONTENT_EXPORT VaapiWrapper {
// Created for the current set of va_surface_ids_ in CreateSurfaces() and
// valid until DestroySurfaces().
VAContextID va_context_id_;
- // True if vaInitialize has been called successfully.
- bool va_initialized_;
// Data queued up for HW codec, to be committed on next execution.
std::vector<VABufferID> pending_slice_bufs_;
@@ -308,11 +356,6 @@ class CONTENT_EXPORT VaapiWrapper {
VAContextID va_vpp_context_id_;
VABufferID va_vpp_buffer_id_;
-#if defined(USE_OZONE)
- // Drm file used to obtain access to the driver interface by VA.
- base::File drm_file_;
-#endif // USE_OZONE
-
// Singleton variable to store supported profile information for encode and
// decode.
static base::LazyInstance<LazyProfileInfos> profile_infos_;
« no previous file with comments | « no previous file | content/common/gpu/media/vaapi_wrapper.cc » ('j') | content/common/gpu/media/vaapi_wrapper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698