X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bindings%2Fpython%2Fvlcglue.h;h=521164572935a1a59df17ae3881c100be3b118c0;hb=df6fda46d49099fc712b159449280d9cf7aa0a7e;hp=f5e450a15001967e76d53d086860505ef09494b9;hpb=07a52db97ca6689ecc846818cfb681dd9b3c02e3;p=vlc diff --git a/bindings/python/vlcglue.h b/bindings/python/vlcglue.h index f5e450a150..5211645729 100644 --- a/bindings/python/vlcglue.h +++ b/bindings/python/vlcglue.h @@ -4,7 +4,7 @@ * Copyright (C) 1998-2004 the VideoLAN team * $Id$ * - * Authors: Olivier Aubert + * Authors: Olivier Aubert * Clément Stenac * * This program is free software; you can redistribute it and/or modify @@ -33,16 +33,22 @@ #include #include -#define SELF ((MediaControl*)self) +/* Python 2.5 64-bit support compatibility define */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +#define PY_SSIZE_T_MAX INT_MAX +#define PY_SSIZE_T_MIN INT_MIN +#endif + /********************************************************************** * Exceptions handling **********************************************************************/ -#define MC_TRY exception=mediacontrol_exception_init(exception) +#define MC_TRY exception=mediacontrol_exception_create( ) #define MC_EXCEPT \ - if( exception->code ) { \ + if( exception && exception->code ) { \ PyObject *py_exc = MediaControl_InternalException; \ switch( exception->code ) { \ case mediacontrol_InternalException: \ @@ -64,29 +70,23 @@ PyErr_SetString( py_exc, exception->message ); \ mediacontrol_exception_free( exception ); \ return NULL; \ - } else { mediacontrol_exception_free( exception ); } + } else if( exception ) { mediacontrol_exception_free( exception ); } PyObject *MediaControl_InternalException; PyObject *MediaControl_PositionKeyNotSupported; PyObject *MediaControl_PositionOriginNotSupported; PyObject *MediaControl_InvalidPosition; PyObject *MediaControl_PlaylistException; -PyObject *vlcInstance_Exception; - -/********************************************************************** - * VLC Object - **********************************************************************/ -#define VLCSELF ( ( vlcObject* )self ) +PyObject *vlc_Exception; /********************************************************************** - * VLCObject Object + * vlc.Instance Object **********************************************************************/ typedef struct { PyObject_HEAD - vlc_object_t* p_object; - int b_released; -} vlcObject; + libvlc_instance_t* p_instance; +} vlcInstance; /********************************************************************** * MediaControl Object @@ -95,6 +95,7 @@ typedef struct { PyObject_HEAD mediacontrol_Instance* mc; + vlcInstance *vlc_instance; } MediaControl; /********************************************************************** @@ -109,39 +110,40 @@ typedef struct } PyPosition; /********************************************************************** - * vlc.Instance Object + * vlc.MediaPlayer Object **********************************************************************/ typedef struct { PyObject_HEAD - libvlc_instance_t* p_instance; -} vlcInstance; - -#define LIBVLC_INSTANCE ((vlcInstance*)self) + libvlc_media_player_t* p_mp; +} vlcMediaPlayer; /********************************************************************** - * vlc.Input Object + * vlc.Media Object **********************************************************************/ typedef struct { PyObject_HEAD - libvlc_input_t* p_input; -} vlcInput; + libvlc_media_t* p_media; +} vlcMedia; /* Forward declarations */ -staticforward PyTypeObject vlcObject_Type; staticforward PyTypeObject MediaControl_Type; staticforward PyTypeObject PyPosition_Type; staticforward PyTypeObject vlcInstance_Type; -staticforward PyTypeObject vlcInput_Type; +staticforward PyTypeObject vlcMediaPlayer_Type; +staticforward PyTypeObject vlcMedia_Type; -#define LIBVLC_INPUT ((vlcInput*)self) +#define LIBVLC_INSTANCE(self) (((vlcInstance*)self)->p_instance) +#define LIBVLC_MEDIAPLAYER(self) (((vlcMediaPlayer*)self)->p_mp) +#define LIBVLC_MEDIA(self) (((vlcMedia*)self)->p_media) +#define LIBVLC_MC(self) (((MediaControl*)self)->mc) #define LIBVLC_TRY libvlc_exception_init( &ex ); #define LIBVLC_EXCEPT if( libvlc_exception_raised( &ex ) ) { \ - PyObject *py_exc = vlcInstance_Exception; \ - PyErr_SetString( py_exc, libvlc_exception_get_message( &ex ) ); \ + PyObject *py_exc = vlc_Exception; \ + PyErr_SetString( py_exc, libvlc_errmsg() ); \ return NULL; \ }