| 284 | | char p_capabilities[200]; |
|---|
| 285 | | char * p_tmp; |
|---|
| 286 | | char * psz_modules; |
|---|
| 287 | | char * psz_parser; |
|---|
| 288 | | char * psz_control; |
|---|
| 289 | | vlc_bool_t b_exit = VLC_FALSE; |
|---|
| 290 | | int i_ret = VLC_EEXIT; |
|---|
| 291 | | module_t *p_help_module; |
|---|
| 292 | | playlist_t *p_playlist; |
|---|
| 293 | | vlc_value_t val; |
|---|
| 294 | | #if defined( ENABLE_NLS ) \ |
|---|
| 295 | | && ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) ) |
|---|
| 296 | | # if defined (WIN32) || defined (__APPLE__) |
|---|
| 297 | | char * psz_language; |
|---|
| 298 | | #endif |
|---|
| 299 | | #endif |
|---|
| 300 | | LIBVLC_FUNC; |
|---|
| 301 | | |
|---|
| 302 | | /* System specific initialization code */ |
|---|
| 303 | | system_Init( p_libvlc, &i_argc, ppsz_argv ); |
|---|
| 304 | | |
|---|
| 305 | | /* Get the executable name (similar to the basename command) */ |
|---|
| 306 | | if( i_argc > 0 ) |
|---|
| 307 | | { |
|---|
| 308 | | p_libvlc->psz_object_name = p_tmp = ppsz_argv[ 0 ]; |
|---|
| 309 | | while( *p_tmp ) |
|---|
| 310 | | { |
|---|
| 311 | | if( *p_tmp == '/' ) p_libvlc->psz_object_name = ++p_tmp; |
|---|
| 312 | | else ++p_tmp; |
|---|
| 313 | | } |
|---|
| 314 | | } |
|---|
| 315 | | else |
|---|
| 316 | | { |
|---|
| 317 | | p_libvlc->psz_object_name = "vlc"; |
|---|
| 318 | | } |
|---|
| 319 | | |
|---|
| 320 | | /* |
|---|
| 321 | | * Support for gettext |
|---|
| 322 | | */ |
|---|
| 323 | | SetLanguage( "" ); |
|---|
| 324 | | |
|---|
| 325 | | /* |
|---|
| 326 | | * Global iconv, must be done after setlocale() |
|---|
| 327 | | * so that vlc_current_charset() works. |
|---|
| 328 | | */ |
|---|
| 329 | | LocaleInit( (vlc_object_t *)p_libvlc ); |
|---|
| 330 | | |
|---|
| 331 | | /* Translate "C" to the language code: "fr", "en_GB", "nl", "ru"... */ |
|---|
| 332 | | msg_Dbg( p_libvlc, "translation test: code is \"%s\"", _("C") ); |
|---|
| 333 | | |
|---|
| 334 | | /* Initialize the module bank and load the configuration of the |
|---|
| 335 | | * main module. We need to do this at this stage to be able to display |
|---|
| 336 | | * a short help if required by the user. (short help == main module |
|---|
| 337 | | * options) */ |
|---|
| 338 | | module_InitBank( p_libvlc ); |
|---|
| 339 | | |
|---|
| 340 | | /* Hack: insert the help module here */ |
|---|
| 341 | | p_help_module = vlc_object_create( p_libvlc, VLC_OBJECT_MODULE ); |
|---|
| 342 | | if( p_help_module == NULL ) |
|---|
| 343 | | { |
|---|
| 344 | | module_EndBank( p_libvlc ); |
|---|
| 345 | | if( i_object ) vlc_object_release( p_libvlc ); |
|---|
| 346 | | return VLC_EGENERIC; |
|---|
| 347 | | } |
|---|
| 348 | | p_help_module->psz_object_name = "help"; |
|---|
| 349 | | p_help_module->psz_longname = N_("Help options"); |
|---|
| 350 | | config_Duplicate( p_help_module, p_help_config ); |
|---|
| 351 | | vlc_object_attach( p_help_module, libvlc_global.p_module_bank ); |
|---|
| 352 | | /* End hack */ |
|---|
| 353 | | |
|---|
| 354 | | if( config_LoadCmdLine( p_libvlc, &i_argc, ppsz_argv, VLC_TRUE ) ) |
|---|
| 355 | | { |
|---|
| 356 | | vlc_object_detach( p_help_module ); |
|---|
| 357 | | config_Free( p_help_module ); |
|---|
| 358 | | vlc_object_destroy( p_help_module ); |
|---|
| 359 | | module_EndBank( p_libvlc ); |
|---|
| 360 | | if( i_object ) vlc_object_release( p_libvlc ); |
|---|
| 361 | | return VLC_EGENERIC; |
|---|
| 362 | | } |
|---|
| 363 | | |
|---|
| 364 | | /* Check for short help option */ |
|---|
| 365 | | if( config_GetInt( p_libvlc, "help" ) ) |
|---|
| 366 | | { |
|---|
| 367 | | Help( p_libvlc, "help" ); |
|---|
| 368 | | b_exit = VLC_TRUE; |
|---|
| 369 | | i_ret = VLC_EEXITSUCCESS; |
|---|
| 370 | | } |
|---|
| 371 | | /* Check for version option */ |
|---|
| 372 | | else if( config_GetInt( p_libvlc, "version" ) ) |
|---|
| 373 | | { |
|---|
| 374 | | Version(); |
|---|
| 375 | | b_exit = VLC_TRUE; |
|---|
| 376 | | i_ret = VLC_EEXITSUCCESS; |
|---|
| 377 | | } |
|---|
| 378 | | |
|---|
| 379 | | /* Set the config file stuff */ |
|---|
| 380 | | p_libvlc->psz_homedir = config_GetHomeDir(); |
|---|
| 381 | | p_libvlc->psz_userdir = config_GetUserDir(); |
|---|
| 382 | | if( p_libvlc->psz_userdir == NULL ) |
|---|
| 383 | | p_libvlc->psz_userdir = strdup(p_libvlc->psz_homedir); |
|---|
| 384 | | p_libvlc->psz_configfile = config_GetPsz( p_libvlc, "config" ); |
|---|
| 385 | | if( p_libvlc->psz_configfile != NULL && p_libvlc->psz_configfile[0] == '~' |
|---|
| 386 | | && p_libvlc->psz_configfile[1] == '/' ) |
|---|
| 387 | | { |
|---|
| 388 | | char *psz = malloc( strlen(p_libvlc->psz_userdir) |
|---|
| 389 | | + strlen(p_libvlc->psz_configfile) ); |
|---|
| 390 | | /* This is incomplete : we should also support the ~cmassiot/ syntax. */ |
|---|
| 391 | | sprintf( psz, "%s/%s", p_libvlc->psz_userdir, |
|---|
| 392 | | p_libvlc->psz_configfile + 2 ); |
|---|
| 393 | | free( p_libvlc->psz_configfile ); |
|---|
| 394 | | p_libvlc->psz_configfile = psz; |
|---|
| 395 | | } |
|---|
| 396 | | |
|---|
| 397 | | /* Check for plugins cache options */ |
|---|
| 398 | | if( config_GetInt( p_libvlc, "reset-plugins-cache" ) ) |
|---|
| 399 | | { |
|---|
| 400 | | libvlc_global.p_module_bank->b_cache_delete = VLC_TRUE; |
|---|
| 401 | | } |
|---|
| 402 | | |
|---|
| 403 | | /* Hack: remove the help module here */ |
|---|
| 404 | | vlc_object_detach( p_help_module ); |
|---|
| 405 | | /* End hack */ |
|---|
| 406 | | |
|---|
| 407 | | /* Will be re-done properly later on */ |
|---|
| 408 | | p_libvlc->p_libvlc_global->i_verbose = config_GetInt( p_libvlc, "verbose" ); |
|---|
| 409 | | |
|---|
| 410 | | /* Check for daemon mode */ |
|---|
| 411 | | #ifndef WIN32 |
|---|
| 412 | | if( config_GetInt( p_libvlc, "daemon" ) ) |
|---|
| 413 | | { |
|---|
| 414 | | #if HAVE_DAEMON |
|---|
| 415 | | if( daemon( 1, 0) != 0 ) |
|---|
| 416 | | { |
|---|
| 417 | | msg_Err( p_libvlc, "Unable to fork vlc to daemon mode" ); |
|---|
| 418 | | b_exit = VLC_TRUE; |
|---|
| 419 | | } |
|---|
| 420 | | |
|---|
| 421 | | p_libvlc->p_libvlc_global->b_daemon = VLC_TRUE; |
|---|
| 422 | | |
|---|
| 423 | | /* lets check if we need to write the pidfile */ |
|---|
| 424 | | char * psz_pidfile = config_GetPsz( p_libvlc, "pidfile" ); |
|---|
| 425 | | |
|---|
| 426 | | msg_Dbg( p_libvlc, "psz_pidfile is %s", psz_pidfile ); |
|---|
| 427 | | |
|---|
| 428 | | if( psz_pidfile != NULL ) |
|---|
| 429 | | { |
|---|
| 430 | | FILE *pidfile; |
|---|
| 431 | | pid_t i_pid = getpid (); |
|---|
| 432 | | |
|---|
| 433 | | msg_Dbg( p_libvlc, "our PID is %d, writing it to %s", i_pid, psz_pidfile ); |
|---|
| 434 | | |
|---|
| 435 | | pidfile = utf8_fopen( psz_pidfile,"w" ); |
|---|
| 436 | | if( pidfile != NULL ) |
|---|
| 437 | | { |
|---|
| 438 | | utf8_fprintf( pidfile, "%d", (int)i_pid ); |
|---|
| 439 | | fclose( pidfile ); |
|---|
| 440 | | } |
|---|
| 441 | | else |
|---|
| 442 | | { |
|---|
| 443 | | msg_Err( p_libvlc, "Cannot open pid file for writing: %s, error: %s", |
|---|
| 444 | | psz_pidfile, strerror(errno) ); |
|---|
| 445 | | } |
|---|
| 446 | | } |
|---|
| 447 | | |
|---|
| 448 | | free( psz_pidfile ); |
|---|
| 449 | | |
|---|
| 450 | | #else |
|---|
| 451 | | pid_t i_pid; |
|---|
| 452 | | |
|---|
| 453 | | if( ( i_pid = fork() ) < 0 ) |
|---|
| 454 | | { |
|---|
| 455 | | msg_Err( p_libvlc, "Unable to fork vlc to daemon mode" ); |
|---|
| 456 | | b_exit = VLC_TRUE; |
|---|
| 457 | | } |
|---|
| 458 | | else if( i_pid ) |
|---|
| 459 | | { |
|---|
| 460 | | /* This is the parent, exit right now */ |
|---|
| 461 | | msg_Dbg( p_libvlc, "closing parent process" ); |
|---|
| 462 | | b_exit = VLC_TRUE; |
|---|
| 463 | | i_ret = VLC_EEXITSUCCESS; |
|---|
| 464 | | } |
|---|
| 465 | | else |
|---|
| 466 | | { |
|---|
| 467 | | /* We are the child */ |
|---|
| 468 | | msg_Dbg( p_libvlc, "daemon spawned" ); |
|---|
| 469 | | close( STDIN_FILENO ); |
|---|
| 470 | | close( STDOUT_FILENO ); |
|---|
| 471 | | close( STDERR_FILENO ); |
|---|
| 472 | | |
|---|
| 473 | | p_libvlc->p_libvlc_global->b_daemon = VLC_TRUE; |
|---|
| 474 | | } |
|---|
| 475 | | #endif |
|---|
| 476 | | } |
|---|
| 477 | | #endif |
|---|
| 478 | | |
|---|
| 479 | | if( b_exit ) |
|---|
| 480 | | { |
|---|
| 481 | | config_Free( p_help_module ); |
|---|
| 482 | | vlc_object_destroy( p_help_module ); |
|---|
| 483 | | module_EndBank( p_libvlc ); |
|---|
| 484 | | if( i_object ) vlc_object_release( p_libvlc ); |
|---|
| 485 | | return i_ret; |
|---|
| 486 | | } |
|---|
| 487 | | |
|---|
| 488 | | /* Check for translation config option */ |
|---|
| 489 | | #if defined( ENABLE_NLS ) \ |
|---|
| 490 | | && ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) ) |
|---|
| 491 | | # if defined (WIN32) || defined (__APPLE__) |
|---|
| 492 | | /* This ain't really nice to have to reload the config here but it seems |
|---|
| 493 | | * the only way to do it. */ |
|---|
| 494 | | config_LoadConfigFile( p_libvlc, "main" ); |
|---|
| 495 | | config_LoadCmdLine( p_libvlc, &i_argc, ppsz_argv, VLC_TRUE ); |
|---|
| 496 | | |
|---|
| 497 | | /* Check if the user specified a custom language */ |
|---|
| 498 | | psz_language = config_GetPsz( p_libvlc, "language" ); |
|---|
| 499 | | if( psz_language && *psz_language && strcmp( psz_language, "auto" ) ) |
|---|
| 500 | | { |
|---|
| 501 | | vlc_bool_t b_cache_delete = libvlc_global.p_module_bank->b_cache_delete; |
|---|
| 502 | | |
|---|
| 503 | | /* Reset the default domain */ |
|---|
| 504 | | SetLanguage( psz_language ); |
|---|
| 505 | | |
|---|
| 506 | | /* Translate "C" to the language code: "fr", "en_GB", "nl", "ru"... */ |
|---|
| 507 | | msg_Dbg( p_libvlc, "translation test: code is \"%s\"", _("C") ); |
|---|
| 508 | | |
|---|
| 509 | | module_EndBank( p_libvlc ); |
|---|
| 510 | | module_InitBank( p_libvlc ); |
|---|
| 511 | | config_LoadConfigFile( p_libvlc, "main" ); |
|---|
| 512 | | config_LoadCmdLine( p_libvlc, &i_argc, ppsz_argv, VLC_TRUE ); |
|---|
| 513 | | libvlc_global.p_module_bank->b_cache_delete = b_cache_delete; |
|---|
| 514 | | } |
|---|
| 515 | | if( psz_language ) free( psz_language ); |
|---|
| 516 | | # endif |
|---|
| 517 | | #endif |
|---|
| 518 | | |
|---|
| 519 | | /* |
|---|
| 520 | | * Load the builtins and plugins into the module_bank. |
|---|
| 521 | | * We have to do it before config_Load*() because this also gets the |
|---|
| 522 | | * list of configuration options exported by each module and loads their |
|---|
| 523 | | * default values. |
|---|
| 524 | | */ |
|---|
| 525 | | module_LoadBuiltins( p_libvlc ); |
|---|
| 526 | | module_LoadPlugins( p_libvlc ); |
|---|
| 527 | | if( p_libvlc->b_die ) |
|---|
| 528 | | { |
|---|
| 529 | | b_exit = VLC_TRUE; |
|---|
| 530 | | } |
|---|
| 531 | | |
|---|
| 532 | | msg_Dbg( p_libvlc, "module bank initialized, found %i modules", |
|---|
| 533 | | libvlc_global.p_module_bank->i_children ); |
|---|
| 534 | | |
|---|
| 535 | | /* Hack: insert the help module here */ |
|---|
| 536 | | vlc_object_attach( p_help_module, libvlc_global.p_module_bank ); |
|---|
| 537 | | /* End hack */ |
|---|
| 538 | | |
|---|
| 539 | | /* Check for help on modules */ |
|---|
| 540 | | if( (p_tmp = config_GetPsz( p_libvlc, "module" )) ) |
|---|
| 541 | | { |
|---|
| 542 | | Help( p_libvlc, p_tmp ); |
|---|
| 543 | | free( p_tmp ); |
|---|
| 544 | | b_exit = VLC_TRUE; |
|---|
| 545 | | i_ret = VLC_EEXITSUCCESS; |
|---|
| 546 | | } |
|---|
| 547 | | /* Check for long help option */ |
|---|
| 548 | | else if( config_GetInt( p_libvlc, "longhelp" ) ) |
|---|
| 549 | | { |
|---|
| 550 | | Help( p_libvlc, "longhelp" ); |
|---|
| 551 | | b_exit = VLC_TRUE; |
|---|
| 552 | | i_ret = VLC_EEXITSUCCESS; |
|---|
| 553 | | } |
|---|
| 554 | | /* Check for module list option */ |
|---|
| 555 | | else if( config_GetInt( p_libvlc, "list" ) ) |
|---|
| 556 | | { |
|---|
| 557 | | ListModules( p_libvlc ); |
|---|
| 558 | | b_exit = VLC_TRUE; |
|---|
| 559 | | i_ret = VLC_EEXITSUCCESS; |
|---|
| 560 | | } |
|---|
| 561 | | |
|---|
| 562 | | /* Check for config file options */ |
|---|
| 563 | | if( config_GetInt( p_libvlc, "reset-config" ) ) |
|---|
| 564 | | { |
|---|
| 565 | | vlc_object_detach( p_help_module ); |
|---|
| 566 | | config_ResetAll( p_libvlc ); |
|---|
| 567 | | config_LoadCmdLine( p_libvlc, &i_argc, ppsz_argv, VLC_TRUE ); |
|---|
| 568 | | config_SaveConfigFile( p_libvlc, NULL ); |
|---|
| 569 | | vlc_object_attach( p_help_module, libvlc_global.p_module_bank ); |
|---|
| 570 | | } |
|---|
| 571 | | if( config_GetInt( p_libvlc, "save-config" ) ) |
|---|
| 572 | | { |
|---|
| 573 | | vlc_object_detach( p_help_module ); |
|---|
| 574 | | config_LoadConfigFile( p_libvlc, NULL ); |
|---|
| 575 | | config_LoadCmdLine( p_libvlc, &i_argc, ppsz_argv, VLC_TRUE ); |
|---|
| 576 | | config_SaveConfigFile( p_libvlc, NULL ); |
|---|
| 577 | | vlc_object_attach( p_help_module, libvlc_global.p_module_bank ); |
|---|
| 578 | | } |
|---|
| 579 | | |
|---|
| 580 | | /* Hack: remove the help module here */ |
|---|
| 581 | | vlc_object_detach( p_help_module ); |
|---|
| 582 | | /* End hack */ |
|---|
| 583 | | |
|---|
| 584 | | if( b_exit ) |
|---|
| 585 | | { |
|---|
| 586 | | config_Free( p_help_module ); |
|---|
| 587 | | vlc_object_destroy( p_help_module ); |
|---|
| 588 | | module_EndBank( p_libvlc ); |
|---|
| 589 | | if( i_object ) vlc_object_release( p_libvlc ); |
|---|
| 590 | | return i_ret; |
|---|
| 591 | | } |
|---|
| 592 | | |
|---|
| 593 | | /* |
|---|
| 594 | | * Init device values |
|---|
| 595 | | */ |
|---|
| 596 | | InitDeviceValues( p_libvlc ); |
|---|
| 597 | | |
|---|
| 598 | | /* |
|---|
| 599 | | * Override default configuration with config file settings |
|---|
| 600 | | */ |
|---|
| 601 | | config_LoadConfigFile( p_libvlc, NULL ); |
|---|
| 602 | | |
|---|
| 603 | | /* Hack: insert the help module here */ |
|---|
| 604 | | vlc_object_attach( p_help_module, libvlc_global.p_module_bank ); |
|---|
| 605 | | /* End hack */ |
|---|
| 606 | | |
|---|
| 607 | | /* |
|---|
| 608 | | * Override configuration with command line settings |
|---|
| 609 | | */ |
|---|
| 610 | | if( config_LoadCmdLine( p_libvlc, &i_argc, ppsz_argv, VLC_FALSE ) ) |
|---|
| 611 | | { |
|---|
| 612 | | #ifdef WIN32 |
|---|
| 613 | | ShowConsole( VLC_FALSE ); |
|---|
| 614 | | /* Pause the console because it's destroyed when we exit */ |
|---|
| 615 | | fprintf( stderr, "The command line options couldn't be loaded, check " |
|---|
| 616 | | "that they are valid.\n" ); |
|---|
| 617 | | PauseConsole(); |
|---|
| 618 | | #endif |
|---|
| 619 | | vlc_object_detach( p_help_module ); |
|---|
| 620 | | config_Free( p_help_module ); |
|---|
| 621 | | vlc_object_destroy( p_help_module ); |
|---|
| 622 | | module_EndBank( p_libvlc ); |
|---|
| 623 | | if( i_object ) vlc_object_release( p_libvlc ); |
|---|
| 624 | | return VLC_EGENERIC; |
|---|
| 625 | | } |
|---|
| 626 | | |
|---|
| 627 | | /* Hack: remove the help module here */ |
|---|
| 628 | | vlc_object_detach( p_help_module ); |
|---|
| 629 | | config_Free( p_help_module ); |
|---|
| 630 | | vlc_object_destroy( p_help_module ); |
|---|
| 631 | | /* End hack */ |
|---|
| 632 | | |
|---|
| 633 | | /* |
|---|
| 634 | | * System specific configuration |
|---|
| 635 | | */ |
|---|
| 636 | | system_Configure( p_libvlc, &i_argc, ppsz_argv ); |
|---|
| 637 | | |
|---|
| 638 | | /* |
|---|
| 639 | | * Message queue options |
|---|
| 640 | | */ |
|---|
| 641 | | |
|---|
| 642 | | var_Create( p_libvlc, "verbose", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); |
|---|
| 643 | | if( config_GetInt( p_libvlc, "quiet" ) ) |
|---|
| 644 | | { |
|---|
| 645 | | val.i_int = -1; |
|---|
| 646 | | var_Set( p_libvlc, "verbose", val ); |
|---|
| 647 | | } |
|---|
| 648 | | var_AddCallback( p_libvlc, "verbose", VerboseCallback, NULL ); |
|---|
| 649 | | var_Change( p_libvlc, "verbose", VLC_VAR_TRIGGER_CALLBACKS, NULL, NULL ); |
|---|
| 650 | | |
|---|
| 651 | | libvlc_global.b_color = libvlc_global.b_color && |
|---|
| 652 | | config_GetInt( p_libvlc, "color" ); |
|---|
| 653 | | |
|---|
| 654 | | /* |
|---|
| 655 | | * Output messages that may still be in the queue |
|---|
| 656 | | */ |
|---|
| 657 | | msg_Flush( p_libvlc ); |
|---|
| 658 | | |
|---|
| 659 | | /* p_libvlc initialization. FIXME ? */ |
|---|
| 660 | | |
|---|
| 661 | | if( !config_GetInt( p_libvlc, "fpu" ) ) |
|---|
| 662 | | libvlc_global.i_cpu &= ~CPU_CAPABILITY_FPU; |
|---|
| 663 | | |
|---|
| 664 | | #if defined( __i386__ ) || defined( __x86_64__ ) |
|---|
| 665 | | if( !config_GetInt( p_libvlc, "mmx" ) ) |
|---|
| 666 | | libvlc_global.i_cpu &= ~CPU_CAPABILITY_MMX; |
|---|
| 667 | | if( !config_GetInt( p_libvlc, "3dn" ) ) |
|---|
| 668 | | libvlc_global.i_cpu &= ~CPU_CAPABILITY_3DNOW; |
|---|
| 669 | | if( !config_GetInt( p_libvlc, "mmxext" ) ) |
|---|
| 670 | | libvlc_global.i_cpu &= ~CPU_CAPABILITY_MMXEXT; |
|---|
| 671 | | if( !config_GetInt( p_libvlc, "sse" ) ) |
|---|
| 672 | | libvlc_global.i_cpu &= ~CPU_CAPABILITY_SSE; |
|---|
| 673 | | if( !config_GetInt( p_libvlc, "sse2" ) ) |
|---|
| 674 | | libvlc_global.i_cpu &= ~CPU_CAPABILITY_SSE2; |
|---|
| 675 | | #endif |
|---|
| 676 | | #if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ ) |
|---|
| 677 | | if( !config_GetInt( p_libvlc, "altivec" ) ) |
|---|
| 678 | | libvlc_global.i_cpu &= ~CPU_CAPABILITY_ALTIVEC; |
|---|
| 679 | | #endif |
|---|
| 680 | | |
|---|
| 681 | | #define PRINT_CAPABILITY( capability, string ) \ |
|---|
| 682 | | if( libvlc_global.i_cpu & capability ) \ |
|---|
| 683 | | { \ |
|---|
| 684 | | strncat( p_capabilities, string " ", \ |
|---|
| 685 | | sizeof(p_capabilities) - strlen(p_capabilities) ); \ |
|---|
| 686 | | p_capabilities[sizeof(p_capabilities) - 1] = '\0'; \ |
|---|
| 687 | | } |
|---|
| 688 | | |
|---|
| 689 | | p_capabilities[0] = '\0'; |
|---|
| 690 | | PRINT_CAPABILITY( CPU_CAPABILITY_486, "486" ); |
|---|
| 691 | | PRINT_CAPABILITY( CPU_CAPABILITY_586, "586" ); |
|---|
| 692 | | PRINT_CAPABILITY( CPU_CAPABILITY_PPRO, "Pentium Pro" ); |
|---|
| 693 | | PRINT_CAPABILITY( CPU_CAPABILITY_MMX, "MMX" ); |
|---|
| 694 | | PRINT_CAPABILITY( CPU_CAPABILITY_3DNOW, "3DNow!" ); |
|---|
| 695 | | PRINT_CAPABILITY( CPU_CAPABILITY_MMXEXT, "MMXEXT" ); |
|---|
| 696 | | PRINT_CAPABILITY( CPU_CAPABILITY_SSE, "SSE" ); |
|---|
| 697 | | PRINT_CAPABILITY( CPU_CAPABILITY_SSE2, "SSE2" ); |
|---|
| 698 | | PRINT_CAPABILITY( CPU_CAPABILITY_ALTIVEC, "AltiVec" ); |
|---|
| 699 | | PRINT_CAPABILITY( CPU_CAPABILITY_FPU, "FPU" ); |
|---|
| 700 | | msg_Dbg( p_libvlc, "CPU has capabilities %s", p_capabilities ); |
|---|
| 701 | | |
|---|
| 702 | | /* |
|---|
| 703 | | * Choose the best memcpy module |
|---|
| 704 | | */ |
|---|
| 705 | | p_libvlc->p_memcpy_module = module_Need( p_libvlc, "memcpy", "$memcpy", 0 ); |
|---|
| 706 | | |
|---|
| 707 | | if( p_libvlc->pf_memcpy == NULL ) |
|---|
| 708 | | { |
|---|
| 709 | | p_libvlc->pf_memcpy = memcpy; |
|---|
| 710 | | } |
|---|
| 711 | | |
|---|
| 712 | | if( p_libvlc->pf_memset == NULL ) |
|---|
| 713 | | { |
|---|
| 714 | | p_libvlc->pf_memset = memset; |
|---|
| 715 | | } |
|---|
| 716 | | |
|---|
| 717 | | p_libvlc->b_stats = config_GetInt( p_libvlc, "stats" ); |
|---|
| 718 | | p_libvlc->i_timers = 0; |
|---|
| 719 | | p_libvlc->pp_timers = NULL; |
|---|
| 720 | | vlc_mutex_init( p_libvlc, &p_libvlc->timer_lock ); |
|---|
| 721 | | |
|---|
| 722 | | /* |
|---|
| 723 | | * Initialize hotkey handling |
|---|
| 724 | | */ |
|---|
| 725 | | var_Create( p_libvlc, "key-pressed", VLC_VAR_INTEGER ); |
|---|
| 726 | | p_libvlc->p_hotkeys = malloc( sizeof(p_hotkeys) ); |
|---|
| 727 | | /* Do a copy (we don't need to modify the strings) */ |
|---|
| 728 | | memcpy( p_libvlc->p_hotkeys, p_hotkeys, sizeof(p_hotkeys) ); |
|---|
| 729 | | |
|---|
| 730 | | /* Initialize playlist and get commandline files */ |
|---|
| 731 | | playlist_ThreadCreate( p_libvlc ); |
|---|
| 732 | | if( !p_libvlc->p_playlist ) |
|---|
| 733 | | { |
|---|
| 734 | | msg_Err( p_libvlc, "playlist initialization failed" ); |
|---|
| 735 | | if( p_libvlc->p_memcpy_module != NULL ) |
|---|
| 736 | | { |
|---|
| 737 | | module_Unneed( p_libvlc, p_libvlc->p_memcpy_module ); |
|---|
| 738 | | } |
|---|
| 739 | | module_EndBank( p_libvlc ); |
|---|
| 740 | | if( i_object ) vlc_object_release( p_libvlc ); |
|---|
| 741 | | return VLC_EGENERIC; |
|---|
| 742 | | } |
|---|
| 743 | | p_playlist = p_libvlc->p_playlist; |
|---|
| 744 | | |
|---|
| 745 | | psz_modules = config_GetPsz( p_playlist, "services-discovery" ); |
|---|
| 746 | | if( psz_modules && *psz_modules ) |
|---|
| 747 | | { |
|---|
| 748 | | /* Add service discovery modules */ |
|---|
| 749 | | playlist_AddSDModules( p_playlist, psz_modules ); |
|---|
| 750 | | } |
|---|
| 751 | | if( psz_modules ) free( psz_modules ); |
|---|
| 752 | | |
|---|
| 753 | | /* |
|---|
| 754 | | * Load background interfaces |
|---|
| 755 | | */ |
|---|
| 756 | | psz_modules = config_GetPsz( p_libvlc, "extraintf" ); |
|---|
| 757 | | psz_control = config_GetPsz( p_libvlc, "control" ); |
|---|
| 758 | | |
|---|
| 759 | | if( psz_modules && *psz_modules && psz_control && *psz_control ) |
|---|
| 760 | | { |
|---|
| 761 | | psz_modules = (char *)realloc( psz_modules, strlen( psz_modules ) + |
|---|
| 762 | | strlen( psz_control ) + 1 ); |
|---|
| 763 | | sprintf( psz_modules, "%s:%s", psz_modules, psz_control ); |
|---|
| 764 | | } |
|---|
| 765 | | else if( psz_control && *psz_control ) |
|---|
| 766 | | { |
|---|
| 767 | | if( psz_modules ) free( psz_modules ); |
|---|
| 768 | | psz_modules = strdup( psz_control ); |
|---|
| 769 | | } |
|---|
| 770 | | |
|---|
| 771 | | psz_parser = psz_modules; |
|---|
| 772 | | while ( psz_parser && *psz_parser ) |
|---|
| 773 | | { |
|---|
| 774 | | char *psz_module, *psz_temp; |
|---|
| 775 | | psz_module = psz_parser; |
|---|
| 776 | | psz_parser = strchr( psz_module, ':' ); |
|---|
| 777 | | if ( psz_parser ) |
|---|
| 778 | | { |
|---|
| 779 | | *psz_parser = '\0'; |
|---|
| 780 | | psz_parser++; |
|---|
| 781 | | } |
|---|
| 782 | | psz_temp = (char *)malloc( strlen(psz_module) + sizeof(",none") ); |
|---|
| 783 | | if( psz_temp ) |
|---|
| 784 | | { |
|---|
| 785 | | sprintf( psz_temp, "%s,none", psz_module ); |
|---|
| 786 | | VLC_AddIntf( 0, psz_temp, VLC_FALSE, VLC_FALSE ); |
|---|
| 787 | | free( psz_temp ); |
|---|
| 788 | | } |
|---|
| 789 | | } |
|---|
| 790 | | if ( psz_modules ) |
|---|
| 791 | | { |
|---|
| 792 | | free( psz_modules ); |
|---|
| 793 | | } |
|---|
| 794 | | |
|---|
| 795 | | /* |
|---|
| 796 | | * Always load the hotkeys interface if it exists |
|---|
| 797 | | */ |
|---|
| 798 | | VLC_AddIntf( 0, "hotkeys,none", VLC_FALSE, VLC_FALSE ); |
|---|
| 799 | | |
|---|
| 800 | | /* |
|---|
| 801 | | * If needed, load the Xscreensaver interface |
|---|
| 802 | | * Currently, only for X |
|---|
| 803 | | */ |
|---|
| 804 | | #ifdef HAVE_X11_XLIB_H |
|---|
| 805 | | if( config_GetInt( p_libvlc, "disable-screensaver" ) == 1 ) |
|---|
| 806 | | { |
|---|
| 807 | | VLC_AddIntf( 0, "screensaver,none", VLC_FALSE, VLC_FALSE ); |
|---|
| 808 | | } |
|---|
| 809 | | #endif |
|---|
| 810 | | |
|---|
| 811 | | if( config_GetInt( p_libvlc, "file-logging" ) == 1 ) |
|---|
| 812 | | { |
|---|
| 813 | | VLC_AddIntf( 0, "logger,none", VLC_FALSE, VLC_FALSE ); |
|---|
| 814 | | } |
|---|
| 815 | | #ifdef HAVE_SYSLOG_H |
|---|
| 816 | | if( config_GetInt( p_libvlc, "syslog" ) == 1 ) |
|---|
| 817 | | { |
|---|
| 818 | | char *psz_logmode = "logmode=syslog"; |
|---|
| 819 | | AddIntfInternal( 0, "logger,none", VLC_FALSE, VLC_FALSE, 1, &psz_logmode ); |
|---|
| 820 | | } |
|---|
| 821 | | #endif |
|---|
| 822 | | |
|---|
| 823 | | if( config_GetInt( p_libvlc, "show-intf" ) == 1 ) |
|---|
| 824 | | { |
|---|
| 825 | | VLC_AddIntf( 0, "showintf,none", VLC_FALSE, VLC_FALSE ); |
|---|
| 826 | | } |
|---|
| 827 | | |
|---|
| 828 | | if( config_GetInt( p_libvlc, "network-synchronisation") == 1 ) |
|---|
| 829 | | { |
|---|
| 830 | | VLC_AddIntf( 0, "netsync,none", VLC_FALSE, VLC_FALSE ); |
|---|
| 831 | | } |
|---|
| 832 | | |
|---|
| 833 | | /* |
|---|
| 834 | | * FIXME: kludge to use a p_libvlc-local variable for the Mozilla plugin |
|---|
| 835 | | */ |
|---|
| 836 | | var_Create( p_libvlc, "drawable", VLC_VAR_INTEGER ); |
|---|
| 837 | | var_Create( p_libvlc, "drawable-view-top", VLC_VAR_INTEGER ); |
|---|
| 838 | | var_Create( p_libvlc, "drawable-view-left", VLC_VAR_INTEGER ); |
|---|
| 839 | | var_Create( p_libvlc, "drawable-view-bottom", VLC_VAR_INTEGER ); |
|---|
| 840 | | var_Create( p_libvlc, "drawable-view-right", VLC_VAR_INTEGER ); |
|---|
| 841 | | var_Create( p_libvlc, "drawable-clip-top", VLC_VAR_INTEGER ); |
|---|
| 842 | | var_Create( p_libvlc, "drawable-clip-left", VLC_VAR_INTEGER ); |
|---|
| 843 | | var_Create( p_libvlc, "drawable-clip-bottom", VLC_VAR_INTEGER ); |
|---|
| 844 | | var_Create( p_libvlc, "drawable-clip-right", VLC_VAR_INTEGER ); |
|---|
| 845 | | |
|---|
| 846 | | /* Create volume callback system. */ |
|---|
| 847 | | var_Create( p_libvlc, "volume-change", VLC_VAR_BOOL ); |
|---|
| 848 | | |
|---|
| 849 | | /* |
|---|
| 850 | | * Get input filenames given as commandline arguments |
|---|
| 851 | | */ |
|---|
| 852 | | GetFilenames( p_libvlc, i_argc, ppsz_argv ); |
|---|
| 853 | | |
|---|
| 854 | | /* |
|---|
| 855 | | * Get --open argument |
|---|
| 856 | | */ |
|---|
| 857 | | var_Create( p_libvlc, "open", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); |
|---|
| 858 | | var_Get( p_libvlc, "open", &val ); |
|---|
| 859 | | if ( val.psz_string != NULL && *val.psz_string ) |
|---|
| 860 | | { |
|---|
| 861 | | VLC_AddTarget( p_libvlc->i_object_id, val.psz_string, NULL, 0, |
|---|
| 862 | | PLAYLIST_INSERT, 0 ); |
|---|
| 863 | | } |
|---|
| 864 | | if ( val.psz_string != NULL ) free( val.psz_string ); |
|---|
| 865 | | |
|---|
| 866 | | LIBVLC_FUNC_END; |
|---|
| 867 | | return VLC_SUCCESS; |
|---|
| | 123 | int i_ret; |
|---|
| | 124 | LIBVLC_FUNC; |
|---|
| | 125 | i_ret = libvlc_InternalInit( p_libvlc, i_argc, ppsz_argv ); |
|---|
| | 126 | LIBVLC_FUNC_END; |
|---|
| | 127 | return i_ret; |
|---|