annotate libvo/video_out.c @ 13:36314c7bda8d

initial version
author arpi_esp
date Tue, 27 Feb 2001 01:08:44 +0000
parents 7400af1c6d44
children 1fc618eba830
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * video_out.c,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 * Copyright (C) Aaron Holtzman - June 2000
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 * mpeg2dec is free software; you can redistribute it and/or modify
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 * the Free Software Foundation; either version 2, or (at your option)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * any later version.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 * mpeg2dec is distributed in the hope that it will be useful,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 * GNU General Public License for more details.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 * along with GNU Make; see the file COPYING. If not, write to
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 #include <unistd.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include <sys/mman.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 #include "../linux/shmem.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 //
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 // Externally visible list of all vo drivers
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 //
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 extern vo_functions_t video_out_mga;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 extern vo_functions_t video_out_xmga;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 extern vo_functions_t video_out_x11;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 extern vo_functions_t video_out_xv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 extern vo_functions_t video_out_gl;
12
7400af1c6d44 DGA support
arpi_esp
parents: 1
diff changeset
43 extern vo_functions_t video_out_dga;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 extern vo_functions_t video_out_sdl;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 extern vo_functions_t video_out_3dfx;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 extern vo_functions_t video_out_null;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 extern vo_functions_t video_out_odivx;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 extern vo_functions_t video_out_pgm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 extern vo_functions_t video_out_md5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 extern vo_functions_t video_out_syncfb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 vo_functions_t* video_out_drivers[] =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 #ifdef HAVE_MGA
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 #ifdef HAVE_X11
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 &video_out_xmga,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 &video_out_mga,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 #ifdef HAVE_SYNCFB
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 &video_out_syncfb,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 #ifdef HAVE_3DFX
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 &video_out_3dfx,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 #ifdef HAVE_XV
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 &video_out_xv,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 #ifdef HAVE_X11
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 &video_out_x11,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 #ifdef HAVE_GL
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 &video_out_gl,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 #endif
12
7400af1c6d44 DGA support
arpi_esp
parents: 1
diff changeset
75 #ifdef HAVE_DGA
7400af1c6d44 DGA support
arpi_esp
parents: 1
diff changeset
76 &video_out_dga,
7400af1c6d44 DGA support
arpi_esp
parents: 1
diff changeset
77 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 #ifdef HAVE_SDL
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 &video_out_sdl,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 &video_out_null,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 &video_out_odivx,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 &video_out_pgm,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 &video_out_md5,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 NULL
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 #ifdef X11_FULLSCREEN
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 #include <X11/Xlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 #include <X11/Xutil.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 #include <X11/Xatom.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 int vo_depthonscreen=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 int vo_screenwidth=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 int vo_screenheight=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 int vo_init( void )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 int CompletionType = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 int mScreen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 int bpp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 char * DisplayName = ":0.0";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 Display * mDisplay;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 XImage * mXImage;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 Window mRootWin;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 static XWindowAttributes attribs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 if(vo_depthonscreen) return 1; // already called
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 mDisplay=XOpenDisplay( DisplayName );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 if ( !mDisplay )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 fprintf( stderr,"vo: couldn't open the X11 display!\n" );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 mScreen=DefaultScreen( mDisplay ); // Screen ID.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 mRootWin=RootWindow( mDisplay,mScreen );// Root window ID.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 vo_screenwidth=DisplayWidth( mDisplay,mScreen );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 vo_screenheight=DisplayHeight( mDisplay,mScreen );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 // get color depth:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 // XGetWindowAttributes(mydisplay, DefaultRootWindow(mDisplay), &attribs);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 XGetWindowAttributes(mDisplay, mRootWin, &attribs);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 vo_depthonscreen=attribs.depth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 // get bits/pixel:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 bpp=mXImage->bits_per_pixel;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 XDestroyImage( mXImage );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 XCloseDisplay( mDisplay );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 #include "../linux/keycodes.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 extern void mplayer_put_key(int code);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 void vo_keyboard( int key )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 switch ( key )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 case wsLeft: mplayer_put_key(KEY_LEFT); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 case wsRight: mplayer_put_key(KEY_RIGHT); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 case wsUp: mplayer_put_key(KEY_UP); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 case wsDown: mplayer_put_key(KEY_DOWN); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 case wsSpace: mplayer_put_key(' '); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 case wsEscape: mplayer_put_key(KEY_ESC); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 case wsEnter: mplayer_put_key(KEY_ENTER); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 case wsq:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 case wsQ: mplayer_put_key('q'); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 case wsp:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 case wsP: mplayer_put_key('p'); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 case wsMinus:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 case wsGrayMinus: mplayer_put_key('-'); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 case wsPlus:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 case wsGrayPlus: mplayer_put_key('+'); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 // ----- Motif header: -------
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 #define MWM_HINTS_DECORATIONS 2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 typedef struct
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 long flags;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 long functions;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 long decorations;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 long input_mode;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 } MotifWmHints;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 extern MotifWmHints vo_MotifWmHints;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 extern Atom vo_MotifHints;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 extern int vo_depthonscreen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 extern int vo_screenwidth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 extern int vo_screenheight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 static MotifWmHints vo_MotifWmHints;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 static Atom vo_MotifHints = None;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 void vo_decoration( Display * vo_Display,Window w,int d )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 vo_MotifHints=XInternAtom( vo_Display,"_MOTIF_WM_HINTS",0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 if ( vo_MotifHints != None )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 vo_MotifWmHints.flags=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 vo_MotifWmHints.decorations=d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 XChangeProperty( vo_Display,w,vo_MotifHints,vo_MotifHints,32,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 PropModeReplace,(unsigned char *)&vo_MotifWmHints,4 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 #include <signal.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 int vo_eventhandler_pid=-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 void vo_kill_eventhandler(){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 if(vo_eventhandler_pid!=-1) kill(vo_eventhandler_pid,SIGTERM);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205