diff options
Diffstat (limited to 'src/xine-engine')
32 files changed, 1736 insertions, 1736 deletions
diff --git a/src/xine-engine/accel_xvmc.h b/src/xine-engine/accel_xvmc.h index 993f914bf..f7deeeb52 100644 --- a/src/xine-engine/accel_xvmc.h +++ b/src/xine-engine/accel_xvmc.h @@ -3,23 +3,23 @@ * Copyright (C) 2004 the Unichrome project * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * * - * Common acceleration definitions for XvMC. + * Common acceleration definitions for XvMC. * * */ @@ -85,7 +85,7 @@ typedef struct xine_xxmc_s { */ xine_xvmc_t xvmc; - + unsigned mpeg; unsigned acceleration; int fallback_format; @@ -107,7 +107,7 @@ typedef struct xine_xxmc_s { * For thread-safety only. */ - int (*proc_xxmc_lock_valid) (vo_frame_t *cur_frame, vo_frame_t *fw_frame, + int (*proc_xxmc_lock_valid) (vo_frame_t *cur_frame, vo_frame_t *fw_frame, vo_frame_t *bw_frame,unsigned pc_type); void (*proc_xxmc_unlock) (vo_driver_t *this_gen); } xine_xxmc_t; diff --git a/src/xine-engine/alphablend.c b/src/xine-engine/alphablend.c index dd8c4987b..15fc538ab 100644 --- a/src/xine-engine/alphablend.c +++ b/src/xine-engine/alphablend.c @@ -1,7 +1,7 @@ /* * * Copyright (C) James Courtier-Dutton James@superbug.demon.co.uk - July 2001 - * + * * Copyright (C) 2000 Thomas Mirlacher * 2002-2004 the xine project * @@ -114,7 +114,7 @@ rle_img_advance_line(rle_elem_t *rle, rle_elem_t *rle_limit, int w) /* * heck, this function is overly complicated and currently buggy. - * if James would like to revive it (implementing proper clipping - + * if James would like to revive it (implementing proper clipping - * not to confuse with button highlight) i would have no objections, * but for now i will be using an alternate version based on rgb24. [MF] * @@ -181,7 +181,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, printf("blend_rgb16: dy_step=%i, x_scale=%i\n", dy_step, x_scale); #endif if (img_width & 1) img_width++; - img_offset = ( ( (y_off * img_height) / dst_height) * img_width) + img_offset = ( ( (y_off * img_height) / dst_height) * img_width) + ( (x_off * img_width) / dst_width); #ifdef LOG_BLEND_RGB16 printf("blend_rgb16: x=%i, y=%i, w=%i, h=%i, img_offset=%lf\n", img_overl->x, img_overl->y, @@ -190,7 +190,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, img_offset); #endif img_pix = (uint16_t *) img + (int)img_offset; -/* +/* + (y_off * img_height / dst_height) * img_width + (x_off * img_width / dst_width); */ @@ -200,26 +200,26 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, clip_right = src_width; else clip_right = dst_width - x_off; - + if( x_off >= 0 ) clip_left = 0; else clip_left = -x_off; - + if( y_off >= 0 ) clip_top = 0; else clip_top = -y_off; - + if( (src_height + y_off) > dst_height ) src_height = dst_height - y_off; - + /* make highlight area fit into clip area */ if( img_overl->hili_right <= clip_right ) hili_right = img_overl->hili_right; else hili_right = clip_right; - + if( img_overl->hili_left >= clip_left ) hili_left = img_overl->hili_left; else @@ -233,7 +233,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, x = x1_scaled = x2_scaled = 0; #ifdef LOG_BLEND_RGB16 - printf("blend_rgb16 started\n"); + printf("blend_rgb16 started\n"); #endif while (zone_state != 6) { @@ -287,10 +287,10 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); } x += rle_this_bite; - if (x >= src_width ) { + if (x >= src_width ) { x -= src_width; img_pix += img_width; - + dy += dy_step; if (dy >= INT_TO_SCALED(1)) { dy -= INT_TO_SCALED(1); @@ -304,7 +304,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, } else { rle = rle_start; /* y-scaling, reuse the last rle encoded line */ } - } + } rle_remainder = rlelen = rle->len; clr_next = rle->color; rle++; @@ -345,7 +345,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); } x += rle_this_bite; - if (x >= src_width ) { + if (x >= src_width ) { x -= src_width; img_pix += img_width; dy += dy_step; @@ -390,7 +390,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); } x += rle_this_bite; - if (x >= src_width ) { + if (x >= src_width ) { x -= src_width; img_pix += img_width; dy += dy_step; @@ -410,7 +410,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, zone_state = 5; break; } - } + } if (rle >= rle_limit) { zone_state = 6; } @@ -435,7 +435,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); } x += rle_this_bite; - if (x >= src_width ) { + if (x >= src_width ) { x -= src_width; img_pix += img_width; dy += dy_step; @@ -455,7 +455,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, zone_state = 5; break; } - } + } if (rle >= rle_limit) { zone_state = 6; } @@ -473,7 +473,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); } x += rle_this_bite; - if (x >= src_width ) { + if (x >= src_width ) { x -= src_width; img_pix += img_width; dy += dy_step; @@ -489,7 +489,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, } else { rle = rle_start; /* y-scaling, reuse the last rle encoded line */ } - } + } rle_remainder = rlelen = rle->len; clr_next = rle->color; rle++; @@ -513,7 +513,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, mem_blend16(img_pix+x1_scaled, *((uint16_t *)&clut[clr]), o, x2_scaled-x1_scaled); } x += rle_this_bite; - if (x >= src_width ) { + if (x >= src_width ) { x -= src_width; img_pix += img_width; dy += dy_step; @@ -529,7 +529,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, } else { rle = rle_start; /* y-scaling, reuse the last rle encoded line */ } - } + } rle_remainder = rlelen = rle->len; clr_next = rle->color; rle++; @@ -544,7 +544,7 @@ void blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, #ifdef LOG_BLEND_RGB16 printf("blend_rgb16 ended\n"); #endif - + } #endif @@ -576,26 +576,26 @@ void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, clip_right = src_width; else clip_right = dst_width - x_off; - + if( x_off >= 0 ) clip_left = 0; else clip_left = -x_off; - + if( y_off >= 0 ) clip_top = 0; else clip_top = -y_off; - + if( (src_height + y_off) > dst_height ) src_height = dst_height - y_off; - + /* make highlight area fit into clip area */ if( img_overl->hili_right <= clip_right ) hili_right = img_overl->hili_right; else hili_right = clip_right; - + if( img_overl->hili_left >= clip_left ) hili_left = img_overl->hili_left; else @@ -619,7 +619,7 @@ void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, if (rlelen <= 0) { if (rle >= rle_limit) break; - + rlelen = rle->len; clr = rle->color; rle++; @@ -627,7 +627,7 @@ void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, if (!mask) { /* above or below highlight area */ - + rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; @@ -646,7 +646,7 @@ void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, trans = img_overl->trans; } else { /* ends left */ - + rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; @@ -666,25 +666,25 @@ void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, trans = img_overl->hili_trans; } else { /* starts right */ - + rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; trans = img_overl->trans; - + if( x + rle_bite >= clip_right ) clipped = 1; } } else { /* starts not left and ends not right */ - + rle_bite = rlelen; /* we're in the center area so choose highlight palette */ colors = (clut_t*)img_overl->hili_color; trans = img_overl->hili_trans; } } - + x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale); o = trans[clr]; @@ -743,26 +743,26 @@ void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, clip_right = src_width; else clip_right = dst_width - x_off; - + if( x_off >= 0 ) clip_left = 0; else clip_left = -x_off; - + if( y_off >= 0 ) clip_top = 0; else clip_top = -y_off; - + if( (src_height + y_off) > dst_height ) src_height = dst_height - y_off; - + /* make highlight area fit into clip area */ if( img_overl->hili_right <= clip_right ) hili_right = img_overl->hili_right; else hili_right = clip_right; - + if( img_overl->hili_left >= clip_left ) hili_left = img_overl->hili_left; else @@ -786,7 +786,7 @@ void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, if (rlelen <= 0) { if (rle >= rle_limit) break; - + rlelen = rle->len; clr = rle->color; rle++; @@ -794,7 +794,7 @@ void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, if (!mask) { /* above or below highlight area */ - + rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; @@ -813,7 +813,7 @@ void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, trans = img_overl->trans; } else { /* ends left */ - + rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; @@ -833,25 +833,25 @@ void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, trans = img_overl->hili_trans; } else { /* starts right */ - + rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; trans = img_overl->trans; - + if( x + rle_bite >= clip_right ) clipped = 1; } } else { /* starts not left and ends not right */ - + rle_bite = rlelen; /* we're in the center area so choose highlight palette */ colors = (clut_t*)img_overl->hili_color; trans = img_overl->hili_trans; } } - + x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale); o = trans[clr]; @@ -910,50 +910,50 @@ void _x_blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, clip_right = src_width; else clip_right = dst_width - x_off; - + if( x_off >= 0 ) clip_left = 0; else clip_left = -x_off; - + if( y_off >= 0 ) clip_top = 0; else clip_top = -y_off; - + if( (src_height + y_off) > dst_height ) src_height = dst_height - y_off; - + /* make highlight area fit into clip area */ if( img_overl->hili_right <= clip_right ) hili_right = img_overl->hili_right; else hili_right = clip_right; - + if( img_overl->hili_left >= clip_left ) hili_left = img_overl->hili_left; else hili_left = clip_left; - + for (y = dy = 0; y < src_height && rle < rle_limit; ) { int mask = !(y < img_overl->hili_top || y >= img_overl->hili_bottom); rle_elem_t *rle_start = rle; int rlelen = 0; uint8_t clr = 0; - + for (x = x1_scaled = 0; x < src_width;) { int rle_bite; clut_t *colors; uint8_t *trans; uint16_t o; int clipped = (y < clip_top); - + /* take next element from rle list everytime an element is finished */ if (rlelen <= 0) { if (rle >= rle_limit) break; - + rlelen = rle->len; clr = rle->color; rle++; @@ -961,7 +961,7 @@ void _x_blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, if (!mask) { /* above or below highlight area */ - + rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; @@ -980,7 +980,7 @@ void _x_blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, trans = img_overl->trans; } else { /* ends left */ - + rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; @@ -1000,25 +1000,25 @@ void _x_blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, trans = img_overl->hili_trans; } else { /* starts right */ - + rle_bite = rlelen; /* choose palette for surrounding area */ colors = (clut_t*)img_overl->color; trans = img_overl->trans; - + if( x + rle_bite >= clip_right ) clipped = 1; } } else { /* starts not left and ends not right */ - + rle_bite = rlelen; /* we're in the center area so choose highlight palette */ colors = (clut_t*)img_overl->hili_color; trans = img_overl->hili_trans; } } - + x2_scaled = SCALED_TO_INT((x + rle_bite) * x_scale); o = trans[clr]; @@ -1056,11 +1056,11 @@ static void mem_blend8(uint8_t *mem, uint8_t val, uint8_t o, size_t sz) } } -static void blend_yuv_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width, +static void blend_yuv_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width, uint8_t *(*blend_yuv_data)[ 3 ][ 2 ]) { int x; - + for (x = 0; x < src_width; x += 2) { /* get opacity of the 4 pixels that share chroma */ int o00 = (*blend_yuv_data)[ 0 ][ 0 ][ x + 0 ]; @@ -1078,7 +1078,7 @@ static void blend_yuv_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width, int cr01 = (*blend_yuv_data)[ 1 ][ 0 ][ x + 1 ]; int cr10 = (*blend_yuv_data)[ 1 ][ 1 ][ x + 0 ]; int cr11 = (*blend_yuv_data)[ 1 ][ 1 ][ x + 1 ]; - + int cb00 = (*blend_yuv_data)[ 2 ][ 0 ][ x + 0 ]; int cb01 = (*blend_yuv_data)[ 2 ][ 0 ][ x + 1 ]; int cb10 = (*blend_yuv_data)[ 2 ][ 1 ][ x + 0 ]; @@ -1113,11 +1113,11 @@ static uint8_t *(*blend_yuv_grow_extra_data(alphablend_t *extra_data, int osd_wi int max_width; uint8_t *data[ 3 ][ 2 ]; } *header = (struct header_s *)extra_data->buffer; - + size_t needed_buffer_size = sizeof (*header) + osd_width * sizeof (uint8_t[ 3 ][ 2 ]); - + if (extra_data->buffer_size < needed_buffer_size) { - + free(extra_data->buffer); header = calloc(1, needed_buffer_size); if (!header) { @@ -1143,7 +1143,7 @@ static uint8_t *(*blend_yuv_grow_extra_data(alphablend_t *extra_data, int osd_wi return &(header->data); } - + void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, int dst_width, int dst_height, int dst_pitches[3], alphablend_t *extra_data) @@ -1168,12 +1168,12 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, int hili_right, hili_left; int clip_right, clip_left, clip_top; uint8_t clr=0; - + int any_line_buffered = 0; int exact_blend_width = ((src_width <= (dst_width - x_off)) ? src_width : (dst_width - x_off)); int exact_blend_width_m2 = (x_odd + exact_blend_width + 1) & ~1; /* make it a (larger) multiple of 2 */ uint8_t *(*blend_yuv_data)[ 3 ][ 2 ] = 0; - + uint8_t *dst_y = dst_base[0] + dst_pitches[0] * y_off + x_off; uint8_t *dst_cr = dst_base[2] + (y_off / 2) * dst_pitches[1] + (x_off / 2); uint8_t *dst_cb = dst_base[1] + (y_off / 2) * dst_pitches[2] + (x_off / 2); @@ -1188,26 +1188,26 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, clip_right = src_width; else clip_right = dst_width - x_off; - + if( x_off >= 0 ) clip_left = 0; else clip_left = -x_off; - + if( y_off >= 0 ) clip_top = 0; else clip_top = -y_off; - + if( (src_height + y_off) > dst_height ) src_height = dst_height - y_off; - + /* make highlight area fit into clip area */ if( img_overl->hili_right <= clip_right ) hili_right = img_overl->hili_right; else hili_right = clip_right; - + if( img_overl->hili_left >= clip_left ) hili_left = img_overl->hili_left; else @@ -1219,16 +1219,16 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, if (enable_exact_blending) { if (exact_blend_width <= 0) return; - + blend_yuv_data = blend_yuv_grow_extra_data(extra_data, exact_blend_width_m2); if (!blend_yuv_data) return; - + /* make linebuffer transparent */ memset(&(*blend_yuv_data)[ 0 ][ 0 ][ 0 ], 0, exact_blend_width_m2); memset(&(*blend_yuv_data)[ 0 ][ 1 ][ 0 ], 0, exact_blend_width_m2); } - + rlelen=rle_remainder=0; for (y = 0; y < src_height; y++) { if (rle >= rle_limit) { @@ -1237,7 +1237,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, #endif break; } - + ymask = ((y < img_overl->hili_top) || (y >= img_overl->hili_bottom)); xmask = 0; #ifdef LOG_BLEND_YUV @@ -1247,14 +1247,14 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, for (x = 0; x < src_width;) { uint16_t o; int clipped = (y < clip_top); - + if (rle >= rle_limit) { #ifdef LOG_BLEND_YUV printf("x-rle_limit\n"); #endif break; } - + #ifdef LOG_BLEND_YUV printf("1:rle_len=%d, remainder=%d, x=%d\n",rlelen, rle_remainder, x); #endif @@ -1263,7 +1263,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, #ifdef LOG_BLEND_YUV printf("alphablend: major bug in blend_yuv < 0\n"); #endif - } + } if (rlelen == 0) { rle_remainder = rlelen = rle->len; clr = rle->color; @@ -1281,11 +1281,11 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, #endif if (ymask == 0) { - if (x < hili_left) { + if (x < hili_left) { /* Starts outside highlight area */ if ((x + rle_remainder) > hili_left ) { #ifdef LOG_BLEND_YUV - printf("Outside highlight left %d, ending inside\n", hili_left); + printf("Outside highlight left %d, ending inside\n", hili_left); #endif /* Cutting needed, starts outside, ends inside */ rle_this_bite = (hili_left - x); @@ -1296,7 +1296,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, xmask = 0; } else { #ifdef LOG_BLEND_YUV - printf("Outside highlight left %d, ending outside\n", hili_left); + printf("Outside highlight left %d, ending outside\n", hili_left); #endif /* no cutting needed, starts outside, ends outside */ rle_this_bite = rle_remainder; @@ -1335,7 +1335,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, } } else if (x >= hili_right) { /* Starts outside highlight area, ends outside highlight area */ - if ((x + rle_remainder ) > src_width ) { + if ((x + rle_remainder ) > src_width ) { #ifdef LOG_BLEND_YUV printf("Outside highlight right %d, ending eol\n", hili_right); #endif @@ -1381,7 +1381,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, /* clip against right edge of destination area */ if ((x + rle_this_bite) > (dst_width - x_off)) { int toClip = (x + rle_this_bite) - (dst_width - x_off); - + rle_this_bite -= toClip; rle_remainder += toClip; rlelen += toClip; @@ -1392,7 +1392,7 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, memset(&(*blend_yuv_data)[ 0 ][ (y + y_odd) & 1 ][ x + x_odd ], o, rle_this_bite); any_line_buffered |= ((y + y_odd) & 1) ? 2 : 1; } - + if (o && !clipped) { if(o >= 15) { memset(dst_y + x, my_clut[clr].y, rle_this_bite); @@ -1434,17 +1434,17 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, /* make second line transparent */ memset(&(*blend_yuv_data)[ 0 ][ 1 ][ 0 ], 0, exact_blend_width_m2); } - + blend_yuv_exact(dst_cr, dst_cb, exact_blend_width, blend_yuv_data); - + any_line_buffered = 0; } } - + dst_cr += dst_pitches[2]; dst_cb += dst_pitches[1]; } - + dst_y += dst_pitches[0]; } @@ -1455,21 +1455,21 @@ void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, /* make second line transparent */ memset(&(*blend_yuv_data)[ 0 ][ 1 ][ 0 ], 0, exact_blend_width_m2); } - + blend_yuv_exact(dst_cr, dst_cb, exact_blend_width, blend_yuv_data); } } - + #ifdef LOG_BLEND_YUV printf("overlay_blend ended\n"); #endif } - + static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width, uint8_t *(*blend_yuy2_data)[ 3 ]) { int x; - + for (x = 0; x < src_width; x += 2) { /* get opacity of the 2 pixels that share chroma */ int o0 = (*blend_yuy2_data)[ 0 ][ x + 0 ]; @@ -1481,7 +1481,7 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width, /* get the chroma components of the 2 pixels */ int cr0 = (*blend_yuy2_data)[ 1 ][ x + 0 ]; int cr1 = (*blend_yuy2_data)[ 1 ][ x + 1 ]; - + int cb0 = (*blend_yuy2_data)[ 2 ][ x + 0 ]; int cb1 = (*blend_yuy2_data)[ 2 ][ x + 1 ]; @@ -1496,7 +1496,7 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width, /* * No need to adjust chroma values with +/- 128: - * *dst_cb + * *dst_cb * = 128 + ((*dst_cb-128) * t2 + (cb0-128) * o0 + (cb1-128) * o1) / (2 * 0xf); * = 128 + (*dst_cb * t2 + cb0 * o0 + cb1 * o1 + (t2*(-128) - 128*o0 - 128*o1)) / (2 * 0xf); * = 128 + (*dst_cb * t2 + cb0 * o0 + cb1 * o1 + ((2*0xf-o0-o1)*(-128) - 128*o0 - 128*o1)) / (2 * 0xf); @@ -1512,8 +1512,8 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width, * =(almost) X * 0x1112/0x10000 * = (X * 0x1112) >> 16 * - * The tricky point is 0x1111/0xffff --> 0x1112/0x10000. - * All calculations are done using integers and X is in + * The tricky point is 0x1111/0xffff --> 0x1112/0x10000. + * All calculations are done using integers and X is in * range of [0 ... 0xff*0xf*4]. This results in error of * X*0x1112/0x10000 - X/0xf * = X*(0x1112/0x10000 - 1/0xf) @@ -1523,7 +1523,7 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width, * As the error is less than 1 and always positive, whole error * "disappears" during truncation (>>16). Rounding to exact results is * guaranteed by selecting 0x1112 instead of more accurate 0x1111 - * (with 0x1111 error=X*(-0.00001111...)). With 0x1112 error is + * (with 0x1111 error=X*(-0.00001111...)). With 0x1112 error is * always positive, but still less than one. * So, one can forget the "=(almost)" as it is really "=" when source * operands are within 0...0xff (U,V) and 0...0xf (A). @@ -1531,7 +1531,7 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width, * 1/0x10000 (= >>16) was originally selected because of MMX pmullhw * instruction; it makes possible to do whole calculation in MMX using * uint16's (pmullhw is (X*Y)>>16). - * + * * Here X/(2*0xf) = X/0xf/2 = ((X*0x1112)>>16)>>1 = (X*0x1112)>>17 */ @@ -1555,11 +1555,11 @@ static uint8_t *(*blend_yuy2_grow_extra_data(alphablend_t *extra_data, int osd_w int max_width; uint8_t *data[ 3 ]; } *header = (struct header_s *)extra_data->buffer; - + size_t needed_buffer_size = sizeof (*header) + osd_width * sizeof (uint8_t[ 3 ]); - + if (extra_data->buffer_size < needed_buffer_size) { - + free(extra_data->buffer); header = calloc(1, needed_buffer_size); if (!header) { @@ -1619,7 +1619,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, int exact_blend_width = ((src_width <= (dst_width - x_off)) ? src_width : (dst_width - x_off)); int exact_blend_width_m2 = (x_odd + exact_blend_width + 1) & ~1; /* make it a (larger) multiple of 2 */ uint8_t *(*blend_yuy2_data)[ 3 ] = 0; - + uint8_t *dst_y = dst_img + dst_pitch * y_off + 2 * x_off; uint8_t *dst; @@ -1631,26 +1631,26 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, clip_right = src_width; else clip_right = dst_width - x_off; - + if( x_off >= 0 ) clip_left = 0; else clip_left = -x_off; - + if( y_off >= 0 ) clip_top = 0; else clip_top = -y_off; - + if( (src_height + y_off) > dst_height ) src_height = dst_height - y_off; - + /* make highlight area fit into clip area */ if( img_overl->hili_right <= clip_right ) hili_right = img_overl->hili_right; else hili_right = clip_right; - + if( img_overl->hili_left >= clip_left ) hili_left = img_overl->hili_left; else @@ -1662,11 +1662,11 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, if (enable_exact_blending) { if (exact_blend_width <= 0) return; - + blend_yuy2_data = blend_yuy2_grow_extra_data(extra_data, exact_blend_width_m2); if (!blend_yuy2_data) return; - + /* make linebuffer transparent */ memset(&(*blend_yuy2_data)[ 0 ][ 0 ], 0, exact_blend_width_m2); } @@ -1675,7 +1675,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, for (y = 0; y < src_height; y++) { if (rle >= rle_limit) break; - + ymask = ((y < img_overl->hili_top) || (y >= img_overl->hili_bottom)); dst = dst_y; @@ -1685,12 +1685,12 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, if (rle >= rle_limit) break; - + if ((rlelen < 0) || (rle_remainder < 0)) { #ifdef LOG_BLEND_YUV printf("alphablend: major bug in blend_yuv < 0\n"); #endif - } + } if (rlelen == 0) { rle_remainder = rlelen = rle->len; clr = rle->color; @@ -1708,11 +1708,11 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, #endif if (ymask == 0) { - if (x < hili_left) { + if (x < hili_left) { /* Starts outside highlight area */ if ((x + rle_remainder) > hili_left ) { #ifdef LOG_BLEND_YUV - printf("Outside highlight left %d, ending inside\n", hili_left); + printf("Outside highlight left %d, ending inside\n", hili_left); #endif /* Cutting needed, starts outside, ends inside */ rle_this_bite = (hili_left - x); @@ -1722,7 +1722,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, my_trans = img_overl->trans; } else { #ifdef LOG_BLEND_YUV - printf("Outside highlight left %d, ending outside\n", hili_left); + printf("Outside highlight left %d, ending outside\n", hili_left); #endif /* no cutting needed, starts outside, ends outside */ rle_this_bite = rle_remainder; @@ -1758,7 +1758,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, } } else if (x >= hili_right) { /* Starts outside highlight area, ends outsite highlight area */ - if ((x + rle_remainder ) > src_width ) { + if ((x + rle_remainder ) > src_width ) { #ifdef LOG_BLEND_YUV printf("Outside highlight right %d, ending eol\n", hili_right); #endif @@ -1798,7 +1798,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, /* clip against right edge of destination area */ if ((x + rle_this_bite) > (dst_width - x_off)) { int toClip = (x + rle_this_bite) - (dst_width - x_off); - + rle_this_bite -= toClip; rle_remainder += toClip; rlelen += toClip; @@ -1850,7 +1850,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, mem_blend32(dst, &yuy2.b[0], o, l); dst += 4*l; } - + if(rle_this_bite & 1) { *dst = BLEND_BYTE(*dst, yuy2.b[0], o); dst++; @@ -1875,15 +1875,15 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, dst += rle_this_bite*2; } } - + x += rle_this_bite; } - + if (enable_exact_blending) { /* blend buffered line */ if (any_line_buffered) { blend_yuy2_exact(dst_y - x_odd * 2 + 3, dst_y - x_odd * 2 + 1, exact_blend_width, blend_yuy2_data); - + any_line_buffered = 0; } } @@ -1892,7 +1892,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, } } -void _x_clear_xx44_palette(xx44_palette_t *p) +void _x_clear_xx44_palette(xx44_palette_t *p) { register int i; register uint32_t *cluts = p->cluts; @@ -1904,20 +1904,20 @@ void _x_clear_xx44_palette(xx44_palette_t *p) i = 2*OVL_PALETTE_SIZE; while(i--) *ids++ = -1; - p->max_used=1; + p->max_used=1; } -void _x_init_xx44_palette(xx44_palette_t *p, unsigned num_entries) +void _x_init_xx44_palette(xx44_palette_t *p, unsigned num_entries) { - p->size = (num_entries > XX44_PALETTE_SIZE) ? XX44_PALETTE_SIZE : num_entries; + p->size = (num_entries > XX44_PALETTE_SIZE) ? XX44_PALETTE_SIZE : num_entries; } -void _x_dispose_xx44_palette(xx44_palette_t *p) +void _x_dispose_xx44_palette(xx44_palette_t *p) { } static void colorToPalette(const uint32_t *icolor, unsigned char *palette_p, - unsigned num_xvmc_components, char *xvmc_components) + unsigned num_xvmc_components, char *xvmc_components) { const clut_t *color = (const clut_t *) icolor; unsigned int i; @@ -1925,7 +1925,7 @@ static void colorToPalette(const uint32_t *icolor, unsigned char *palette_p, switch(xvmc_components[i]) { case 'V': *palette_p = color->cr; break; case 'U': *palette_p = color->cb; break; - case 'Y': + case 'Y': default: *palette_p = color->y; break; } palette_p++; @@ -1935,7 +1935,7 @@ static void colorToPalette(const uint32_t *icolor, unsigned char *palette_p, void _x_xx44_to_xvmc_palette(const xx44_palette_t *p,unsigned char *xvmc_palette, unsigned first_xx44_entry, unsigned num_xx44_entries, - unsigned num_xvmc_components, char *xvmc_components) + unsigned num_xvmc_components, char *xvmc_components) { register unsigned int i; register const uint32_t *cluts = p->cluts + first_xx44_entry; @@ -1946,16 +1946,16 @@ void _x_xx44_to_xvmc_palette(const xx44_palette_t *p,unsigned char *xvmc_palette xvmc_palette += num_xvmc_components; } } -} +} -static int xx44_paletteIndex(xx44_palette_t *p, int color, uint32_t clut) +static int xx44_paletteIndex(xx44_palette_t *p, int color, uint32_t clut) { register unsigned int i; register uint32_t *cluts = p->cluts; register int tmp; - if ((tmp = p->lookup_cache[color]) >= 0) + if ((tmp = p->lookup_cache[color]) >= 0) if (cluts[tmp] == clut) return tmp; for (i=0; i<p->max_used; ++i) { @@ -1972,7 +1972,7 @@ static int xx44_paletteIndex(xx44_palette_t *p, int color, uint32_t clut) static void memblend_xx44(uint8_t *mem,uint8_t val, register size_t size, uint8_t mask) { - register uint8_t + register uint8_t masked_val; if (0 == (masked_val = val & mask)) return; @@ -1984,16 +1984,16 @@ static void memblend_xx44(uint8_t *mem,uint8_t val, register size_t size, uint8_ } void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl, - int dst_width, int dst_height, int dst_pitch, + int dst_width, int dst_height, int dst_pitch, alphablend_t *extra_data, - xx44_palette_t *palette,int ia44) + xx44_palette_t *palette,int ia44) { int src_width, src_height; rle_elem_t *rle, *rle_limit; int mask; int x_off, y_off; int x, y; - uint8_t norm_pixel,hili_pixel; + uint8_t norm_pixel,hili_pixel; uint8_t *dst_y; uint8_t *dst; uint8_t alphamask = (ia44) ? 0x0F : 0xF0; @@ -2017,26 +2017,26 @@ void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl, clip_right = src_width; else clip_right = dst_width - x_off; - + if( x_off >= 0 ) clip_left = 0; else clip_left = -x_off; - + if( y_off >= 0 ) clip_top = 0; else clip_top = -y_off; - + if( (src_height + y_off) > dst_height ) src_height = dst_height - y_off; - + /* make highlight area fit into clip area */ if( img_overl->hili_right <= clip_right ) hili_right = img_overl->hili_right; else hili_right = clip_right; - + if( img_overl->hili_left >= clip_left ) hili_left = img_overl->hili_left; else @@ -2053,10 +2053,10 @@ void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl, if (len > 0) { norm_pixel = (uint8_t)((xx44_paletteIndex(palette,rle->color, - img_overl->color[rle->color]) << 4) | + img_overl->color[rle->color]) << 4) | (img_overl->trans[rle->color] & 0x0F)); hili_pixel = (uint8_t)((xx44_paletteIndex(palette,rle->color+OVL_PALETTE_SIZE, - img_overl->hili_color[rle->color]) << 4) | + img_overl->hili_color[rle->color]) << 4) | (img_overl->hili_trans[rle->color] & 0x0F)); if (!ia44) { norm_pixel = ((norm_pixel & 0x0F) << 4) | ((norm_pixel & 0xF0) >> 4); @@ -2091,7 +2091,7 @@ void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl, dst += len; } } - } else if (x < hili_right) { + } else if (x < hili_right) { if (len <= hili_right - x) { if(!clipped) memblend_xx44(dst,hili_pixel,len, alphamask); @@ -2123,7 +2123,7 @@ void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl, x += rle->len; rle++; if (rle >= rle_limit) break; - } + } if (rle >= rle_limit) break; dst_y += dst_pitch; } @@ -2139,7 +2139,7 @@ static void alphablend_disable_exact_osd_alpha_blending_changed(void *user_data, void _x_alphablend_init(alphablend_t *extra_data, xine_t *xine) { config_values_t *config = xine->config; - + extra_data->buffer = 0; extra_data->buffer_size = 0; extra_data->offset_x = 0; diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index 483567994..687121457 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/audio_decoder.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2005 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -60,18 +60,18 @@ static void *audio_decoder_loop (void *stream_gen) { while (running) { - lprintf ("audio_loop: waiting for package...\n"); + lprintf ("audio_loop: waiting for package...\n"); if( !replaying_headers ) buf = stream->audio_fifo->get (stream->audio_fifo); - lprintf ("audio_loop: got package pts = %"PRId64", type = %08x\n", buf->pts, buf->type); + lprintf ("audio_loop: got package pts = %"PRId64", type = %08x\n", buf->pts, buf->type); _x_extra_info_merge( stream->audio_decoder_extra_info, buf->extra_info ); stream->audio_decoder_extra_info->seek_count = stream->video_seek_count; - + switch (buf->type) { - + case BUF_CONTROL_HEADERS_DONE: pthread_mutex_lock (&stream->counter_lock); stream->header_count_audio++; @@ -85,11 +85,11 @@ static void *audio_decoder_loop (void *stream_gen) { /* decoder dispose might call port functions */ running_ticket->acquire(running_ticket, 0); - + if (stream->audio_decoder_plugin) { lprintf ("close old decoder\n"); - + stream->keep_ao_driver_open = !!(buf->decoder_flags & BUF_FLAG_GAPLESS_SW); _x_free_audio_decoder (stream, stream->audio_decoder_plugin); stream->audio_decoder_plugin = NULL; @@ -97,15 +97,15 @@ static void *audio_decoder_loop (void *stream_gen) { stream->audio_type = 0; stream->keep_ao_driver_open = 0; } - + running_ticket->release(running_ticket, 0); - + if( !(buf->decoder_flags & BUF_FLAG_GAPLESS_SW) ) stream->metronom->handle_audio_discontinuity (stream->metronom, DISC_STREAMSTART, 0); - + buftype_unknown = 0; break; - + case BUF_CONTROL_END: /* free all held header buffers, see comments below */ @@ -128,12 +128,12 @@ static void *audio_decoder_loop (void *stream_gen) { */ while(1) { int num_bufs, num_streams; - + running_ticket->acquire(running_ticket, 0); num_bufs = stream->audio_out->get_property(stream->audio_out, AO_PROP_BUFS_IN_FIFO); num_streams = stream->audio_out->get_property(stream->audio_out, AO_PROP_NUM_STREAMS); running_ticket->release(running_ticket, 0); - + if( num_bufs > 0 && num_streams == 1 && !stream->early_finish_event) xine_usec_sleep (10000); else @@ -144,7 +144,7 @@ static void *audio_decoder_loop (void *stream_gen) { pthread_mutex_lock (&stream->counter_lock); stream->finished_count_audio++; - + lprintf ("reached end marker # %d\n", stream->finished_count_audio); pthread_cond_broadcast (&stream->counter_changed); @@ -164,18 +164,18 @@ static void *audio_decoder_loop (void *stream_gen) { stream->audio_channel_auto = -1; break; - + case BUF_CONTROL_QUIT: /* decoder dispose might call port functions */ running_ticket->acquire(running_ticket, 0); - + if (stream->audio_decoder_plugin) { _x_free_audio_decoder (stream, stream->audio_decoder_plugin); stream->audio_decoder_plugin = NULL; stream->audio_track_map_entries = 0; stream->audio_type = 0; } - + running_ticket->release(running_ticket, 0); running = 0; break; @@ -193,14 +193,14 @@ static void *audio_decoder_loop (void *stream_gen) { running_ticket->release(running_ticket, 0); } break; - + case BUF_CONTROL_DISCONTINUITY: if (stream->audio_decoder_plugin) { running_ticket->acquire(running_ticket, 0); stream->audio_decoder_plugin->discontinuity (stream->audio_decoder_plugin); running_ticket->release(running_ticket, 0); } - + stream->metronom->handle_audio_discontinuity (stream->metronom, DISC_RELATIVE, buf->disc_off); break; @@ -210,7 +210,7 @@ static void *audio_decoder_loop (void *stream_gen) { stream->audio_decoder_plugin->discontinuity (stream->audio_decoder_plugin); running_ticket->release(running_ticket, 0); } - + if (buf->decoder_flags & BUF_FLAG_SEEK) { stream->metronom->handle_audio_discontinuity (stream->metronom, DISC_STREAMSEEK, buf->disc_off); } else { @@ -220,7 +220,7 @@ static void *audio_decoder_loop (void *stream_gen) { case BUF_CONTROL_AUDIO_CHANNEL: { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "audio_decoder: suggested switching to stream_id %02x\n", buf->decoder_info[0]); stream->audio_channel_auto = buf->decoder_info[0] & 0xff; } @@ -248,27 +248,27 @@ static void *audio_decoder_loop (void *stream_gen) { xine_profiler_start_count (prof_audio_decode); running_ticket->acquire(running_ticket, 0); - + if ( (buf->type & 0xFF000000) == BUF_AUDIO_BASE ) { - + uint32_t audio_type = 0; int i,j; uint32_t chan=buf->type&0x0000FFFF; /* printf("audio_decoder: buf_type=%08x auto=%08x user=%08x\n", - buf->type, + buf->type, stream->audio_channel_auto, audio_channel_user); */ /* update track map */ - + i = 0; - while ( (i<stream->audio_track_map_entries) && ((stream->audio_track_map[i]&0x0000FFFF)<chan) ) + while ( (i<stream->audio_track_map_entries) && ((stream->audio_track_map[i]&0x0000FFFF)<chan) ) i++; - - if ( (i==stream->audio_track_map_entries) + + if ( (i==stream->audio_track_map_entries) || ((stream->audio_track_map[i]&0x0000FFFF)!=chan) ) { xine_event_t ui_event; @@ -304,7 +304,7 @@ static void *audio_decoder_loop (void *stream_gen) { lprintf ("audio_channel_auto = %d\n", stream->audio_channel_auto); if (stream->audio_channel_auto>=0) { - + if ((buf->type & 0xFF) == stream->audio_channel_auto) { audio_type = buf->type; } else @@ -321,30 +321,30 @@ static void *audio_decoder_loop (void *stream_gen) { } /* now, decode stream buffer if it's the right audio type */ - + if (buf->type == audio_type) { - + int streamtype = (buf->type>>16) & 0xFF; /* close old decoder of audio type has changed */ - - if( buf->type != buftype_unknown && + + if( buf->type != buftype_unknown && (stream->audio_decoder_streamtype != streamtype || !stream->audio_decoder_plugin) ) { - + if (stream->audio_decoder_plugin) { _x_free_audio_decoder (stream, stream->audio_decoder_plugin); } - + stream->audio_decoder_streamtype = streamtype; stream->audio_decoder_plugin = _x_get_audio_decoder (stream, streamtype); - + _x_stream_info_set(stream, XINE_STREAM_INFO_AUDIO_HANDLED, (stream->audio_decoder_plugin != NULL)); } - + if (audio_type != stream->audio_type) { - + if (stream->audio_decoder_plugin) { xine_event_t event; @@ -355,23 +355,23 @@ static void *audio_decoder_loop (void *stream_gen) { xine_event_send(stream, &event); } } - + /* finally - decode data */ - - if (stream->audio_decoder_plugin) + + if (stream->audio_decoder_plugin) stream->audio_decoder_plugin->decode_data (stream->audio_decoder_plugin, buf); - - if (buf->type != buftype_unknown && + + if (buf->type != buftype_unknown && !_x_stream_info_get(stream, XINE_STREAM_INFO_AUDIO_HANDLED)) { xine_log (stream->xine, XINE_LOG_MSG, _("audio_decoder: no plugin available to handle '%s'\n"), _x_buf_audio_name( buf->type ) ); - + if( !_x_meta_info_get(stream, XINE_META_INFO_AUDIOCODEC) ) _x_meta_info_set_utf8(stream, XINE_META_INFO_AUDIOCODEC, _x_buf_audio_name( buf->type )); - + buftype_unknown = buf->type; - /* fatal error - dispose plugin */ + /* fatal error - dispose plugin */ if (stream->audio_decoder_plugin) { _x_free_audio_decoder (stream, stream->audio_decoder_plugin); stream->audio_decoder_plugin = NULL; @@ -380,7 +380,7 @@ static void *audio_decoder_loop (void *stream_gen) { } } } else if( buf->type != buftype_unknown ) { - xine_log (stream->xine, XINE_LOG_MSG, + xine_log (stream->xine, XINE_LOG_MSG, _("audio_decoder: error, unknown buffer type: %08x\n"), buf->type ); buftype_unknown = buf->type; } @@ -388,14 +388,14 @@ static void *audio_decoder_loop (void *stream_gen) { if (running_ticket->ticket_revoked) running_ticket->renew(running_ticket, 0); running_ticket->release(running_ticket, 0); - + xine_profiler_stop_count (prof_audio_decode); } /* some decoders require a full reinitialization when audio * channel is changed (rate might be change and even a - * different codec may be used). - * + * different codec may be used). + * * we must close the old decoder and process all the headers * again, since they are needed for decoder initialization. */ @@ -408,7 +408,7 @@ static void *audio_decoder_loop (void *stream_gen) { running_ticket->acquire(running_ticket, 0); _x_free_audio_decoder (stream, stream->audio_decoder_plugin); running_ticket->release(running_ticket, 0); - + stream->audio_decoder_plugin = NULL; stream->audio_track_map_entries = 0; stream->audio_type = 0; @@ -456,7 +456,7 @@ static void *audio_decoder_loop (void *stream_gen) { } first_header = last_header = NULL; } - + return NULL; } @@ -471,7 +471,7 @@ int _x_audio_decoder_init (xine_stream_t *stream) { return 1; } else { int num_buffers; - + /* The fifo size is based on dvd playback where buffers are filled * with 2k of data. With 230 buffers and a typical audio data rate * of 1.8 Mbit/s (four ac3 streams), the fifo can hold about 2 seconds @@ -479,7 +479,7 @@ int _x_audio_decoder_init (xine_stream_t *stream) { * We provide buffers of 8k size instead of 2k for demuxers sending * larger chunks. */ - + num_buffers = stream->xine->config->register_num (stream->xine->config, "engine.buffers.audio_num_buffers", 230, @@ -489,7 +489,7 @@ int _x_audio_decoder_init (xine_stream_t *stream) { "mean smoother playback for unreliable inputs, but " "also increased latency and memory consumption."), 20, NULL, NULL); - + stream->audio_fifo = _x_fifo_buffer_new (num_buffers, 8192); stream->audio_channel_user = -1; stream->audio_channel_auto = -1; @@ -505,17 +505,17 @@ int _x_audio_decoder_init (xine_stream_t *stream) { pth_params.sched_priority = sched_get_priority_min(SCHED_OTHER); pthread_attr_setschedparam(&pth_attrs, &pth_params); pthread_attr_setscope(&pth_attrs, PTHREAD_SCOPE_SYSTEM); - - stream->audio_thread_created = 1; + + stream->audio_thread_created = 1; if ((err = pthread_create (&stream->audio_thread, &pth_attrs, audio_decoder_loop, stream)) != 0) { - xprintf (stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "audio_decoder: can't create new thread (%s)\n", strerror(err)); stream->audio_thread_created = 0; pthread_attr_destroy(&pth_attrs); return 0; } - + pthread_attr_destroy(&pth_attrs); } return 1; @@ -532,16 +532,16 @@ void _x_audio_decoder_shutdown (xine_stream_t *stream) { buf = stream->audio_fifo->buffer_pool_alloc (stream->audio_fifo); buf->type = BUF_CONTROL_QUIT; stream->audio_fifo->put (stream->audio_fifo, buf); - + pthread_join (stream->audio_thread, &p); stream->audio_thread_created = 0; } - + stream->audio_fifo->dispose (stream->audio_fifo); stream->audio_fifo = NULL; } int _x_get_audio_channel (xine_stream_t *stream) { - return stream->audio_type & 0xFFFF; + return stream->audio_type & 0xFFFF; } diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 2f29f92ea..c9daa4e4e 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2006 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with self program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -102,7 +102,7 @@ #define ZERO_BUF_SIZE 5000 /* By adding gap errors (difference between reported and expected - * sound card clock) into metronom's vpts_offset we can use its + * sound card clock) into metronom's vpts_offset we can use its * smoothing algorithms to correct sound card clock drifts. * obs: previously this error was added to xine scr. * @@ -158,13 +158,13 @@ typedef struct { #define EQ_BANDS 10 #define EQ_CHANNELS 8 -#define FP_FRBITS 28 +#define FP_FRBITS 28 #define EQ_REAL(x) ((int)((x) * (1 << FP_FRBITS))) typedef struct { int beta; - int alpha; + int alpha; int gamma; } sIIRCoefficients; @@ -197,15 +197,15 @@ static const sIIRCoefficients iir_cf[] = { /* 16k Hz*/ { EQ_REAL(2.4201241845e-01), EQ_REAL(3.7899379077e-01), EQ_REAL(-8.0847117831e-01) }, }; - + typedef struct { - + xine_audio_port_t ao; /* public part */ /* private stuff */ ao_driver_t *driver; pthread_mutex_t driver_lock; - + uint32_t driver_open:1; uint32_t audio_loop_running:1; uint32_t audio_thread_created:1; @@ -230,7 +230,7 @@ typedef struct { int64_t audio_step; /* pts per 32 768 samples (sample = #bytes/2) */ int32_t frames_per_kpts; /* frames per 1024/90000 sec */ - + int av_sync_method_conf; resample_sync_t resample_sync_info; double resample_sync_factor; /* correct buffer length by this factor @@ -253,7 +253,7 @@ typedef struct { /* FIXME: replace all this->clock->speed with this->current_speed. we should make * sure nobody will change speed without going through xine.c:set_speed_internal */ int slow_fast_audio; /* play audio even on slow/fast speeds */ - + int16_t last_sample[RESAMPLE_MAX_CHANNELS]; audio_buffer_t *frame_buf[2]; /* two buffers for "stackable" conversions */ int16_t *zero_space; @@ -279,7 +279,7 @@ typedef struct { int eq_k; sXYData eq_data_history[EQ_BANDS][EQ_CHANNELS]; - + } aos_t; struct audio_fifo_s { @@ -444,7 +444,7 @@ static void fifo_wait_empty (audio_fifo_t *fifo) { } -static void write_pause_burst(aos_t *this, uint32_t num_frames) { +static void write_pause_burst(aos_t *this, uint32_t num_frames) { uint16_t sbuf[4096]; sbuf[0] = 0xf872; @@ -474,7 +474,7 @@ static void ao_fill_gap (aos_t *this, int64_t pts_len) { if ((this->output.mode == AO_CAP_MODE_A52) || (this->output.mode == AO_CAP_MODE_AC5)) { write_pause_burst(this,num_frames); - return; + return; } while (num_frames > 0 && !this->discard_buffers) { @@ -498,7 +498,7 @@ static void ensure_buffer_size (audio_buffer_t *buf, int bytes_per_frame, int frames) { int size = bytes_per_frame * frames; - + if (buf->mem_size < size) { buf->mem = realloc( buf->mem, size ); buf->mem_size = size; @@ -529,7 +529,7 @@ int _x_ao_mode2channels( int mode ) { return 6; } return 0; -} +} int _x_ao_channels2mode( int channels ) { @@ -560,7 +560,7 @@ static void audio_filter_compress (aos_t *this, int16_t *mem, int num_frames) { return; maxs = 0; - + /* measure */ for (i=0; i<num_frames*num_channels; i++) { @@ -576,12 +576,12 @@ static void audio_filter_compress (aos_t *this, int16_t *mem, int num_frames) { this->compression_factor = this->compression_factor * 0.999 + f_max * 0.001; if (this->compression_factor > f_max) this->compression_factor = f_max; - + if (this->compression_factor > this->compression_factor_max) this->compression_factor = this->compression_factor_max; } else f_max = 1.0; - + lprintf ("max=%d f_max=%f compression_factor=%f\n", maxs, f_max, this->compression_factor); /* apply it */ @@ -596,7 +596,7 @@ static void audio_filter_amp (aos_t *this, void *buf, int num_frames) { double amp_factor; int i; const int total_frames = num_frames * _x_ao_mode2channels (this->input.mode); - + if (!total_frames) return; @@ -615,11 +615,11 @@ static void audio_filter_amp (aos_t *this, void *buf, int num_frames) { /* Force limit on amp_factor to prevent clipping */ if (test < INT8_MIN) { this->amp_factor = amp_factor = amp_factor * INT8_MIN / test; - test=INT8_MIN; + test=INT8_MIN; } if (test > INT8_MAX) { this->amp_factor = amp_factor = amp_factor * INT8_MIN / test; - test=INT8_MAX; + test=INT8_MAX; } mem[i] = test; } @@ -632,11 +632,11 @@ static void audio_filter_amp (aos_t *this, void *buf, int num_frames) { /* Force limit on amp_factor to prevent clipping */ if (test < INT16_MIN) { this->amp_factor = amp_factor = amp_factor * INT16_MIN / test; - test=INT16_MIN; + test=INT16_MIN; } if (test > INT16_MAX) { this->amp_factor = amp_factor = amp_factor * INT16_MIN / test; - test=INT16_MAX; + test=INT16_MAX; } mem[i] = test; } @@ -940,7 +940,7 @@ static int resample_rate_adjust(aos_t *this, int64_t gap, audio_buffer_t *buf) { if (gap_diff < RESAMPLE_MAX_GAP_DIFF) { #if LOG_RESAMPLE_SYNC int num_frames; - + /* if we are already resampling to a different output rate, consider * this during calculation */ num_frames = (this->do_resample) ? (buf->num_frames * this->frame_rate_factor) @@ -975,7 +975,7 @@ static int resample_rate_adjust(aos_t *this, int64_t gap, audio_buffer_t *buf) { info->window_duration += buf->vpts - info->last_vpts; info->last_vpts = buf->vpts; info->window++; - } + } return 0; } @@ -983,7 +983,7 @@ static int resample_rate_adjust(aos_t *this, int64_t gap, audio_buffer_t *buf) { static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mode); /* Audio output loop: - - * 1) Check for pause. + * 1) Check for pause. * 2) Make sure audio hardware is in RUNNING state. * 3) Get delay * 4) Do drop, 0-fill or output samples. @@ -1011,7 +1011,7 @@ static void *ao_loop (void *this_gen) { /* * get buffer to process for this loop iteration */ - + if (!in_buf) { lprintf ("loop: get buf from fifo\n"); in_buf = fifo_peek (this->out_fifo); @@ -1036,18 +1036,18 @@ static void *ao_loop (void *this_gen) { continue; } pthread_mutex_unlock(&this->flush_audio_driver_lock); - - /* + + /* * wait until user unpauses stream * if we are playing at a different speed (without slow_fast_audio flag) * we must process/free buffers otherwise the entire engine will stop. */ - + pthread_mutex_lock(&this->current_speed_lock); - if ( this->audio_loop_running && - (this->clock->speed == XINE_SPEED_PAUSE || - (this->clock->speed != XINE_FINE_SPEED_NORMAL && + if ( this->audio_loop_running && + (this->clock->speed == XINE_SPEED_PAUSE || + (this->clock->speed != XINE_FINE_SPEED_NORMAL && !this->slow_fast_audio) ) ) { if (this->clock->speed != XINE_SPEED_PAUSE) { @@ -1085,7 +1085,7 @@ static void *ao_loop (void *this_gen) { in_buf->format.rate != this->input.rate || in_buf->format.mode != this->input.mode ) { lprintf("audio format has changed\n"); - if( !in_buf->stream->emergency_brake && + if( !in_buf->stream->emergency_brake && ao_change_settings(this, in_buf->format.bits, in_buf->format.rate, @@ -1109,7 +1109,7 @@ static void *ao_loop (void *this_gen) { delay = 0; pthread_mutex_unlock( &this->driver_lock ); - + if (in_buf && in_buf->num_frames) { xine_list_iterator_t ite; @@ -1129,8 +1129,8 @@ static void *ao_loop (void *this_gen) { } } - cur_time = this->clock->get_current_time (this->clock); - + cur_time = this->clock->get_current_time (this->clock); + /* we update current_extra_info if either there is no video stream that could do that * or if the current_extra_info is getting too much out of date */ if( in_buf && in_buf->stream && (!in_buf->stream->video_decoder_plugin || @@ -1140,9 +1140,9 @@ static void *ao_loop (void *this_gen) { _x_extra_info_merge( in_buf->stream->current_extra_info, in_buf->extra_info ); pthread_mutex_unlock( &in_buf->stream->current_extra_info_lock ); } - + /* - * where, in the timeline is the "end" of the + * where, in the timeline is the "end" of the * hardware audio buffer at the moment? */ @@ -1150,12 +1150,12 @@ static void *ao_loop (void *this_gen) { lprintf ("current delay is %" PRId64 ", current time is %" PRId64 "\n", delay, cur_time); /* External A52 decoder delay correction */ - if ((this->output.mode==AO_CAP_MODE_A52) || (this->output.mode==AO_CAP_MODE_AC5)) + if ((this->output.mode==AO_CAP_MODE_A52) || (this->output.mode==AO_CAP_MODE_AC5)) delay += this->passthrough_offset; if(this->frames_per_kpts) hw_vpts += (delay * 1024) / this->frames_per_kpts; - + /* * calculate gap: */ @@ -1191,13 +1191,13 @@ static void *ao_loop (void *this_gen) { in_buf->vpts, gap); in_buf = NULL; - - /* for small gaps ( tolerance < abs(gap) < AO_MAX_GAP ) + + /* for small gaps ( tolerance < abs(gap) < AO_MAX_GAP ) * feedback them into metronom's vpts_offset (when using * metronom feedback for A/V sync) */ } else if ( abs(gap) < AO_MAX_GAP && abs(gap) > this->gap_tolerance && - cur_time > (last_sync_time + SYNC_TIME_INVERVAL) && + cur_time > (last_sync_time + SYNC_TIME_INVERVAL) && bufs_since_sync >= SYNC_BUF_INTERVAL && !this->resample_sync_method ) { xine_list_iterator_t *ite; @@ -1250,7 +1250,7 @@ static void *ao_loop (void *this_gen) { result = 0; } fifo_remove (this->out_fifo); - + if( result < 0 ) { /* device unplugged. */ xprintf(this->xine, XINE_VERBOSITY_LOG, _("write to sound card failed. Assuming the device was unplugged.\n")); @@ -1274,7 +1274,7 @@ static void *ao_loop (void *this_gen) { pthread_mutex_unlock( &this->driver_lock ); /* closing the driver will result in XINE_MSG_AUDIO_OUT_UNAVAILABLE to be emitted */ } - + lprintf ("loop: next buf from fifo\n"); if (in_buf->stream) _x_refcounter_dec(in_buf->stream->refcounter); @@ -1327,9 +1327,9 @@ int xine_get_next_audio_frame (xine_audio_port_t *this_gen, continue; } stream = xine_list_get_value(this->streams, ite); - + /* FIXME: ugly, use conditions and locks instead? */ - + pthread_mutex_lock (&this->out_fifo->mutex); in_buf = this->out_fifo->first; if (!in_buf) { @@ -1383,10 +1383,10 @@ void xine_free_audio_frame (xine_audio_port_t *this_gen, xine_audio_frame_t *fra } static int ao_update_resample_factor(aos_t *this) { - + if( !this->driver_open ) return 0; - + switch (this->resample_conf) { case 1: /* force off */ this->do_resample = 0; @@ -1411,7 +1411,7 @@ static int ao_update_resample_factor(aos_t *this) { this->frame_rate_factor = ( XINE_FINE_SPEED_NORMAL / (double)this->current_speed ) * ((double)(this->output.rate)) / ((double)(this->input.rate)); this->frames_per_kpts = (this->output.rate * 1024) / 90000; this->audio_step = ((int64_t)90000 * (int64_t)32768) / (int64_t)this->input.rate; - + lprintf ("audio_step %" PRId64 " pts per 32768 frames\n", this->audio_step); return this->output.rate; } @@ -1420,7 +1420,7 @@ static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mod int output_sample_rate; if(this->driver_open && !this->grab_only) - this->driver->close(this->driver); + this->driver->close(this->driver); this->driver_open = 0; this->input.mode = mode; @@ -1429,7 +1429,7 @@ static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mod if (!this->grab_only) { /* not all drivers/cards support 8 bits */ - if( this->input.bits == 8 && + if( this->input.bits == 8 && !(this->driver->get_capabilities(this->driver) & AO_CAP_8BITS) ) { bits = 16; xprintf (this->xine, XINE_VERBOSITY_LOG, @@ -1449,7 +1449,7 @@ static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mod xprintf (this->xine, XINE_VERBOSITY_LOG, _("stereo not supported by driver, converting to mono.\n")); } - + output_sample_rate=(this->driver->open) (this->driver,bits,(this->force_rate ? this->force_rate : rate),mode); } else output_sample_rate = this->input.rate; @@ -1497,7 +1497,7 @@ static inline void dec_num_driver_actions(aos_t *this) { static int ao_open(xine_audio_port_t *this_gen, xine_stream_t *stream, uint32_t bits, uint32_t rate, int mode) { - + aos_t *this = (aos_t *) this_gen; int channels; @@ -1513,7 +1513,7 @@ static int ao_open(xine_audio_port_t *this_gen, xine_stream_t *stream, pthread_mutex_lock( &this->driver_lock ); ret = ao_change_settings(this, bits, rate, mode); pthread_mutex_unlock( &this->driver_lock ); - + if( !ret ) { stream->emergency_brake = 1; _x_message (stream, XINE_MSG_AUDIO_OUT_UNAVAILABLE, NULL); @@ -1524,7 +1524,7 @@ static int ao_open(xine_audio_port_t *this_gen, xine_stream_t *stream, } } - /* + /* * set metainfo */ if (stream) { @@ -1543,7 +1543,7 @@ static int ao_open(xine_audio_port_t *this_gen, xine_stream_t *stream, pthread_mutex_lock(&this->streams_lock); xine_list_push_back(this->streams, stream); pthread_mutex_unlock(&this->streams_lock); - + return this->output.rate; } @@ -1551,18 +1551,18 @@ static audio_buffer_t *ao_get_buffer (xine_audio_port_t *this_gen) { aos_t *this = (aos_t *) this_gen; audio_buffer_t *buf; - + while (!(buf = fifo_remove_nonblock (this->free_fifo))) if (this->xine->port_ticket->ticket_revoked) this->xine->port_ticket->renew(this->xine->port_ticket, 1); - + _x_extra_info_reset( buf->extra_info ); buf->stream = NULL; - + return buf; } -static void ao_put_buffer (xine_audio_port_t *this_gen, +static void ao_put_buffer (xine_audio_port_t *this_gen, audio_buffer_t *buf, xine_stream_t *stream) { aos_t *this = (aos_t *) this_gen; @@ -1575,11 +1575,11 @@ static void ao_put_buffer (xine_audio_port_t *this_gen, /* handle anonymous streams like NULL for easy checking */ if (stream == XINE_ANON_STREAM) stream = NULL; - + buf->stream = stream; - + pts = buf->vpts; - + if (stream) { buf->format.bits = _x_stream_info_get(stream, XINE_STREAM_INFO_AUDIO_BITS); buf->format.rate = _x_stream_info_get(stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE); @@ -1589,7 +1589,7 @@ static void ao_put_buffer (xine_audio_port_t *this_gen, } buf->extra_info->vpts = buf->vpts; - + lprintf ("ao_put_buffer, pts=%" PRId64 ", vpts=%" PRId64 ", flushmode=%d\n", pts, buf->vpts, this->discard_buffers); @@ -1599,7 +1599,7 @@ static void ao_put_buffer (xine_audio_port_t *this_gen, fifo_append (this->out_fifo, buf); } else fifo_append (this->free_fifo, buf); - + this->last_audio_vpts = buf->vpts; lprintf ("ao_put_buffer done\n"); @@ -1622,7 +1622,7 @@ static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { break; } } - ite = xine_list_front(this->streams); + ite = xine_list_front(this->streams); pthread_mutex_unlock(&this->streams_lock); /* close driver if no streams left */ @@ -1645,7 +1645,7 @@ static void ao_close(xine_audio_port_t *this_gen, xine_stream_t *stream) { pthread_mutex_lock( &this->driver_lock ); if(this->driver_open) - this->driver->close(this->driver); + this->driver->close(this->driver); this->driver_open = 0; pthread_mutex_unlock( &this->driver_lock ); } @@ -1655,7 +1655,7 @@ static void ao_exit(xine_audio_port_t *this_gen) { aos_t *this = (aos_t *) this_gen; int vol; int prop = 0; - + audio_buffer_t *buf, *next; if (this->audio_loop_running) { @@ -1671,15 +1671,15 @@ static void ao_exit(xine_audio_port_t *this_gen) { pthread_join (this->audio_thread, &p); this->audio_thread_created = 0; } - + if (!this->grab_only) { pthread_mutex_lock( &this->driver_lock ); - + if((this->driver->get_capabilities(this->driver)) & AO_CAP_MIXER_VOL) prop = AO_PROP_MIXER_VOL; else if((this->driver->get_capabilities(this->driver)) & AO_CAP_PCM_VOL) prop = AO_PROP_PCM_VOL; - + vol = this->driver->get_property(this->driver, prop); this->xine->config->update_num(this->xine->config, "audio.volume.mixer_volume", vol); if(this->driver_open) @@ -1701,7 +1701,7 @@ static void ao_exit(xine_audio_port_t *this_gen) { free (this->frame_buf[1]->extra_info); free (this->frame_buf[1]); free (this->zero_space); - + pthread_mutex_destroy(&this->current_speed_lock); pthread_mutex_destroy(&this->flush_audio_driver_lock); pthread_cond_destroy(&this->flush_audio_driver_reached); @@ -1735,11 +1735,11 @@ static void ao_exit(xine_audio_port_t *this_gen) { pthread_mutex_destroy(&this->free_fifo->mutex); pthread_cond_destroy(&this->free_fifo->empty); pthread_cond_destroy(&this->free_fifo->not_empty); - + pthread_mutex_destroy(&this->out_fifo->mutex); pthread_cond_destroy(&this->out_fifo->empty); pthread_cond_destroy(&this->out_fifo->not_empty); - + free (this->free_fifo); free (this->out_fifo); free (this); @@ -1748,7 +1748,7 @@ static void ao_exit(xine_audio_port_t *this_gen) { static uint32_t ao_get_capabilities (xine_audio_port_t *this_gen) { aos_t *this = (aos_t *) this_gen; uint32_t result; - + if (this->grab_only) { return AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO ; @@ -1760,7 +1760,7 @@ static uint32_t ao_get_capabilities (xine_audio_port_t *this_gen) { inc_num_driver_actions(this); pthread_mutex_lock( &this->driver_lock ); dec_num_driver_actions(this); - result=this->driver->get_capabilities(this->driver); + result=this->driver->get_capabilities(this->driver); pthread_mutex_unlock( &this->driver_lock ); } return result; @@ -1774,25 +1774,25 @@ static int ao_get_property (xine_audio_port_t *this_gen, int property) { case AO_PROP_COMPRESSOR: ret = this->compression_factor_max*100; break; - + case AO_PROP_BUFS_IN_FIFO: ret = this->audio_loop_running ? this->out_fifo->num_buffers : -1; break; - + case AO_PROP_NUM_STREAMS: pthread_mutex_lock(&this->streams_lock); ret = xine_list_size(this->streams); pthread_mutex_unlock(&this->streams_lock); break; - + case AO_PROP_AMP: ret = this->amp_factor*100; break; - + case AO_PROP_AMP_MUTE: ret = this->amp_mute; break; - + case AO_PROP_EQ_30HZ: case AO_PROP_EQ_60HZ: case AO_PROP_EQ_125HZ: @@ -1802,14 +1802,14 @@ static int ao_get_property (xine_audio_port_t *this_gen, int property) { case AO_PROP_EQ_2000HZ: case AO_PROP_EQ_4000HZ: case AO_PROP_EQ_8000HZ: - case AO_PROP_EQ_16000HZ: + case AO_PROP_EQ_16000HZ: ret = (100.0 * this->eq_gain[property - AO_PROP_EQ_30HZ]) / (1 << FP_FRBITS) ; break; case AO_PROP_DISCARD_BUFFERS: ret = this->discard_buffers; break; - + case AO_PROP_CLOCK_SPEED: ret = this->current_speed; break; @@ -1837,7 +1837,7 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value ret = this->compression_factor_max*100; break; - + case AO_PROP_AMP: this->amp_factor = (double) value / 100.0; @@ -1862,13 +1862,13 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value case AO_PROP_EQ_2000HZ: case AO_PROP_EQ_4000HZ: case AO_PROP_EQ_8000HZ: - case AO_PROP_EQ_16000HZ: + case AO_PROP_EQ_16000HZ: { int min_gain, max_gain, i; this->eq_gain[property - AO_PROP_EQ_30HZ] = EQ_REAL(((float)value / 100.0)) ; - + /* calc pregain, find out if any gain != 0.0 - enable eq if that is the case */ min_gain = EQ_REAL(0.0); max_gain = EQ_REAL(0.0); @@ -1878,7 +1878,7 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value if (this->eq_gain[i] > max_gain) max_gain = this->eq_gain[i]; } - + lprintf ("eq min_gain=%d, max_gain=%d\n", min_gain, max_gain); this->do_equ = ((min_gain != EQ_REAL(0.0)) || (max_gain != EQ_REAL(0.0))); @@ -1886,22 +1886,22 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value ret = value; } break; - + case AO_PROP_DISCARD_BUFFERS: /* recursive discard buffers setting */ if(value) this->discard_buffers++; else this->discard_buffers--; - + ret = this->discard_buffers; - + /* discard buffers here because we have no output thread */ if (this->grab_only && this->discard_buffers) { audio_buffer_t *buf; - + pthread_mutex_lock(&this->out_fifo->mutex); - + while ((buf = this->out_fifo->first)) { lprintf ("flushing out frame\n"); buf = fifo_remove_int (this->out_fifo, 1); @@ -1942,7 +1942,7 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value if( this->slow_fast_audio ) ao_update_resample_factor(this); break; - + default: if (!this->grab_only) { /* Let the sound driver lock it's own mixer */ @@ -1988,7 +1988,7 @@ static void ao_flush (xine_audio_port_t *this_gen) { pthread_mutex_lock(&this->flush_audio_driver_lock); this->discard_buffers++; this->flush_audio_driver++; - + /* do not try this in paused mode */ while( this->flush_audio_driver && this->clock->speed != XINE_SPEED_PAUSE) { struct timeval tv; @@ -2027,7 +2027,7 @@ static int ao_status (xine_audio_port_t *this_gen, xine_stream_t *stream, xine_stream_t *cur; int ret = 0; xine_list_iterator_t ite; - + pthread_mutex_lock(&this->streams_lock); for (ite = xine_list_front(this->streams); ite; ite = xine_list_next(this->streams, ite)) { @@ -2041,8 +2041,8 @@ static int ao_status (xine_audio_port_t *this_gen, xine_stream_t *stream, } } pthread_mutex_unlock(&this->streams_lock); - - return ret; + + return ret; } static void ao_update_av_sync_method(void *this_gen, xine_cfg_entry_t *entry) { @@ -2051,7 +2051,7 @@ static void ao_update_av_sync_method(void *this_gen, xine_cfg_entry_t *entry) { lprintf ("av_sync_method = %d\n", entry->num_value); this->av_sync_method_conf = entry->num_value; - + switch (this->av_sync_method_conf) { case 0: this->resample_sync_method = 0; @@ -2068,7 +2068,7 @@ static void ao_update_av_sync_method(void *this_gen, xine_cfg_entry_t *entry) { xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, int grab_only) { - + config_values_t *config = xine->config; aos_t *this; int i, err; @@ -2084,7 +2084,7 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, this->clock = xine->clock; this->current_speed = xine->clock->speed; this->streams = xine_list_new(); - + /* warning: driver_lock is a recursive mutex. it must NOT be * used with neither pthread_cond_wait() or pthread_cond_timedwait() */ @@ -2108,13 +2108,13 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, this->ao.flush = ao_flush; this->ao.status = ao_status; - this->num_driver_actions = 0; + this->num_driver_actions = 0; this->audio_loop_running = 0; this->grab_only = grab_only; this->flush_audio_driver = 0; this->discard_buffers = 0; this->zero_space = calloc (1, ZERO_BUF_SIZE * 4 * 6); /* MAX as 32bit, 6 channels. */ - + pthread_mutex_init( &this->current_speed_lock, NULL ); pthread_mutex_init( &this->flush_audio_driver_lock, NULL ); pthread_cond_init( &this->flush_audio_driver_reached, NULL ); @@ -2150,7 +2150,7 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, "an external decoder in digital form."), 20, ao_update_av_sync_method, this); config->update_num(config,"audio.synchronization.av_sync_method",this->av_sync_method_conf); - + this->resample_conf = config->register_enum (config, "audio.synchronization.resample_mode", 0, resample_modes, _("enable resampling"), @@ -2177,7 +2177,7 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, "a fixed offset here to compensate.\nThe unit of " "the value is one PTS tick, which is the 90000th " "part of a second."), 10, NULL, NULL); - + this->slow_fast_audio = config->register_bool (config, "audio.synchronization.slow_fast_audio", 0, @@ -2229,12 +2229,12 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, buf->mem = calloc (1, AUDIO_BUF_SIZE); buf->mem_size = AUDIO_BUF_SIZE; buf->extra_info = malloc(sizeof(extra_info_t)); - + fifo_append (this->free_fifo, buf); } memset (this->last_sample, 0, sizeof (this->last_sample)); - + /* buffers used for audio conversions */ for (i=0; i<2; i++) { @@ -2253,13 +2253,13 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, */ if(this->driver){ int vol; - - vol = config->register_range (config, "audio.volume.mixer_volume", - 50, 0, 100, _("startup audio volume"), + + vol = config->register_range (config, "audio.volume.mixer_volume", + 50, 0, 100, _("startup audio volume"), _("The overall audio volume set at xine startup."), 10, NULL, NULL); - + if(config->register_bool (config, "audio.volume.remember_volume", 0, - _("restore volume level at startup"), + _("restore volume level at startup"), _("If disabled, xine will not modify any mixer settings at startup."), 10, NULL, NULL)) { int prop = 0; @@ -2268,34 +2268,34 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, prop = AO_PROP_MIXER_VOL; else if((ao_get_capabilities(&this->ao)) & AO_CAP_PCM_VOL) prop = AO_PROP_PCM_VOL; - + ao_set_property(&this->ao, prop, vol); } - } - + } + if (!this->grab_only) { /* * start output thread */ - this->audio_loop_running = 1; - + this->audio_loop_running = 1; + pthread_attr_init(&pth_attrs); pthread_attr_setscope(&pth_attrs, PTHREAD_SCOPE_SYSTEM); this->audio_thread_created = 1; if ((err = pthread_create (&this->audio_thread, &pth_attrs, ao_loop, this)) != 0) { - + xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_out: can't create thread (%s)\n", strerror(err)); - xprintf (this->xine, XINE_VERBOSITY_LOG, + xprintf (this->xine, XINE_VERBOSITY_LOG, _("audio_out: sorry, this should not happen. please restart xine.\n")); _x_abort(); - + } else xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_out: thread created\n"); - + pthread_attr_destroy(&pth_attrs); } diff --git a/src/xine-engine/broadcaster.c b/src/xine-engine/broadcaster.c index 8be3dda5d..24f2ef636 100644 --- a/src/xine-engine/broadcaster.c +++ b/src/xine-engine/broadcaster.c @@ -9,7 +9,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -27,7 +27,7 @@ * - master will wait for connections on specified port, accepting new clients. * - several xine clients may connect to the server as "slaves", using mrl: * slave://master_address:port - * - streams played on master will appear on every slave. + * - streams played on master will appear on every slave. * if master is not meant to use video/audio devices it may be started with * 'xine -V none -A none' */ @@ -73,7 +73,7 @@ struct broadcaster_s { int port; /* server port */ int msock; /* master network socket */ xine_list_t *connections; /* active connections */ - + pthread_t manager_thread; pthread_mutex_t lock; @@ -87,21 +87,21 @@ static int sock_check_opened(int socket) { fd_set readfds, writefds, exceptfds; int retval; struct timeval timeout; - + for(;;) { - FD_ZERO(&readfds); - FD_ZERO(&writefds); + FD_ZERO(&readfds); + FD_ZERO(&writefds); FD_ZERO(&exceptfds); FD_SET(socket, &exceptfds); - - timeout.tv_sec = 0; + + timeout.tv_sec = 0; timeout.tv_usec = 0; - + retval = select(socket + 1, &readfds, &writefds, &exceptfds, &timeout); - + if(retval == -1 && (errno != EAGAIN && errno != EINTR)) return 0; - + if (retval != -1) return 1; } @@ -116,21 +116,21 @@ static int sock_data_write(xine_t *xine, int socket, void *buf_gen, int len) { ssize_t size; int wlen = 0; uint8_t *buf = buf_gen; - + if((socket < 0) || (buf == NULL)) return -1; - + if(!sock_check_opened(socket)) return -1; - + while(len) { size = write(socket, buf, len); - + if(size <= 0) { xprintf(xine, XINE_VERBOSITY_DEBUG, "broadcaster: error writing to socket %d\n",socket); return -1; } - + len -= size; wlen += size; buf += size; @@ -143,20 +143,20 @@ static int XINE_FORMAT_PRINTF(3, 4) sock_string_write(xine_t *xine, int socket, const char *msg, ...) { char buf[_BUFSIZ]; va_list args; - + va_start(args, msg); vsnprintf(buf, _BUFSIZ - 1, msg, args); va_end(args); - + /* Each line sent is '\n' terminated */ if((buf[strlen(buf)] == '\0') && (buf[strlen(buf) - 1] != '\n')) strcat(buf, "\n"); - + return sock_data_write(xine, socket, buf, strlen(buf)); } /* - * this is the most important broadcaster function. + * this is the most important broadcaster function. * it sends data to every connected client (slaves). */ static void broadcaster_data_write(broadcaster_t *this, void *buf, int len) { @@ -166,9 +166,9 @@ static void broadcaster_data_write(broadcaster_t *this, void *buf, int len) { while (ite) { int *psock = xine_list_get_value(this->connections, ite); - + ite = xine_list_next(this->connections, ite); - + /* in case of failure remove from list */ if( sock_data_write(this->stream->xine, *psock, buf, len) < 0 ) { @@ -185,15 +185,15 @@ static void XINE_FORMAT_PRINTF(2, 3) broadcaster_string_write(broadcaster_t *this, const char *msg, ...) { char buf[_BUFSIZ]; va_list args; - + va_start(args, msg); vsnprintf(buf, _BUFSIZ - 1, msg, args); va_end(args); - + /* Each line sent is '\n' terminated */ if((buf[strlen(buf)] == '\0') && (buf[strlen(buf) - 1] != '\n')) strcat(buf, "\n"); - + broadcaster_data_write(this, buf, strlen(buf)); } @@ -210,40 +210,40 @@ static void *manager_loop (void *this_gen) { socklen_t alen; /* from-address length */ fd_set rfds; /* read file descriptor set */ fd_set efds; /* exception descriptor set */ - + while( this->running ) { FD_ZERO(&rfds); FD_SET(this->msock, &rfds); FD_ZERO(&efds); FD_SET(this->msock, &efds); - + if (select(this->msock+1, &rfds, (fd_set *)0, &efds, (struct timeval *)0) > 0) { - + pthread_mutex_lock( &this->lock ); - + if (FD_ISSET(this->msock, &rfds)) { int ssock; alen = sizeof(fsin.in); - + ssock = accept(this->msock, &(fsin.sa), &alen); if (ssock >= 0) { /* identification string, helps demuxer probing */ if( sock_string_write(this->stream->xine, ssock,"master xine v1") > 0 ) { int *psock = malloc(sizeof(int)); *psock = ssock; - - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "broadcaster: new connection socket %d\n", *psock); xine_list_push_back(this->connections, psock); } } } - + pthread_mutex_unlock( &this->lock ); } } - + return NULL; } @@ -254,7 +254,7 @@ static void *manager_loop (void *this_gen) { */ static void send_buf (broadcaster_t *this, const char *from, buf_element_t *buf) { int i; - + /* ignore END buffers since they would stop the slavery */ if( buf->type == BUF_CONTROL_END ) return; @@ -273,7 +273,7 @@ static void send_buf (broadcaster_t *this, const char *from, buf_element_t *buf) broadcaster_data_write(this, buf->decoder_info_ptr[i], buf->decoder_info[i]); } } - + broadcaster_string_write(this, "buffer fifo=%s size=%d type=%u pts=%"PRId64" disc=%"PRId64" flags=%u", from, buf->size, buf->type, buf->pts, buf->disc_off, buf->decoder_flags ); @@ -307,7 +307,7 @@ broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port) struct sockaddr sa; } servAddr; int msock, err; - + msock = socket(PF_INET, SOCK_STREAM, 0); if( msock < 0 ) { @@ -325,7 +325,7 @@ broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port) } listen(msock,QLEN); - + signal( SIGPIPE, SIG_IGN ); this = calloc(1, sizeof(broadcaster_t)); @@ -333,23 +333,23 @@ broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port) this->stream = stream; this->msock = msock; this->connections = xine_list_new(); - + pthread_mutex_init (&this->lock, NULL); - + stream->video_fifo->register_put_cb(stream->video_fifo, video_put_cb, this); if(stream->audio_fifo) stream->audio_fifo->register_put_cb(stream->audio_fifo, audio_put_cb, this); - + this->running = 1; if ((err = pthread_create (&this->manager_thread, NULL, manager_loop, (void *)this)) != 0) { - xprintf (stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "broadcaster: can't create new thread (%s)\n", strerror(err)); _x_abort(); } - - return this; + + return this; } void _x_close_broadcaster(broadcaster_t *this) @@ -358,15 +358,15 @@ void _x_close_broadcaster(broadcaster_t *this) pthread_cancel(this->manager_thread); pthread_join(this->manager_thread,NULL); close(this->msock); - + if (this->stream->video_fifo) this->stream->video_fifo->unregister_put_cb(this->stream->video_fifo, video_put_cb); if(this->stream->audio_fifo) this->stream->audio_fifo->unregister_put_cb(this->stream->audio_fifo, audio_put_cb); - + xine_list_iterator_t ite; - + while ( (ite = xine_list_front(this->connections)) ) { int *psock = xine_list_get_value(this->connections, ite); xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "broadcaster: closing socket %d\n", *psock); @@ -383,5 +383,5 @@ void _x_close_broadcaster(broadcaster_t *this) int _x_get_broadcaster_port(broadcaster_t *this) { - return this->port; + return this->port; } diff --git a/src/xine-engine/bswap.h b/src/xine-engine/bswap.h index 635c6ae3a..f58648728 100644 --- a/src/xine-engine/bswap.h +++ b/src/xine-engine/bswap.h @@ -23,7 +23,7 @@ #include "config.h" -#define always_inline inline +#define always_inline inline #include "ffmpeg_bswap.h" @@ -98,7 +98,7 @@ ( (uint32_t)(unsigned char)(ch1) << 8 ) | \ ( (uint32_t)(unsigned char)(ch2) << 16 ) | \ ( (uint32_t)(unsigned char)(ch3) << 24 ) ) - + #ifdef WORDS_BIGENDIAN #define ME_FOURCC BE_FOURCC #else diff --git a/src/xine-engine/buffer.c b/src/xine-engine/buffer.c index bf2ea41e9..50ffb57cd 100644 --- a/src/xine-engine/buffer.c +++ b/src/xine-engine/buffer.c @@ -1,13 +1,13 @@ /* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -70,7 +70,7 @@ static void buffer_pool_free (buf_element_t *element) { fprintf(stderr, _("xine-lib: buffer.c: There has been a fatal error: TOO MANY FREE's\n")); _x_abort(); } - + pthread_cond_signal (&this->buffer_pool_cond_not_empty); pthread_mutex_unlock (&this->buffer_pool_mutex); @@ -110,7 +110,7 @@ static buf_element_t *buffer_pool_alloc (fifo_buffer_t *this) { memset(buf->decoder_info, 0, sizeof(buf->decoder_info)); memset(buf->decoder_info_ptr, 0, sizeof(buf->decoder_info_ptr)); _x_extra_info_reset( buf->extra_info ); - + return buf; } @@ -157,7 +157,7 @@ static buf_element_t *buffer_pool_try_alloc (fifo_buffer_t *this) { */ static void fifo_buffer_put (fifo_buffer_t *fifo, buf_element_t *element) { int i; - + pthread_mutex_lock (&fifo->mutex); for(i = 0; fifo->put_cb[i]; i++) @@ -183,7 +183,7 @@ static void fifo_buffer_put (fifo_buffer_t *fifo, buf_element_t *element) { */ static void dummy_fifo_buffer_put (fifo_buffer_t *fifo, buf_element_t *element) { int i; - + pthread_mutex_lock (&fifo->mutex); for(i = 0; fifo->put_cb[i]; i++) @@ -450,7 +450,7 @@ static void fifo_unregister_alloc_cb (fifo_buffer_t *this, this->alloc_cb_data[j] = this->alloc_cb_data[j+1]; } } - } + } pthread_mutex_unlock(&this->mutex); } @@ -471,7 +471,7 @@ static void fifo_unregister_put_cb (fifo_buffer_t *this, this->put_cb_data[j] = this->put_cb_data[j+1]; } } - } + } pthread_mutex_unlock(&this->mutex); } @@ -492,7 +492,7 @@ static void fifo_unregister_get_cb (fifo_buffer_t *this, this->get_cb_data[j] = this->get_cb_data[j+1]; } } - } + } pthread_mutex_unlock(&this->mutex); } diff --git a/src/xine-engine/buffer_types.c b/src/xine-engine/buffer_types.c index 9e7c8084b..4d4be3a34 100644 --- a/src/xine-engine/buffer_types.c +++ b/src/xine-engine/buffer_types.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2008 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -20,7 +20,7 @@ * * contents: * - * buffer types management. + * buffer types management. * convert FOURCC and audioformattag to BUF_xxx defines */ @@ -272,7 +272,7 @@ static const video_db_t video_db[] = { "Raw RGB" }, { - { + { /* is this right? copied from demux_qt: else if (!strncasecmp (video, "yuv2", 4)) this->video_type = BUF_VIDEO_YUY2; @@ -887,7 +887,7 @@ static const audio_db_t audio_db[] = { }, { { - 0x02, + 0x02, ME_FOURCC('m', 's', 0, 0x02), 0 }, @@ -911,7 +911,7 @@ static const audio_db_t audio_db[] = { "MS GSM" }, { - { + { /* these formattags are used by Vorbis ACM encoder and supported by NanDub, a variant of VirtualDub. */ 0x674f, 0x676f, 0x6750, 0x6770, 0x6751, 0x6771, @@ -1020,7 +1020,7 @@ static const audio_db_t audio_db[] = { ME_FOURCC('M', 'P', '4', 'A'), ME_FOURCC('r', 'a', 'a', 'c'), ME_FOURCC('r', 'a', 'c', 'p'), - ME_FOURCC('A', 'A', 'C', ' '), + ME_FOURCC('A', 'A', 'C', ' '), 0 }, BUF_AUDIO_AAC, @@ -1189,7 +1189,7 @@ static uint32_t cached_buf_type=0; if( fourcc_int == cached_fourcc ) return cached_buf_type; - + for( i = 0; video_db[i].buf_type; i++ ) { for( j = 0; video_db[i].fourcc[j]; j++ ) { if( fourcc_int == video_db[i].fourcc[j] ) { @@ -1204,9 +1204,9 @@ static uint32_t cached_buf_type=0; const char * _x_buf_video_name( uint32_t buf_type ) { int i; - + buf_type &= 0xffff0000; - + for( i = 0; video_db[i].buf_type; i++ ) { if( buf_type == video_db[i].buf_type ) { return video_db[i].name; @@ -1223,7 +1223,7 @@ static uint32_t cached_buf_type=0; if( formattag == cached_formattag ) return cached_buf_type; - + for( i = 0; audio_db[i].buf_type; i++ ) { for( j = 0; audio_db[i].formattag[j]; j++ ) { if( formattag == audio_db[i].formattag[j] ) { @@ -1238,9 +1238,9 @@ static uint32_t cached_buf_type=0; const char * _x_buf_audio_name( uint32_t buf_type ) { int i; - + buf_type &= 0xffff0000; - + for( i = 0; audio_db[i].buf_type; i++ ) { if( buf_type == audio_db[i].buf_type ) { return audio_db[i].name; @@ -1291,7 +1291,7 @@ void _x_bmiheader_le2me( xine_bmiheader *bih ) { /* OBS: fourcc must be read using machine endianness * so don't play with biCompression here! */ - + bih->biSize = le2me_32(bih->biSize); bih->biWidth = le2me_32(bih->biWidth); bih->biHeight = le2me_32(bih->biHeight); @@ -1305,7 +1305,7 @@ void _x_bmiheader_le2me( xine_bmiheader *bih ) { } void _x_waveformatex_le2me( xine_waveformatex *wavex ) { - + wavex->wFormatTag = le2me_16(wavex->wFormatTag); wavex->nChannels = le2me_16(wavex->nChannels); wavex->nSamplesPerSec = le2me_32(wavex->nSamplesPerSec); diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index a3742bb68..e014f4132 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -229,7 +229,7 @@ static int config_section_enum(const char *sect) { NULL }; int i = 0; - + while (known_section[i]) if (strcmp(sect, known_section[i++]) == 0) return i; @@ -238,7 +238,7 @@ static int config_section_enum(const char *sect) { static void config_key_split(const char *key, char **base, char **section, char **subsect, char **name) { char *parse; - + *base = strdup(key); if ((parse = strchr(*base, '.'))) { *section = *base; @@ -263,10 +263,10 @@ static void config_insert(config_values_t *this, cfg_entry_t *new_entry) { cfg_entry_t *cur, *prev; char *new_base, *new_section, *new_subsect, *new_name; char *cur_base, *cur_section, *cur_subsect, *cur_name; - + /* extract parts of the new key */ config_key_split(new_entry->key, &new_base, &new_section, &new_subsect, &new_name); - + /* search right position */ cur_base = NULL; for (cur = this->first, prev = NULL; cur; prev = cur, cur = cur->next) { @@ -274,7 +274,7 @@ static void config_insert(config_values_t *this, cfg_entry_t *new_entry) { if (cur_base) free(cur_base); config_key_split(cur->key, &cur_base, &cur_section, &cur_subsect, &cur_name); - + /* sort by section name */ if (!new_section && cur_section) break; if ( new_section && !cur_section) continue; @@ -306,14 +306,14 @@ static void config_insert(config_values_t *this, cfg_entry_t *new_entry) { if (cmp < 0) break; if (cmp > 0) continue; } - + break; } if (new_base) free(new_base); if (cur_base) free(cur_base); - + new_entry->next = cur; if (!cur) this->last = new_entry; @@ -334,7 +334,7 @@ static cfg_entry_t *XINE_MALLOC config_add (config_values_t *this, const char *k entry->unknown_value = NULL; entry->str_value = NULL; entry->exp_level = exp_level; - + config_insert(this, entry); lprintf ("add entry key=%s\n", key); @@ -401,7 +401,7 @@ static void config_lookup_entry_int (config_values_t *this, const char *key, *prev = *entry; *entry = (*entry)->next; } - + if (*entry) { free(tmp); return; @@ -424,11 +424,11 @@ static void config_lookup_entry_int (config_values_t *this, const char *key, static cfg_entry_t *config_lookup_entry(config_values_t *this, const char *key) { cfg_entry_t *entry, *prev; - + pthread_mutex_lock(&this->config_lock); config_lookup_entry_int(this, key, &entry, &prev); pthread_mutex_unlock(&this->config_lock); - + return entry; } @@ -539,7 +539,7 @@ static cfg_entry_t *config_register_string_internal (config_values_t *this, /* set string */ entry->type = XINE_CONFIG_TYPE_STRING; - + if (entry->unknown_value) entry->str_value = strdup(entry->unknown_value); else @@ -770,7 +770,7 @@ static int config_register_enum (config_values_t *this, entry->num_value = config_parse_enum (entry->unknown_value, (const char **)values); else entry->num_value = def_value; - + /* fill out rest of struct */ entry->num_default = def_value; @@ -820,7 +820,7 @@ static void config_shallow_copy(xine_cfg_entry_t *dest, cfg_entry_t *src) static void config_update_num (config_values_t *this, const char *key, int value) { - + cfg_entry_t *entry; entry = this->lookup_entry (this, key); @@ -849,13 +849,13 @@ static void config_update_num (config_values_t *this, xine_cfg_entry_t cb_entry; config_shallow_copy(&cb_entry, entry); - + /* it is safe to enter the callback from within a locked context * because we use a recursive mutex. */ entry->callback (entry->callback_data, &cb_entry); } - + pthread_mutex_unlock(&this->config_lock); } @@ -877,7 +877,7 @@ static void config_update_string (config_values_t *this, return; } - + /* if an enum is updated with a string, we convert the string to * its index and use update number */ if (entry->type == XINE_CONFIG_TYPE_ENUM) { @@ -901,7 +901,7 @@ static void config_update_string (config_values_t *this, xine_cfg_entry_t cb_entry; config_shallow_copy(&cb_entry, entry); - + /* it is safe to enter the callback from within a locked context * because we use a recursive mutex. */ @@ -943,7 +943,7 @@ void xine_config_load (xine_t *xine, const char *filename) { if (line[0] == '#') continue; - + if (line[0] == '.') { if (strncmp(line, ".version:", 9) == 0) { sscanf(line + 9, "%d", &this->current_version); @@ -1016,32 +1016,32 @@ void xine_config_save (xine_t *xine, const char *filename) { unlink (temp); if (stat(temp, &backup_stat) != 0) { - + lprintf("backing up configfile to %s\n", temp); f_backup = fopen(temp, "w"); f_config = fopen(filename, "r"); - + if (f_config && f_backup && (stat(filename, &config_stat) == 0)) { char *buf = NULL; size_t rlen; - + buf = (char *) malloc(config_stat.st_size + 1); if((rlen = fread(buf, 1, config_stat.st_size, f_config)) && ((off_t)rlen == config_stat.st_size)) { (void) fwrite(buf, 1, rlen, f_backup); } free(buf); - + fclose(f_config); fclose(f_backup); stat(temp, &backup_stat); - + if (config_stat.st_size == backup_stat.st_size) backup = 1; else unlink(temp); - - } + + } else { if (f_config) @@ -1054,17 +1054,17 @@ void xine_config_save (xine_t *xine, const char *filename) { } } - + if (!backup && (stat(filename, &config_stat) == 0)) { xprintf(xine, XINE_VERBOSITY_LOG, _("configfile: WARNING: backing up configfile to %s failed\n"), temp); xprintf(xine, XINE_VERBOSITY_LOG, _("configfile: WARNING: your configuration will not be saved\n")); return; } - + lprintf ("writing config file to %s\n", filename); f_config = fopen(filename, "w"); - + if (f_config) { cfg_entry_t *entry; @@ -1155,7 +1155,7 @@ void xine_config_save (xine_t *xine, const char *filename) { entry = entry->next; } pthread_mutex_unlock(&this->config_lock); - + if (fclose(f_config) != 0) { xprintf(xine, XINE_VERBOSITY_LOG, _("configfile: WARNING: writing configuration to %s failed\n"), filename); xprintf(xine, XINE_VERBOSITY_LOG, _("configfile: WARNING: removing possibly broken config file %s\n"), filename); @@ -1166,7 +1166,7 @@ void xine_config_save (xine_t *xine, const char *filename) { backup = 0; } } - + if (backup) unlink(temp); } @@ -1237,7 +1237,7 @@ static int put_int(uint8_t *buffer, int pos, int value) { buffer[pos + 1] = (value_int32 >> 8) & 0xFF; buffer[pos + 2] = (value_int32 >> 16) & 0xFF; buffer[pos + 3] = (value_int32 >> 24) & 0xFF; - + return 4; } @@ -1251,10 +1251,10 @@ static int put_string(uint8_t *buffer, int pos, const char *value, int value_len static char* config_get_serialized_entry (config_values_t *this, const char *key) { char *output = NULL; cfg_entry_t *entry, *prev; - + pthread_mutex_lock(&this->config_lock); config_lookup_entry_int(this, key, &entry, &prev); - + if (entry) { /* now serialize this stuff fields to serialize : @@ -1270,7 +1270,7 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key char *help; char **enum_values; */ - + int key_len = 0; int str_default_len = 0; int description_len = 0; @@ -1281,7 +1281,7 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key int value_len[10]; int pos = 0; int i; - + if (entry->key) key_len = strlen(entry->key); if (entry->str_default) @@ -1290,11 +1290,11 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key description_len = strlen(entry->description); if (entry->help) help_len = strlen(entry->help); - + /* integers */ /* value: 4 bytes */ total_len = 6 * sizeof(int32_t); - + /* strings (size + char buffer) * length: 4 bytes * buffer: length bytes @@ -1303,16 +1303,16 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key total_len += sizeof(int32_t) + str_default_len; total_len += sizeof(int32_t) + description_len; total_len += sizeof(int32_t) + help_len; - + /* enum values... * value count: 4 bytes * for each value: - * length: 4 bytes + * length: 4 bytes * buffer: length bytes */ value_count = 0; total_len += sizeof(int32_t); /* value count */ - + char **cur_value = entry->enum_values; if (cur_value) { while (*cur_value && (value_count < (sizeof(value_len) / sizeof(int) ))) { @@ -1326,9 +1326,9 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key /* Now we have the length needed to serialize the entry and the length of each string */ uint8_t *buffer = malloc (total_len); if (!buffer) return NULL; - + /* Let's go */ - + /* the integers */ pos += put_int(buffer, pos, entry->type); pos += put_int(buffer, pos, entry->range_min); @@ -1336,7 +1336,7 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key pos += put_int(buffer, pos, entry->exp_level); pos += put_int(buffer, pos, entry->num_default); pos += put_int(buffer, pos, entry->num_value); - + /* the strings */ pos += put_string(buffer, pos, entry->key, key_len); pos += put_string(buffer, pos, entry->str_default, str_default_len); @@ -1346,7 +1346,7 @@ static char* config_get_serialized_entry (config_values_t *this, const char *key /* the enum stuff */ pos += put_int(buffer, pos, value_count); cur_value = entry->enum_values; - + for (i = 0; i < value_count; i++) { pos += put_string(buffer, pos, *cur_value, value_len[i]); cur_value++; @@ -1373,7 +1373,7 @@ static int get_int(uint8_t *buffer, int buffer_size, int pos, int *value) { if ((pos + sizeof(int32_t)) > buffer_size) return 0; - + value_int32 = _X_LE_32(&buffer[pos]); *value = (int)value_int32; return sizeof(int32_t); @@ -1383,15 +1383,15 @@ static int get_string(uint8_t *buffer, int buffer_size, int pos, char **value) { int len; int bytes = get_int(buffer, buffer_size, pos, &len); *value = NULL; - + if (!bytes || (len < 0) || (len > 1024*64)) return 0; - + char *str = malloc(len + 1); pos += bytes; memcpy(str, &buffer[pos], len); str[len] = 0; - + *value = str; return bytes + len; } @@ -1422,25 +1422,25 @@ static char* config_register_serialized_entry (config_values_t *this, const char char *description = NULL; char *help = NULL; char **enum_values = NULL; - + int bytes; int pos; void *output = NULL; size_t output_len; int value_count = 0; int i; - + output_len = strlen(value) * 3 / 4 + 1; output = malloc(output_len); av_base64_decode(output, value, output_len); - + pos = 0; pos += bytes = get_int(output, output_len, pos, &type); if (!bytes) goto exit; pos += bytes = get_int(output, output_len, pos, &range_min); if (!bytes) goto exit; - + pos += bytes = get_int(output, output_len, pos, &range_max); if (!bytes) goto exit; @@ -1455,7 +1455,7 @@ static char* config_register_serialized_entry (config_values_t *this, const char pos += bytes = get_string(output, output_len, pos, &key); if (!bytes) goto exit; - + pos += bytes = get_string(output, output_len, pos, &str_default); if (!bytes) goto exit; @@ -1468,7 +1468,7 @@ static char* config_register_serialized_entry (config_values_t *this, const char pos += bytes = get_int(output, output_len, pos, &value_count); if (!bytes) goto exit; if ((value_count < 0) || (value_count > 256)) goto exit; - + enum_values = calloc (value_count + 1, sizeof(void*)); for (i = 0; i < value_count; i++) { pos += bytes = get_string(output, output_len, pos, &enum_values[i]); @@ -1476,7 +1476,7 @@ static char* config_register_serialized_entry (config_values_t *this, const char } enum_values[value_count] = NULL; -#ifdef LOG +#ifdef LOG printf("config entry deserialization:\n"); printf(" key : %s\n", key); printf(" type : %d\n", type); @@ -1489,7 +1489,7 @@ static char* config_register_serialized_entry (config_values_t *this, const char printf(" description: %s\n", description); printf(" help : %s\n", help); printf(" enum : %d values\n", value_count); - + for (i = 0; i < value_count; i++) { printf(" enum[%2d]: %s\n", i, enum_values[i]); } @@ -1625,13 +1625,13 @@ int _x_config_change_opt(config_values_t *config, const char *opt) { free(key); return -1; } - + switch(entry->type) { case XINE_CONFIG_TYPE_STRING: config->update_string(config, key, value); handled = 1; break; - + case XINE_CONFIG_TYPE_RANGE: case XINE_CONFIG_TYPE_ENUM: case XINE_CONFIG_TYPE_NUM: @@ -1639,13 +1639,13 @@ int _x_config_change_opt(config_values_t *config, const char *opt) { config->update_num(config, key, (atoi(value))); handled = 1; break; - + case XINE_CONFIG_TYPE_UNKNOWN: entry->unknown_value = strdup(value); handled = 1; break; } - + free(key); return handled; } diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c index fb4176763..f7db28e2b 100644 --- a/src/xine-engine/demux.c +++ b/src/xine-engine/demux.c @@ -50,7 +50,7 @@ #include <winsock.h> #endif -/* +/* * Flush audio and video buffers. It is called from demuxers on * seek/stop, and may be useful when user input changes a stream and * xine-lib has cached buffers that have yet to be played. @@ -62,10 +62,10 @@ void _x_demux_flush_engine (xine_stream_t *stream) { buf_element_t *buf; - + if( stream->gapless_switch ) return; - + stream->xine->port_ticket->acquire(stream->xine->port_ticket, 1); /* only flush/discard output ports on master streams */ @@ -77,23 +77,23 @@ void _x_demux_flush_engine (xine_stream_t *stream) { stream->audio_out->set_property(stream->audio_out, AO_PROP_DISCARD_BUFFERS, 1); } } - + stream->video_fifo->clear(stream->video_fifo); stream->audio_fifo->clear(stream->audio_fifo); - - pthread_mutex_lock(&stream->demux_mutex); + + pthread_mutex_lock(&stream->demux_mutex); buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo); buf->type = BUF_CONTROL_RESET_DECODER; stream->video_fifo->put (stream->video_fifo, buf); - + buf = stream->audio_fifo->buffer_pool_alloc (stream->audio_fifo); buf->type = BUF_CONTROL_RESET_DECODER; stream->audio_fifo->put (stream->audio_fifo, buf); - - pthread_mutex_unlock(&stream->demux_mutex); - /* on seeking we must wait decoder fifos to process before doing flush. + pthread_mutex_unlock(&stream->demux_mutex); + + /* on seeking we must wait decoder fifos to process before doing flush. * otherwise we flush too early (before the old data has left decoders) */ _x_demux_control_headers_done (stream); @@ -102,7 +102,7 @@ void _x_demux_flush_engine (xine_stream_t *stream) { video_overlay_manager_t *ovl = stream->video_out->get_overlay_manager(stream->video_out); ovl->flush_events(ovl); } - + /* only flush/discard output ports on master streams */ if( stream->master == stream ) { if (stream->video_out) { @@ -115,7 +115,7 @@ void _x_demux_flush_engine (xine_stream_t *stream) { stream->audio_out->set_property(stream->audio_out, AO_PROP_DISCARD_BUFFERS, 0); } } - + stream->xine->port_ticket->release(stream->xine->port_ticket, 1); } @@ -151,8 +151,8 @@ static struct timespec _x_compute_interval(unsigned int millisecs) { void _x_demux_control_newpts( xine_stream_t *stream, int64_t pts, uint32_t flags ) { buf_element_t *buf; - - pthread_mutex_lock(&stream->demux_mutex); + + pthread_mutex_lock(&stream->demux_mutex); buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo); buf->type = BUF_CONTROL_NEWPTS; @@ -166,7 +166,7 @@ void _x_demux_control_newpts( xine_stream_t *stream, int64_t pts, uint32_t flags buf->disc_off = pts; stream->audio_fifo->put (stream->audio_fifo, buf); - pthread_mutex_unlock(&stream->demux_mutex); + pthread_mutex_unlock(&stream->demux_mutex); } /* avoid ao_loop being stuck in a pthread_cond_wait, waiting for data; @@ -201,7 +201,7 @@ void _x_demux_control_headers_done (xine_stream_t *stream) { /* we use demux_action_pending to wake up sleeping spu decoders */ stream->demux_action_pending = 1; - + /* allocate the buffers before grabbing the lock to prevent cyclic wait situations */ buf_video = stream->video_fifo->buffer_pool_alloc (stream->video_fifo); buf_audio = stream->audio_fifo->buffer_pool_alloc (stream->audio_fifo); @@ -219,8 +219,8 @@ void _x_demux_control_headers_done (xine_stream_t *stream) { } else { header_count_audio = 0; } - - pthread_mutex_lock(&stream->demux_mutex); + + pthread_mutex_lock(&stream->demux_mutex); buf_video->type = BUF_CONTROL_HEADERS_DONE; stream->video_fifo->put (stream->video_fifo, buf_video); @@ -228,24 +228,24 @@ void _x_demux_control_headers_done (xine_stream_t *stream) { buf_audio->type = BUF_CONTROL_HEADERS_DONE; stream->audio_fifo->put (stream->audio_fifo, buf_audio); - pthread_mutex_unlock(&stream->demux_mutex); + pthread_mutex_unlock(&stream->demux_mutex); unsigned int max_iterations = 0; - while ((stream->header_count_audio < header_count_audio) || + while ((stream->header_count_audio < header_count_audio) || (stream->header_count_video < header_count_video)) { lprintf ("waiting for headers. v:%d %d a:%d %d\n", stream->header_count_video, header_count_video, - stream->header_count_audio, header_count_audio); - - struct timespec ts = _x_compute_interval(1000); + stream->header_count_audio, header_count_audio); + + struct timespec ts = _x_compute_interval(1000); int ret_wait; /* use timedwait to workaround buggy pthread broadcast implementations */ ret_wait = pthread_cond_timedwait (&stream->counter_changed, &stream->counter_lock, &ts); if (ret_wait == ETIMEDOUT && demux_unstick_ao_loop (stream) && ++max_iterations > 4) { - xine_log(stream->xine, + xine_log(stream->xine, XINE_LOG_MSG,_("Stuck in _x_demux_control_headers_done(). Taking the emergency exit\n")); stream->emergency_brake = 1; break; @@ -254,7 +254,7 @@ void _x_demux_control_headers_done (xine_stream_t *stream) { stream->demux_action_pending = 0; pthread_cond_signal(&stream->demux_resume); - + lprintf ("headers processed.\n"); pthread_mutex_unlock (&stream->counter_lock); @@ -265,7 +265,7 @@ void _x_demux_control_start( xine_stream_t *stream ) { buf_element_t *buf; uint32_t flags = (stream->gapless_switch) ? BUF_FLAG_GAPLESS_SW : 0; - pthread_mutex_lock(&stream->demux_mutex); + pthread_mutex_lock(&stream->demux_mutex); buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo); buf->type = BUF_CONTROL_START; @@ -277,14 +277,14 @@ void _x_demux_control_start( xine_stream_t *stream ) { buf->decoder_flags = flags; stream->audio_fifo->put (stream->audio_fifo, buf); - pthread_mutex_unlock(&stream->demux_mutex); + pthread_mutex_unlock(&stream->demux_mutex); } void _x_demux_control_end( xine_stream_t *stream, uint32_t flags ) { buf_element_t *buf; - pthread_mutex_lock(&stream->demux_mutex); + pthread_mutex_lock(&stream->demux_mutex); buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo); buf->type = BUF_CONTROL_END; @@ -296,26 +296,26 @@ void _x_demux_control_end( xine_stream_t *stream, uint32_t flags ) { buf->decoder_flags = flags; stream->audio_fifo->put (stream->audio_fifo, buf); - pthread_mutex_unlock(&stream->demux_mutex); + pthread_mutex_unlock(&stream->demux_mutex); } void _x_demux_control_nop( xine_stream_t *stream, uint32_t flags ) { buf_element_t *buf; - pthread_mutex_lock(&stream->demux_mutex); + pthread_mutex_lock(&stream->demux_mutex); buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo); buf->type = BUF_CONTROL_NOP; buf->decoder_flags = flags; stream->video_fifo->put (stream->video_fifo, buf); - + buf = stream->audio_fifo->buffer_pool_alloc (stream->audio_fifo); buf->type = BUF_CONTROL_NOP; buf->decoder_flags = flags; stream->audio_fifo->put (stream->audio_fifo, buf); - pthread_mutex_unlock(&stream->demux_mutex); + pthread_mutex_unlock(&stream->demux_mutex); } static void *demux_loop (void *stream_gen) { @@ -330,7 +330,7 @@ static void *demux_loop (void *stream_gen) { pthread_mutex_lock( &stream->demux_lock ); stream->emergency_brake = 0; - + /* do-while needed to seek after demux finished */ do { @@ -349,7 +349,7 @@ static void *demux_loop (void *stream_gen) { gettimeofday(&tv, NULL); ts.tv_sec = tv.tv_sec; ts.tv_nsec = (tv.tv_usec + 100000) * 1000; - + pthread_cond_timedwait (&stream->demux_resume, &stream->demux_lock, &ts); } } @@ -398,7 +398,7 @@ static void *demux_loop (void *stream_gen) { /* demux_thread_running is zero if demux loop has been stopped by user */ non_user = stream->demux_thread_running; stream->demux_thread_running = 0; - + _x_demux_control_end(stream, non_user); lprintf ("loop finished, end buffer sent\n"); @@ -409,7 +409,7 @@ static void *demux_loop (void *stream_gen) { struct timespec ts; unsigned int max_iterations = 0; int ret_wait; - while ((stream->finished_count_audio < finished_count_audio) || + while ((stream->finished_count_audio < finished_count_audio) || (stream->finished_count_video < finished_count_video)) { lprintf ("waiting for finisheds.\n"); ts = _x_compute_interval(1000); @@ -423,7 +423,7 @@ static void *demux_loop (void *stream_gen) { } } pthread_mutex_unlock (&stream->counter_lock); - + _x_handle_stream_end(stream, non_user); return NULL; } @@ -431,14 +431,14 @@ static void *demux_loop (void *stream_gen) { int _x_demux_start_thread (xine_stream_t *stream) { int err; - + lprintf ("start thread called\n"); - + stream->demux_action_pending = 1; pthread_mutex_lock( &stream->demux_lock ); stream->demux_action_pending = 0; pthread_cond_signal(&stream->demux_resume); - + if( !stream->demux_thread_running ) { if (stream->demux_thread_created) { @@ -454,17 +454,17 @@ int _x_demux_start_thread (xine_stream_t *stream) { _x_abort(); } } - + pthread_mutex_unlock( &stream->demux_lock ); return 0; } int _x_demux_stop_thread (xine_stream_t *stream) { - + void *p; - + lprintf ("stop thread called\n"); - + stream->demux_action_pending = 1; pthread_mutex_lock( &stream->demux_lock ); stream->demux_thread_running = 0; @@ -478,12 +478,12 @@ int _x_demux_stop_thread (xine_stream_t *stream) { pthread_mutex_unlock( &stream->demux_lock ); lprintf ("joining thread %ld\n", stream->demux_thread ); - + if( stream->demux_thread_created ) { pthread_join (stream->demux_thread, &p); stream->demux_thread_created = 0; } - + /* * Wake up xine_play if it's waiting for a frame */ @@ -634,7 +634,7 @@ int _x_action_pending (xine_stream_t *stream) { * * the other ones help enforcing that demuxers provide the information * they have about the stream, so things like the GUI slider bar can - * work as expected. + * work as expected. */ void _x_demux_send_data(fifo_buffer_t *fifo, uint8_t *data, int size, int64_t pts, uint32_t type, uint32_t decoder_flags, @@ -682,10 +682,10 @@ void _x_demux_send_data(fifo_buffer_t *fifo, uint8_t *data, int size, * * If reading fails, -1 is returned */ -int _x_demux_read_send_data(fifo_buffer_t *fifo, input_plugin_t *input, - int size, int64_t pts, uint32_t type, - uint32_t decoder_flags, off_t input_normpos, - int input_time, int total_time, +int _x_demux_read_send_data(fifo_buffer_t *fifo, input_plugin_t *input, + int size, int64_t pts, uint32_t type, + uint32_t decoder_flags, off_t input_normpos, + int input_time, int total_time, uint32_t frame_number) { buf_element_t *buf; @@ -707,7 +707,7 @@ int _x_demux_read_send_data(fifo_buffer_t *fifo, input_plugin_t *input, if(input->read(input, buf->content, buf->size) < buf->size) { buf->free_buffer(buf); - return -1; + return -1; } size -= buf->size; @@ -723,7 +723,7 @@ int _x_demux_read_send_data(fifo_buffer_t *fifo, input_plugin_t *input, fifo->put (fifo, buf); } - + return 0; } @@ -750,7 +750,7 @@ void _x_demux_send_mrl_reference (xine_stream_t *stream, int alternative, event.data_length = offsetof (xine_mrl_reference_data_ext_t, mrl) + mrl_len + strlen (title) + 2; data.e = event.data = malloc (event.data_length); - + data.e->alternative = alternative; data.e->start_time = start_time; data.e->duration = duration; diff --git a/src/xine-engine/events.c b/src/xine-engine/events.c index bf0d88fae..3c2c28f6d 100644 --- a/src/xine-engine/events.c +++ b/src/xine-engine/events.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -94,7 +94,7 @@ void xine_event_send (xine_stream_t *stream, const xine_event_t *event) { cevent->data = NULL; } gettimeofday (&cevent->tv, NULL); - + pthread_mutex_lock (&queue->lock); xine_list_push_back (queue->events, cevent); pthread_cond_signal (&queue->new_event); @@ -135,7 +135,7 @@ void xine_event_dispose_queue (xine_event_queue_t *queue) { xine_event_t *qevent; xine_event_queue_t *q; xine_list_iterator_t ite; - + pthread_mutex_lock (&stream->event_queues_lock); ite = xine_list_front (stream->event_queues); @@ -144,7 +144,7 @@ void xine_event_dispose_queue (xine_event_queue_t *queue) { if ( ite ) { do { q = xine_list_get_value (stream->event_queues, ite); - + if ( q == queue ) break; } while( (ite = xine_list_next (stream->event_queues, ite)) ); @@ -160,17 +160,17 @@ void xine_event_dispose_queue (xine_event_queue_t *queue) { xine_list_remove (stream->event_queues, ite); pthread_mutex_unlock (&stream->event_queues_lock); - /* - * send quit event + /* + * send quit event */ qevent = (xine_event_t *)malloc(sizeof(xine_event_t)); - + qevent->type = XINE_EVENT_QUIT; qevent->stream = stream; qevent->data = NULL; qevent->data_length = 0; gettimeofday (&qevent->tv, NULL); - + pthread_mutex_lock (&queue->lock); xine_list_push_back (queue->events, qevent); pthread_cond_signal (&queue->new_event); @@ -179,15 +179,15 @@ void xine_event_dispose_queue (xine_event_queue_t *queue) { /* * join listener thread, if any */ - + if (queue->listener_thread) { void *p; pthread_join (*queue->listener_thread, &p); free (queue->listener_thread); } - + /* - * clean up pending events + * clean up pending events */ while ( (event = xine_event_get (queue)) ) { @@ -233,7 +233,7 @@ static void *listener_loop (void *queue_gen) { } -void xine_event_create_listener_thread (xine_event_queue_t *queue, +void xine_event_create_listener_thread (xine_event_queue_t *queue, xine_event_listener_cb_t callback, void *user_data) { int err; diff --git a/src/xine-engine/info_helper.c b/src/xine-engine/info_helper.c index 2b09dcd3b..93fc2173d 100644 --- a/src/xine-engine/info_helper.c +++ b/src/xine-engine/info_helper.c @@ -40,7 +40,7 @@ /* ******************* Stream Info *************************** */ /* - * Compare stream_info, private and public values, + * Compare stream_info, private and public values, * return 1 if it's identical, otherwirse 0. */ static int stream_info_is_identical(xine_stream_t *stream, int info) { @@ -105,7 +105,7 @@ uint32_t _x_stream_info_get(xine_stream_t *stream, int info) { pthread_mutex_lock(&stream->info_mutex); stream_info = stream->stream_info[info]; pthread_mutex_unlock(&stream->info_mutex); - + return stream_info; } @@ -120,7 +120,7 @@ uint32_t _x_stream_info_get_public(xine_stream_t *stream, int info) { if(info_valid(info) && (!stream_info_is_identical(stream, info))) stream_info = stream->stream_info_public[info] = stream->stream_info[info]; pthread_mutex_unlock(&stream->info_mutex); - + return stream_info; } @@ -137,7 +137,7 @@ static void meta_info_chomp(char *str) { if (!len) return; i = len - 1; - + while ((i >= 0) && ((unsigned char)str[i] <= 32)) { str[i] = 0; i--; @@ -145,13 +145,13 @@ static void meta_info_chomp(char *str) { } /* - * Compare stream_info, public and private values, + * Compare stream_info, public and private values, * return 1 if it's identical, otherwise 0. */ static int meta_info_is_identical(xine_stream_t *stream, int info) { - + if((!(stream->meta_info_public[info] && stream->meta_info[info])) || - ((stream->meta_info_public[info] && stream->meta_info[info]) && + ((stream->meta_info_public[info] && stream->meta_info[info]) && strcmp(stream->meta_info_public[info], stream->meta_info[info]))) return 0; @@ -175,7 +175,7 @@ static int meta_valid(int info) { */ static void meta_info_set_unlocked_utf8(xine_stream_t *stream, int info, const char *value) { if(meta_valid(info)) { - + if(stream->meta_info[info]) free(stream->meta_info[info]); @@ -275,7 +275,7 @@ static void meta_info_set_unlocked_encoding(xine_stream_t *stream, int info, con } } #endif - + meta_info_set_unlocked_utf8(stream, info, value); } @@ -349,7 +349,7 @@ void _x_meta_info_n_set(xine_stream_t *stream, int info, const char *buf, int le pthread_mutex_lock(&stream->meta_mutex); if(meta_valid(info) && len) { char *str = strndup(buf, len); - + meta_info_set_unlocked(stream, info, str); free(str); } @@ -367,7 +367,7 @@ void _x_meta_info_set_multi(xine_stream_t *stream, int info, ...) { char *args[1025]; char *buf; size_t n, len; - + len = n = 0; va_start(ap, info); @@ -377,32 +377,32 @@ void _x_meta_info_set_multi(xine_stream_t *stream, int info, ...) { n++; } va_end(ap); - + args[n] = NULL; - + if(len) { char *p, *meta; - + p = meta = (char *) malloc(len + 1); - + n = 0; while(args[n]) { strcpy(meta, args[n]); meta += strlen(args[n]) + 1; n++; } - + *meta = '\0'; if(stream->meta_info[info]) free(stream->meta_info[info]); - + stream->meta_info[info] = p; - + if(stream->meta_info[info] && strlen(stream->meta_info[info])) meta_info_chomp(stream->meta_info[info]); } - + } pthread_mutex_unlock(&stream->meta_mutex); } @@ -412,11 +412,11 @@ void _x_meta_info_set_multi(xine_stream_t *stream, int info, ...) { */ const char *_x_meta_info_get(xine_stream_t *stream, int info) { const char *meta_info = NULL; - + pthread_mutex_lock(&stream->meta_mutex); meta_info = stream->meta_info[info]; pthread_mutex_unlock(&stream->meta_mutex); - + return meta_info; } @@ -430,13 +430,13 @@ const char *_x_meta_info_get_public(xine_stream_t *stream, int info) { meta_info = stream->meta_info_public[info]; if(meta_valid(info) && (!meta_info_is_identical(stream, info))) { meta_info_public_reset_unlocked(stream, info); - + if(stream->meta_info[info]) stream->meta_info_public[info] = strdup(stream->meta_info[info]); meta_info = stream->meta_info_public[info]; } pthread_mutex_unlock(&stream->meta_mutex); - + return meta_info; } diff --git a/src/xine-engine/input_cache.c b/src/xine-engine/input_cache.c index eafd397d7..40aaba660 100644 --- a/src/xine-engine/input_cache.c +++ b/src/xine-engine/input_cache.c @@ -19,7 +19,7 @@ * * Buffered Input Plugin (request optimizer). * - * The goal of this input plugin is to reduce + * The goal of this input plugin is to reduce * the number of calls to the real input plugin. */ @@ -59,7 +59,7 @@ typedef struct { } cache_input_plugin_t; -/* +/* * read data from input plugin and write it into file */ static off_t cache_plugin_read(input_plugin_t *this_gen, void *buf_gen, off_t len) { @@ -130,13 +130,13 @@ static off_t cache_plugin_read(input_plugin_t *this_gen, void *buf_gen, off_t le /* readahead bytes */ main_read = this->main_input_plugin->read(this->main_input_plugin, this->buf, this->buf_size); this->main_read_call++; - + if( main_read >= 0 ) { this->buf_len = main_read; - + if (len > this->buf_len) len = this->buf_len; - + if (len) { xine_fast_memcpy(buf + read_len, this->buf, len); this->buf_pos = len; @@ -150,7 +150,7 @@ static off_t cache_plugin_read(input_plugin_t *this_gen, void *buf_gen, off_t le /* direct read */ main_read = this->main_input_plugin->read(this->main_input_plugin, buf + read_len, len); this->main_read_call++; - + if( main_read >= 0 ) read_len += main_read; else @@ -158,7 +158,7 @@ static off_t cache_plugin_read(input_plugin_t *this_gen, void *buf_gen, off_t le read_len = main_read; } } - + return read_len; } @@ -192,7 +192,7 @@ static buf_element_t *cache_plugin_read_block(input_plugin_t *this_gen, fifo_buf buf = fifo->buffer_pool_alloc (fifo); if (buf) { buf->type = BUF_DEMUX_BLOCK; - + assert(todo <= buf->max_size); read_len = cache_plugin_read (this_gen, buf->content, todo); buf->size = read_len; @@ -228,11 +228,11 @@ static off_t cache_plugin_seek(input_plugin_t *this_gen, off_t offset, int origi case SEEK_CUR: rel_offset = offset; break; - + case SEEK_SET: rel_offset = offset - cur_pos; break; - + default: /* invalid origin - main input should know better */ cur_pos = this->main_input_plugin->seek(this->main_input_plugin, offset, origin); @@ -240,16 +240,16 @@ static off_t cache_plugin_seek(input_plugin_t *this_gen, off_t offset, int origi this->main_seek_call++; return cur_pos; } - + new_buf_pos = (off_t)this->buf_pos + rel_offset; lprintf("buf_len: %d, rel_offset=%"PRId64", new_buf_pos=%"PRId64"\n", - this->buf_len, rel_offset, new_buf_pos); - + this->buf_len, rel_offset, new_buf_pos); + if ((new_buf_pos < 0) || (new_buf_pos >= this->buf_len)) { if( origin == SEEK_SET ) cur_pos = this->main_input_plugin->seek(this->main_input_plugin, offset, origin); else - cur_pos = this->main_input_plugin->seek(this->main_input_plugin, + cur_pos = this->main_input_plugin->seek(this->main_input_plugin, offset - (this->buf_len - this->buf_pos), origin); this->buf_len = this->buf_pos = 0; this->main_seek_call++; @@ -264,7 +264,7 @@ static off_t cache_plugin_seek(input_plugin_t *this_gen, off_t offset, int origi static off_t cache_plugin_seek_time(input_plugin_t *this_gen, int time_offset, int origin) { cache_input_plugin_t *this = (cache_input_plugin_t *)this_gen; off_t cur_pos; - + lprintf("time_offset: %d, origin: %d\n", time_offset, origin); this->seek_call++; @@ -277,7 +277,7 @@ static off_t cache_plugin_seek_time(input_plugin_t *this_gen, int time_offset, i static off_t cache_plugin_get_current_pos(input_plugin_t *this_gen) { cache_input_plugin_t *this = (cache_input_plugin_t *)this_gen; off_t cur_pos; - + cur_pos = this->main_input_plugin->get_current_pos(this->main_input_plugin); if( this->buf_len ) { if( cur_pos >= (this->buf_len - this->buf_pos) ) @@ -292,7 +292,7 @@ static off_t cache_plugin_get_current_pos(input_plugin_t *this_gen) { static int cache_plugin_get_current_time(input_plugin_t *this_gen) { cache_input_plugin_t *this = (cache_input_plugin_t *)this_gen; int cur_time; - + cur_time = this->main_input_plugin->get_current_time(this->main_input_plugin); return cur_time; @@ -316,7 +316,7 @@ static const char* cache_plugin_get_mrl (input_plugin_t *this_gen) { return this->main_input_plugin->get_mrl(this->main_input_plugin); } -static int cache_plugin_get_optional_data (input_plugin_t *this_gen, +static int cache_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { cache_input_plugin_t *this = (cache_input_plugin_t *)this_gen; @@ -324,8 +324,8 @@ static int cache_plugin_get_optional_data (input_plugin_t *this_gen, this->main_input_plugin, data, data_type); } -/* - * dispose main input plugin and self +/* + * dispose main input plugin and self */ static void cache_plugin_dispose(input_plugin_t *this_gen) { cache_input_plugin_t *this = (cache_input_plugin_t *)this_gen; @@ -343,8 +343,8 @@ static void cache_plugin_dispose(input_plugin_t *this_gen) { } -/* - * create self instance, +/* + * create self instance, */ input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream) { cache_input_plugin_t *this; @@ -361,7 +361,7 @@ input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream) { this = calloc(1, sizeof(cache_input_plugin_t)); if (!this) return NULL; - + this->main_input_plugin = main_plugin; this->stream = stream; diff --git a/src/xine-engine/input_rip.c b/src/xine-engine/input_rip.c index bfa68786d..c1cbbf043 100644 --- a/src/xine-engine/input_rip.c +++ b/src/xine-engine/input_rip.c @@ -20,12 +20,12 @@ * Rip Input Plugin for catching streams * * It saves raw data into file as go from input plugins. - * + * * Usage: * * - activation: * xine stream_mrl#save:file.raw - * + * * - it's possible speeder saving streams in the xine without playing: * xine stream_mrl#save:file.raw\;noaudio\;novideo */ @@ -96,7 +96,7 @@ static off_t min_off(off_t a, off_t b) { return a <= b ? a : b; } -/* +/* * read data from input plugin and write it into file */ static off_t rip_plugin_read(input_plugin_t *this_gen, void *buf_gen, off_t len) { @@ -125,7 +125,7 @@ static off_t rip_plugin_read(input_plugin_t *this_gen, void *buf_gen, off_t len) npreview = 0; nread = min_off(this->savepos - this->curpos, len); } - + /* size to write into file */ nwrite = len - npreview - nread; /* size to read from file */ @@ -151,7 +151,7 @@ static off_t rip_plugin_read(input_plugin_t *this_gen, void *buf_gen, off_t len) lprintf("%s => returned %"PRId64"" CLR_RST "\n", retlen == nread_orig + nwrite ? "" : CLR_FAIL, retlen); if (retlen < 0) { - xine_log(this->stream->xine, XINE_LOG_MSG, + xine_log(this->stream->xine, XINE_LOG_MSG, _("input_rip: reading by input plugin failed\n")); return -1; } @@ -165,10 +165,10 @@ static off_t rip_plugin_read(input_plugin_t *this_gen, void *buf_gen, off_t len) } this->savepos += nwrite; lprintf(" => saved %"PRId64" bytes\n", nwrite); - } else + } else nwrite = 0; } - + this->curpos += (npreview + nread + nwrite); return npreview + nread + nwrite; @@ -193,7 +193,7 @@ static uint32_t rip_plugin_get_capabilities(input_plugin_t *this_gen) { uint32_t caps; caps = this->main_input_plugin->get_capabilities(this->main_input_plugin); - + if (this->regular) caps |= INPUT_CAP_SEEKABLE; @@ -201,11 +201,11 @@ static uint32_t rip_plugin_get_capabilities(input_plugin_t *this_gen) { return caps; } -/* +/* * read a block of data from input plugin and write it into file * * This rip plugin returns block unchanged from main input plugin. But special - * cases are reading over preview or reading already saved data - it returns + * cases are reading over preview or reading already saved data - it returns * own allocated block. */ static buf_element_t *rip_plugin_read_block(input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t todo) { @@ -232,7 +232,7 @@ static buf_element_t *rip_plugin_read_block(input_plugin_t *this_gen, fifo_buffe npreview = 0; nread = min_off(this->savepos - this->curpos, todo); } - + /* size to write into file */ nwrite = todo - npreview - nread; /* size to read from file */ @@ -251,7 +251,7 @@ static buf_element_t *rip_plugin_read_block(input_plugin_t *this_gen, fifo_buffe lprintf(" => get %"PRId64" bytes from the preview (block)\n", npreview); memcpy(buf->content, &this->preview[this->curpos], npreview); } - + /* re-reading from the file */ if (nread_file) { lprintf(" => read %"PRId64" bytes from the file (block)\n", nread_file); @@ -288,17 +288,17 @@ static buf_element_t *rip_plugin_read_block(input_plugin_t *this_gen, fifo_buffe if (retlen > nread_orig) { nwrite = retlen - nread_orig; if (fwrite(buf->content + this->savepos - this->curpos, nwrite, 1, this->file) != 1) { - xine_log(this->stream->xine, XINE_LOG_MSG, + xine_log(this->stream->xine, XINE_LOG_MSG, _("input_rip: error writing to file %" PRIdMAX " bytes: %s\n"), (intmax_t)(retlen - nread_orig), strerror(errno)); return NULL; } this->savepos += nwrite; lprintf(" => saved %"PRId64" bytes\n", nwrite); - } else + } else nwrite = 0; } - + this->curpos += (npreview + nread + nwrite); buf->size = npreview + nread + nwrite; @@ -325,11 +325,11 @@ static off_t rip_seek_original(rip_input_plugin_t *this, off_t reqpos) { return pos; } - + /* * seek in RIP - * - * If we are seeking back and we can read from saved file, + * + * If we are seeking back and we can read from saved file, * position of original input plugin isn't changed. */ static off_t rip_plugin_seek(input_plugin_t *this_gen, off_t offset, int origin) { @@ -341,7 +341,7 @@ static off_t rip_plugin_seek(input_plugin_t *this_gen, off_t offset, int origin) double interval = 0; lprintf("seek, offset %"PRId64", origin %d (curpos %"PRId64", savepos %"PRId64")\n", offset, origin, this->curpos, this->savepos); - + switch (origin) { case SEEK_SET: newpos = offset; break; case SEEK_CUR: newpos = this->curpos + offset; break; @@ -378,7 +378,7 @@ static off_t rip_plugin_seek(input_plugin_t *this_gen, off_t offset, int origin) if ((pos = rip_seek_original(this, reqpos)) == -1) return -1; if (pos == reqpos) this->curpos = newpos; } - + return this->curpos; } @@ -395,7 +395,7 @@ static off_t rip_plugin_seek(input_plugin_t *this_gen, off_t offset, int origin) if ((pos = rip_seek_original(this, this->savepos)) == -1) return -1; if (pos > this->savepos) xine_log(this->stream->xine, XINE_LOG_MSG, - _("input_rip: %" PRIdMAX " bytes dropped\n"), + _("input_rip: %" PRIdMAX " bytes dropped\n"), (intmax_t)(pos - this->savepos)); } } @@ -427,13 +427,13 @@ static off_t rip_plugin_seek(input_plugin_t *this_gen, off_t offset, int origin) } lprintf(" => new position %"PRId64"\n", this->curpos); - + return this->curpos; } static off_t rip_plugin_seek_time(input_plugin_t *this_gen, int time_offset, int origin) { rip_input_plugin_t *this = (rip_input_plugin_t *)this_gen; - + lprintf("seek_time, time_offset: %d, origin: %d\n", time_offset, origin); return this->main_input_plugin->seek_time(this->main_input_plugin, time_offset, origin); @@ -453,13 +453,13 @@ static off_t rip_plugin_get_current_pos(input_plugin_t *this_gen) { lprintf(CLR_FAIL "position: computed = %"PRId64", input plugin = %"PRId64"" CLR_RST "\n", this->curpos, pos); } #endif - + return this->curpos; } static int rip_plugin_get_current_time(input_plugin_t *this_gen) { rip_input_plugin_t *this = (rip_input_plugin_t *)this_gen; - + return this->main_input_plugin->get_current_time(this->main_input_plugin); } @@ -486,7 +486,7 @@ static const char* rip_plugin_get_mrl (input_plugin_t *this_gen) { return this->main_input_plugin->get_mrl(this->main_input_plugin); } -static int rip_plugin_get_optional_data (input_plugin_t *this_gen, +static int rip_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) { rip_input_plugin_t *this = (rip_input_plugin_t *)this_gen; @@ -496,11 +496,11 @@ static int rip_plugin_get_optional_data (input_plugin_t *this_gen, return this->preview_size; } else return this->main_input_plugin->get_optional_data( - this->main_input_plugin, data, data_type); + this->main_input_plugin, data, data_type); } -/* - * dispose main input plugin and self +/* + * dispose main input plugin and self */ static void rip_plugin_dispose(input_plugin_t *this_gen) { rip_input_plugin_t *this = (rip_input_plugin_t *)this_gen; @@ -542,8 +542,8 @@ static int dir_file_concat(char *target, size_t maxlen, const char *dir, const c } -/* - * create self instance, +/* + * create self instance, * target file for writing stream is specified in 'data' */ input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *filename) { @@ -573,7 +573,7 @@ input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *f #ifndef SAVING_ALWAYS_PERMIT if ( main_plugin->get_capabilities(main_plugin) & INPUT_CAP_RIP_FORBIDDEN ) { - xine_log(stream->xine, XINE_LOG_MSG, + xine_log(stream->xine, XINE_LOG_MSG, _("input_rip: ripping/caching of this source is not permitted!\n")); _x_message(stream, XINE_MSG_SECURITY, _("xine is not allowed to save from this source. (possibly copyrighted material?)"), NULL); @@ -594,7 +594,7 @@ input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *f fnc = strdup(filename); target_basename = basename(fnc); - dir_file_concat(target, MAX_TARGET_LEN, stream->xine->save_path, + dir_file_concat(target, MAX_TARGET_LEN, stream->xine->save_path, target_basename); strcpy(target_no, target); @@ -623,7 +623,7 @@ input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *f lprintf("target file: %s\n", target_no); if ((this->file = fopen(target_no, mode)) == NULL) { - xine_log(this->stream->xine, XINE_LOG_MSG, + xine_log(this->stream->xine, XINE_LOG_MSG, _("input_rip: error opening file %s: %s\n"), target_no, strerror(errno)); free(this); return NULL; @@ -641,7 +641,7 @@ input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *f this->preview_size = buf->size; this->preview = malloc(this->preview_size); memcpy(this->preview, buf->content, this->preview_size); - + buf->free_buffer(buf); } else { this->preview = malloc(MAX_PREVIEW_SIZE); @@ -653,7 +653,7 @@ input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *f if (this->preview && this->preview_size) { if (fwrite(this->preview, this->preview_size, 1, this->file) != 1) { - xine_log(this->stream->xine, XINE_LOG_MSG, + xine_log(this->stream->xine, XINE_LOG_MSG, _("input_rip: error writing to file %" PRIdMAX " bytes: %s\n"), (intmax_t)(this->preview_size), strerror(errno)); fclose(this->file); diff --git a/src/xine-engine/io_helper.c b/src/xine-engine/io_helper.c index d51feb4c6..34540a208 100644 --- a/src/xine-engine/io_helper.c +++ b/src/xine-engine/io_helper.c @@ -53,14 +53,14 @@ static int _x_io_tcp_connect_ipv4(xine_stream_t *stream, const char *host, int p struct hostent *h; int i, s; - + h = gethostbyname(host); if (h == NULL) { _x_message(stream, XINE_MSG_UNKNOWN_HOST, "unable to resolve", host, NULL); return -1; } - s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (s == -1) { _x_message(stream, XINE_MSG_CONNECTION_REFUSED, "failed to create socket", strerror(errno), NULL); return -1; @@ -88,12 +88,12 @@ static int _x_io_tcp_connect_ipv4(xine_stream_t *stream, const char *host, int p for (i = 0; h->h_addr_list[i]; i++) { struct in_addr ia; struct sockaddr_in sin; - + memcpy (&ia, h->h_addr_list[i], 4); sin.sin_family = AF_INET; sin.sin_addr = ia; sin.sin_port = htons(port); - + #ifndef WIN32 if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && errno != EINPROGRESS) { #else @@ -106,7 +106,7 @@ static int _x_io_tcp_connect_ipv4(xine_stream_t *stream, const char *host, int p close(s); continue; } - + return s; } return -1; @@ -122,10 +122,10 @@ int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port) { struct addrinfo hints, *res, *tmpaddr; int error; char strport[16]; - + memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; - hints.ai_family = PF_UNSPEC; + hints.ai_family = PF_UNSPEC; snprintf(strport, sizeof(strport), "%d", port); @@ -135,7 +135,7 @@ int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port) { error = getaddrinfo(host, strport, &hints, &res); if (error) { - _x_message(stream, XINE_MSG_UNKNOWN_HOST, + _x_message(stream, XINE_MSG_UNKNOWN_HOST, "unable to resolve", host, NULL); return -1; } @@ -143,10 +143,10 @@ int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port) { tmpaddr = res; while (tmpaddr) { - - s = socket(tmpaddr->ai_family, SOCK_STREAM, IPPROTO_TCP); + + s = socket(tmpaddr->ai_family, SOCK_STREAM, IPPROTO_TCP); if (s == -1) { - _x_message(stream, XINE_MSG_CONNECTION_REFUSED, + _x_message(stream, XINE_MSG_CONNECTION_REFUSED, "failed to create socket", strerror(errno), NULL); tmpaddr = tmpaddr->ai_next; continue; @@ -177,12 +177,12 @@ int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port) { } #ifndef WIN32 - if (connect(s, tmpaddr->ai_addr, + if (connect(s, tmpaddr->ai_addr, tmpaddr->ai_addrlen)==-1 && errno != EINPROGRESS) { - + #else - if (connect(s, tmpaddr->ai_addr, - tmpaddr->ai_addrlen)==-1 && + if (connect(s, tmpaddr->ai_addr, + tmpaddr->ai_addrlen)==-1 && WSAGetLastError() != WSAEWOULDBLOCK) { if (stream) @@ -196,12 +196,12 @@ int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port) { } else { return s; } - + tmpaddr = tmpaddr->ai_next; } _x_message(stream, XINE_MSG_CONNECTION_REFUSED, strerror(error), NULL); - + return -1; #endif } @@ -302,14 +302,14 @@ int _x_io_select (xine_stream_t *stream, int fd, int state, int timeout_msec) { */ int _x_io_tcp_connect_finish(xine_stream_t *stream, int fd, int timeout_msec) { int ret; - + ret = _x_io_select(stream, fd, XIO_WRITE_READY, timeout_msec); /* find out, if connection is successfull */ if (ret == XIO_READY) { socklen_t len = sizeof(int); int err; - + if ((getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&err, &len)) == -1) { _x_message(stream, XINE_MSG_CONNECTION_REFUSED, _("failed to get status of socket"), strerror(errno), NULL); return XIO_ERROR; @@ -347,14 +347,14 @@ static off_t xio_rw_abort(xine_stream_t *stream, int fd, int cmd, void *buf_gen, } else { timeout = 30000; /* 30K msecs = 30 secs */ } - + while (total < todo) { sret = _x_io_select(stream, fd, state, timeout); - + if (sret != XIO_READY) return -1; - + switch (cmd) { case XIO_FILE_READ: ret = read(fd, &buf[total], todo - total); @@ -404,7 +404,7 @@ static off_t xio_rw_abort(xine_stream_t *stream, int fd, int cmd, void *buf_gen, if (stream) xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "io_helper: WSAGetLastError() = %d\n", WSAGetLastError()); #endif - + return ret; } total += ret; diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 3f563dd62..3fdd65d93 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -109,7 +109,7 @@ static const int plugin_iface_versions[] = { SPU_DECODER_IFACE_VERSION, AUDIO_OUT_IFACE_VERSION, VIDEO_OUT_DRIVER_IFACE_VERSION, - POST_PLUGIN_IFACE_VERSION + POST_PLUGIN_IFACE_VERSION }; static void _build_list_typed_plugins(plugin_catalog_t **catalog, xine_sarray_t *type) { @@ -120,7 +120,7 @@ static void _build_list_typed_plugins(plugin_catalog_t **catalog, xine_sarray_t list_size = xine_sarray_size (type); for (list_id = 0, i = 0; list_id < list_size; list_id++) { node = xine_sarray_get(type, list_id); - + /* add only unique ids to the list */ for ( j = 0; j < i; j++ ) { if( !strcmp((*catalog)->ids[j], node->info->id) ) @@ -165,9 +165,9 @@ static int get_decoder_priority(xine_t *this, plugin_node_t *node) { char key[80]; snprintf(key, sizeof(key), "engine.decoder_priorities.%s", node->info->id); - + entry = this->config->lookup_entry(this->config, key); - + if (entry && entry->num_value) /* user given priorities should definitely override defaults, so multiply them */ return entry->num_value * 100; @@ -266,14 +266,14 @@ static plugin_node_t *_get_cached_node (xine_t *this, node->file->filesize == filesize && node->file->filemtime == filemtime && !strcmp( node->file->filename, filename )) { - + return node; } - + /* skip previously returned items */ if( node == previous_node ) previous_node = NULL; - + } return NULL; } @@ -327,7 +327,7 @@ static void _insert_node (xine_t *this, _x_assert(list); _x_assert(info); if (info->API != api_version) { - xprintf(this, XINE_VERBOSITY_LOG, + xprintf(this, XINE_VERBOSITY_LOG, _("load_plugins: ignoring plugin %s, wrong iface version %d (should be %d)\n"), info->id, info->API, api_version); return; @@ -385,7 +385,7 @@ static void _insert_node (xine_t *this, decoder_new->supported_types = types; } entry->priority = decoder_new->priority = decoder_old->priority; - + snprintf(key, sizeof(key), "engine.decoder_priorities.%s", info->id); for (i = 0; catalog->prio_desc[i]; i++); asprintf(&catalog->prio_desc[i], _("priority for %s decoder"), info->id); @@ -404,23 +404,23 @@ static void _insert_node (xine_t *this, entry->info->special_info = decoder_new; break; - + case PLUGIN_POST: post_old = info->special_info; post_new = calloc(1, sizeof(post_info_t)); post_new->type = post_old->type; entry->info->special_info = post_new; break; - + case PLUGIN_DEMUX: demux_old = info->special_info; demux_new = calloc(1, sizeof(demuxer_info_t)); - + if (demux_old) { entry->priority = demux_new->priority = demux_old->priority; lprintf("demux: %s, priority: %d\n", info->id, entry->priority); } else { - xprintf(this, XINE_VERBOSITY_LOG, + xprintf(this, XINE_VERBOSITY_LOG, _("load_plugins: demuxer plugin %s does not provide a priority," " xine-lib will use the default priority.\n"), info->id); @@ -432,12 +432,12 @@ static void _insert_node (xine_t *this, case PLUGIN_INPUT: input_old = info->special_info; input_new = calloc(1, sizeof(input_info_t)); - + if (input_old) { entry->priority = input_new->priority = input_old->priority; lprintf("input: %s, priority: %d\n", info->id, entry->priority); } else { - xprintf(this, XINE_VERBOSITY_LOG, + xprintf(this, XINE_VERBOSITY_LOG, _("load_plugins: input plugin %s does not provide a priority," " xine-lib will use the default priority.\n"), info->id); @@ -499,7 +499,7 @@ static void _register_plugins_internal(xine_t *this, plugin_file_t *file, else xine_log (this, XINE_LOG_PLUGIN, _("load_plugins: static plugin found\n")); - + if (this->plugin_catalog->plugin_count >= PLUGIN_MAX || (this->plugin_catalog->decoder_count >= DECODER_MAX && info->type >= PLUGIN_AUDIO_DECODER && info->type <= PLUGIN_SPU_DECODER)) { @@ -533,7 +533,7 @@ static void _register_plugins_internal(xine_t *this, plugin_file_t *file, } this->plugin_catalog->plugin_count++; } - + /* get next info */ if( file && !file->lib_handle ) { lprintf("get cached info\n"); @@ -573,7 +573,7 @@ static void collect_plugins(xine_t *this, char *path){ void *lib = NULL; plugin_info_t *info = NULL; plugin_node_t *node = NULL; - + struct stat statbuffer; size_t d_len = strlen(pEntry->d_name); @@ -627,7 +627,7 @@ static void collect_plugins(xine_t *this, char *path){ if(!info && (lib = dlopen (str, RTLD_LAZY | RTLD_GLOBAL)) == NULL) { const char *error = dlerror(); /* too noisy -- but good to catch unresolved references */ - xprintf(this, XINE_VERBOSITY_LOG, + xprintf(this, XINE_VERBOSITY_LOG, _("load_plugins: cannot open plugin lib %s:\n%s\n"), str, error); } else { @@ -670,14 +670,14 @@ static void collect_plugins(xine_t *this, char *path){ * generic 2nd stage plugin loader */ -static inline int _plugin_info_equal(const plugin_info_t *a, +static inline int _plugin_info_equal(const plugin_info_t *a, const plugin_info_t *b) { - if (a->type != b->type || + if (a->type != b->type || a->API != b->API || strcasecmp(a->id, b->id) || a->version != b->version) return 0; - + switch (a->type & PLUGIN_TYPE_MASK) { case PLUGIN_VIDEO_OUT: /* FIXME: Could special_info be NULL? */ @@ -686,16 +686,16 @@ static inline int _plugin_info_equal(const plugin_info_t *a, ((vo_info_t*)b->special_info)->visual_type); } break; - + default: break; } - + return 1; } static void _attach_entry_to_node (plugin_node_t *node, char *key) { - + if (!node->config_entry_list) { node->config_entry_list = xine_list_new(); } @@ -709,7 +709,7 @@ static void _attach_entry_to_node (plugin_node_t *node, char *key) { */ static void _new_entry_cb (void *user_data, xine_cfg_entry_t *entry) { plugin_node_t *node = (plugin_node_t *)user_data; - + _attach_entry_to_node(node, strdup(entry->key)); } @@ -760,7 +760,7 @@ static int _load_plugin_class(xine_t *this, info++; } lprintf("plugin not found\n"); - + } else { xine_log (this, XINE_LOG_PLUGIN, _("load_plugins: Yikes! %s doesn't contain plugin info.\n"), filename); @@ -828,7 +828,7 @@ static void _load_required_plugins(xine_t *this, xine_sarray_t *list) { list_size = xine_sarray_size(list); while (list_id < list_size) { plugin_node_t *node = xine_sarray_get(list, list_id); - + /* * preload plugins if not cached */ @@ -897,12 +897,12 @@ static void save_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *list) { fprintf(fp, "visual_type=%d\n", vo_info->visual_type ); fprintf(fp, "vo_priority=%d\n", vo_info->priority ); break; - + case PLUGIN_AUDIO_OUT: ao_info = node->info->special_info; fprintf(fp, "ao_priority=%d\n", ao_info->priority ); break; - + case PLUGIN_AUDIO_DECODER: case PLUGIN_VIDEO_DECODER: case PLUGIN_SPU_DECODER: @@ -973,11 +973,11 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) { char *value; size_t line_len; int version_ok = 0; - + line = malloc(LINE_MAX_LENGTH); if (!line) return; - + node = NULL; file = NULL; while (fgets (line, LINE_MAX_LENGTH, fp)) { @@ -986,7 +986,7 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) { line_len = strlen(line); if (line_len < 3) continue; - + value = &line[line_len - 1]; if( (*value == '\r') || (*value == '\n') ) *value-- = (char) 0; /* eliminate any cr/lf */ @@ -1024,7 +1024,7 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) { if( i == CACHE_CATALOG_VERSION ) version_ok = 1; else - return; + return; } } else if (node) { if( !strcmp("size",line) ) { @@ -1036,19 +1036,19 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) { } else if( !strcmp("type",line) ) { sscanf(value," %d",&i); node->info->type = i; - + switch (node->info->type & PLUGIN_TYPE_MASK){ - + case PLUGIN_VIDEO_OUT: node->info->special_info = vo_info = calloc(1, sizeof(vo_info_t)); break; - + case PLUGIN_AUDIO_OUT: node->info->special_info = ao_info = calloc(1, sizeof(ao_info_t)); break; - + case PLUGIN_DEMUX: node->info->special_info = demuxer_info = calloc(1, sizeof(demuxer_info_t)); @@ -1065,13 +1065,13 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) { node->info->special_info = decoder_info = calloc(1, sizeof(decoder_info_t)); break; - + case PLUGIN_POST: node->info->special_info = post_info = calloc(1, sizeof(post_info_t)); break; - } - + } + } else if( !strcmp("api",line) ) { sscanf(value," %d",&i); node->info->API = i; @@ -1086,7 +1086,7 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) { } else if( !strcmp("supported_types",line) && decoder_info ) { char *s; uint32_t *supported_types; - + for( s = value, i = 0; s && sscanf(s," %lu",&lu) > 0; i++ ) { s = strchr(s+1, ' '); } @@ -1115,7 +1115,7 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) { post_info->type = lu; } else if( !strcmp("config_key",line) ) { char* cfg_key; - + cfg_key = this->config->register_serialized_entry(this->config, value); if (cfg_key) { /* this node is a cached node */ @@ -1127,11 +1127,11 @@ static void load_plugin_list(xine_t *this, FILE *fp, xine_sarray_t *plugins) { } } } - + if( node ) { xine_sarray_add (plugins, node); } - + free (line); } @@ -1203,7 +1203,7 @@ static void save_catalog (xine_t *this) { if( (fp = fopen(cachefile_new,"w")) != NULL ) { int i; - + fprintf(fp, "# this file is automatically created by xine, do not edit.\n\n"); fprintf(fp, "cache_catalog_version=%d\n\n", CACHE_CATALOG_VERSION); @@ -1270,7 +1270,7 @@ void _x_scan_plugins (xine_t *this) { char *homedir, *pluginpath; xine_list_t *plugindirs = xine_list_new (); xine_list_iterator_t iter; - + lprintf("_x_scan_plugins()\n"); if (this == NULL || this->config == NULL) { @@ -1325,7 +1325,7 @@ void _x_scan_plugins (xine_t *this) { free(homedir); load_required_plugins (this); - + XINE_PROFILE(save_catalog (this)); map_decoders (this); @@ -1355,7 +1355,7 @@ input_plugin_t *_x_find_input_plugin (xine_stream_t *stream, const char *mrl) { plugin->node = node; break; } - } + } } pthread_mutex_unlock (&catalog->lock); @@ -1449,7 +1449,7 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth /* ... then try the extension */ stream->content_detection_method = methods[i]; - if ( stream->content_detection_method == METHOD_BY_MRL && + if ( stream->content_detection_method == METHOD_BY_MRL && ! _x_demux_check_extension(input->get_mrl(input), ((demux_class_t *)node->plugin_class)->extensions) ) @@ -1515,7 +1515,7 @@ demux_plugin_t *_x_find_demux_plugin_by_name(xine_stream_t *stream, const char * if (strcasecmp(node->info->id, name) == 0) { if (node->plugin_class || _load_plugin_class(stream->xine, node, NULL)) { - if ( stream->content_detection_method == METHOD_BY_MRL && + if ( stream->content_detection_method == METHOD_BY_MRL && ! _x_demux_check_extension(input->get_mrl(input), ((demux_class_t *)node->plugin_class)->extensions) ) @@ -1575,17 +1575,17 @@ demux_plugin_t *_x_find_demux_plugin_last_probe(xine_stream_t *stream, const cha if (strcasecmp(node->info->id, last_demux_name) == 0) { last_demux = node; } else { - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "load_plugin: probing '%s' (method %d)...\n", node->info->id, stream->content_detection_method ); if (node->plugin_class || _load_plugin_class(xine, node, NULL)) { - if ( stream->content_detection_method == METHOD_BY_MRL && + if ( stream->content_detection_method == METHOD_BY_MRL && ! _x_demux_check_extension(input->get_mrl(input), ((demux_class_t *)node->plugin_class)->extensions) ) continue; - + if ((plugin = ((demux_class_t *)node->plugin_class)->open_plugin(node->plugin_class, stream, input))) { xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "load_plugins: using demuxer '%s' (instead of '%s')\n", node->info->id, last_demux_name); @@ -1692,7 +1692,7 @@ const char *const *xine_get_browsable_input_plugin_ids(xine_t *this) { for (list_id = 0; list_id < list_size; list_id++) { input_class_t *ic; - + node = xine_sarray_get(catalog->plugin_lists[PLUGIN_INPUT - 1], list_id); if (node->plugin_class || _load_plugin_class(this, node, NULL)) { @@ -1751,7 +1751,7 @@ vo_driver_t *_x_load_video_output_plugin(xine_t *this, if (id && !strcasecmp(id, "auto")) id = NULL; - + pthread_mutex_lock (&catalog->lock); list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1]); @@ -1799,7 +1799,7 @@ xine_video_port_t *xine_open_video_driver (xine_t *this, } port = _x_vo_new_port(this, driver, 0); - + return port; } @@ -1838,7 +1838,7 @@ xine_video_port_t *xine_new_framegrab_video_port (xine_t *this) { } port = _x_vo_new_port(this, driver, 1); - + return port; } @@ -1848,7 +1848,7 @@ xine_video_port_t *xine_new_framegrab_video_port (xine_t *this) { const char *const *xine_list_audio_output_plugins (xine_t *xine) { plugin_catalog_t *catalog = xine->plugin_catalog; - + pthread_mutex_lock (&catalog->lock); _build_list_typed_plugins(&catalog, catalog->plugin_lists[PLUGIN_AUDIO_OUT - 1]); pthread_mutex_unlock (&catalog->lock); @@ -1858,7 +1858,7 @@ const char *const *xine_list_audio_output_plugins (xine_t *xine) { const char *const *xine_list_video_output_plugins (xine_t *xine) { plugin_catalog_t *catalog = xine->plugin_catalog; - + pthread_mutex_lock (&catalog->lock); _build_list_typed_plugins(&catalog, catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1]); pthread_mutex_unlock (&catalog->lock); @@ -1871,7 +1871,7 @@ const char *const *xine_list_video_output_plugins_typed(xine_t *xine, uint64_t t plugin_catalog_t *catalog = xine->plugin_catalog; plugin_node_t *node; int list_id, list_size, i; - + pthread_mutex_lock (&catalog->lock); list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1]); @@ -1958,7 +1958,7 @@ xine_audio_port_t *xine_open_audio_driver (xine_t *this, const char *id, if (id && !strcasecmp(id, "auto") ) id = NULL; - + pthread_mutex_lock (&catalog->lock); driver = NULL; @@ -1984,13 +1984,13 @@ xine_audio_port_t *xine_open_audio_driver (xine_t *this, const char *id, } pthread_mutex_unlock (&catalog->lock); - + if (!driver) { if (id) xprintf (this, XINE_VERBOSITY_LOG, _("load_plugins: failed to load audio output plugin <%s>\n"), id); else - xprintf (this, XINE_VERBOSITY_LOG, + xprintf (this, XINE_VERBOSITY_LOG, _("load_plugins: audio output auto-probing didn't find any usable audio driver.\n")); return NULL; } @@ -2048,7 +2048,7 @@ char **xine_get_autoplay_mrls (xine_t *this, const char *plugin_id, if (node->plugin_class || _load_plugin_class (this, node, NULL)) { ic = (input_class_t *) node->plugin_class; - + if (!ic->get_autoplay_list) return NULL; @@ -2082,7 +2082,7 @@ xine_mrl_t **xine_get_browse_mrls (xine_t *this, const char *plugin_id, if (node->plugin_class || _load_plugin_class (this, node, NULL)) { ic = (input_class_t *) node->plugin_class; - + if (!ic->get_dir) return NULL; @@ -2114,7 +2114,7 @@ video_decoder_t *_x_get_video_decoder (xine_stream_t *stream, uint8_t stream_typ if (!node->plugin_class && !_load_plugin_class (stream->xine, node, NULL)) { /* remove non working plugin from catalog */ - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "load_plugins: plugin %s failed to init its class.\n", node->info->id); for (j = i + 1; j < PLUGINS_PER_TYPE; j++) catalog->video_decoder_map[stream_type][j - 1] = @@ -2130,9 +2130,9 @@ video_decoder_t *_x_get_video_decoder (xine_stream_t *stream, uint8_t stream_typ inc_node_ref(node); vd->node = node; xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "load_plugins: plugin %s will be used for video streamtype %02x.\n", + "load_plugins: plugin %s will be used for video streamtype %02x.\n", node->info->id, stream_type); - + break; } else { /* remove non working plugin from catalog */ @@ -2185,7 +2185,7 @@ audio_decoder_t *_x_get_audio_decoder (xine_stream_t *stream, uint8_t stream_typ if (!node->plugin_class && !_load_plugin_class (stream->xine, node, NULL)) { /* remove non working plugin from catalog */ - xprintf(stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "load_plugins: plugin %s failed to init its class.\n", node->info->id); for (j = i + 1; j < PLUGINS_PER_TYPE; j++) catalog->audio_decoder_map[stream_type][j - 1] = @@ -2201,7 +2201,7 @@ audio_decoder_t *_x_get_audio_decoder (xine_stream_t *stream, uint8_t stream_typ inc_node_ref(node); ad->node = node; xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "load_plugins: plugin %s will be used for audio streamtype %02x.\n", + "load_plugins: plugin %s will be used for audio streamtype %02x.\n", node->info->id, stream_type); break; } else { @@ -2241,11 +2241,11 @@ int _x_decoder_available (xine_t *xine, uint32_t buftype) if ( (buftype & 0xFF000000) == BUF_VIDEO_BASE ) { if( catalog->video_decoder_map[stream_type][0] ) return 1; - } else + } else if ( (buftype & 0xFF000000) == BUF_AUDIO_BASE ) { if( catalog->audio_decoder_map[stream_type][0] ) return 1; - } else + } else if ( (buftype & 0xFF000000) == BUF_SPU_BASE ) { if( catalog->spu_decoder_map[stream_type][0] ) return 1; @@ -2272,7 +2272,7 @@ static void _display_file_plugin_list (xine_list_t *list, plugin_file_t *file) { #endif static void _unload_unref_plugins(xine_t *this, xine_sarray_t *list) { - + plugin_node_t *node; int list_id, list_size; @@ -2310,7 +2310,7 @@ void xine_plugins_garbage_collector(xine_t *self) { pthread_mutex_lock (&catalog->lock); for(i = 0; i < PLUGIN_TYPE_MAX; i++) { _unload_unref_plugins(self, self->plugin_catalog->plugin_lists[i]); - } + } #if 0 { @@ -2372,7 +2372,7 @@ spu_decoder_t *_x_get_spu_decoder (xine_stream_t *stream, uint8_t stream_type) { inc_node_ref(node); sd->node = node; xprintf(stream->xine, XINE_VERBOSITY_DEBUG, - "load_plugins: plugin %s will be used for spu streamtype %02x.\n", + "load_plugins: plugin %s will be used for spu streamtype %02x.\n", node->info->id, stream_type); break; } else { @@ -2406,7 +2406,7 @@ void _x_free_spu_decoder (xine_stream_t *stream, spu_decoder_t *sd) { const char *const *xine_list_demuxer_plugins(xine_t *xine) { plugin_catalog_t *catalog = xine->plugin_catalog; - + pthread_mutex_lock (&catalog->lock); _build_list_typed_plugins(&catalog, catalog->plugin_lists[PLUGIN_DEMUX - 1]); pthread_mutex_unlock (&catalog->lock); @@ -2416,7 +2416,7 @@ const char *const *xine_list_demuxer_plugins(xine_t *xine) { const char *const *xine_list_input_plugins(xine_t *xine) { plugin_catalog_t *catalog = xine->plugin_catalog; - + pthread_mutex_lock (&catalog->lock); _build_list_typed_plugins(&catalog, catalog->plugin_lists[PLUGIN_INPUT - 1]); pthread_mutex_unlock (&catalog->lock); @@ -2426,7 +2426,7 @@ const char *const *xine_list_input_plugins(xine_t *xine) { const char *const *xine_list_spu_plugins(xine_t *xine) { plugin_catalog_t *catalog = xine->plugin_catalog; - + pthread_mutex_lock (&catalog->lock); _build_list_typed_plugins(&catalog, catalog->plugin_lists[PLUGIN_SPU_DECODER - 1]); pthread_mutex_unlock (&catalog->lock); @@ -2436,7 +2436,7 @@ const char *const *xine_list_spu_plugins(xine_t *xine) { const char *const *xine_list_audio_decoder_plugins(xine_t *xine) { plugin_catalog_t *catalog = xine->plugin_catalog; - + pthread_mutex_lock (&catalog->lock); _build_list_typed_plugins(&catalog, catalog->plugin_lists[PLUGIN_AUDIO_DECODER - 1]); pthread_mutex_unlock (&catalog->lock); @@ -2446,7 +2446,7 @@ const char *const *xine_list_audio_decoder_plugins(xine_t *xine) { const char *const *xine_list_video_decoder_plugins(xine_t *xine) { plugin_catalog_t *catalog = xine->plugin_catalog; - + pthread_mutex_lock (&catalog->lock); _build_list_typed_plugins(&catalog, catalog->plugin_lists[PLUGIN_VIDEO_DECODER - 1]); pthread_mutex_unlock (&catalog->lock); @@ -2456,7 +2456,7 @@ const char *const *xine_list_video_decoder_plugins(xine_t *xine) { const char *const *xine_list_post_plugins(xine_t *xine) { plugin_catalog_t *catalog = xine->plugin_catalog; - + pthread_mutex_lock (&catalog->lock); _build_list_typed_plugins(&catalog, catalog->plugin_lists[PLUGIN_POST - 1]); pthread_mutex_unlock (&catalog->lock); @@ -2469,7 +2469,7 @@ const char *const *xine_list_post_plugins_typed(xine_t *xine, uint32_t type) { plugin_node_t *node; int i; int list_id, list_size; - + pthread_mutex_lock (&catalog->lock); i = 0; @@ -2524,25 +2524,25 @@ xine_post_t *xine_post_init(xine_t *xine, const char *name, int inputs, plugin_node_t *node; post_plugin_t *post = NULL; int list_id, list_size; - + if( !name ) return NULL; - + pthread_mutex_lock(&catalog->lock); - + list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_POST - 1]); for (list_id = 0; list_id < list_size; list_id++) { node = xine_sarray_get (catalog->plugin_lists[PLUGIN_POST - 1], list_id); - + if (strcmp(node->info->id, name) == 0) { - + if (!node->plugin_class && !_load_plugin_class(xine, node, NULL)) { xprintf(xine, XINE_VERBOSITY_DEBUG, "load_plugins: requested post plugin %s failed to load\n", name); break; } - + post = ((post_class_t *)node->plugin_class)->open_plugin(node->plugin_class, inputs, audio_target, video_target); @@ -2551,12 +2551,12 @@ xine_post_t *xine_post_init(xine_t *xine, const char *name, int inputs, xine_post_out_t *output; xine_list_iterator_t ite; int i; - + post->running_ticket = xine->port_ticket; post->xine = xine; post->node = node; inc_node_ref(node); - + /* init the lists of announced connections */ i = 0; ite = xine_list_front(post->input); @@ -2574,7 +2574,7 @@ xine_post_t *xine_post_init(xine_t *xine, const char *name, int inputs, ite = xine_list_next (post->input, ite); } post->input_ids[i] = NULL; - + i = 0; ite = xine_list_front (post->output); while (ite) { @@ -2591,10 +2591,10 @@ xine_post_t *xine_post_init(xine_t *xine, const char *name, int inputs, ite = xine_list_next (post->output, ite); } post->output_ids[i] = NULL; - + /* copy the post plugin type to the public part */ post->xine_post.type = ((post_info_t *)node->info->special_info)->type; - + break; } else { xprintf(xine, XINE_VERBOSITY_DEBUG, @@ -2603,9 +2603,9 @@ xine_post_t *xine_post_init(xine_t *xine, const char *name, int inputs, } } } - + pthread_mutex_unlock(&catalog->lock); - + if(post) return &post->xine_post; else { @@ -2647,7 +2647,7 @@ static char *_x_concatenate_with_string(char const **strings, size_t count, char } /* get a list of file extensions for file types supported by xine - * the list is separated by spaces + * the list is separated by spaces * * the pointer returned can be free()ed when no longer used */ char *xine_get_file_extensions (xine_t *self) { @@ -2675,7 +2675,7 @@ char *xine_get_file_extensions (xine_t *self) { /* create output string */ char *const result = _x_concatenate_with_string(extensions, list_size, " ", len); free(extensions); - + /* Drop the last whitespace */ result[len-1] = '\0'; @@ -2698,7 +2698,7 @@ char *xine_get_mime_types (xine_t *self) { /* calc length of output string and create an array of strings to concatenate */ - size_t len = 0; + size_t len = 0; const int list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]); const char **mimetypes = calloc(list_size, sizeof(char*)); @@ -2759,7 +2759,7 @@ static void dispose_plugin_list (xine_sarray_t *list, int is_cache) { int list_id, list_size; if (list) { - + list_size = xine_sarray_size (list); for (list_id = 0; list_id < list_size; list_id++) { @@ -2780,12 +2780,12 @@ static void dispose_plugin_list (xine_sarray_t *list, int is_cache) { decoder_info = (decoder_info_t *)node->info->special_info; free (decoder_info->supported_types); - + default: free ((void *)node->info->special_info); break; } - + /* free info structure and string copies */ free (node->info->id); free (node->info); diff --git a/src/xine-engine/lrb.c b/src/xine-engine/lrb.c index 6c624143c..9acc2f1b6 100644 --- a/src/xine-engine/lrb.c +++ b/src/xine-engine/lrb.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -29,7 +29,7 @@ lrb_t *lrb_new (int max_num_entries, fifo_buffer_t *fifo) { lrb_t *this; - + this = calloc(1, sizeof(lrb_t)); this->max_num_entries = max_num_entries; @@ -42,7 +42,7 @@ lrb_t *lrb_new (int max_num_entries, } void lrb_drop (lrb_t *this) { - + buf_element_t *buf = this->oldest; _x_assert(buf); @@ -67,7 +67,7 @@ void lrb_add (lrb_t *this, buf_element_t *buf) { } else { - if (this->cur_num_entries >= this->max_num_entries) + if (this->cur_num_entries >= this->max_num_entries) lrb_drop (this); buf->next = NULL; @@ -94,7 +94,7 @@ void lrb_feedback (lrb_t *this, fifo_buffer_t *fifo) { if (!fifo->last) fifo->last = buf; - + fifo->fifo_size++; pthread_cond_signal (&fifo->not_empty); @@ -114,6 +114,6 @@ void lrb_feedback (lrb_t *this, fifo_buffer_t *fifo) { } void lrb_flush (lrb_t *this) { - while (this->cur_num_entries) + while (this->cur_num_entries) lrb_drop (this); } diff --git a/src/xine-engine/lrb.h b/src/xine-engine/lrb.h index 0f524b7eb..dfac5e543 100644 --- a/src/xine-engine/lrb.h +++ b/src/xine-engine/lrb.h @@ -1,18 +1,18 @@ /* * Copyright (C) 2001-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index bd4c1e42f..3d44ce39a 100644 --- a/src/xine-engine/metronom.c +++ b/src/xine-engine/metronom.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -46,7 +46,7 @@ #define MAX_AUDIO_DELTA 1600 #define AUDIO_SAMPLE_NUM 32768 -#define WRAP_THRESHOLD 120000 +#define WRAP_THRESHOLD 120000 #define MAX_NUM_WRAP_DIFF 10 #define MAX_SCR_PROVIDERS 10 #define VIDEO_DRIFT_TOLERANCE 45000 @@ -63,7 +63,7 @@ /* * **************************************** - * primary SCR plugin: + * primary SCR plugin: * unix System Clock Reference * **************************************** */ @@ -88,19 +88,19 @@ static void unixscr_set_pivot (unixscr_t *this) { struct timeval tv; int64_t pts; - double pts_calc; + double pts_calc; xine_monotonic_clock(&tv, NULL); pts_calc = (tv.tv_sec - this->cur_time.tv_sec) * this->speed_factor; pts_calc += (tv.tv_usec - this->cur_time.tv_usec) * this->speed_factor / 1e6; pts = this->cur_pts + pts_calc; -/* This next part introduces a one off inaccuracy - * to the scr due to rounding tv to pts. +/* This next part introduces a one off inaccuracy + * to the scr due to rounding tv to pts. */ this->cur_time.tv_sec=tv.tv_sec; this->cur_time.tv_usec=tv.tv_usec; - this->cur_pts=pts; + this->cur_pts=pts; return ; } @@ -141,7 +141,7 @@ static void unixscr_start (scr_plugin_t *scr, int64_t start_vpts) { this->cur_pts = start_vpts; pthread_mutex_unlock (&this->lock); - + unixscr_set_speed (&this->scr, XINE_FINE_SPEED_NORMAL); } @@ -150,16 +150,16 @@ static int64_t unixscr_get_current (scr_plugin_t *scr) { struct timeval tv; int64_t pts; - double pts_calc; + double pts_calc; pthread_mutex_lock (&this->lock); xine_monotonic_clock(&tv, NULL); - + pts_calc = (tv.tv_sec - this->cur_time.tv_sec) * this->speed_factor; pts_calc += (tv.tv_usec - this->cur_time.tv_usec) * this->speed_factor / 1e6; pts = this->cur_pts + pts_calc; - + pthread_mutex_unlock (&this->lock); return pts; @@ -176,7 +176,7 @@ static scr_plugin_t *XINE_MALLOC unixscr_init () { unixscr_t *this; this = calloc(1, sizeof(unixscr_t)); - + this->scr.interface_version = 3; this->scr.get_priority = unixscr_get_priority; this->scr.set_fine_speed = unixscr_set_speed; @@ -184,15 +184,15 @@ static scr_plugin_t *XINE_MALLOC unixscr_init () { this->scr.start = unixscr_start; this->scr.get_current = unixscr_get_current; this->scr.exit = unixscr_exit; - + pthread_mutex_init (&this->lock, NULL); - + unixscr_set_speed (&this->scr, XINE_SPEED_PAUSE); lprintf("xine-scr_init complete\n"); return &this->scr; } - + /* * **************************************** @@ -208,7 +208,7 @@ static void metronom_start_clock (metronom_clock_t *this, int64_t pts) { for (scr = this->scr_list; scr < this->scr_list+MAX_SCR_PROVIDERS; scr++) if (*scr) (*scr)->start(*scr, pts); - + this->speed = XINE_FINE_SPEED_NORMAL; } @@ -243,7 +243,7 @@ static int metronom_set_speed (metronom_clock_t *this, int speed) { int true_speed; true_speed = this->scr_master->set_fine_speed (this->scr_master, speed); - + this->speed = true_speed; for (scr = this->scr_list; scr < this->scr_list+MAX_SCR_PROVIDERS; scr++) @@ -267,33 +267,33 @@ static int64_t metronom_got_spu_packet (metronom_t *this, int64_t pts) { int64_t vpts; pthread_mutex_lock (&this->lock); - + if (this->master) { metronom_t *master = this->master; - + pthread_mutex_lock(&this->master->lock); pthread_mutex_unlock(&this->lock); - + this->vpts_offset = this->master->vpts_offset; this->spu_offset = this->master->spu_offset; - + /* no recursion, please */ this->master = NULL; vpts = master->got_spu_packet(this, pts); this->master = master; - + pthread_mutex_unlock(&this->master->lock); return vpts; } vpts = pts + this->vpts_offset + this->spu_offset; - + /* no vpts going backwards please */ if( vpts < this->spu_vpts ) vpts = this->spu_vpts; - + this->spu_vpts = vpts; - + pthread_mutex_unlock (&this->lock); return vpts; } @@ -353,7 +353,7 @@ static void metronom_handle_discontinuity (metronom_t *this, int type, this->vpts_offset = this->video_vpts - disc_off; break; } - + this->last_video_pts = 0; this->last_audio_pts = 0; } @@ -368,18 +368,18 @@ static void metronom_handle_video_discontinuity (metronom_t *this, int type, pthread_mutex_unlock(&this->lock); return; } - + this->video_discontinuity_count++; pthread_cond_signal (&this->video_discontinuity_reached); - + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video discontinuity #%d, type is %d, disc_off %" PRId64 "\n", this->video_discontinuity_count, type, disc_off); - + if (this->have_audio) { while (this->audio_discontinuity_count < this->video_discontinuity_count) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, "waiting for audio discontinuity #%d\n", + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "waiting for audio discontinuity #%d\n", this->video_discontinuity_count); pthread_cond_wait (&this->audio_discontinuity_reached, &this->lock); @@ -399,15 +399,15 @@ static void metronom_got_video_frame (metronom_t *this, vo_frame_t *img) { int64_t vpts; int64_t pts = img->pts; int64_t diff; - + pthread_mutex_lock (&this->lock); if (this->master) { metronom_t *master = this->master; - + pthread_mutex_lock(&this->master->lock); pthread_mutex_unlock(&this->lock); - + if (!this->discontinuity_handled_count) { /* we are not initialized yet */ if (this->master->video_vpts > this->master->audio_vpts) @@ -420,15 +420,15 @@ static void metronom_got_video_frame (metronom_t *this, vo_frame_t *img) { this->force_video_jump = 1; this->discontinuity_handled_count++; } - + this->vpts_offset = this->master->vpts_offset; this->av_offset = this->master->av_offset; - + /* no recursion, please */ this->master = NULL; master->got_video_frame(this, img); this->master = master; - + pthread_mutex_unlock(&this->master->lock); return; } @@ -459,23 +459,23 @@ static void metronom_got_video_frame (metronom_t *this, vo_frame_t *img) { } this->img_cpt = 0; this->last_video_pts = pts; - - + + /* * compare predicted (this->video_vpts) and given (pts+vpts_offset) * pts values - hopefully they will be the same * if not, for small diffs try to interpolate * for big diffs: jump */ - + vpts = pts + this->vpts_offset; if (this->video_mode == VIDEO_PREDICTION_MODE) { - + diff = this->video_vpts - vpts; lprintf("video diff is %" PRId64 " (predicted %" PRId64 ", given %" PRId64 ")\n", diff, this->video_vpts, vpts); - + if ((abs (diff) > VIDEO_DRIFT_TOLERANCE) || (this->force_video_jump)) { this->force_video_jump = 0; @@ -489,7 +489,7 @@ static void metronom_got_video_frame (metronom_t *this, vo_frame_t *img) { this->video_drift = diff; this->video_drift_step = diff / 30; /* this will fix video drift with a constant compensation each - frame for about 1 second of video. */ + frame for about 1 second of video. */ if (diff) lprintf("video drift, drift is %" PRId64 "\n", this->video_drift); } @@ -503,7 +503,7 @@ static void metronom_got_video_frame (metronom_t *this, vo_frame_t *img) { if (this->video_mode == VIDEO_PREDICTION_MODE) { lprintf("video vpts for %10"PRId64" : %10"PRId64" (duration:%d drift:%" PRId64 " step:%" PRId64 ")\n", - pts, this->video_vpts, img->duration, this->video_drift, this->video_drift_step ); + pts, this->video_vpts, img->duration, this->video_drift, this->video_drift_step ); if (this->video_drift * this->video_drift_step > 0) { img->duration -= this->video_drift_step; @@ -516,7 +516,7 @@ static void metronom_got_video_frame (metronom_t *this, vo_frame_t *img) { * this->video_vpts is used as the next frame vpts if next frame pts=0 */ this->video_vpts += this->img_duration; - + pthread_mutex_unlock (&this->lock); } @@ -524,7 +524,7 @@ static void metronom_handle_audio_discontinuity (metronom_t *this, int type, int64_t disc_off) { pthread_mutex_lock (&this->lock); - + if (this->master) { /* slaves are currently not allowed to set discontinuities */ pthread_mutex_unlock(&this->lock); @@ -533,19 +533,19 @@ static void metronom_handle_audio_discontinuity (metronom_t *this, int type, this->audio_discontinuity_count++; pthread_cond_signal (&this->audio_discontinuity_reached); - + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "audio discontinuity #%d, type is %d, disc_off %" PRId64 "\n", this->audio_discontinuity_count, type, disc_off); if (this->have_video) { - + /* next_vpts_offset, in_discontinuity is handled in expect_video_discontinuity */ while ( this->audio_discontinuity_count > this->discontinuity_handled_count ) { - - xprintf(this->xine, XINE_VERBOSITY_DEBUG, "waiting for in_discontinuity update #%d\n", + + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "waiting for in_discontinuity update #%d\n", this->audio_discontinuity_count); - + pthread_cond_wait (&this->video_discontinuity_reached, &this->lock); } } else { @@ -554,11 +554,11 @@ static void metronom_handle_audio_discontinuity (metronom_t *this, int type, this->audio_samples = 0; this->audio_drift_step = 0; - + pthread_mutex_unlock (&this->lock); } -static int64_t metronom_got_audio_samples (metronom_t *this, int64_t pts, +static int64_t metronom_got_audio_samples (metronom_t *this, int64_t pts, int nsamples) { int64_t vpts; @@ -568,34 +568,34 @@ static int64_t metronom_got_audio_samples (metronom_t *this, int64_t pts, lprintf("AUDIO pts from last= %" PRId64 "\n", pts-this->last_audio_pts); pthread_mutex_lock (&this->lock); - + if (this->master) { metronom_t *master = this->master; - + pthread_mutex_lock(&this->master->lock); pthread_mutex_unlock(&this->lock); - + if (!this->discontinuity_handled_count) { /* we are not initialized yet */ if (this->master->video_vpts > this->master->audio_vpts) this->video_vpts = this->audio_vpts = this->master->video_vpts; else this->video_vpts = this->audio_vpts = this->master->audio_vpts; - this->audio_vpts_rmndr = 0; + this->audio_vpts_rmndr = 0; /* when being attached to the first master, do not drift into * his vpts values but adopt at once */ this->force_audio_jump = 1; this->force_video_jump = 1; this->discontinuity_handled_count++; } - + this->vpts_offset = this->master->vpts_offset; - + /* no recursion, please */ this->master = NULL; vpts = master->got_audio_samples(this, pts, nsamples); this->master = master; - + pthread_mutex_unlock(&this->master->lock); return vpts; } @@ -609,7 +609,7 @@ static int64_t metronom_got_audio_samples (metronom_t *this, int64_t pts, if((abs(diff) > AUDIO_DRIFT_TOLERANCE) || (this->force_audio_jump)) { this->force_audio_jump = 0; this->audio_vpts = vpts; - this->audio_vpts_rmndr = 0; + this->audio_vpts_rmndr = 0; this->audio_drift_step = 0; xprintf(this->xine, XINE_VERBOSITY_DEBUG, "audio jump, diff=%" PRId64 "\n", diff); } else { @@ -619,15 +619,15 @@ static int64_t metronom_got_audio_samples (metronom_t *this, int64_t pts, diff *= AUDIO_SAMPLE_NUM; diff /= this->audio_samples * 4; - + /* drift_step is not allowed to change rate by more than 25% */ if( diff > this->pts_per_smpls/4 ) - diff = this->pts_per_smpls/4; + diff = this->pts_per_smpls/4; if( diff < -this->pts_per_smpls/4 ) diff = -this->pts_per_smpls/4; - + this->audio_drift_step = diff; - + lprintf("audio_drift = %" PRId64 ", pts_per_smpls = %" PRId64 "\n", diff, this->pts_per_smpls); } } @@ -635,12 +635,12 @@ static int64_t metronom_got_audio_samples (metronom_t *this, int64_t pts, } vpts = this->audio_vpts; - /* drift here is caused by streams where nominal sample rate differs from + /* drift here is caused by streams where nominal sample rate differs from * the rate of which pts increments. fixing the audio_vpts won't do us any * good because sound card won't play it faster or slower just because * we want. however, adding the error to the vpts_offset will force video * to change it's frame rate to keep in sync with us. - * + * * Since we are using integer division below, it can happen that we lose * precision for the calculated duration in vpts for each audio buffer * (< 1 PTS, e.g. 0.25 PTS during playback of most DVDs with LPCM audio). @@ -658,7 +658,7 @@ static int64_t metronom_got_audio_samples (metronom_t *this, int64_t pts, } this->audio_samples += nsamples; this->vpts_offset += nsamples * this->audio_drift_step / AUDIO_SAMPLE_NUM; - + lprintf("audio vpts for %10"PRId64" : %10"PRId64"\n", pts, vpts); pthread_mutex_unlock (&this->lock); @@ -669,7 +669,7 @@ static int64_t metronom_got_audio_samples (metronom_t *this, int64_t pts, static void metronom_set_option (metronom_t *this, int option, int64_t value) { pthread_mutex_lock (&this->lock); - + if (this->master) { /* pass the option on to the master */ this->master->set_option(this->master, option, value); @@ -725,7 +725,7 @@ static void metronom_clock_set_option (metronom_clock_t *this, } static int64_t metronom_get_option (metronom_t *this, int option) { - + if (this->master) return this->master->get_option(this->master, option); @@ -756,7 +756,7 @@ static int64_t metronom_clock_get_option (metronom_clock_t *this, int option) { static void metronom_set_master(metronom_t *this, metronom_t *master) { metronom_t *old_master = this->master; - + pthread_mutex_lock(&this->lock); /* someone might currently be copying values from the old master, * so we need his lock too */ @@ -774,7 +774,7 @@ static scr_plugin_t* get_master_scr(metronom_clock_t *this) { /* find the SCR provider with the highest priority */ for (i=0; i<MAX_SCR_PROVIDERS; i++) if (this->scr_list[i]) { scr_plugin_t *scr = this->scr_list[i]; - + if (maxprio < scr->get_priority(scr)) { select = i; maxprio = scr->get_priority(scr); @@ -791,7 +791,7 @@ static int metronom_register_scr (metronom_clock_t *this, scr_plugin_t *scr) { int i; if (scr->interface_version != 3) { - xprintf(this->xine, XINE_VERBOSITY_NONE, + xprintf(this->xine, XINE_VERBOSITY_NONE, "wrong interface version for scr provider!\n"); return -1; } @@ -813,19 +813,19 @@ static void metronom_unregister_scr (metronom_clock_t *this, scr_plugin_t *scr) /* never unregister scr_list[0]! */ for (i=1; i<MAX_SCR_PROVIDERS; i++) - if (this->scr_list[i] == scr) + if (this->scr_list[i] == scr) break; if (i >= MAX_SCR_PROVIDERS) return; /* Not found */ - + this->scr_list[i] = NULL; time = this->get_current_time(this); - + /* master could have been adjusted, others must follow now */ for (i=0; i<MAX_SCR_PROVIDERS; i++) if (this->scr_list[i]) this->scr_list[i]->adjust(this->scr_list[i], time); - + this->scr_master = get_master_scr(this); } @@ -836,13 +836,13 @@ static void *metronom_sync_loop (void *const this_gen) { struct timespec ts; scr_plugin_t** scr; int64_t pts; - + while (this->thread_running) { /* synchronise every 5 seconds */ pthread_mutex_lock (&this->lock); pts = this->scr_master->get_current(this->scr_master); - + for (scr = this->scr_list; scr < this->scr_list+MAX_SCR_PROVIDERS; scr++) if (*scr && *scr != this->scr_master) (*scr)->adjust(*scr, pts); @@ -870,7 +870,7 @@ static void metronom_clock_exit (metronom_clock_t *this) { scr_plugin_t** scr; this->thread_running = 0; - + pthread_mutex_lock (&this->lock); pthread_cond_signal (&this->cancel); pthread_mutex_unlock (&this->lock); @@ -905,7 +905,7 @@ metronom_t * _x_metronom_init (int have_video, int have_audio, xine_t *xine) { this->xine = xine; this->master = NULL; - + pthread_mutex_init (&this->lock, NULL); this->prebuffer = PREBUFFER_PTS_OFFSET; @@ -914,7 +914,7 @@ metronom_t * _x_metronom_init (int have_video, int have_audio, xine_t *xine) { this->vpts_offset = 0; /* initialize video stuff */ - + this->video_vpts = this->prebuffer; this->video_drift = 0; this->video_drift_step = 0; @@ -925,8 +925,8 @@ metronom_t * _x_metronom_init (int have_video, int have_audio, xine_t *xine) { this->img_cpt = 0; this->last_video_pts = 0; this->last_audio_pts = 0; - - + + /* initialize audio stuff */ this->have_video = have_video; @@ -935,7 +935,7 @@ metronom_t * _x_metronom_init (int have_video, int have_audio, xine_t *xine) { this->audio_vpts_rmndr = 0; this->audio_discontinuity_count = 0; pthread_cond_init (&this->audio_discontinuity_reached, NULL); - + return this; } @@ -945,7 +945,7 @@ metronom_clock_t *_x_metronom_clock_init(xine_t *xine) { metronom_clock_t *this = calloc(1, sizeof(metronom_clock_t)); int err; - + this->set_option = metronom_clock_set_option; this->get_option = metronom_clock_get_option; this->start_clock = metronom_start_clock; @@ -957,19 +957,19 @@ metronom_clock_t *_x_metronom_clock_init(xine_t *xine) this->register_scr = metronom_register_scr; this->unregister_scr = metronom_unregister_scr; this->exit = metronom_clock_exit; - + this->xine = xine; this->scr_adjustable = 1; this->scr_list = calloc(MAX_SCR_PROVIDERS, sizeof(void*)); this->register_scr(this, unixscr_init()); - + pthread_mutex_init (&this->lock, NULL); pthread_cond_init (&this->cancel, NULL); - + this->thread_running = 1; if ((err = pthread_create(&this->sync_thread, NULL, - metronom_sync_loop, this)) != 0) + metronom_sync_loop, this)) != 0) xprintf(this->xine, XINE_VERBOSITY_NONE, "cannot create sync thread (%s)\n", strerror(err)); diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c index 48b44ca4c..73fe76a0a 100644 --- a/src/xine-engine/osd.c +++ b/src/xine-engine/osd.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2005 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -102,10 +102,10 @@ static const char *const textpalettes_str[NUMBER_OF_TEXT_PALETTES+1] = { "white-black-transparent", "white-none-transparent", "white-none-translucid", - "yellow-black-transparent", + "yellow-black-transparent", NULL}; -/* +/* Palette entries as used by osd fonts: 0: not used by font, always transparent @@ -116,10 +116,10 @@ static const char *const textpalettes_str[NUMBER_OF_TEXT_PALETTES+1] = { 6: font border. if the font is to be displayed without border this will probably be adjusted to font background or near. 7-9: transition between border and foreground - 10: font color (foreground) + 10: font color (foreground) */ -/* +/* The palettes below were made by hand, ie, i just throw values that seemed to do the transitions i wanted. This can surelly be improved a lot. [Miguel] @@ -207,7 +207,7 @@ struct osd_font_s { uint16_t size; uint16_t num_fontchars; uint16_t loaded; -}; +}; #ifdef HAVE_FT2 struct osd_ft2context_s { @@ -241,11 +241,11 @@ static inline void osd_free_ft2 (osd_object_t *osd __attr_unused) {} */ static osd_object_t *XINE_MALLOC osd_new_object (osd_renderer_t *this, int width, int height) { - + osd_object_t *osd; - - pthread_mutex_lock (&this->osd_mutex); - + + pthread_mutex_lock (&this->osd_mutex); + osd = calloc(1, sizeof(osd_object_t)); osd->renderer = this; osd->next = this->osds; @@ -256,12 +256,12 @@ static osd_object_t *XINE_MALLOC osd_new_object (osd_renderer_t *this, int width osd->video_window_width = 0; osd->video_window_height = 0; osd->extent_width = 0; - osd->extent_height = 0; + osd->extent_height = 0; osd->width = width; osd->height = height; osd->area = calloc(width, height); osd->area_touched = 0; - + osd->x1 = osd->argb_layer.x1 = width; osd->y1 = osd->argb_layer.y1 = height; osd->x2 = osd->argb_layer.x2 = 0; @@ -269,8 +269,8 @@ static osd_object_t *XINE_MALLOC osd_new_object (osd_renderer_t *this, int width pthread_mutex_init(&osd->argb_layer.mutex, NULL); - memcpy(osd->color, textpalettes_color[0], sizeof(textpalettes_color[0])); - memcpy(osd->trans, textpalettes_trans[0], sizeof(textpalettes_trans[0])); + memcpy(osd->color, textpalettes_color[0], sizeof(textpalettes_color[0])); + memcpy(osd->trans, textpalettes_trans[0], sizeof(textpalettes_trans[0])); osd->handle = -1; @@ -278,11 +278,11 @@ static osd_object_t *XINE_MALLOC osd_new_object (osd_renderer_t *this, int width osd->cd = (iconv_t)-1; osd->encoding = NULL; #endif - - pthread_mutex_unlock (&this->osd_mutex); + + pthread_mutex_unlock (&this->osd_mutex); lprintf("osd=%p size: %dx%d\n", osd, width, height); - + return osd; } @@ -324,7 +324,7 @@ static int _osd_hide (osd_object_t *osd, int64_t vpts); * the object is not changed. there may be subsequent drawing on it. */ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) { - + osd_renderer_t *this = osd->renderer; video_overlay_manager_t *ovl_manager; rle_elem_t rle, *rle_p=0; @@ -332,21 +332,21 @@ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) { uint8_t *c; lprintf("osd=%p vpts=%"PRId64"\n", osd, vpts); - + this->stream->xine->port_ticket->acquire(this->stream->xine->port_ticket, 1); - + ovl_manager = this->stream->video_out->get_overlay_manager(this->stream->video_out); - + if( osd->handle < 0 ) { if( (osd->handle = ovl_manager->get_handle(ovl_manager, 0)) == -1 ) { this->stream->xine->port_ticket->release(this->stream->xine->port_ticket, 1); return 0; } } - - pthread_mutex_lock (&this->osd_mutex); - - /* clip update area to allowed range */ + + pthread_mutex_lock (&this->osd_mutex); + + /* clip update area to allowed range */ if(osd->x1 > osd->width) osd->x1 = osd->width; if(osd->x2 > osd->width) @@ -360,13 +360,13 @@ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) { if(osd->y1 < 0) osd->y1 = 0; if(osd->y2 < 0) osd->y2 = 0; -#ifdef DEBUG_RLE +#ifdef DEBUG_RLE lprintf("osd_show %p rle starts\n", osd); -#endif +#endif /* check if osd is valid (something drawn on it) */ if( osd->x2 > osd->x1 && osd->y2 > osd->y1 ) { - + this->event.object.handle = osd->handle; memset( this->event.object.overlay, 0, sizeof(*this->event.object.overlay) ); @@ -386,12 +386,12 @@ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) { this->event.object.overlay->extent_width = osd->extent_width; this->event.object.overlay->extent_height = osd->extent_height; - + this->event.object.overlay->hili_top = 0; this->event.object.overlay->hili_bottom = this->event.object.overlay->height; this->event.object.overlay->hili_left = 0; this->event.object.overlay->hili_right = this->event.object.overlay->width; - + /* there will be at least that many rle objects (one for each row) */ this->event.object.overlay->num_rle = 0; if (!osd->area_touched) { @@ -403,13 +403,13 @@ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) { Rely on lazy page allocation to avoid us actually taking up this much RAM */ this->event.object.overlay->data_size = osd->width * osd->height; - rle_p = this->event.object.overlay->rle = + rle_p = this->event.object.overlay->rle = malloc(this->event.object.overlay->data_size * sizeof(rle_elem_t) ); - + for( y = osd->y1; y < osd->y2; y++ ) { -#ifdef DEBUG_RLE +#ifdef DEBUG_RLE lprintf("osd_show %p y = %d: ", osd, y); -#endif +#endif c = osd->area + y * osd->width + osd->x1; /* initialize a rle object with the first pixel's color */ @@ -419,17 +419,17 @@ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) { /* loop over the remaining pixels in the row */ for( x = osd->x1 + rle.len; x < osd->x2; x++, c++ ) { if( rle.color != *c ) { -#ifdef DEBUG_RLE +#ifdef DEBUG_RLE lprintf("(%d, %d), ", rle.len, rle.color); #endif *rle_p++ = rle; - this->event.object.overlay->num_rle++; + this->event.object.overlay->num_rle++; rle.color = *c; rle.len = 1; } else { rle.len++; - } + } } #ifdef DEBUG_RLE lprintf("(%d, %d)\n", rle.len, rle.color); @@ -441,13 +441,13 @@ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) { lprintf("osd_show %p rle ends\n", osd); #endif lprintf("num_rle = %d\n", this->event.object.overlay->num_rle); - - memcpy(this->event.object.overlay->hili_color, osd->color, sizeof(osd->color)); - memcpy(this->event.object.overlay->hili_trans, osd->trans, sizeof(osd->trans)); - memcpy(this->event.object.overlay->color, osd->color, sizeof(osd->color)); - memcpy(this->event.object.overlay->trans, osd->trans, sizeof(osd->trans)); + + memcpy(this->event.object.overlay->hili_color, osd->color, sizeof(osd->color)); + memcpy(this->event.object.overlay->hili_trans, osd->trans, sizeof(osd->trans)); + memcpy(this->event.object.overlay->color, osd->color, sizeof(osd->color)); + memcpy(this->event.object.overlay->trans, osd->trans, sizeof(osd->trans)); } - + this->event.event_type = OVERLAY_EVENT_SHOW; this->event.vpts = vpts; ovl_manager->add_event(ovl_manager, (void *)&this->event); @@ -455,10 +455,10 @@ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) { /* osd empty - hide it */ _osd_hide(osd, vpts); } - pthread_mutex_unlock (&this->osd_mutex); - + pthread_mutex_unlock (&this->osd_mutex); + this->stream->xine->port_ticket->release(this->stream->xine->port_ticket, 1); - + return 1; } @@ -480,24 +480,24 @@ static int osd_show_unscaled (osd_object_t *osd, int64_t vpts) { * send event to hide osd at given pts (0=now) * the object is not changed. there may be subsequent drawing on it. */ -static int _osd_hide (osd_object_t *osd, int64_t vpts) { +static int _osd_hide (osd_object_t *osd, int64_t vpts) { osd_renderer_t *this = osd->renderer; video_overlay_manager_t *ovl_manager; - + lprintf("osd=%p vpts=%"PRId64"\n",osd, vpts); - + if( osd->handle < 0 ) return 0; - + this->event.object.handle = osd->handle; - + /* not really needed this, but good pratice to clean it up */ memset( this->event.object.overlay, 0, sizeof(this->event.object.overlay) ); - + this->event.event_type = OVERLAY_EVENT_HIDE; this->event.vpts = vpts; - + ovl_manager = this->stream->video_out->get_overlay_manager(this->stream->video_out); ovl_manager->add_event(ovl_manager, (void *)&this->event); @@ -546,14 +546,14 @@ static void osd_clear (osd_object_t *osd) { static void osd_point (osd_object_t *osd, int x, int y, int color) { uint8_t *c; - + lprintf("osd=%p (%d x %d)\n", osd, x, y); - + if (x < 0 || x >= osd->width) return; if (y < 0 || y >= osd->height) return; - + /* update clipping area */ osd->x1 = MIN(osd->x1, x); osd->x2 = MAX(osd->x2, (x + 1)); @@ -571,14 +571,14 @@ static void osd_point (osd_object_t *osd, int x, int y, int color) { static void osd_line (osd_object_t *osd, int x1, int y1, int x2, int y2, int color) { - + uint8_t *c; int dx, dy, t, inc, d, inc1, inc2; int swap_x = 0; int swap_y = 0; lprintf("osd=%p (%d,%d)-(%d,%d)\n",osd, x1,y1, x2,y2 ); - + /* sort line */ if (x2 < x1) { t = x1; @@ -593,7 +593,7 @@ static void osd_line (osd_object_t *osd, swap_y = 1; } - /* clip line */ + /* clip line */ if (x1 < 0) { y1 = y1 + (y2-y1) * -x1 / (x2-x1); x1 = 0; @@ -610,20 +610,20 @@ static void osd_line (osd_object_t *osd, x2 = x1 + (x2-x1) * (osd->height-y1) / (y2-y1); y2 = osd->height; } - + if (x1 >= osd->width || y1 >= osd->height) return; - + /* update clipping area */ osd->x1 = MIN( osd->x1, x1 ); osd->x2 = MAX( osd->x2, x2 ); osd->y1 = MIN( osd->y1, y1 ); osd->y2 = MAX( osd->y2, y2 ); osd->area_touched = 1; - + dx = x2 - x1; dy = y2 - y1; - + /* unsort line */ if (swap_x) { t = x1; @@ -642,7 +642,7 @@ static void osd_line (osd_object_t *osd, t = x2; x2 = x1; x1 = t; t = y2; y2 = y1; y1 = t; } - + if( y2 > y1 ) inc = 1; else inc = -1; inc1 = 2*dy; @@ -650,11 +650,11 @@ static void osd_line (osd_object_t *osd, inc2 = 2*(dy-dx); c = osd->area + y1 * osd->width + x1; - + while(x1<x2) { *c++ = color; - + x1++; if( d<0 ) { d+=inc1; @@ -679,8 +679,8 @@ static void osd_line (osd_object_t *osd, c = osd->area + y1 * osd->width + x1; while(y1<y2) { - *c = color; - + *c = color; + c += osd->width; y1++; if( d<0 ) { @@ -705,17 +705,17 @@ static void osd_filled_rect (osd_object_t *osd, int x, y, dx, dy; lprintf("osd=%p (%d,%d)-(%d,%d)\n",osd, x1,y1, x2,y2 ); - + /* sort rectangle */ x = MIN( x1, x2 ); dx = MAX( x1, x2 ); y = MIN( y1, y2 ); dy = MAX( y1, y2 ); - + /* clip rectangle */ if (x >= osd->width || y >= osd->height) return; - + if (x < 0) { dx += x; x = 0; @@ -727,7 +727,7 @@ static void osd_filled_rect (osd_object_t *osd, dx = MIN( dx, osd->width ); dy = MIN( dy, osd->height ); - + /* update clipping area */ osd->x1 = MIN( osd->x1, x ); osd->x2 = MAX( osd->x2, dx ); @@ -754,7 +754,7 @@ static void osd_set_palette(osd_object_t *osd, const uint32_t *color, const uint } /* - * set on existing text palette + * set on existing text palette * (-1 to set user specified palette) */ @@ -773,7 +773,7 @@ static void osd_set_text_palette(osd_object_t *osd, int palette_number, memcpy(&osd->color[color_base], textpalettes_color[palette_number], sizeof(textpalettes_color[palette_number])); memcpy(&osd->trans[color_base], textpalettes_trans[palette_number], - sizeof(textpalettes_trans[palette_number])); + sizeof(textpalettes_trans[palette_number])); } @@ -809,7 +809,7 @@ static uint16_t gzread_i16(gzFile *fp) { } /* - load bitmap font into osd engine + load bitmap font into osd engine */ static int osd_renderer_load_font(osd_renderer_t *this, char *filename) { @@ -817,7 +817,7 @@ static int osd_renderer_load_font(osd_renderer_t *this, char *filename) { gzFile *fp; osd_font_t *font = NULL; int i, ret = 0; - + lprintf("name=%s\n", filename ); /* load quick & dirt font format */ @@ -828,36 +828,36 @@ static int osd_renderer_load_font(osd_renderer_t *this, char *filename) { gzread(fp, font->name, sizeof(font->name) ); font->version = gzread_i16(fp); - + if( font->version == FONT_VERSION ) { - + font->size = gzread_i16(fp); font->num_fontchars = gzread_i16(fp); font->loaded = 1; - + font->fontchar = malloc( sizeof(osd_fontchar_t) * font->num_fontchars ); - + lprintf("font '%s' chars=%d\n", font->name, font->num_fontchars); - + /* load all characters */ for( i = 0; i < font->num_fontchars; i++ ) { font->fontchar[i].code = gzread_i16(fp); font->fontchar[i].width = gzread_i16(fp); font->fontchar[i].height = gzread_i16(fp); font->fontchar[i].bmp = malloc(font->fontchar[i].width*font->fontchar[i].height); - if( gzread(fp, font->fontchar[i].bmp, + if( gzread(fp, font->fontchar[i].bmp, font->fontchar[i].width*font->fontchar[i].height) <= 0 ) break; } - + /* check if all expected characters were loaded */ if( i == font->num_fontchars ) { osd_font_t *known_font; ret = 1; - + lprintf("font '%s' loaded\n",font->name); - - /* check if font is already known to us */ + + /* check if font is already known to us */ known_font = this->fonts; while( known_font ) { if( !strcasecmp(known_font->name,font->name) && @@ -865,16 +865,16 @@ static int osd_renderer_load_font(osd_renderer_t *this, char *filename) { break; known_font = known_font->next; } - + if( !known_font ) { - + /* new font, add it to list */ font->filename = strdup(filename); font->next = this->fonts; this->fonts = font; - + } else { - + if( !known_font->loaded ) { /* the font was preloaded before. * add loaded characters to the existing entry. @@ -885,7 +885,7 @@ static int osd_renderer_load_font(osd_renderer_t *this, char *filename) { known_font->fontchar = font->fontchar; free(font); } else { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("font '%s-%d' already loaded, weird.\n"), font->name, font->size); while( --i >= 0 ) { free(font->fontchar[i].bmp); @@ -893,13 +893,13 @@ static int osd_renderer_load_font(osd_renderer_t *this, char *filename) { free(font->fontchar); free(font); } - + } } else { - + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("font '%s' loading failed (%d < %d)\n") ,font->name, i, font->num_fontchars); - + while( --i >= 0 ) { free(font->fontchar[i].bmp); } @@ -925,13 +925,13 @@ static int osd_renderer_unload_font(osd_renderer_t *this, char *fontname ) { osd_font_t *font, *last; osd_object_t *osd; int i, ret = 0; - + lprintf("font '%s'\n", fontname); pthread_mutex_lock (&this->osd_mutex); osd = this->osds; - while( osd ) { + while( osd ) { if( !strcasecmp(osd->font->name, fontname) ) osd->font = NULL; osd = osd->next; @@ -943,14 +943,14 @@ static int osd_renderer_unload_font(osd_renderer_t *this, char *fontname ) { if ( !strcasecmp(font->name,fontname) ) { free( font->filename ); - + if( font->loaded ) { for( i = 0; i < font->num_fontchars; i++ ) { free( font->fontchar[i].bmp ); } free( font->fontchar ); } - + if( last ) last->next = font->next; else @@ -991,7 +991,7 @@ static int osd_lookup_fontconfig( osd_object_t *osd, const char *const fontname, match = FcFontMatch(NULL, pat, &result); FcPatternDestroy(pat); - + if ( ! match ) { FcFontSetDestroy(fs); xprintf(osd->renderer->stream->xine, XINE_VERBOSITY_LOG, @@ -1052,7 +1052,7 @@ static int osd_lookup_xdg( osd_object_t *osd, const char *const fontname ) { data_dirs++; } - xprintf(osd->renderer->stream->xine, XINE_VERBOSITY_LOG, + xprintf(osd->renderer->stream->xine, XINE_VERBOSITY_LOG, _("osd: error loading font %s with in XDG data directories.\n"), fontname); return 0; } @@ -1073,7 +1073,7 @@ static int osd_set_font_freetype2( osd_object_t *osd, const char *fontname, int FT_Done_Face (osd->ft2->face); osd->ft2->face = NULL; } - + do { /* while 0 */ #ifdef HAVE_FONTCONFIG if ( osd_lookup_fontconfig(osd, fontname, size) ) @@ -1102,11 +1102,11 @@ static int osd_set_font_freetype2( osd_object_t *osd, const char *fontname, int set the font of osd object */ -static int osd_set_font( osd_object_t *osd, const char *fontname, int size) { +static int osd_set_font( osd_object_t *osd, const char *fontname, int size) { int ret = 1; lprintf("osd=%p font '%s'\n", osd, fontname); - + pthread_mutex_lock (&osd->renderer->osd_mutex); #ifdef HAVE_FT2 @@ -1121,7 +1121,7 @@ static int osd_set_font( osd_object_t *osd, const char *fontname, int size) { font = osd->renderer->fonts; while( font ) { - if( !strcasecmp(font->name, fontname) && (size>=font->size) + if( !strcasecmp(font->name, fontname) && (size>=font->size) && (best<font->size)) { ret = 1; osd->font = font; @@ -1137,7 +1137,7 @@ static int osd_set_font( osd_object_t *osd, const char *fontname, int size) { ret = osd_renderer_load_font(osd->renderer, osd->font->filename); if(!ret) osd->font = NULL; - } + } } pthread_mutex_unlock (&osd->renderer->osd_mutex); @@ -1167,29 +1167,29 @@ static int osd_search(osd_fontchar_t *array, size_t n, uint16_t code) { if (array[right].code == code) return right; - else + else return ALIAS_CHARACTER_FONT < n ? ALIAS_CHARACTER_FONT : n; #else size_t i; - + for( i = 0; i < n; i++ ) { if( font->fontchar[i].code == unicode ) break; } - if (i < n) + if (i < n) return i; - else + else return ALIAS_CHARACTER_FONT < n ? ALIAS_CHARACTER_FONT : n; #endif } #ifdef HAVE_ICONV -/* - * get next unicode value +/* + * get next unicode value */ -static uint16_t osd_iconv_getunicode(xine_t *xine, +static uint16_t osd_iconv_getunicode(xine_t *xine, iconv_t cd, const char *encoding, ICONV_CONST char **inbuf, size_t *inbytesleft) { uint16_t unicode; @@ -1241,7 +1241,7 @@ static void osd_free_encoding(osd_object_t *osd) { /* - * set encoding of text + * set encoding of text * * NULL ... no conversion (iso-8859-1) * "" ... locale encoding @@ -1306,7 +1306,7 @@ static int osd_render_text (osd_object_t *osd, int x1, int y1, #endif lprintf("osd=%p (%d,%d) \"%s\"\n", osd, x1, y1, text); - + /* some sanity checks for the color indices */ if( color_base < 0 ) color_base = 0; @@ -1322,7 +1322,7 @@ static int osd_render_text (osd_object_t *osd, int x1, int y1, #ifdef HAVE_FT2 if (osd->ft2) proceed = 1; #endif - + if (proceed == 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("osd: font isn't defined\n")); pthread_mutex_unlock(&this->osd_mutex); @@ -1336,10 +1336,10 @@ static int osd_render_text (osd_object_t *osd, int x1, int y1, inbuf = text; inbytesleft = strlen(text); - + while( inbytesleft ) { #ifdef HAVE_ICONV - unicode = osd_iconv_getunicode(this->stream->xine, osd->cd, osd->encoding, + unicode = osd_iconv_getunicode(this->stream->xine, osd->cd, osd->encoding, (ICONV_CONST char **)&inbuf, &inbytesleft); #else unicode = inbuf[0]; @@ -1397,7 +1397,7 @@ static int osd_render_text (osd_object_t *osd, int x1, int y1, while (s < src + slot->bitmap.width) { if ((d >= dst) && (d < dst + osd->width) && *s) *d = (uint8_t)(*s/25) + (uint8_t) color_base; - + d++; s++; } @@ -1416,15 +1416,15 @@ static int osd_render_text (osd_object_t *osd, int x1, int y1, #endif i = osd_search(font->fontchar, font->num_fontchars, unicode); - - lprintf("font '%s' [%d, U+%04X == U+%04X] %dx%d -> %d,%d\n", font->name, i, - unicode, font->fontchar[i].code, font->fontchar[i].width, + + lprintf("font '%s' [%d, U+%04X == U+%04X] %dx%d -> %d,%d\n", font->name, i, + unicode, font->fontchar[i].code, font->fontchar[i].width, font->fontchar[i].height, x1, y1); - + if ( i != font->num_fontchars ) { dst = osd->area + y1 * osd->width; src = font->fontchar[i].bmp; - + for( y = 0; y < font->fontchar[i].height; y++ ) { uint8_t *s = src; uint8_t *d = dst + x1; @@ -1436,7 +1436,7 @@ static int osd_render_text (osd_object_t *osd, int x1, int y1, while (s < src + font->fontchar[i].width) { if((d >= dst) && (d < dst + osd->width) && (*s > 1)) /* skip drawing transparency */ *d = *s + (uint8_t) color_base; - + d++; s++; } @@ -1444,12 +1444,12 @@ static int osd_render_text (osd_object_t *osd, int x1, int y1, dst += osd->width; } x1 += font->fontchar[i].width - (font->fontchar[i].width * FONT_OVERLAP); - + if( x1 > osd->x2 ) osd->x2 = x1; - if( y1 + font->fontchar[i].height > osd->y2 ) + if( y1 + font->fontchar[i].height > osd->y2 ) osd->y2 = y1 + font->fontchar[i].height; } - + #ifdef HAVE_FT2 } /* !(osd->ft2) */ #endif @@ -1481,7 +1481,7 @@ static int osd_get_text_size(osd_object_t *osd, const char *text, int *width, in #endif lprintf("osd=%p \"%s\"\n", osd, text); - + pthread_mutex_lock (&this->osd_mutex); { @@ -1491,7 +1491,7 @@ static int osd_get_text_size(osd_object_t *osd, const char *text, int *width, in #ifdef HAVE_FT2 if (osd->ft2) proceed = 1; #endif - + if (proceed == 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("osd: font isn't defined\n")); pthread_mutex_unlock(&this->osd_mutex); @@ -1504,10 +1504,10 @@ static int osd_get_text_size(osd_object_t *osd, const char *text, int *width, in inbuf = text; inbytesleft = strlen(text); - + while( inbytesleft ) { #ifdef HAVE_ICONV - unicode = osd_iconv_getunicode(this->stream->xine, osd->cd, osd->encoding, + unicode = osd_iconv_getunicode(this->stream->xine, osd->cd, osd->encoding, (ICONV_CONST char **)&inbuf, &inbytesleft); #else unicode = inbuf[0]; @@ -1598,7 +1598,7 @@ static void osd_preload_fonts (osd_renderer_t *this, char *path) { int len; len = strlen (entry->d_name); - + if ( (len > 12) && !strncmp (&entry->d_name[len-12], ".xinefont.gz", 12)) { s = strdup(entry->d_name); @@ -1609,15 +1609,15 @@ static void osd_preload_fonts (osd_renderer_t *this, char *path) { *p++ = '\0'; font = calloc(1, sizeof(osd_font_t) ); - + strncpy(font->name, s, sizeof(font->name)); font->size = atoi(p); - lprintf("font '%s' size %d is preloaded\n", + lprintf("font '%s' size %d is preloaded\n", font->name, font->size); asprintf (&font->filename, "%s/%s", path, entry->d_name); - + font->next = this->fonts; this->fonts = font; } @@ -1634,30 +1634,30 @@ static void osd_preload_fonts (osd_renderer_t *this, char *path) { */ static void osd_free_object (osd_object_t *osd_to_close) { - + osd_renderer_t *this = osd_to_close->renderer; video_overlay_manager_t *ovl_manager; osd_object_t *osd, *last; if( osd_to_close->handle >= 0 ) { osd_hide(osd_to_close,0); - + this->event.object.handle = osd_to_close->handle; - + /* not really needed this, but good pratice to clean it up */ memset( this->event.object.overlay, 0, sizeof(this->event.object.overlay) ); this->event.event_type = OVERLAY_EVENT_FREE_HANDLE; this->event.vpts = 0; - + this->stream->xine->port_ticket->acquire(this->stream->xine->port_ticket, 1); ovl_manager = this->stream->video_out->get_overlay_manager(this->stream->video_out); ovl_manager->add_event(ovl_manager, (void *)&this->event); this->stream->xine->port_ticket->release(this->stream->xine->port_ticket, 1); - + osd_to_close->handle = -1; /* handle will be freed */ } - - pthread_mutex_lock (&this->osd_mutex); + + pthread_mutex_lock (&this->osd_mutex); last = NULL; osd = this->osds; @@ -1667,7 +1667,7 @@ static void osd_free_object (osd_object_t *osd_to_close) { osd_free_ft2 (osd); osd_free_encoding(osd); - + if( last ) last->next = osd->next; else @@ -1680,7 +1680,7 @@ static void osd_free_object (osd_object_t *osd_to_close) { last = osd; osd = osd->next; } - pthread_mutex_unlock (&this->osd_mutex); + pthread_mutex_unlock (&this->osd_mutex); } static void osd_renderer_close (osd_renderer_t *this) { @@ -1768,7 +1768,7 @@ static void osd_set_argb_buffer(osd_object_t *osd, uint32_t *argb_buffer, } static uint32_t osd_get_capabilities (osd_object_t *osd) { - + osd_renderer_t *this = osd->renderer; uint32_t capabilities = 0; uint32_t vo_capabilities; @@ -1786,14 +1786,14 @@ static uint32_t osd_get_capabilities (osd_object_t *osd) { if (vo_capabilities & VO_CAP_CUSTOM_EXTENT_OVERLAY) capabilities |= XINE_OSD_CAP_CUSTOM_EXTENT; - + if (vo_capabilities & VO_CAP_ARGB_LAYER_OVERLAY) capabilities |= XINE_OSD_CAP_ARGB_LAYER; if (vo_capabilities & VO_CAP_VIDEO_WINDOW_OVERLAY) capabilities |= XINE_OSD_CAP_VIDEO_WINDOW; - return capabilities; + return capabilities; } @@ -1805,7 +1805,7 @@ osd_renderer_t *_x_osd_renderer_init( xine_stream_t *stream ) { osd_renderer_t *this; - this = calloc(1, sizeof(osd_renderer_t)); + this = calloc(1, sizeof(osd_renderer_t)); this->stream = stream; this->event.object.overlay = calloc(1, sizeof(vo_overlay_t)); @@ -1826,20 +1826,20 @@ osd_renderer_t *_x_osd_renderer_init( xine_stream_t *stream ) { osd_preload_fonts(this, fontpath); free(fontpath); - + data_dirs++; } } this->textpalette = this->stream->xine->config->register_enum (this->stream->xine->config, "ui.osd.text_palette", 0, - textpalettes_str, + textpalettes_str, _("palette (foreground-border-background) to use for subtitles and OSD"), _("The palette for on-screen-display and some subtitle formats that do " "not specify any colouring themselves. The palettes are listed in the " "form: foreground-border-background."), 10, update_text_palette, this); - + /* * set up function pointer */ diff --git a/src/xine-engine/post.c b/src/xine-engine/post.c index 4c485035b..98cb3b69c 100644 --- a/src/xine-engine/post.c +++ b/src/xine-engine/post.c @@ -1,23 +1,23 @@ /* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA */ - + /* * some helper functions for post plugins */ @@ -41,7 +41,7 @@ void _x_post_init(post_plugin_t *post, int num_audio_inputs, int num_video_input static uint32_t post_video_get_capabilities(xine_video_port_t *port_gen) { post_video_port_t *port = (post_video_port_t *)port_gen; uint32_t caps; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); caps = port->original_port->get_capabilities(port->original_port); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -50,7 +50,7 @@ static uint32_t post_video_get_capabilities(xine_video_port_t *port_gen) { static void post_video_open(xine_video_port_t *port_gen, xine_stream_t *stream) { post_video_port_t *port = (post_video_port_t *)port_gen; - + _x_post_rewire(port->post); _x_post_inc_usage(port); if (port->port_lock) pthread_mutex_lock(port->port_lock); @@ -59,31 +59,31 @@ static void post_video_open(xine_video_port_t *port_gen, xine_stream_t *stream) port->stream = stream; } -static vo_frame_t *post_video_get_frame(xine_video_port_t *port_gen, uint32_t width, +static vo_frame_t *post_video_get_frame(xine_video_port_t *port_gen, uint32_t width, uint32_t height, double ratio, int format, int flags) { post_video_port_t *port = (post_video_port_t *)port_gen; vo_frame_t *frame; - + _x_post_rewire(port->post); if (port->port_lock) pthread_mutex_lock(port->port_lock); frame = port->original_port->get_frame(port->original_port, width, height, ratio, format, flags); if (port->port_lock) pthread_mutex_unlock(port->port_lock); - + if (frame && (!port->intercept_frame || port->intercept_frame(port, frame))) { _x_post_inc_usage(port); if (port->frame_lock) pthread_mutex_lock(port->frame_lock); frame = _x_post_intercept_video_frame(frame, port); if (port->frame_lock) pthread_mutex_unlock(port->frame_lock); } - + return frame; } static vo_frame_t *post_video_get_last_frame(xine_video_port_t *port_gen) { post_video_port_t *port = (post_video_port_t *)port_gen; vo_frame_t *frame; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); frame = port->original_port->get_last_frame(port->original_port); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -92,15 +92,15 @@ static vo_frame_t *post_video_get_last_frame(xine_video_port_t *port_gen) { static void post_video_enable_ovl(xine_video_port_t *port_gen, int ovl_enable) { post_video_port_t *port = (post_video_port_t *)port_gen; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); port->original_port->enable_ovl(port->original_port, ovl_enable); if (port->port_lock) pthread_mutex_unlock(port->port_lock); } - + static void post_video_close(xine_video_port_t *port_gen, xine_stream_t *stream) { post_video_port_t *port = (post_video_port_t *)port_gen; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); port->original_port->close(port->original_port, stream); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -110,7 +110,7 @@ static void post_video_close(xine_video_port_t *port_gen, xine_stream_t *stream) static void post_video_exit(xine_video_port_t *port_gen) { post_video_port_t *port = (post_video_port_t *)port_gen; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); port->original_port->exit(port->original_port); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -119,11 +119,11 @@ static void post_video_exit(xine_video_port_t *port_gen) { static video_overlay_manager_t *post_video_get_overlay_manager(xine_video_port_t *port_gen) { post_video_port_t *port = (post_video_port_t *)port_gen; video_overlay_manager_t *manager; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); manager = port->original_port->get_overlay_manager(port->original_port); if (port->port_lock) pthread_mutex_unlock(port->port_lock); - + if (port->intercept_ovl && port->intercept_ovl(port)) { if (manager && !port->original_manager) /* this is the first access to overlay manager */ @@ -138,7 +138,7 @@ static video_overlay_manager_t *post_video_get_overlay_manager(xine_video_port_t static void post_video_flush(xine_video_port_t *port_gen) { post_video_port_t *port = (post_video_port_t *)port_gen; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); port->original_port->flush(port->original_port); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -146,7 +146,7 @@ static void post_video_flush(xine_video_port_t *port_gen) { static void post_video_trigger_drawing(xine_video_port_t *port_gen) { post_video_port_t *port = (post_video_port_t *)port_gen; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); port->original_port->trigger_drawing(port->original_port); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -156,7 +156,7 @@ static int post_video_status(xine_video_port_t *port_gen, xine_stream_t *stream, int *width, int *height, int64_t *img_duration) { post_video_port_t *port = (post_video_port_t *)port_gen; int status; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); status = port->original_port->status(port->original_port, stream, width, height, img_duration); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -166,7 +166,7 @@ static int post_video_status(xine_video_port_t *port_gen, xine_stream_t *stream, static int post_video_get_property(xine_video_port_t *port_gen, int property) { post_video_port_t *port = (post_video_port_t *)port_gen; int prop; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); prop = port->original_port->get_property(port->original_port, property); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -176,7 +176,7 @@ static int post_video_get_property(xine_video_port_t *port_gen, int property) { static int post_video_set_property(xine_video_port_t *port_gen, int property, int value) { post_video_port_t *port = (post_video_port_t *)port_gen; int val; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); val = port->original_port->set_property(port->original_port, property, value); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -191,23 +191,23 @@ static int post_video_rewire(xine_post_out_t *output_gen, void *data) { post_plugin_t *this = output->post; int64_t img_duration; int width, height; - + if (!new_port) return 0; - + this->running_ticket->lock_port_rewiring(this->running_ticket, -1); this->running_ticket->revoke(this->running_ticket, 1); - + if (input_port->original_port->status(input_port->original_port, input_port->stream, &width, &height, &img_duration)) { (new_port->open) (new_port, input_port->stream); input_port->original_port->close(input_port->original_port, input_port->stream); } input_port->original_port = new_port; - + this->running_ticket->issue(this->running_ticket, 1); this->running_ticket->unlock_port_rewiring(this->running_ticket); - + return 1; } @@ -215,10 +215,10 @@ static int post_video_rewire(xine_post_out_t *output_gen, void *data) { post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_port_t *original, post_in_t **input, post_out_t **output) { post_video_port_t *port = calloc(1, sizeof(post_video_port_t)); - + if (!port) return NULL; - + port->new_port.get_capabilities = post_video_get_capabilities; port->new_port.open = post_video_open; port->new_port.get_frame = post_video_get_frame; @@ -233,15 +233,15 @@ post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_ port->new_port.get_property = post_video_get_property; port->new_port.set_property = post_video_set_property; port->new_port.driver = original->driver; - + port->original_port = original; port->new_frame = &port->frame_storage; port->new_manager = &port->manager_storage; port->post = post; - + pthread_mutex_init(&port->usage_lock, NULL); pthread_mutex_init(&port->free_frames_lock, NULL); - + if (input) { *input = calloc(1, sizeof(post_in_t)); if (!*input) return port; @@ -251,7 +251,7 @@ post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_ (*input)->post = post; xine_list_push_back(post->input, *input); } - + if (output) { *output = calloc(1, sizeof(post_out_t)); if (!*output) return port; @@ -263,7 +263,7 @@ post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_ (*output)->user_data = port; xine_list_push_back(post->output, *output); } - + return port; } @@ -271,7 +271,7 @@ post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_ /* dummy intercept functions for frames */ static void post_frame_free(vo_frame_t *vo_img) { post_video_port_t *port = _x_post_video_frame_to_port(vo_img); - + if (port->frame_lock) pthread_mutex_lock(port->frame_lock); if (--vo_img->lock_counter == 0) { /* this frame is free */ @@ -290,7 +290,7 @@ static void post_frame_free(vo_frame_t *vo_img) { static void post_frame_proc_slice(vo_frame_t *vo_img, uint8_t **src) { post_video_port_t *port = _x_post_video_frame_to_port(vo_img); - + if (port->frame_lock) pthread_mutex_lock(port->frame_lock); _x_post_frame_copy_down(vo_img, vo_img->next); vo_img->next->proc_slice(vo_img->next, src); @@ -300,7 +300,7 @@ static void post_frame_proc_slice(vo_frame_t *vo_img, uint8_t **src) { static void post_frame_proc_frame(vo_frame_t *vo_img) { post_video_port_t *port = _x_post_video_frame_to_port(vo_img); - + if (port->frame_lock) pthread_mutex_lock(port->frame_lock); _x_post_frame_copy_down(vo_img, vo_img->next); vo_img->next->proc_frame(vo_img->next); @@ -310,7 +310,7 @@ static void post_frame_proc_frame(vo_frame_t *vo_img) { static void post_frame_field(vo_frame_t *vo_img, int which_field) { post_video_port_t *port = _x_post_video_frame_to_port(vo_img); - + if (port->frame_lock) pthread_mutex_lock(port->frame_lock); _x_post_frame_copy_down(vo_img, vo_img->next); vo_img->next->field(vo_img->next, which_field); @@ -321,7 +321,7 @@ static void post_frame_field(vo_frame_t *vo_img, int which_field) { static int post_frame_draw(vo_frame_t *vo_img, xine_stream_t *stream) { post_video_port_t *port = _x_post_video_frame_to_port(vo_img); int skip; - + if (port->frame_lock) pthread_mutex_lock(port->frame_lock); _x_post_frame_copy_down(vo_img, vo_img->next); skip = vo_img->next->draw(vo_img->next, stream); @@ -332,7 +332,7 @@ static int post_frame_draw(vo_frame_t *vo_img, xine_stream_t *stream) { static void post_frame_lock(vo_frame_t *vo_img) { post_video_port_t *port = _x_post_video_frame_to_port(vo_img); - + if (port->frame_lock) pthread_mutex_lock(port->frame_lock); _x_post_frame_copy_down(vo_img, vo_img->next); vo_img->lock_counter++; @@ -343,7 +343,7 @@ static void post_frame_lock(vo_frame_t *vo_img) { static void post_frame_dispose(vo_frame_t *vo_img) { post_video_port_t *port = _x_post_video_frame_to_port(vo_img); - + if (port->frame_lock) pthread_mutex_lock(port->frame_lock); vo_img = _x_post_restore_video_frame(vo_img, port); vo_img->dispose(vo_img); @@ -354,7 +354,7 @@ static void post_frame_dispose(vo_frame_t *vo_img) { vo_frame_t *_x_post_intercept_video_frame(vo_frame_t *frame, post_video_port_t *port) { vo_frame_t *new_frame; - + /* get a free frame slot */ pthread_mutex_lock(&port->free_frames_lock); if (port->free_frame_slots) { @@ -364,14 +364,14 @@ vo_frame_t *_x_post_intercept_video_frame(vo_frame_t *frame, post_video_port_t * new_frame = calloc(1, sizeof(vo_frame_t)); } pthread_mutex_unlock(&port->free_frames_lock); - + /* make a copy and attach the original */ xine_fast_memcpy(new_frame, frame, sizeof(vo_frame_t)); new_frame->next = frame; if (new_frame->stream) _x_refcounter_inc(new_frame->stream->refcounter); - + /* modify the frame with the intercept functions */ new_frame->port = &port->new_port; new_frame->proc_frame = @@ -398,17 +398,17 @@ vo_frame_t *_x_post_intercept_video_frame(vo_frame_t *frame, post_video_port_t * if (frame->proc_slice && !new_frame->proc_slice) new_frame->proc_slice = post_frame_proc_slice; } - + return new_frame; } vo_frame_t *_x_post_restore_video_frame(vo_frame_t *frame, post_video_port_t *port) { /* the first attched context is the original frame */ vo_frame_t *original = frame->next; - + /* propagate any changes */ _x_post_frame_copy_down(frame, original); - + if (frame->stream) _x_refcounter_dec(frame->stream->refcounter); @@ -417,7 +417,7 @@ vo_frame_t *_x_post_restore_video_frame(vo_frame_t *frame, post_video_port_t *po frame->next = port->free_frame_slots; port->free_frame_slots = frame; pthread_mutex_unlock(&port->free_frames_lock); - + return original; } @@ -458,7 +458,7 @@ void _x_post_frame_copy_up(vo_frame_t *to, vo_frame_t *from) { to->vpts = from->vpts; to->duration = from->duration; to->stream = from->stream; - + if (to->extra_info != from->extra_info) _x_extra_info_merge(to->extra_info, from->extra_info); } @@ -474,14 +474,14 @@ void _x_post_frame_u_turn(vo_frame_t *frame, xine_stream_t *stream) { if (stream) { _x_extra_info_merge(frame->extra_info, stream->video_decoder_extra_info); stream->metronom->got_video_frame(stream->metronom, frame); - } + } } /* dummy intercept functions that just pass the call on to the original overlay manager */ static void post_overlay_init(video_overlay_manager_t *ovl_gen) { post_video_port_t *port = _x_post_ovl_manager_to_port(ovl_gen); - + if (port->manager_lock) pthread_mutex_lock(port->manager_lock); port->original_manager->init(port->original_manager); if (port->manager_lock) pthread_mutex_unlock(port->manager_lock); @@ -489,7 +489,7 @@ static void post_overlay_init(video_overlay_manager_t *ovl_gen) { static void post_overlay_dispose(video_overlay_manager_t *ovl_gen) { post_video_port_t *port = _x_post_ovl_manager_to_port(ovl_gen); - + if (port->manager_lock) pthread_mutex_lock(port->manager_lock); port->original_manager->dispose(port->original_manager); if (port->manager_lock) pthread_mutex_unlock(port->manager_lock); @@ -498,7 +498,7 @@ static void post_overlay_dispose(video_overlay_manager_t *ovl_gen) { static int32_t post_overlay_get_handle(video_overlay_manager_t *ovl_gen, int object_type) { post_video_port_t *port = _x_post_ovl_manager_to_port(ovl_gen); int32_t handle; - + if (port->manager_lock) pthread_mutex_lock(port->manager_lock); handle = port->original_manager->get_handle(port->original_manager, object_type); if (port->manager_lock) pthread_mutex_unlock(port->manager_lock); @@ -507,7 +507,7 @@ static int32_t post_overlay_get_handle(video_overlay_manager_t *ovl_gen, int obj static void post_overlay_free_handle(video_overlay_manager_t *ovl_gen, int32_t handle) { post_video_port_t *port = _x_post_ovl_manager_to_port(ovl_gen); - + if (port->manager_lock) pthread_mutex_lock(port->manager_lock); port->original_manager->free_handle(port->original_manager, handle); if (port->manager_lock) pthread_mutex_unlock(port->manager_lock); @@ -516,7 +516,7 @@ static void post_overlay_free_handle(video_overlay_manager_t *ovl_gen, int32_t h static int32_t post_overlay_add_event(video_overlay_manager_t *ovl_gen, void *event) { post_video_port_t *port = _x_post_ovl_manager_to_port(ovl_gen); int32_t result; - + if (port->manager_lock) pthread_mutex_lock(port->manager_lock); result = port->original_manager->add_event(port->original_manager, event); if (port->manager_lock) pthread_mutex_unlock(port->manager_lock); @@ -525,7 +525,7 @@ static int32_t post_overlay_add_event(video_overlay_manager_t *ovl_gen, void *ev static void post_overlay_flush_events(video_overlay_manager_t *ovl_gen) { post_video_port_t *port = _x_post_ovl_manager_to_port(ovl_gen); - + if (port->manager_lock) pthread_mutex_lock(port->manager_lock); port->original_manager->flush_events(port->original_manager); if (port->manager_lock) pthread_mutex_unlock(port->manager_lock); @@ -534,17 +534,17 @@ static void post_overlay_flush_events(video_overlay_manager_t *ovl_gen) { static int post_overlay_redraw_needed(video_overlay_manager_t *ovl_gen, int64_t vpts) { post_video_port_t *port = _x_post_ovl_manager_to_port(ovl_gen); int redraw; - + if (port->manager_lock) pthread_mutex_lock(port->manager_lock); redraw = port->original_manager->redraw_needed(port->original_manager, vpts); if (port->manager_lock) pthread_mutex_unlock(port->manager_lock); return redraw; } -static void post_overlay_multiple_overlay_blend(video_overlay_manager_t *ovl_gen, int64_t vpts, +static void post_overlay_multiple_overlay_blend(video_overlay_manager_t *ovl_gen, int64_t vpts, vo_driver_t *output, vo_frame_t *vo_img, int enabled) { post_video_port_t *port = _x_post_ovl_manager_to_port(ovl_gen); - + if (port->manager_lock) pthread_mutex_lock(port->manager_lock); port->original_manager->multiple_overlay_blend(port->original_manager, vpts, output, vo_img, enabled); if (port->manager_lock) pthread_mutex_unlock(port->manager_lock); @@ -568,7 +568,7 @@ void _x_post_intercept_overlay_manager(video_overlay_manager_t *original, post_v port->new_manager->redraw_needed = post_overlay_redraw_needed; if (!port->new_manager->multiple_overlay_blend) port->new_manager->multiple_overlay_blend = post_overlay_multiple_overlay_blend; - + port->original_manager = original; } @@ -577,7 +577,7 @@ void _x_post_intercept_overlay_manager(video_overlay_manager_t *original, post_v static uint32_t post_audio_get_capabilities(xine_audio_port_t *port_gen) { post_audio_port_t *port = (post_audio_port_t *)port_gen; uint32_t caps; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); caps = port->original_port->get_capabilities(port->original_port); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -587,7 +587,7 @@ static uint32_t post_audio_get_capabilities(xine_audio_port_t *port_gen) { static int post_audio_get_property(xine_audio_port_t *port_gen, int property) { post_audio_port_t *port = (post_audio_port_t *)port_gen; int prop; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); prop = port->original_port->get_property(port->original_port, property); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -597,7 +597,7 @@ static int post_audio_get_property(xine_audio_port_t *port_gen, int property) { static int post_audio_set_property(xine_audio_port_t *port_gen, int property, int value) { post_audio_port_t *port = (post_audio_port_t *)port_gen; int val; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); val = port->original_port->set_property(port->original_port, property, value); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -608,7 +608,7 @@ static int post_audio_open(xine_audio_port_t *port_gen, xine_stream_t *stream, uint32_t bits, uint32_t rate, int mode) { post_audio_port_t *port = (post_audio_port_t *)port_gen; int result; - + _x_post_rewire(port->post); _x_post_inc_usage(port); if (port->port_lock) pthread_mutex_lock(port->port_lock); @@ -624,7 +624,7 @@ static int post_audio_open(xine_audio_port_t *port_gen, xine_stream_t *stream, static audio_buffer_t *post_audio_get_buffer(xine_audio_port_t *port_gen) { post_audio_port_t *port = (post_audio_port_t *)port_gen; audio_buffer_t *buf; - + _x_post_rewire(port->post); if (port->port_lock) pthread_mutex_lock(port->port_lock); buf = port->original_port->get_buffer(port->original_port); @@ -635,15 +635,15 @@ static audio_buffer_t *post_audio_get_buffer(xine_audio_port_t *port_gen) { static void post_audio_put_buffer(xine_audio_port_t *port_gen, audio_buffer_t *buf, xine_stream_t *stream) { post_audio_port_t *port = (post_audio_port_t *)port_gen; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); port->original_port->put_buffer(port->original_port, buf, stream); if (port->port_lock) pthread_mutex_unlock(port->port_lock); } - + static void post_audio_close(xine_audio_port_t *port_gen, xine_stream_t *stream) { post_audio_port_t *port = (post_audio_port_t *)port_gen; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); port->original_port->close(port->original_port, stream); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -653,7 +653,7 @@ static void post_audio_close(xine_audio_port_t *port_gen, xine_stream_t *stream) static void post_audio_exit(xine_audio_port_t *port_gen) { post_audio_port_t *port = (post_audio_port_t *)port_gen; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); port->original_port->exit(port->original_port); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -677,7 +677,7 @@ static int post_audio_control(xine_audio_port_t *port_gen, int cmd, ...) { static void post_audio_flush(xine_audio_port_t *port_gen) { post_audio_port_t *port = (post_audio_port_t *)port_gen; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); port->original_port->flush(port->original_port); if (port->port_lock) pthread_mutex_unlock(port->port_lock); @@ -687,7 +687,7 @@ static int post_audio_status(xine_audio_port_t *port_gen, xine_stream_t *stream, uint32_t *bits, uint32_t *rate, int *mode) { post_audio_port_t *port = (post_audio_port_t *)port_gen; int result; - + if (port->port_lock) pthread_mutex_lock(port->port_lock); result = port->original_port->status(port->original_port, stream, bits, rate, mode); *bits = port->bits; @@ -705,33 +705,33 @@ static int post_audio_rewire(xine_post_out_t *output_gen, void *data) { post_plugin_t *this = output->post; uint32_t bits, rate; int mode; - + if (!new_port) return 0; - + this->running_ticket->lock_port_rewiring(this->running_ticket, -1); this->running_ticket->revoke(this->running_ticket, 1); - + if (input_port->original_port->status(input_port->original_port, input_port->stream, &bits, &rate, &mode)) { (new_port->open) (new_port, input_port->stream, bits, rate, mode); input_port->original_port->close(input_port->original_port, input_port->stream); } input_port->original_port = new_port; - + this->running_ticket->issue(this->running_ticket, 1); this->running_ticket->unlock_port_rewiring(this->running_ticket); - + return 1; } post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_port_t *original, post_in_t **input, post_out_t **output) { post_audio_port_t *port = calloc(1, sizeof(post_audio_port_t)); - + if (!port) return NULL; - + port->new_port.open = post_audio_open; port->new_port.get_buffer = post_audio_get_buffer; port->new_port.put_buffer = post_audio_put_buffer; @@ -743,12 +743,12 @@ post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_ port->new_port.control = post_audio_control; port->new_port.flush = post_audio_flush; port->new_port.status = post_audio_status; - + port->original_port = original; port->post = post; - + pthread_mutex_init(&port->usage_lock, NULL); - + if (input) { *input = calloc(1, sizeof(post_in_t)); if (!*input) return port; @@ -758,7 +758,7 @@ post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_ (*input)->post = post; xine_list_push_back(post->input, *input); } - + if (output) { *output = calloc(1, sizeof(post_out_t)); if (!*output) return port; @@ -770,14 +770,14 @@ post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_ (*output)->user_data = port; xine_list_push_back(post->output, *output); } - + return port; } int _x_post_dispose(post_plugin_t *this) { int i, in_use = 0; - + /* acquire all usage locks */ for (i = 0; this->xine_post.audio_input[i]; i++) { post_audio_port_t *port = (post_audio_port_t *)this->xine_post.audio_input[i]; @@ -787,11 +787,11 @@ int _x_post_dispose(post_plugin_t *this) { post_video_port_t *port = (post_video_port_t *)this->xine_post.video_input[i]; pthread_mutex_lock(&port->usage_lock); } - + /* we can set this witout harm, because it is always checked with * usage lock held */ this->dispose_pending = 1; - + /* check counters */ for (i = 0; this->xine_post.audio_input[i]; i++) { post_audio_port_t *port = (post_audio_port_t *)this->xine_post.audio_input[i]; @@ -807,7 +807,7 @@ int _x_post_dispose(post_plugin_t *this) { break; } } - + /* free the locks */ for (i = 0; this->xine_post.audio_input[i]; i++) { post_audio_port_t *port = (post_audio_port_t *)this->xine_post.audio_input[i]; @@ -817,20 +817,20 @@ int _x_post_dispose(post_plugin_t *this) { post_video_port_t *port = (post_video_port_t *)this->xine_post.video_input[i]; pthread_mutex_unlock(&port->usage_lock); } - + if (!in_use) { xine_post_in_t *input; xine_post_out_t *output; xine_list_iterator_t ite; - + /* we can really dispose it */ - + free(this->xine_post.audio_input); free(this->xine_post.video_input); /* these were allocated in the plugin loader */ free(this->input_ids); free(this->output_ids); - + for (ite = xine_list_front(this->input); ite; ite = xine_list_next(this->input, ite)) { input = xine_list_get_value(this->input, ite); @@ -839,16 +839,16 @@ int _x_post_dispose(post_plugin_t *this) { { post_video_port_t *port = (post_video_port_t *)input->data; vo_frame_t *first, *second; - + pthread_mutex_destroy(&port->usage_lock); pthread_mutex_destroy(&port->free_frames_lock); - + second = NULL; for (first = port->free_frame_slots; first; second = first, first = first->next) free(second); free(second); - + free(port); free(input); } @@ -856,9 +856,9 @@ int _x_post_dispose(post_plugin_t *this) { case XINE_POST_DATA_AUDIO: { post_audio_port_t *port = (post_audio_port_t *)input->data; - + pthread_mutex_destroy(&port->usage_lock); - + free(port); free(input); } @@ -881,18 +881,18 @@ int _x_post_dispose(post_plugin_t *this) { break; } } - + xine_list_delete(this->input); xine_list_delete(this->output); - + /* since the plugin loader does not know, when the plugin gets disposed, * we have to handle the reference counter here */ pthread_mutex_lock(&this->xine->plugin_catalog->lock); this->node->ref--; pthread_mutex_unlock(&this->xine->plugin_catalog->lock); - + return 1; } - + return 0; } diff --git a/src/xine-engine/refcounter.c b/src/xine-engine/refcounter.c index 2c1b5a786..216693e88 100644 --- a/src/xine-engine/refcounter.c +++ b/src/xine-engine/refcounter.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -27,7 +27,7 @@ /* #define LOG */ - + #include <xine/xine_internal.h> #include <xine/refcounter.h> @@ -53,7 +53,7 @@ int _x_refcounter_inc(refcounter_t *refcounter) _x_abort(); res = ++refcounter->count; pthread_mutex_unlock(&refcounter->lock); - + return res; } @@ -68,7 +68,7 @@ int _x_refcounter_dec(refcounter_t *refcounter) lprintf("calling destructor of object %p\n", refcounter->object); refcounter->destructor(refcounter->object); } - + return res; } diff --git a/src/xine-engine/resample.c b/src/xine-engine/resample.c index f907c965e..c354bbd68 100644 --- a/src/xine-engine/resample.c +++ b/src/xine-engine/resample.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -30,7 +30,7 @@ /* contributed by paul flinders */ void _x_audio_out_resample_mono(int16_t *last_sample, - int16_t* input_samples, uint32_t in_samples, + int16_t* input_samples, uint32_t in_samples, int16_t* output_samples, uint32_t out_samples) { unsigned int osample; @@ -54,11 +54,11 @@ void _x_audio_out_resample_mono(int16_t *last_sample, int s2; int16_t os; uint32_t t = isample&0xffff; - + /* don't "optimize" the (isample >> 16)*2 to (isample >> 15) */ s1 = input_samples[(isample >> 16)]; s2 = input_samples[(isample >> 16)+1]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[osample] = os; @@ -68,7 +68,7 @@ void _x_audio_out_resample_mono(int16_t *last_sample, } void _x_audio_out_resample_stereo(int16_t *last_sample, - int16_t* input_samples, uint32_t in_samples, + int16_t* input_samples, uint32_t in_samples, int16_t* output_samples, uint32_t out_samples) { unsigned int osample; @@ -93,17 +93,17 @@ void _x_audio_out_resample_stereo(int16_t *last_sample, int s2; int16_t os; uint32_t t = isample&0xffff; - + /* don't "optimize" the (isample >> 16)*2 to (isample >> 15) */ s1 = input_samples[(isample >> 16)*2]; s2 = input_samples[(isample >> 16)*2+2]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[osample * 2] = os; s1 = input_samples[(isample >> 16)*2+1]; s2 = input_samples[(isample >> 16)*2+3]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 2 )+1] = os; isample += istep; @@ -113,7 +113,7 @@ void _x_audio_out_resample_stereo(int16_t *last_sample, void _x_audio_out_resample_4channel(int16_t *last_sample, - int16_t* input_samples, uint32_t in_samples, + int16_t* input_samples, uint32_t in_samples, int16_t* output_samples, uint32_t out_samples) { unsigned int osample; @@ -140,29 +140,29 @@ void _x_audio_out_resample_4channel(int16_t *last_sample, int s2; int16_t os; uint32_t t = isample&0xffff; - + /* don't "optimize" the (isample >> 16)*2 to (isample >> 15) */ s1 = input_samples[(isample >> 16)*4]; s2 = input_samples[(isample >> 16)*4+4]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[osample * 4] = os; s1 = input_samples[(isample >> 16)*4+1]; s2 = input_samples[(isample >> 16)*4+5]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 4 )+1] = os; s1 = input_samples[(isample >> 16)*4+2]; s2 = input_samples[(isample >> 16)*4+6]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 4 )+2] = os; s1 = input_samples[(isample >> 16)*4+3]; s2 = input_samples[(isample >> 16)*4+7]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 4 )+3] = os; @@ -173,7 +173,7 @@ void _x_audio_out_resample_4channel(int16_t *last_sample, void _x_audio_out_resample_5channel(int16_t *last_sample, - int16_t* input_samples, uint32_t in_samples, + int16_t* input_samples, uint32_t in_samples, int16_t* output_samples, uint32_t out_samples) { unsigned int osample; @@ -201,35 +201,35 @@ void _x_audio_out_resample_5channel(int16_t *last_sample, int s2; int16_t os; uint32_t t = isample&0xffff; - + /* don't "optimize" the (isample >> 16)*2 to (isample >> 15) */ s1 = input_samples[(isample >> 16)*5]; s2 = input_samples[(isample >> 16)*5+5]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[osample * 5] = os; s1 = input_samples[(isample >> 16)*5+1]; s2 = input_samples[(isample >> 16)*5+6]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 5 )+1] = os; s1 = input_samples[(isample >> 16)*5+2]; s2 = input_samples[(isample >> 16)*5+7]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 5 )+2] = os; s1 = input_samples[(isample >> 16)*5+3]; s2 = input_samples[(isample >> 16)*5+8]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 5 )+3] = os; s1 = input_samples[(isample >> 16)*5+4]; s2 = input_samples[(isample >> 16)*5+9]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 5 )+4] = os; @@ -240,7 +240,7 @@ void _x_audio_out_resample_5channel(int16_t *last_sample, void _x_audio_out_resample_6channel(int16_t *last_sample, - int16_t* input_samples, uint32_t in_samples, + int16_t* input_samples, uint32_t in_samples, int16_t* output_samples, uint32_t out_samples) { unsigned int osample; @@ -269,41 +269,41 @@ void _x_audio_out_resample_6channel(int16_t *last_sample, int s2; int16_t os; uint32_t t = isample&0xffff; - + /* don't "optimize" the (isample >> 16)*2 to (isample >> 15) */ s1 = input_samples[(isample >> 16)*6]; s2 = input_samples[(isample >> 16)*6+6]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[osample * 6] = os; s1 = input_samples[(isample >> 16)*6+1]; s2 = input_samples[(isample >> 16)*6+7]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 6 )+1] = os; s1 = input_samples[(isample >> 16)*6+2]; s2 = input_samples[(isample >> 16)*6+8]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 6 )+2] = os; s1 = input_samples[(isample >> 16)*6+3]; s2 = input_samples[(isample >> 16)*6+9]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 6 )+3] = os; s1 = input_samples[(isample >> 16)*6+4]; s2 = input_samples[(isample >> 16)*6+10]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 6 )+4] = os; s1 = input_samples[(isample >> 16)*6+5]; s2 = input_samples[(isample >> 16)*6+11]; - + os = (s1 * (0x10000-t)+ s2 * t) >> 16; output_samples[(osample * 6 )+5] = os; @@ -312,48 +312,48 @@ void _x_audio_out_resample_6channel(int16_t *last_sample, memcpy (last_sample, &input_samples[in_samples*6-6], 6 * sizeof (last_sample[0])); } -void _x_audio_out_resample_8to16(int8_t* input_samples, +void _x_audio_out_resample_8to16(int8_t* input_samples, int16_t* output_samples, uint32_t samples) { while( samples-- ) { int16_t os; - + os = *input_samples++; os = (os - 0x80) << 8; *output_samples++ = os; } } -void _x_audio_out_resample_16to8(int16_t* input_samples, +void _x_audio_out_resample_16to8(int16_t* input_samples, int8_t* output_samples, uint32_t samples) { while( samples-- ) { int16_t os; - + os = *input_samples++; os = (os >> 8) + 0x80; *output_samples++ = os; } } -void _x_audio_out_resample_monotostereo(int16_t* input_samples, +void _x_audio_out_resample_monotostereo(int16_t* input_samples, int16_t* output_samples, uint32_t frames) { while( frames-- ) { int16_t os; - + os = *input_samples++; *output_samples++ = os; *output_samples++ = os; } } -void _x_audio_out_resample_stereotomono(int16_t* input_samples, +void _x_audio_out_resample_stereotomono(int16_t* input_samples, int16_t* output_samples, uint32_t frames) { while( frames-- ) { int16_t os; - + os = (*input_samples++)>>1; os += (*input_samples++)>>1; *output_samples++ = os; diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c index 02c415e96..a15cd42d1 100644 --- a/src/xine-engine/scratch.c +++ b/src/xine-engine/scratch.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -84,14 +84,14 @@ static char **scratch_get_content (scratch_buffer_t *this) { static void scratch_dispose (scratch_buffer_t *this) { int i; - + pthread_mutex_lock (&this->lock); for(i = 0; i < this->num_lines; i++ ) { free(this->ordered[i]); free(this->lines[i]); } - + free (this->lines); free (this->ordered); diff --git a/src/xine-engine/spu.c b/src/xine-engine/spu.c index c610a43c9..9bc1de84c 100644 --- a/src/xine-engine/spu.c +++ b/src/xine-engine/spu.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2007 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @@ -46,7 +46,7 @@ void _x_spu_misc_init (xine_t *this) void _x_spu_get_opacity (xine_t *this, xine_spu_opacity_t *opacity) { cfg_entry_t *entry; - + entry = this->config->lookup_entry (this->config, "subtitles.bitmap.black_opacity"); opacity->black = entry ? entry->num_value : BLACK_OPACITY; entry = this->config->lookup_entry (this->config, "subtitles.bitmap.colour_opacity"); diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index af22ecdd0..ed2e41ef3 100644 --- a/src/xine-engine/video_decoder.c +++ b/src/xine-engine/video_decoder.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2005 the xine project * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -46,13 +46,13 @@ static void update_spu_decoder (xine_stream_t *stream, int type) { int streamtype = (type>>16) & 0xFF; - + if( stream->spu_decoder_streamtype != streamtype || !stream->spu_decoder_plugin ) { - + if (stream->spu_decoder_plugin) _x_free_spu_decoder (stream, stream->spu_decoder_plugin); - + stream->spu_decoder_streamtype = streamtype; stream->spu_decoder_plugin = _x_get_spu_decoder (stream, streamtype); @@ -64,27 +64,27 @@ int _x_spu_decoder_sleep(xine_stream_t *stream, int64_t next_spu_vpts) { int64_t time, wait; int thread_vacant = 1; - + /* we wait until one second before the next SPU is due */ next_spu_vpts -= 90000; - + do { if (next_spu_vpts) time = stream->xine->clock->get_current_time(stream->xine->clock); else time = 0; - + /* wait in pieces of one half second */ if (next_spu_vpts - time < SPU_SLEEP_INTERVAL) wait = next_spu_vpts - time; else wait = SPU_SLEEP_INTERVAL; - + if (wait > 0) xine_usec_sleep(wait * 11); - + if (stream->xine->port_ticket->ticket_revoked) stream->xine->port_ticket->renew(stream->xine->port_ticket, 0); - + /* never wait, if we share the thread with a video decoder */ thread_vacant = !stream->video_decoder_plugin; /* we have to return if video out calls for the decoder */ @@ -93,9 +93,9 @@ int _x_spu_decoder_sleep(xine_stream_t *stream, int64_t next_spu_vpts) /* we have to return if the demuxer needs us to release a buffer */ if (thread_vacant) thread_vacant = !stream->demux_action_pending; - + } while (wait == SPU_SLEEP_INTERVAL && thread_vacant); - + return thread_vacant; } @@ -118,7 +118,7 @@ static void *video_decoder_loop (void *stream_gen) { */ nice(-1); #endif /* WIN32 */ - + if (prof_video_decode == -1) prof_video_decode = xine_profiler_allocate_slot ("video decoder"); if (prof_spu_decode == -1) @@ -126,15 +126,15 @@ static void *video_decoder_loop (void *stream_gen) { while (running) { - lprintf ("getting buffer...\n"); + lprintf ("getting buffer...\n"); buf = stream->video_fifo->get (stream->video_fifo); - + _x_extra_info_merge( stream->video_decoder_extra_info, buf->extra_info ); stream->video_decoder_extra_info->seek_count = stream->video_seek_count; - - lprintf ("got buffer 0x%08x\n", buf->type); - + + lprintf ("got buffer 0x%08x\n", buf->type); + switch (buf->type & 0xffff0000) { case BUF_CONTROL_HEADERS_DONE: pthread_mutex_lock (&stream->counter_lock); @@ -144,34 +144,34 @@ static void *video_decoder_loop (void *stream_gen) { break; case BUF_CONTROL_START: - + /* decoder dispose might call port functions */ running_ticket->acquire(running_ticket, 0); - + if (stream->video_decoder_plugin) { _x_free_video_decoder (stream, stream->video_decoder_plugin); stream->video_decoder_plugin = NULL; } - + if (stream->spu_decoder_plugin) { _x_free_spu_decoder (stream, stream->spu_decoder_plugin); stream->spu_decoder_plugin = NULL; stream->spu_track_map_entries = 0; } - + running_ticket->release(running_ticket, 0); - + if( !(buf->decoder_flags & BUF_FLAG_GAPLESS_SW) ) - stream->metronom->handle_video_discontinuity (stream->metronom, + stream->metronom->handle_video_discontinuity (stream->metronom, DISC_STREAMSTART, 0); - + buftype_unknown = 0; break; case BUF_CONTROL_SPU_CHANNEL: { xine_event_t ui_event; - + /* We use widescreen spu as the auto selection, because widescreen * display is common. SPU decoders can choose differently if it suits * them. */ @@ -180,7 +180,7 @@ static void *video_decoder_loop (void *stream_gen) { stream->spu_channel_pan_scan = buf->decoder_info[2]; if (stream->spu_channel_user == -1) stream->spu_channel = stream->spu_channel_auto; - + /* Inform UI of SPU channel changes */ ui_event.type = XINE_EVENT_UI_CHANNELS_CHANGED; ui_event.data_length = 0; @@ -190,7 +190,7 @@ static void *video_decoder_loop (void *stream_gen) { break; case BUF_CONTROL_END: - + /* flush decoder frames if stream finished naturally (non-user stop) */ if( buf->decoder_flags ) { running_ticket->acquire(running_ticket, 0); @@ -211,12 +211,12 @@ static void *video_decoder_loop (void *stream_gen) { */ while(1) { int num_bufs, num_streams; - + running_ticket->acquire(running_ticket, 0); num_bufs = stream->video_out->get_property(stream->video_out, VO_PROP_BUFS_IN_FIFO); num_streams = stream->video_out->get_property(stream->video_out, VO_PROP_NUM_STREAMS); running_ticket->release(running_ticket, 0); - + if( num_bufs > 0 && num_streams == 1 && !stream->early_finish_event && stream->master == stream ) xine_usec_sleep (10000); @@ -230,7 +230,7 @@ static void *video_decoder_loop (void *stream_gen) { stream->finished_count_video++; - lprintf ("reached end marker # %d\n", + lprintf ("reached end marker # %d\n", stream->finished_count_video); pthread_cond_broadcast (&stream->counter_changed); @@ -247,7 +247,7 @@ static void *video_decoder_loop (void *stream_gen) { pthread_cond_timedwait (&stream->counter_changed, &stream->counter_lock, &ts); } } - + pthread_mutex_unlock (&stream->counter_lock); /* Wake up xine_play if it's waiting for a frame */ @@ -262,7 +262,7 @@ static void *video_decoder_loop (void *stream_gen) { case BUF_CONTROL_QUIT: /* decoder dispose might call port functions */ running_ticket->acquire(running_ticket, 0); - + if (stream->video_decoder_plugin) { _x_free_video_decoder (stream, stream->video_decoder_plugin); stream->video_decoder_plugin = NULL; @@ -298,7 +298,7 @@ static void *video_decoder_loop (void *stream_gen) { running_ticket->release(running_ticket, 0); } break; - + case BUF_CONTROL_DISCONTINUITY: lprintf ("discontinuity ahead\n"); @@ -310,11 +310,11 @@ static void *video_decoder_loop (void *stream_gen) { stream->video_decoder_plugin->discontinuity (stream->video_decoder_plugin); running_ticket->release(running_ticket, 0); } - + stream->metronom->handle_video_discontinuity (stream->metronom, DISC_RELATIVE, buf->disc_off); break; - + case BUF_CONTROL_NEWPTS: lprintf ("new pts %"PRId64"\n", buf->disc_off); @@ -326,14 +326,14 @@ static void *video_decoder_loop (void *stream_gen) { stream->video_decoder_plugin->discontinuity (stream->video_decoder_plugin); running_ticket->release(running_ticket, 0); } - + if (buf->decoder_flags & BUF_FLAG_SEEK) { stream->metronom->handle_video_discontinuity (stream->metronom, DISC_STREAMSEEK, buf->disc_off); } else { stream->metronom->handle_video_discontinuity (stream->metronom, DISC_ABSOLUTE, buf->disc_off); - } + } break; - + case BUF_CONTROL_AUDIO_CHANNEL: { xine_event_t ui_event; @@ -346,7 +346,7 @@ static void *video_decoder_loop (void *stream_gen) { case BUF_CONTROL_NOP: break; - + default: if ( (buf->type & 0xFF000000) == BUF_VIDEO_BASE ) { @@ -355,43 +355,43 @@ static void *video_decoder_loop (void *stream_gen) { break; xine_profiler_start_count (prof_video_decode); - + running_ticket->acquire(running_ticket, 0); - + /* - printf ("video_decoder: got package %d, decoder_info[0]:%d\n", + printf ("video_decoder: got package %d, decoder_info[0]:%d\n", buf, buf->decoder_info[0]); - */ - + */ + streamtype = (buf->type>>16) & 0xFF; - + if( buf->type != buftype_unknown && (stream->video_decoder_streamtype != streamtype || !stream->video_decoder_plugin) ) { - + if (stream->video_decoder_plugin) { _x_free_video_decoder (stream, stream->video_decoder_plugin); } - + stream->video_decoder_streamtype = streamtype; stream->video_decoder_plugin = _x_get_video_decoder (stream, streamtype); - + _x_stream_info_set(stream, XINE_STREAM_INFO_VIDEO_HANDLED, (stream->video_decoder_plugin != NULL)); } if (stream->video_decoder_plugin) - stream->video_decoder_plugin->decode_data (stream->video_decoder_plugin, buf); - - if (buf->type != buftype_unknown && + stream->video_decoder_plugin->decode_data (stream->video_decoder_plugin, buf); + + if (buf->type != buftype_unknown && !_x_stream_info_get(stream, XINE_STREAM_INFO_VIDEO_HANDLED)) { - xine_log (stream->xine, XINE_LOG_MSG, + xine_log (stream->xine, XINE_LOG_MSG, _("video_decoder: no plugin available to handle '%s'\n"), _x_buf_video_name( buf->type ) ); - + if( !_x_meta_info_get(stream, XINE_META_INFO_VIDEOCODEC)) _x_meta_info_set_utf8(stream, XINE_META_INFO_VIDEOCODEC, _x_buf_video_name( buf->type )); - + buftype_unknown = buf->type; - + /* fatal error - dispose plugin */ if (stream->video_decoder_plugin) { _x_free_video_decoder (stream, stream->video_decoder_plugin); @@ -402,7 +402,7 @@ static void *video_decoder_loop (void *stream_gen) { if (running_ticket->ticket_revoked) running_ticket->renew(running_ticket, 0); running_ticket->release(running_ticket, 0); - + xine_profiler_stop_count (prof_video_decode); } else if ( (buf->type & 0xFF000000) == BUF_SPU_BASE ) { @@ -415,15 +415,15 @@ static void *video_decoder_loop (void *stream_gen) { xine_profiler_start_count (prof_spu_decode); running_ticket->acquire(running_ticket, 0); - + update_spu_decoder(stream, buf->type); /* update track map */ i = 0; - while ( (i<stream->spu_track_map_entries) && (stream->spu_track_map[i]<buf->type) ) + while ( (i<stream->spu_track_map_entries) && (stream->spu_track_map[i]<buf->type) ) i++; - + if ( (i==stream->spu_track_map_entries) || (stream->spu_track_map[i] != buf->type) ) { xine_event_t ui_event; @@ -459,15 +459,15 @@ static void *video_decoder_loop (void *stream_gen) { if (running_ticket->ticket_revoked) running_ticket->renew(running_ticket, 0); running_ticket->release(running_ticket, 0); - + xine_profiler_stop_count (prof_spu_decode); } else if (buf->type != buftype_unknown) { - xine_log (stream->xine, XINE_LOG_MSG, + xine_log (stream->xine, XINE_LOG_MSG, _("video_decoder: error, unknown buffer type: %08x\n"), buf->type ); buftype_unknown = buf->type; } - + break; } @@ -479,13 +479,13 @@ static void *video_decoder_loop (void *stream_gen) { } int _x_video_decoder_init (xine_stream_t *stream) { - + if (stream->video_out == NULL) { stream->video_fifo = _x_dummy_fifo_buffer_new (5, 8192); stream->spu_track_map_entries = 0; return 1; } else { - + pthread_attr_t pth_attrs; struct sched_param pth_params; int err, num_buffers; @@ -496,7 +496,7 @@ int _x_video_decoder_init (xine_stream_t *stream) { * We provide buffers of 8k size instead of 2k for demuxers sending * larger chunks. */ - + num_buffers = stream->xine->config->register_num (stream->xine->config, "engine.buffers.video_num_buffers", 500, @@ -506,15 +506,15 @@ int _x_video_decoder_init (xine_stream_t *stream) { "mean smoother playback for unreliable inputs, but " "also increased latency and memory consumption."), 20, NULL, NULL); - + stream->video_fifo = _x_fifo_buffer_new (num_buffers, 8192); if (stream->video_fifo == NULL) { xine_log(stream->xine, XINE_LOG_MSG, "video_decoder: can't allocated video fifo\n"); return 0; } - + stream->spu_track_map_entries = 0; - + pthread_attr_init(&pth_attrs); pthread_attr_getschedparam(&pth_attrs, &pth_params); pth_params.sched_priority = sched_get_priority_min(SCHED_OTHER); @@ -530,7 +530,7 @@ int _x_video_decoder_init (xine_stream_t *stream) { pthread_attr_destroy(&pth_attrs); return 0; } - + pthread_attr_destroy(&pth_attrs); } return 1; @@ -562,7 +562,7 @@ void _x_video_decoder_shutdown (xine_stream_t *stream) { lprintf ("shutdown...4\n"); } - + stream->video_fifo->dispose (stream->video_fifo); stream->video_fifo = NULL; } diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 6a2d751bd..59975bab0 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -57,10 +57,10 @@ #define FIRST_FRAME_POLL_DELAY 3000 #define FIRST_FRAME_MAX_POLL 10 /* poll n times at most */ -/* experimental optimization: try to allocate frames from free queue +/* experimental optimization: try to allocate frames from free queue * in the same format as requested (avoid unnecessary free/alloc in * vo driver). up to 25% less cpu load using deinterlace with film mode. - */ + */ #define EXPERIMENTAL_FRAME_QUEUE_OPTIMIZATION 1 static vo_frame_t * crop_frame( xine_video_port_t *this_gen, vo_frame_t *img ); @@ -77,7 +77,7 @@ typedef struct { } img_buf_fifo_t; typedef struct { - + xine_video_port_t vo; /* public part */ vo_driver_t *driver; @@ -86,7 +86,7 @@ typedef struct { metronom_clock_t *clock; xine_list_t *streams; pthread_mutex_t streams_lock; - + img_buf_fifo_t *free_img_buf_queue; img_buf_fifo_t *display_img_buf_queue; @@ -105,7 +105,7 @@ typedef struct { uint32_t redraw_needed:3; int discard_frames; - + pthread_t video_thread; int num_frames_delivered; @@ -118,7 +118,7 @@ typedef struct { int warn_threshold_exceeded; /* pts value when decoder delivered last video frame */ - int64_t last_delivery_pts; + int64_t last_delivery_pts; video_overlay_manager_t *overlay_source; @@ -218,7 +218,7 @@ static vo_frame_t *vo_remove_from_img_buf_queue_int (img_buf_fifo_t *queue, int img = img->next; i++; } - + if( width && height ) { if( !img ) { if( queue->num_buffers == 1 && !blocking && queue->num_buffers_max > 8) { @@ -266,7 +266,7 @@ static vo_frame_t *vo_remove_from_img_buf_queue_int (img_buf_fifo_t *queue, int if( img == queue->last ) queue->last = previous; } - + img->next = NULL; if (!queue->first) { queue->last = NULL; @@ -275,7 +275,7 @@ static vo_frame_t *vo_remove_from_img_buf_queue_int (img_buf_fifo_t *queue, int queue->num_buffers--; } } - + return img; } @@ -306,7 +306,7 @@ static vo_frame_t *vo_remove_from_img_buf_queue_nonblock (img_buf_fifo_t *queue, * functions to maintain lock_counter */ static void vo_frame_inc_lock (vo_frame_t *img) { - + pthread_mutex_lock (&img->mutex); img->lock_counter++; @@ -315,11 +315,11 @@ static void vo_frame_inc_lock (vo_frame_t *img) { } static void vo_frame_dec_lock (vo_frame_t *img) { - + pthread_mutex_lock (&img->mutex); img->lock_counter--; - if (!img->lock_counter) { + if (!img->lock_counter) { vos_t *this = (vos_t *) img->port; if (img->stream) _x_refcounter_dec(img->stream->refcounter); @@ -336,11 +336,11 @@ static void vo_frame_driver_proc(vo_frame_t *img) img->proc_frame(img); } if (img->proc_called) return; - + if (img->proc_slice) { int height = img->height; uint8_t* src[3]; - + switch (img->format) { case XINE_IMGFMT_YV12: src[0] = img->base[0]; @@ -365,7 +365,7 @@ static void vo_frame_driver_proc(vo_frame_t *img) } /* - * + * * functions called by video decoder: * * get_frame => alloc frame for rendering @@ -396,7 +396,7 @@ static vo_frame_t *vo_get_frame (xine_video_port_t *this_gen, /* some decoders report strange ratios */ if (ratio <= 0.0) ratio = (double)width / (double)height; - + pthread_mutex_lock (&img->mutex); img->lock_counter = 1; img->width = width; @@ -421,11 +421,11 @@ static vo_frame_t *vo_get_frame (xine_video_port_t *this_gen, /* let driver ensure this image has the right format */ - this->driver->update_frame_format (this->driver, img, width, height, + this->driver->update_frame_format (this->driver, img, width, height, ratio, format, flags); pthread_mutex_unlock (&img->mutex); - + lprintf ("get_frame (%d x %d) done\n", width, height); return img; @@ -442,11 +442,11 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { /* handle anonymous streams like NULL for easy checking */ if (stream == XINE_ANON_STREAM) stream = NULL; - + img->stream = stream; this->current_width = img->width; this->current_height = img->height; - + if (stream) { _x_refcounter_inc(stream->refcounter); _x_extra_info_merge( img->extra_info, stream->video_decoder_extra_info ); @@ -468,13 +468,13 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { this->num_frames_delivered++; diff = pic_vpts - cur_vpts; - + /* avoid division by zero */ if( img->duration <= 0 ) duration = DEFAULT_FRAME_DURATION; else duration = img->duration; - + /* Frame dropping slow start: * The engine starts to drop frames if there are less than frame_drop_limit * frames in advance. There might be a problem just after a seek because @@ -500,7 +500,7 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { if (this->display_img_buf_queue->num_buffers >= this->frame_drop_limit || frames_to_skip < 0) frames_to_skip = 0; - + /* Do not drop frames immediately, but remember this as suggestion and give * decoder a further chance to supply frames. * This avoids unnecessary frame drops in situations where there is only @@ -518,7 +518,7 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { lprintf ("delivery diff : %" PRId64 ", current vpts is %" PRId64 ", %d frames to skip\n", diff, cur_vpts, frames_to_skip); - + } else { frames_to_skip = 0; @@ -531,18 +531,18 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { if (!img->bad_frame) { - + int img_already_locked = 0; xine_list_iterator_t ite; - + /* add cropping requested by frontend */ img->crop_left += this->crop_left; img->crop_right += this->crop_right; img->crop_top += this->crop_top; img->crop_bottom += this->crop_bottom; - + /* perform cropping when vo driver does not support it */ - if( (img->crop_left || img->crop_top || + if( (img->crop_left || img->crop_top || img->crop_right || img->crop_bottom) && (this->grab_only || !(this->driver->get_capabilities (this->driver) & VO_CAP_CROP)) ) { @@ -559,11 +559,11 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { img->crop_bottom = 0; } } - + /* do not call proc_*() for frames that will be dropped */ if( !frames_to_skip && !img->proc_called ) vo_frame_driver_proc(img); - + /* * put frame into FIFO-Buffer */ @@ -597,7 +597,7 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { if (!img_already_locked) vo_frame_inc_lock( img ); vo_append_to_img_buf_queue (this->display_img_buf_queue, img); - + } else { lprintf ("bad_frame\n"); @@ -629,7 +629,7 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { /* make sure threshold has being consistently exceeded - 5 times in a row * (that is, this is not just a small burst of dropped frames). */ - send_event = (this->warn_threshold_exceeded == 5 && + send_event = (this->warn_threshold_exceeded == 5 && !this->warn_threshold_event_sent); this->warn_threshold_event_sent = send_event; @@ -638,7 +638,7 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { ite = xine_list_next(this->streams, ite)) { stream = xine_list_get_value(this->streams, ite); if (stream == XINE_ANON_STREAM) continue; - _x_stream_info_set(stream, XINE_STREAM_INFO_SKIPPED_FRAMES, + _x_stream_info_set(stream, XINE_STREAM_INFO_SKIPPED_FRAMES, 1000 * this->num_frames_skipped / this->num_frames_delivered); _x_stream_info_set(stream, XINE_STREAM_INFO_DISCARDED_FRAMES, 1000 * this->num_frames_discarded / this->num_frames_delivered); @@ -666,8 +666,8 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { if( this->num_frames_skipped || this->num_frames_discarded ) { xine_log(this->xine, XINE_LOG_MSG, - _("%d frames delivered, %d frames skipped, %d frames discarded\n"), - this->num_frames_delivered, + _("%d frames delivered, %d frames skipped, %d frames discarded\n"), + this->num_frames_delivered, this->num_frames_skipped, this->num_frames_discarded); } @@ -675,7 +675,7 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { this->num_frames_discarded = 0; this->num_frames_skipped = 0; } - + return frames_to_skip; } @@ -685,9 +685,9 @@ static int vo_frame_draw (vo_frame_t *img, xine_stream_t *stream) { * */ -/* duplicate_frame(): this function is used to keep playing frames - * while video is still or player paused. - * +/* duplicate_frame(): this function is used to keep playing frames + * while video is still or player paused. + * * frame allocation inside vo loop is dangerous: * we must never wait for a free frame -> deadlock condition. * to avoid deadlocks we don't use vo_remove_from_img_buf_queue() @@ -712,7 +712,7 @@ static vo_frame_t * duplicate_frame( vos_t *this, vo_frame_t *img ) { else { this->free_img_buf_queue->num_buffers--; } - + pthread_mutex_lock (&dupl->mutex); dupl->lock_counter = 1; dupl->width = img->width; @@ -729,16 +729,16 @@ static vo_frame_t * duplicate_frame( vos_t *this, vo_frame_t *img ) { dupl->crop_bottom = img->crop_bottom; dupl->overlay_offset_x = img->overlay_offset_x; dupl->overlay_offset_y = img->overlay_offset_y; - - this->driver->update_frame_format (this->driver, dupl, dupl->width, dupl->height, + + this->driver->update_frame_format (this->driver, dupl, dupl->width, dupl->height, dupl->ratio, dupl->format, dupl->flags); pthread_mutex_unlock (&dupl->mutex); - + if (dupl->proc_duplicate_frame_data) { dupl->proc_duplicate_frame_data(dupl,img); } else { - + switch (img->format) { case XINE_IMGFMT_YV12: yv12_to_yv12( @@ -764,8 +764,8 @@ static vo_frame_t * duplicate_frame( vos_t *this, vo_frame_t *img ) { img->width, img->height); break; } - } - + } + dupl->bad_frame = 0; dupl->pts = 0; dupl->vpts = 0; @@ -776,10 +776,10 @@ static vo_frame_t * duplicate_frame( vos_t *this, vo_frame_t *img ) { dupl->stream = NULL; memcpy( dupl->extra_info, img->extra_info, sizeof(extra_info_t) ); - + /* delay frame processing for now, we might not even need it (eg. frame will be discarded) */ /* vo_frame_driver_proc(dupl); */ - + return dupl; } @@ -792,7 +792,7 @@ static void expire_frames (vos_t *this, int64_t cur_vpts) { int duration; pthread_mutex_lock(&this->display_img_buf_queue->mutex); - + img = this->display_img_buf_queue->first; /* @@ -809,7 +809,7 @@ static void expire_frames (vos_t *this, int64_t cur_vpts) { /* * before displaying the first frame without - * "metronom prebuffering" we should make sure it's + * "metronom prebuffering" we should make sure it's * not used as a decoder reference anymore. */ if( img->lock_counter == 1 ) { @@ -831,21 +831,21 @@ static void expire_frames (vos_t *this, int64_t cur_vpts) { duration = DEFAULT_FRAME_DURATION; } else duration = img->duration; - + pts = img->vpts; diff = cur_vpts - pts; - + if (diff > duration || this->discard_frames) { - + if( !this->discard_frames ) { xine_log(this->xine, XINE_LOG_MSG, _("video_out: throwing away image with pts %" PRId64 " because it's too old (diff : %" PRId64 ").\n"), pts, diff); this->num_frames_discarded++; } - + img = vo_remove_from_img_buf_queue_int (this->display_img_buf_queue, 1, 0, 0, 0, 0, 0); - + if (img->stream) { pthread_mutex_lock( &img->stream->current_extra_info_lock ); _x_extra_info_merge( img->stream->current_extra_info, img->extra_info ); @@ -854,21 +854,21 @@ static void expire_frames (vos_t *this, int64_t cur_vpts) { /* when flushing frames, keep the first one as backup */ if( this->discard_frames ) { - + if (!this->img_backup) { this->img_backup = img; } else { vo_frame_dec_lock( img ); - } - + } + } else { /* - * last frame? back it up for + * last frame? back it up for * still frame creation */ - + if (!this->display_img_buf_queue->first) { - + if (this->img_backup) { lprintf("overwriting frame backup\n"); @@ -878,20 +878,20 @@ static void expire_frames (vos_t *this, int64_t cur_vpts) { lprintf("possible still frame (old)\n"); this->img_backup = img; - - /* wait 4 frames before drawing this one. + + /* wait 4 frames before drawing this one. this allow slower systems to recover. */ - this->redraw_needed = 4; + this->redraw_needed = 4; } else { vo_frame_dec_lock( img ); } } img = this->display_img_buf_queue->first; - + } else break; } - + pthread_mutex_unlock(&this->display_img_buf_queue->mutex); } @@ -900,16 +900,16 @@ static void expire_frames (vos_t *this, int64_t cur_vpts) { */ static vo_frame_t *get_next_frame (vos_t *this, int64_t cur_vpts, int64_t *next_frame_vpts) { - + vo_frame_t *img; pthread_mutex_lock(&this->display_img_buf_queue->mutex); - + img = this->display_img_buf_queue->first; *next_frame_vpts = 0; - /* + /* * still frame detection: */ @@ -934,11 +934,11 @@ static vo_frame_t *get_next_frame (vos_t *this, int64_t cur_vpts, /* extra info of the backup is thrown away, because it is not up to date */ _x_extra_info_reset(img->extra_info); } - + return img; } else { - + if( this->redraw_needed ) this->redraw_needed--; @@ -970,13 +970,13 @@ static vo_frame_t *get_next_frame (vos_t *this, int64_t cur_vpts, vo_frame_dec_lock( this->img_backup ); this->img_backup = NULL; } - - /* - * last frame? make backup for possible still image + + /* + * last frame? make backup for possible still image */ pthread_mutex_lock( &this->free_img_buf_queue->mutex ); if (img && !img->next) { - + if (!img->stream || _x_stream_info_get(img->stream, XINE_STREAM_INFO_VIDEO_HAS_STILL) || !img->stream->video_fifo || @@ -992,7 +992,7 @@ static vo_frame_t *get_next_frame (vos_t *this, int64_t cur_vpts, /* * remove frame from display queue and show it */ - + img = vo_remove_from_img_buf_queue_int (this->display_img_buf_queue, 1, 0, 0, 0, 0, 0); pthread_mutex_unlock(&this->display_img_buf_queue->mutex); @@ -1000,7 +1000,7 @@ static vo_frame_t *get_next_frame (vos_t *this, int64_t cur_vpts, } } -static void overlay_and_display_frame (vos_t *this, +static void overlay_and_display_frame (vos_t *this, vo_frame_t *img, int64_t vpts) { xine_stream_t *stream; xine_list_iterator_t ite; @@ -1012,19 +1012,19 @@ static void overlay_and_display_frame (vos_t *this, */ if(!img->proc_called ) vo_frame_driver_proc(img); - + if (img->stream) { int64_t diff; pthread_mutex_lock( &img->stream->current_extra_info_lock ); diff = img->extra_info->vpts - img->stream->current_extra_info->vpts; - if ((diff > 3000) || (diff<-300000)) + if ((diff > 3000) || (diff<-300000)) _x_extra_info_merge( img->stream->current_extra_info, img->extra_info ); pthread_mutex_unlock( &img->stream->current_extra_info_lock ); } if (this->overlay_source) { - this->overlay_source->multiple_overlay_blend (this->overlay_source, - vpts, + this->overlay_source->multiple_overlay_blend (this->overlay_source, + vpts, this->driver, img, this->video_loop_running && this->overlay_enabled); } @@ -1037,7 +1037,7 @@ static void overlay_and_display_frame (vos_t *this, this->last_frame = img; this->driver->display_frame (this->driver, img); - + /* * Wake up xine_play if it's waiting for a frame */ @@ -1057,16 +1057,16 @@ static void overlay_and_display_frame (vos_t *this, pthread_mutex_unlock(&this->streams_lock); } - this->redraw_needed = 0; + this->redraw_needed = 0; } static void check_redraw_needed (vos_t *this, int64_t vpts) { if (this->overlay_source) { if( this->overlay_source->redraw_needed (this->overlay_source, vpts) ) - this->redraw_needed = 1; + this->redraw_needed = 1; } - + if( this->driver->redraw_needed (this->driver) ) this->redraw_needed = 1; } @@ -1100,36 +1100,36 @@ static int interruptable_sleep(vos_t *this, int usec_to_sleep) /* special loop for paused mode * needed to update screen due overlay changes, resize, window * movement, brightness adjusting etc. - */ + */ static void paused_loop( vos_t *this, int64_t vpts ) { vo_frame_t *img; - + pthread_mutex_lock( &this->free_img_buf_queue->mutex ); /* prevent decoder thread from allocating new frames */ this->free_img_buf_queue->locked_for_read = 1; - + while (this->clock->speed == XINE_SPEED_PAUSE && this->video_loop_running) { - + /* we need at least one free frame to keep going */ if( this->display_img_buf_queue->first && !this->free_img_buf_queue->first ) { - + img = vo_remove_from_img_buf_queue (this->display_img_buf_queue); img->next = NULL; this->free_img_buf_queue->first = img; this->free_img_buf_queue->last = img; this->free_img_buf_queue->num_buffers = 1; } - + /* set img_backup to play the same frame several times */ if( this->display_img_buf_queue->first && !this->img_backup ) { this->img_backup = vo_remove_from_img_buf_queue (this->display_img_buf_queue); this->redraw_needed = 1; } - + check_redraw_needed( this, vpts ); - + if( this->redraw_needed && this->img_backup ) { img = duplicate_frame (this, this->img_backup ); if( img ) { @@ -1138,16 +1138,16 @@ static void paused_loop( vos_t *this, int64_t vpts ) pthread_mutex_unlock( &this->free_img_buf_queue->mutex ); overlay_and_display_frame (this, img, vpts); pthread_mutex_lock( &this->free_img_buf_queue->mutex ); - } + } } - + pthread_mutex_unlock( &this->free_img_buf_queue->mutex ); interruptable_sleep(this, 20000); pthread_mutex_lock( &this->free_img_buf_queue->mutex ); } - + this->free_img_buf_queue->locked_for_read = 0; - + if( this->free_img_buf_queue->first ) pthread_cond_signal (&this->free_img_buf_queue->not_empty); pthread_mutex_unlock( &this->free_img_buf_queue->mutex ); @@ -1160,7 +1160,7 @@ static void *video_out_loop (void *this_gen) { vos_t *this = (vos_t *) this_gen; int64_t next_frame_vpts = 0; int64_t usec_to_sleep; - + #ifndef WIN32 /* nice(-value) will fail silently for normal users. * however when running as root this may provide smoother @@ -1174,7 +1174,7 @@ static void *video_out_loop (void *this_gen) { * here it is - the heart of xine (or rather: one of the hearts * of xine) : the video output loop */ - + lprintf ("loop starting...\n"); while ( this->video_loop_running ) { @@ -1214,7 +1214,7 @@ static void *video_out_loop (void *this_gen) { diff = vpts - this->last_delivery_pts; if (diff > 30000 && !this->display_img_buf_queue->first) { xine_list_iterator_t ite; - + pthread_mutex_lock(&this->streams_lock); for (ite = xine_list_front(this->streams); ite; ite = xine_list_next(this->streams, ite)) { @@ -1222,9 +1222,9 @@ static void *video_out_loop (void *this_gen) { if (stream == XINE_ANON_STREAM) continue; if (stream->video_decoder_plugin && stream->video_fifo) { buf_element_t *buf; - + lprintf ("flushing current video decoder plugin\n"); - + buf = stream->video_fifo->buffer_pool_try_alloc (stream->video_fifo); if( buf ) { buf->type = BUF_CONTROL_FLUSH_DECODER; @@ -1244,12 +1244,12 @@ static void *video_out_loop (void *this_gen) { next_frame_vpts = img->vpts + img->duration; } /* else next_frame_vpts is returned by get_next_frame */ - + lprintf ("next_frame_vpts is %" PRId64 "\n", next_frame_vpts); - + do { vpts = this->clock->get_current_time (this->clock); - + if (this->clock->speed == XINE_SPEED_PAUSE) paused_loop (this, vpts); @@ -1266,11 +1266,11 @@ static void *video_out_loop (void *this_gen) { usec_to_sleep = MAX_USEC_TO_SLEEP; lprintf ("%" PRId64 " usec to sleep at master vpts %" PRId64 "\n", usec_to_sleep, vpts); - + if ( (next_frame_vpts - vpts) > 2*90000 ) xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out: vpts/clock error, next_vpts=%" PRId64 " cur_vpts=%" PRId64 "\n", next_frame_vpts,vpts); - + if (usec_to_sleep > 0) { if (0 == interruptable_sleep(this, usec_to_sleep)) @@ -1286,7 +1286,7 @@ static void *video_out_loop (void *this_gen) { /* * throw away undisplayed frames */ - + pthread_mutex_lock(&this->display_img_buf_queue->mutex); img = this->display_img_buf_queue->first; while (img) { @@ -1329,9 +1329,9 @@ int xine_get_next_video_frame (xine_video_port_t *this_gen, xine_usec_sleep (5000); continue; } - + /* FIXME: ugly, use conditions and locks instead? */ - + pthread_mutex_lock(&this->display_img_buf_queue->mutex); img = this->display_img_buf_queue->first; if (!img) { @@ -1348,7 +1348,7 @@ int xine_get_next_video_frame (xine_video_port_t *this_gen, /* * remove frame from display queue and show it */ - + img = vo_remove_from_img_buf_queue_int (this->display_img_buf_queue, 1, 0, 0, 0, 0, 0); pthread_mutex_unlock(&this->display_img_buf_queue->mutex); @@ -1367,7 +1367,7 @@ int xine_get_next_video_frame (xine_video_port_t *this_gen, return 1; } -void xine_free_video_frame (xine_video_port_t *port, +void xine_free_video_frame (xine_video_port_t *port, xine_video_frame_t *frame) { vo_frame_t *img = (vo_frame_t *) frame->xine_frame; @@ -1409,7 +1409,7 @@ static void vo_close (xine_video_port_t *this_gen, xine_stream_t *stream) { this->overlay_source->flush_events (this->overlay_source); this->video_opened = 0; - + /* unregister stream */ pthread_mutex_lock(&this->streams_lock); for (ite = xine_list_front(this->streams); ite; @@ -1432,17 +1432,17 @@ static int vo_get_property (xine_video_port_t *this_gen, int property) { case VO_PROP_DISCARD_FRAMES: ret = this->discard_frames; break; - + case VO_PROP_BUFS_IN_FIFO: ret = this->video_loop_running ? this->display_img_buf_queue->num_buffers : -1; break; - + case VO_PROP_NUM_STREAMS: pthread_mutex_lock(&this->streams_lock); ret = xine_list_size(this->streams); pthread_mutex_unlock(&this->streams_lock); break; - + /* * handle XINE_PARAM_xxx properties (convert from driver's range) */ @@ -1458,7 +1458,7 @@ static int vo_get_property (xine_video_port_t *this_gen, int property) { case XINE_PARAM_VO_CROP_BOTTOM: ret = this->crop_bottom; break; - + case XINE_PARAM_VO_HUE: case XINE_PARAM_VO_SATURATION: case XINE_PARAM_VO_CONTRAST: @@ -1476,12 +1476,12 @@ static int vo_get_property (xine_video_port_t *this_gen, int property) { if (range_v > 0) ret = ((v-min_v) * 65536 + 32768) / range_v; - else + else ret = 0; pthread_mutex_unlock( &this->driver_lock ); } break; - + default: pthread_mutex_lock( &this->driver_lock ); ret = this->driver->get_property(this->driver, property & 0xffffff); @@ -1495,7 +1495,7 @@ static int vo_set_property (xine_video_port_t *this_gen, int property, int value int ret; switch (property) { - + case VO_PROP_DISCARD_FRAMES: /* recursive discard frames setting */ pthread_mutex_lock(&this->display_img_buf_queue->mutex); @@ -1505,19 +1505,19 @@ static int vo_set_property (xine_video_port_t *this_gen, int property, int value this->discard_frames--; pthread_mutex_unlock(&this->display_img_buf_queue->mutex); ret = this->discard_frames; - + /* discard buffers here because we have no output thread */ if (this->grab_only && this->discard_frames) { vo_frame_t *img; - + pthread_mutex_lock(&this->display_img_buf_queue->mutex); - + while ((img = this->display_img_buf_queue->first)) { - + lprintf ("flushing out frame\n"); - + img = vo_remove_from_img_buf_queue_int (this->display_img_buf_queue, 1, 0, 0, 0, 0, 0); - + vo_frame_dec_lock (img); } pthread_mutex_unlock(&this->display_img_buf_queue->mutex); @@ -1547,32 +1547,32 @@ static int vo_set_property (xine_video_port_t *this_gen, int property, int value value = 0; ret = this->crop_bottom = value; break; - + case XINE_PARAM_VO_HUE: case XINE_PARAM_VO_SATURATION: case XINE_PARAM_VO_CONTRAST: case XINE_PARAM_VO_BRIGHTNESS: if (!this->grab_only) { int v, min_v, max_v, range_v; - + pthread_mutex_lock( &this->driver_lock ); - + this->driver->get_property_min_max (this->driver, - property & 0xffffff, - &min_v, &max_v); - + property & 0xffffff, + &min_v, &max_v); + range_v = max_v - min_v + 1; - + v = (value * range_v + (range_v/2)) / 65536 + min_v; - + this->driver->set_property(this->driver, property & 0xffffff, v); pthread_mutex_unlock( &this->driver_lock ); ret = value; } else ret = 0; break; - - + + default: if (!this->grab_only) { pthread_mutex_lock( &this->driver_lock ); @@ -1606,7 +1606,7 @@ static int vo_status (xine_video_port_t *this_gen, xine_stream_t *stream, } } pthread_mutex_unlock(&this->streams_lock); - + return ret; } @@ -1651,7 +1651,7 @@ static void vo_exit (xine_video_port_t *this_gen) { if (this->overlay_source) { this->overlay_source->dispose (this->overlay_source); } - + xine_list_delete(this->streams); pthread_mutex_destroy(&this->streams_lock); @@ -1670,7 +1670,7 @@ static vo_frame_t *vo_get_last_frame (xine_video_port_t *this_gen) { } /* - * overlay stuff + * overlay stuff */ static video_overlay_manager_t *vo_get_overlay_manager (xine_video_port_t *this_gen) { @@ -1680,7 +1680,7 @@ static video_overlay_manager_t *vo_get_overlay_manager (xine_video_port_t *this_ static void vo_enable_overlay (xine_video_port_t *this_gen, int overlay_enabled) { vos_t *this = (vos_t *) this_gen; - + if (overlay_enabled) { /* we always ENable ... */ this->overlay_enabled = 1; @@ -1713,7 +1713,7 @@ static void vo_flush (xine_video_port_t *this_gen) { pthread_mutex_lock(&this->display_img_buf_queue->mutex); this->discard_frames++; pthread_mutex_unlock(&this->display_img_buf_queue->mutex); - + /* do not try this in paused mode */ while(this->clock->speed != XINE_SPEED_PAUSE) { pthread_mutex_lock(&this->display_img_buf_queue->mutex); @@ -1723,7 +1723,7 @@ static void vo_flush (xine_video_port_t *this_gen) { break; xine_usec_sleep (20000); /* pthread_cond_t could be used here */ } - + pthread_mutex_lock(&this->display_img_buf_queue->mutex); this->discard_frames--; pthread_mutex_unlock(&this->display_img_buf_queue->mutex); @@ -1747,29 +1747,29 @@ static vo_frame_t * crop_frame( xine_video_port_t *this_gen, vo_frame_t *img ) { vo_frame_t *dupl; dupl = vo_get_frame ( this_gen, - img->width - img->crop_left - img->crop_right, + img->width - img->crop_left - img->crop_right, img->height - img->crop_top - img->crop_bottom, img->ratio, img->format, img->flags | VO_BOTH_FIELDS); - + dupl->progressive_frame = img->progressive_frame; dupl->repeat_first_field = img->repeat_first_field; dupl->top_field_first = img->top_field_first; dupl->overlay_offset_x = img->overlay_offset_x; dupl->overlay_offset_y = img->overlay_offset_y; - + switch (img->format) { case XINE_IMGFMT_YV12: yv12_to_yv12( /* Y */ - img->base[0] + img->crop_top * img->pitches[0] + + img->base[0] + img->crop_top * img->pitches[0] + img->crop_left, img->pitches[0], dupl->base[0], dupl->pitches[0], /* U */ - img->base[1] + img->crop_top/2 * img->pitches[1] + + img->base[1] + img->crop_top/2 * img->pitches[1] + img->crop_left/2, img->pitches[1], dupl->base[1], dupl->pitches[1], /* V */ - img->base[2] + img->crop_top/2 * img->pitches[2] + + img->base[2] + img->crop_top/2 * img->pitches[2] + img->crop_left/2, img->pitches[2], dupl->base[2], dupl->pitches[2], /* width x height */ @@ -1786,7 +1786,7 @@ static vo_frame_t * crop_frame( xine_video_port_t *this_gen, vo_frame_t *img ) { dupl->width, dupl->height); break; } - + dupl->bad_frame = 0; dupl->pts = img->pts; dupl->vpts = img->vpts; @@ -1799,10 +1799,10 @@ static vo_frame_t * crop_frame( xine_video_port_t *this_gen, vo_frame_t *img ) { if (img->stream) _x_refcounter_inc(img->stream->refcounter); memcpy( dupl->extra_info, img->extra_info, sizeof(extra_info_t) ); - + /* delay frame processing for now, we might not even need it (eg. frame will be discarded) */ /* vo_frame_driver_proc(dupl); */ - + return dupl; } @@ -1821,10 +1821,10 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabon this->clock = xine->clock; this->driver = driver; this->streams = xine_list_new(); - + pthread_mutex_init(&this->streams_lock, NULL); pthread_mutex_init(&this->driver_lock, NULL ); - + this->vo.open = vo_open; this->vo.get_frame = vo_get_frame; this->vo.get_last_frame = vo_get_last_frame; @@ -1849,7 +1849,7 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabon this->last_frame = NULL; this->img_backup = NULL; - + this->overlay_source = _x_video_overlay_new_manager(xine); this->overlay_source->init (this->overlay_source); this->overlay_enabled = 1; @@ -1871,7 +1871,7 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabon num_frame_buffers = i; /* we need at least 5 frames */ - if (num_frame_buffers<5) + if (num_frame_buffers<5) num_frame_buffers = 5; /* Choose a frame_drop_limit which matches num_frame_buffers. @@ -1903,7 +1903,7 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabon img->proc_duplicate_frame_data = NULL; img->id = i; - + img->port = &this->vo; img->free = vo_frame_dec_lock; img->lock = vo_frame_inc_lock; @@ -1915,13 +1915,13 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabon img); } - this->warn_skipped_threshold = + this->warn_skipped_threshold = xine->config->register_num (xine->config, "engine.performance.warn_skipped_threshold", 10, _("percentage of skipped frames to tolerate"), _("When more than this percentage of frames are not shown, because they " "were not decoded in time, xine sends a notification."), 20, NULL, NULL); - this->warn_discarded_threshold = + this->warn_discarded_threshold = xine->config->register_num (xine->config, "engine.performance.warn_discarded_threshold", 10, _("percentage of discarded frames to tolerate"), _("When more than this percentage of frames are not shown, because they " @@ -1951,10 +1951,10 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabon this->video_loop_running = 1; this->video_opened = 0; this->grab_only = 0; - + pthread_attr_init(&pth_attrs); pthread_attr_setscope(&pth_attrs, PTHREAD_SCOPE_SYSTEM); - + if ((err = pthread_create (&this->video_thread, &pth_attrs, video_out_loop, this)) != 0) { @@ -1966,7 +1966,7 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabon } else xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out: thread created\n"); - + pthread_attr_destroy(&pth_attrs); } diff --git a/src/xine-engine/video_overlay.c b/src/xine-engine/video_overlay.c index cb9aa96fa..172a93c3e 100644 --- a/src/xine-engine/video_overlay.c +++ b/src/xine-engine/video_overlay.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2006 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -51,15 +51,15 @@ typedef struct video_overlay_showing_s { typedef struct video_overlay_s { video_overlay_manager_t video_overlay; - + xine_t *xine; - pthread_mutex_t events_mutex; + pthread_mutex_t events_mutex; video_overlay_events_t events[MAX_EVENTS]; - pthread_mutex_t objects_mutex; + pthread_mutex_t objects_mutex; video_overlay_object_t objects[MAX_OBJECTS]; pthread_mutex_t showing_mutex; - video_overlay_showing_t showing[MAX_SHOWING]; + video_overlay_showing_t showing[MAX_SHOWING]; int showing_changed; } video_overlay_t; @@ -67,24 +67,24 @@ typedef struct video_overlay_s { static void add_showing_handle( video_overlay_t *this, int32_t handle ) { int i; - + pthread_mutex_lock( &this->showing_mutex ); this->showing_changed++; - + for( i = 0; i < MAX_SHOWING; i++ ) if( this->showing[i].handle == handle ) break; /* already showing */ - + if( i == MAX_SHOWING ) { for( i = 0; i < MAX_SHOWING && this->showing[i].handle >= 0; i++ ) ; - + if( i != MAX_SHOWING ) this->showing[i].handle = handle; else xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_overlay: error: no showing slots available\n"); } - + pthread_mutex_unlock( &this->showing_mutex ); } @@ -94,13 +94,13 @@ static void remove_showing_handle( video_overlay_t *this, int32_t handle ) pthread_mutex_lock( &this->showing_mutex ); this->showing_changed++; - + for( i = 0; i < MAX_SHOWING; i++ ) { if( this->showing[i].handle == handle ) { this->showing[i].handle = -1; } } - + pthread_mutex_unlock( &this->showing_mutex ); } @@ -110,34 +110,34 @@ static void remove_events_handle( video_overlay_t *this, int32_t handle, int loc if( lock ) pthread_mutex_lock( &this->events_mutex ); - + this_event=0; do { last_event=this_event; this_event=this->events[last_event].next_event; - - while( this_event && + + while( this_event && this->events[this_event].event->object.handle == handle ) { /* remove event from pts list */ this->events[last_event].next_event= this->events[this_event].next_event; - /* free its overlay */ - if( this->events[this_event].event->object.overlay ) { + /* free its overlay */ + if( this->events[this_event].event->object.overlay ) { if( this->events[this_event].event->object.overlay->rle ) free( this->events[this_event].event->object.overlay->rle ); free(this->events[this_event].event->object.overlay); this->events[this_event].event->object.overlay = NULL; } - + /* mark as free */ this->events[this_event].next_event = 0; this->events[this_event].event->event_type = OVERLAY_EVENT_NULL; - + this_event=this->events[last_event].next_event; } } while ( this_event ); - + if( lock ) pthread_mutex_unlock( &this->events_mutex ); } @@ -149,35 +149,35 @@ static void remove_events_handle( video_overlay_t *this, int32_t handle, int loc static int32_t video_overlay_get_handle(video_overlay_manager_t *this_gen, int object_type ) { video_overlay_t *this = (video_overlay_t *) this_gen; int n; - + pthread_mutex_lock( &this->objects_mutex ); - + for( n=0; n < MAX_OBJECTS && this->objects[n].handle > -1; n++ ) ; - + if (n == MAX_OBJECTS) { n = -1; } else { this->objects[n].handle = n; this->objects[n].object_type = object_type; } - + pthread_mutex_unlock( &this->objects_mutex ); return n; } -/* +/* free a handle from the object pool (internal function) */ static void internal_video_overlay_free_handle(video_overlay_t *this, int32_t handle) { - + pthread_mutex_lock( &this->objects_mutex ); if( this->objects[handle].overlay ) { if( this->objects[handle].overlay->rle ) free( this->objects[handle].overlay->rle ); free( this->objects[handle].overlay ); - this->objects[handle].overlay = NULL; + this->objects[handle].overlay = NULL; } this->objects[handle].handle = -1; @@ -199,7 +199,7 @@ static void video_overlay_free_handle(video_overlay_manager_t *this_gen, int32_t static void video_overlay_reset (video_overlay_t *this) { int i; - + pthread_mutex_lock (&this->events_mutex); for (i=0; i < MAX_EVENTS; i++) { if (this->events[i].event == NULL) { @@ -212,17 +212,17 @@ static void video_overlay_reset (video_overlay_t *this) { #endif } this->events[i].event->event_type = 0; /* Empty slot */ - this->events[i].next_event = 0; + this->events[i].next_event = 0; } pthread_mutex_unlock (&this->events_mutex); - + for( i = 0; i < MAX_SHOWING; i++ ) this->showing[i].handle = -1; - + for (i=0; i < MAX_OBJECTS; i++) { internal_video_overlay_free_handle(this, i); } - + this->showing_changed = 0; } @@ -234,7 +234,7 @@ static void video_overlay_init (video_overlay_manager_t *this_gen) { pthread_mutex_init (&this->events_mutex,NULL); pthread_mutex_init (&this->objects_mutex,NULL); pthread_mutex_init (&this->showing_mutex,NULL); - + video_overlay_reset(this); } @@ -256,13 +256,13 @@ static int32_t video_overlay_add_event(video_overlay_manager_t *this_gen, void uint32_t last_event,this_event,new_event; pthread_mutex_lock (&this->events_mutex); - + /* We skip the 0 entry because that is used as a pointer to the first event.*/ /* Find a free event slot */ - for( new_event = 1; new_event<MAX_EVENTS && + for( new_event = 1; new_event<MAX_EVENTS && this->events[new_event].event->event_type > 0; new_event++ ) ; - + if (new_event < MAX_EVENTS) { /* Find position in event queue to be added. */ this_event=0; @@ -274,7 +274,7 @@ static int32_t video_overlay_add_event(video_overlay_manager_t *this_gen, void this->events[last_event].next_event=new_event; this->events[new_event].next_event=this_event; - + /* memcpy everything except the actual image */ if ( this->events[new_event].event == NULL ) { xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_overlay: error: event slot is NULL!\n"); @@ -287,7 +287,7 @@ static int32_t video_overlay_add_event(video_overlay_manager_t *this_gen, void if ( this->events[new_event].event->object.overlay ) { xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_overlay: add_event: event->object.overlay was not freed!\n"); } - + if( event->object.overlay ) { int i; for(i = 0; i < OVL_PALETTE_SIZE; i++) { @@ -298,7 +298,7 @@ static int32_t video_overlay_add_event(video_overlay_manager_t *this_gen, void } this->events[new_event].event->object.overlay = calloc(1, sizeof(vo_overlay_t)); - xine_fast_memcpy(this->events[new_event].event->object.overlay, + xine_fast_memcpy(this->events[new_event].event->object.overlay, event->object.overlay, sizeof(vo_overlay_t)); /* We took the callers rle and data, therefore it will be our job to free it */ @@ -311,9 +311,9 @@ static int32_t video_overlay_add_event(video_overlay_manager_t *this_gen, void xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_overlay:No spare subtitle event slots\n"); new_event = -1; } - + pthread_mutex_unlock (&this->events_mutex); - + return new_event; } @@ -335,7 +335,7 @@ static void video_overlay_print_overlay( vo_overlay_t *ovl ) { printf ("video_overlay: \thili_trans [%d %d %d %d]\n", ovl->hili_trans[0], ovl->hili_trans[1], ovl->hili_trans[2], ovl->hili_trans[3]); return; -} +} #endif /* @@ -347,9 +347,9 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { int32_t handle; uint32_t this_event; int processed = 0; - + pthread_mutex_lock (&this->events_mutex); - + this_event=this->events[0].next_event; while ( this_event && (vpts > this->events[this_event].event->vpts || vpts == 0) ) { @@ -375,21 +375,21 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { */ remove_showing_handle(this,handle); internal_video_overlay_free_handle(this, handle); - + this->objects[handle].handle = handle; if( this->objects[handle].overlay ) { xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_overlay: error: object->overlay was not freed!\n"); } - this->objects[handle].overlay = + this->objects[handle].overlay = this->events[this_event].event->object.overlay; - this->objects[handle].pts = + this->objects[handle].pts = this->events[this_event].event->object.pts; this->events[this_event].event->object.overlay = NULL; - + add_showing_handle( this, handle ); } break; - + case OVERLAY_EVENT_HIDE: #ifdef LOG_DEBUG printf ("video_overlay: HIDE SPU NOW\n"); @@ -399,17 +399,17 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { if( this->events[this_event].event->object.overlay->rle != NULL ) free( this->events[this_event].event->object.overlay->rle ); free(this->events[this_event].event->object.overlay); - this->events[this_event].event->object.overlay = NULL; + this->events[this_event].event->object.overlay = NULL; } remove_showing_handle( this, handle ); break; - + case OVERLAY_EVENT_FREE_HANDLE: #ifdef LOG_DEBUG printf ("video_overlay: FREE SPU NOW\n"); #endif /* free any overlay associated with this event */ - if( this->events[this_event].event->object.overlay != NULL) { + if( this->events[this_event].event->object.overlay != NULL) { if( this->events[this_event].event->object.overlay->rle != NULL ) free( this->events[this_event].event->object.overlay->rle ); free(this->events[this_event].event->object.overlay); @@ -423,7 +423,7 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { internal_video_overlay_free_handle( this, handle ); break; - + case OVERLAY_EVENT_MENU_BUTTON: /* mixes palette and copy clip coords */ #ifdef LOG_DEBUG @@ -433,10 +433,10 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { /* This code drops buttons, where the button PTS derived from the NAV * packet on DVDs does not match the SPU PTS. Practical experience shows, * that this is not necessary and causes problems with some DVDs */ - if ( (this->events[this_event].event->object.pts != + if ( (this->events[this_event].event->object.pts != this->objects[handle].pts) ) { - xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "video_overlay:MENU BUTTON DROPPED menu pts=%lld spu pts=%lld\n", + xprintf (this->xine, XINE_VERBOSITY_DEBUG, + "video_overlay:MENU BUTTON DROPPED menu pts=%lld spu pts=%lld\n", this->events[this_event].event->object.pts, this->objects[handle].pts); break; @@ -446,7 +446,7 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { (this->objects[handle].overlay) ) { vo_overlay_t *overlay = this->objects[handle].overlay; vo_overlay_t *event_overlay = this->events[this_event].event->object.overlay; - + #ifdef LOG_DEBUG printf ("video_overlay:overlay present\n"); #endif @@ -477,84 +477,84 @@ static int video_overlay_event( video_overlay_t *this, int64_t vpts ) { free( this->events[this_event].event->object.overlay->rle ); this->events[this_event].event->object.overlay->rle = NULL; } - + if (this->events[this_event].event->object.overlay != NULL) { free (this->events[this_event].event->object.overlay); this->events[this_event].event->object.overlay = NULL; } break; - + default: xprintf (this->xine, XINE_VERBOSITY_DEBUG, "video_overlay: unhandled event type\n"); break; } - - this->events[0].next_event = this->events[this_event].next_event; + + this->events[0].next_event = this->events[this_event].next_event; this->events[this_event].next_event = 0; this->events[this_event].event->event_type = 0; - + this_event=this->events[0].next_event; } - + pthread_mutex_unlock (&this->events_mutex); return processed; } - -/* This is called from video_out.c + +/* This is called from video_out.c * must call output->overlay_blend for each active overlay. */ -static void video_overlay_multiple_overlay_blend (video_overlay_manager_t *this_gen, int64_t vpts, +static void video_overlay_multiple_overlay_blend (video_overlay_manager_t *this_gen, int64_t vpts, vo_driver_t *output, vo_frame_t *vo_img, int enabled) { video_overlay_t *this = (video_overlay_t *) this_gen; int i; int32_t handle; - /* Look at next events, if current video vpts > first event on queue, process the event - * else just continue + /* Look at next events, if current video vpts > first event on queue, process the event + * else just continue */ video_overlay_event( this, vpts ); - - /* Scan through 5 entries and display any present. + + /* Scan through 5 entries and display any present. */ pthread_mutex_lock( &this->showing_mutex ); if( output->overlay_begin ) output->overlay_begin(output, vo_img, this->showing_changed); - + for( i = 0; enabled && output->overlay_blend && i < MAX_SHOWING; i++ ) { - handle=this->showing[i].handle; + handle=this->showing[i].handle; if (handle >= 0 ) { output->overlay_blend(output, vo_img, this->objects[handle].overlay); } } - + if( output->overlay_end ) output->overlay_end(output, vo_img); - + this->showing_changed = 0; - + pthread_mutex_unlock( &this->showing_mutex ); } -/* this should be called on stream end or stop to make sure every +/* this should be called on stream end or stop to make sure every hide event is processed. */ static void video_overlay_flush_events(video_overlay_manager_t *this_gen ) { video_overlay_t *this = (video_overlay_t *) this_gen; - + video_overlay_event( this, 0 ); } -/* this is called from video_out.c on still frames to check +/* this is called from video_out.c on still frames to check if a redraw is needed. */ static int video_overlay_redraw_needed(video_overlay_manager_t *this_gen, int64_t vpts ) { video_overlay_t *this = (video_overlay_t *) this_gen; - + video_overlay_event( this, vpts ); return this->showing_changed; } @@ -575,7 +575,7 @@ static void video_overlay_dispose(video_overlay_manager_t *this_gen) { free (this->events[i].event); } } - + for (i=0; i < MAX_OBJECTS; i++) internal_video_overlay_free_handle(this, i); diff --git a/src/xine-engine/vo_scale.c b/src/xine-engine/vo_scale.c index 7c5cfd38c..e44fc4966 100644 --- a/src/xine-engine/vo_scale.c +++ b/src/xine-engine/vo_scale.c @@ -7,7 +7,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -53,14 +53,14 @@ void _x_vo_scale_compute_ideal_size (vo_scale_t *this) { this->video_pixel_aspect = this->gui_pixel_aspect; } else { - - /* + + /* * aspect ratio */ - + image_ratio = (double) (this->delivered_width - (this->crop_left + this->crop_right)) / (double) (this->delivered_height - (this->crop_top + this->crop_bottom)); - + switch (this->user_ratio) { case XINE_VO_ASPECT_AUTO: desired_ratio = this->delivered_ratio; @@ -80,7 +80,7 @@ void _x_vo_scale_compute_ideal_size (vo_scale_t *this) { } this->video_pixel_aspect = desired_ratio / image_ratio; - + _x_assert(this->gui_pixel_aspect != 0.0); if (fabs (this->video_pixel_aspect / this->gui_pixel_aspect - 1.0) @@ -89,7 +89,7 @@ void _x_vo_scale_compute_ideal_size (vo_scale_t *this) { } #if 0 - + /* onefield_xv divide by 2 the number of lines */ if (this->deinterlace_enabled && (this->deinterlace_method == DEINTERLACE_ONEFIELDXV) @@ -107,17 +107,17 @@ void _x_vo_scale_compute_ideal_size (vo_scale_t *this) { */ void _x_vo_scale_compute_output_size (vo_scale_t *this) { - + int cropped_width, cropped_height; double x_factor, y_factor, aspect; - + cropped_width = this->delivered_width - (this->crop_left + this->crop_right); - cropped_height = this->delivered_height - (this->crop_top + this->crop_bottom); + cropped_height = this->delivered_height - (this->crop_top + this->crop_bottom); aspect = this->video_pixel_aspect / this->gui_pixel_aspect; x_factor = (double) this->gui_width / (double) (cropped_width * aspect); y_factor = (double) (this->gui_height * aspect) / (double) cropped_height; - + if (this->scaling_disabled) { this->output_width = cropped_width; @@ -128,8 +128,8 @@ void _x_vo_scale_compute_output_size (vo_scale_t *this) { } else { if ( this->support_zoom ) { - - /* zoom behaviour: + + /* zoom behaviour: * - window size never changes due zooming * - output image shall be increased whenever there are * black borders to use. @@ -138,7 +138,7 @@ void _x_vo_scale_compute_output_size (vo_scale_t *this) { if (((double)this->gui_width - (double)cropped_width * y_factor) < ((double)this->gui_height - (double)cropped_height * x_factor)) { this->output_width = this->gui_width; this->displayed_width = (double)cropped_width / this->zoom_factor_x + 0.5; - + this->output_height = (double)cropped_height * x_factor + 0.5; if( this->output_height * this->zoom_factor_y <= this->gui_height ) { this->displayed_height = cropped_height; @@ -151,7 +151,7 @@ void _x_vo_scale_compute_output_size (vo_scale_t *this) { } else { this->output_height = this->gui_height; this->displayed_height = (double)cropped_height / this->zoom_factor_y + 0.5; - + this->output_width = (double)cropped_width * y_factor + 0.5; if( this->output_width * this->zoom_factor_x <= this->gui_width ) { this->displayed_width = cropped_width; @@ -162,7 +162,7 @@ void _x_vo_scale_compute_output_size (vo_scale_t *this) { this->output_width = this->gui_width; } } - + } else { if (((double)this->gui_width - (double)cropped_width * y_factor) < ((double)this->gui_height - (double)cropped_height * x_factor)) { this->output_width = (double) this->gui_width; @@ -174,27 +174,27 @@ void _x_vo_scale_compute_output_size (vo_scale_t *this) { this->displayed_width = cropped_width; this->displayed_height = cropped_height; } - } - + } + /* make sure displayed values are sane, that is, we are not trying to display * something outside the delivered image. may happen when zoom < 100%. */ if( this->displayed_width > this->delivered_width ) { - this->output_width = (double) this->output_width * + this->output_width = (double) this->output_width * this->delivered_width / this->displayed_width + 0.5; this->displayed_width = this->delivered_width; } if( this->displayed_height > this->delivered_height ) { - this->output_height = (double) this->output_height * + this->output_height = (double) this->output_height * this->delivered_height / this->displayed_height + 0.5; this->displayed_height = this->delivered_height; } - + this->output_xoffset = (this->gui_width - this->output_width) * this->output_horizontal_position + this->gui_x; this->output_yoffset = (this->gui_height - this->output_height) * this->output_vertical_position + this->gui_y; - + this->displayed_xoffset = ((cropped_width - this->displayed_width) / 2) + this->crop_left; this->displayed_yoffset = ((cropped_height - this->displayed_height) / 2) + this->crop_top; @@ -219,8 +219,8 @@ void _x_vo_scale_compute_output_size (vo_scale_t *this) { /* no top/bottom borders */ this->border[0].w = this->border[0].h = 0; this->border[1].w = this->border[1].h = 0; - } - + } + if (this->output_width < this->gui_width) { /* left */ this->border[2].x = 0; @@ -252,10 +252,10 @@ int _x_vo_scale_redraw_needed (vo_scale_t *this) { _x_assert(this->frame_output_cb); if ( ! this->frame_output_cb ) return 0; - + this->frame_output_cb (this->user_data, - this->delivered_width - (this->crop_left + this->crop_right), - this->delivered_height - (this->crop_top + this->crop_bottom), + this->delivered_width - (this->crop_left + this->crop_right), + this->delivered_height - (this->crop_top + this->crop_bottom), this->video_pixel_aspect, &gui_x, &gui_y, &gui_width, &gui_height, &gui_pixel_aspect, &gui_win_x, &gui_win_y ); @@ -277,7 +277,7 @@ int _x_vo_scale_redraw_needed (vo_scale_t *this) { } else ret = this->force_redraw; - + this->force_redraw = 0; return ret; } @@ -306,7 +306,7 @@ void _x_vo_scale_translate_gui2video(vo_scale_t *this, * translate output area coordianates into the delivered area * coordiantes. */ - + x = x * this->displayed_width / this->output_width + this->displayed_xoffset; y = y * this->displayed_height / this->output_height + this->displayed_yoffset; } @@ -336,21 +336,21 @@ const char _x_vo_scale_aspect_ratio_name_table[][8] = { */ static void vo_scale_horizontal_pos_changed(void *data, xine_cfg_entry_t *entry) { vo_scale_t *this = (vo_scale_t *)data; - + this->output_horizontal_position = entry->num_value / 100.0; this->force_redraw = 1; } static void vo_scale_vertical_pos_changed(void *data, xine_cfg_entry_t *entry) { vo_scale_t *this = (vo_scale_t *)data; - + this->output_vertical_position = entry->num_value / 100.0; this->force_redraw = 1; } static void vo_scale_disable_scaling_changed(void *data, xine_cfg_entry_t *entry) { vo_scale_t *this = (vo_scale_t *)data; - + if (this->scaling_disabled < 2) { this->scaling_disabled = entry->num_value; this->force_redraw = 1; @@ -358,13 +358,13 @@ static void vo_scale_disable_scaling_changed(void *data, xine_cfg_entry_t *entry } -/* +/* * initialize rescaling struct */ - + void _x_vo_scale_init(vo_scale_t *this, int support_zoom, int scaling_disabled, config_values_t *config ) { - + memset( this, 0, sizeof(vo_scale_t) ); this->support_zoom = support_zoom; this->force_redraw = 1; @@ -373,13 +373,13 @@ void _x_vo_scale_init(vo_scale_t *this, int support_zoom, int scaling_disabled, this->gui_pixel_aspect = 1.0; this->user_ratio = XINE_VO_ASPECT_AUTO; this->delivered_ratio = 0.0; - + this->crop_left = 0; this->crop_right = 0; this->crop_top = 0; this->crop_bottom = 0; - - this->output_horizontal_position = + + this->output_horizontal_position = config->register_range(config, "video.output.horizontal_position", 50, 0, 100, _("horizontal image position in the output window"), _("If the video window's horizontal size is bigger than the actual image " diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 1299b0f01..8162598aa 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2006 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -98,7 +98,7 @@ void _x_handle_stream_end (xine_stream_t *stream, int non_user) { * if they have called xine_stop explicitly, so only send * it if stream playback finished because of stream end reached */ - + xine_event_t event; event.data_length = 0; @@ -156,7 +156,7 @@ static int acquire_allowed_to_block(xine_ticket_t *this) { /* List too small. Realloc to larger size */ new_size = this->holder_thread_count * 2; lprintf("Reallocing from %d to %d entries\n", this->holder_thread_count, new_size); - + this->holder_threads = realloc(this->holder_threads, sizeof(*this->holder_threads) * new_size); memset(this->holder_threads + this->holder_thread_count, 0, this->holder_thread_count); @@ -165,15 +165,15 @@ static int acquire_allowed_to_block(xine_ticket_t *this) { this->holder_threads[this->holder_thread_count].holder = own_id; this->holder_thread_count = new_size; - return 1; + return 1; } - + static int ticket_acquire_internal(xine_ticket_t *this, int irrevocable, int nonblocking) { int must_wait = 0; pthread_mutex_lock(&this->lock); int allowed_to_block = acquire_allowed_to_block(this); - + if (this->ticket_revoked && !this->irrevocable_tickets) must_wait = !nonblocking; else if (this->atomic_revoke && !pthread_equal(this->atomic_revoker_thread, pthread_self())) @@ -187,12 +187,12 @@ static int ticket_acquire_internal(xine_ticket_t *this, int irrevocable, int non pthread_cond_wait(&this->issued, &this->lock); } - + this->tickets_granted++; if (irrevocable) this->irrevocable_tickets++; - - pthread_mutex_unlock(&this->lock); + + pthread_mutex_unlock(&this->lock); return 1; } @@ -207,7 +207,7 @@ static void ticket_acquire(xine_ticket_t *this, int irrevocable) { static int release_allowed_to_block(xine_ticket_t *this) { pthread_t own_id = pthread_self(); unsigned entry; - + for(entry = 0; entry < this->holder_thread_count; ++entry) { if(pthread_equal(this->holder_threads[entry].holder, own_id)) { this->holder_threads[entry].count--; @@ -223,18 +223,18 @@ static void ticket_release_internal(xine_ticket_t *this, int irrevocable, int no pthread_mutex_lock(&this->lock); int allowed_to_block = release_allowed_to_block(this); - + this->tickets_granted--; if (irrevocable) this->irrevocable_tickets--; - + if (this->ticket_revoked && !this->tickets_granted) pthread_cond_broadcast(&this->revoked); if (allowed_to_block) { if (this->ticket_revoked && !this->irrevocable_tickets && !nonblocking) pthread_cond_wait(&this->issued, &this->lock); } - + pthread_mutex_unlock(&this->lock); } @@ -249,17 +249,17 @@ static void ticket_release(xine_ticket_t *this, int irrevocable) { static void ticket_renew(xine_ticket_t *this, int irrevocable) { pthread_mutex_lock(&this->lock); - + this->tickets_granted--; - + _x_assert(this->ticket_revoked); if (!this->tickets_granted) pthread_cond_broadcast(&this->revoked); if (!this->irrevocable_tickets || !irrevocable) pthread_cond_wait(&this->issued, &this->lock); - + this->tickets_granted++; - + pthread_mutex_unlock(&this->lock); } @@ -268,12 +268,12 @@ static void ticket_issue(xine_ticket_t *this, int atomic) { if (!atomic) pthread_mutex_lock(&this->revoke_lock); pthread_mutex_lock(&this->lock); - + this->pending_revocations--; if (!this->pending_revocations) pthread_cond_broadcast(&this->issued); this->atomic_revoke = 0; - + pthread_mutex_unlock(&this->lock); pthread_mutex_unlock(&this->revoke_lock); } @@ -282,7 +282,7 @@ static void ticket_revoke(xine_ticket_t *this, int atomic) { pthread_mutex_lock(&this->revoke_lock); pthread_mutex_lock(&this->lock); - + this->pending_revocations++; this->ticket_revoked = 1; if (this->tickets_granted) @@ -293,7 +293,7 @@ static void ticket_revoke(xine_ticket_t *this, int atomic) { this->atomic_revoke = 1; this->atomic_revoker_thread = pthread_self(); } - + pthread_mutex_unlock(&this->lock); if (!atomic) pthread_mutex_unlock(&this->revoke_lock); @@ -334,15 +334,15 @@ static void ticket_dispose(xine_ticket_t *this) { pthread_mutex_destroy(&this->revoke_lock); pthread_cond_destroy(&this->issued); pthread_cond_destroy(&this->revoked); - + free(this); } static xine_ticket_t *XINE_MALLOC ticket_init(void) { xine_ticket_t *port_ticket; - + port_ticket = calloc(1, sizeof(xine_ticket_t)); - + port_ticket->acquire_nonblocking = ticket_acquire_nonblocking; port_ticket->acquire = ticket_acquire; port_ticket->release_nonblocking = ticket_release_nonblocking; @@ -355,13 +355,13 @@ static xine_ticket_t *XINE_MALLOC ticket_init(void) { port_ticket->dispose = ticket_dispose; port_ticket->holder_thread_count = XINE_MAX_TICKET_HOLDER_THREADS; port_ticket->holder_threads = calloc(XINE_MAX_TICKET_HOLDER_THREADS,sizeof(*port_ticket->holder_threads)); - + pthread_mutex_init(&port_ticket->lock, NULL); pthread_mutex_init(&port_ticket->revoke_lock, NULL); pthread_mutex_init(&port_ticket->port_rewiring_lock, NULL); pthread_cond_init(&port_ticket->issued, NULL); pthread_cond_init(&port_ticket->revoked, NULL); - + return port_ticket; } @@ -372,25 +372,25 @@ static void set_speed_internal (xine_stream_t *stream, int speed) { if (old_speed != XINE_SPEED_PAUSE && speed == XINE_SPEED_PAUSE) /* get all decoder and post threads in a state where they agree to be blocked */ xine->port_ticket->revoke(xine->port_ticket, 0); - + if (old_speed == XINE_SPEED_PAUSE && speed != XINE_SPEED_PAUSE) /* all decoder and post threads may continue now */ xine->port_ticket->issue(xine->port_ticket, 0); - + if (old_speed != XINE_SPEED_PAUSE && speed == XINE_SPEED_PAUSE) /* set master clock so audio_out loop can pause in a safe place */ stream->xine->clock->set_fine_speed (stream->xine->clock, speed); - + /* see coment on audio_out loop about audio_paused */ if( stream->audio_out ) { xine->port_ticket->acquire(xine->port_ticket, 1); - + /* inform audio_out that speed has changed - he knows what to do */ stream->audio_out->set_property (stream->audio_out, AO_PROP_CLOCK_SPEED, speed); - + xine->port_ticket->release(xine->port_ticket, 1); } - + if (old_speed == XINE_SPEED_PAUSE || speed != XINE_SPEED_PAUSE) /* master clock is set after resuming the audio device (audio_out loop may continue) */ stream->xine->clock->set_fine_speed (stream->xine->clock, speed); @@ -443,18 +443,18 @@ void xine_stop (xine_stream_t *stream) { stream->video_out->set_property(stream->video_out, VO_PROP_DISCARD_FRAMES, 1); stop_internal (stream); - + if (stream->slave && (stream->slave_affection & XINE_MASTER_SLAVE_STOP)) xine_stop(stream->slave); if (stream->video_out) - stream->video_out->set_property(stream->video_out, VO_PROP_DISCARD_FRAMES, 0); + stream->video_out->set_property(stream->video_out, VO_PROP_DISCARD_FRAMES, 0); if (stream->audio_out) stream->audio_out->set_property(stream->audio_out, AO_PROP_DISCARD_BUFFERS, 0); - + stream->xine->port_ticket->release(stream->xine->port_ticket, 1); stream->ignore_speed_change = 0; - + pthread_cleanup_pop (0); pthread_mutex_unlock (&stream->frontend_lock); } @@ -481,25 +481,25 @@ static void close_internal (xine_stream_t *stream) { pthread_mutex_unlock(&stream->speed_change_lock); stream->xine->port_ticket->acquire(stream->xine->port_ticket, 1); - + if (stream->audio_out) stream->audio_out->set_property(stream->audio_out, AO_PROP_DISCARD_BUFFERS, 1); if (stream->video_out) stream->video_out->set_property(stream->video_out, VO_PROP_DISCARD_FRAMES, 1); } - + stop_internal( stream ); - + if( !gapless_switch ) { if (stream->video_out) - stream->video_out->set_property(stream->video_out, VO_PROP_DISCARD_FRAMES, 0); + stream->video_out->set_property(stream->video_out, VO_PROP_DISCARD_FRAMES, 0); if (stream->audio_out) stream->audio_out->set_property(stream->audio_out, AO_PROP_DISCARD_BUFFERS, 0); - + stream->xine->port_ticket->release(stream->xine->port_ticket, 1); stream->ignore_speed_change = 0; } - + if (stream->demux_plugin) { _x_free_demux_plugin(stream, stream->demux_plugin); stream->demux_plugin = NULL; @@ -562,14 +562,14 @@ static int stream_rewire_audio(xine_post_out_t *output, void *data) stream->xine->port_ticket->lock_port_rewiring(stream->xine->port_ticket, -1); stream->xine->port_ticket->revoke(stream->xine->port_ticket, 1); - + if (stream->audio_out->status(stream->audio_out, stream, &bits, &rate, &mode)) { /* register our stream at the new output port */ (new_port->open) (new_port, stream, bits, rate, mode); stream->audio_out->close(stream->audio_out, stream); } stream->audio_out = new_port; - + stream->xine->port_ticket->issue(stream->xine->port_ticket, 1); stream->xine->port_ticket->unlock_port_rewiring(stream->xine->port_ticket); @@ -582,20 +582,20 @@ static int stream_rewire_video(xine_post_out_t *output, void *data) xine_video_port_t *new_port = (xine_video_port_t *)data; int64_t img_duration; int width, height; - + if (!data) return 0; stream->xine->port_ticket->lock_port_rewiring(stream->xine->port_ticket, -1); stream->xine->port_ticket->revoke(stream->xine->port_ticket, 1); - + if (stream->video_out->status(stream->video_out, stream, &width, &height, &img_duration)) { /* register our stream at the new output port */ (new_port->open) (new_port, stream); stream->video_out->close(stream->video_out, stream); } stream->video_out = new_port; - + stream->xine->port_ticket->issue(stream->xine->port_ticket, 1); stream->xine->port_ticket->unlock_port_rewiring(stream->xine->port_ticket); @@ -652,24 +652,24 @@ xine_stream_t *xine_stream_new (xine_t *this, stream->video_driver = vo->driver; else stream->video_driver = NULL; - + stream->video_channel = 0; stream->video_decoder_plugin = NULL; stream->video_decoder_streamtype = -1; - stream->header_count_audio = 0; - stream->header_count_video = 0; - stream->finished_count_audio = 0; + stream->header_count_audio = 0; + stream->header_count_video = 0; + stream->finished_count_audio = 0; stream->finished_count_video = 0; stream->err = 0; stream->broadcaster = NULL; - + /* * initial master/slave */ stream->master = stream; stream->slave = NULL; stream->slave_is_subtitle = 0; - + /* * init mutexes and conditions */ @@ -704,7 +704,7 @@ xine_stream_t *xine_stream_new (xine_t *this, _x_meta_info_reset(stream, i); _x_meta_info_public_reset(stream, i); } - + /* * event queues */ @@ -776,12 +776,12 @@ xine_stream_t *xine_stream_new (xine_t *this, stream->video_source.type = XINE_POST_DATA_VIDEO; stream->video_source.data = stream; stream->video_source.rewire = stream_rewire_video; - + stream->audio_source.name = "audio source"; stream->audio_source.type = XINE_POST_DATA_AUDIO; stream->audio_source.data = stream; stream->audio_source.rewire = stream_rewire_audio; - + return stream; } @@ -791,7 +791,7 @@ void _x_mrl_unescape(char *mrl) { for (i = 0; i < len; i++) { if ((mrl[i]=='%') && (i<(len-2))) { unsigned int c; - + if (sscanf(&mrl[i + 1], "%02x", &c) == 1) { mrl[i]= (char)c; memmove(mrl + i + 1, mrl + i + 3, len - i - 3); @@ -851,7 +851,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) { const char *stream_setup = NULL; const char *mrl_proto = NULL; int no_cache = 0; - + if (!mrl) { xprintf (stream->xine, XINE_VERBOSITY_LOG, _("xine: error while parsing mrl\n")); stream->err = XINE_ERROR_MALFORMED_MRL; @@ -883,23 +883,23 @@ static int open_internal (xine_stream_t *stream, const char *mrl) { if (!mrl_proto[0] || mrl_proto[0] != ':' || mrl_proto[1] != '/') mrl_proto = NULL; } - + /* for raw filenames we must try every '#' checking if it is part of the filename */ if( !mrl_proto && stream_setup) { struct stat stat_buf; int res; - + while( stream_setup ) { char *raw_filename = strndup (mrl, stream_setup - mrl); - + res = stat(raw_filename, &stat_buf); free(raw_filename); - if( !res ) + if( !res ) break; stream_setup = strchr(stream_setup + 1, '#'); } } - + { char *input_source = strndup (mrl, stream_setup ? stream_setup - mrl : strlen (mrl)); @@ -908,7 +908,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) { */ stream->input_plugin = _x_find_input_plugin (stream, input_source); free(input_source); - + if ( stream->input_plugin ) { int res; @@ -917,7 +917,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) { stream->input_plugin->input_class->description)); if (stream->input_plugin->input_class->eject_media) stream->eject_class = stream->input_plugin->input_class; - _x_meta_info_set_utf8(stream, XINE_META_INFO_INPUT_PLUGIN, + _x_meta_info_set_utf8(stream, XINE_META_INFO_INPUT_PLUGIN, stream->input_plugin->input_class->identifier); res = (stream->input_plugin->open) (stream->input_plugin); @@ -936,7 +936,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) { } } } - + if (!stream->input_plugin) { xine_log (stream->xine, XINE_LOG_MSG, _("xine: cannot find input plugin for MRL [%s]\n"),mrl); stream->err = XINE_ERROR_NO_INPUT_PLUGIN; @@ -1004,7 +1004,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) { xine_log(stream->xine, XINE_LOG_MSG, _("xine: join rip input plugin\n")); input_saver = _x_rip_plugin_get_instance (stream, filename); free(filename); - + if( input_saver ) { stream->input_plugin = input_saver; } else { @@ -1182,7 +1182,7 @@ static int open_internal (xine_stream_t *stream, const char *mrl) { if( xine_open( stream->slave, subtitle_mrl ) ) { xprintf (stream->xine, XINE_VERBOSITY_LOG, _("subtitle mrl opened '%s'\n"), subtitle_mrl); stream->slave->master = stream; - stream->slave_is_subtitle = 1; + stream->slave_is_subtitle = 1; } else { xprintf(stream->xine, XINE_VERBOSITY_LOG, _("xine: error opening subtitle mrl\n")); xine_dispose( stream->slave ); @@ -1382,9 +1382,9 @@ static int play_internal (xine_stream_t *stream, int start_pos, int start_time) /* set normal speed */ if (_x_get_speed(stream) != XINE_SPEED_NORMAL) set_speed_internal (stream, XINE_FINE_SPEED_NORMAL); - + stream->xine->port_ticket->acquire(stream->xine->port_ticket, 1); - + /* only flush/discard output ports on master streams */ if( stream->master == stream && !stream->gapless_switch) { /* discard audio/video buffers to get engine going and take the lock faster */ @@ -1393,26 +1393,26 @@ static int play_internal (xine_stream_t *stream, int start_pos, int start_time) if (stream->video_out) stream->video_out->set_property(stream->video_out, VO_PROP_DISCARD_FRAMES, 1); } - + pthread_mutex_lock( &stream->demux_lock ); /* demux_lock taken. now demuxer is suspended */ stream->demux_action_pending = 0; pthread_cond_signal(&stream->demux_resume); - /* set normal speed again (now that demuxer/input pair is suspended) + /* set normal speed again (now that demuxer/input pair is suspended) * some input plugin may have changed speed by itself, we must ensure * the engine is not paused. */ if (_x_get_speed(stream) != XINE_SPEED_NORMAL) set_speed_internal (stream, XINE_FINE_SPEED_NORMAL); - + /* * start/seek demux */ /* seek to new position (no data is sent to decoders yet) */ demux_status = stream->demux_plugin->seek (stream->demux_plugin, - start_pos, start_time, + start_pos, start_time, stream->demux_thread_running); /* only flush/discard output ports on master streams */ @@ -1422,9 +1422,9 @@ static int play_internal (xine_stream_t *stream, int start_pos, int start_time) if (stream->video_out) stream->video_out->set_property(stream->video_out, VO_PROP_DISCARD_FRAMES, 0); } - + stream->xine->port_ticket->release(stream->xine->port_ticket, 1); - + /* before resuming the demuxer, set first_frame_flag */ pthread_mutex_lock (&stream->first_frame_lock); stream->first_frame_flag = 2; @@ -1436,7 +1436,7 @@ static int play_internal (xine_stream_t *stream, int start_pos, int start_time) pthread_mutex_unlock( &stream->current_extra_info_lock ); demux_thread_running = stream->demux_thread_running; - + /* now resume demuxer thread if it is running already */ pthread_mutex_unlock( &stream->demux_lock ); @@ -1459,7 +1459,7 @@ static int play_internal (xine_stream_t *stream, int start_pos, int start_time) * see video_out.c */ wait_first_frame (stream); - + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "play_internal ...done\n"); return 1; @@ -1473,26 +1473,26 @@ int xine_play (xine_stream_t *stream, int start_pos, int start_time) { pthread_cleanup_push (mutex_cleanup, (void *) &stream->frontend_lock); stream->delay_finish_event = 0; - + ret = play_internal (stream, start_pos, start_time); if( stream->slave && (stream->slave_affection & XINE_MASTER_SLAVE_PLAY) ) xine_play (stream->slave, start_pos, start_time); - + stream->gapless_switch = 0; pthread_cleanup_pop (0); pthread_mutex_unlock (&stream->frontend_lock); - + return ret; } int xine_eject (xine_stream_t *stream) { - + int status; - if (!stream->eject_class) + if (!stream->eject_class) return 0; - + pthread_mutex_lock (&stream->frontend_lock); pthread_cleanup_push (mutex_cleanup, (void *) &stream->frontend_lock); @@ -1507,7 +1507,7 @@ int xine_eject (xine_stream_t *stream) { pthread_cleanup_pop (0); pthread_mutex_unlock (&stream->frontend_lock); - + return status; } @@ -1539,7 +1539,7 @@ static void xine_dispose_internal (xine_stream_t *stream) { pthread_mutex_unlock(&stream->xine->streams_lock); _x_refcounter_dispose(stream->refcounter); - + free (stream->current_extra_info); free (stream->video_decoder_extra_info); free (stream->audio_decoder_extra_info); @@ -1557,7 +1557,7 @@ void xine_dispose (xine_stream_t *stream) { xine_close(stream); if( stream->master != stream ) { - stream->master->slave = NULL; + stream->master->slave = NULL; } if( stream->slave && stream->slave->master == stream ) { stream->slave->master = NULL; @@ -1565,7 +1565,7 @@ void xine_dispose (xine_stream_t *stream) { if(stream->broadcaster) _x_close_broadcaster(stream->broadcaster); - + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "shutdown audio\n"); _x_audio_decoder_shutdown (stream); @@ -1597,13 +1597,13 @@ void xine_exit (xine_t *this) { if(this->clock) this->clock->exit (this->clock); - + if(this->config) this->config->dispose(this->config); if(this->port_ticket) this->port_ticket->dispose(this->port_ticket); - + #if defined(WIN32) WSACleanup(); #endif @@ -1663,7 +1663,7 @@ xine_t *xine_new (void) { #endif /* WIN32 */ this->verbosity = XINE_VERBOSITY_NONE; - + return this; } @@ -1717,10 +1717,10 @@ static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) { strcmp(entry->str_value, homedir_trail_slash) == 0)) { xine_stream_t *stream; xine_list_iterator_t ite; - + xine_log(this, XINE_LOG_MSG, _("xine: The specified save_dir \"%s\" might be a security risk.\n"), entry->str_value); - + pthread_mutex_lock(&this->streams_lock); if ( (ite = xine_list_front(this->streams)) ) { stream = xine_list_get_value(this->streams, ite); @@ -1728,7 +1728,7 @@ static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) { } pthread_mutex_unlock(&this->streams_lock); } - + this->save_path = entry->str_value; } @@ -1744,7 +1744,7 @@ void xine_init (xine_t *this) { */ pthread_mutex_init (&this->streams_lock, NULL); pthread_mutex_init (&this->log_lock, NULL); - + /* initialize color conversion tables and functions */ init_yuv_conversion(); @@ -1784,7 +1784,7 @@ void xine_init (xine_t *this) { * save directory */ this->save_path = this->config->register_filename ( - this->config, + this->config, "media.capture.save_dir", "", XINE_CONFIG_STRING_IS_DIRECTORY_NAME, _("directory for saving streams"), _("When using the stream save feature, files will be written only into this directory.\n" @@ -1792,7 +1792,7 @@ void xine_init (xine_t *this) { "can be used to fill files in it with arbitrary content. So you should be careful that " "the directory you specify is robust against any content in any file."), XINE_CONFIG_SECURITY, config_save_cb, this); - + /* * implicit configuration changes */ @@ -1832,7 +1832,7 @@ void xine_init (xine_t *this) { this->clock = _x_metronom_clock_init(this); this->clock->start_clock (this->clock, 0); - + /* * tickets */ @@ -1845,7 +1845,7 @@ void _x_select_spu_channel (xine_stream_t *stream, int channel) { stream->spu_channel_user = (channel >= -2 ? channel : -2); stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0); - + switch (stream->spu_channel_user) { case -2: stream->spu_channel = -1; @@ -1865,7 +1865,7 @@ void _x_select_spu_channel (xine_stream_t *stream, int channel) { lprintf("set to %d\n",stream->spu_channel); stream->xine->port_ticket->release(stream->xine->port_ticket, 0); - + pthread_mutex_unlock (&stream->frontend_lock); } @@ -1925,10 +1925,10 @@ void _x_set_fine_speed (xine_stream_t *stream, int speed) { { if (speed <= XINE_SPEED_PAUSE) speed = XINE_SPEED_PAUSE; - + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "set_speed %d\n", speed); set_speed_internal (stream, speed); - + if (stream->slave && (stream->slave_affection & XINE_MASTER_SLAVE_SPEED)) set_speed_internal (stream->slave, speed); } @@ -1940,7 +1940,7 @@ int _x_get_fine_speed (xine_stream_t *stream) { } void _x_set_speed (xine_stream_t *stream, int speed) { - + if (speed > XINE_SPEED_FAST_4) speed = XINE_SPEED_FAST_4; @@ -1949,13 +1949,13 @@ void _x_set_speed (xine_stream_t *stream, int speed) { int _x_get_speed (xine_stream_t *stream) { int speed = _x_get_fine_speed (stream); - + /* - * ensure compatibility with old API, only valid XINE_SPEED_xxx + * ensure compatibility with old API, only valid XINE_SPEED_xxx * constants are allowed. XINE_SPEED_NORMAL may only be returned * if speed is exactly XINE_FINE_SPEED_NORMAL. */ - + if( speed <= XINE_SPEED_PAUSE ) return XINE_SPEED_PAUSE; if( speed <= XINE_SPEED_SLOW_4 * XINE_FINE_SPEED_NORMAL / XINE_SPEED_NORMAL ) @@ -2023,7 +2023,7 @@ static int _x_get_current_frame_data (xine_stream_t *stream, if (frame) frame->lock(frame); stream->xine->port_ticket->release(stream->xine->port_ticket, 0); - + if (!frame) { data->img_size = 0; return 0; @@ -2047,7 +2047,7 @@ static int _x_get_current_frame_data (xine_stream_t *stream, data->ratio_code = XINE_VO_ASPECT_ANAMORPHIC; else if (RATIO_LIKE(data->ratio_code, 21100)) data->ratio_code = XINE_VO_ASPECT_DVB; - + data->format = frame->format; data->interlaced = frame->progressive_frame ? 0 : (2 - frame->top_field_first); @@ -2072,7 +2072,7 @@ static int _x_get_current_frame_data (xine_stream_t *stream, if (!data->img && !(flags & XINE_FRAME_DATA_ALLOCATE_IMG)) break; /* not interested in image data */ - xprintf (stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "xine: error, snapshot function not implemented for format 0x%x\n", frame->format); /* fall though and provide "green" YV12 image */ data->format = XINE_IMGFMT_YV12; @@ -2109,7 +2109,7 @@ static int _x_get_current_frame_data (xine_stream_t *stream, /* return used buffer size */ data->img_size = required_size; } - + if (data->img) { switch (frame->format) { @@ -2307,7 +2307,7 @@ static inline void check_log_alloc (xine_t *this, int buf) void xine_log (xine_t *this, int buf, const char *format, ...) { va_list argp; char buffer[SCRATCH_LINE_LEN_MAX]; - + check_log_alloc (this, buf); va_start (argp, format); @@ -2319,13 +2319,13 @@ void xine_log (xine_t *this, int buf, const char *format, ...) { vsnprintf(buffer, SCRATCH_LINE_LEN_MAX, format, argp); printf("%s", buffer); va_end (argp); - } + } if (this->log_cb) this->log_cb (this->log_cb_user_data, buf); } -void xine_vlog(xine_t *this, int buf, const char *format, +void xine_vlog(xine_t *this, int buf, const char *format, va_list args) { check_log_alloc (this, buf); @@ -2373,13 +2373,13 @@ int _x_query_buffer_usage(xine_stream_t *stream, int *num_video_buffers, int *nu if (num_video_buffers) *num_video_buffers = (stream->video_fifo ? stream->video_fifo->size(stream->video_fifo) : 0); - + if (num_audio_buffers) *num_audio_buffers = (stream->audio_fifo ? stream->audio_fifo->size(stream->audio_fifo) : 0); - + if ((num_video_frames && stream->video_out) || (num_audio_frames && stream->audio_out)) { - + ticket_acquired = stream->xine->port_ticket->acquire_nonblocking(stream->xine->port_ticket, 1); } @@ -2437,14 +2437,14 @@ int _x_query_unprocessed_osd_events(xine_stream_t *stream) { video_overlay_manager_t *ovl; int redraw_needed; - + if (!stream->xine->port_ticket->acquire_nonblocking(stream->xine->port_ticket, 1)) return -1; ovl = stream->video_out->get_overlay_manager(stream->video_out); redraw_needed = ovl->redraw_needed(ovl, 0); - - if (redraw_needed) + + if (redraw_needed) stream->video_out->trigger_drawing(stream->video_out); stream->xine->port_ticket->release_nonblocking(stream->xine->port_ticket, 1); diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c index 7c0d85c59..62965fbf8 100644 --- a/src/xine-engine/xine_interface.c +++ b/src/xine-engine/xine_interface.c @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -46,7 +46,7 @@ #include <xine/demux.h> #include <xine/post.h> -/* +/* * version information / checking */ @@ -65,12 +65,12 @@ void xine_get_version (int *major, int *minor, int *sub) { } int xine_check_version(int major, int minor, int sub) { - - if((XINE_MAJOR > major) || - ((XINE_MAJOR == major) && (XINE_MINOR > minor)) || + + if((XINE_MAJOR > major) || + ((XINE_MAJOR == major) && (XINE_MINOR > minor)) || ((XINE_MAJOR == major) && (XINE_MINOR == minor) && (XINE_SUB >= sub))) return 1; - + return 0; } @@ -86,7 +86,7 @@ const char* xine_config_register_string (xine_t *self, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { - + return self->config->register_string (self->config, key, def_value, @@ -107,7 +107,7 @@ const char* xine_config_register_filename (xine_t *self, int exp_level, xine_config_cb_t changed_cb, void *cb_data) { - + return self->config->register_filename (self->config, key, def_value, req_type, description, help, exp_level, @@ -128,7 +128,7 @@ int xine_config_register_range (xine_t *self, description, help, exp_level, changed_cb, cb_data); } - + int xine_config_register_enum (xine_t *self, const char *key, @@ -144,7 +144,7 @@ int xine_config_register_enum (xine_t *self, description, help, exp_level, changed_cb, cb_data); } - + int xine_config_register_num (xine_t *self, const char *key, @@ -155,7 +155,7 @@ int xine_config_register_num (xine_t *self, xine_config_cb_t changed_cb, void *cb_data) { return self->config->register_num (self->config, - key, def_value, + key, def_value, description, help, exp_level, changed_cb, cb_data); } @@ -170,11 +170,11 @@ int xine_config_register_bool (xine_t *self, xine_config_cb_t changed_cb, void *cb_data) { return self->config->register_bool (self->config, - key, def_value, + key, def_value, description, help, exp_level, changed_cb, cb_data); } - + /* * helper function: @@ -210,7 +210,7 @@ static int config_get_current_entry (xine_t *this, xine_cfg_entry_t *entry) { } /* - * get first config item + * get first config item */ int xine_config_get_first_entry (xine_t *this, xine_cfg_entry_t *entry) { int result; @@ -227,12 +227,12 @@ int xine_config_get_first_entry (xine_t *this, xine_cfg_entry_t *entry) { return result; } - + /* * get next config item (iterate through the items) * this will return NULL when called after returning the last item - */ + */ int xine_config_get_next_entry (xine_t *this, xine_cfg_entry_t *entry) { int result; config_values_t *config = this->config; @@ -243,7 +243,7 @@ int xine_config_get_next_entry (xine_t *this, xine_cfg_entry_t *entry) { pthread_mutex_unlock(&config->config_lock); return (xine_config_get_first_entry(this, entry)); } - + /* do not hand out unclaimed entries */ do { config->cur = config->cur->next; @@ -252,11 +252,11 @@ int xine_config_get_next_entry (xine_t *this, xine_cfg_entry_t *entry) { pthread_mutex_unlock(&config->config_lock); return result; -} - +} + /* - * search for a config entry by key + * search for a config entry by key */ int xine_config_lookup_entry (xine_t *this, const char *key, @@ -274,7 +274,7 @@ int xine_config_lookup_entry (xine_t *this, const char *key, return result; } - + /* * update a config entry (which was returned from lookup_entry() ) @@ -294,12 +294,12 @@ void xine_config_update_entry (xine_t *this, const xine_cfg_entry_t *entry) { break; default: - xprintf (this, XINE_VERBOSITY_DEBUG, + xprintf (this, XINE_VERBOSITY_DEBUG, "xine_interface: error, unknown config entry type %d\n", entry->type); _x_abort(); } } - + void xine_config_reset (xine_t *this) { @@ -325,7 +325,7 @@ void xine_config_reset (xine_t *this) { int xine_port_send_gui_data (xine_video_port_t *vo, int type, void *data) { - return vo->driver->gui_data_exchange (vo->driver, + return vo->driver->gui_data_exchange (vo->driver, type, data); } @@ -360,7 +360,7 @@ void xine_set_param (xine_stream_t *stream, int param, int value) { _x_set_speed (stream, value); pthread_mutex_unlock (&stream->frontend_lock); break; - + case XINE_PARAM_FINE_SPEED: pthread_mutex_lock (&stream->frontend_lock); _x_set_fine_speed (stream, value); @@ -370,7 +370,7 @@ void xine_set_param (xine_stream_t *stream, int param, int value) { case XINE_PARAM_AV_OFFSET: stream->metronom->set_option (stream->metronom, METRONOM_AV_OFFSET, value); break; - + case XINE_PARAM_SPU_OFFSET: stream->metronom->set_option (stream->metronom, METRONOM_SPU_OFFSET, value); break; @@ -408,14 +408,14 @@ void xine_set_param (xine_stream_t *stream, int param, int value) { stream->audio_out->set_property (stream->audio_out, AO_PROP_MUTE_VOL, value); stream->xine->port_ticket->release(stream->xine->port_ticket, 0); break; - + case XINE_PARAM_AUDIO_COMPR_LEVEL: stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0); if (stream->audio_out) stream->audio_out->set_property (stream->audio_out, AO_PROP_COMPRESSOR, value); stream->xine->port_ticket->release(stream->xine->port_ticket, 0); break; - + case XINE_PARAM_AUDIO_AMP_LEVEL: stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0); if (stream->audio_out) { @@ -455,8 +455,8 @@ void xine_set_param (xine_stream_t *stream, int param, int value) { case XINE_PARAM_EQ_16000HZ: stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0); if (stream->audio_out) - stream->audio_out->set_property (stream->audio_out, - param - XINE_PARAM_EQ_30HZ + AO_PROP_EQ_30HZ, + stream->audio_out->set_property (stream->audio_out, + param - XINE_PARAM_EQ_30HZ + AO_PROP_EQ_30HZ, value); stream->xine->port_ticket->release(stream->xine->port_ticket, 0); break; @@ -486,15 +486,15 @@ void xine_set_param (xine_stream_t *stream, int param, int value) { case XINE_PARAM_IGNORE_VIDEO: _x_stream_info_set(stream, XINE_STREAM_INFO_IGNORE_VIDEO, value); break; - + case XINE_PARAM_IGNORE_AUDIO: _x_stream_info_set(stream, XINE_STREAM_INFO_IGNORE_AUDIO, value); break; - + case XINE_PARAM_IGNORE_SPU: _x_stream_info_set(stream, XINE_STREAM_INFO_IGNORE_SPU, value); break; - + case XINE_PARAM_METRONOM_PREBUFFER: stream->metronom->set_option(stream->metronom, METRONOM_PREBUFFER, value); break; @@ -507,26 +507,26 @@ void xine_set_param (xine_stream_t *stream, int param, int value) { stream->broadcaster = NULL; } break; - + case XINE_PARAM_EARLY_FINISHED_EVENT: stream->early_finish_event = !!value; break; - + case XINE_PARAM_DELAY_FINISHED_EVENT: stream->delay_finish_event = value; break; - + case XINE_PARAM_GAPLESS_SWITCH: stream->gapless_switch = !!value; if( stream->gapless_switch && !stream->early_finish_event ) { xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "frontend possibly buggy: gapless_switch without early_finish_event\n"); } break; - + default: xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "xine_interface: unknown or deprecated stream param %d set\n", param); - } + } } int xine_get_param (xine_stream_t *stream, int param) { @@ -536,7 +536,7 @@ int xine_get_param (xine_stream_t *stream, int param) { case XINE_PARAM_SPEED: ret = _x_get_speed(stream); break; - + case XINE_PARAM_FINE_SPEED: ret = _x_get_fine_speed(stream); break; @@ -544,7 +544,7 @@ int xine_get_param (xine_stream_t *stream, int param) { case XINE_PARAM_AV_OFFSET: ret = stream->metronom->get_option (stream->metronom, METRONOM_AV_OFFSET); break; - + case XINE_PARAM_SPU_OFFSET: ret = stream->metronom->get_option (stream->metronom, METRONOM_SPU_OFFSET); break; @@ -567,7 +567,7 @@ int xine_get_param (xine_stream_t *stream, int param) { ret = -1; else ret = stream->audio_out->get_property (stream->audio_out, AO_PROP_MIXER_VOL); - stream->xine->port_ticket->release(stream->xine->port_ticket, 0); + stream->xine->port_ticket->release(stream->xine->port_ticket, 0); break; case XINE_PARAM_AUDIO_MUTE: @@ -576,7 +576,7 @@ int xine_get_param (xine_stream_t *stream, int param) { ret = -1; else ret = stream->audio_out->get_property (stream->audio_out, AO_PROP_MUTE_VOL); - stream->xine->port_ticket->release(stream->xine->port_ticket, 0); + stream->xine->port_ticket->release(stream->xine->port_ticket, 0); break; case XINE_PARAM_AUDIO_COMPR_LEVEL: @@ -585,7 +585,7 @@ int xine_get_param (xine_stream_t *stream, int param) { ret = -1; else ret = stream->audio_out->get_property (stream->audio_out, AO_PROP_COMPRESSOR); - stream->xine->port_ticket->release(stream->xine->port_ticket, 0); + stream->xine->port_ticket->release(stream->xine->port_ticket, 0); break; case XINE_PARAM_AUDIO_AMP_LEVEL: @@ -594,7 +594,7 @@ int xine_get_param (xine_stream_t *stream, int param) { ret = -1; else ret = stream->audio_out->get_property (stream->audio_out, AO_PROP_AMP); - stream->xine->port_ticket->release(stream->xine->port_ticket, 0); + stream->xine->port_ticket->release(stream->xine->port_ticket, 0); break; case XINE_PARAM_AUDIO_AMP_MUTE: @@ -603,7 +603,7 @@ int xine_get_param (xine_stream_t *stream, int param) { ret = -1; else ret = stream->audio_out->get_property (stream->audio_out, AO_PROP_AMP_MUTE); - stream->xine->port_ticket->release(stream->xine->port_ticket, 0); + stream->xine->port_ticket->release(stream->xine->port_ticket, 0); break; case XINE_PARAM_EQ_30HZ: @@ -620,9 +620,9 @@ int xine_get_param (xine_stream_t *stream, int param) { if (!stream->audio_out) ret = -1; else - ret= stream->audio_out->get_property (stream->audio_out, + ret= stream->audio_out->get_property (stream->audio_out, param - XINE_PARAM_EQ_30HZ + AO_PROP_EQ_30HZ); - stream->xine->port_ticket->release(stream->xine->port_ticket, 0); + stream->xine->port_ticket->release(stream->xine->port_ticket, 0); break; case XINE_PARAM_VERBOSITY: @@ -646,17 +646,17 @@ int xine_get_param (xine_stream_t *stream, int param) { case XINE_PARAM_VO_CROP_BOTTOM: stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0); ret = stream->video_out->get_property(stream->video_out, param); - stream->xine->port_ticket->release(stream->xine->port_ticket, 0); + stream->xine->port_ticket->release(stream->xine->port_ticket, 0); break; - + case XINE_PARAM_IGNORE_VIDEO: ret = _x_stream_info_get_public(stream, XINE_STREAM_INFO_IGNORE_VIDEO); break; - + case XINE_PARAM_IGNORE_AUDIO: ret = _x_stream_info_get_public(stream, XINE_STREAM_INFO_IGNORE_AUDIO); break; - + case XINE_PARAM_IGNORE_SPU: ret = _x_stream_info_get_public(stream, XINE_STREAM_INFO_IGNORE_SPU); break; @@ -664,22 +664,22 @@ int xine_get_param (xine_stream_t *stream, int param) { case XINE_PARAM_METRONOM_PREBUFFER: ret = stream->metronom->get_option(stream->metronom, METRONOM_PREBUFFER); break; - + case XINE_PARAM_BROADCASTER_PORT: if( stream->broadcaster ) ret = _x_get_broadcaster_port(stream->broadcaster); else ret = 0; break; - + case XINE_PARAM_EARLY_FINISHED_EVENT: ret = stream->early_finish_event; break; - + case XINE_PARAM_DELAY_FINISHED_EVENT: ret = stream->delay_finish_event; break; - + case XINE_PARAM_GAPLESS_SWITCH: ret = stream->gapless_switch; break; @@ -749,7 +749,7 @@ uint32_t xine_get_stream_info (xine_stream_t *stream, int info) { case XINE_STREAM_INFO_MAX_SPU_CHANNEL: return stream->spu_track_map_entries; - + default: xprintf (stream->xine, XINE_VERBOSITY_DEBUG, "xine_interface: unknown or deprecated stream info %d requested\n", info); @@ -770,11 +770,11 @@ xine_osd_t *xine_osd_new(xine_stream_t *stream, int x, int y, int width, int hei uint32_t xine_osd_get_capabilities(xine_osd_t *this) { return this->osd.renderer->get_capabilities(&this->osd); -} +} void xine_osd_draw_point(xine_osd_t *this, int x, int y, int color) { this->osd.renderer->point(&this->osd, x, y, color); -} +} void xine_osd_draw_line(xine_osd_t *this, int x1, int y1, int x2, int y2, int color) { this->osd.renderer->line(&this->osd, x1, y1, x2, y2, color); @@ -876,7 +876,7 @@ const char *const *xine_post_list_outputs(xine_post_t *this_gen) { xine_post_in_t *xine_post_input(xine_post_t *this_gen, const char *name) { post_plugin_t *this = (post_plugin_t *)this_gen; xine_list_iterator_t ite; - + ite = xine_list_front(this->input); while (ite) { xine_post_in_t *input = xine_list_get_value(this->input, ite); @@ -890,7 +890,7 @@ xine_post_in_t *xine_post_input(xine_post_t *this_gen, const char *name) { xine_post_out_t *xine_post_output(xine_post_t *this_gen, const char *name) { post_plugin_t *this = (post_plugin_t *)this_gen; xine_list_iterator_t ite; - + ite = xine_list_front(this->output); while (ite) { xine_post_out_t *output = xine_list_get_value(this->output, ite); @@ -941,7 +941,7 @@ int xine_post_wire_audio_port(xine_post_out_t *source, xine_audio_port_t *ao) { } xine_post_out_t * xine_get_video_source(xine_stream_t *stream) { - return &stream->video_source; + return &stream->video_source; } xine_post_out_t * xine_get_audio_source(xine_stream_t *stream) { @@ -998,14 +998,14 @@ int _x_message(xine_stream_t *stream, int type, ...) { va_end(ap); args[n] = NULL; - + size += sizeof(xine_ui_message_data_t) + 1; data = calloc(1, size ); strcpy(data->compatibility.str, "Upgrade your frontend to see the error messages"); data->type = type; data->num_parameters = n; - + if( explanation ) { strcpy(data->messages, explanation); data->explanation = data->messages - (char *)data; @@ -1016,10 +1016,10 @@ int _x_message(xine_stream_t *stream, int type, ...) { } data->parameters = params - (char *)data; - + n = 0; *params = '\0'; - + while(args[n]) { strcpy(params, args[n]); params += strlen(args[n]) + 1; diff --git a/src/xine-engine/xine_private.h b/src/xine-engine/xine_private.h index 6fb215bab..6c01d3a2d 100644 --- a/src/xine-engine/xine_private.h +++ b/src/xine-engine/xine_private.h @@ -1,18 +1,18 @@ /* * Copyright (C) 2000-2008 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |