]> git.sesse.net Git - vlc/blob - plugins/ggi/intf_ggi.c
. should compile & run on Solaris with ./configure --disable-dsp
[vlc] / plugins / ggi / intf_ggi.c
1 /*****************************************************************************
2  * intf_ggi.c: GGI interface plugin
3  * Since GII doesnt seem to work well for keyboard events, the GGI display is
4  * used, and therefore the GII interface can't be spawned without a video output
5  * thread. It also needs a kludge to get the visual from the video output GGI
6  * driver.
7  *****************************************************************************
8  * Copyright (C) 1999, 2000 VideoLAN
9  * $Id: intf_ggi.c,v 1.7 2001/01/05 18:46:43 massiot Exp $
10  *
11  * Authors:
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  * 
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
26  *****************************************************************************/
27
28 /*****************************************************************************
29  * Preamble
30  *****************************************************************************/
31 #include "defs.h"
32
33 #include <errno.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <ggi/ggi.h>
37
38 #include "config.h"
39 #include "common.h"
40 #include "threads.h"
41 #include "mtime.h"
42 #include "plugins.h"
43
44 #include "stream_control.h"
45 #include "input_ext-intf.h"
46
47 #include "video.h"
48 #include "video_output.h"
49
50 #include "interface.h"
51 #include "intf_msg.h"
52
53 #include "main.h"
54
55 /*****************************************************************************
56  * intf_sys_t: description and status of GGI interface
57  *****************************************************************************/
58 typedef struct intf_sys_s
59 {
60     /* GGI system information */
61     ggi_visual_t                 p_display;                       /* display */
62
63 } intf_sys_t;
64
65 /*****************************************************************************
66  * External prototypes
67  *****************************************************************************/
68
69 /* vout_SysGetVisual: get back visual from video output thread - in video_ggi.c
70  * This function is used to get back the display pointer once the video output
71  * thread has been spawned. */
72 ggi_visual_t    vout_SysGetVisual( vout_thread_t *p_vout );
73
74 /*****************************************************************************
75  * intf_GGICreate: initialize and create GII interface
76  *****************************************************************************/
77 int intf_GGICreate( intf_thread_t *p_intf )
78 {
79     /* Check that b_video is set */
80     if( !p_main->b_video )
81     {
82         intf_ErrMsg("error: GGI interface require a video output thread");
83         return( 1 );
84     }
85
86     /* Allocate instance and initialize some members */
87     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
88     if( p_intf->p_sys == NULL )
89     {
90         intf_ErrMsg("error: %s", strerror(ENOMEM) );
91         return( 1 );
92     }
93
94     /* Spawn video output thread */
95     p_intf->p_vout = vout_CreateThread( main_GetPszVariable( VOUT_DISPLAY_VAR,
96                                                              NULL), 0,
97                                         main_GetIntVariable( VOUT_WIDTH_VAR,
98                                                          VOUT_WIDTH_DEFAULT ),
99                                         main_GetIntVariable( VOUT_HEIGHT_VAR,
100                                                         VOUT_HEIGHT_DEFAULT ),
101                                         NULL, 0,
102                                         (void *)&p_intf->p_sys->p_display );
103
104     if( p_intf->p_vout == NULL )                                  /* error */
105     {
106         intf_ErrMsg("error: can't create video output thread" );
107         free( p_intf->p_sys );
108         return( 1 );
109     }
110     
111     /* Assign basic keys */
112     intf_AssignNormalKeys( p_intf );
113
114     
115     return( 0 );
116 }
117
118 /*****************************************************************************
119  * intf_GGIDestroy: destroy interface
120  *****************************************************************************/
121 void intf_GGIDestroy( intf_thread_t *p_intf )
122 {
123     /* Close input thread, if any (blocking) */
124     if( p_intf->p_input )
125     {
126         input_DestroyThread( p_intf->p_input, NULL );
127     }
128
129     /* Close video output thread, if any (blocking) */
130     if( p_intf->p_vout )
131     {
132         vout_DestroyThread( p_intf->p_vout, NULL );
133     }
134
135     /* Destroy structure */
136     free( p_intf->p_sys );
137 }
138
139
140 /*****************************************************************************
141  * intf_GGIManage: event loop
142  *****************************************************************************/
143 void intf_GGIManage( intf_thread_t *p_intf )
144 {
145     int         i_key;                                        /* unicode key */
146
147     /* For all events in queue */
148     while( ggiKbhit( p_intf->p_sys->p_display ) )
149     {
150         i_key = ggiGetc( p_intf->p_sys->p_display );
151         if( intf_ProcessKey( p_intf, i_key ) )
152         {
153             intf_DbgMsg("unhandled key '%c' (%i)", (char) i_key, i_key );
154         }
155     }
156 }
157
158
159