1 /*******************************************************************************
2 * control.c: user control functions
4 *******************************************************************************
5 * Library of functions common to all threads, allowing access to various
6 * structures and settings. Interfaces should only use those functions
7 * to read or write informations from other threads.
8 *******************************************************************************/
10 /*******************************************************************************
12 *******************************************************************************/
14 #include <netinet/in.h>
15 #include <sys/soundcard.h>
18 #include <X11/extensions/XShm.h>
23 #include "vlc_thread.h"
26 #include "input_vlan.h"
28 #include "audio_output.h"
31 #include "video_output.h"
34 #include "interface.h"
40 /*******************************************************************************
41 * intf_CreateVoutThread: create video output thread in interface
42 *******************************************************************************
43 * This function creates - if possible - a new video output thread in the
44 * interface registery, using interface default settings. It returns the
45 * thread number for the interface, or a negative number.
46 * If video is desactivated, nothing will be done. If psz_title is not NULL, it
47 * will be used as window's title, and width and height will also be used if
49 *******************************************************************************/
50 int intf_CreateVoutThread( intf_thread_t *p_intf, char *psz_title, int i_width, int i_height )
52 int i_thread; /* thread index */
53 video_cfg_t cfg; /* thread configuration */
55 /* Verify that video is enabled */
56 if( !p_program_data->cfg.b_video )
61 /* Set configuration */
62 memcpy( &cfg, &p_program_data->vout_cfg, sizeof( cfg ) );
63 if( psz_title != NULL )
65 cfg.i_properties |= VIDEO_CFG_TITLE;
66 cfg.psz_title = psz_title;
70 cfg.i_properties |= VIDEO_CFG_WIDTH;
71 cfg.i_width = i_width;
75 cfg.i_properties |= VIDEO_CFG_HEIGHT;
76 cfg.i_height = i_height;
79 /* Find an empty place */
80 for( i_thread = 0; i_thread < VOUT_MAX_THREADS; i_thread++ )
82 if( p_intf->pp_vout[i_thread] == NULL )
84 /* The current place is empty: create a thread */
85 p_intf->pp_vout[i_thread] = vout_CreateThread( &cfg, NULL );
86 if( p_intf->pp_vout[i_thread] == NULL ) /* error */
93 /* No empty place has been found */
98 /*******************************************************************************
99 * intf_DestroyVoutThread: destroy video output thread in interface
100 *******************************************************************************
101 * This function destroy a video output thread created with
102 * intf_CreateVoutThread().
103 *******************************************************************************/
104 void intf_DestroyVoutThread( intf_thread_t *p_intf, int i_thread )
107 /* Check if thread still exists */
108 if( p_intf->pp_vout[i_thread] == NULL )
110 intf_DbgMsg("intf error: destruction of an inexistant vout thread\n");
115 /* Destroy thread and marks its place as empty */
116 vout_DestroyThread( p_intf->pp_vout[i_thread], NULL );
117 p_intf->pp_vout[i_thread] = NULL;
121 /*******************************************************************************
122 * intf_CreateInputThread: create input thread in interface
123 *******************************************************************************
124 * This function creates - if possible - a new input thread in the
125 * interface registery, using interface default settings. It returns the
126 * thread number for the interface, or a negative number.
127 *******************************************************************************/
128 int intf_CreateInputThread( intf_thread_t *p_intf, input_cfg_t* p_cfg )
130 int i_thread; /* thread index */
132 /* Find an empty place */
133 for( i_thread = 0; i_thread < INPUT_MAX_THREADS; i_thread++ )
135 if( p_intf->pp_input[i_thread] == NULL )
137 /* The current place is empty: create a thread and return */
138 p_intf->pp_input[i_thread] = input_CreateThread( p_cfg );
139 return( (p_intf->pp_input[i_thread] != NULL) ? i_thread : -1 );
143 /* No empty place has been found */
147 /*******************************************************************************
148 * intf_DestroyInputThread: destroy input thread in interface
149 *******************************************************************************
150 * This function destroy aa input thread created with
151 * intf_CreateInputThread().
152 *******************************************************************************/
153 void intf_DestroyInputThread( intf_thread_t *p_intf, int i_thread )
156 /* Check if thread still exists */
157 if( p_intf->pp_input[i_thread] == NULL )
159 intf_DbgMsg("intf error: destruction of an inexistant input thread\n");
164 /* Destroy thread and marks its place as empty */
165 input_DestroyThread( p_intf->pp_input[i_thread] );
166 p_intf->pp_input[i_thread] = NULL;