From 5416b52f7a465c94b5a9fdb5c27515a57ff04c93 Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Thu, 5 Jan 2012 23:38:25 +0100 Subject: [PATCH 01/15] Experimental OpenGL OSD --- xine-lib/src/video_out/video_out_opengl.c | 111 ++++++++++++++++++++-- 1 file changed, 104 insertions(+), 7 deletions(-) diff --git a/xine-lib/src/video_out/video_out_opengl.c b/xine-lib/src/video_out/video_out_opengl.c index 5d8b606..deaf206 100644 --- a/xine-lib/src/video_out/video_out_opengl.c +++ b/xine-lib/src/video_out/video_out_opengl.c @@ -139,6 +139,13 @@ #define MY_PI 3.1415926 #define MY_2PI 6.2831853 +typedef struct opengl_argb_layer_s { + pthread_mutex_t mutex; + uint32_t *buffer; + /* dirty area */ + int width; + int height; +} opengl_argb_layer_t; typedef struct { vo_frame_t vo_frame; @@ -213,6 +220,7 @@ typedef struct { /* Frame state */ opengl_frame_t *frame[NUM_FRAMES_BACKLOG]; x11osd *xoverlay; + opengl_argb_layer_t argb_layer; int ovl_changed; config_values_t *config; @@ -243,6 +251,10 @@ typedef struct { enum render_e defaction; /* Fallback: change to following render backend if this one doesn't work */ int fallback; + /* Upload new overlay image; Returns 0 if failed */ + int (*ovl_image)(opengl_driver_t *, opengl_frame_t *); + /* Display current overlay */ + void (*ovl_display)(opengl_driver_t *, opengl_frame_t *); } opengl_render_t; @@ -271,6 +283,50 @@ static void render_tex2d (opengl_driver_t *this, opengl_frame_t *frame) { glEnd (); } +/* Static Overlay display */ +static void render_overlay (opengl_driver_t *this, opengl_frame_t *frame) { + int x1, x2, y1, y2; + float tx, ty; + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + if (this->tex_width == 0 && this->tex_height == 0) // Image_Pipeline renderer is active (no texture support) + { + glPixelZoom (((float)this->sc.output_width) / this->argb_layer.width, + - ((float)this->sc.output_height) / this->argb_layer.height); + glRasterPos2i (this->sc.output_xoffset, this->sc.output_yoffset); + glDrawPixels (this->argb_layer.width, this->argb_layer.height, GL_BGRA, + GL_UNSIGNED_BYTE, this->argb_layer.buffer); + } + else + { + if (this->fprog != -1) // 2D_Tex_Fragprog is active which uses a pixelshader to make yuv2rgb conversion + // -> disable it because texture is already argb + glDisable(MYGL_FRAGMENT_PROGRAM_ARB); + + /* Calc texture/rectangle coords */ + x1 = this->sc.output_xoffset; + y1 = this->sc.output_yoffset; + x2 = x1 + this->sc.output_width; + y2 = y1 + this->sc.output_height; + tx = (float) this->argb_layer.width / this->tex_width; + ty = (float) this->argb_layer.height / this->tex_height; + + /* Draw quad */ + glBegin (GL_QUADS); + glTexCoord2f (tx, ty); glVertex2i (x2, y2); + glTexCoord2f (0, ty); glVertex2i (x1, y2); + glTexCoord2f (0, 0); glVertex2i (x1, y1); + glTexCoord2f (tx, 0); glVertex2i (x2, y1); + glEnd (); + + if (this->fprog != -1) // enable pixelshader for next normal video frame + glEnable(MYGL_FRAGMENT_PROGRAM_ARB); + } + glDisable(GL_BLEND); +} + /* Static 2d texture tiled based display */ static void render_tex2dtiled (opengl_driver_t *this, opengl_frame_t *frame) { int tex_w, tex_h, frame_w, frame_h; @@ -555,6 +611,21 @@ static int render_image_tex (opengl_driver_t *this, opengl_frame_t *frame) { return 1; } +static int render_overlay_image_tex (opengl_driver_t *this, opengl_frame_t *frame) { + int ret; + + ret = render_help_image_tex (this, this->argb_layer.width, this->argb_layer.height, + 4, GL_BGRA); + + if (! ret) + return 0; + + glTexSubImage2D (GL_TEXTURE_2D, 0, 4, 0, this->argb_layer.width, this->argb_layer.height, + GL_BGRA, GL_UNSIGNED_BYTE, + this->argb_layer.buffer); + return 1; +} + static int render_image_tiledtex (opengl_driver_t *this, opengl_frame_t *frame) { int ret; int frame_w, frame_h, tex_w, tex_h, i, j, nx, ny; @@ -971,20 +1042,20 @@ static int render_setup_fp_yuv (opengl_driver_t *this) { /* * List of render backends */ -/* name, display, image, setup, needsrgb, defaction, fallback */ +/* name, display, image, setup, needsrgb, defaction, fallback, ovl_image, ovl_display */ static const opengl_render_t opengl_rb[] = { { "2D_Tex_Fragprog", render_tex2d, render_image_fp_yuv, - render_setup_fp_yuv, 0, RENDER_NONE, 1 }, + render_setup_fp_yuv, 0, RENDER_NONE, 1, render_overlay_image_tex, render_overlay }, { "2D_Tex", render_tex2d, render_image_tex, - render_setup_tex2d, 1, RENDER_NONE, 2 }, + render_setup_tex2d, 1, RENDER_NONE, 2, render_overlay_image_tex, render_overlay }, { "2D_Tex_Tiled", render_tex2dtiled, render_image_tiledtex, - render_setup_tex2d, 1, RENDER_NONE, 3 }, + render_setup_tex2d, 1, RENDER_NONE, 3, render_overlay_image_tex, render_overlay }, { "Image_Pipeline", render_draw, render_image_nop, - render_setup_2d, 1, RENDER_NONE, -1 }, + render_setup_2d, 1, RENDER_NONE, -1, render_image_nop, render_overlay }, { "Cylinder", render_cyl, render_image_tex, - render_setup_cyl, 1, RENDER_DRAW, 1 }, + render_setup_cyl, 1, RENDER_DRAW, 1, render_image_nop, render_image_nop }, { "Env_Mapped_Torus", render_env_tor, render_image_envtex, - render_setup_torus, 1, RENDER_DRAW, 1 } + render_setup_torus, 1, RENDER_DRAW, 1, render_image_nop, render_image_nop } } ; @@ -1064,6 +1135,14 @@ static void *render_run (opengl_driver_t *this) { if (changed) ret = (render->image) (this, frame); (render->display) (this, frame); + // display overlay + pthread_mutex_lock (&this->argb_layer.mutex); + if (this->argb_layer.buffer) + { + ret = (render->ovl_image) (this, frame); + (render->ovl_display) (this, frame); + } + pthread_mutex_unlock (&this->argb_layer.mutex); if (this->render_double_buffer) glXSwapBuffers(this->display, this->drawable); else @@ -1473,6 +1552,9 @@ static void opengl_overlay_blend (vo_driver_t *this_gen, opengl_driver_t *this = (opengl_driver_t *) this_gen; opengl_frame_t *frame = (opengl_frame_t *) frame_gen; + if (overlay->width <= 0 || overlay->height <= 0 || (!overlay->rle && (!overlay->argb_layer || !overlay->argb_layer->buffer))) + return; + /* Alpha Blend here */ if (overlay->rle) { if (overlay->unscaled) { @@ -1500,6 +1582,18 @@ static void opengl_overlay_blend (vo_driver_t *this_gen, # endif } } + else if (overlay && overlay->argb_layer && overlay->argb_layer->buffer && this->ovl_changed) + { + // copy argb_buffer because it gets invalid after overlay_end and rendering is after overlay_end + pthread_mutex_lock (&this->argb_layer.mutex); + if (this->argb_layer.buffer) + free(this->argb_layer.buffer); + this->argb_layer.buffer = calloc(overlay->extent_width * overlay->extent_height, sizeof(uint32_t)); + this->argb_layer.width = overlay->extent_width; + this->argb_layer.height = overlay->extent_height; + xine_fast_memcpy(this->argb_layer.buffer, overlay->argb_layer->buffer, overlay->extent_width * overlay->extent_height * sizeof(uint32_t)); + pthread_mutex_unlock (&this->argb_layer.mutex); + } } static int opengl_redraw_needed (vo_driver_t *this_gen) { @@ -1848,6 +1942,9 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v this->fprog = -1; this->xoverlay = NULL; + this->argb_layer.buffer = NULL; + this->argb_layer.width = 0; + this->argb_layer.height = 0; this->ovl_changed = 0; this->xine = class->xine; this->config = config; From 02e922c8ac7b3b94b61d25630859e9b6acaf7500 Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Fri, 6 Jan 2012 19:13:14 +0100 Subject: [PATCH 02/15] Bugfixing fullscreen and 2dTiledTex --- xine-lib/src/video_out/video_out_opengl.c | 67 +++++++++++++++++++++-- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/xine-lib/src/video_out/video_out_opengl.c b/xine-lib/src/video_out/video_out_opengl.c index deaf206..1111327 100644 --- a/xine-lib/src/video_out/video_out_opengl.c +++ b/xine-lib/src/video_out/video_out_opengl.c @@ -219,9 +219,13 @@ typedef struct { /* Frame state */ opengl_frame_t *frame[NUM_FRAMES_BACKLOG]; + + /* Overlay */ x11osd *xoverlay; opengl_argb_layer_t argb_layer; int ovl_changed; + int last_ovl_width, last_ovl_height; + int tex_ovl_width, tex_ovl_height; /* independend of frame */ config_values_t *config; xine_t *xine; @@ -291,7 +295,7 @@ static void render_overlay (opengl_driver_t *this, opengl_frame_t *frame) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - if (this->tex_width == 0 && this->tex_height == 0) // Image_Pipeline renderer is active (no texture support) + if (this->tex_ovl_width == 0 && this->tex_ovl_height == 0) // Image_Pipeline renderer is active (no texture support) { glPixelZoom (((float)this->sc.output_width) / this->argb_layer.width, - ((float)this->sc.output_height) / this->argb_layer.height); @@ -301,6 +305,9 @@ static void render_overlay (opengl_driver_t *this, opengl_frame_t *frame) { } else { + if (this->glBindTextureEXT) // bind overlay texture + this->glBindTextureEXT (GL_TEXTURE_2D, 1000); + if (this->fprog != -1) // 2D_Tex_Fragprog is active which uses a pixelshader to make yuv2rgb conversion // -> disable it because texture is already argb glDisable(MYGL_FRAGMENT_PROGRAM_ARB); @@ -310,8 +317,8 @@ static void render_overlay (opengl_driver_t *this, opengl_frame_t *frame) { y1 = this->sc.output_yoffset; x2 = x1 + this->sc.output_width; y2 = y1 + this->sc.output_height; - tx = (float) this->argb_layer.width / this->tex_width; - ty = (float) this->argb_layer.height / this->tex_height; + tx = (float) this->argb_layer.width / this->tex_ovl_width; + ty = (float) this->argb_layer.height / this->tex_ovl_height; /* Draw quad */ glBegin (GL_QUADS); @@ -323,6 +330,9 @@ static void render_overlay (opengl_driver_t *this, opengl_frame_t *frame) { if (this->fprog != -1) // enable pixelshader for next normal video frame glEnable(MYGL_FRAGMENT_PROGRAM_ARB); + + if (this->glBindTextureEXT) // unbind overlay texture + this->glBindTextureEXT (GL_TEXTURE_2D, 0); } glDisable(GL_BLEND); } @@ -527,6 +537,45 @@ static int render_help_image_tex (opengl_driver_t *this, int new_w, int new_h, return 2; } +/* holds/allocates extra texture for overlay */ +/* returns 0: allocation failure 1: texture updated 2: texture kept */ +static int render_help_overlay_image_tex(opengl_driver_t *this, int new_w, int new_h, + GLint glformat, GLint texformat) { + int tex_w, tex_h, err; + + /* check necessary texture size and allocate */ + if (new_w != this->last_ovl_width || + new_h != this->last_ovl_height || + ! this->tex_ovl_width || ! this->tex_ovl_height) { + tex_w = tex_h = 16; + while (tex_w < new_w) + tex_w <<= 1; + while (tex_h < new_h) + tex_h <<= 1; + + if (tex_w != this->tex_ovl_width || tex_h != this->tex_ovl_height) { + char *tmp = calloc (tex_w * tex_h, 4); /* 4 enough until RGBA */ + if (this->glBindTextureEXT) // xine code binds without call glGenTextures -> seems to me not correct + this->glBindTextureEXT (GL_TEXTURE_2D, 1000); // bind 1000 to avoid collision with tiledtex textures / don't want to rewrite everything ... + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexImage2D (GL_TEXTURE_2D, 0, glformat, tex_w, tex_h, + 0, texformat, GL_UNSIGNED_BYTE, tmp); + err = glGetError (); + free (tmp); + if (err) + return 0; + this->tex_ovl_width = tex_w; + this->tex_ovl_height = tex_h; + lprintf ("* new texsize: %dx%d\n", tex_w, tex_h); + } + this->last_ovl_width = new_w; + this->last_ovl_height = new_h; + return 1; + } + return 2; +} + /* returns 0: allocation failure 1: textures updated 2: textures kept */ static int render_help_image_tiledtex (opengl_driver_t *this, int new_w, int new_h, @@ -613,13 +662,16 @@ static int render_image_tex (opengl_driver_t *this, opengl_frame_t *frame) { static int render_overlay_image_tex (opengl_driver_t *this, opengl_frame_t *frame) { int ret; - - ret = render_help_image_tex (this, this->argb_layer.width, this->argb_layer.height, - 4, GL_BGRA); + + // use own texture + ret = render_help_overlay_image_tex (this, this->argb_layer.width, this->argb_layer.height, + 4, GL_BGRA); if (! ret) return 0; + if (this->glBindTextureEXT) + this->glBindTextureEXT (GL_TEXTURE_2D, 1000); glTexSubImage2D (GL_TEXTURE_2D, 0, 4, 0, this->argb_layer.width, this->argb_layer.height, GL_BGRA, GL_UNSIGNED_BYTE, this->argb_layer.buffer); @@ -1208,6 +1260,7 @@ static void *render_run (opengl_driver_t *this) { } XUnlockDisplay (this->display); this->tex_width = this->tex_height = 0; + this->tex_ovl_width = this->tex_ovl_height = 0; } break; @@ -1946,6 +1999,8 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v this->argb_layer.width = 0; this->argb_layer.height = 0; this->ovl_changed = 0; + this->last_ovl_width = this->last_ovl_height = -1; + this->xine = class->xine; this->config = config; From bc9252480a2d220fb179eec3a56cb0c0f4eaa30d Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Fri, 13 Jan 2012 23:05:16 +0100 Subject: [PATCH 03/15] don't start updateWindowState when there is no resize + resize didn't work if only height or width was changed --- enigma2/lib/gdi/gxlibdc.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/enigma2/lib/gdi/gxlibdc.cpp b/enigma2/lib/gdi/gxlibdc.cpp index 6ea07d0..32b5bb3 100644 --- a/enigma2/lib/gdi/gxlibdc.cpp +++ b/enigma2/lib/gdi/gxlibdc.cpp @@ -225,6 +225,8 @@ void gXlibDC::setResolution(int xres, int yres) if (argb_buffer) delete [] argb_buffer; argb_buffer = new uint32_t[windowWidth*windowHeight]; + int i; + for (i=0; inewOsd(windowWidth, windowHeight, argb_buffer); @@ -346,11 +348,14 @@ void gXlibDC::thread() xpos = cne.x; ypos = cne.y; } - if (!fullscreen){ - windowWidth = cne.width; - windowHeight = cne.height; + if (!fullscreen){ + if (cne.width != windowWidth || cne.height != windowHeight) + { + windowWidth = cne.width; + windowHeight = cne.height; + updateWindowState(); + } } - updateWindowState(); } break; } From 7700aba62713632bdd2b3ca12eb56989f635617c Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Fri, 13 Jan 2012 23:07:21 +0100 Subject: [PATCH 04/15] saftey check + release memory --- xine-lib/src/video_out/video_out_opengl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xine-lib/src/video_out/video_out_opengl.c b/xine-lib/src/video_out/video_out_opengl.c index 1111327..5de690d 100644 --- a/xine-lib/src/video_out/video_out_opengl.c +++ b/xine-lib/src/video_out/video_out_opengl.c @@ -1642,6 +1642,11 @@ static void opengl_overlay_blend (vo_driver_t *this_gen, if (this->argb_layer.buffer) free(this->argb_layer.buffer); this->argb_layer.buffer = calloc(overlay->extent_width * overlay->extent_height, sizeof(uint32_t)); + if (this->argb_layer.buffer == NULL) + { + printf("Fatal error(opengl_overlay_blend): No memory\n"); + return; + } this->argb_layer.width = overlay->extent_width; this->argb_layer.height = overlay->extent_height; xine_fast_memcpy(this->argb_layer.buffer, overlay->argb_layer->buffer, overlay->extent_width * overlay->extent_height * sizeof(uint32_t)); @@ -1944,6 +1949,11 @@ static void opengl_dispose (vo_driver_t *this_gen) { XUnlockDisplay (this->display); } + pthread_mutex_lock (&this->argb_layer.mutex); + if (this->argb_layer.buffer) + free(this->argb_layer.buffer); + pthread_mutex_unlock (&this->argb_layer.mutex); + _x_alphablend_free(&this->alphablend_extra_data); free (this); From 4500e36470252f5a0eb484134189c24b0765e517 Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Fri, 13 Jan 2012 23:08:20 +0100 Subject: [PATCH 05/15] OSD for XSHM driver --- xine-lib/src/video_out/video_out_xshm.c | 8 ++ xine-lib/src/video_out/x11osd.c | 155 +++++++++++++++++++++++- xine-lib/src/video_out/x11osd.h | 4 + 3 files changed, 166 insertions(+), 1 deletion(-) diff --git a/xine-lib/src/video_out/video_out_xshm.c b/xine-lib/src/video_out/video_out_xshm.c index 675575e..b0579cf 100644 --- a/xine-lib/src/video_out/video_out_xshm.c +++ b/xine-lib/src/video_out/video_out_xshm.c @@ -689,6 +689,14 @@ static void xshm_overlay_blend (vo_driver_t *this_gen, } } } + else if (overlay && overlay->argb_layer && overlay->argb_layer->buffer && this->ovl_changed) + { + pthread_mutex_lock (&overlay->argb_layer->mutex); + LOCK_DISPLAY(this); + x11osd_blend(this->xoverlay, overlay); + UNLOCK_DISPLAY(this); + pthread_mutex_unlock (&overlay->argb_layer->mutex); + } } static void clean_output_area (xshm_driver_t *this, xshm_frame_t *frame) { diff --git a/xine-lib/src/video_out/x11osd.c b/xine-lib/src/video_out/x11osd.c index 8d8a781..20a3e09 100644 --- a/xine-lib/src/video_out/x11osd.c +++ b/xine-lib/src/video_out/x11osd.c @@ -78,6 +78,7 @@ struct x11osd Pixmap bitmap; Visual *visual; Colormap cmap; + XImage *argb_img; GC gc; @@ -96,6 +97,12 @@ x11osd_expose (x11osd * osd) assert (osd); lprintf("expose (state:%d)\n", osd->clean ); + + // copy argb data to bitmap + if (osd->argb_img && osd->argb_img->data) + { + XPutImage(osd->display, osd->bitmap, osd->gc, osd->argb_img, 0, 0, 0, 0, osd->width, osd->height); + } switch (osd->mode) { case X11OSD_SHAPED: @@ -153,6 +160,11 @@ x11osd_resize (x11osd * osd, int width, int height) osd->width, osd->height, osd->depth); break; } + + // resize argb_img data + XDestroyImage(osd->argb_img); + osd->argb_img = XCreateImage(osd->display, osd->visual, 24, ZPixmap, 0, NULL, osd->width, osd->height, 32, 0); + osd->argb_img->data = calloc(osd->width * osd->height, sizeof(uint32_t)); osd->clean = UNDEFINED; x11osd_clear(osd); @@ -224,6 +236,11 @@ x11osd_drawable_changed (x11osd * osd, Window window) break; } + // resize argb_img data + XDestroyImage(osd->argb_img); + osd->argb_img = XCreateImage(osd->display, osd->visual, 24, ZPixmap, 0, NULL, osd->width, osd->height, 32, 0); + osd->argb_img->data = calloc(osd->width * osd->height, sizeof(uint32_t)); + osd->clean = UNDEFINED; /* do not x11osd_clear() here: osd->u.colorkey.sc has not being updated yet */ } @@ -268,6 +285,10 @@ x11osd_create (xine_t *xine, Display *display, int screen, Window window, enum x assert(osd->width); assert(osd->height); + // create image for argb overlay + osd->argb_img = XCreateImage(osd->display, osd->visual, 24, ZPixmap, 0, NULL, osd->width, osd->height, 32, 0); + osd->argb_img->data = calloc(osd->width * osd->height, sizeof(uint32_t)); + switch (mode) { case X11OSD_SHAPED: if (!XShapeQueryExtension (osd->display, &event_basep, &error_basep)) { @@ -395,7 +416,7 @@ x11osd_destroy (x11osd * osd) XFreePixmap (osd->display, osd->u.shaped.mask_bitmap); XDestroyWindow (osd->display, osd->u.shaped.window); } - + XDestroyImage(osd->argb_img); free (osd); } @@ -546,5 +567,137 @@ void x11osd_blend(x11osd *osd, vo_overlay_t *overlay) } osd->clean = DRAWN; } + else if (overlay->argb_layer && overlay->argb_layer->buffer) + { + osd->argb_img->data = realloc(osd->argb_img->data, osd->width * osd->height * sizeof(uint32_t)); + + x11osd_scale_argb32_image((uint32_t*)overlay->argb_layer->buffer, (uint32_t*)osd->argb_img->data, overlay->extent_width, overlay->extent_height, osd->width, osd->height); + + + uint32_t bx, by; + uint32_t w, h; + if(osd->mode==X11OSD_SHAPED) // fill bitmask / if bit is set, the corresponding pixel is drawn to screen + { + w= osd->width - overlay->x; + h= osd->height - overlay->y; + for (by= 0; by < h; by++) + for (bx= 0; bx < w; bx++) + if (((uint32_t*)osd->argb_img->data)[bx+by*w] != 0xFFFFFF ) + XDrawPoint(osd->display, osd->u.shaped.mask_bitmap, osd->u.shaped.mask_gc, bx, by); + } + + osd->clean = DRAWN; + } +} + +// adapted algorithm from yuv2rgb.c to scale rgb images +void x11osd_scale_argb32_image(uint32_t* src, uint32_t* dst, int src_width, int src_height, int dst_width, int dst_height) +{ + int step_dx = src_width * 32768 / dst_width; + int step_dy = src_height * 32768 / dst_height; + int height, dy= 0; + + if (src_width == dst_width && src_height == dst_height) + { + xine_fast_memcpy (dst, src, dst_width*dst_height*4); + return; + } + + for (height = 0;; ) + { + x11osd_scale_line (src, dst, dst_width, step_dx); //scale_line + + dy += step_dy; + dst += dst_width; + + while (--dst_height > 0 && dy < 32768) // copy scaled line (only enlarging) + { + xine_fast_memcpy (dst, dst-(dst_width), dst_width*4); // copy last line + + dy += step_dy; + dst += dst_width; + } + if (dst_height <= 0) + break; + + do + { // skip at least one line (possibly more if scale factor < 1) + dy -= 32768; + src += src_width; + + height++; + } while( dy>=32768); + } } +// adapted algorithm from yuv2rgb.c to scale single argb line +void x11osd_scale_line(uint32_t* src, uint32_t* dst, int width, int step) +{ + uint32_t p1; + uint32_t p2; + int dx; + + p1 = *src++; + p2 = *src++; + dx = 0; + + if (step < 32768) { + while (width) { + *dst = ((((p1 >> 24) * (32768-dx)) + ((p2 >> 24) * dx))>>15) << 24 + | (((((p1 >> 16) & 0xFF) * (32768-dx)) + (((p2 >> 16) & 0xFF) * dx))>>15) << 16 + | (((((p1 >> 8) & 0xFF) * (32768-dx)) + (((p2 >> 8) & 0xFF) * dx))>>15) << 8 + | (((p1 & 0xFF) * (32768-dx)) + ((p2 & 0xFF) * dx))>>15; + + dx += step; + if (dx > 32768) { + dx -= 32768; + p1 = p2; + p2 = *src++; + } + + dst ++; + width --; + } + } else if (step <= 65536) { + while (width) { + *dst = ((((p1 >> 24) * (32768-dx)) + ((p2 >> 24) * dx))>>15) << 24 + | (((((p1 >> 16) & 0xFF) * (32768-dx)) + (((p2 >> 16) & 0xFF) * dx))>>15) << 16 + | (((((p1 >> 8) & 0xFF) * (32768-dx)) + (((p2 >> 8) & 0xFF) * dx))>>15) << 8 + | (((p1 & 0xFF) * (32768-dx)) + ((p2 & 0xFF) * dx))>>15; + + dx += step; + if (dx > 65536) { + dx -= 65536; + p1 = *src++; + p2 = *src++; + } else { + dx -= 32768; + p1 = p2; + p2 = *src++; + } + + dst ++; + width --; + } + } else { + while (width) { + int offs; + + *dst = ((((p1 >> 24) * (32768-dx)) + ((p2 >> 24) * dx))>>15) << 24 + | (((((p1 >> 16) & 0xFF) * (32768-dx)) + (((p2 >> 16) & 0xFF) * dx))>>15) << 16 + | (((((p1 >> 8) & 0xFF) * (32768-dx)) + (((p2 >> 8) & 0xFF) * dx))>>15) << 8 + | (((p1 & 0xFF) * (32768-dx)) + ((p2 & 0xFF) * dx))>>15; + + dx += step; + offs=((dx-1)>>15); + dx-=offs<<15; + src+=offs-2; + p1=*src++; + p2=*src++; + dst ++; + width --; + } + } + +}; + diff --git a/xine-lib/src/video_out/x11osd.h b/xine-lib/src/video_out/x11osd.h index 15ea3dc..74aa3e1 100644 --- a/xine-lib/src/video_out/x11osd.h +++ b/xine-lib/src/video_out/x11osd.h @@ -49,4 +49,8 @@ void x11osd_clear(x11osd *osd); void x11osd_blend(x11osd *osd, vo_overlay_t *overlay); +void x11osd_scale_argb32_image(uint32_t* src, uint32_t* dst, int src_width, int src_height, int dst_width, int dst_height); + +void x11osd_scale_line(uint32_t* src, uint32_t* dst, int width, int step); + #endif From bc2aa40f9f39c387f64882bf7ae5fbc7b722e5c7 Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Mon, 16 Jan 2012 22:26:05 +0100 Subject: [PATCH 06/15] corrected wrong git command --- build_libs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_libs.sh b/build_libs.sh index e23542f..6ebeab3 100755 --- a/build_libs.sh +++ b/build_libs.sh @@ -107,7 +107,7 @@ if [ -d $PKG ]; then rm -Rf $PKG rm -f $PKG* fi -git://git.videolan.org/libbluray.git +git clone git://git.videolan.org/libbluray.git cd $PKG git checkout $LIB_BLURAY_REF autoreconf -vif From c45f149e644807099b54193493df208709ef4a72 Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Mon, 16 Jan 2012 22:35:51 +0100 Subject: [PATCH 07/15] added MMX support for osd scaling --- xine-lib/src/video_out/x11osd.c | 234 ++++++++++++++++++++++++++++---- xine-lib/src/video_out/x11osd.h | 5 +- 2 files changed, 209 insertions(+), 30 deletions(-) diff --git a/xine-lib/src/video_out/x11osd.c b/xine-lib/src/video_out/x11osd.c index 20a3e09..b81064f 100644 --- a/xine-lib/src/video_out/x11osd.c +++ b/xine-lib/src/video_out/x11osd.c @@ -44,6 +44,9 @@ #include #include +#include +#include "xine_mmx.h" + #define LOG_MODULE "x11osd" #define LOG_VERBOSE @@ -79,6 +82,8 @@ struct x11osd Visual *visual; Colormap cmap; XImage *argb_img; + void (*scale_func) (uint32_t* src, uint32_t* dst, int width, int step); + int scale_mmx; GC gc; @@ -288,6 +293,22 @@ x11osd_create (xine_t *xine, Display *display, int screen, Window window, enum x // create image for argb overlay osd->argb_img = XCreateImage(osd->display, osd->visual, 24, ZPixmap, 0, NULL, osd->width, osd->height, 32, 0); osd->argb_img->data = calloc(osd->width * osd->height, sizeof(uint32_t)); + + // scale function +#if defined(ARCH_X86) || defined(ARCH_X86_64) + uint32_t mm = xine_mm_accel(); + if ((osd->scale_func == NULL) && ((mm & MM_ACCEL_X86_MMX) || (mm & MM_ACCEL_X86_MMXEXT))) + { + osd->scale_func= x11osd_scale_line_mmx; + osd->scale_mmx= 1; + printf("X11OSD: MMX OSD scaling active\n"); + } +#endif + if (osd->scale_func == NULL) + { + osd->scale_func= x11osd_scale_line; + osd->scale_mmx= 0; + } switch (mode) { case X11OSD_SHAPED: @@ -571,8 +592,7 @@ void x11osd_blend(x11osd *osd, vo_overlay_t *overlay) { osd->argb_img->data = realloc(osd->argb_img->data, osd->width * osd->height * sizeof(uint32_t)); - x11osd_scale_argb32_image((uint32_t*)overlay->argb_layer->buffer, (uint32_t*)osd->argb_img->data, overlay->extent_width, overlay->extent_height, osd->width, osd->height); - + x11osd_scale_argb32_image(osd, (uint32_t*)overlay->argb_layer->buffer, (uint32_t*)osd->argb_img->data, overlay->extent_width, overlay->extent_height, osd->width, osd->height); uint32_t bx, by; uint32_t w, h; @@ -591,7 +611,7 @@ void x11osd_blend(x11osd *osd, vo_overlay_t *overlay) } // adapted algorithm from yuv2rgb.c to scale rgb images -void x11osd_scale_argb32_image(uint32_t* src, uint32_t* dst, int src_width, int src_height, int dst_width, int dst_height) +void x11osd_scale_argb32_image(x11osd *osd, uint32_t* src, uint32_t* dst, int src_width, int src_height, int dst_width, int dst_height) { int step_dx = src_width * 32768 / dst_width; int step_dy = src_height * 32768 / dst_height; @@ -605,8 +625,8 @@ void x11osd_scale_argb32_image(uint32_t* src, uint32_t* dst, int src_width, int for (height = 0;; ) { - x11osd_scale_line (src, dst, dst_width, step_dx); //scale_line - + osd->scale_func(src, dst, dst_width, step_dx); // scale_line with or without mmx + dy += step_dy; dst += dst_width; @@ -628,6 +648,7 @@ void x11osd_scale_argb32_image(uint32_t* src, uint32_t* dst, int src_width, int height++; } while( dy>=32768); } + if (osd->scale_mmx) emms(); // empties the MMX state } // adapted algorithm from yuv2rgb.c to scale single argb line @@ -641,46 +662,55 @@ void x11osd_scale_line(uint32_t* src, uint32_t* dst, int width, int step) p2 = *src++; dx = 0; - if (step < 32768) { - while (width) { - *dst = ((((p1 >> 24) * (32768-dx)) + ((p2 >> 24) * dx))>>15) << 24 - | (((((p1 >> 16) & 0xFF) * (32768-dx)) + (((p2 >> 16) & 0xFF) * dx))>>15) << 16 - | (((((p1 >> 8) & 0xFF) * (32768-dx)) + (((p2 >> 8) & 0xFF) * dx))>>15) << 8 - | (((p1 & 0xFF) * (32768-dx)) + ((p2 & 0xFF) * dx))>>15; - + if (step < 32768) + { + while (width) + { + *dst = ((((p1 >> 24) * (32768-dx)) + ((p2 >> 24) * dx))>>15) << 24 // interpolate A: (A1*(32768-dx)+A2*dx) / 32768 + | (((((p1 >> 16) & 0xFF) * (32768-dx)) + (((p2 >> 16) & 0xFF) * dx))>>15) << 16 // interpolate R + | (((((p1 >> 8) & 0xFF) * (32768-dx)) + (((p2 >> 8) & 0xFF) * dx))>>15) << 8 // interpolate G + | (((p1 & 0xFF) * (32768-dx)) + ((p2 & 0xFF) * dx))>>15; // interpolate B + dx += step; - if (dx > 32768) { - dx -= 32768; - p1 = p2; - p2 = *src++; + if (dx > 32768) + { + dx -= 32768; + p1 = p2; + p2 = *src++; } dst ++; width --; } - } else if (step <= 65536) { - while (width) { + } else if (step <= 65536) + { + while (width) + { *dst = ((((p1 >> 24) * (32768-dx)) + ((p2 >> 24) * dx))>>15) << 24 | (((((p1 >> 16) & 0xFF) * (32768-dx)) + (((p2 >> 16) & 0xFF) * dx))>>15) << 16 | (((((p1 >> 8) & 0xFF) * (32768-dx)) + (((p2 >> 8) & 0xFF) * dx))>>15) << 8 | (((p1 & 0xFF) * (32768-dx)) + ((p2 & 0xFF) * dx))>>15; dx += step; - if (dx > 65536) { - dx -= 65536; - p1 = *src++; - p2 = *src++; - } else { - dx -= 32768; - p1 = p2; - p2 = *src++; + if (dx > 65536) + { + dx -= 65536; + p1 = *src++; + p2 = *src++; + } else + { + dx -= 32768; + p1 = p2; + p2 = *src++; } dst ++; width --; } - } else { - while (width) { + } else + { + while (width) + { int offs; *dst = ((((p1 >> 24) * (32768-dx)) + ((p2 >> 24) * dx))>>15) << 24 @@ -698,6 +728,152 @@ void x11osd_scale_line(uint32_t* src, uint32_t* dst, int width, int step) width --; } } - }; +// adapted algorithm from yuv2rgb.c to scale single argb line +void x11osd_scale_line_mmx(uint32_t* src, uint32_t* dst, int width, int step) +{ + uint32_t p1; + uint32_t p2; + int dx; + int dx2; + + p1 = *src++; + p2 = *src++; + dx = 0; + + if (step < 32768) + { + while (width) + { + dx2 = dx * 2; + if (dx2==65536) + dx2-= 1; + + /* + * MMX ARGB interpolation between p1(a1,r1,g1,b1) and p2(a2,r2,g2,b2) + * a= (a1* (32768-dx) + a2 * dx) / 32768 -> a = a1 - a1*dx/32768 + a2*dx/32768 + * r= (r1* (32768-dx) + r2 * dx) / 32768 -> r = r1 - r1*dx/32768 + r2*dx/32768 + * ... + * Doing multiplication of a,r,g,b with dx in one step + * Division by 32768 is not necessary in mmx because you can get only the high 16 bits of a multiplication + */ + movd_m2r(p1,mm0); // mm0 = p1; + movq_r2r(mm0,mm1); // mm1 = mm0; copy because result of unpack overides mm1 and we need p1 later again + pxor_r2r(mm2,mm2); // mm2 = 0; + punpcklbw_r2r(mm2,mm1); // mm1 = unpacked p1 (00 AA 00 RR 00 GG 00 BB) + movd_m2r(dx2,mm3); // mm3 = dx2; from here i call dx2 = 0xd1d2 + movd_m2r(dx2,mm4); // mm4 = dx2; + punpcklwd_r2r(mm3,mm4); // mm4 = 00 00 00 00 d1 d2 d1 d2; + movq_r2r(mm4,mm3); // mm3 = mm4; + punpcklwd_r2r(mm3,mm4); // mm4 = d1 d2 d1 d2 d1 d2 d1 d2; 4 times dx2 + movq_r2r(mm4,mm5); // mm5 = mm4; copy + pmulhuw_r2r(mm4,mm1); // mm1 = mm4 * mm1 = dx2 * p1 = dx * p1 / 32768 // get from multiplication only high 16 bits + packuswb_r2r(mm2,mm1); // mm1 = packed mm1 + movd_m2r(p2,mm6); // mm6 = p2; + punpcklbw_r2r(mm2,mm6); // mm6 = unpacked p2 (00 AA 00 RR 00 GG 00 BB) + pmulhuw_r2r(mm5,mm6); // mm6 = mm5 * mm6 = dx2 * p2 = dx * p2 / 32768 // get from multiplication only high 16 bits + packuswb_r2r(mm2,mm6); // mm6 = packed mm6 + psubusb_r2r(mm1,mm0); // mm0 = mm0 - mm1 = p1 - (p1*dx/32768) + paddusb_r2r(mm0,mm6); // mm5 = mm0 + mm5 = p1 - (p1*dx/32768) + (p2*dx/32768) + + movd_r2m(mm6, *dst); + + dx += step; + if (dx > 32768) + { + dx -= 32768; + p1 = p2; + p2 = *src++; + } + + dst ++; + width --; + } + } else if (step <= 65536) + { + while (width) + { + dx2 = dx * 2; + if (dx2==65536) + dx2-= 1; + + movd_m2r(p1,mm0); // mm0 = p1; + movq_r2r(mm0,mm1); // mm1 = mm0; copy because result of unpack overides mm1 and we need p1 later again + pxor_r2r(mm2,mm2); // mm2 = 0; + punpcklbw_r2r(mm2,mm1); // mm1 = unpacked p1 (00 AA 00 RR 00 GG 00 BB) + movd_m2r(dx2,mm3); // mm3 = dx2; from here i call dx2 = 0xd1d2 + movd_m2r(dx2,mm4); // mm4 = dx2; + punpcklwd_r2r(mm3,mm4); // mm4 = 00 00 00 00 d1 d2 d1 d2; + movq_r2r(mm4,mm3); // mm3 = mm4; + punpcklwd_r2r(mm3,mm4); // mm4 = d1 d2 d1 d2 d1 d2 d1 d2; 4 times dx2 + movq_r2r(mm4,mm5); // mm5 = mm4; copy + pmulhuw_r2r(mm4,mm1); // mm1 = mm4 * mm1 = dx2 * p1 = dx * p1 / 32768 // get from multiplication only high 16 bits + packuswb_r2r(mm2,mm1); // mm1 = packed mm1 + movd_m2r(p2,mm6); // mm6 = p2; + punpcklbw_r2r(mm2,mm6); // mm6 = unpacked p2 (00 AA 00 RR 00 GG 00 BB) + pmulhuw_r2r(mm5,mm6); // mm6 = mm5 * mm6 = dx2 * p2 = dx * p2 / 32768 // get from multiplication only high 16 bits + packuswb_r2r(mm2,mm6); // mm6 = packed mm6 + psubusb_r2r(mm1,mm0); // mm0 = mm0 - mm1 = p1 - (p1*dx/32768) + paddusb_r2r(mm0,mm6); // mm5 = mm0 + mm5 = p1 - (p1*dx/32768) + (p2*dx/32768) + + movd_r2m(mm6, *dst); + + dx += step; + if (dx > 65536) + { + dx -= 65536; + p1 = *src++; + p2 = *src++; + } else + { + dx -= 32768; + p1 = p2; + p2 = *src++; + } + + dst ++; + width --; + } + } else + { + while (width) + { + int offs; + + dx2 = dx * 2; + if (dx2==65536) + dx2-= 1; + + movd_m2r(p1,mm0); // mm0 = p1; + movq_r2r(mm0,mm1); // mm1 = mm0; copy because result of unpack overides mm1 and we need p1 later again + pxor_r2r(mm2,mm2); // mm2 = 0; + punpcklbw_r2r(mm2,mm1); // mm1 = unpacked p1 (00 AA 00 RR 00 GG 00 BB) + movd_m2r(dx2,mm3); // mm3 = dx2; from here i call dx2 = 0xd1d2 + movd_m2r(dx2,mm4); // mm4 = dx2; + punpcklwd_r2r(mm3,mm4); // mm4 = 00 00 00 00 d1 d2 d1 d2; + movq_r2r(mm4,mm3); // mm3 = mm4; + punpcklwd_r2r(mm3,mm4); // mm4 = d1 d2 d1 d2 d1 d2 d1 d2; 4 times dx2 + movq_r2r(mm4,mm5); // mm5 = mm4; copy + pmulhuw_r2r(mm4,mm1); // mm1 = mm4 * mm1 = dx2 * p1 = dx * p1 / 32768 // get from multiplication only high 16 bits + packuswb_r2r(mm2,mm1); // mm1 = packed mm1 + movd_m2r(p2,mm6); // mm6 = p2; + punpcklbw_r2r(mm2,mm6); // mm6 = unpacked p2 (00 AA 00 RR 00 GG 00 BB) + pmulhuw_r2r(mm5,mm6); // mm6 = mm5 * mm6 = dx2 * p2 = dx * p2 / 32768 // get from multiplication only high 16 bits + packuswb_r2r(mm2,mm6); // mm6 = packed mm6 + psubusb_r2r(mm1,mm0); // mm0 = mm0 - mm1 = p1 - (p1*dx/32768) + paddusb_r2r(mm0,mm6); // mm5 = mm0 + mm5 = p1 - (p1*dx/32768) + (p2*dx/32768) + + movd_r2m(mm6, *dst); + + dx += step; + offs=((dx-1)>>15); + dx-=offs<<15; + src+=offs-2; + p1=*src++; + p2=*src++; + dst ++; + width --; + } + } +}; diff --git a/xine-lib/src/video_out/x11osd.h b/xine-lib/src/video_out/x11osd.h index 74aa3e1..7b4caa1 100644 --- a/xine-lib/src/video_out/x11osd.h +++ b/xine-lib/src/video_out/x11osd.h @@ -29,6 +29,7 @@ #define X11OSD_H #include +#include typedef struct x11osd x11osd; enum x11osd_mode {X11OSD_SHAPED, X11OSD_COLORKEY}; @@ -49,8 +50,10 @@ void x11osd_clear(x11osd *osd); void x11osd_blend(x11osd *osd, vo_overlay_t *overlay); -void x11osd_scale_argb32_image(uint32_t* src, uint32_t* dst, int src_width, int src_height, int dst_width, int dst_height); +void x11osd_scale_argb32_image(x11osd *osd, uint32_t* src, uint32_t* dst, int src_width, int src_height, int dst_width, int dst_height); void x11osd_scale_line(uint32_t* src, uint32_t* dst, int width, int step); +void x11osd_scale_line_mmx(uint32_t* src, uint32_t* dst, int width, int step); + #endif From c54044efa6db0691da695f66e891236bd272033a Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Tue, 17 Jan 2012 21:39:07 +0100 Subject: [PATCH 08/15] now only using alpha byte to determine transparency --- enigma2/lib/gdi/gxlibdc.cpp | 3 +-- xine-lib/src/video_out/x11osd.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/enigma2/lib/gdi/gxlibdc.cpp b/enigma2/lib/gdi/gxlibdc.cpp index 32b5bb3..400a518 100644 --- a/enigma2/lib/gdi/gxlibdc.cpp +++ b/enigma2/lib/gdi/gxlibdc.cpp @@ -225,8 +225,7 @@ void gXlibDC::setResolution(int xres, int yres) if (argb_buffer) delete [] argb_buffer; argb_buffer = new uint32_t[windowWidth*windowHeight]; - int i; - for (i=0; inewOsd(windowWidth, windowHeight, argb_buffer); diff --git a/xine-lib/src/video_out/x11osd.c b/xine-lib/src/video_out/x11osd.c index b81064f..700eb56 100644 --- a/xine-lib/src/video_out/x11osd.c +++ b/xine-lib/src/video_out/x11osd.c @@ -602,7 +602,7 @@ void x11osd_blend(x11osd *osd, vo_overlay_t *overlay) h= osd->height - overlay->y; for (by= 0; by < h; by++) for (bx= 0; bx < w; bx++) - if (((uint32_t*)osd->argb_img->data)[bx+by*w] != 0xFFFFFF ) + if ((((uint32_t*)osd->argb_img->data)[bx+by*w] >> 24) != 0 ) XDrawPoint(osd->display, osd->u.shaped.mask_bitmap, osd->u.shaped.mask_gc, bx, by); } From d7ccf65f5d539ab807e3fd466db9fc320c773b37 Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Sat, 21 Jan 2012 19:13:41 +0100 Subject: [PATCH 09/15] support for archlinux --- enigma2/lib/base/Makefile.am | 3 ++- enigma2/main/Makefile.am | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/enigma2/lib/base/Makefile.am b/enigma2/lib/base/Makefile.am index 5423ca1..6e09c4b 100644 --- a/enigma2/lib/base/Makefile.am +++ b/enigma2/lib/base/Makefile.am @@ -2,7 +2,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/include \ -include Python.h \ - -include $(top_builddir)/enigma2_config.h + -include $(top_builddir)/enigma2_config.h \ + -lrt noinst_LIBRARIES = libenigma_base.a diff --git a/enigma2/main/Makefile.am b/enigma2/main/Makefile.am index fa74d33..68aedb4 100644 --- a/enigma2/main/Makefile.am +++ b/enigma2/main/Makefile.am @@ -53,7 +53,7 @@ enigma2_LDADD = \ @PYTHON_LDFLAGS@ \ @X11_LIBS@ \ @LIBDDVD_LIBS@ \ - -lcrypt -lnl -lnl-genl -ldvbcsa + -lcrypt -lnl -lnl-genl -ldvbcsa -lrt enigma2_LDFLAGS = -Wl,--export-dynamic From 7d54217ee38f806e7b5b245a4662d4aae149b526 Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Tue, 24 Jan 2012 21:47:47 +0100 Subject: [PATCH 10/15] - audio channel selection is possible - video/audio is now working on more channels --- xine-lib/src/demuxers/demux_ts.c | 55 +++++++++++++++++--------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/xine-lib/src/demuxers/demux_ts.c b/xine-lib/src/demuxers/demux_ts.c index 76363b0..3e75a7b 100644 --- a/xine-lib/src/demuxers/demux_ts.c +++ b/xine-lib/src/demuxers/demux_ts.c @@ -2229,30 +2229,8 @@ static void demux_ts_parse_packet (demux_ts_t*this) { } /* PAT */ - if (pid == 0) { - demux_ts_parse_pat(this, originalPkt, originalPkt+data_offset-4, - payload_unit_start_indicator); - return; - } - /* PMT */ - program_count=0; - while ((this->program_number[program_count] != INVALID_PROGRAM) && - (program_count < MAX_PMTS)) { - if (pid == this->pmt_pid[program_count]) { - -#ifdef TS_LOG - printf ("demux_ts: PMT prog: 0x%.4x pid: 0x%.4x\n", - this->program_number[program_count], - this->pmt_pid[program_count]); -#endif - demux_ts_parse_pmt (this, originalPkt, originalPkt+data_offset-4, - payload_unit_start_indicator, - program_count); - return; - } - program_count++; - } + // PAT and PMT are not processed for openpliPC. PIDs are recognized in E2 data_len = PKT_SIZE - data_offset; @@ -2314,6 +2292,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) { static void demux_ts_event_handler (demux_ts_t *this) { xine_event_t *event; + int mi; while ((event = xine_event_get (this->event_queue))) { @@ -2324,13 +2303,37 @@ static void demux_ts_event_handler (demux_ts_t *this) { /* flush all streams */ demux_ts_flush(this); /* fall thru */ - + break; + case XINE_EVENT_PIDS_CHANGE: - - demux_ts_dynamic_pmt_clear(this); + demux_ts_dynamic_pmt_clear(this); this->send_newpts = 1; _x_demux_control_start (this->stream); break; + + case XINE_EVENT_SET_VIDEO_STREAMTYPE: + printf("RECEIVED XINE_EVENT_SET_VIDEO_STREAMTYPE\n"); + + if (event->data) { + xine_streamtype_data_t* data = (xine_streamtype_data_t*)event->data; + + mi = demux_ts_dynamic_pmt_find (this, data->pid, BUF_VIDEO_BASE, data->streamtype); + if (mi >= 0) { + this->videoPid = data->pid; + this->videoMedia = mi; + } + } + break; + + case XINE_EVENT_SET_AUDIO_STREAMTYPE: + printf("RECEIVED XINE_EVENT_SET_AUDIO_STREAMTYPE\n"); + + if (event->data) { + xine_streamtype_data_t* data = (xine_streamtype_data_t*)event->data; + + mi = demux_ts_dynamic_pmt_find (this, data->pid, BUF_AUDIO_BASE, data->streamtype); + } + break; } From 7b8b0ae5fc9dd19354936dd6bc34b8abce7a69f8 Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Sat, 28 Jan 2012 21:38:40 +0100 Subject: [PATCH 11/15] Bugfix: window size switching many times a second --- enigma2/lib/gdi/gxlibdc.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/enigma2/lib/gdi/gxlibdc.cpp b/enigma2/lib/gdi/gxlibdc.cpp index 400a518..04eaa77 100644 --- a/enigma2/lib/gdi/gxlibdc.cpp +++ b/enigma2/lib/gdi/gxlibdc.cpp @@ -239,7 +239,8 @@ void gXlibDC::setResolution(int xres, int yres) m_surface.offset = 0; m_pixmap = new gPixmap(&m_surface); - + + XResizeWindow(display, window, windowWidth, windowHeight); updateWindowState(); } @@ -252,6 +253,15 @@ void gXlibDC::updateWindowState() { height = windowHeight; } + XFlush(display); + xineLib->updateWindowSize(width, height); + xineLib->showOsd(); +} + +void gXlibDC::fullscreen_switch() { + printf("FULLSCREEN EVENT\n"); + fullscreen ^= 1; + XEvent xev; Atom wm_state = XInternAtom(display, "_NET_WM_STATE", False); Atom fullscreenAtom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False); @@ -265,18 +275,7 @@ void gXlibDC::updateWindowState() { xev.xclient.data.l[1] = fullscreenAtom; xev.xclient.data.l[2] = 0; XSendEvent(display, XDefaultRootWindow(display), False, SubstructureNotifyMask, &xev); - - if (!fullscreen) - XResizeWindow(display, window, windowWidth, windowHeight); - - XFlush(display); - xineLib->updateWindowSize(width, height); - xineLib->showOsd(); -} - -void gXlibDC::fullscreen_switch() { - printf("FULLSCREEN EVENT\n"); - fullscreen ^= 1; + updateWindowState(); } From a788b18fc087de638f382c6d7ad3681b884c6671 Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Mon, 30 Jan 2012 23:12:00 +0100 Subject: [PATCH 12/15] corrected osd aspect ratio for opengl driver; video is scaled to window (used in some skins) for opengl and xshm driver --- xine-lib/src/video_out/video_out_opengl.c | 146 +++++++++++++++------- xine-lib/src/video_out/video_out_xshm.c | 40 ++++-- 2 files changed, 131 insertions(+), 55 deletions(-) diff --git a/xine-lib/src/video_out/video_out_opengl.c b/xine-lib/src/video_out/video_out_opengl.c index 5de690d..47de3e0 100644 --- a/xine-lib/src/video_out/video_out_opengl.c +++ b/xine-lib/src/video_out/video_out_opengl.c @@ -145,6 +145,7 @@ typedef struct opengl_argb_layer_s { /* dirty area */ int width; int height; + int changed; } opengl_argb_layer_t; typedef struct { @@ -226,6 +227,7 @@ typedef struct { int ovl_changed; int last_ovl_width, last_ovl_height; int tex_ovl_width, tex_ovl_height; /* independend of frame */ + int video_window_width, video_window_height, video_window_x, video_window_y; config_values_t *config; xine_t *xine; @@ -272,10 +274,21 @@ static void render_tex2d (opengl_driver_t *this, opengl_frame_t *frame) { float tx, ty; /* Calc texture/rectangle coords */ - x1 = this->sc.output_xoffset; - y1 = this->sc.output_yoffset; - x2 = x1 + this->sc.output_width; - y2 = y1 + this->sc.output_height; + if (this->video_window_width && this->video_window_height) // video is displayed in a small window + { + x1 = this->video_window_x; + y1 = this->video_window_y; + x2 = x1 + this->video_window_width; + y2 = y1 + this->video_window_height; + } + else + { + x1 = this->sc.output_xoffset; + y1 = this->sc.output_yoffset; + x2 = x1 + this->sc.output_width; + y2 = y1 + this->sc.output_height; + } + tx = (float) frame->width / this->tex_width; ty = (float) frame->height / this->tex_height; /* Draw quad */ @@ -297,9 +310,9 @@ static void render_overlay (opengl_driver_t *this, opengl_frame_t *frame) { if (this->tex_ovl_width == 0 && this->tex_ovl_height == 0) // Image_Pipeline renderer is active (no texture support) { - glPixelZoom (((float)this->sc.output_width) / this->argb_layer.width, - - ((float)this->sc.output_height) / this->argb_layer.height); - glRasterPos2i (this->sc.output_xoffset, this->sc.output_yoffset); + glPixelZoom (((float)this->gui_width) / this->argb_layer.width, + - ((float)this->gui_height) / this->argb_layer.height); + glRasterPos2i (0, 0); glDrawPixels (this->argb_layer.width, this->argb_layer.height, GL_BGRA, GL_UNSIGNED_BYTE, this->argb_layer.buffer); } @@ -313,10 +326,10 @@ static void render_overlay (opengl_driver_t *this, opengl_frame_t *frame) { glDisable(MYGL_FRAGMENT_PROGRAM_ARB); /* Calc texture/rectangle coords */ - x1 = this->sc.output_xoffset; - y1 = this->sc.output_yoffset; - x2 = x1 + this->sc.output_width; - y2 = y1 + this->sc.output_height; + x1 = 0; + y1 = 0; + x2 = this->gui_width; + y2 = this->gui_height; tx = (float) this->argb_layer.width / this->tex_ovl_width; ty = (float) this->argb_layer.height / this->tex_ovl_height; @@ -348,10 +361,20 @@ static void render_tex2dtiled (opengl_driver_t *this, opengl_frame_t *frame) { frame_w = frame->width; frame_h = frame->height; /* Calc texture/rectangle coords */ - x1 = this->sc.output_xoffset; - y1 = this->sc.output_yoffset; - x2 = x1 + this->sc.output_width; - y2 = y1 + this->sc.output_height; + if (this->video_window_width && this->video_window_height) // video is displayed in a small window + { + x1 = this->video_window_x; + y1 = this->video_window_y; + x2 = x1 + this->video_window_width; + y2 = y1 + this->video_window_height; + } + else + { + x1 = this->sc.output_xoffset; + y1 = this->sc.output_yoffset; + x2 = x1 + this->sc.output_width; + y2 = y1 + this->sc.output_height; + } txa = 1.0 / tex_w; tya = 1.0 / tex_h; txb = (float) frame_w / (tex_w-2); /* temporary: total */ @@ -382,11 +405,23 @@ static void render_tex2dtiled (opengl_driver_t *this, opengl_frame_t *frame) { /* Static image pipline based display */ static void render_draw (opengl_driver_t *this, opengl_frame_t *frame) { - glPixelZoom (((float)this->sc.output_width) / frame->width, - - ((float)this->sc.output_height) / frame->height); - glRasterPos2i (this->sc.output_xoffset, this->sc.output_yoffset); - glDrawPixels (frame->width, frame->height, RGB_TEXTURE_FORMAT, - GL_UNSIGNED_BYTE, frame->rgb); + + if (this->video_window_width && this->video_window_height) // video is displayed in a small window + { + glPixelZoom(((float)this->video_window_width) / frame->width, + - ((float)this->video_window_height) / frame->height); + glRasterPos2i(this->video_window_x, this->video_window_y); + glDrawPixels (frame->width, frame->height, RGB_TEXTURE_FORMAT, + GL_UNSIGNED_BYTE, frame->rgb); + } + else + { + glPixelZoom(((float)this->sc.output_width) / frame->width, + - ((float)this->sc.output_height) / frame->height); + glRasterPos2i(this->sc.output_xoffset, this->sc.output_yoffset); + glDrawPixels (frame->width, frame->height, RGB_TEXTURE_FORMAT, + GL_UNSIGNED_BYTE, frame->rgb); + } } /* Animated spinning cylinder */ @@ -1185,20 +1220,27 @@ static void *render_run (opengl_driver_t *this) { CHECKERR ("pre-render"); ret = 1; if (changed) + if (this->argb_layer.changed) // clean window after every overlay change - do it twice because of double buffering + { + glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + if (this->argb_layer.changed == 1) + this->argb_layer.changed++; + else this->argb_layer.changed = 0; + } ret = (render->image) (this, frame); - (render->display) (this, frame); - // display overlay - pthread_mutex_lock (&this->argb_layer.mutex); - if (this->argb_layer.buffer) - { - ret = (render->ovl_image) (this, frame); - (render->ovl_display) (this, frame); - } - pthread_mutex_unlock (&this->argb_layer.mutex); - if (this->render_double_buffer) - glXSwapBuffers(this->display, this->drawable); - else - glFlush (); + (render->display) (this, frame); + // display overlay + pthread_mutex_lock (&this->argb_layer.mutex); + if (this->argb_layer.buffer) + { + ret = (render->ovl_image) (this, frame); + (render->ovl_display) (this, frame); + } + pthread_mutex_unlock (&this->argb_layer.mutex); + if (this->render_double_buffer) + glXSwapBuffers(this->display, this->drawable); + else + glFlush (); /* Note: no glFinish() - work concurrently to the graphics pipe */ CHECKERR ("post-render"); XUnlockDisplay (this->display); @@ -1637,20 +1679,25 @@ static void opengl_overlay_blend (vo_driver_t *this_gen, } else if (overlay && overlay->argb_layer && overlay->argb_layer->buffer && this->ovl_changed) { - // copy argb_buffer because it gets invalid after overlay_end and rendering is after overlay_end - pthread_mutex_lock (&this->argb_layer.mutex); - if (this->argb_layer.buffer) - free(this->argb_layer.buffer); - this->argb_layer.buffer = calloc(overlay->extent_width * overlay->extent_height, sizeof(uint32_t)); - if (this->argb_layer.buffer == NULL) - { - printf("Fatal error(opengl_overlay_blend): No memory\n"); - return; - } - this->argb_layer.width = overlay->extent_width; - this->argb_layer.height = overlay->extent_height; - xine_fast_memcpy(this->argb_layer.buffer, overlay->argb_layer->buffer, overlay->extent_width * overlay->extent_height * sizeof(uint32_t)); - pthread_mutex_unlock (&this->argb_layer.mutex); + // copy argb_buffer because it gets invalid after overlay_end and rendering is after overlay_end + pthread_mutex_lock (&this->argb_layer.mutex); + if (this->argb_layer.buffer) + free(this->argb_layer.buffer); + this->argb_layer.buffer = calloc(overlay->extent_width * overlay->extent_height, sizeof(uint32_t)); + if (this->argb_layer.buffer == NULL) + { + printf("Fatal error(opengl_overlay_blend): No memory\n"); + return; + } + this->argb_layer.width = overlay->extent_width; + this->argb_layer.height = overlay->extent_height; + this->argb_layer.changed= 1; + xine_fast_memcpy(this->argb_layer.buffer, overlay->argb_layer->buffer, overlay->extent_width * overlay->extent_height * sizeof(uint32_t)); + pthread_mutex_unlock (&this->argb_layer.mutex); + this->video_window_width = overlay->video_window_width; + this->video_window_height = overlay->video_window_height; + this->video_window_x = overlay->video_window_x; + this->video_window_y = overlay->video_window_y; } } @@ -2008,8 +2055,13 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v this->argb_layer.buffer = NULL; this->argb_layer.width = 0; this->argb_layer.height = 0; + this->argb_layer.changed = 0; this->ovl_changed = 0; this->last_ovl_width = this->last_ovl_height = -1; + this->video_window_width = 0; + this->video_window_height = 0; + this->video_window_x = 0; + this->video_window_y = 0; this->xine = class->xine; this->config = config; diff --git a/xine-lib/src/video_out/video_out_xshm.c b/xine-lib/src/video_out/video_out_xshm.c index b0579cf..557731f 100644 --- a/xine-lib/src/video_out/video_out_xshm.c +++ b/xine-lib/src/video_out/video_out_xshm.c @@ -116,6 +116,7 @@ typedef struct { xshm_frame_t *cur_frame; x11osd *xoverlay; int ovl_changed; + int video_window_width, video_window_height, video_window_x, video_window_y; int (*x11_old_error_handler) (Display *, XErrorEvent *); @@ -505,13 +506,28 @@ static void xshm_update_frame_format (vo_driver_t *this_gen, if ((frame->sc.gui_width != gui_width) || (frame->sc.gui_height != gui_height) || + (this->video_window_width && this->video_window_height) || do_adapt) { do_adapt = 1; - frame->sc.gui_width = gui_width; - frame->sc.gui_height = gui_height; + if (this->video_window_width && this->video_window_height) + { + frame->sc.gui_width = this->video_window_width; + frame->sc.gui_height = this->video_window_height; + } + else + { + frame->sc.gui_width = gui_width; + frame->sc.gui_height = gui_height; + } xshm_compute_rgb_size (this, frame); + + if (this->video_window_width && this->video_window_height) + { + frame->sc.output_xoffset+= this->video_window_x; + frame->sc.output_yoffset+= this->video_window_y; + } lprintf ("gui_size has changed => adapt\n"); } @@ -691,11 +707,15 @@ static void xshm_overlay_blend (vo_driver_t *this_gen, } else if (overlay && overlay->argb_layer && overlay->argb_layer->buffer && this->ovl_changed) { - pthread_mutex_lock (&overlay->argb_layer->mutex); - LOCK_DISPLAY(this); - x11osd_blend(this->xoverlay, overlay); - UNLOCK_DISPLAY(this); - pthread_mutex_unlock (&overlay->argb_layer->mutex); + pthread_mutex_lock (&overlay->argb_layer->mutex); + LOCK_DISPLAY(this); + x11osd_blend(this->xoverlay, overlay); + UNLOCK_DISPLAY(this); + pthread_mutex_unlock (&overlay->argb_layer->mutex); + this->video_window_width = overlay->video_window_width; + this->video_window_height = overlay->video_window_height; + this->video_window_x = overlay->video_window_x; + this->video_window_y = overlay->video_window_y; } } @@ -710,7 +730,7 @@ static void clean_output_area (xshm_driver_t *this, xshm_frame_t *frame) { for( i = 0; i < 4; i++ ) { if( this->sc.border[i].w && this->sc.border[i].h ) XFillRectangle(this->display, this->drawable, this->gc, - this->sc.border[i].x, this->sc.border[i].y, + this->sc.border[i].x + this->video_window_x, this->sc.border[i].y + this->video_window_y, this->sc.border[i].w, this->sc.border[i].h); } if (this->xoverlay) { @@ -1115,6 +1135,10 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v UNLOCK_DISPLAY(this); this->xoverlay = NULL; this->ovl_changed = 0; + this->video_window_width = 0; + this->video_window_height = 0; + this->video_window_x = 0; + this->video_window_y = 0; this->x11_old_error_handler = NULL; this->xine = class->xine; From 15f8b47f53c5a01e33dc9b3801585ad24d105829 Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Sat, 4 Feb 2012 19:52:10 +0100 Subject: [PATCH 13/15] removed fix path to /usr/local/e2 --- enigma2/lib/driver/misc_options.cpp | 11 ++-- enigma2/lib/dvb/decoder.cpp | 5 +- enigma2/lib/dvb/dvb.cpp | 6 +- enigma2/lib/dvb/dvbtime.cpp | 15 +++-- enigma2/lib/dvb/frontend.cpp | 7 ++- enigma2/lib/dvb_ci/dvbci.cpp | 15 ++--- enigma2/lib/gdi/lcd.cpp | 19 +++--- enigma2/lib/python/Components/AVSwitch.py | 20 +++---- enigma2/lib/python/Components/NimManager.py | 14 ++--- enigma2/lib/python/Components/Timezones.py | 8 +-- .../VideoEnhancement/VideoEnhancement.py | 59 ++++++++++--------- .../SystemPlugins/Videomode/VideoHardware.py | 4 +- enigma2/lib/python/Screens/Ci.py | 4 +- enigma2/lib/python/Tools/DreamboxHardware.py | 13 ++-- enigma2/lib/python/Tools/HardwareInfo.py | 4 +- 15 files changed, 113 insertions(+), 91 deletions(-) diff --git a/enigma2/lib/driver/misc_options.cpp b/enigma2/lib/driver/misc_options.cpp index acbe6b9..ebd8409 100644 --- a/enigma2/lib/driver/misc_options.cpp +++ b/enigma2/lib/driver/misc_options.cpp @@ -8,6 +8,7 @@ #include #include #include +#include Misc_Options *Misc_Options::instance = 0; @@ -22,10 +23,11 @@ int Misc_Options::set_12V_output(int state) { if (state == m_12V_output_state) return 0; - int fd = open("/usr/local/e2/etc/stb/misc/12V_output", O_WRONLY); + int fd = open(eEnv::resolve("${sysconfdir}/stb/misc/12V_output").c_str(), O_WRONLY); if (fd < 0) { - eDebug("couldn't open /usr/local/e2/etc/stb/misc/12V_output"); + std::string err= "couldn't open " + eEnv::resolve("${sysconfdir}/stb/misc/12V_output"); + eDebug(err.c_str()); return -1; } const char *str=0; @@ -42,10 +44,11 @@ int Misc_Options::set_12V_output(int state) bool Misc_Options::detected_12V_output() { - int fd = open("/usr/local/e2/etc/stb/misc/12V_output", O_WRONLY); + int fd = open(eEnv::resolve("${sysconfdir}/stb/misc/12V_output").c_str(), O_WRONLY); if (fd < 0) { - eDebug("couldn't open /usr/local/e2/etc/stb/misc/12V_output"); + std::string err= "couldn't open " + eEnv::resolve("${sysconfdir}/stb/misc/12V_output"); + eDebug(err.c_str()); return false; } close(fd); diff --git a/enigma2/lib/dvb/decoder.cpp b/enigma2/lib/dvb/decoder.cpp index 2354ece..e5adce3 100644 --- a/enigma2/lib/dvb/decoder.cpp +++ b/enigma2/lib/dvb/decoder.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -423,7 +424,7 @@ RESULT eTSMPEGDecoder::setHwPCMDelay(int delay) { if (delay != m_pcm_delay ) { - FILE *fp = fopen("/usr/local/e2/etc/stb/audio/audio_delay_pcm", "w"); + FILE *fp = fopen(eEnv::resolve("${sysconfdir}/stb/audio/audio_delay_pcm").c_str(), "w"); if (fp) { fprintf(fp, "%x", delay*90); @@ -439,7 +440,7 @@ RESULT eTSMPEGDecoder::setHwAC3Delay(int delay) { if ( delay != m_ac3_delay ) { - FILE *fp = fopen("/usr/local/e2/etc/stb/audio/audio_delay_bitstream", "w"); + FILE *fp = fopen(eEnv::resolve("${sysconfdir}/stb/audio/audio_delay_bitstream").c_str(), "w"); if (fp) { fprintf(fp, "%x", delay*90); diff --git a/enigma2/lib/dvb/dvb.cpp b/enigma2/lib/dvb/dvb.cpp index b97e244..82d7434 100644 --- a/enigma2/lib/dvb/dvb.cpp +++ b/enigma2/lib/dvb/dvb.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -82,7 +83,7 @@ eDVBResourceManager::eDVBResourceManager() num_adapter++; } - int fd = open("/usr/local/e2/etc/stb/info/model", O_RDONLY); + int fd = open(eEnv::resolve("${sysconfdir}/stb/info/model").c_str(), O_RDONLY); char tmp[16]; int rd = fd >= 0 ? read(fd, tmp, sizeof(tmp)) : 0; if (fd >= 0) @@ -101,7 +102,8 @@ eDVBResourceManager::eDVBResourceManager() else if (!strncmp(tmp, "dm7020hd\n", rd)) m_boxtype = DM7020HD; else { - eDebug("boxtype detection via /usr/local/e2/etc/stb/info not possible... use fallback via demux count!\n"); + std::string info= "boxtype detection via " + eEnv::resolve("${sysconfdir}/stb/info") + " not possible... use fallback via demux count!\n"; + eDebug(info.c_str()); if (m_demux.size() == 3) m_boxtype = DM800; else if (m_demux.size() < 5) diff --git a/enigma2/lib/dvb/dvbtime.cpp b/enigma2/lib/dvb/dvbtime.cpp index dfe8cb7..29e2656 100644 --- a/enigma2/lib/dvb/dvbtime.cpp +++ b/enigma2/lib/dvb/dvbtime.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -17,13 +18,16 @@ static time_t prev_time; void setRTC(time_t time) { - FILE *f = fopen("/usr/local/e2/etc/stb/fp/rtc", "w"); + FILE *f = fopen(eEnv::resolve("${sysconfdir}/stb/fp/rtc").c_str(), "w"); if (f) { if (fprintf(f, "%u", (unsigned int)time)) prev_time = time; else - eDebug("write /usr/local/e2/etc/stb/fp/rtc failed (%m)"); + { + std::string err= "write " + eEnv::resolve("${sysconfdir}/stb/fp/rtc") + "failed (%m)"; + eDebug(err.c_str()); + } fclose(f); } else @@ -43,13 +47,16 @@ void setRTC(time_t time) time_t getRTC() { time_t rtc_time=0; - FILE *f = fopen("/usr/local/e2/etc/stb/fp/rtc", "r"); + FILE *f = fopen(eEnv::resolve("${sysconfdir}/stb/fp/rtc").c_str(), "r"); if (f) { // sanity check to detect corrupt atmel firmware unsigned int tmp; if (fscanf(f, "%u", &tmp) != 1) - eDebug("read /usr/local/e2/etc/stb/fp/rtc failed (%m)"); + { + std::string err= "read " + eEnv::resolve("${sysconfdir}/stb/fp/rtc") + " failed (%m)"; + eDebug(err.c_str()); + } else rtc_time=tmp; fclose(f); diff --git a/enigma2/lib/dvb/frontend.cpp b/enigma2/lib/dvb/frontend.cpp index 204f445..ce92789 100644 --- a/enigma2/lib/dvb/frontend.cpp +++ b/enigma2/lib/dvb/frontend.cpp @@ -2,6 +2,7 @@ #include #include #include // access to python config +#include #include #include #include @@ -1485,8 +1486,8 @@ int eDVBFrontend::readInputpower() int power=m_slotid; // this is needed for read inputpower from the correct tuner ! char proc_name[64]; char proc_name2[64]; - sprintf(proc_name, "/usr/local/e2/etc/stb/frontend/%d/lnb_sense", m_slotid); - sprintf(proc_name2, "/usr/local/e2/etc/stb/fp/lnb_sense%d", m_slotid); + sprintf(proc_name, eEnv::resolve("${sysconfdir}/stb/frontend/%d/lnb_sense").c_str(), m_slotid); + sprintf(proc_name2, eEnv::resolve("${sysconfdir}/stb/fp/lnb_sense%d").c_str(), m_slotid); FILE *f; if ((f=fopen(proc_name, "r")) || (f=fopen(proc_name2, "r"))) { @@ -1855,7 +1856,7 @@ int eDVBFrontend::tuneLoopInt() // called by m_tuneTimer if (!m_simulate) { char proc_name[64]; - sprintf(proc_name, "/usr/local/e2/etc/stb/frontend/%d/static_current_limiting", sec_fe->m_dvbid); + sprintf(proc_name, eEnv::resolve("${sysconfdir}/stb/frontend/%d/static_current_limiting").c_str(), sec_fe->m_dvbid); FILE *f=fopen(proc_name, "w"); if (f) // new interface exist? { diff --git a/enigma2/lib/dvb_ci/dvbci.cpp b/enigma2/lib/dvb_ci/dvbci.cpp index f6c61ff..71d4b29 100644 --- a/enigma2/lib/dvb_ci/dvbci.cpp +++ b/enigma2/lib/dvb_ci/dvbci.cpp @@ -4,7 +4,7 @@ #include #include #include - +#include #include #include // access to python config #include @@ -653,7 +653,7 @@ int eDVBCIInterfaces::setInputSource(int tuner_no, data_source source) if (getNumOfSlots() > 1) // FIXME .. we force DM8000 when more than one CI Slot is avail { char buf[64]; - snprintf(buf, 64, "/usr/local/e2/etc/stb/tsmux/input%d", tuner_no); + snprintf(buf, 64, eEnv::resolve("${sysconfdir}/stb/tsmux/input%d").c_str(), tuner_no); FILE *input=0; if((input = fopen(buf, "wb")) == NULL) { @@ -700,7 +700,7 @@ int eDVBCIInterfaces::setInputSource(int tuner_no, data_source source) else // DM7025 { char buf[64]; - snprintf(buf, 64, "/usr/local/e2/etc/stb/tsmux/input%d", tuner_no); + snprintf(buf, 64, eEnv::resolve("${sysconfdir}/stb/tsmux/input%d").c_str(), tuner_no); if (tuner_no > 1) eDebug("setInputSource(%d, %d) failed... dm7025 just have two inputs", tuner_no, (int)source); @@ -1277,7 +1277,7 @@ int eDVBCISlot::setSource(data_source source) if (eDVBCIInterfaces::getInstance()->getNumOfSlots() > 1) // FIXME .. we force DM8000 when more than one CI Slot is avail { char buf[64]; - snprintf(buf, 64, "/usr/local/e2/etc/stb/tsmux/ci%d_input", slotid); + snprintf(buf, 64, eEnv::resolve("${sysconfdir}/stb/tsmux/ci%d_input").c_str(), slotid); FILE *ci = fopen(buf, "wb"); switch(source) { @@ -1315,9 +1315,10 @@ int eDVBCISlot::setSource(data_source source) { // eDebug("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); // eDebug("eDVBCISlot::enableTS(%d %d)", enable, (int)source); - FILE *ci = fopen("/usr/local/e2/etc/stb/tsmux/input2", "wb"); + FILE *ci = fopen(eEnv::resolve("${sysconfdir}/stb/tsmux/input2").c_str(), "wb"); if(ci == NULL) { - eDebug("cannot open /usr/local/e2/etc/stb/tsmux/input2"); + std::string err= "cannot open " + eEnv::resolve("${sysconfdir}/stb/tsmux/input2"); + eDebug(err.c_str()); return 0; } if (source != TUNER_A && source != TUNER_B) @@ -1333,7 +1334,7 @@ int eDVBCISlot::setSource(data_source source) int eDVBCISlot::setClockRate(int rate) { char buf[64]; - snprintf(buf, 64, "/usr/local/e2/etc/stb/tsmux/ci%d_tsclk", slotid); + snprintf(buf, 64, eEnv::resolve("${sysconfdir}/stb/tsmux/ci%d_tsclk").c_str(), slotid); FILE *ci = fopen(buf, "wb"); if (ci) { diff --git a/enigma2/lib/gdi/lcd.cpp b/enigma2/lib/gdi/lcd.cpp index e07498e..c690a6b 100644 --- a/enigma2/lib/gdi/lcd.cpp +++ b/enigma2/lib/gdi/lcd.cpp @@ -75,8 +75,8 @@ eDBoxLCD::eDBoxLCD() lcdfd = open("/dev/dbox/oled0", O_RDWR); if (lcdfd < 0) { - if (!access("/usr/local/e2/etc/stb/lcd/oled_brightness", W_OK) || - !access("/usr/local/e2/etc/stb/fp/oled_brightness", W_OK) ) + if (!access(eEnv::resolve("${sysconfdir}/stb/lcd/oled_brightness").c_str(), W_OK) || + !access(eEnv::resolve("${sysconfdir}/stb/fp/oled_brightness").c_str(), W_OK) ) is_oled = 2; lcdfd = open("/dev/dbox/lcd0", O_RDWR); } else @@ -92,20 +92,20 @@ eDBoxLCD::eDBoxLCD() int i=LCD_MODE_BIN; ioctl(lcdfd, LCD_IOCTL_ASC_MODE, &i); inverted=0; - FILE *f = fopen("/usr/local/e2/etc/stb/lcd/xres", "r"); + FILE *f = fopen(eEnv::resolve("${sysconfdir}/stb/lcd/xres").c_str(), "r"); if (f) { int tmp; if (fscanf(f, "%x", &tmp) == 1) xres = tmp; fclose(f); - f = fopen("/usr/local/e2/etc/stb/lcd/yres", "r"); + f = fopen(eEnv::resolve("${sysconfdir}/stb/lcd/yres").c_str(), "r"); if (f) { if (fscanf(f, "%x", &tmp) == 1) yres = tmp; fclose(f); - f = fopen("/usr/local/e2/etc/stb/lcd/bpp", "r"); + f = fopen(eEnv::resolve("${sysconfdir}/stb/lcd/bpp").c_str(), "r"); if (f) { if (fscanf(f, "%x", &tmp) == 1) @@ -151,13 +151,16 @@ int eDBoxLCD::setLCDBrightness(int brightness) { #ifndef NO_LCD eDebug("setLCDBrightness %d", brightness); - FILE *f=fopen("/usr/local/e2/etc/stb/lcd/oled_brightness", "w"); + FILE *f=fopen(eEnv::resolve("${sysconfdir}/stb/lcd/oled_brightness").c_str(), "w"); if (!f) - f = fopen("/usr/local/e2/etc/stb/fp/oled_brightness", "w"); + f = fopen(eEnv::resolve("${sysconfdir}/stb/fp/oled_brightness").c_str(), "w"); if (f) { if (fprintf(f, "%d", brightness) == 0) - eDebug("write /usr/local/e2/etc/stb/lcd/oled_brightness failed!! (%m)"); + { + std::string err= "write " + eEnv::resolve("${sysconfdir}/stb/lcd/oled_brightness") + " failed!! (%m)"; + eDebug(err.c_str()); + } fclose(f); } else diff --git a/enigma2/lib/python/Components/AVSwitch.py b/enigma2/lib/python/Components/AVSwitch.py index 9c06865..65c2936 100644 --- a/enigma2/lib/python/Components/AVSwitch.py +++ b/enigma2/lib/python/Components/AVSwitch.py @@ -1,6 +1,6 @@ from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, \ ConfigEnableDisable, ConfigSubsection, ConfigBoolean, ConfigSelectionNumber, ConfigNothing, NoSave -from enigma import eAVSwitch, getDesktop +from enigma import eAVSwitch, getDesktop, eEnv from SystemInfo import SystemInfo import os @@ -24,7 +24,7 @@ def getOutputAspect(self): return (4,3) elif valstr == "16_9": # auto ... 4:3 or 16:9 try: - aspect_str = open("/usr/local/e2/etc/stb/vmpeg/0/aspect", "r").read() + aspect_str = open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/aspect"), "r").read() if aspect_str == "1": # 4:3 return (4,3) except IOError: @@ -146,14 +146,14 @@ def setWSS(configElement): SystemInfo["ScartSwitch"] = eAVSwitch.getInstance().haveScartSwitch() try: - can_downmix = open("/usr/local/e2/etc/stb/audio/ac3_choices", "r").read()[:-1].find("downmix") != -1 + can_downmix = open(eEnv.resolve("${sysconfdir}/stb/audio/ac3_choices"), "r").read()[:-1].find("downmix") != -1 except: can_downmix = False SystemInfo["CanDownmixAC3"] = can_downmix if can_downmix: def setAC3Downmix(configElement): - open("/usr/local/e2/etc/stb/audio/ac3", "w").write(configElement.value and "downmix" or "passthrough") + open(eEnv.resolve("${sysconfdir}/stb/audio/ac3"), "w").write(configElement.value and "downmix" or "passthrough") config.av.downmix_ac3 = ConfigYesNo(default = True) config.av.downmix_ac3.addNotifier(setAC3Downmix) @@ -161,7 +161,7 @@ def setAC3Downmix(configElement): SystemInfo["CanDownmixDTS"] = can_downmix if can_downmix: def setDTSDownmix(configElement): - open("/usr/local/e2/etc/stb/dts_mode", "w").write(configElement.value and "downmix" or "passthrough") + open(eEnv.resolve("${sysconfdir}/stb/dts_mode"), "w").write(configElement.value and "downmix" or "passthrough") try: os.unlink('/home/root/.gstreamer-0.10/registry.mipsel.bin') except: @@ -170,26 +170,26 @@ def setDTSDownmix(configElement): config.av.downmix_dts.addNotifier(setDTSDownmix) try: - can_osd_alpha = open("/usr/local/e2/etc/stb/video/alpha", "r") and True or False + can_osd_alpha = open(eEnv.resolve("${sysconfdir}/stb/video/alpha"), "r") and True or False except: can_osd_alpha = False SystemInfo["CanChangeOsdAlpha"] = can_osd_alpha def setAlpha(config): - open("/usr/local/e2/etc/stb/video/alpha", "w").write(str(config.value)) + open(eEnv.resolve("${sysconfdir}/stb/video/alpha"), "w").write(str(config.value)) if can_osd_alpha: config.av.osd_alpha = ConfigSlider(default=255, limits=(0,255)) config.av.osd_alpha.addNotifier(setAlpha) - if os.path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_scaler_sharpness"): + if os.path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_scaler_sharpness")): def setScaler_sharpness(config): myval = int(config.value) try: print "--> setting scaler_sharpness to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_scaler_sharpness", "w").write("%0.8X" % myval) - open("/usr/local/e2/etc/stb/vmpeg/0/pep_apply", "w").write("1") + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_scaler_sharpness"), "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_apply"), "w").write("1") except IOError: print "couldn't write pep_scaler_sharpness" diff --git a/enigma2/lib/python/Components/NimManager.py b/enigma2/lib/python/Components/NimManager.py index 6c7e585..7fb5815 100644 --- a/enigma2/lib/python/Components/NimManager.py +++ b/enigma2/lib/python/Components/NimManager.py @@ -538,12 +538,12 @@ def internallyConnectableTo(self): def setInternalLink(self): if self.internally_connectable is not None: print "setting internal link on frontend id", self.frontend_id - open("/usr/local/e2/etc/stb/frontend/%d/rf_switch" % self.frontend_id, "w").write("internal") + open(eEnv.resolve("${sysconfdir}/stb/frontend/%d/rf_switch") % self.frontend_id, "w").write("internal") def removeInternalLink(self): if self.internally_connectable is not None: print "removing internal link on frontend id", self.frontend_id - open("/usr/local/e2/etc/stb/frontend/%d/rf_switch" % self.frontend_id, "w").write("external") + open(eEnv.resolve("${sysconfdir}/stb/frontend/%d/rf_switch") % self.frontend_id, "w").write("external") def isMultiType(self): return (len(self.multi_type) > 0) @@ -682,7 +682,7 @@ def enumerateNIMs(self): self.nim_slots = [ ] try: - nimfile = open("/usr/local/e2/etc/tuxbox/nim_sockets") + nimfile = open(eEnv.resolve("${sysconfdir}/tuxbox/nim_sockets")) except IOError: return @@ -740,7 +740,7 @@ def enumerateNIMs(self): if not (entry.has_key("has_outputs")): entry["has_outputs"] = True if entry.has_key("frontend_device"): # check if internally connectable - if path.exists("/usr/local/e2/etc/stb/frontend/%d/rf_switch" % entry["frontend_device"]): + if path.exists(eEnv.resolve("${sysconfdir}/stb/frontend/%d/rf_switch") % entry["frontend_device"]): entry["internally_connectable"] = entry["frontend_device"] - 1 else: entry["internally_connectable"] = None @@ -1353,12 +1353,12 @@ def toneAmplitudeChanged(configElement): fe_id = configElement.fe_id slot_id = configElement.slot_id if nimmgr.nim_slots[slot_id].description == 'Alps BSBE2': - open("/usr/local/e2/etc/stb/frontend/%d/tone_amplitude" %(fe_id), "w").write(configElement.value) + open(eEnv.resolve("${sysconfdir}/stb/frontend/%d/tone_amplitude") %(fe_id), "w").write(configElement.value) def tunerTypeChanged(nimmgr, configElement): fe_id = configElement.fe_id - cur_type = int(open("/usr/local/e2/etc/stb/frontend/%d/mode" % (fe_id), "r").read()) + cur_type = int(open(eEnv.resolve("${sysconfdir}/stb/frontend/%d/mode") % (fe_id), "r").read()) if cur_type != int(configElement.value): print "tunerTypeChanged feid %d from %d to mode %d" % (fe_id, cur_type, int(configElement.value)) @@ -1370,7 +1370,7 @@ def tunerTypeChanged(nimmgr, configElement): frontend = eDVBResourceManager.getInstance().allocateRawChannel(fe_id).getFrontend() frontend.closeFrontend() - open("/usr/local/e2/etc/stb/frontend/%d/mode" % (fe_id), "w").write(configElement.value) + open(eEnv.resolve("${sysconfdir}/stb/frontend/%d/mode") % (fe_id), "w").write(configElement.value) frontend.reopenFrontend() try: open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write(oldvalue) diff --git a/enigma2/lib/python/Components/Timezones.py b/enigma2/lib/python/Components/Timezones.py index 08b4151..fd8a14a 100644 --- a/enigma2/lib/python/Components/Timezones.py +++ b/enigma2/lib/python/Components/Timezones.py @@ -1,6 +1,6 @@ from xml.sax import make_parser from xml.sax.handler import ContentHandler - +from enigma import eEnv from os import environ, unlink, symlink import time @@ -25,7 +25,7 @@ def readTimezonesFromFile(self): try: timezonesHandler = self.parseTimezones(self.timezones) parser.setContentHandler(timezonesHandler) - parser.parse('/usr/local/e2/etc/tuxbox/timezone.xml') + parser.parse(eEnv.resolve("${sysconfdir}/tuxbox/timezone.xml")) except: pass @@ -38,11 +38,11 @@ def activateTimezone(self, index): environ['TZ'] = self.timezones[index][1] try: - unlink("/usr/local/e2/etc/localtime") + unlink(eEnv.resolve("${sysconfdir}/localtime")) except OSError: pass try: - symlink("/usr/local/e2/share/zoneinfo/%s" %(self.timezones[index][1]), "/usr/local/e2/etc/localtime") + symlink(eEnv.resolve("${datarootdir}/zoneinfo/%s") %(self.timezones[index][1]), eEnv.resolve("${sysconfdir}/localtime")) except OSError: pass try: diff --git a/enigma2/lib/python/Plugins/SystemPlugins/VideoEnhancement/VideoEnhancement.py b/enigma2/lib/python/Plugins/SystemPlugins/VideoEnhancement/VideoEnhancement.py index 251d76d..f5424f3 100755 --- a/enigma2/lib/python/Plugins/SystemPlugins/VideoEnhancement/VideoEnhancement.py +++ b/enigma2/lib/python/Plugins/SystemPlugins/VideoEnhancement/VideoEnhancement.py @@ -1,6 +1,7 @@ from Components.config import config, ConfigSubsection, ConfigSlider, ConfigSelection, ConfigNothing, NoSave from Tools.CList import CList from os import path as os_path +from enigma import eEnv # The "VideoEnhancement" is the interface to /usr/local/e2/etc/stb/vmpeg/0. class VideoEnhancement: @@ -14,12 +15,12 @@ def createConfig(self, *args): config.pep = ConfigSubsection() config.pep.configsteps = NoSave(ConfigSelection(choices=[1, 5, 10, 25], default = 1)) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_contrast"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_contrast")): def setContrast(config): myval = int(config.value*256) try: print "--> setting contrast to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_contrast", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_contrast"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_contrast." @@ -31,12 +32,12 @@ def setContrast(config): else: config.pep.contrast = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_saturation"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_saturation")): def setSaturation(config): myval = int(config.value*256) try: print "--> setting saturation to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_saturation", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_saturation"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_saturaion." @@ -48,12 +49,12 @@ def setSaturation(config): else: config.pep.saturation = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_hue"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_hue")): def setHue(config): myval = int(config.value*256) try: print "--> setting hue to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_hue", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_hue"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_hue." @@ -65,12 +66,12 @@ def setHue(config): else: config.pep.hue = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_brightness"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_brightness")): def setBrightness(config): myval = int(config.value*256) try: print "--> setting brightness to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_brightness", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_brightness"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_brightness." @@ -82,12 +83,12 @@ def setBrightness(config): else: config.pep.brightness = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_block_noise_reduction"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_block_noise_reduction")): def setBlock_noise_reduction(config): myval = int(config.value) try: print "--> setting block_noise_reduction to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_block_noise_reduction", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_block_noise_reduction"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_block_noise_reduction." @@ -99,12 +100,12 @@ def setBlock_noise_reduction(config): else: config.pep.block_noise_reduction = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_mosquito_noise_reduction"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_mosquito_noise_reduction")): def setMosquito_noise_reduction(config): myval = int(config.value) try: print "--> setting mosquito_noise_reduction to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_mosquito_noise_reduction", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_mosquito_noise_reduction"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_mosquito_noise_reduction." @@ -116,12 +117,12 @@ def setMosquito_noise_reduction(config): else: config.pep.mosquito_noise_reduction = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_digital_contour_removal"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_digital_contour_removal")): def setDigital_contour_removal(config): myval = int(config.value) try: print "--> setting digital_contour_removal to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_digital_contour_removal", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_digital_contour_removal"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_digital_contour_removal." @@ -133,11 +134,11 @@ def setDigital_contour_removal(config): else: config.pep.digital_contour_removal = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_split"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_split")): def setSplitMode(config): try: print "--> setting splitmode to:",str(config.value) - open("/usr/local/e2/etc/stb/vmpeg/0/pep_split", "w").write(str(config.value)) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_split"), "w").write(str(config.value)) except IOError: print "couldn't write pep_split." @@ -153,12 +154,12 @@ def setSplitMode(config): else: config.pep.split = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_sharpness"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_sharpness")): def setSharpness(config): myval = int(config.value*256) try: print "--> setting sharpness to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_sharpness", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_sharpness"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_sharpness." @@ -170,12 +171,12 @@ def setSharpness(config): else: config.pep.sharpness = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_auto_flesh"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_auto_flesh")): def setAutoflesh(config): myval = int(config.value) try: print "--> setting auto_flesh to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_auto_flesh", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_auto_flesh"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_auto_flesh." @@ -187,12 +188,12 @@ def setAutoflesh(config): else: config.pep.auto_flesh = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_green_boost"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_green_boost")): def setGreenboost(config): myval = int(config.value) try: print "--> setting green_boost to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_green_boost", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_green_boost"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_green_boost." @@ -204,12 +205,12 @@ def setGreenboost(config): else: config.pep.green_boost = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_blue_boost"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_blue_boost")): def setBlueboost(config): myval = int(config.value) try: print "--> setting blue_boost to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_blue_boost", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_blue_boost"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_blue_boost." @@ -221,12 +222,12 @@ def setBlueboost(config): else: config.pep.blue_boost = NoSave(ConfigNothing()) - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_dynamic_contrast"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_dynamic_contrast")): def setDynamic_contrast(config): myval = int(config.value) try: print "--> setting dynamic_contrast to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_dynamic_contrast", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_dynamic_contrast"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_dynamic_contrast." @@ -241,12 +242,12 @@ def setDynamic_contrast(config): try: x = config.av.scaler_sharpness.value except KeyError: - if os_path.exists("/usr/local/e2/etc/stb/vmpeg/0/pep_scaler_sharpness"): + if os_path.exists(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_scaler_sharpness")): def setScaler_sharpness(config): myval = int(config.value) try: print "--> setting scaler_sharpness to: %0.8X" % myval - open("/usr/local/e2/etc/stb/vmpeg/0/pep_scaler_sharpness", "w").write("%0.8X" % myval) + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_scaler_sharpness"), "w").write("%0.8X" % myval) except IOError: print "couldn't write pep_scaler_sharpness." @@ -266,7 +267,7 @@ def setScaler_sharpness(config): def setConfiguredValues(self): try: print "--> applying pep values" - open("/usr/local/e2/etc/stb/vmpeg/0/pep_apply", "w").write("1") + open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/pep_apply"), "w").write("1") except IOError: print "couldn't apply pep values." diff --git a/enigma2/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py b/enigma2/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py index 4f9a36b..b5c7ec6 100644 --- a/enigma2/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py +++ b/enigma2/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py @@ -1,4 +1,4 @@ -from enigma import eTimer, eAVSwitch +from enigma import eTimer, eAVSwitch, eEnv from Components.config import config, ConfigSelection, ConfigSubDict, ConfigYesNo from Tools.CList import CList @@ -34,7 +34,7 @@ def getOutputAspect(self): ret = (16,10) elif is_auto: try: - aspect_str = open("/usr/local/e2/stb/vmpeg/0/aspect", "r").read() + aspect_str = open(eEnv.resolve("${sysconfdir}/stb/vmpeg/0/aspect"), "r").read() if aspect_str == "1": # 4:3 ret = (4,3) except IOError: diff --git a/enigma2/lib/python/Screens/Ci.py b/enigma2/lib/python/Screens/Ci.py index 119a514..5ea96b8 100644 --- a/enigma2/lib/python/Screens/Ci.py +++ b/enigma2/lib/python/Screens/Ci.py @@ -8,7 +8,7 @@ from Components.SystemInfo import SystemInfo -from enigma import eTimer, eDVBCI_UI, eDVBCIInterfaces +from enigma import eTimer, eDVBCI_UI, eDVBCIInterfaces, eEnv MAX_NUM_CI = 4 @@ -242,7 +242,7 @@ def __init__(self): eDVBCI_UI.getInstance().ciStateChanged.get().append(self.ciStateChanged) SystemInfo["CommonInterface"] = eDVBCIInterfaces.getInstance().getNumOfSlots() > 0 try: - file = open("/usr/local/e2/etc/stb/tsmux/ci0_tsclk", "r") + file = open(eEnv.resolve("${sysconfdir}/stb/tsmux/ci0_tsclk"), "r") file.close() SystemInfo["CommonInterfaceSupportsHighBitrates"] = True except: diff --git a/enigma2/lib/python/Tools/DreamboxHardware.py b/enigma2/lib/python/Tools/DreamboxHardware.py index 99e6f96..5b35178 100644 --- a/enigma2/lib/python/Tools/DreamboxHardware.py +++ b/enigma2/lib/python/Tools/DreamboxHardware.py @@ -1,10 +1,11 @@ from fcntl import ioctl from struct import pack, unpack +from enigma import eEnv def getFPVersion(): ret = None try: - ret = long(open("/usr/local/e2/etc/stb/fp/version", "r").read()) + ret = long(open(eEnv.resolve("${sysconfdir}/stb/fp/version"), "r").read()) except IOError: try: fp = open("/dev/dbox/fp0") @@ -15,7 +16,7 @@ def getFPVersion(): def setFPWakeuptime(wutime): try: - open("/usr/local/e2/etc/stb/fp/wakeup_time", "w").write(str(wutime)) + open(eEnv.resolve("${sysconfdir}/stb/fp/wakeup_time"), "w").write(str(wutime)) except IOError: try: fp = open("/dev/dbox/fp0") @@ -25,7 +26,7 @@ def setFPWakeuptime(wutime): def setRTCtime(wutime): try: - open("/usr/local/e2/etc/stb/fp/rtc", "w").write(str(wutime)) + open(eEnv.resolve("${sysconfdir}/stb/fp/rtc"), "w").write(str(wutime)) except IOError: try: fp = open("/dev/dbox/fp0") @@ -36,7 +37,7 @@ def setRTCtime(wutime): def getFPWakeuptime(): ret = 0 try: - ret = long(open("/usr/local/e2/etc/stb/fp/wakeup_time", "r").read()) + ret = long(open(eEnv.resolve("${sysconfdir}/stb/fp/wakeup_time"), "r").read()) except IOError: try: fp = open("/dev/dbox/fp0") @@ -53,7 +54,7 @@ def getFPWasTimerWakeup(): return wasTimerWakeup wasTimerWakeup = False try: - wasTimerWakeup = int(open("/usr/local/e2/etc/stb/fp/was_timer_wakeup", "r").read()) and True or False + wasTimerWakeup = int(open(eEnv.resolve("${sysconfdir}/stb/fp/was_timer_wakeup"), "r").read()) and True or False except: try: fp = open("/dev/dbox/fp0") @@ -67,7 +68,7 @@ def getFPWasTimerWakeup(): def clearFPWasTimerWakeup(): try: - open("/usr/local/e2/etc/stb/fp/was_timer_wakeup", "w").write('0') + open(eEnv.resolve("${sysconfdir}/stb/fp/was_timer_wakeup"), "w").write('0') except: try: fp = open("/dev/dbox/fp0") diff --git a/enigma2/lib/python/Tools/HardwareInfo.py b/enigma2/lib/python/Tools/HardwareInfo.py index 4ba51b9..80f27ee 100644 --- a/enigma2/lib/python/Tools/HardwareInfo.py +++ b/enigma2/lib/python/Tools/HardwareInfo.py @@ -1,3 +1,5 @@ +from enigma import eEnv + class HardwareInfo: device_name = None device_version = None @@ -9,7 +11,7 @@ def __init__(self): HardwareInfo.device_name = "unknown" try: - file = open("/usr/local/e2/etc/stb/info/model", "r") + file = open(eEnv.resolve("${sysconfdir}/stb/info/model"), "r") HardwareInfo.device_name = file.readline().strip() file.close() try: From d887b2d674bf57085621588b3e7ba686851ce70f Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Sun, 19 Feb 2012 16:55:46 +0100 Subject: [PATCH 14/15] improved build_opnepliPC.sh script --- build_openpliPC.sh | 126 +++++++++++++++++++++++++++++++-------------- 1 file changed, 87 insertions(+), 39 deletions(-) diff --git a/build_openpliPC.sh b/build_openpliPC.sh index fe8577a..6c7e1bf 100755 --- a/build_openpliPC.sh +++ b/build_openpliPC.sh @@ -11,6 +11,8 @@ DO_BACKUP=0 DO_RESTORE=0 DO_XINE=1 DO_CONFIGURE=1 +DO_PARALLEL=1 +DO_MAKEINSTALL=1 function e2_backup { echo "-----------------------------" @@ -36,6 +38,8 @@ function usage { echo " -r : restore E2 conf file after re-compile" echo " -x : don't compile xine-lib (compile only enigma2)" echo " -nc: don't start configure/autoconf" + echo " -py: parallel compile (y threads) e.g. -p2" + echo " -ni: only execute make and no make install" echo " -h : this help" echo "" echo "common usage:" @@ -46,24 +50,37 @@ function usage { while [ "$1" != "" ]; do case $1 in -b ) DO_BACKUP=1 - shift - ;; - -r ) DO_RESTORE=1 - shift - ;; - -x ) DO_XINE=0 - shift - ;; - -nc ) DO_CONFIGURE=0 - shift - ;; - -h ) usage - exit - ;; - * ) echo "Unknown parameter" - usage - exit - ;; + shift + ;; + -r ) DO_RESTORE=1 + shift + ;; + -x ) DO_XINE=0 + shift + ;; + -nc ) DO_CONFIGURE=0 + shift + ;; + -ni ) DO_MAKEINSTALL=0 + shift + ;; + -p* ) if [ "`expr substr "$1" 3 3`" = "" ] + then + echo "Number threads is missing" + usage + exit + else + DO_PARALLEL=`expr substr "$1" 3 3` + fi + shift + ;; + -h ) usage + exit + ;; + * ) echo "Unknown parameter $1" + usage + exit + ;; esac done @@ -81,24 +98,40 @@ if [ "$DO_XINE" -eq "1" ]; then cd $PKG if [ "$DO_CONFIGURE" -eq "1" ]; then - echo "-----------------------------------------" - echo "configuring OpenPliPC $PKG" - echo "-----------------------------------------" + echo "-----------------------------------------" + echo "configuring OpenPliPC $PKG" + echo "-----------------------------------------" - ./autogen.sh --disable-xinerama --disable-musepack --prefix=/usr + ./autogen.sh --disable-xinerama --disable-musepack --prefix=/usr fi - echo "-----------------------------------------" - echo "build OpenPliPC $PKG, please wait..." - echo "-----------------------------------------" - - make - - echo "--------------------------------------" - echo "installing OpenPliPC $PKG" - echo "--------------------------------------" - - sudo make install + if [ "$DO_MAKEINSTALL" -eq "0" ]; then + echo "-----------------------------------------" + echo "build OpenPliPC $PKG, please wait..." + echo "-----------------------------------------" + + make -j"$DO_PARALLEL" + if [ ! $? -eq 0 ] + then + echo "" + echo "An error occured while building xine-lib" + exit + fi + + else + echo "--------------------------------------" + echo "installing OpenPliPC $PKG" + echo "--------------------------------------" + + sudo make -j"$DO_PARALLEL" install + if [ ! $? -eq 0 ] + then + echo "" + echo "An error occured while building xine-lib" + exit + fi + fi + cd .. fi @@ -125,13 +158,28 @@ echo "--------------------------------------" echo "build OpenPliPC $PKG, please wait..." echo "--------------------------------------" -make - -echo "--------------------------------------" -echo "installing OpenPliPC $PKG in $INSTALL_E2DIR" -echo "--------------------------------------" +if [ "$DO_MAKEINSTALL" -eq "0" ]; then + make -j"$DO_PARALLEL" + if [ ! $? -eq 0 ] + then + echo "" + echo "An error occured while building OpenPliPC" + exit + fi + +else + echo "--------------------------------------" + echo "installing OpenPliPC $PKG in $INSTALL_E2DIR" + echo "--------------------------------------" -sudo make install + sudo make -j"$DO_PARALLEL" install + if [ ! $? -eq 0 ] + then + echo "" + echo "An error occured while building OpenPliPC" + exit + fi +fi cd .. echo "--------------------------------------" From 5e930255aaee007652d803a18dd34dcb092c30ff Mon Sep 17 00:00:00 2001 From: betacentauri <@> Date: Thu, 23 Feb 2012 21:05:59 +0100 Subject: [PATCH 15/15] fix resolution(for users without windowmanager) --- enigma2/lib/gdi/gxlibdc.cpp | 25 +++++++++++++++++++++---- enigma2/lib/gdi/gxlibdc.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/enigma2/lib/gdi/gxlibdc.cpp b/enigma2/lib/gdi/gxlibdc.cpp index 04eaa77..f7c61a9 100644 --- a/enigma2/lib/gdi/gxlibdc.cpp +++ b/enigma2/lib/gdi/gxlibdc.cpp @@ -49,6 +49,12 @@ static bool getConfigBool(const std::string &key, bool defaultValue) return defaultValue; } +static int getConfigInt(const std::string &key) +{ + std::string value = getConfigString(key, "0"); + return atoi(value.c_str()); +} + gXlibDC::gXlibDC() : m_pump(eApp, 1) { double res_h, res_v; @@ -60,6 +66,8 @@ gXlibDC::gXlibDC() : m_pump(eApp, 1) argb_buffer = NULL; fullscreen = getConfigBool("config.pc.default_fullscreen", false); + initialWindowWidth = getConfigInt("config.pc.initial_window_width"); + initialWindowHeight = getConfigInt("config.pc.initial_window_height"); windowWidth = 720; windowHeight = 576; xpos = 0; @@ -90,7 +98,10 @@ gXlibDC::gXlibDC() : m_pump(eApp, 1) } XLockDisplay(display); - window = XCreateSimpleWindow(display, XDefaultRootWindow(display), xpos, ypos, windowWidth, windowHeight, 0, 0, 0); + if (initialWindowWidth && initialWindowHeight) + window = XCreateSimpleWindow(display, XDefaultRootWindow(display), xpos, ypos, initialWindowWidth, initialWindowHeight, 0, 0, 0); + else + window = XCreateSimpleWindow(display, XDefaultRootWindow(display), xpos, ypos, windowWidth, windowHeight, 0, 0, 0); XSelectInput (display, window, INPUT_MOTION); XMapRaised(display, window); res_h = (DisplayWidth(display, screen) * 1000 / DisplayWidthMM(display, screen)); @@ -239,8 +250,9 @@ void gXlibDC::setResolution(int xres, int yres) m_surface.offset = 0; m_pixmap = new gPixmap(&m_surface); - - XResizeWindow(display, window, windowWidth, windowHeight); + + if (initialWindowWidth == 0 || initialWindowHeight == 0) + XResizeWindow(display, window, windowWidth, windowHeight); updateWindowState(); } @@ -248,7 +260,12 @@ void gXlibDC::updateWindowState() { if (fullscreen) { width = DisplayWidth( display, screen ); height = DisplayHeight( display, screen ); - } else { + } else if (initialWindowWidth && initialWindowHeight) + { + width = initialWindowWidth; + height = initialWindowHeight; + } else + { width = windowWidth; height = windowHeight; } diff --git a/enigma2/lib/gdi/gxlibdc.h b/enigma2/lib/gdi/gxlibdc.h index 69193dc..5189e7e 100644 --- a/enigma2/lib/gdi/gxlibdc.h +++ b/enigma2/lib/gdi/gxlibdc.h @@ -29,6 +29,7 @@ class gXlibDC: public gMainDC, public eThread, public Object x11_visual_t vis; int fullscreen; int windowWidth, windowHeight; + int initialWindowWidth, initialWindowHeight; cXineLib *xineLib; gSurface m_surface; uint32_t *argb_buffer;