Mercurial > mplayer.hg
annotate libvo/vo_xmga.c @ 28118:4455edd2be89
100l, reorder check for AC3 format to avoid a possible memleak
author | reimar |
---|---|
date | Mon, 15 Dec 2008 20:19:27 +0000 |
parents | 6f199f065e15 |
children | 7681eab10aea |
rev | line source |
---|---|
100 | 1 |
2 //#define SHOW_TIME | |
1 | 3 |
4 /* | |
7680 | 5 * vo_xmga.c |
1 | 6 * |
7 * Copyright (C) Zoltan Ponekker - Jan 2001 | |
8 * | |
9 */ | |
10 | |
11 #include <stdio.h> | |
12 #include <stdlib.h> | |
13 #include <string.h> | |
14 | |
15 #include "config.h" | |
6296 | 16 |
1 | 17 #include "video_out.h" |
18 #include "video_out_internal.h" | |
19 | |
20 | |
21 #include <sys/ioctl.h> | |
22 #include <unistd.h> | |
23 #include <fcntl.h> | |
24 #include <sys/mman.h> | |
25 | |
26 #include "drivers/mga_vid.h" | |
27 | |
28 #include <X11/Xlib.h> | |
29 #include <X11/Xutil.h> | |
30 #include <errno.h> | |
31 | |
27377
d58d06eafe83
Change a bunch of X11-specific preprocessor directives.
diego
parents:
27343
diff
changeset
|
32 #ifdef CONFIG_XINERAMA |
4017 | 33 #include <X11/extensions/Xinerama.h> |
34 #endif | |
35 | |
31 | 36 #include "x11_common.h" |
616 | 37 #include "sub.h" |
2057 | 38 #include "aspect.h" |
31 | 39 |
182 | 40 #ifdef SHOW_TIME |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13056
diff
changeset
|
41 #include "osdep/timer.h" |
12582 | 42 static unsigned int timer = 0; |
43 static unsigned int timerd = 0; | |
100 | 44 #endif |
45 | |
27343 | 46 #ifdef CONFIG_GUI |
23077 | 47 #include "gui/interface.h" |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
48 #endif |
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
49 |
25216 | 50 static const vo_info_t info = { |
12582 | 51 "Matrox G200/G4x0/G550 overlay in X11 window (using /dev/mga_vid)", |
52 "xmga", | |
53 "Zoltan Ponekker <pontscho@makacs.poliod.hu>", | |
54 "" | |
1 | 55 }; |
56 | |
25220
c9e9ac2008c2
Mark the vo_functions_t definitions as const where possible.
reimar
parents:
25216
diff
changeset
|
57 const LIBVO_EXTERN(xmga) |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8017
diff
changeset
|
58 |
12582 | 59 static uint32_t mDepth; |
60 static XWindowAttributes attribs; | |
10988 | 61 static int colorkey; |
1 | 62 |
12582 | 63 static uint32_t mvHeight; |
64 static uint32_t mvWidth; | |
1 | 65 |
12582 | 66 static Window mRoot; |
1 | 67 |
12582 | 68 static XSetWindowAttributes xWAttribs; |
1 | 69 |
25962 | 70 static int initialized = 0; |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
6307
diff
changeset
|
71 |
4981 | 72 #define VO_XMGA |
1 | 73 #include "mga_common.c" |
4981 | 74 #undef VO_XMGA |
1 | 75 |
12582 | 76 static void mDrawColorKey(void) |
1 | 77 { |
12582 | 78 XSetBackground(mDisplay, vo_gc, 0); |
79 XClearWindow(mDisplay, vo_window); | |
80 XSetForeground(mDisplay, vo_gc, colorkey); | |
81 XFillRectangle(mDisplay, vo_window, vo_gc, drwX, drwY, drwWidth, | |
82 (vo_fs ? drwHeight - 1 : drwHeight)); | |
83 XFlush(mDisplay); | |
1 | 84 } |
85 | |
31 | 86 static void check_events(void) |
1 | 87 { |
12582 | 88 int e = vo_x11_check_events(mDisplay); |
89 | |
90 if (!(e & VO_EVENT_RESIZE) && !(e & VO_EVENT_EXPOSE)) | |
91 return; | |
92 set_window(); | |
93 mDrawColorKey(); | |
94 if (ioctl(f, MGA_VID_CONFIG, &mga_vid_config)) | |
95 mp_msg(MSGT_VO, MSGL_WARN, | |
96 "Error in mga_vid_config ioctl (wrong mga_vid.o version?)"); | |
1 | 97 } |
98 | |
12582 | 99 static void flip_page(void) |
100 { | |
182 | 101 #ifdef SHOW_TIME |
100 | 102 unsigned int t; |
12582 | 103 |
104 t = GetTimer(); | |
105 mp_msg(MSGT_VO, MSGL_STATUS, | |
106 " [timer: %08X diff: %6d dd: %6d ] \n", t, t - timer, | |
107 (t - timer) - timerd); | |
108 timerd = t - timer; | |
109 timer = t; | |
182 | 110 #endif |
100 | 111 |
12582 | 112 vo_mga_flip_page(); |
31 | 113 } |
1 | 114 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15540
diff
changeset
|
115 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
12582 | 116 uint32_t d_height, uint32_t flags, char *title, |
117 uint32_t format) | |
1 | 118 { |
12582 | 119 XVisualInfo vinfo; |
120 unsigned long xswamask; | |
121 int r, g, b; | |
122 | |
123 if (mga_init(width, height, format)) | |
124 return -1; // ioctl errors? | |
1 | 125 |
12582 | 126 aspect_save_orig(width, height); |
127 aspect_save_prescale(d_width, d_height); | |
18116 | 128 update_xinerama_info(); |
12582 | 129 |
130 mvWidth = width; | |
131 mvHeight = height; | |
1 | 132 |
12582 | 133 vo_panscan_x = vo_panscan_y = vo_panscan_amount = 0; |
2249
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
134 |
18509
94965d83e2b6
do aspect correction of video size before calculating vo_dx and vo_dy.
reimar
parents:
18116
diff
changeset
|
135 aspect(&d_width, &d_height, A_NOZOOM); |
12582 | 136 vo_dx = (vo_screenwidth - d_width) / 2; |
137 vo_dy = (vo_screenheight - d_height) / 2; | |
138 geometry(&vo_dx, &vo_dy, &d_width, &d_height, vo_screenwidth, | |
139 vo_screenheight); | |
18116 | 140 vo_dx += xinerama_x; |
141 vo_dy += xinerama_y; | |
12582 | 142 vo_dwidth = d_width; |
143 vo_dheight = d_height; | |
6307 | 144 |
12582 | 145 r = (vo_colorkey & 0x00ff0000) >> 16; |
146 g = (vo_colorkey & 0x0000ff00) >> 8; | |
147 b = vo_colorkey & 0x000000ff; | |
148 switch (vo_depthonscreen) | |
149 { | |
150 case 32: | |
151 colorkey = vo_colorkey; | |
152 break; | |
153 case 24: | |
154 colorkey = vo_colorkey & 0x00ffffff; | |
155 break; | |
156 case 16: | |
157 colorkey = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); | |
158 break; | |
159 case 15: | |
160 colorkey = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3); | |
161 break; | |
162 default: | |
163 mp_msg(MSGT_VO, MSGL_ERR, | |
164 "Sorry, this (%d) color depth not supported.\n", | |
165 vo_depthonscreen); | |
166 return -1; | |
167 } | |
13946 | 168 mp_msg(MSGT_VO, MSGL_V, "Using colorkey: %x\n", colorkey); |
1 | 169 |
25962 | 170 initialized = 1; |
1 | 171 |
27343 | 172 #ifdef CONFIG_GUI |
12582 | 173 if (use_gui) |
174 guiGetEvent(guiSetShVideo, 0); // the GUI will set up / resize the window | |
175 else | |
5985 | 176 #endif |
12582 | 177 { |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13946
diff
changeset
|
178 if (flags & VOFLAG_FULLSCREEN) |
12582 | 179 aspect(&dwidth, &dheight, A_ZOOM); |
723 | 180 |
12582 | 181 XGetWindowAttributes(mDisplay, mRootWin, &attribs); |
182 mDepth = attribs.depth; | |
183 if (mDepth != 15 && mDepth != 16 && mDepth != 24 && mDepth != 32) | |
184 mDepth = 24; | |
185 XMatchVisualInfo(mDisplay, mScreen, mDepth, TrueColor, &vinfo); | |
186 xWAttribs.colormap = | |
187 XCreateColormap(mDisplay, mRootWin, vinfo.visual, AllocNone); | |
188 xWAttribs.background_pixel = 0; | |
189 xWAttribs.border_pixel = 0; | |
27927
6f199f065e15
Factor common code like -wid handling, vo_gc creation etc. out into
reimar
parents:
27903
diff
changeset
|
190 xswamask = CWBackPixel | CWBorderPixel | CWColormap; |
1 | 191 |
23655
00aa61cde84a
Make X11 window creation and (with -fixed-vo) management simpler and more
reimar
parents:
23077
diff
changeset
|
192 vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, |
23822 | 193 flags, xWAttribs.colormap, "xmga", title); |
24348
f96e42d494f9
Fix borders for xmga broken by r23675. Tested by Diego.
reimar
parents:
23822
diff
changeset
|
194 XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xWAttribs); |
7679 | 195 |
12582 | 196 } // !GUI |
7679 | 197 |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13946
diff
changeset
|
198 if ((flags & VOFLAG_FULLSCREEN) && (!WinID)) |
12582 | 199 { |
200 vo_dx = 0; | |
201 vo_dy = 0; | |
202 vo_dwidth = vo_screenwidth; | |
203 vo_dheight = vo_screenheight; | |
204 vo_fs = 1; | |
205 } | |
7679 | 206 |
12582 | 207 panscan_calc(); |
6755 | 208 |
12582 | 209 mga_vid_config.colkey_on = 1; |
210 mga_vid_config.colkey_red = r; | |
211 mga_vid_config.colkey_green = g; | |
212 mga_vid_config.colkey_blue = b; | |
213 | |
214 set_window(); // set up mga_vid_config.dest_width etc | |
215 | |
216 XSync(mDisplay, False); | |
217 | |
218 ioctl(f, MGA_VID_ON, 0); | |
219 | |
220 return 0; | |
1 | 221 } |
222 | |
12582 | 223 static void uninit(void) |
224 { | |
225 mp_msg(MSGT_VO, MSGL_V, "vo: uninit!\n"); | |
226 mga_uninit(); | |
25962 | 227 if (!initialized) |
12582 | 228 return; // no window? |
25962 | 229 initialized = 0; |
12582 | 230 vo_x11_uninit(); // destroy the window |
1 | 231 } |