Changeset dbdd540a2e2aefb8f572d199ddd1b850f9d97f11

Show
Ignore:
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
  • include/main.h

    r0d0f59a rdbdd540  
    4646    playlist_t            *p_playlist;       ///< playlist object 
    4747 
     48    vlc_object_t          *p_interaction;       ///< interface interaction object 
     49 
    4850    /* Messages */ 
    4951    msg_bank_t             msg_bank;    ///< The message bank 
  • src/interface/interaction.c

    r55f3a9f rdbdd540  
    3939 
    4040#include <vlc_interface.h> 
     41#include "interface.h" 
    4142 
    4243/***************************************************************************** 
    4344 * Local prototypes 
    4445 *****************************************************************************/ 
    45 static interaction_t *          InteractionInit( libvlc_int_t * ); 
    4646static interaction_t *          InteractionGet( vlc_object_t * ); 
    4747static void                     InteractionSearchInterface( interaction_t * ); 
    4848static void                     InteractionLoop( vlc_object_t * ); 
    4949static void                     InteractionManage( interaction_t * ); 
     50static void interaction_Destructor( vlc_object_t *p_interaction ); 
    5051 
    5152static interaction_dialog_t    *DialogGetById( interaction_t* , int ); 
     
    347348} 
    348349 
    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 */ 
     356vlc_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 ); 
    370364 
    371365    if( p_interaction ) 
     
    388382            p_interaction = NULL; 
    389383        } 
    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 
     391static 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 */ 
     401static interaction_t * InteractionGet( vlc_object_t *p_this ) 
     402
     403    return vlc_object_find( p_this, VLC_OBJECT_INTERACTION, FIND_ANYWHERE ); 
     404
     405 
    396406 
    397407/* Look for an interface suitable for interaction */ 
     
    551561        REMOVE_ELEM( p_interaction->pp_dialogs, p_interaction->i_dialogs, i ); 
    552562    } 
    553  
    554     vlc_object_detach( p_this ); 
    555     vlc_object_release( p_this ); 
    556563} 
    557564 
  • src/libvlc-common.c

    r8594365 rdbdd540  
    4343#include "modules/modules.h" 
    4444#include "config/configuration.h" 
     45#include "interface/interface.h" 
    4546 
    4647#include <errno.h>                                                 /* ENOMEM */ 
     
    193194    } 
    194195    p_libvlc->p_playlist = NULL; 
     196    p_libvlc->p_interaction = NULL; 
    195197    p_libvlc->psz_object_name = "libvlc"; 
    196198 
     
    733735    memcpy( p_libvlc->p_hotkeys, libvlc_hotkeys, libvlc_hotkeys_size ); 
    734736 
     737    /* Initialize interaction */ 
     738    p_libvlc->p_interaction = interaction_Init( p_libvlc ); 
     739 
    735740    /* Initialize playlist and get commandline files */ 
    736741    playlist_ThreadCreate( p_libvlc ); 
     
    945950        aout_Delete( p_aout ); 
    946951    } 
     952 
     953    /* Free interaction */ 
     954    msg_Dbg( p_libvlc, "removing interaction" ); 
     955    vlc_object_release( p_libvlc->p_interaction ); 
    947956 
    948957    stats_TimersDumpAll( p_libvlc );