Changeset dbdd540a2e2aefb8f572d199ddd1b850f9d97f11
- Timestamp:
- 23/03/08 00:55:15
(7 months ago)
- Author:
- Pierre d'Herbemont <pdherbemont@videolan.org>
- git-committer:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1206230115 +0100
- git-parent:
[f0fbb2b3eeb132bf961902f156e31431d43a6938]
- git-author:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1206230115 +0100
- Message:
interaction: Keep a libvlc's global interaction object reference around, and properly release it when done.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r0d0f59a |
rdbdd540 |
|
| 46 | 46 | playlist_t *p_playlist; ///< playlist object |
|---|
| 47 | 47 | |
|---|
| | 48 | vlc_object_t *p_interaction; ///< interface interaction object |
|---|
| | 49 | |
|---|
| 48 | 50 | /* Messages */ |
|---|
| 49 | 51 | msg_bank_t msg_bank; ///< The message bank |
|---|
| r55f3a9f |
rdbdd540 |
|
| 39 | 39 | |
|---|
| 40 | 40 | #include <vlc_interface.h> |
|---|
| | 41 | #include "interface.h" |
|---|
| 41 | 42 | |
|---|
| 42 | 43 | /***************************************************************************** |
|---|
| 43 | 44 | * Local prototypes |
|---|
| 44 | 45 | *****************************************************************************/ |
|---|
| 45 | | static interaction_t * InteractionInit( libvlc_int_t * ); |
|---|
| 46 | 46 | static interaction_t * InteractionGet( vlc_object_t * ); |
|---|
| 47 | 47 | static void InteractionSearchInterface( interaction_t * ); |
|---|
| 48 | 48 | static void InteractionLoop( vlc_object_t * ); |
|---|
| 49 | 49 | static void InteractionManage( interaction_t * ); |
|---|
| | 50 | static void interaction_Destructor( vlc_object_t *p_interaction ); |
|---|
| 50 | 51 | |
|---|
| 51 | 52 | static interaction_dialog_t *DialogGetById( interaction_t* , int ); |
|---|
| … | … | |
| 347 | 348 | } |
|---|
| 348 | 349 | |
|---|
| 349 | | /********************************************************************** |
|---|
| 350 | | * The following functions are local |
|---|
| 351 | | **********************************************************************/ |
|---|
| 352 | | |
|---|
| 353 | | /* Get the interaction object. Create it if needed */ |
|---|
| 354 | | static interaction_t * InteractionGet( vlc_object_t *p_this ) |
|---|
| 355 | | { |
|---|
| 356 | | interaction_t *p_interaction = |
|---|
| 357 | | vlc_object_find( p_this, VLC_OBJECT_INTERACTION, FIND_ANYWHERE ); |
|---|
| 358 | | |
|---|
| 359 | | if( !p_interaction ) |
|---|
| 360 | | p_interaction = InteractionInit( p_this->p_libvlc ); |
|---|
| 361 | | |
|---|
| 362 | | return p_interaction; |
|---|
| 363 | | } |
|---|
| 364 | | |
|---|
| 365 | | /* Create the interaction object in the given playlist object */ |
|---|
| 366 | | static interaction_t * InteractionInit( libvlc_int_t *p_libvlc ) |
|---|
| 367 | | { |
|---|
| 368 | | interaction_t *p_interaction = |
|---|
| 369 | | vlc_object_create( p_libvlc, VLC_OBJECT_INTERACTION ); |
|---|
| | 350 | /** |
|---|
| | 351 | * Create the initial interaction object |
|---|
| | 352 | * (should only be used in libvlc_InternalInit, LibVLC private) |
|---|
| | 353 | * |
|---|
| | 354 | * \return a vlc_object_t that should be freed when done. |
|---|
| | 355 | */ |
|---|
| | 356 | vlc_object_t * interaction_Init( libvlc_int_t *p_libvlc ) |
|---|
| | 357 | { |
|---|
| | 358 | interaction_t *p_interaction; |
|---|
| | 359 | |
|---|
| | 360 | /* Make sure we haven't yet created an interaction object */ |
|---|
| | 361 | assert( vlc_object_find( p_libvlc, VLC_OBJECT_INTERACTION, FIND_ANYWHERE ) == NULL ); |
|---|
| | 362 | |
|---|
| | 363 | p_interaction = vlc_object_create( p_libvlc, VLC_OBJECT_INTERACTION ); |
|---|
| 370 | 364 | |
|---|
| 371 | 365 | if( p_interaction ) |
|---|
| … | … | |
| 388 | 382 | p_interaction = NULL; |
|---|
| 389 | 383 | } |
|---|
| 390 | | else |
|---|
| 391 | | vlc_object_yield( p_interaction ); |
|---|
| 392 | | } |
|---|
| 393 | | |
|---|
| 394 | | return p_interaction; |
|---|
| 395 | | } |
|---|
| | 384 | } |
|---|
| | 385 | |
|---|
| | 386 | vlc_object_set_destructor( p_interaction, interaction_Destructor ); |
|---|
| | 387 | |
|---|
| | 388 | return VLC_OBJECT( p_interaction ); |
|---|
| | 389 | } |
|---|
| | 390 | |
|---|
| | 391 | static void interaction_Destructor( vlc_object_t *p_interaction ) |
|---|
| | 392 | { |
|---|
| | 393 | vlc_thread_join( p_interaction ); |
|---|
| | 394 | } |
|---|
| | 395 | |
|---|
| | 396 | /********************************************************************** |
|---|
| | 397 | * The following functions are local |
|---|
| | 398 | **********************************************************************/ |
|---|
| | 399 | |
|---|
| | 400 | /* Get the interaction object. Create it if needed */ |
|---|
| | 401 | static interaction_t * InteractionGet( vlc_object_t *p_this ) |
|---|
| | 402 | { |
|---|
| | 403 | return vlc_object_find( p_this, VLC_OBJECT_INTERACTION, FIND_ANYWHERE ); |
|---|
| | 404 | } |
|---|
| | 405 | |
|---|
| 396 | 406 | |
|---|
| 397 | 407 | /* Look for an interface suitable for interaction */ |
|---|
| … | … | |
| 551 | 561 | REMOVE_ELEM( p_interaction->pp_dialogs, p_interaction->i_dialogs, i ); |
|---|
| 552 | 562 | } |
|---|
| 553 | | |
|---|
| 554 | | vlc_object_detach( p_this ); |
|---|
| 555 | | vlc_object_release( p_this ); |
|---|
| 556 | 563 | } |
|---|
| 557 | 564 | |
|---|
| r8594365 |
rdbdd540 |
|
| 43 | 43 | #include "modules/modules.h" |
|---|
| 44 | 44 | #include "config/configuration.h" |
|---|
| | 45 | #include "interface/interface.h" |
|---|
| 45 | 46 | |
|---|
| 46 | 47 | #include <errno.h> /* ENOMEM */ |
|---|
| … | … | |
| 193 | 194 | } |
|---|
| 194 | 195 | p_libvlc->p_playlist = NULL; |
|---|
| | 196 | p_libvlc->p_interaction = NULL; |
|---|
| 195 | 197 | p_libvlc->psz_object_name = "libvlc"; |
|---|
| 196 | 198 | |
|---|
| … | … | |
| 733 | 735 | memcpy( p_libvlc->p_hotkeys, libvlc_hotkeys, libvlc_hotkeys_size ); |
|---|
| 734 | 736 | |
|---|
| | 737 | /* Initialize interaction */ |
|---|
| | 738 | p_libvlc->p_interaction = interaction_Init( p_libvlc ); |
|---|
| | 739 | |
|---|
| 735 | 740 | /* Initialize playlist and get commandline files */ |
|---|
| 736 | 741 | playlist_ThreadCreate( p_libvlc ); |
|---|
| … | … | |
| 945 | 950 | aout_Delete( p_aout ); |
|---|
| 946 | 951 | } |
|---|
| | 952 | |
|---|
| | 953 | /* Free interaction */ |
|---|
| | 954 | msg_Dbg( p_libvlc, "removing interaction" ); |
|---|
| | 955 | vlc_object_release( p_libvlc->p_interaction ); |
|---|
| 947 | 956 | |
|---|
| 948 | 957 | stats_TimersDumpAll( p_libvlc ); |
|---|