[MPlayer-dev-eng] [PATCH] 2/5 Make cmap a file-scope static variable
Alan Curry
pacman at theworld.com
Thu Apr 20 03:46:27 CEST 2006
When VT switching is implemented, the directcolor cmap will need to be
reinstalled every time the movie-playing VT is activated. Currently the
colormap is built, installed, and freed by config(), and no other function
will be able to reinstall it without building it again. This patch causes the
cmap to be kept in a static variable, and freed only when playback is
finished.
This is purely preparation, and should have no noticeable effect on behavior.
--- libvo/vo_fbdev.c.orig 2006-04-18 14:31:52.000000000 -0500
+++ libvo/vo_fbdev.c 2006-04-18 14:29:13.000000000 -0500
@@ -558,7 +558,7 @@
static struct fb_var_screeninfo fb_vinfo;
static unsigned short fb_ored[256], fb_ogreen[256], fb_oblue[256];
static struct fb_cmap fb_oldcmap = { 0, 256, fb_ored, fb_ogreen, fb_oblue };
-static int fb_cmap_changed = 0;
+static struct fb_cmap *fb_newcmap;
static int fb_pixel_size; // 32: 4 24: 3 16: 2 15: 2
static int fb_bpp; // 32: 32 24: 24 16: 16 15: 15
static int fb_bpp_we_want; // 32: 32 24: 24 16: 16 15: 15
@@ -649,6 +649,14 @@
return cmap;
}
+static void freecmap(struct fb_cmap *cmap)
+{
+ free(cmap->red);
+ free(cmap->green);
+ free(cmap->blue);
+ free(cmap);
+}
+
static void vtswitch_init(void)
{
if (fb_tty_fd < 0)
@@ -832,7 +840,6 @@
uint32_t d_height, uint32_t flags, char *title,
uint32_t format)
{
- struct fb_cmap *cmap;
int vm = flags & VOFLAG_MODESWITCHING;
int zoom = flags & VOFLAG_SWSCALE;
int vt_fd;
@@ -949,23 +956,23 @@
break;
case FB_VISUAL_DIRECTCOLOR:
mp_msg(MSGT_VO, MSGL_V, "creating cmap for directcolor\n");
+ if(fb_newcmap) {
+ freecmap(fb_newcmap);
+ fb_newcmap = NULL;
+ }
if (ioctl(fb_dev_fd, FBIOGETCMAP, &fb_oldcmap)) {
mp_msg(MSGT_VO, MSGL_ERR, "can't get cmap: %s\n",
strerror(errno));
return 1;
}
- if (!(cmap = make_directcolor_cmap(&fb_vinfo)))
+ if (!(fb_newcmap = make_directcolor_cmap(&fb_vinfo)))
return 1;
- if (ioctl(fb_dev_fd, FBIOPUTCMAP, cmap)) {
+ if (ioctl(fb_dev_fd, FBIOPUTCMAP, fb_newcmap)) {
mp_msg(MSGT_VO, MSGL_ERR, "can't put cmap: %s\n",
strerror(errno));
+ freecmap(fb_newcmap);
return 1;
}
- fb_cmap_changed = 1;
- free(cmap->red);
- free(cmap->green);
- free(cmap->blue);
- free(cmap);
break;
default:
mp_msg(MSGT_VO, MSGL_ERR, "visual: %d not yet supported\n",
@@ -1004,6 +1011,10 @@
mp_msg(MSGT_VO, MSGL_ERR, "Can't initialize VIDIX driver\n");
vidix_name = NULL;
vidix_term();
+ if (fb_newcmap) {
+ free(fb_newcmap);
+ fb_newcmap = NULL;
+ }
return -1;
}
else mp_msg(MSGT_VO, MSGL_V, "Using VIDIX\n");
@@ -1031,6 +1042,10 @@
if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE,
MAP_SHARED, fb_dev_fd, 0)) == (uint8_t *) -1) {
mp_msg(MSGT_VO, MSGL_ERR, "Can't mmap %s: %s\n", fb_dev_name, strerror(errno));
+ if (fb_newcmap) {
+ free(fb_newcmap);
+ fb_newcmap = NULL;
+ }
return 1;
}
@@ -1124,10 +1139,11 @@
static void uninit(void)
{
- if (fb_cmap_changed) {
+ if (fb_newcmap) {
if (ioctl(fb_dev_fd, FBIOPUTCMAP, &fb_oldcmap))
mp_msg(MSGT_VO, MSGL_WARN, "Can't restore original cmap\n");
- fb_cmap_changed = 0;
+ freecmap(fb_newcmap);
+ fb_newcmap = NULL;
}
if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo))
mp_msg(MSGT_VO, MSGL_WARN, "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno));
More information about the MPlayer-dev-eng
mailing list