[vlc-commits] picture: inline and relax picture_Hold()

Rémi Denis-Courmont git at videolan.org
Tue Dec 11 18:11:17 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Dec 10 23:34:40 2018 +0200| [aae07419ece284a903ad68ca8644916ec686c6b0] | committer: Rémi Denis-Courmont

picture: inline and relax picture_Hold()

Relaxed memory order cannot work with an external function.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aae07419ece284a903ad68ca8644916ec686c6b0
---

 include/vlc_picture.h | 14 ++++++++++----
 src/libvlccore.sym    |  1 -
 src/misc/picture.c    |  9 ---------
 3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index 772bc4fc1d..3629aa4d72 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -32,6 +32,8 @@
 #else
 #include <atomic>
 using std::atomic_uintptr_t;
+using std::memory_order;
+using std::memory_order_relaxed;
 #endif
 
 /**
@@ -166,12 +168,16 @@ typedef struct
 VLC_API picture_t * picture_NewFromResource( const video_format_t *, const picture_resource_t * ) VLC_USED;
 
 /**
- * This function will increase the picture reference count.
- * It will not have any effect on picture obtained from vout
+ * Increments the picture reference count.
  *
- * It returns the given picture for convenience.
+ * \return picture
  */
-VLC_API picture_t *picture_Hold( picture_t *p_picture );
+static inline picture_t *picture_Hold(picture_t *picture)
+{
+    atomic_fetch_add_explicit(&picture->refs, (uintptr_t)1,
+                              memory_order_relaxed);
+    return picture;
+}
 
 /**
  * This function will release a picture.
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index d53f6b27c1..c0c6429dba 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -298,7 +298,6 @@ NTPtime64
 picture_BlendSubpicture
 picture_Clone
 picture_CopyPixels
-picture_Hold
 picture_Release
 picture_CopyProperties
 picture_Copy
diff --git a/src/misc/picture.c b/src/misc/picture.c
index b97d181aba..924d2ca960 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -320,15 +320,6 @@ picture_t *picture_New( vlc_fourcc_t i_chroma, int i_width, int i_height, int i_
  *
  *****************************************************************************/
 
-picture_t *picture_Hold( picture_t *p_picture )
-{
-    assert( p_picture != NULL );
-
-    uintptr_t refs = atomic_fetch_add(&p_picture->refs, 1);
-    assert( refs > 0 );
-    return p_picture;
-}
-
 void picture_Release( picture_t *p_picture )
 {
     assert( p_picture != NULL );



More information about the vlc-commits mailing list