annotate libvo/video_out.c @ 5:6c8fb6b35c26

added Andreas Ackermann
author arpi_esp
date Sun, 25 Feb 2001 22:22:41 +0000
parents 3b5f5d1c5041
children 7400af1c6d44
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;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 extern vo_functions_t video_out_sdl;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 extern vo_functions_t video_out_3dfx;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 extern vo_functions_t video_out_null;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 extern vo_functions_t video_out_odivx;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 extern vo_functions_t video_out_pgm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 extern vo_functions_t video_out_md5;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 extern vo_functions_t video_out_syncfb;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 vo_functions_t* video_out_drivers[] =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 #ifdef HAVE_MGA
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 #ifdef HAVE_X11
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 &video_out_xmga,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 &video_out_mga,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 #ifdef HAVE_SYNCFB
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 &video_out_syncfb,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 #ifdef HAVE_3DFX
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 &video_out_3dfx,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 #ifdef HAVE_XV
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 &video_out_xv,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 #ifdef HAVE_X11
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 &video_out_x11,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 #ifdef HAVE_GL
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 &video_out_gl,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 #ifdef HAVE_SDL
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 &video_out_sdl,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 &video_out_null,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 &video_out_odivx,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 &video_out_pgm,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 &video_out_md5,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 NULL
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 #ifdef X11_FULLSCREEN
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 #include <X11/Xlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 #include <X11/Xutil.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 #include <X11/Xatom.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 int vo_depthonscreen=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 int vo_screenwidth=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 int vo_screenheight=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 int vo_init( void )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 int CompletionType = -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 int mScreen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 int bpp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 char * DisplayName = ":0.0";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 Display * mDisplay;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 XImage * mXImage;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 Window mRootWin;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 static XWindowAttributes attribs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 if(vo_depthonscreen) return 1; // already called
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 mDisplay=XOpenDisplay( DisplayName );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 if ( !mDisplay )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 fprintf( stderr,"vo: couldn't open the X11 display!\n" );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 mScreen=DefaultScreen( mDisplay ); // Screen ID.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 mRootWin=RootWindow( mDisplay,mScreen );// Root window ID.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 vo_screenwidth=DisplayWidth( mDisplay,mScreen );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 vo_screenheight=DisplayHeight( mDisplay,mScreen );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 // get color depth:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 // XGetWindowAttributes(mydisplay, DefaultRootWindow(mDisplay), &attribs);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 XGetWindowAttributes(mDisplay, mRootWin, &attribs);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 vo_depthonscreen=attribs.depth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 // get bits/pixel:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 mXImage=XGetImage( mDisplay,mRootWin,0,0,1,1,AllPlanes,ZPixmap );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 bpp=mXImage->bits_per_pixel;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 XDestroyImage( mXImage );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 if((vo_depthonscreen+7)/8 != (bpp+7)/8) vo_depthonscreen=bpp; // by A'rpi
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 XCloseDisplay( mDisplay );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 printf("X11 running at %dx%d depth: %d\n",vo_screenwidth,vo_screenheight,vo_depthonscreen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 #include "../linux/keycodes.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 extern void mplayer_put_key(int code);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 void vo_keyboard( int key )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 switch ( key )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 case wsLeft: mplayer_put_key(KEY_LEFT); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 case wsRight: mplayer_put_key(KEY_RIGHT); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 case wsUp: mplayer_put_key(KEY_UP); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 case wsDown: mplayer_put_key(KEY_DOWN); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 case wsSpace: mplayer_put_key(' '); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 case wsEscape: mplayer_put_key(KEY_ESC); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 case wsEnter: mplayer_put_key(KEY_ENTER); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 case wsq:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 case wsQ: mplayer_put_key('q'); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 case wsp:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 case wsP: mplayer_put_key('p'); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 case wsMinus:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 case wsGrayMinus: mplayer_put_key('-'); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 case wsPlus:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 case wsGrayPlus: mplayer_put_key('+'); break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 // ----- Motif header: -------
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 #define MWM_HINTS_DECORATIONS 2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 typedef struct
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 long flags;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 long functions;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 long decorations;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 long input_mode;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 } MotifWmHints;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 extern MotifWmHints vo_MotifWmHints;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 extern Atom vo_MotifHints;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 extern int vo_depthonscreen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 extern int vo_screenwidth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 extern int vo_screenheight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 static MotifWmHints vo_MotifWmHints;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 static Atom vo_MotifHints = None;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 void vo_decoration( Display * vo_Display,Window w,int d )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 vo_MotifHints=XInternAtom( vo_Display,"_MOTIF_WM_HINTS",0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 if ( vo_MotifHints != None )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 vo_MotifWmHints.flags=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 vo_MotifWmHints.decorations=d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 XChangeProperty( vo_Display,w,vo_MotifHints,vo_MotifHints,32,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 PropModeReplace,(unsigned char *)&vo_MotifWmHints,4 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 #include <signal.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 int vo_eventhandler_pid=-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 void vo_kill_eventhandler(){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 if(vo_eventhandler_pid!=-1) kill(vo_eventhandler_pid,SIGTERM);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201