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 )
53 int i_thread; /* thread index */
54 video_cfg_t cfg; /* thread configuration */
56 /* Verify that video is enabled */
57 if( !p_program_data->cfg.b_video )
62 /* Set configuration */
63 memcpy( &cfg, &p_program_data->vout_cfg, sizeof( cfg ) );
64 if( psz_title != NULL )
66 cfg.i_properties |= VIDEO_CFG_TITLE;
67 cfg.psz_title = psz_title;
71 cfg.i_properties |= VIDEO_CFG_WIDTH;
72 cfg.i_width = i_width;
76 cfg.i_properties |= VIDEO_CFG_HEIGHT;
77 cfg.i_height = i_height;
80 /* Find an empty place */
81 for( i_thread = 0; i_thread < VOUT_MAX_THREADS; i_thread++ )
83 if( p_intf->pp_vout[i_thread] == NULL )
85 /* The current place is empty: create a thread */
86 p_intf->pp_vout[i_thread] = vout_CreateThread( &cfg, NULL );
87 if( p_intf->pp_vout[i_thread] == NULL ) /* error */
94 /* No empty place has been found */
100 /*******************************************************************************
101 * intf_DestroyVoutThread: destroy video output thread in interface
102 *******************************************************************************
103 * This function destroy a video output thread created with
104 * intf_CreateVoutThread().
105 *******************************************************************************/
106 void intf_DestroyVoutThread( intf_thread_t *p_intf, int i_thread )
110 /* Check if thread still exists */
111 if( p_intf->pp_vout[i_thread] == NULL )
113 intf_DbgMsg("intf error: destruction of an inexistant vout thread\n");
118 /* Destroy thread and marks its place as empty */
119 vout_DestroyThread( p_intf->pp_vout[i_thread], NULL );
120 p_intf->pp_vout[i_thread] = NULL;
125 /*******************************************************************************
126 * intf_CreateInputThread: create input thread in interface
127 *******************************************************************************
128 * This function creates - if possible - a new input thread in the
129 * interface registery, using interface default settings. It returns the
130 * thread number for the interface, or a negative number.
131 *******************************************************************************/
132 int intf_CreateInputThread( intf_thread_t *p_intf, input_cfg_t* p_cfg )
134 int i_thread; /* thread index */
136 /* Find an empty place */
137 for( i_thread = 0; i_thread < INPUT_MAX_THREADS; i_thread++ )
139 if( p_intf->pp_input[i_thread] == NULL )
141 /* The current place is empty: create a thread and return */
142 p_intf->pp_input[i_thread] = input_CreateThread( p_cfg );
143 return( (p_intf->pp_input[i_thread] != NULL) ? i_thread : -1 );
147 /* No empty place has been found */
151 /*******************************************************************************
152 * intf_DestroyInputThread: destroy input thread in interface
153 *******************************************************************************
154 * This function destroy aa input thread created with
155 * intf_CreateInputThread().
156 *******************************************************************************/
157 void intf_DestroyInputThread( intf_thread_t *p_intf, int i_thread )
160 /* Check if thread still exists */
161 if( p_intf->pp_input[i_thread] == NULL )
163 intf_DbgMsg("intf error: destruction of an inexistant input thread\n");
168 /* Destroy thread and marks its place as empty */
169 input_DestroyThread( p_intf->pp_input[i_thread] );
170 p_intf->pp_input[i_thread] = NULL;