Changeset 464bd2e5b4a533b2b232b472390abd0bdab5b93d
- Timestamp:
- 12/10/02 00:32:56 (6 years ago)
- git-parent:
- Files:
-
- Makefile.am (modified) (2 diffs)
- configure.ac.in (modified) (2 diffs)
- include/interface.h (modified) (3 diffs)
- include/vlc/vlc.h (modified) (4 diffs)
- include/vlc_common.h (modified) (7 diffs)
- include/vlc_objects.h (modified) (4 diffs)
- modules/control/rc/rc.c (modified) (7 diffs)
- mozilla/vlcpeer.cpp (modified) (5 diffs)
- mozilla/vlcplugin.h (modified) (3 diffs)
- mozilla/vlcshell.cpp (modified) (14 diffs)
- src/interface/interface.c (modified) (6 diffs)
- src/libvlc.c (modified) (19 diffs)
- src/misc/objects.c (modified) (6 diffs)
- src/vlc.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Makefile.am
r66bbe48 r464bd2e 172 172 include/stream_control.h \ 173 173 include/stream_output.h \ 174 include/variables.h \ 174 175 include/video.h \ 175 176 include/video_output.h \ … … 335 336 src/misc/messages.c \ 336 337 src/misc/objects.c \ 338 src/misc/variables.c \ 337 339 src/misc/extras.c \ 338 340 $(SOURCES_libvlc_win32) \ configure.ac.in
rcc5919a r464bd2e 2127 2127 LDFLAGS_test3="${LDFLAGS_test3} -lobjc" 2128 2128 PLUGINS="${PLUGINS} ${TESTS}" 2129 BUILTINS="${BUILTINS} ${TESTS}"2129 #BUILTINS="${BUILTINS} ${TESTS}" 2130 2130 fi 2131 2131 … … 2201 2201 dnl Stuff used by the program 2202 2202 dnl 2203 AC_DEFINE_UNQUOTED(VERSION_MESSAGE, " vlc ${VERSION} ${CODENAME} Copyright 1996-2002 VideoLAN", [Simple version string])2203 AC_DEFINE_UNQUOTED(VERSION_MESSAGE, "${VERSION} ${CODENAME}", [Simple version string]) 2204 2204 AC_DEFINE_UNQUOTED(COPYRIGHT_MESSAGE, "VideoLAN Client - version ${VERSION} ${CODENAME} - (c) 1996-2002 VideoLAN", [Copyright string]) 2205 2205 AC_DEFINE_UNQUOTED(CONFIGURE_LINE, "${CONFIGURE_LINE}", [The ./configure command line]) include/interface.h
r80b1569 r464bd2e 5 5 ***************************************************************************** 6 6 * Copyright (C) 1999, 2000 VideoLAN 7 * $Id: interface.h,v 1.3 5 2002/10/04 12:01:40 gbazinExp $7 * $Id: interface.h,v 1.36 2002/10/11 22:32:55 sam Exp $ 8 8 * 9 9 * Authors: Vincent Seguin <seguin@via.ecp.fr> … … 56 56 #define intf_Create(a) __intf_Create(VLC_OBJECT(a)) 57 57 VLC_EXPORT( intf_thread_t *, __intf_Create, ( vlc_object_t * ) ); 58 VLC_EXPORT( vlc_error_t,intf_RunThread, ( intf_thread_t * ) );58 VLC_EXPORT( int, intf_RunThread, ( intf_thread_t * ) ); 59 59 VLC_EXPORT( void, intf_StopThread, ( intf_thread_t * ) ); 60 60 VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) ); … … 69 69 freopen( "CONOUT$", "w", stderr ); \ 70 70 freopen( "CONIN$", "r", stdin ); \ 71 msg_Info( p_intf, VERSION_MESSAGE ); \71 msg_Info( p_intf, COPYRIGHT_MESSAGE ); \ 72 72 msg_Info( p_intf, _("\nWarning: if you can't access the GUI " \ 73 73 "anymore, open a dos command box, go to the " \ include/vlc/vlc.h
r1354358 r464bd2e 3 3 ***************************************************************************** 4 4 * Copyright (C) 1998, 1999, 2000 VideoLAN 5 * $Id: vlc.h,v 1.1 4 2002/09/29 18:19:53sam Exp $5 * $Id: vlc.h,v 1.15 2002/10/11 22:32:56 sam Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or modify … … 30 30 * Our custom types 31 31 *****************************************************************************/ 32 typedef struct vlc_t vlc_t; 33 typedef struct vlc_list_t vlc_list_t; 34 typedef struct vlc_object_t vlc_object_t; 32 typedef int vlc_bool_t; 35 33 36 typedef signed int vlc_error_t; 37 typedef int vlc_bool_t; 38 typedef int vlc_status_t; 34 typedef union 35 { 36 int i_int; 37 vlc_bool_t b_bool; 38 float f_float; 39 char * psz_string; 40 void * p_address; 41 42 /* Use this to make sure the structure is at least 64bits */ 43 struct { char a, b, c, d, e, f, g, h; } padding; 44 45 } vlc_value_t; 39 46 40 47 /***************************************************************************** … … 47 54 #define VLC_ETHREAD -4 /* Could not spawn thread */ 48 55 #define VLC_EOBJECT -5 /* Object not found */ 56 #define VLC_EVAR -6 /* Variable not found */ 49 57 #define VLC_EEXIT -255 /* Program exited */ 50 58 #define VLC_EGENERIC -666 /* Generic error */ … … 103 111 * Exported libvlc API 104 112 *****************************************************************************/ 105 vlc_status_t vlc_status( void );113 char * VLC_Version ( void ); 106 114 107 vlc_error_t vlc_create( void );108 vlc_error_t vlc_init (int, char *[] );109 vlc_error_t vlc_die ( void);110 vlc_error_t vlc_destroy ( void);115 int VLC_Create ( void ); 116 int VLC_Init ( int, int, char *[] ); 117 int VLC_Die ( int ); 118 int VLC_Destroy ( int ); 111 119 112 vlc_error_t vlc_set ( const char *, const char * ); 113 vlc_error_t vlc_add_intf ( const char *, vlc_bool_t ); 114 vlc_error_t vlc_add_target ( const char *, int, int ); 120 int VLC_Set ( int, const char *, vlc_value_t ); 121 int VLC_Get ( int, const char *, vlc_value_t * ); 122 int VLC_AddIntf ( int, const char *, vlc_bool_t ); 123 int VLC_AddTarget ( int, const char *, int, int ); 115 124 116 vlc_error_t vlc_play ( ); 117 vlc_error_t vlc_pause ( ); 118 vlc_error_t vlc_stop ( void ); 119 vlc_error_t vlc_fullscreen ( ); 120 121 /***************************************************************************** 122 * Exported libvlc reentrant API 123 *****************************************************************************/ 124 vlc_status_t vlc_status_r ( vlc_t * ); 125 126 vlc_t * vlc_create_r ( void ); 127 vlc_error_t vlc_init_r ( vlc_t *, int, char *[] ); 128 vlc_error_t vlc_die_r ( vlc_t * ); 129 vlc_error_t vlc_destroy_r ( vlc_t * ); 130 131 vlc_error_t vlc_set_r ( vlc_t *, const char *, const char * ); 132 vlc_error_t vlc_add_intf_r ( vlc_t *, const char *, vlc_bool_t ); 133 vlc_error_t vlc_add_target_r ( vlc_t *, const char *, int, int ); 134 135 vlc_error_t vlc_play_r ( vlc_t * ); 136 vlc_error_t vlc_pause_r ( vlc_t * ); 137 vlc_error_t vlc_stop_r ( vlc_t * ); 138 vlc_error_t vlc_fullscreen_r ( vlc_t * ); 125 int VLC_Play ( int ); 126 int VLC_Pause ( int ); 127 int VLC_Stop ( int ); 128 int VLC_FullScreen ( int ); 139 129 140 130 # ifdef __cplusplus include/vlc_common.h
r145b196 r464bd2e 4 4 ***************************************************************************** 5 5 * Copyright (C) 1998, 1999, 2000 VideoLAN 6 * $Id: vlc_common.h,v 1.2 8 2002/10/03 13:21:54sam Exp $6 * $Id: vlc_common.h,v 1.29 2002/10/11 22:32:55 sam Exp $ 7 7 * 8 8 * Authors: Samuel Hocevar <sam@via.ecp.fr> … … 157 157 /* Internal types */ 158 158 typedef struct libvlc_t libvlc_t; 159 typedef struct vlc_t vlc_t; 160 typedef struct vlc_list_t vlc_list_t; 161 typedef struct vlc_object_t vlc_object_t; 162 typedef struct variable_t variable_t; 159 163 160 164 /* Messages */ … … 272 276 vlc_cond_t object_wait; \ 273 277 \ 278 /* Object properties */ \ 274 279 volatile vlc_bool_t b_error; /* set by the object */ \ 275 280 volatile vlc_bool_t b_die; /* set by the outside */ \ … … 277 282 volatile vlc_bool_t b_attached; /* set by the object */ \ 278 283 \ 284 /* Object variables */ \ 285 vlc_mutex_t var_lock; \ 286 int i_vars; \ 287 variable_t * p_vars; \ 288 \ 289 /* Stuff related to the libvlc structure */ \ 279 290 libvlc_t * p_libvlc; /* root of all evil */ \ 280 291 vlc_t * p_vlc; /* (root of all evil) - 1 */ \ … … 290 301 /* Just a reminder so that people don't cast garbage */ \ 291 302 int be_sure_to_add_VLC_COMMON_MEMBERS_to_struct; \ 292 293 /* The real vlc_object_t type. Yes, it's that simple :-) */294 struct vlc_object_t295 {296 VLC_COMMON_MEMBERS297 };298 299 /* The object list */300 struct vlc_list_t301 {302 int i_count;303 vlc_object_t ** pp_objects;304 305 /* Private */306 int _i_extra;307 vlc_object_t * _p_first;308 };309 303 310 304 /* VLC_OBJECT: attempt at doing a clever cast */ … … 509 503 #include "os_specific.h" 510 504 #include "vlc_messages.h" 505 #include "variables.h" 506 #include "vlc_objects.h" 511 507 #include "vlc_threads_funcs.h" 512 508 #include "mtime.h" … … 514 510 #include "main.h" 515 511 #include "configuration.h" 516 #include "vlc_objects.h"517 512 518 513 #if defined( __BORLANDC__ ) include/vlc_objects.h
r145b196 r464bd2e 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: vlc_objects.h,v 1.1 1 2002/10/03 13:21:54sam Exp $5 * $Id: vlc_objects.h,v 1.12 2002/10/11 22:32:55 sam Exp $ 6 6 * 7 7 * Authors: Samuel Hocevar <sam@zoy.org> … … 44 44 45 45 /***************************************************************************** 46 * The vlc_object_t type. Yes, it's that simple :-) 47 *****************************************************************************/ 48 struct vlc_object_t 49 { 50 VLC_COMMON_MEMBERS 51 }; 52 53 /***************************************************************************** 54 * The vlc_list_t object list type 55 *****************************************************************************/ 56 struct vlc_list_t 57 { 58 int i_count; 59 vlc_object_t ** pp_objects; 60 61 /* Private */ 62 int _i_extra; 63 vlc_object_t * _p_first; 64 }; 65 66 /***************************************************************************** 46 67 * Prototypes 47 68 *****************************************************************************/ … … 50 71 VLC_EXPORT( void, __vlc_object_attach, ( vlc_object_t *, vlc_object_t * ) ); 51 72 VLC_EXPORT( void, __vlc_object_detach, ( vlc_object_t * ) ); 73 VLC_EXPORT( void *, __vlc_object_get, ( vlc_object_t *, int ) ); 52 74 VLC_EXPORT( void *, __vlc_object_find, ( vlc_object_t *, int, int ) ); 53 75 VLC_EXPORT( void, __vlc_object_yield, ( vlc_object_t * ) ); … … 72 94 __vlc_object_attach( VLC_OBJECT(a), VLC_OBJECT(b) ) 73 95 96 #define vlc_object_get(a,b) \ 97 __vlc_object_get( VLC_OBJECT(a),b) 98 74 99 #define vlc_object_find(a,b,c) \ 75 100 __vlc_object_find( VLC_OBJECT(a),b,c) modules/control/rc/rc.c
r6dafa41 r464bd2e 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001 VideoLAN 5 * $Id: rc.c,v 1. 7 2002/10/03 17:01:59 gbazinExp $5 * $Id: rc.c,v 1.8 2002/10/11 22:32:56 sam Exp $ 6 6 * 7 7 * Authors: Peter Surda <shurdeek@panorama.sth.ac.at> … … 70 70 add_category_hint( N_("Remote control"), NULL ); 71 71 add_bool( "rc-show-pos", 0, NULL, POS_TEXT, POS_LONGTEXT ); 72 #ifdef HAVE_ISATTY 72 73 add_bool( "fake-tty", 0, NULL, TTY_TEXT, TTY_LONGTEXT ); 74 #endif 73 75 set_description( _("remote control interface module") ); 74 76 set_capability( "interface", 20 ); … … 131 133 p_playlist = NULL; 132 134 135 var_Create( p_intf, "foo", VLC_VAR_STRING ); 136 var_Set( p_intf, "foo", (vlc_value_t)"test" ); 137 133 138 while( !p_intf->b_die ) 134 139 { … … 214 219 { 215 220 char *p_cmd = p_buffer; 216 char *p_tmp;217 221 218 222 if( !strcmp( p_cmd, "quit" ) ) … … 252 256 vlc_liststructure( p_intf->p_vlc ); 253 257 } 254 else if( !strncmp( p_cmd, "set ", 4 ) ) 255 { 256 // vlc_set_r( p_intf->p_vlc, p_cmd + 4, strstr( p_cmd + 4, " " ) ); 257 p_tmp = strstr( p_cmd + 4, " " ); 258 p_tmp[0] = '\0'; 259 config_PutPsz( p_intf->p_vlc, p_cmd + 4, p_tmp + 1 ); 260 config_PutInt( p_intf->p_vlc, p_cmd + 4, atoi(p_tmp + 1) ); 258 else if( !strncmp( p_cmd, "setfoo ", 7 ) ) 259 { 260 vlc_value_t value; 261 value.psz_string = p_cmd + 7; 262 var_Set( p_intf, "foo", value ); 263 } 264 else if( !strncmp( p_cmd, "getfoo", 6 ) ) 265 { 266 vlc_value_t value; 267 var_Get( p_intf, "foo", &value ); 268 printf( "current value is '%s'\n", value.psz_string ); 261 269 } 262 270 else if( !strncmp( p_cmd, "intf ", 5 ) ) … … 392 400 } 393 401 } 394 395 msleep( INTF_IDLE_SLEEP );396 402 } 397 403 … … 407 413 p_playlist = NULL; 408 414 } 415 416 var_Destroy( p_intf, "foo" ); 409 417 } 410 418 mozilla/vlcpeer.cpp
r2799d36 r464bd2e 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: vlcpeer.cpp,v 1. 2 2002/09/30 11:05:41sam Exp $5 * $Id: vlcpeer.cpp,v 1.3 2002/10/11 22:32:56 sam Exp $ 6 6 * 7 7 * Authors: Samuel Hocevar <sam@zoy.org> … … 71 71 if( !p_plugin->b_stream && p_plugin->psz_target ) 72 72 { 73 vlc_add_target_r( p_plugin->p_vlc, p_plugin->psz_target,74 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );73 VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target, 74 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); 75 75 p_plugin->b_stream = 1; 76 76 } 77 77 78 vlc_play_r( p_plugin->p_vlc );78 VLC_Play( p_plugin->i_vlc ); 79 79 } 80 80 return NS_OK; … … 85 85 if( p_plugin ) 86 86 { 87 vlc_pause_r( p_plugin->p_vlc );87 VLC_Pause( p_plugin->i_vlc ); 88 88 } 89 89 return NS_OK; … … 94 94 if( p_plugin ) 95 95 { 96 vlc_stop_r( p_plugin->p_vlc );96 VLC_Stop( p_plugin->i_vlc ); 97 97 p_plugin->b_stream = 0; 98 98 } … … 104 104 if( p_plugin ) 105 105 { 106 vlc_fullscreen_r( p_plugin->p_vlc );106 VLC_FullScreen( p_plugin->i_vlc ); 107 107 } 108 108 return NS_OK; mozilla/vlcplugin.h
r2799d36 r464bd2e 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: vlcplugin.h,v 1. 4 2002/09/30 11:05:41sam Exp $5 * $Id: vlcplugin.h,v 1.5 2002/10/11 22:32:56 sam Exp $ 6 6 * 7 7 * Authors: Samuel Hocevar <sam@zoy.org> … … 48 48 49 49 /* vlc data members */ 50 vlc_t * p_vlc;50 int i_vlc; 51 51 int b_stream; 52 52 int b_autoplay; … … 65 65 "VideoLAN Client Multimedia Player Plugin <br>" \ 66 66 " <br>" \ 67 /*COPYRIGHT_MESSAGE*/ "<br>" \67 "version %s <br>" \ 68 68 "VideoLAN WWW: <a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>" 69 69 mozilla/vlcshell.cpp
rf501554 r464bd2e 3 3 ***************************************************************************** 4 4 * Copyright (C) 2002 VideoLAN 5 * $Id: vlcshell.cpp,v 1. 3 2002/10/03 18:56:09sam Exp $5 * $Id: vlcshell.cpp,v 1.4 2002/10/11 22:32:56 sam Exp $ 6 6 * 7 7 * Authors: Samuel Hocevar <sam@zoy.org> … … 30 30 /* vlc stuff */ 31 31 #include <vlc/vlc.h> 32 #include "config.h"33 32 34 33 /* Mozilla stuff */ … … 89 88 { 90 89 static nsIID nsid = VLCINTF_IID; 90 static char psz_desc[1000]; 91 91 92 92 switch( variable ) … … 97 97 98 98 case NPPVpluginDescriptionString: 99 *((char **)value) = PLUGIN_DESCRIPTION; 99 snprintf( psz_desc, 1000-1, PLUGIN_DESCRIPTION, VLC_Version() ); 100 psz_desc[1000-1] = 0; 101 *((char **)value) = psz_desc; 100 102 return NPERR_NO_ERROR; 103 104 default: 105 /* go on... */ 106 break; 101 107 } 102 108 … … 155 161 char* argn[], char* argv[], NPSavedData* saved ) 156 162 { 163 vlc_value_t value; 157 164 int i_ret; 158 165 int i; … … 186 193 p_plugin->window = 0; 187 194 188 p_plugin->p_vlc = vlc_create_r(); 189 if( p_plugin->p_vlc == NULL ) 190 { 195 p_plugin->i_vlc = VLC_Create(); 196 if( p_plugin->i_vlc < 0 ) 197 { 198 p_plugin->i_vlc = 0; 191 199 delete p_plugin; 192 200 p_plugin = NULL; … … 194 202 } 195 203 196 i_ret = vlc_init_r( p_plugin->p_vlc, sizeof(ppsz_foo)/sizeof(char*), ppsz_foo );204 i_ret = VLC_Init( p_plugin->i_vlc, sizeof(ppsz_foo)/sizeof(char*), ppsz_foo ); 197 205 if( i_ret ) 198 206 { 199 vlc_destroy_r( p_plugin->p_vlc );200 p_plugin-> p_vlc = NULL;207 VLC_Destroy( p_plugin->i_vlc ); 208 p_plugin->i_vlc = 0; 201 209 delete p_plugin; 202 210 p_plugin = NULL; … … 204 212 } 205 213 206 vlc_set_r( p_plugin->p_vlc, "vout", "xvideo,x11,dummy" ); 207 vlc_set_r( p_plugin->p_vlc, "intf", "dummy" ); 214 value.psz_string = "xvideo,x11,dummy"; 215 VLC_Set( p_plugin->i_vlc, "conf::vout", value ); 216 value.psz_string = "dummy"; 217 VLC_Set( p_plugin->i_vlc, "conf::intf", value ); 208 218 209 219 p_plugin->b_stream = 0; … … 228 238 if( !strcmp( argv[i], "yes" ) ) 229 239 { 230 vlc_set_r( p_plugin->p_vlc, "loop", "1" ); 240 value.b_bool = VLC_TRUE; 241 VLC_Set( p_plugin->i_vlc, "conf::loop", value ); 231 242 } 232 243 } … … 252 263 if( p_plugin != NULL ) 253 264 { 254 if( p_plugin-> p_vlc != NULL)255 { 256 vlc_stop_r( p_plugin->p_vlc );257 vlc_destroy_r( p_plugin->p_vlc );258 p_plugin-> p_vlc = NULL;265 if( p_plugin->i_vlc ) 266 { 267 VLC_Stop( p_plugin->i_vlc ); 268 VLC_Destroy( p_plugin->i_vlc ); 269 p_plugin->i_vlc = 0; 259 270 } 260 271 … … 275 286 NPError NPP_SetWindow( NPP instance, NPWindow* window ) 276 287 { 277 char psz_window[32];288 vlc_value_t value; 278 289 279 290 if( instance == NULL ) … … 285 296 286 297 /* Write the window ID for vlc */ 287 sprintf( psz_window, "%li", (long int)window->window ); 288 vlc_set_r( p_plugin->p_vlc, "x11-drawable", psz_window ); 289 vlc_set_r( p_plugin->p_vlc, "xvideo-drawable", psz_window ); 298 value.p_address = (void*)window->window; 299 VLC_Set( p_plugin->i_vlc, "drawable", value ); 290 300 291 301 /* … … 324 334 if( p_plugin->psz_target ) 325 335 { 326 vlc_add_target_r( p_plugin->p_vlc, p_plugin->psz_target,327 i_mode, PLAYLIST_END );336 VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target, 337 i_mode, PLAYLIST_END ); 328 338 p_plugin->b_stream = 1; 329 339 } … … 423 433 424 434 fprintf(stderr, "NPP_StreamAsFile\n"); 425 vlc_add_target_r( p_plugin->p_vlc, fname,426 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );435 VLC_AddTarget( p_plugin->i_vlc, fname, 436 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); 427 437 } 428 438 src/interface/interface.c
r7d2f6de r464bd2e 5 5 ***************************************************************************** 6 6 * Copyright (C) 1998-2001 VideoLAN 7 * $Id: interface.c,v 1. 99 2002/08/29 23:53:22 massiotExp $7 * $Id: interface.c,v 1.100 2002/10/11 22:32:56 sam Exp $ 8 8 * 9 9 * Authors: Vincent Seguin <seguin@via.ecp.fr> … … 79 79 80 80 /* Initialize structure */ 81 p_intf->b_menu = 0;82 p_intf->b_menu_change = 0;81 p_intf->b_menu = VLC_FALSE; 82 p_intf->b_menu_change = VLC_FALSE; 83 83 84 84 /* Initialize mutexes */ … … 99 99 * or runs the interface in the current thread, depending on b_block. 100 100 *****************************************************************************/ 101 vlc_error_t intf_RunThread( intf_thread_t *p_intf )101 int intf_RunThread( intf_thread_t *p_intf ) 102 102 { 103 103 if( p_intf->b_block ) … … 113 113 p_intf->pf_run( p_intf ); 114 114 115 p_intf->b_die = 1;115 p_intf->b_die = VLC_TRUE; 116 116 117 117 /* Do not join the thread... intf_StopThread will do it for us */ … … 141 141 if( !p_intf->b_block ) 142 142 { 143 p_intf->b_die = 1;143 p_intf->b_die = VLC_TRUE; 144 144 } 145 145 … … 181 181 if( p_intf->p_vlc->b_die ) 182 182 { 183 p_intf->b_die = 1;183 p_intf->b_die = VLC_TRUE; 184 184 return; 185 185 } src/libvlc.c
r9de9dd0 r464bd2e 3 3 ***************************************************************************** 4 4 * Copyright (C) 1998-2002 VideoLAN 5 * $Id: libvlc.c,v 1.3 7 2002/10/08 18:10:09sam Exp $5 * $Id: libvlc.c,v 1.38 2002/10/11 22:32:56 sam Exp $ 6 6 * 7 7 * Authors: Vincent Seguin <seguin@via.ecp.fr> … … 81 81 *****************************************************************************/ 82 82 static libvlc_t libvlc; 83 84 //#define GLOBAL_VLC NULL 85 #define GLOBAL_VLC ((vlc_t*)libvlc.pp_children[1]) 83 static vlc_t * p_static_vlc; 86 84 87 85 /***************************************************************************** … … 98 96 99 97 /***************************************************************************** 100 * vlc_create: allocate a vlc_t structure, and initialize libvlc if needed. 101 ***************************************************************************** 102 * This function allocates a vlc_t structure and returns NULL in case of 103 * failure. Also, the thread system is initialized. 104 *****************************************************************************/ 105 vlc_error_t vlc_create( void ) 106 { 107 vlc_t * p_vlc; 108 vlc_bool_t b_failed = VLC_FALSE; 109 110 /* This call should be thread-safe, but an additional check will be 111 * necessary afterwards to check that only one p_vlc is created. */ 112 p_vlc = vlc_create_r(); 113 114 if( p_vlc == NULL ) 115 { 116 return VLC_EGENERIC; 117 } 118 119 /* We have created an object, which ensures us that p_global_lock has 120 * been properly initialized. We can now atomically check that we are 121 * the only p_vlc object. */ 122 #if 0 123 vlc_mutex_lock( libvlc.p_global_lock ); 124 if( libvlc.i_children != 1 ) /* FIXME !!! FIXME */ 125 { 126 b_failed = VLC_TRUE; 127 } 128 vlc_mutex_unlock( libvlc.p_global_lock ); 129 #endif 130 131 /* There can be only one */ 132 if( b_failed ) 133 { 134 vlc_destroy_r( p_vlc ); 135 return VLC_EGENERIC; 136 } 137 138 return VLC_SUCCESS; 139 } 140 141 vlc_t * vlc_create_r( void ) 98 * VLC_Version: return the libvlc version. 99 ***************************************************************************** 100 * This function returns full version string (numeric version and codename). 101 *****************************************************************************/ 102 char * VLC_Version( void ) 103 { 104 return VERSION_MESSAGE; 105 } 106 107 /***************************************************************************** 108 * VLC_Create: allocate a vlc_t structure, and initialize libvlc if needed. 109 ***************************************************************************** 110 * This function allocates a vlc_t structure and returns a negative value 111 * in case of failure. Also, the thread system is initialized. 112 *****************************************************************************/ 113 int VLC_Create( void ) 142 114 { 143 115 int i_ret; … … 148 120 * allowed before the thread system has been initialized. */ 149 121 i_ret = vlc_threads_init( &libvlc ); 150 if( i_ret )151 { 152 return NULL;122 if( i_ret < 0 ) 123 { 124 return i_ret; 153 125 } 154 126 … … 197 169 if( p_vlc == NULL ) 198 170 { 199 return NULL;171 return VLC_EGENERIC; 200 172 } 201 173 … … 208 180 vlc_object_attach( p_vlc, &libvlc ); 209 181 182 /* Store data for the non-reentrant API */ 183 p_static_vlc = p_vlc; 184 210 185 /* Update the handle status */ 211 186 p_vlc->i_status = VLC_STATUS_CREATED; 212 187 213 return p_vlc ;214 } 215 216 /***************************************************************************** 217 * vlc_init: initialize a vlc_t structure.188 return p_vlc->i_object_id; 189 } 190 191 /***************************************************************************** 192 * VLC_Init: initialize a vlc_t structure. 218 193 ***************************************************************************** 219 194 * This function initializes a previously allocated vlc_t structure: … … 223 198 * - configuration and commandline parsing 224 199 *****************************************************************************/ 225 vlc_error_t vlc_init( int i_argc, char *ppsz_argv[] ) 226 { 227 return vlc_init_r( GLOBAL_VLC, i_argc, ppsz_argv ); 228 } 229 230 vlc_error_t vlc_init_r( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) 200 int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] ) 231 201 { 232 202 char p_capabilities[200]; 233 203 char * p_tmp; 234 204 vlc_bool_t b_exit; 205 vlc_t * p_vlc; 235 206 module_t *p_help_module; 236 207 playlist_t *p_playlist; 208 209 p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; 237 210 238 211 /* Check that the handle is valid */ … … 522 495 523 496 /***************************************************************************** 524 * vlc_add_intf: add an interface497 * VLC_AddIntf: add an interface 525 498 ***************************************************************************** 526 499 * This function opens an interface plugin and runs it. If b_block is set 527 * to 0, vlc_add_intf will return immediately and let the interface run in a528 * separate thread. If b_block is set to 1, vlc_add_intf will continue until500 * to 0, VLC_AddIntf will return immediately and let the interface run in a 501 * separate thread. If b_block is set to 1, VLC_AddIntf will continue until 529 502 * user requests to quit. 530 503 *****************************************************************************/ 531 vlc_error_t vlc_add_intf( const char *psz_module, vlc_bool_t b_block ) 532 { 533 return vlc_add_intf_r( GLOBAL_VLC, 534 psz_module, b_block ); 535 } 536 537 vlc_error_t vlc_add_intf_r( vlc_t *p_vlc, const char *psz_module, 538 vlc_bool_t b_block ) 539 { 540 vlc_error_t err; 504 int VLC_AddIntf( int i_object, const char *psz_module, vlc_bool_t b_block ) 505 { 506 int i_err; 541 507 intf_thread_t *p_intf; 508 vlc_t *p_vlc; 542 509 char *psz_oldmodule = NULL; 510 511 p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; 543 512 544 513 /* Check that the handle is valid */ … … 575 544 /* Try to run the interface */ 576 545 p_intf->b_block = b_block; 577 err = intf_RunThread( p_intf );578 if( err )546 i_err = intf_RunThread( p_intf ); 547 if( i_err ) 579 548 { 580 549 vlc_object_detach( p_intf ); 581 550 intf_Destroy( p_intf ); 582 return err;551 return i_err; 583 552 } 584 553 … … 587 556 588 557 /***************************************************************************** 589 * vlc_destroy: stop playing and destroy everything.558 * VLC_Destroy: stop playing and destroy everything. 590 559 ***************************************************************************** 591 560 * This function requests the running threads to finish, waits for their 592 561 * termination, and destroys their structure. 593 562 *****************************************************************************/ 594 vlc_error_t vlc_destroy( void ) 595 { 596 return vlc_destroy_r( GLOBAL_VLC ); 597 } 598 599 vlc_error_t vlc_destroy_r( vlc_t *p_vlc ) 600 { 563 int VLC_Destroy( int i_object ) 564 { 565 vlc_t *p_vlc; 566 567 p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; 568 601 569 /* Check that the handle is valid */ 602 570 if( !p_vlc || (p_vlc->i_status != VLC_STATUS_STOPPED … … 659 627 660 628 /***************************************************************************** 661 * vlc_die: ask vlc to die.629 * VLC_Die: ask vlc to die. 662 630 ***************************************************************************** 663 631 * This function sets p_vlc->b_die to VLC_TRUE, but does not do any other 664 * task. It is your duty to call vlc_end and vlc_destroy afterwards. 665 *****************************************************************************/ 666 vlc_error_t vlc_die( void ) 667 { 668 return vlc_die_r( GLOBAL_VLC ); 669 } 670 671 vlc_error_t vlc_die_r( vlc_t *p_vlc ) 672 { 632 * task. It is your duty to call vlc_end and VLC_Destroy afterwards. 633 *****************************************************************************/ 634 int VLC_Die( int i_object ) 635 { 636 vlc_t *p_vlc; 637 638 p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; 639 673 640 if( !p_vlc ) 674 641 { … … 683 650 684 651 /***************************************************************************** 685 * vlc_status: return the current vlc status. 686 ***************************************************************************** 687 * This function returns the current value of p_vlc->i_status. 688 *****************************************************************************/ 689 vlc_status_t vlc_status( void ) 690 { 691 return vlc_status_r( GLOBAL_VLC ); 692 } 693 694 vlc_status_t vlc_status_r( vlc_t *p_vlc ) 695 { 696 if( !p_vlc ) 697 { 698 return VLC_STATUS_NONE; 699 } 700 701 return p_vlc->i_status; 702 } 703 704 /***************************************************************************** 705 * vlc_add_target: adds a target for playing. 652 * VLC_AddTarget: adds a target for playing. 706 653 ***************************************************************************** 707 654 * This function adds psz_target to the current playlist. If a playlist does 708 655 * not exist, it will create one. 709 656 *****************************************************************************/ 710 vlc_error_t vlc_add_target( const char *psz_target, int i_mode, int i_pos ) 711 { 712 return vlc_add_target_r( GLOBAL_VLC, 713 psz_target, i_mode, i_pos ); 714 } 715 716 vlc_error_t vlc_add_target_r( vlc_t *p_vlc, const char *psz_target, 717 int i_mode, int i_pos ) 718 { 719 vlc_error_t err; 657 int VLC_AddTarget( int i_object, const char *psz_target, int i_mode, int i_pos ) 658 { 659 int i_err; 720 660 playlist_t *p_playlist; 661 vlc_t *p_vlc; 662 663 p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; 721 664 722 665 if( !p_vlc || ( p_vlc->i_status != VLC_STATUS_STOPPED … … 742 685 } 743 686 744 err = playlist_Add( p_playlist, psz_target, i_mode, i_pos );687 i_err = playlist_Add( p_playlist, psz_target, i_mode, i_pos ); 745 688 746 689 vlc_object_release( p_playlist ); 747 690 748 return err;749 } 750 751 /***************************************************************************** 752 * vlc_set: set a vlc variable691 return i_err; 692 } 693 694 /***************************************************************************** 695 * VLC_Set: set a vlc variable 753 696 ***************************************************************************** 754 697 * 755 698 *****************************************************************************/ 756 vlc_error_t vlc_set( const char *psz_var, const char *psz_val ) 757 { 758 return vlc_set_r( GLOBAL_VLC, psz_var, psz_val ); 759 } 760 761
