]> git.sesse.net Git - vlc/blob - src/interface/control.c
* Makefile : ajout du nouveau d�codeur (comment�) ;
[vlc] / src / interface / control.c
1 /*******************************************************************************
2  * control.c: user control functions
3  * (c)1999 VideoLAN
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  *******************************************************************************/
9
10 /*******************************************************************************
11  * Preamble
12  *******************************************************************************/
13 #include <stdio.h>
14 #include <netinet/in.h>
15 #include <sys/soundcard.h>
16 #include <sys/uio.h>
17 #include <X11/Xlib.h> 
18 #include <X11/extensions/XShm.h>
19
20 #include "config.h"
21 #include "common.h"
22 #include "mtime.h"
23 #include "vlc_thread.h"
24
25 #include "input.h"
26 #include "input_vlan.h"
27
28 #include "audio_output.h"
29
30 #include "video.h"
31 #include "video_output.h"
32
33 #include "xconsole.h"
34 #include "interface.h"
35 #include "intf_msg.h"
36 #include "control.h"
37
38 #include "pgm_data.h"
39
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
48  * they are positive.
49  *******************************************************************************/
50 int intf_CreateVoutThread( intf_thread_t *p_intf, char *psz_title, int i_width, int i_height )
51 {
52 #if 0
53     int             i_thread;                                  /* thread index */
54     video_cfg_t     cfg;                               /* thread configuration */    
55
56     /* Verify that video is enabled */
57     if( !p_program_data->cfg.b_video )
58     {
59         return( -1 );
60     }
61
62     /* Set configuration */
63     memcpy( &cfg, &p_program_data->vout_cfg, sizeof( cfg ) );
64     if( psz_title != NULL )
65     {
66         cfg.i_properties |= VIDEO_CFG_TITLE;
67         cfg.psz_title = psz_title;        
68     }
69     if( i_width > 0 )
70     {
71         cfg.i_properties |= VIDEO_CFG_WIDTH;
72         cfg.i_width = i_width;        
73     }
74     if( i_height > 0 )
75     {
76         cfg.i_properties |= VIDEO_CFG_HEIGHT;
77         cfg.i_height = i_height;
78     }
79
80     /* Find an empty place */
81     for( i_thread = 0; i_thread < VOUT_MAX_THREADS; i_thread++ )
82     {
83         if( p_intf->pp_vout[i_thread] == NULL )
84         {
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 */
88             {                    
89                 return( -1 );
90             }
91         }
92     }
93
94     /* No empty place has been found */
95     return( -1 );
96 #endif
97 }
98
99
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 )
107 {
108 #if 0
109 #ifdef DEBUG
110     /* Check if thread still exists */
111     if( p_intf->pp_vout[i_thread] == NULL )
112     {
113         intf_DbgMsg("intf error: destruction of an inexistant vout thread\n");
114         return;
115     }
116 #endif
117
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;
121 #endif
122 }
123
124
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 )
133 {
134     int             i_thread;                                  /* thread index */
135
136     /* Find an empty place */
137     for( i_thread = 0; i_thread < INPUT_MAX_THREADS; i_thread++ )
138     {
139         if( p_intf->pp_input[i_thread] == NULL )
140         {
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 );
144         }
145     }
146
147     /* No empty place has been found */
148     return( -1 );    
149 }
150
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 )
158 {
159 #ifdef DEBUG
160     /* Check if thread still exists */
161     if( p_intf->pp_input[i_thread] == NULL )
162     {
163         intf_DbgMsg("intf error: destruction of an inexistant input thread\n");
164         return;        
165     }
166 #endif
167
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;
171 }