[vlc-commits] python bindings: emulate libvlc_free if not present in libvlc

Olivier Aubert git at videolan.org
Fri Apr 29 11:21:55 CEST 2011


vlc/python | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Mon Apr 18 21:41:06 2011 +0200| [dd89e1ca51c846f895e964d899f79f10589f8c22] | committer: Olivier Aubert

python bindings: emulate libvlc_free if not present in libvlc
Signed-off-by: Olivier Aubert <olivier.aubert at liris.cnrs.fr>

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

 footer.py |   15 +++++++++++++++
 header.py |    1 +
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/footer.py b/footer.py
index 59fda18..2dd903e 100644
--- a/footer.py
+++ b/footer.py
@@ -6,6 +6,21 @@ def callbackmethod(callback):
     """Now obsolete @callbackmethod decorator."""
     return callback
 
+# libvlc_free is not present in some versions of libvlc. If it is not
+# in the library, then emulate it by calling libc.free
+if not hasattr(dll, 'libvlc_free'):
+    # need to find the free function in the C runtime. This is
+    # platform specific.
+    if sys.platform.startswith('linux'):
+        libc = ctypes.CDLL(find_library('c'))
+        libvlc_free = libc.free
+    else:
+        raise NotImplementedError('%s: %s without libvlc_free not supported' % (sys.argv[0], sys.platform))
+
+    # ensure argtypes is right, because default type of int won't work
+    # on 64-bit systems
+    libvlc_free.argtypes = [ ctypes.c_void_p ]
+
 # Version functions
 def _dot2int(v):
     '''(INTERNAL) Convert 'i.i.i[.i]' str to int.
diff --git a/header.py b/header.py
index 33549c9..cc1ac8d 100755
--- a/header.py
+++ b/header.py
@@ -39,6 +39,7 @@ C{get_instance} method of L{MediaPlayer} and L{MediaListPlayer}.
 """
 
 import ctypes
+from ctypes.util import find_library
 import os
 import sys
 



More information about the vlc-commits mailing list