Commit 6113551a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Remove interaction core

One useless thread gone (the new subsystem does not need a thread).
parent 9deb4cb1
...@@ -180,8 +180,6 @@ typedef struct config_category_t config_category_t; ...@@ -180,8 +180,6 @@ typedef struct config_category_t config_category_t;
typedef struct intf_thread_t intf_thread_t; typedef struct intf_thread_t intf_thread_t;
typedef struct intf_sys_t intf_sys_t; typedef struct intf_sys_t intf_sys_t;
typedef struct intf_msg_t intf_msg_t; typedef struct intf_msg_t intf_msg_t;
typedef struct interaction_t interaction_t;
typedef struct interaction_dialog_t interaction_dialog_t;
typedef struct user_widget_t user_widget_t; typedef struct user_widget_t user_widget_t;
/* Input */ /* Input */
......
...@@ -92,7 +92,7 @@ struct intf_dialog_args_t ...@@ -92,7 +92,7 @@ struct intf_dialog_args_t
bool b_multiple; bool b_multiple;
/* Specific to INTF_DIALOG_INTERACTION */ /* Specific to INTF_DIALOG_INTERACTION */
interaction_dialog_t *p_dialog; struct interaction_dialog_t *p_dialog;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -108,9 +108,6 @@ VLC_EXPORT( int, __intf_Eject, ( vlc_object_t *, const char * ) ); ...@@ -108,9 +108,6 @@ VLC_EXPORT( int, __intf_Eject, ( vlc_object_t *, const char * ) );
VLC_EXPORT( void, libvlc_Quit, ( libvlc_int_t * ) ); VLC_EXPORT( void, libvlc_Quit, ( libvlc_int_t * ) );
VLC_EXPORT( int, interaction_Register, ( intf_thread_t * ) );
VLC_EXPORT( int, interaction_Unregister, ( intf_thread_t * ) );
/*@}*/ /*@}*/
/***************************************************************************** /*****************************************************************************
...@@ -198,7 +195,7 @@ typedef enum vlc_dialog { ...@@ -198,7 +195,7 @@ typedef enum vlc_dialog {
/** /**
* This structure describes a piece of interaction with the user * This structure describes a piece of interaction with the user
*/ */
struct interaction_dialog_t typedef struct interaction_dialog_t
{ {
int i_type; ///< Type identifier int i_type; ///< Type identifier
char *psz_title; ///< Title char *psz_title; ///< Title
...@@ -225,7 +222,7 @@ struct interaction_dialog_t ...@@ -225,7 +222,7 @@ struct interaction_dialog_t
//for interaction //for interaction
intf_thread_t *p_interface; intf_thread_t *p_interface;
vlc_mutex_t *p_lock; vlc_mutex_t *p_lock;
}; } interaction_dialog_t;
/** /**
* Possible flags . Dialog types * Possible flags . Dialog types
...@@ -242,7 +239,6 @@ struct interaction_dialog_t ...@@ -242,7 +239,6 @@ struct interaction_dialog_t
/** Possible return codes */ /** Possible return codes */
enum enum
{ {
DIALOG_DEFAULT,
DIALOG_OK_YES, DIALOG_OK_YES,
DIALOG_NO, DIALOG_NO,
DIALOG_CANCELLED DIALOG_CANCELLED
...@@ -251,21 +247,10 @@ enum ...@@ -251,21 +247,10 @@ enum
/** Possible status */ /** Possible status */
enum enum
{ {
SENT_DIALOG=1, ///< Sent to interface
UPDATED_DIALOG, ///< Update to send
ANSWERED_DIALOG, ///< Got "answer" ANSWERED_DIALOG, ///< Got "answer"
HIDING_DIALOG, ///< Hiding requested
HIDDEN_DIALOG, ///< Now hidden. Requesting destruction
DESTROYED_DIALOG, ///< Interface has destroyed it DESTROYED_DIALOG, ///< Interface has destroyed it
}; };
/** Possible interaction types */
enum
{
INTERACT_DIALOG_ONEWAY, ///< Dialog box without feedback
INTERACT_DIALOG_TWOWAY, ///< Dialog box with feedback
};
/** Possible actions */ /** Possible actions */
enum enum
{ {
...@@ -275,11 +260,10 @@ enum ...@@ -275,11 +260,10 @@ enum
INTERACT_DESTROY INTERACT_DESTROY
}; };
/***************************************************************************
* Exported symbols
***************************************************************************/
#define intf_UserStringInput( a, b, c, d ) (VLC_OBJECT(a),b,c,d, VLC_EGENERIC) #define intf_UserStringInput( a, b, c, d ) (VLC_OBJECT(a),b,c,d, VLC_EGENERIC)
#define interaction_Register( t ) (t, VLC_EGNERIC)
#define interaction_Unregister( t ) (t, VLC_EGENERIC)
/** @} */ /** @} */
/** @} */ /** @} */
......
...@@ -266,10 +266,8 @@ SOURCES_libvlc_common = \ ...@@ -266,10 +266,8 @@ SOURCES_libvlc_common = \
missing.c \ missing.c \
version.c \ version.c \
interface/dialog.c \ interface/dialog.c \
interface/interface.h \
interface/interface.c \ interface/interface.c \
interface/intf_eject.c \ interface/intf_eject.c \
interface/interaction.c \
playlist/playlist_internal.h \ playlist/playlist_internal.h \
playlist/art.c \ playlist/art.c \
playlist/art.h \ playlist/art.h \
......
/*****************************************************************************
* interaction.c: User interaction functions
*****************************************************************************
* Copyright © 2005-2008 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* Felix Kühne <fkuehne@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/**
* \file
* This file contains functions related to user interaction management
*/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_interface.h>
#include "interface.h"
#include "libvlc.h"
#include <assert.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
/**
* This structure contains the active interaction dialogs, and is
* used by the manager
*/
struct interaction_t
{
VLC_COMMON_MEMBERS
vlc_thread_t thread;
vlc_mutex_t lock;
vlc_cond_t wait;
int i_dialogs; ///< Number of dialogs
interaction_dialog_t **pp_dialogs; ///< Dialogs
intf_thread_t *p_intf; ///< Interface to use
};
static void* InteractionLoop( void * );
static void InteractionManage( interaction_t * );
static void DialogDestroy( interaction_dialog_t * );
#define DIALOG_INIT( type, err ) \
interaction_dialog_t* p_new = calloc( 1, sizeof( interaction_dialog_t ) ); \
if( !p_new ) return err; \
p_new->p_parent = vlc_object_hold( p_this ); \
p_new->b_cancelled = false; \
p_new->i_status = SENT_DIALOG; \
p_new->i_flags = 0; \
p_new->i_type = INTERACT_DIALOG_##type; \
p_new->psz_returned[0] = NULL; \
p_new->psz_returned[1] = NULL
/**
* Create the initial interaction object
* (should only be used in libvlc_InternalInit, LibVLC private)
*
* \return a vlc_object_t that should be freed when done.
*/
interaction_t * interaction_Init( libvlc_int_t *p_libvlc )
{
interaction_t *p_interaction;
/* Make sure we haven't yet created an interaction object */
assert( libvlc_priv(p_libvlc)->p_interaction == NULL );
p_interaction = vlc_custom_create( VLC_OBJECT(p_libvlc),
sizeof( *p_interaction ),
VLC_OBJECT_GENERIC, "interaction" );
if( !p_interaction )
return NULL;
vlc_object_attach( p_interaction, p_libvlc );
p_interaction->i_dialogs = 0;
p_interaction->pp_dialogs = NULL;
p_interaction->p_intf = NULL;
vlc_mutex_init( &p_interaction->lock );
vlc_cond_init( &p_interaction->wait );
if( vlc_clone( &p_interaction->thread, InteractionLoop, p_interaction,
VLC_THREAD_PRIORITY_LOW ) )
{
msg_Err( p_interaction, "Interaction control thread creation failed, "
"interaction will not be displayed" );
vlc_object_detach( p_interaction );
vlc_object_release( p_interaction );
return NULL;
}
return p_interaction;
}
void interaction_Destroy( interaction_t *p_interaction )
{
if( !p_interaction )
return;
vlc_cancel( p_interaction->thread );
vlc_join( p_interaction->thread, NULL );
vlc_cond_destroy( &p_interaction->wait );
vlc_mutex_destroy( &p_interaction->lock );
/* Remove all dialogs - Interfaces must be able to clean up their data */
for( int i = p_interaction->i_dialogs -1 ; i >= 0; i-- )
{
interaction_dialog_t * p_dialog = p_interaction->pp_dialogs[i];
DialogDestroy( p_dialog );
REMOVE_ELEM( p_interaction->pp_dialogs, p_interaction->i_dialogs, i );
}
vlc_object_release( p_interaction );
}
static vlc_mutex_t intf_lock = VLC_STATIC_MUTEX;
int interaction_Register( intf_thread_t *intf )
{
libvlc_priv_t *priv = libvlc_priv( intf->p_libvlc );
int ret = VLC_EGENERIC;
vlc_mutex_lock( &intf_lock );
if( priv->p_interaction_intf == NULL )
{ /* Since the interface is responsible for unregistering itself before
* it terminates, an object reference is not needed. */
priv->p_interaction_intf = intf;
ret = VLC_SUCCESS;
}
vlc_mutex_unlock( &intf_lock );
return ret;
}
int interaction_Unregister( intf_thread_t *intf )
{
libvlc_priv_t *priv = libvlc_priv( intf->p_libvlc );
int ret = VLC_EGENERIC;
vlc_mutex_lock( &intf_lock );
if( priv->p_interaction_intf == intf )
{
priv->p_interaction_intf = NULL;
ret = VLC_SUCCESS;
}
vlc_mutex_unlock( &intf_lock );
return ret;
}
/**********************************************************************
* The following functions are local
**********************************************************************/
/* Destroy a dialog */
static void DialogDestroy( interaction_dialog_t *p_dialog )
{
free( p_dialog->psz_title );
free( p_dialog->psz_description );
free( p_dialog->psz_alternate_button );
vlc_object_release( p_dialog->p_parent );
free( p_dialog );
}
static void* InteractionLoop( void *p_this )
{
interaction_t *p_interaction = p_this;
vlc_mutex_lock( &p_interaction->lock );
mutex_cleanup_push( &p_interaction->lock );
for( ;; )
{
int canc = vlc_savecancel();
InteractionManage( p_interaction );
vlc_restorecancel( canc );
vlc_cond_wait( &p_interaction->wait, &p_interaction->lock );
}
vlc_cleanup_pop( );
assert( 0 );
}
/**
* The main interaction processing loop
*
* \param p_interaction the interaction object
* \return nothing
*/
static void InteractionManage( interaction_t *p_interaction )
{
vlc_value_t val;
int i_index;
for( i_index = 0 ; i_index < p_interaction->i_dialogs; i_index ++ )
{
interaction_dialog_t *p_dialog = p_interaction->pp_dialogs[i_index];
switch( p_dialog->i_status )
{
case ANSWERED_DIALOG:
/* Ask interface to hide it */
p_dialog->i_action = INTERACT_HIDE;
val.p_address = p_dialog;
var_Set( p_dialog->p_interface, "interaction", val );
p_dialog->i_status = HIDING_DIALOG;
break;
case UPDATED_DIALOG:
p_dialog->i_action = INTERACT_UPDATE;
val.p_address = p_dialog;
var_Set( p_dialog->p_interface, "interaction", val );
p_dialog->i_status = SENT_DIALOG;
break;
case HIDDEN_DIALOG:
if( !(p_dialog->i_flags & DIALOG_GOT_ANSWER) ) break;
p_dialog->i_action = INTERACT_DESTROY;
val.p_address = p_dialog;
var_Set( p_dialog->p_interface, "interaction", val );
break;
case DESTROYED_DIALOG:
/* Interface has now destroyed it, remove it */
REMOVE_ELEM( p_interaction->pp_dialogs, p_interaction->i_dialogs,
i_index);
i_index--;
DialogDestroy( p_dialog );
break;
}
}
}
/*****************************************************************************
* interface.h: Internal interface prototypes and structures
*****************************************************************************
* Copyright (C) 1998-2006 the VideoLAN team
* $Id$
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Clément Stenac <zorglub@videolan.org>
* Felix Kühne <fkuehne@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
# error This header file can only be included from LibVLC.
#endif
#ifndef __LIBVLC_INTERFACE_H
# define __LIBVLC_INTERFACE_H 1
/**********************************************************************
* Interaction
**********************************************************************/
interaction_t * interaction_Init( libvlc_int_t *p_libvlc );
void interaction_Destroy( interaction_t * );
#endif
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "modules/modules.h" #include "modules/modules.h"
#include "config/configuration.h" #include "config/configuration.h"
#include "interface/interface.h"
#include <errno.h> /* ENOMEM */ #include <errno.h> /* ENOMEM */
#include <stdio.h> /* sprintf() */ #include <stdio.h> /* sprintf() */
...@@ -258,7 +257,6 @@ libvlc_int_t * libvlc_InternalCreate( void ) ...@@ -258,7 +257,6 @@ libvlc_int_t * libvlc_InternalCreate( void )
priv = libvlc_priv (p_libvlc); priv = libvlc_priv (p_libvlc);
priv->p_playlist = NULL; priv->p_playlist = NULL;
priv->p_interaction = NULL;
priv->p_dialog_provider = NULL; priv->p_dialog_provider = NULL;
priv->p_vlm = NULL; priv->p_vlm = NULL;
p_libvlc->psz_object_name = strdup( "libvlc" ); p_libvlc->psz_object_name = strdup( "libvlc" );
...@@ -805,9 +803,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -805,9 +803,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
var_AddCallback( p_libvlc, "key-pressed", vlc_key_to_action, var_AddCallback( p_libvlc, "key-pressed", vlc_key_to_action,
p_libvlc->p_hotkeys ); p_libvlc->p_hotkeys );
/* Initialize interaction */
priv->p_interaction = interaction_Init( p_libvlc );
/* Initialize playlist and get commandline files */ /* Initialize playlist and get commandline files */
p_playlist = playlist_Create( VLC_OBJECT(p_libvlc) ); p_playlist = playlist_Create( VLC_OBJECT(p_libvlc) );
if( !p_playlist ) if( !p_playlist )
...@@ -1063,10 +1058,6 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc ) ...@@ -1063,10 +1058,6 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
/* Free interaction */
msg_Dbg( p_libvlc, "removing interaction" );
interaction_Destroy( priv->p_interaction );
stats_TimersDumpAll( p_libvlc ); stats_TimersDumpAll( p_libvlc );
stats_TimersCleanAll( p_libvlc ); stats_TimersCleanAll( p_libvlc );
......
...@@ -220,8 +220,6 @@ typedef struct libvlc_priv_t ...@@ -220,8 +220,6 @@ typedef struct libvlc_priv_t
module_t *p_memcpy_module; ///< Fast memcpy plugin used module_t *p_memcpy_module; ///< Fast memcpy plugin used
playlist_t *p_playlist; //< the playlist singleton playlist_t *p_playlist; //< the playlist singleton
vlm_t *p_vlm; ///< the VLM singleton (or NULL) vlm_t *p_vlm; ///< the VLM singleton (or NULL)
interaction_t *p_interaction; ///< old interaction object
intf_thread_t *p_interaction_intf; ///< old interface for interaction
vlc_object_t *p_dialog_provider; ///< dialog provider vlc_object_t *p_dialog_provider; ///< dialog provider
httpd_t *p_httpd; ///< HTTP daemon (src/network/httpd.c) httpd_t *p_httpd; ///< HTTP daemon (src/network/httpd.c)
#ifdef ENABLE_SOUT #ifdef ENABLE_SOUT
......
...@@ -195,8 +195,6 @@ __input_Read ...@@ -195,8 +195,6 @@ __input_Read
input_SplitMRL input_SplitMRL
input_StopThread input_StopThread
input_vaControl input_vaControl
interaction_Register
interaction_Unregister
__intf_Create __intf_Create
__intf_Eject __intf_Eject
intf_RunThread intf_RunThread
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment