summaryrefslogtreecommitdiff
path: root/src/xine-engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/xine-engine')
-rw-r--r--src/xine-engine/accel_xvmc.h12
-rw-r--r--src/xine-engine/alphablend.c318
-rw-r--r--src/xine-engine/alphablend.h23
-rw-r--r--src/xine-engine/audio_decoder.c132
-rw-r--r--src/xine-engine/audio_decoder.h22
-rw-r--r--src/xine-engine/audio_out.c314
-rw-r--r--src/xine-engine/audio_out.h42
-rw-r--r--src/xine-engine/broadcaster.c102
-rw-r--r--src/xine-engine/broadcaster.h8
-rw-r--r--src/xine-engine/bswap.h4
-rw-r--r--src/xine-engine/buffer.c24
-rw-r--r--src/xine-engine/buffer.h79
-rw-r--r--src/xine-engine/buffer_types.c89
-rw-r--r--src/xine-engine/configfile.c113
-rw-r--r--src/xine-engine/configfile.h8
-rw-r--r--src/xine-engine/demux.c210
-rw-r--r--src/xine-engine/events.c34
-rw-r--r--src/xine-engine/info_helper.c69
-rw-r--r--src/xine-engine/info_helper.h2
-rw-r--r--src/xine-engine/input_cache.c50
-rw-r--r--src/xine-engine/input_rip.c81
-rw-r--r--src/xine-engine/io_helper.c46
-rw-r--r--src/xine-engine/load_plugins.c659
-rw-r--r--src/xine-engine/lrb.c20
-rw-r--r--src/xine-engine/lrb.h8
-rw-r--r--src/xine-engine/metronom.c193
-rw-r--r--src/xine-engine/metronom.h50
-rw-r--r--src/xine-engine/osd.c365
-rw-r--r--src/xine-engine/osd.h60
-rw-r--r--src/xine-engine/plugin_catalog.h14
-rw-r--r--src/xine-engine/post.c223
-rw-r--r--src/xine-engine/post.h82
-rw-r--r--src/xine-engine/refcounter.c21
-rw-r--r--src/xine-engine/refcounter.h14
-rw-r--r--src/xine-engine/resample.c82
-rw-r--r--src/xine-engine/resample.h28
-rw-r--r--src/xine-engine/scratch.c29
-rw-r--r--src/xine-engine/scratch.h15
-rw-r--r--src/xine-engine/spu_decoder.h20
-rw-r--r--src/xine-engine/tvmode.c10
-rw-r--r--src/xine-engine/video_decoder.c150
-rw-r--r--src/xine-engine/video_decoder.h22
-rw-r--r--src/xine-engine/video_out.c338
-rw-r--r--src/xine-engine/video_out.h94
-rw-r--r--src/xine-engine/video_overlay.c176
-rw-r--r--src/xine-engine/video_overlay.h20
-rw-r--r--src/xine-engine/vo_scale.c80
-rw-r--r--src/xine-engine/vo_scale.h44
-rw-r--r--src/xine-engine/xine.c521
-rw-r--r--src/xine-engine/xine_interface.c147
-rw-r--r--src/xine-engine/xine_internal.h97
-rw-r--r--src/xine-engine/xine_plugin.h10
-rw-r--r--src/xine-engine/xineintl.h8
53 files changed, 2880 insertions, 2502 deletions
diff --git a/src/xine-engine/accel_xvmc.h b/src/xine-engine/accel_xvmc.h
index cec5f9558..197b76050 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.
*
*
*/
@@ -81,7 +81,7 @@ typedef struct xine_xxmc_s {
*/
xine_xvmc_t xvmc;
-
+
unsigned mpeg;
unsigned acceleration;
int fallback_format;
@@ -103,7 +103,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 a7ab33cf8..4727740bd 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
*
@@ -23,6 +23,10 @@
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
/*
#define LOG_BLEND_YUV
#define LOG_BLEND_RGB16
@@ -110,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]
*
@@ -177,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,
@@ -186,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);
*/
@@ -196,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
@@ -229,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) {
@@ -283,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);
@@ -300,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++;
@@ -341,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;
@@ -386,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;
@@ -406,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;
}
@@ -431,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;
@@ -451,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;
}
@@ -469,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;
@@ -485,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++;
@@ -509,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;
@@ -525,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++;
@@ -540,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
@@ -572,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
@@ -615,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++;
@@ -623,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;
@@ -642,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;
@@ -662,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];
@@ -739,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
@@ -782,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++;
@@ -790,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;
@@ -809,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;
@@ -829,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];
@@ -906,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++;
@@ -957,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;
@@ -976,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;
@@ -996,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];
@@ -1052,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 ];
@@ -1074,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 ];
@@ -1104,18 +1108,18 @@ static void blend_yuv_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
static uint8_t *(*blend_yuv_grow_extra_data(alphablend_t *extra_data, int osd_width))[ 3 ][ 2 ]
{
- struct __attribute__((packed)) header_s {
+ struct XINE_PACKED header_s {
int id;
int max_width;
uint8_t *data[ 3 ][ 2 ];
} *header = (struct header_s *)extra_data->buffer;
-
- int needed_buffer_size = sizeof (*header) + osd_width * sizeof (uint8_t[ 3 ][ 2 ]);
-
+
+ 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 = xine_xmalloc(needed_buffer_size);
+ header = calloc(1, needed_buffer_size);
if (!header) {
extra_data->buffer_size = 0;
return 0;
@@ -1139,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)
@@ -1164,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);
@@ -1184,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
@@ -1215,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) {
@@ -1233,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
@@ -1243,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
@@ -1259,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;
@@ -1277,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);
@@ -1292,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;
@@ -1331,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
@@ -1377,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;
@@ -1388,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);
@@ -1430,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];
}
@@ -1451,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 ];
@@ -1477,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 ];
@@ -1492,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);
@@ -1508,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)
@@ -1519,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).
@@ -1527,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
*/
@@ -1546,18 +1550,18 @@ static void blend_yuy2_exact(uint8_t *dst_cr, uint8_t *dst_cb, int src_width,
static uint8_t *(*blend_yuy2_grow_extra_data(alphablend_t *extra_data, int osd_width))[ 3 ]
{
- struct __attribute__((packed)) header_s {
+ struct XINE_PACKED header_s {
int id;
int max_width;
uint8_t *data[ 3 ];
} *header = (struct header_s *)extra_data->buffer;
-
- int needed_buffer_size = sizeof (*header) + osd_width * sizeof (uint8_t[ 3 ]);
-
+
+ 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 = xine_xmalloc(needed_buffer_size);
+ header = calloc(1, needed_buffer_size);
if (!header) {
extra_data->buffer_size = 0;
return 0;
@@ -1615,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;
@@ -1627,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
@@ -1658,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);
}
@@ -1671,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;
@@ -1681,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;
@@ -1704,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);
@@ -1718,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;
@@ -1754,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
@@ -1794,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;
@@ -1846,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++;
@@ -1871,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;
}
}
@@ -1888,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;
@@ -1900,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;
@@ -1921,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++;
@@ -1931,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;
@@ -1942,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) {
@@ -1968,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;
@@ -1980,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;
@@ -2013,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
@@ -2049,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);
@@ -2087,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);
@@ -2119,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;
}
@@ -2135,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/alphablend.h b/src/xine-engine/alphablend.h
index 3c9a693d9..86cc68302 100644
--- a/src/xine-engine/alphablend.h
+++ b/src/xine-engine/alphablend.h
@@ -39,22 +39,7 @@ typedef struct {
void _x_alphablend_init(alphablend_t *extra_data, xine_t *xine) XINE_PROTECTED;
void _x_alphablend_free(alphablend_t *extra_data) XINE_PROTECTED;
-/* _MSC_VER port changes */
-#undef ATTRIBUTE_PACKED
-#undef PRAGMA_PACK_BEGIN
-#undef PRAGMA_PACK_END
-
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined(__ICC)
-#define ATTRIBUTE_PACKED __attribute__ ((packed))
-#define PRAGMA_PACK 0
-#endif
-
-#if !defined(ATTRIBUTE_PACKED)
-#define ATTRIBUTE_PACKED
-#define PRAGMA_PACK 1
-#endif
-
-#if PRAGMA_PACK
+#if !SUPPORT_ATTRIBUTE_PACKED
#pragma pack(8)
#endif
@@ -63,10 +48,10 @@ typedef struct { /* CLUT == Color LookUp Table */
uint8_t cr;
uint8_t y;
uint8_t foo;
-} ATTRIBUTE_PACKED clut_t;
+} XINE_PACKED clut_t;
-#if PRAGMA_PACK
+#if !SUPPORT_ATTRIBUTE_PACKED
#pragma pack()
#endif
@@ -112,7 +97,7 @@ void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl,
*/
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) XINE_PROTECTED;
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c
index 5476262d9..dd15bf696 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,25 +85,27 @@ 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;
stream->audio_track_map_entries = 0;
stream->audio_type = 0;
+ stream->keep_ao_driver_open = 0;
}
-
+
running_ticket->release(running_ticket, 0);
-
- if( !stream->gapless_switch )
+
+ 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 */
@@ -126,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
@@ -142,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);
@@ -162,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;
@@ -191,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;
@@ -208,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 {
@@ -218,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;
}
@@ -246,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;
@@ -302,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
@@ -319,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;
@@ -353,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;
@@ -378,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;
}
@@ -386,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.
*/
@@ -406,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;
@@ -454,7 +456,7 @@ static void *audio_decoder_loop (void *stream_gen) {
}
first_header = last_header = NULL;
}
-
+
return NULL;
}
@@ -469,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
@@ -477,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,
@@ -487,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;
@@ -503,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;
@@ -530,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_decoder.h b/src/xine-engine/audio_decoder.h
index 8f75ba242..9f695685f 100644
--- a/src/xine-engine/audio_decoder.h
+++ b/src/xine-engine/audio_decoder.h
@@ -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,14 +46,14 @@ struct audio_decoder_class_s {
* open a new instance of this plugin class
*/
audio_decoder_t* (*open_plugin) (audio_decoder_class_t *this, xine_stream_t *stream);
-
+
/*
* return short, human readable identifier for this plugin class
*/
char* (*get_identifier) (audio_decoder_class_t *this);
/*
- * return human readable (verbose = 1 line) description for
+ * return human readable (verbose = 1 line) description for
* this plugin class
*/
char* (*get_description) (audio_decoder_class_t *this);
@@ -69,8 +69,8 @@ struct audio_decoder_class_s {
struct audio_decoder_s {
/*
- * decode data from buf and feed decoded samples to
- * audio output
+ * decode data from buf and feed decoded samples to
+ * audio output
*/
void (*decode_data) (audio_decoder_t *this, buf_element_t *buf);
@@ -79,13 +79,13 @@ struct audio_decoder_s {
* audio data not related to recently decoded data)
*/
void (*reset) (audio_decoder_t *this);
-
+
/*
* inform decoder that a time reference discontinuity has happened.
* that is, it must forget any currently held pts value
*/
- void (*discontinuity) (audio_decoder_t *this);
-
+ void (*discontinuity) (audio_decoder_t *this);
+
/*
* close down, free all resources
*/
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c
index 7fe92d9fe..4f68b8975 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
@@ -22,7 +22,7 @@
* 20-8-2001 First implementation of Audio sync and Audio driver separation.
* (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk
*/
-
+
/*
* General Programming Guidelines: -
* New concept of an "audio_frame".
@@ -98,7 +98,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.
*
@@ -154,13 +154,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;
@@ -193,15 +193,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;
@@ -215,6 +215,7 @@ typedef struct {
int num_driver_actions; /* number of threads, that wish to call
* functions needing driver_lock */
pthread_mutex_t driver_action_lock; /* protects num_driver_actions */
+ pthread_cond_t driver_action_cond; /* informs about num_driver_actions-- */
metronom_clock_t *clock;
xine_t *xine;
@@ -225,7 +226,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
@@ -243,11 +244,12 @@ typedef struct {
audio_fifo_t *free_fifo;
audio_fifo_t *out_fifo;
int64_t last_audio_vpts;
+ pthread_mutex_t current_speed_lock;
uint32_t current_speed; /* the current playback speed */
/* 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;
@@ -273,7 +275,7 @@ typedef struct {
int eq_k;
sXYData eq_data_history[EQ_BANDS][EQ_CHANNELS];
-
+
} aos_t;
struct audio_fifo_s {
@@ -287,13 +289,14 @@ struct audio_fifo_s {
int num_buffers;
};
+static int ao_get_property (xine_audio_port_t *this_gen, int property);
static int ao_set_property (xine_audio_port_t *this_gen, int property, int value);
-static audio_fifo_t *fifo_new (xine_t *xine) {
+static audio_fifo_t *XINE_MALLOC fifo_new (xine_t *xine) {
audio_fifo_t *fifo;
- fifo = (audio_fifo_t *) xine_xmalloc (sizeof (audio_fifo_t));
+ fifo = (audio_fifo_t *) calloc(1, sizeof(audio_fifo_t));
if (!fifo)
return NULL;
@@ -437,7 +440,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;
@@ -467,7 +470,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) {
@@ -491,7 +494,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;
@@ -522,7 +525,7 @@ int _x_ao_mode2channels( int mode ) {
return 6;
}
return 0;
-}
+}
int _x_ao_channels2mode( int channels ) {
@@ -553,7 +556,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++) {
@@ -569,12 +572,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 */
@@ -610,11 +613,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;
}
@@ -627,11 +630,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;
}
@@ -935,7 +938,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)
@@ -970,7 +973,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;
}
@@ -978,7 +981,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.
@@ -1006,7 +1009,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);
@@ -1031,17 +1034,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.
*/
-
- if ( this->audio_loop_running &&
- (this->clock->speed == XINE_SPEED_PAUSE ||
- (this->clock->speed != XINE_FINE_SPEED_NORMAL &&
+
+ 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 &&
!this->slow_fast_audio) ) ) {
if (this->clock->speed != XINE_SPEED_PAUSE) {
@@ -1054,6 +1058,7 @@ static void *ao_loop (void *this_gen) {
_x_refcounter_dec(in_buf->stream->refcounter);
fifo_append (this->free_fifo, in_buf);
in_buf = NULL;
+ pthread_mutex_unlock(&this->current_speed_lock);
continue;
}
@@ -1064,6 +1069,7 @@ static void *ao_loop (void *this_gen) {
}
lprintf ("loop:pause: I feel sleepy (%d buffers).\n", this->out_fifo->num_buffers);
+ pthread_mutex_unlock(&this->current_speed_lock);
xine_usec_sleep (10000);
lprintf ("loop:pause: I wake up.\n");
continue;
@@ -1077,7 +1083,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,
@@ -1101,7 +1107,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;
@@ -1121,8 +1127,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 ||
@@ -1132,9 +1138,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?
*/
@@ -1142,12 +1148,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:
*/
@@ -1183,13 +1189,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;
@@ -1242,7 +1248,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"));
@@ -1266,19 +1272,27 @@ 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);
fifo_append (this->free_fifo, in_buf);
in_buf = NULL;
}
+ pthread_mutex_unlock(&this->current_speed_lock);
/* Give other threads a chance to use functions which require this->driver_lock to
* be available. This is needed when using NPTL on Linux (and probably PThreads
* on Solaris as well). */
- if (this->num_driver_actions > 0)
- sched_yield();
+ if (this->num_driver_actions > 0) {
+ /* calling sched_yield() is not sufficient on multicore systems */
+ /* sched_yield(); */
+ /* instead wait for the other thread to acquire this->driver_lock */
+ pthread_mutex_lock(&this->driver_action_lock);
+ if (this->num_driver_actions > 0)
+ pthread_cond_wait(&this->driver_action_cond, &this->driver_action_lock);
+ pthread_mutex_unlock(&this->driver_action_lock);
+ }
}
if (in_buf) {
@@ -1311,9 +1325,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) {
@@ -1367,10 +1381,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;
@@ -1395,7 +1409,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;
}
@@ -1404,7 +1418,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;
@@ -1413,7 +1427,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,
@@ -1433,7 +1447,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;
@@ -1469,6 +1483,8 @@ static inline void dec_num_driver_actions(aos_t *this) {
pthread_mutex_lock(&this->driver_action_lock);
this->num_driver_actions--;
+ /* indicate the change to ao_loop() */
+ pthread_cond_broadcast(&this->driver_action_cond);
pthread_mutex_unlock(&this->driver_action_lock);
}
@@ -1479,7 +1495,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;
@@ -1495,7 +1511,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);
@@ -1506,7 +1522,7 @@ static int ao_open(xine_audio_port_t *this_gen, xine_stream_t *stream,
}
}
- /*
+ /*
* set metainfo
*/
if (stream) {
@@ -1525,7 +1541,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;
}
@@ -1533,18 +1549,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;
@@ -1557,11 +1573,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);
@@ -1571,7 +1587,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);
@@ -1581,7 +1597,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");
@@ -1604,26 +1620,30 @@ 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 */
- if (!ite && !this->grab_only && !stream->gapless_switch) {
+ if (!ite && !this->grab_only && !stream->keep_ao_driver_open) {
xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_out: no streams left, closing driver\n");
if (this->audio_loop_running) {
+ /* make sure there are no more buffers on queue */
if (this->clock->speed == XINE_SPEED_PAUSE ||
(this->clock->speed != XINE_FINE_SPEED_NORMAL && !this->slow_fast_audio)) {
- /* discard buffers, otherwise we'll wait forever */
+ int discard = ao_get_property(this_gen, AO_PROP_DISCARD_BUFFERS);
+ /* discard buffers while waiting, otherwise we'll wait forever */
ao_set_property(this_gen, AO_PROP_DISCARD_BUFFERS, 1);
+ fifo_wait_empty(this->out_fifo);
+ ao_set_property(this_gen, AO_PROP_DISCARD_BUFFERS, discard);
}
- /* make sure there are no more buffers on queue */
- fifo_wait_empty(this->out_fifo);
+ else
+ fifo_wait_empty(this->out_fifo);
}
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 );
}
@@ -1633,7 +1653,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) {
@@ -1649,15 +1669,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)
@@ -1667,6 +1687,7 @@ static void ao_exit(xine_audio_port_t *this_gen) {
}
pthread_mutex_destroy(&this->driver_lock);
+ pthread_cond_destroy(&this->driver_action_cond);
pthread_mutex_destroy(&this->driver_action_lock);
pthread_mutex_destroy(&this->streams_lock);
xine_list_delete(this->streams);
@@ -1678,7 +1699,8 @@ 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);
@@ -1711,11 +1733,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);
@@ -1724,7 +1746,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 ;
@@ -1736,7 +1758,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;
@@ -1750,25 +1772,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:
@@ -1778,14 +1800,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;
@@ -1813,7 +1835,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;
@@ -1838,13 +1860,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);
@@ -1854,7 +1876,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)));
@@ -1862,22 +1884,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);
@@ -1905,13 +1927,20 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value
if (value != XINE_FINE_SPEED_NORMAL && value != XINE_SPEED_PAUSE && !this->slow_fast_audio )
this->ao.control(&this->ao, AO_CTRL_FLUSH_BUFFERS, NULL);
- this->ao.control(&this->ao,
- (value == XINE_SPEED_PAUSE) ? AO_CTRL_PLAY_PAUSE : AO_CTRL_PLAY_RESUME, NULL);
+ if( value == XINE_SPEED_PAUSE ) {
+ /* current_speed_lock is here to make sure the ao_loop will pause in a safe place.
+ * that is, we cannot pause writing to device, filling gaps etc. */
+ pthread_mutex_lock(&this->current_speed_lock);
+ this->ao.control(&this->ao, AO_CTRL_PLAY_PAUSE, NULL);
+ pthread_mutex_unlock(&this->current_speed_lock);
+ } else {
+ this->ao.control(&this->ao, AO_CTRL_PLAY_RESUME, NULL);
+ }
this->current_speed = 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 */
@@ -1957,7 +1986,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;
@@ -1996,7 +2025,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)) {
@@ -2010,8 +2039,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) {
@@ -2020,7 +2049,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;
@@ -2037,7 +2066,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;
@@ -2046,13 +2075,14 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver,
static const char* resample_modes[] = {"auto", "off", "on", NULL};
static const char* av_sync_methods[] = {"metronom feedback", "resample", NULL};
- this = xine_xmalloc (sizeof (aos_t)) ;
+ this = calloc(1, sizeof(aos_t)) ;
this->driver = driver;
this->xine = xine;
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()
*/
@@ -2062,6 +2092,7 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver,
pthread_mutex_init( &this->streams_lock, NULL );
pthread_mutex_init( &this->driver_lock, &attr );
pthread_mutex_init( &this->driver_action_lock, NULL );
+ pthread_cond_init( &this->driver_action_cond, NULL );
this->ao.open = ao_open;
this->ao.get_buffer = ao_get_buffer;
@@ -2075,13 +2106,14 @@ 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 = xine_xmalloc (ZERO_BUF_SIZE * 4 * 6); /* MAX as 32bit, 6 channels. */
-
+ 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 );
@@ -2116,7 +2148,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"),
@@ -2143,7 +2175,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,
@@ -2191,23 +2223,23 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver,
audio_buffer_t *buf;
- buf = (audio_buffer_t *) xine_xmalloc (sizeof (audio_buffer_t));
- buf->mem = xine_xmalloc (AUDIO_BUF_SIZE);
+ buf = (audio_buffer_t *) calloc(1, sizeof(audio_buffer_t));
+ 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++) {
audio_buffer_t *buf;
- buf = (audio_buffer_t *) xine_xmalloc (sizeof (audio_buffer_t));
- buf->mem = xine_xmalloc (4*AUDIO_BUF_SIZE);
+ buf = (audio_buffer_t *) calloc(1, sizeof(audio_buffer_t));
+ buf->mem = calloc(4, AUDIO_BUF_SIZE);
buf->mem_size = 4*AUDIO_BUF_SIZE;
buf->extra_info = malloc(sizeof(extra_info_t));
@@ -2219,13 +2251,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;
@@ -2234,34 +2266,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,
+
+ xprintf (this->xine, XINE_VERBOSITY_NONE,
"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/audio_out.h b/src/xine-engine/audio_out.h
index c4581ec24..832c65a9e 100644
--- a/src/xine-engine/audio_out.h
+++ b/src/xine-engine/audio_out.h
@@ -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
@@ -48,9 +48,9 @@ typedef struct ao_driver_s ao_driver_t;
struct ao_driver_s {
- /*
+ /*
*
- * find out what output modes + capatilities are supported by
+ * find out what output modes + capatilities are supported by
* this plugin (constants for the bit vector to return see above)
*
* See AO_CAP_* bellow.
@@ -58,7 +58,7 @@ struct ao_driver_s {
uint32_t (*get_capabilities) (ao_driver_t *);
/*
- * open the driver and make it ready to receive audio data
+ * open the driver and make it ready to receive audio data
* buffers may be flushed(!)
*
* return value: 0 : failure, >0 : output sample rate
@@ -74,21 +74,21 @@ struct ao_driver_s {
*/
int (*bytes_per_frame)(ao_driver_t *self_gen);
- /* return the delay is frames measured by
+ /* return the delay is frames measured by
* looking at pending samples in the audio output device
*/
int (*delay)(ao_driver_t *self_gen);
- /*
+ /*
* return gap tolerance (in pts) needed for this driver
*/
int (*get_gap_tolerance) (ao_driver_t *self_gen);
/*
* write audio data to audio output device
- * return value:
+ * return value:
* >0 => audio samples were processed ok
- * 0 => audio samples were not yet processed,
+ * 0 => audio samples were not yet processed,
* call write_audio_data with the _same_ samples again
*/
int (*write)(ao_driver_t *,
@@ -152,9 +152,9 @@ struct audio_buffer_s {
int64_t vpts;
uint32_t frame_header_count;
uint32_t first_access_unit;
-
+
/* extra info coming from input or demuxers */
- extra_info_t *extra_info;
+ extra_info_t *extra_info;
xine_stream_t *stream; /* stream that send that buffer */
@@ -179,7 +179,7 @@ struct xine_audio_port_s {
int (*get_property) (xine_audio_port_t *, int property);
int (*set_property) (xine_audio_port_t *, int property, int value);
- /* open audio driver for audio output
+ /* open audio driver for audio output
* return value: 0:failure, >0:output sample rate
*/
/* when you are not a full-blown stream, but still need to open the port
@@ -188,7 +188,7 @@ struct xine_audio_port_s {
uint32_t bits, uint32_t rate, int mode);
/*
- * get a piece of memory for audio data
+ * get a piece of memory for audio data
*/
audio_buffer_t * (*get_buffer) (xine_audio_port_t *);
@@ -218,7 +218,7 @@ struct xine_audio_port_s {
* Flush audio_out fifo.
*/
void (*flush) (xine_audio_port_t *);
-
+
/*
* Check if port is opened for this stream and get parameters.
* The stream can be anonymous.
@@ -236,14 +236,14 @@ struct audio_driver_class_s {
* open a new instance of this plugin class
*/
ao_driver_t* (*open_plugin) (audio_driver_class_t *, const void *data);
-
+
/*
* return short, human readable identifier for this plugin class
*/
char* (*get_identifier) (audio_driver_class_t *);
/*
- * return human readable (verbose = 1 line) description for
+ * return human readable (verbose = 1 line) description for
* this plugin class
*/
char* (*get_description) (audio_driver_class_t *);
@@ -255,11 +255,11 @@ struct audio_driver_class_s {
void (*dispose) (audio_driver_class_t *);
};
-/*
+/*
* this initiates the audio_out sync routines
* found in ./src/xine-engine/audio_out.c
*/
-xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, int grab_only) XINE_PROTECTED;
+xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, int grab_only) XINE_MALLOC XINE_PROTECTED;
/*
* audio output modes + capabilities
@@ -331,7 +331,7 @@ int _x_ao_channels2mode( int channels ) XINE_PROTECTED;
/* audio device control ops */
#define AO_CTRL_PLAY_PAUSE 0
#define AO_CTRL_PLAY_RESUME 1
-#define AO_CTRL_FLUSH_BUFFERS 2
+#define AO_CTRL_FLUSH_BUFFERS 2
/* above that value audio frames are discarded */
#define AO_MAX_GAP 15000
diff --git a/src/xine-engine/broadcaster.c b/src/xine-engine/broadcaster.c
index 1d2f01366..a554337a3 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,11 +27,15 @@
* - 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'
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -69,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;
@@ -83,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;
}
@@ -111,21 +115,21 @@ static int sock_check_opened(int socket) {
static int sock_data_write(xine_t *xine, int socket, char *buf, int len) {
ssize_t size;
int wlen = 0;
-
+
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;
@@ -138,20 +142,20 @@ static int XINE_FORMAT_PRINTF(3, 4)
sock_string_write(xine_t *xine, int socket, 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, char *buf, int len) {
@@ -161,9 +165,9 @@ static void broadcaster_data_write(broadcaster_t *this, char *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 ) {
@@ -180,15 +184,15 @@ static void XINE_FORMAT_PRINTF(2, 3)
broadcaster_string_write(broadcaster_t *this, 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));
}
@@ -205,40 +209,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;
}
@@ -249,7 +253,7 @@ static void *manager_loop (void *this_gen) {
*/
static void send_buf (broadcaster_t *this, char *from, buf_element_t *buf) {
int i;
-
+
/* ignore END buffers since they would stop the slavery */
if( buf->type == BUF_CONTROL_END )
return;
@@ -268,7 +272,7 @@ static void send_buf (broadcaster_t *this, 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 );
@@ -302,7 +306,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 )
{
@@ -320,31 +324,31 @@ broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port)
}
listen(msock,QLEN);
-
+
signal( SIGPIPE, SIG_IGN );
- this = xine_xmalloc(sizeof(broadcaster_t));
+ this = calloc(1, sizeof(broadcaster_t));
this->port = 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_NONE,
"broadcaster: can't create new thread (%s)\n", strerror(err));
_x_abort();
}
-
- return this;
+
+ return this;
}
void _x_close_broadcaster(broadcaster_t *this)
@@ -353,15 +357,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);
@@ -378,5 +382,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/broadcaster.h b/src/xine-engine/broadcaster.h
index 093fb4af0..0cd416cac 100644
--- a/src/xine-engine/broadcaster.h
+++ b/src/xine-engine/broadcaster.h
@@ -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
@@ -27,13 +27,9 @@
extern "C" {
#endif
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
typedef struct broadcaster_s broadcaster_t;
-broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port) XINE_PROTECTED;
+broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port) XINE_MALLOC XINE_PROTECTED;
void _x_close_broadcaster(broadcaster_t *this) XINE_PROTECTED;
int _x_get_broadcaster_port(broadcaster_t *this) XINE_PROTECTED;
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 93ad75ba0..77c0abc9d 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
@@ -64,7 +64,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);
@@ -104,7 +104,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;
}
@@ -151,7 +151,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++)
@@ -177,7 +177,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++)
@@ -444,7 +444,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);
}
@@ -465,7 +465,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);
}
@@ -486,7 +486,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);
}
@@ -500,7 +500,7 @@ fifo_buffer_t *_x_fifo_buffer_new (int num_buffers, uint32_t buf_size) {
int alignment = 2048;
unsigned char *multi_buffer = NULL;
- this = xine_xmalloc (sizeof (fifo_buffer_t));
+ this = calloc(1, sizeof(fifo_buffer_t));
this->first = NULL;
this->last = NULL;
@@ -551,7 +551,7 @@ fifo_buffer_t *_x_fifo_buffer_new (int num_buffers, uint32_t buf_size) {
for (i = 0; i<num_buffers; i++) {
buf_element_t *buf;
- buf = xine_xmalloc (sizeof (buf_element_t));
+ buf = calloc(1, sizeof(buf_element_t));
buf->mem = multi_buffer;
multi_buffer += buf_size;
diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h
index 35ab1e620..42302b30f 100644
--- a/src/xine-engine/buffer.h
+++ b/src/xine-engine/buffer.h
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2000-2004 the xine project
- *
+ * 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
@@ -35,10 +35,7 @@
extern "C" {
#endif
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
+#include <string.h>
#include <stdio.h>
#include <pthread.h>
#include <sys/types.h>
@@ -111,7 +108,7 @@ extern "C" {
#define BUF_VIDEO_WMV8 0x02140000
#define BUF_VIDEO_MSVC 0x02150000
#define BUF_VIDEO_DV 0x02160000
-#define BUF_VIDEO_REAL 0x02170000
+#define BUF_VIDEO_REAL 0x02170000
#define BUF_VIDEO_VP31 0x02180000
#define BUF_VIDEO_H263 0x02190000
#define BUF_VIDEO_3IVX 0x021A0000
@@ -190,6 +187,8 @@ extern "C" {
#define BUF_VIDEO_VP6F 0x02630000
#define BUF_VIDEO_THEORA_RAW 0x02640000
#define BUF_VIDEO_VC1 0x02650000
+#define BUF_VIDEO_VMNC 0x02660000
+#define BUF_VIDEO_SNOW 0x02670000
/* audio buffer types: (please keep in sync with buffer_types.c) */
@@ -210,7 +209,7 @@ extern "C" {
#define BUF_AUDIO_VOXWARE 0x030c0000
#define BUF_AUDIO_ACELPNET 0x030d0000
#define BUF_AUDIO_AAC 0x030e0000
-#define BUF_AUDIO_DNET 0x030f0000
+#define BUF_AUDIO_DNET 0x030f0000
#define BUF_AUDIO_VIVOG723 0x03100000
#define BUF_AUDIO_DK3ADPCM 0x03110000
#define BUF_AUDIO_DK4ADPCM 0x03120000
@@ -228,10 +227,10 @@ extern "C" {
#define BUF_AUDIO_GSM610 0x031E0000
#define BUF_AUDIO_EA_ADPCM 0x031F0000
#define BUF_AUDIO_WMAV2 0x03200000
-#define BUF_AUDIO_COOK 0x03210000
-#define BUF_AUDIO_ATRK 0x03220000
-#define BUF_AUDIO_14_4 0x03230000
-#define BUF_AUDIO_28_8 0x03240000
+#define BUF_AUDIO_COOK 0x03210000
+#define BUF_AUDIO_ATRK 0x03220000
+#define BUF_AUDIO_14_4 0x03230000
+#define BUF_AUDIO_28_8 0x03240000
#define BUF_AUDIO_SIPRO 0x03250000
#define BUF_AUDIO_WMAV3 0x03260000
#define BUF_AUDIO_INTERPLAY 0x03270000
@@ -257,6 +256,9 @@ extern "C" {
#define BUF_AUDIO_SMACKER 0x033B0000
#define BUF_AUDIO_FLVADPCM 0x033C0000
#define BUF_AUDIO_WAVPACK 0x033D0000
+#define BUF_AUDIO_MP3ADU 0x033E0000
+#define BUF_AUDIO_AMR_NB 0x033F0000
+#define BUF_AUDIO_AMR_WB 0x03400000
/* spu buffer types: */
@@ -269,6 +271,7 @@ extern "C" {
#define BUF_SPU_CVD 0x04050000
#define BUF_SPU_OGM 0x04060000
#define BUF_SPU_CMML 0x04070000
+#define BUF_SPU_HDMV 0x04080000
/* demuxer block types: */
@@ -281,7 +284,7 @@ typedef struct extra_info_s extra_info_t;
* to output frames (past decoder). new data must be added after the existing
* fields for backward compatibility.
*/
-
+
struct extra_info_s {
int input_normpos; /* remember where this buf came from in
@@ -290,10 +293,10 @@ struct extra_info_s {
int input_time; /* time offset in miliseconds from
* beginning of stream */
uint32_t frame_number; /* number of current frame if known */
-
+
int seek_count; /* internal engine use */
- int64_t vpts; /* set on output layers only */
-
+ int64_t vpts; /* set on output layers only */
+
int invalid; /* do not use this extra info to update anything */
int total_time; /* duration in miliseconds of the stream */
};
@@ -319,7 +322,7 @@ struct buf_element_s {
uint32_t decoder_flags; /* stuff like keyframe, is_header ... see below */
/* additional decoder flags and other dec-spec. stuff */
- uint32_t decoder_info[BUF_NUM_DEC_INFO];
+ uint32_t decoder_info[BUF_NUM_DEC_INFO];
/* pointers to dec-spec. stuff */
void *decoder_info_ptr[BUF_NUM_DEC_INFO];
@@ -366,12 +369,22 @@ struct buf_element_s {
* xine_waveformatex is actually optional since the most important
* information for audio init is available from decoder_info[].
* note: BUF_FLAG_HEADER must also be set. */
-#define BUF_FLAG_STDHEADER 0x0400
+#define BUF_FLAG_STDHEADER 0x0400
/* decoder_info[1] carries numerator for display aspect ratio
* decoder_info[2] carries denominator for display aspect ratio */
#define BUF_FLAG_ASPECT 0x0800
+/* represent the state of gapless_switch at the time buf was enqueued */
+#define BUF_FLAG_GAPLESS_SW 0x1000
+
+/* Amount of audio padding added by encoder (mp3, aac). These empty
+ * audio frames are causing a gap when switching between mp3 files.
+ * decoder_info[1] carries amount of audio frames padded at the
+ * beginning of the buffer
+ * decoder_info[2] carries amount of audio frames padded at the end of
+ * the buffer */
+#define BUF_FLAG_AUDIO_PADDING 0x2000
/* Special buffer types:
* Sometimes there is a need to relay special information from a demuxer
@@ -443,7 +456,7 @@ struct buf_element_s {
* four length bytes at the beginning
* decoder_info_ptr[2] = pointer to ImageDescription atom, starting with
* the codec fourcc
- * Some Quicktime decoders need information contained within the
+ * Some Quicktime decoders need information contained within the
* ImageDescription atom inside a Quicktime file's stsd atom. This
* special buffer carries the ImageDescription atom from the QT demuxer
* to an A/V decoder.
@@ -476,7 +489,7 @@ struct buf_element_s {
* In a BUF_SPECIAL_SPU_DVD_SUBTYPE:
* decoder_info[1] = BUF_SPECIAL_SPU_DVD_SUBTYPE
* decoder_info[2] = subtype
- * decoder_info[3] =
+ * decoder_info[3] =
* This buffer is pass SPU subtypes from DVDs
*/
#define BUF_SPECIAL_SPU_DVD_SUBTYPE 8
@@ -516,7 +529,7 @@ struct spu_dvb_descriptor_s
long comp_page_id;
long aux_page_id;
} ;
-
+
typedef struct palette_entry_s palette_entry_t;
struct palette_entry_s
{
@@ -605,8 +618,8 @@ struct fifo_buffer_s
* allocate num_buffers of buf_size bytes each
*/
-fifo_buffer_t *_x_fifo_buffer_new (int num_buffers, uint32_t buf_size) XINE_PROTECTED;
-fifo_buffer_t *_x_dummy_fifo_buffer_new (int num_buffers, uint32_t buf_size) XINE_PROTECTED;
+fifo_buffer_t *_x_fifo_buffer_new (int num_buffers, uint32_t buf_size) XINE_MALLOC XINE_PROTECTED;
+fifo_buffer_t *_x_dummy_fifo_buffer_new (int num_buffers, uint32_t buf_size) XINE_MALLOC XINE_PROTECTED;
/* return BUF_VIDEO_xxx given the fourcc
@@ -616,16 +629,16 @@ fifo_buffer_t *_x_dummy_fifo_buffer_new (int num_buffers, uint32_t buf_size) XIN
uint32_t _x_fourcc_to_buf_video( uint32_t fourcc_int ) XINE_PROTECTED;
/* return codec name given BUF_VIDEO_xxx */
-char * _x_buf_video_name( uint32_t buf_type ) XINE_PROTECTED;
+const char * _x_buf_video_name( uint32_t buf_type ) XINE_PROTECTED;
/* return BUF_AUDIO_xxx given the formattag */
uint32_t _x_formattag_to_buf_audio( uint32_t formattag ) XINE_PROTECTED;
/* return codec name given BUF_AUDIO_xxx */
-char * _x_buf_audio_name( uint32_t buf_type ) XINE_PROTECTED;
+const char * _x_buf_audio_name( uint32_t buf_type ) XINE_PROTECTED;
-#ifndef ATTRIBUTE_PACKED
+#ifndef SUPPORT_ATTRIBUTE_PACKED
/* no attribute packed? let's try with pragma pack as a last resort */
#pragma pack(2)
#endif
@@ -634,7 +647,7 @@ char * _x_buf_audio_name( uint32_t buf_type ) XINE_PROTECTED;
* - will always use machine endian format, so demuxers reading
* stuff from win32 formats must use the function below.
*/
-typedef struct __attribute__((__packed__)) {
+typedef struct XINE_PACKED {
int32_t biSize;
int32_t biWidth;
int32_t biHeight;
@@ -648,10 +661,10 @@ typedef struct __attribute__((__packed__)) {
int32_t biClrImportant;
} xine_bmiheader;
-/* this is xine version of WAVEFORMATEX
+/* this is xine version of WAVEFORMATEX
* (the same comments from xine_bmiheader)
*/
-typedef struct __attribute__((__packed__)) {
+typedef struct XINE_PACKED {
int16_t wFormatTag;
int16_t nChannels;
int32_t nSamplesPerSec;
@@ -660,7 +673,7 @@ typedef struct __attribute__((__packed__)) {
int16_t wBitsPerSample;
int16_t cbSize;
} xine_waveformatex;
-#ifndef ATTRIBUTE_PACKED
+#ifndef SUPPORT_ATTRIBUTE_PACKED
#pragma pack()
#endif
@@ -670,6 +683,10 @@ void _x_bmiheader_le2me( xine_bmiheader *bih ) XINE_PROTECTED;
/* convert xine_waveformatex struct from little endian */
void _x_waveformatex_le2me( xine_waveformatex *wavex ) XINE_PROTECTED;
+static __inline int _x_is_fourcc(void *ptr, void *tag) {
+ return memcmp(ptr, tag, 4) == 0;
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/src/xine-engine/buffer_types.c b/src/xine-engine/buffer_types.c
index ee50e5391..51e688f7e 100644
--- a/src/xine-engine/buffer_types.c
+++ b/src/xine-engine/buffer_types.c
@@ -1,18 +1,18 @@
/*
- * Copyright (C) 2000-2005 the xine project
- *
+ * 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
*/
@@ -270,7 +270,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;
@@ -659,6 +659,8 @@ static const video_db_t video_db[] = {
ME_FOURCC('a','v','c','1'),
ME_FOURCC('h','2','6','4'),
ME_FOURCC('H','2','6','4'),
+ ME_FOURCC('x','2','6','4'),
+ ME_FOURCC('X','2','6','4'),
0
},
BUF_VIDEO_H264,
@@ -771,6 +773,22 @@ static const video_db_t video_db[] = {
BUF_VIDEO_KMVC,
"Karl Morton's Video Codec"
},
+{
+ {
+ ME_FOURCC('V','M','n','c'),
+ 0
+ },
+ BUF_VIDEO_VMNC,
+ "VMware Screen Codec"
+},
+{
+ {
+ ME_FOURCC('S','N','O','W'),
+ 0
+ },
+ BUF_VIDEO_SNOW,
+ "Snow"
+},
{ { 0 }, 0, "last entry" }
};
@@ -798,6 +816,14 @@ static const audio_db_t audio_db[] = {
},
{
{
+ ME_FOURCC('a', 'd', 'u', 0x55),
+ 0
+ },
+ BUF_AUDIO_MP3ADU,
+ "MPEG layer-3 adu"
+},
+{
+ {
ME_FOURCC('t','w','o','s'),
ME_FOURCC('i','n','2','4'),
0
@@ -859,7 +885,7 @@ static const audio_db_t audio_db[] = {
},
{
{
- 0x02,
+ 0x02,
ME_FOURCC('m', 's', 0, 0x02),
0
},
@@ -883,7 +909,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,
@@ -992,7 +1018,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,
@@ -1124,11 +1150,32 @@ static const audio_db_t audio_db[] = {
},
{
{
- 0
+ ME_FOURCC('W', 'V', 'P', 'K'),
},
BUF_AUDIO_WAVPACK,
"Wavpack"
},
+{
+ {
+ ME_FOURCC('s', 'a', 'm', 'r'),
+ },
+ BUF_AUDIO_AMR_NB,
+ "AMR narrow band"
+},
+{
+ {
+ ME_FOURCC('s', 'a', 'w', 'b'),
+ },
+ BUF_AUDIO_AMR_WB,
+ "AMR wide band"
+},
+{
+ {
+ ME_FOURCC('T', 'T', 'A', '1'),
+ },
+ BUF_AUDIO_TTA,
+ "True Audio Lossless"
+},
{ { 0 }, 0, "last entry" }
};
@@ -1140,7 +1187,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] ) {
@@ -1153,11 +1200,11 @@ static uint32_t cached_buf_type=0;
return 0;
}
-char * _x_buf_video_name( uint32_t buf_type ) {
+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;
@@ -1174,7 +1221,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] ) {
@@ -1187,11 +1234,11 @@ static uint32_t cached_buf_type=0;
return 0;
}
-char * _x_buf_audio_name( uint32_t buf_type ) {
+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;
@@ -1205,7 +1252,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);
@@ -1219,7 +1266,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 2dc89f0af..8b274a801 100644
--- a/src/xine-engine/configfile.c
+++ b/src/xine-engine/configfile.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2004 the xine project
+ * Copyright (C) 2000-2008 the xine project
*
* This file is part of xine, a free video player.
*
@@ -225,7 +225,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;
@@ -234,7 +234,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;
@@ -259,10 +259,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) {
@@ -270,7 +270,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;
@@ -302,14 +302,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;
@@ -319,18 +319,18 @@ static void config_insert(config_values_t *this, cfg_entry_t *new_entry) {
this->first = new_entry;
}
-static cfg_entry_t *config_add (config_values_t *this, const char *key, int exp_level) {
+static cfg_entry_t *XINE_MALLOC config_add (config_values_t *this, const char *key, int exp_level) {
cfg_entry_t *entry;
- entry = (cfg_entry_t *) xine_xmalloc (sizeof (cfg_entry_t));
+ entry = calloc (1, sizeof (cfg_entry_t));
entry->config = this;
entry->key = strdup(key);
entry->type = XINE_CONFIG_TYPE_UNKNOWN;
entry->unknown_value = NULL;
entry->str_value = NULL;
entry->exp_level = exp_level;
-
+
config_insert(this, entry);
lprintf ("add entry key=%s\n", key);
@@ -356,22 +356,22 @@ static const char *config_xlate_internal (const char *key, const xine_config_ent
return NULL;
}
-static const char *config_translate_key (const char *key) {
+static const char *config_translate_key (const char *key, char **tmp) {
/* Returns translated key or, if no translation found, NULL.
* Translated key may be in a static buffer allocated within this function.
* NOT re-entrant; assumes that config_lock is held.
*/
unsigned trans;
- static char *newkey = NULL;
+ const char *newkey = NULL;
/* first, special-case the decoder entries (so that new ones can be added
* without requiring modification of the translation table)
*/
+ *tmp = NULL;
if (!strncmp (key, "decoder.", 8) &&
!strcmp (key + (trans = strlen (key)) - 9, "_priority")) {
- newkey = realloc (newkey, trans + 27 - 17); /* diff. in string lengths */
- sprintf (newkey, "engine.decoder_priorities.%.*s", trans - 17, key + 8);
- return newkey;
+ asprintf (tmp, "engine.decoder_priorities.%.*s", trans - 17, key + 8);
+ return *tmp;
}
/* search the translation table... */
@@ -386,6 +386,7 @@ static void config_lookup_entry_int (config_values_t *this, const char *key,
cfg_entry_t **entry, cfg_entry_t **prev) {
int trans;
+ char *tmp = NULL;
/* try twice at most (second time with translation from old key name) */
for (trans = 2; trans; --trans) {
@@ -396,15 +397,19 @@ static void config_lookup_entry_int (config_values_t *this, const char *key,
*prev = *entry;
*entry = (*entry)->next;
}
-
- if (*entry)
+
+ if (*entry) {
+ free(tmp);
return;
+ }
/* we did not find a match, maybe this is an old config entry name
* trying to translate */
- key = config_translate_key(key);
- if (!key)
+ key = config_translate_key(key, &tmp);
+ if (!key) {
+ free(tmp);
return;
+ }
}
}
@@ -415,11 +420,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;
}
@@ -520,7 +525,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
@@ -748,22 +753,22 @@ static int config_register_enum (config_values_t *this,
entry->type = XINE_CONFIG_TYPE_ENUM;
if (entry->unknown_value)
- entry->num_value = config_parse_enum (entry->unknown_value, values);
+ 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;
/* allocate and copy the enum values */
- value_src = values;
+ value_src = (const char **)values;
value_count = 0;
while (*value_src) {
value_src++;
value_count++;
}
entry->enum_values = malloc (sizeof(char*) * (value_count + 1));
- value_src = values;
+ value_src = (const char **)values;
value_dest = entry->enum_values;
while (*value_src) {
*value_dest = strdup(*value_src);
@@ -801,7 +806,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);
@@ -830,13 +835,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);
}
@@ -858,11 +863,11 @@ 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) {
- config_update_num(this, key, config_parse_enum(value, entry->enum_values));
+ config_update_num(this, key, config_parse_enum(value, (const char **)entry->enum_values));
return;
}
@@ -882,7 +887,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.
*/
@@ -924,7 +929,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);
@@ -944,15 +949,17 @@ void xine_config_load (xine_t *xine, const char *filename) {
if (!(entry = config_lookup_entry(this, line))) {
const char *key = line;
+ char *tmp = NULL;
pthread_mutex_lock(&this->config_lock);
if (this->current_version < CONFIG_FILE_VERSION) {
/* old config file -> let's see if we have to rename this one */
- key = config_translate_key(key);
+ key = config_translate_key(key, &tmp);
if (!key)
key = line; /* no translation? fall back on untranslated key */
}
entry = config_add (this, key, 50);
entry->unknown_value = strdup(value);
+ free(tmp);
pthread_mutex_unlock(&this->config_lock);
} else {
switch (entry->type) {
@@ -995,32 +1002,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 *) xine_xmalloc(config_stat.st_size + 1);
+
+ 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)
@@ -1033,17 +1040,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;
@@ -1134,7 +1141,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);
@@ -1145,7 +1152,7 @@ void xine_config_save (xine_t *xine, const char *filename) {
backup = 0;
}
}
-
+
if (backup)
unlink(temp);
}
@@ -1204,7 +1211,7 @@ config_values_t *_x_config_init (void) {
config_values_t *this;
pthread_mutexattr_t attr;
- if (!(this = xine_xmalloc(sizeof(config_values_t)))) {
+ if (!(this = calloc(1, sizeof(config_values_t)))) {
printf ("configfile: could not allocate config object\n");
_x_abort();
@@ -1277,13 +1284,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:
@@ -1291,13 +1298,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/configfile.h b/src/xine-engine/configfile.h
index e21b08db0..4622f87fe 100644
--- a/src/xine-engine/configfile.h
+++ b/src/xine-engine/configfile.h
@@ -38,11 +38,11 @@ extern "C" {
#define CONFIG_FILE_VERSION 2
/*
- * config entries above this experience
+ * config entries above this experience
* level must never be changed from MRL
*/
#define XINE_CONFIG_SECURITY 30
-
+
typedef struct cfg_entry_s cfg_entry_t;
typedef struct config_values_s config_values_t;
@@ -190,7 +190,7 @@ struct config_values_s {
* mutex for modification to the config
*/
pthread_mutex_t config_lock;
-
+
/*
* current config file's version number
*/
@@ -200,7 +200,7 @@ struct config_values_s {
/*
* allocate and init a new xine config object
*/
-config_values_t *_x_config_init (void) XINE_PROTECTED;
+config_values_t *_x_config_init (void) XINE_MALLOC XINE_PROTECTED;
/*
* interpret stream_setup part of mrls for config value changes
diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c
index f33397256..bbc130988 100644
--- a/src/xine-engine/demux.c
+++ b/src/xine-engine/demux.c
@@ -21,6 +21,9 @@
* hide some xine engine details from demuxers and reduce code duplication
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <stdio.h>
#include <string.h>
@@ -47,12 +50,7 @@
#include <winsock.h>
#endif
-#ifdef MIN
-#undef MIN
-#endif
-#define MIN(a,b) ( (a) < (b) ) ? (a) : (b)
-
-/*
+/*
* 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.
@@ -64,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 */
@@ -79,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);
@@ -104,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) {
@@ -117,16 +115,44 @@ 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);
}
+static struct timespec _x_compute_interval(unsigned int millisecs) {
+ struct timespec ts;
+#ifdef WIN32
+ FILETIME ft;
+ ULARGE_INTEGER ui;
+
+ GetSystemTimeAsFileTime(&ft);
+ ui.u.LowPart = ft.dwLowDateTime;
+ ui.u.HighPart = ft.dwHighDateTime;
+ ui.QuadPart += millisecs * 10000;
+ ts.tv_sec = ui.QuadPart / 10000000;
+ ts.tv_sec = (ui.QuadPart % 10000000)*100;
+#elif _POSIX_TIMERS > 0
+ clock_gettime(CLOCK_REALTIME, &ts);
+ uint64_t ttimer = (uint64_t)ts.tv_sec*1000 + ts.tv_nsec/1000000 + millisecs;
+ ts.tv_sec = ttimer/1000;
+ ts.tv_nsec = (ttimer%1000)*1000000;
+#else
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ uint64_t ttimer = (uint64_t)tv.tv_sec*1000 + tv.tv_usec/1000 + millisecs;
+ ts.tv_sec = ttimer/1000;
+ ts.tv_nsec = (ttimer%1000)*1000000;
+#endif
+ return ts;
+}
+
+
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;
@@ -140,7 +166,30 @@ 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;
+ * return 1 if the stream is stopped
+ * (better fix wanted!)
+ */
+static int demux_unstick_ao_loop (xine_stream_t *stream)
+{
+/* if (!stream->audio_thread_created)
+ return 0;
+*/
+ int status = xine_get_status (stream);
+ if (status != XINE_STATUS_QUIT && status != XINE_STATUS_STOP && stream->demux_plugin->get_status(stream->demux_plugin) != DEMUX_FINISHED)
+ return 0;
+#if 0
+ /* right, stream is stopped... */
+ audio_buffer_t *buf = stream->audio_out->get_buffer (stream->audio_out);
+ buf->num_frames = 0;
+ buf->stream = NULL;
+ stream->audio_out->put_buffer (stream->audio_out, buf, stream);
+#endif
+ lprintf("stuck\n");
+ return 1;
}
/* sync with decoder fifos, making sure everything gets processed */
@@ -152,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);
@@ -170,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);
@@ -179,26 +228,33 @@ 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)) {
- struct timeval tv;
- struct timespec ts;
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);
+ stream->header_count_audio, header_count_audio);
+
+ struct timespec ts = _x_compute_interval(1000);
+ int ret_wait;
- gettimeofday(&tv, NULL);
- ts.tv_sec = tv.tv_sec + 1;
- ts.tv_nsec = tv.tv_usec * 1000;
/* use timedwait to workaround buggy pthread broadcast implementations */
- pthread_cond_timedwait (&stream->counter_changed, &stream->counter_lock, &ts);
+ 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_MSG,_("Stuck in _x_demux_control_headers_done(). Taking the emergency exit\n"));
+ stream->emergency_brake = 1;
+ break;
+ }
}
stream->demux_action_pending = 0;
-
+ pthread_cond_signal(&stream->demux_resume);
+
lprintf ("headers processed.\n");
pthread_mutex_unlock (&stream->counter_lock);
@@ -207,25 +263,28 @@ void _x_demux_control_headers_done (xine_stream_t *stream) {
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;
+ 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_START;
+ 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;
@@ -237,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) {
@@ -271,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 {
@@ -284,12 +343,14 @@ static void *demux_loop (void *stream_gen) {
/* someone may want to interrupt us */
if( stream->demux_action_pending ) {
- pthread_mutex_unlock( &stream->demux_lock );
+ struct timeval tv;
+ struct timespec ts;
- lprintf ("sched_yield\n");
+ gettimeofday(&tv, NULL);
+ ts.tv_sec = tv.tv_sec;
+ ts.tv_nsec = (tv.tv_usec + 100000) * 1000;
- sched_yield();
- pthread_mutex_lock( &stream->demux_lock );
+ pthread_cond_timedwait (&stream->demux_resume, &stream->demux_lock, &ts);
}
}
@@ -337,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");
@@ -345,13 +406,24 @@ static void *demux_loop (void *stream_gen) {
pthread_mutex_unlock( &stream->demux_lock );
pthread_mutex_lock (&stream->counter_lock);
- while ((stream->finished_count_audio < finished_count_audio) ||
+ struct timespec ts;
+ unsigned int max_iterations = 0;
+ int ret_wait;
+ while ((stream->finished_count_audio < finished_count_audio) ||
(stream->finished_count_video < finished_count_video)) {
lprintf ("waiting for finisheds.\n");
- pthread_cond_wait (&stream->counter_changed, &stream->counter_lock);
+ ts = _x_compute_interval(1000);
+ 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_MSG,_("Stuck in demux_loop(). Taking the emergency exit\n"));
+ stream->emergency_brake = 1;
+ break;
+ }
}
pthread_mutex_unlock (&stream->counter_lock);
-
+
_x_handle_stream_end(stream, non_user);
return NULL;
}
@@ -359,13 +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) {
@@ -381,21 +454,22 @@ 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;
stream->demux_action_pending = 0;
+ pthread_cond_signal(&stream->demux_resume);
/* At that point, the demuxer has sent the last audio/video buffer,
* so it's a safe place to flush the engine.
@@ -404,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
*/
@@ -435,7 +509,7 @@ int _x_demux_read_header( input_plugin_t *input, unsigned char *buffer, off_t si
read_size = input->read(input, buffer, size);
input->seek(input, 0, SEEK_SET);
} else if (input->get_capabilities(input) & INPUT_CAP_PREVIEW) {
- buf = xine_xmalloc(MAX_PREVIEW_SIZE);
+ buf = malloc(MAX_PREVIEW_SIZE);
read_size = input->get_optional_data(input, buf, INPUT_OPTIONAL_DATA_PREVIEW);
read_size = MIN (read_size, size);
memcpy(buffer, buf, read_size);
@@ -547,7 +621,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,
@@ -595,10 +669,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;
@@ -620,7 +694,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;
@@ -636,7 +710,7 @@ int _x_demux_read_send_data(fifo_buffer_t *fifo, input_plugin_t *input,
fifo->put (fifo, buf);
}
-
+
return 0;
}
@@ -652,7 +726,7 @@ void _x_demux_send_mrl_reference (xine_stream_t *stream, int alternative,
xine_mrl_reference_data_ext_t *e;
xine_mrl_reference_data_t *b;
} data;
- int mrl_len = strlen (mrl);
+ const size_t mrl_len = strlen (mrl);
if (!title)
title = "";
@@ -663,7 +737,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 f79187682..a51813adc 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;
@@ -244,7 +244,7 @@ void xine_event_create_listener_thread (xine_event_queue_t *queue,
if ((err = pthread_create (queue->listener_thread,
NULL, listener_loop, queue)) != 0) {
- xprintf (queue->stream->xine, XINE_VERBOSITY_DEBUG,
+ xprintf (queue->stream->xine, XINE_VERBOSITY_NONE,
"events: can't create new thread (%s)\n", strerror(err));
_x_abort();
}
diff --git a/src/xine-engine/info_helper.c b/src/xine-engine/info_helper.c
index 1ac4ed982..e45336d98 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;
}
@@ -131,13 +131,13 @@ uint32_t _x_stream_info_get_public(xine_stream_t *stream, int info) {
* at the end of the string
*/
static void meta_info_chomp(char *str) {
- int i, len;
+ ssize_t i, len;
len = strlen(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]);
@@ -251,7 +251,15 @@ static void meta_info_set_unlocked_encoding(xine_stream_t *stream, int info, con
size_t inbytesleft, outbytesleft;
inbuf = (ICONV_CONST char *)value;
- inbytesleft = strlen(value);
+ if (!strncmp (enc, "UTF-16", 6) || !strncmp (enc, "UCS-2", 5))
+ {
+ /* strlen() won't work with UTF-16* or UCS-2* */
+ inbytesleft = 0;
+ while (value[inbytesleft] || value[inbytesleft + 1])
+ inbytesleft += 2;
+ } /* ... do we need to handle UCS-4? Probably not. */
+ else
+ inbytesleft = strlen(value);
outbytesleft = 4 * inbytesleft; /* estimative (max) */
outbuf = utf8_value = malloc(outbytesleft+1);
@@ -267,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);
}
@@ -340,11 +348,10 @@ void _x_meta_info_set_utf8(xine_stream_t *stream, int info, const char *str) {
void _x_meta_info_n_set(xine_stream_t *stream, int info, const char *buf, int len) {
pthread_mutex_lock(&stream->meta_mutex);
if(meta_valid(info) && len) {
- char *str = xine_xmalloc(len + 1);
-
- snprintf(str, len + 1 , "%s", buf);
- meta_info_set_unlocked(stream, info, (const char *) &str[0]);
- free(str);
+ char *str = strndup(buf, len);
+
+ meta_info_set_unlocked(stream, info, str);
+ free(str);
}
pthread_mutex_unlock(&stream->meta_mutex);
}
@@ -359,8 +366,8 @@ void _x_meta_info_set_multi(xine_stream_t *stream, int info, ...) {
va_list ap;
char *args[1025];
char *buf;
- int n, len;
-
+ size_t n, len;
+
len = n = 0;
va_start(ap, info);
@@ -370,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 *) xine_xmalloc(len + 1);
-
+
+ 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);
}
@@ -405,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;
}
@@ -423,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/info_helper.h b/src/xine-engine/info_helper.h
index d4123ba2b..666b94f08 100644
--- a/src/xine-engine/info_helper.h
+++ b/src/xine-engine/info_helper.h
@@ -20,7 +20,7 @@
* stream metainfo helper functions
* hide some xine engine details from demuxers and reduce code duplication
*
- * $id$
+ * $id$
*/
#ifndef INFO_HELPER_H
diff --git a/src/xine-engine/input_cache.c b/src/xine-engine/input_cache.c
index 30b1ba4aa..e761fed38 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.
*/
@@ -58,7 +58,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, char *buf, off_t len) {
@@ -128,13 +128,13 @@ static off_t cache_plugin_read(input_plugin_t *this_gen, char *buf, off_t len) {
/* 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;
@@ -148,7 +148,7 @@ static off_t cache_plugin_read(input_plugin_t *this_gen, char *buf, off_t len) {
/* 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
@@ -156,7 +156,7 @@ static off_t cache_plugin_read(input_plugin_t *this_gen, char *buf, off_t len) {
read_len = main_read;
}
}
-
+
return read_len;
}
@@ -190,7 +190,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;
@@ -226,11 +226,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);
@@ -238,16 +238,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++;
@@ -262,7 +262,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++;
@@ -275,7 +275,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) )
@@ -290,7 +290,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;
@@ -314,7 +314,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;
@@ -322,8 +322,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;
@@ -341,8 +341,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, int readahead_size) {
cache_input_plugin_t *this;
@@ -356,10 +356,10 @@ input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream, int readahe
lprintf("mrl: %s\n", main_plugin->get_mrl(main_plugin));
- this = (cache_input_plugin_t *)xine_xmalloc(sizeof(cache_input_plugin_t));
+ this = calloc(1, sizeof(cache_input_plugin_t));
if (!this)
return NULL;
-
+
this->main_input_plugin = main_plugin;
this->stream = stream;
@@ -386,7 +386,7 @@ input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream, int readahe
this->buf_size = DEFAULT_BUFFER_SIZE;
}
- this->buf = (char *)xine_xmalloc(this->buf_size);
+ this->buf = calloc(1, this->buf_size);
if (!this->buf) {
free (this);
return NULL;
diff --git a/src/xine-engine/input_rip.c b/src/xine-engine/input_rip.c
index 0c185aa1b..faeaae62d 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
*/
@@ -95,7 +95,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, char *buf, off_t len) {
@@ -123,7 +123,7 @@ static off_t rip_plugin_read(input_plugin_t *this_gen, char *buf, 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 */
@@ -149,7 +149,7 @@ static off_t rip_plugin_read(input_plugin_t *this_gen, char *buf, 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;
}
@@ -163,10 +163,10 @@ static off_t rip_plugin_read(input_plugin_t *this_gen, char *buf, 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;
@@ -191,7 +191,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;
@@ -199,11 +199,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) {
@@ -230,7 +230,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 */
@@ -249,7 +249,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);
@@ -286,17 +286,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;
@@ -323,11 +323,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) {
@@ -339,7 +339,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;
@@ -376,7 +376,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;
}
@@ -393,7 +393,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));
}
}
@@ -425,13 +425,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);
@@ -451,13 +451,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);
}
@@ -484,7 +484,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;
@@ -494,11 +494,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;
@@ -517,10 +517,9 @@ static void rip_plugin_dispose(input_plugin_t *this_gen) {
* returns non-zero, if there was enough space
*/
static int dir_file_concat(char *target, size_t maxlen, const char *dir, const char *name) {
- size_t len_dir, len_name, pos_name = 0;
-
- len_name = strlen(name);
- len_dir = strlen(dir);
+ size_t len_name = strlen(name);
+ size_t len_dir = strlen(dir);
+ size_t pos_name = 0;
/* remove slashes */
if (dir[len_dir - 1] == '/') len_dir--;
@@ -541,8 +540,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) {
@@ -572,7 +571,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);
@@ -585,7 +584,7 @@ input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *f
return NULL;
}
- this = (rip_input_plugin_t *)xine_xmalloc(sizeof(rip_input_plugin_t));
+ this = calloc(1, sizeof(rip_input_plugin_t));
this->main_input_plugin = main_plugin;
this->stream = stream;
this->curpos = 0;
@@ -593,7 +592,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);
@@ -622,7 +621,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;
@@ -640,7 +639,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);
@@ -652,7 +651,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 c3654c762..b06c47709 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;
@@ -346,14 +346,14 @@ static off_t xio_rw_abort(xine_stream_t *stream, int fd, int cmd, char *buf, off
} 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);
@@ -403,7 +403,7 @@ static off_t xio_rw_abort(xine_stream_t *stream, int fd, int cmd, char *buf, off
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 71cb19d3b..9eb33f8ed 100644
--- a/src/xine-engine/load_plugins.c
+++ b/src/xine-engine/load_plugins.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2006 the xine project
+ * Copyright (C) 2000-2008 the xine project
*
* This file is part of xine, a free video player.
*
@@ -101,7 +101,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) {
@@ -112,7 +112,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) )
@@ -157,9 +157,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;
@@ -258,14 +258,14 @@ static plugin_info_t *_get_cached_info (xine_t *this,
node->file->filesize == filesize &&
node->file->filemtime == filemtime &&
!strcmp( node->file->filename, filename )) {
-
+
return node->info;
}
-
+
/* skip previously returned items */
if( node->info == previous_info )
previous_info = NULL;
-
+
}
return NULL;
}
@@ -313,20 +313,19 @@ static void _insert_node (xine_t *this,
const input_info_t *input_old;
uint32_t *types;
char key[80];
- char desc[100];
int i;
_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;
}
- entry = xine_xmalloc(sizeof(plugin_node_t));
- entry->info = xine_xmalloc(sizeof(plugin_info_t));
+ entry = calloc(1, sizeof(plugin_node_t));
+ entry->info = calloc(1, sizeof(plugin_info_t));
*(entry->info) = *info;
entry->info->id = strdup(info->id);
entry->info->init = info->init;
@@ -339,7 +338,7 @@ static void _insert_node (xine_t *this,
case PLUGIN_VIDEO_OUT:
vo_old = info->special_info;
- vo_new = xine_xmalloc(sizeof(vo_info_t));
+ vo_new = calloc(1, sizeof(vo_info_t));
entry->priority = vo_new->priority = vo_old->priority;
vo_new->visual_type = vo_old->visual_type;
entry->info->special_info = vo_new;
@@ -347,7 +346,7 @@ static void _insert_node (xine_t *this,
case PLUGIN_AUDIO_OUT:
ao_old = info->special_info;
- ao_new = xine_xmalloc(sizeof(ao_info_t));
+ ao_new = calloc(1, sizeof(ao_info_t));
entry->priority = ao_new->priority = ao_old->priority;
entry->info->special_info = ao_new;
break;
@@ -356,7 +355,7 @@ static void _insert_node (xine_t *this,
case PLUGIN_VIDEO_DECODER:
case PLUGIN_SPU_DECODER:
decoder_old = info->special_info;
- decoder_new = xine_xmalloc(sizeof(decoder_info_t));
+ decoder_new = calloc(1, sizeof(decoder_info_t));
if (decoder_old == NULL) {
if (file)
xprintf (this, XINE_VERBOSITY_DEBUG,
@@ -368,22 +367,21 @@ static void _insert_node (xine_t *this,
info->id);
_x_abort();
}
- for (i=0; decoder_old->supported_types[i] != 0; ++i);
- types = xine_xmalloc((i+1)*sizeof(uint32_t));
- for (i=0; decoder_old->supported_types[i] != 0; ++i){
- types[i] = decoder_old->supported_types[i];
+ {
+ size_t supported_types_size;
+ for (supported_types_size=0; decoder_old->supported_types[supported_types_size] != 0; ++supported_types_size);
+ types = calloc((supported_types_size+1), sizeof(uint32_t));
+ memcpy(types, decoder_old->supported_types, supported_types_size*sizeof(uint32_t));
+ decoder_new->supported_types = types;
}
- decoder_new->supported_types = types;
entry->priority = decoder_new->priority = decoder_old->priority;
-
+
snprintf(key, sizeof(key), "engine.decoder_priorities.%s", info->id);
- snprintf(desc, sizeof(desc), _("priority for %s decoder"), info->id);
/* write the description on the heap because the config system
* does not strdup() it, so we have to provide a different pointer
* for each decoder */
for (i = 0; catalog->prio_desc[i]; i++);
- catalog->prio_desc[i] = malloc(strlen(desc) + 1);
- strcpy(catalog->prio_desc[i], desc);
+ asprintf(&catalog->prio_desc[i], _("priority for %s decoder"), info->id);
this->config->register_num (this->config,
key,
0,
@@ -399,23 +397,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 = xine_xmalloc(sizeof(post_info_t));
+ 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 = xine_xmalloc(sizeof(demuxer_info_t));
-
+ 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);
@@ -426,13 +424,13 @@ static void _insert_node (xine_t *this,
case PLUGIN_INPUT:
input_old = info->special_info;
- input_new = xine_xmalloc(sizeof(input_info_t));
-
+ 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);
@@ -463,12 +461,12 @@ static int _plugin_node_comparator(void *a, void *b) {
}
}
-static plugin_catalog_t *_new_catalog(void){
+static plugin_catalog_t *XINE_MALLOC _new_catalog(void){
plugin_catalog_t *catalog;
int i;
- catalog = xine_xmalloc(sizeof(plugin_catalog_t));
+ catalog = calloc(1, sizeof(plugin_catalog_t));
for (i = 0; i < PLUGIN_TYPE_MAX; i++) {
catalog->plugin_lists[i] = xine_sarray_new(0, _plugin_node_comparator);
@@ -487,13 +485,13 @@ static void _register_plugins_internal(xine_t *this, plugin_file_t *file, plugin
while ( info && info->type != PLUGIN_NONE ) {
- if (file)
+ if (file && file->filename)
xine_log (this, XINE_LOG_PLUGIN,
_("load_plugins: plugin %s found\n"), file->filename);
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)) {
@@ -527,7 +525,7 @@ static void _register_plugins_internal(xine_t *this, plugin_file_t *file, plugin
}
this->plugin_catalog->plugin_count++;
}
-
+
/* get next info */
if( file && !file->lib_handle ) {
lprintf("get cached info\n");
@@ -556,25 +554,20 @@ static void collect_plugins(xine_t *this, char *path){
dir = opendir(path);
if (dir) {
struct dirent *pEntry;
- size_t path_len, str_size;
- char *str = NULL;
- path_len = strlen(path);
- str_size = path_len * 2 + 2; /* +2 for '/' and '\0' */
- str = malloc(str_size);
- xine_fast_memcpy(str, path, path_len);
- str[path_len] = '/';
- str[path_len + 1] = '\0';
+ size_t path_len = strlen(path);
+ size_t str_size = path_len * 2 + 2; /* +2 for '/' and '\0' */
+ char *str = malloc(str_size);
+ sprintf(str, "%s/", path);
while ((pEntry = readdir (dir)) != NULL) {
- size_t new_str_size, d_len;
void *lib = NULL;
plugin_info_t *info = NULL;
-
+
struct stat statbuffer;
- d_len = strlen(pEntry->d_name);
- new_str_size = path_len + d_len + 2;
+ size_t d_len = strlen(pEntry->d_name);
+ size_t new_str_size = path_len + d_len + 2;
if (str_size < new_str_size) {
str_size = new_str_size + new_str_size / 2;
str = realloc(str, str_size);
@@ -599,7 +592,7 @@ static void collect_plugins(xine_t *this, char *path){
#if defined(__hpux)
if(!strstr(str, ".sl")
#elif defined(__CYGWIN__) || defined(WIN32)
- if(!strstr(str, ".dll")
+ if(!strstr(str, ".dll") || strstr(str, ".dll.a")
#else
if(!strstr(str, ".so")
#endif
@@ -623,7 +616,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 {
@@ -666,14 +659,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? */
@@ -682,11 +675,11 @@ static inline int _plugin_info_equal(const plugin_info_t *a,
((vo_info_t*)b->special_info)->visual_type);
}
break;
-
+
default:
break;
}
-
+
return 1;
}
@@ -729,7 +722,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);
@@ -797,9 +790,9 @@ 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);
-
+
if( (node->info->type & PLUGIN_MUST_PRELOAD) && !node->plugin_class ) {
-
+
lprintf("preload plugin %s from %s\n", node->info->id, node->file->filename);
if (! _load_plugin_class (this, node, NULL)) {
@@ -838,7 +831,7 @@ static void save_plugin_list(FILE *fp, xine_sarray_t *list) {
const vo_info_t *vo_info;
const ao_info_t *ao_info;
const post_info_t *post_info;
-
+
int i;
int list_id = 0;
int list_size;
@@ -855,20 +848,20 @@ static void save_plugin_list(FILE *fp, xine_sarray_t *list) {
fprintf(fp, "api=%d\n", node->info->API );
fprintf(fp, "id=%s\n", node->info->id );
fprintf(fp, "version=%lu\n", (unsigned long) node->info->version );
-
+
switch (node->info->type & PLUGIN_TYPE_MASK){
-
+
case PLUGIN_VIDEO_OUT:
vo_info = node->info->special_info;
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:
@@ -885,7 +878,7 @@ static void save_plugin_list(FILE *fp, xine_sarray_t *list) {
demuxer_info = node->info->special_info;
fprintf(fp, "demuxer_priority=%d\n", demuxer_info->priority);
break;
-
+
case PLUGIN_INPUT:
input_info = node->info->special_info;
fprintf(fp, "input_priority=%d\n", input_info->priority);
@@ -895,8 +888,8 @@ static void save_plugin_list(FILE *fp, xine_sarray_t *list) {
post_info = node->info->special_info;
fprintf(fp, "post_type=%lu\n", (unsigned long)post_info->type);
break;
- }
-
+ }
+
fprintf(fp, "\n");
list_id++;
}
@@ -921,13 +914,13 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) {
char line[1024];
char *value;
int version_ok = 0;
-
+
node = NULL;
file = NULL;
while (fgets (line, 1023, fp)) {
if (line[0] == '#')
continue;
-
+
if( (value = strchr(line, '\r')) || (value = strchr(line, '\n')) )
*value = (char) 0; /* eliminate any cr/lf */
@@ -941,11 +934,11 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) {
if( node ) {
xine_sarray_add (plugins, node);
}
- node = xine_xmalloc(sizeof(plugin_node_t));
- file = xine_xmalloc(sizeof(plugin_file_t));
+ node = calloc(1, sizeof(plugin_node_t));
+ file = calloc(1, sizeof(plugin_file_t));
node->file = file;
file->filename = strdup(line+1);
- node->info = xine_xmalloc(2*sizeof(plugin_info_t));
+ node->info = calloc(2, sizeof(plugin_info_t));
node->info[1].type = PLUGIN_NONE;
decoder_info = NULL;
vo_info = NULL;
@@ -964,7 +957,7 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) {
if( i == CACHE_CATALOG_VERSION )
version_ok = 1;
else
- return;
+ return;
}
} else if (node) {
if( !strcmp("size",line) ) {
@@ -976,42 +969,42 @@ static void load_plugin_list(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 =
- xine_xmalloc(sizeof(vo_info_t));
+ calloc(1, sizeof(vo_info_t));
break;
-
+
case PLUGIN_AUDIO_OUT:
node->info->special_info = ao_info =
- xine_xmalloc(sizeof(ao_info_t));
+ calloc(1, sizeof(ao_info_t));
break;
-
+
case PLUGIN_DEMUX:
node->info->special_info = demuxer_info =
- xine_xmalloc(sizeof(demuxer_info_t));
+ calloc(1, sizeof(demuxer_info_t));
break;
case PLUGIN_INPUT:
node->info->special_info = input_info =
- xine_xmalloc(sizeof(input_info_t));
+ calloc(1, sizeof(input_info_t));
break;
case PLUGIN_AUDIO_DECODER:
case PLUGIN_VIDEO_DECODER:
case PLUGIN_SPU_DECODER:
node->info->special_info = decoder_info =
- xine_xmalloc(sizeof(decoder_info_t));
+ calloc(1, sizeof(decoder_info_t));
break;
-
+
case PLUGIN_POST:
node->info->special_info = post_info =
- xine_xmalloc(sizeof(post_info_t));
+ calloc(1, sizeof(post_info_t));
break;
- }
-
+ }
+
} else if( !strcmp("api",line) ) {
sscanf(value," %d",&i);
node->info->API = i;
@@ -1025,11 +1018,11 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) {
vo_info->visual_type = i;
} else if( !strcmp("supported_types",line) && decoder_info ) {
char *s;
-
+
for( s = value, i = 0; s && sscanf(s," %lu",&lu) > 0; i++ ) {
s = strchr(s+1, ' ');
}
- decoder_info->supported_types = xine_xmalloc((i+1)*sizeof(uint32_t));
+ decoder_info->supported_types = calloc((i+1), sizeof(uint32_t));
for( s = value, i = 0; s && sscanf(s," %lu",&lu) > 0; i++ ) {
decoder_info->supported_types[i] = lu;
s = strchr(s+1, ' ');
@@ -1056,7 +1049,7 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) {
}
}
}
-
+
if( node ) {
xine_sarray_add (plugins, node);
}
@@ -1069,33 +1062,52 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) {
static void save_catalog (xine_t *this) {
FILE *fp;
- char *cachefile, *dirfile;
+ char *cachefile, *cachefile_new, *dirfile;
const char *relname = CACHE_CATALOG_FILE;
const char *dirname = CACHE_CATALOG_DIR;
-
- cachefile = (char *) xine_xmalloc(strlen(xine_get_homedir()) +
- strlen(relname) + 2);
- sprintf(cachefile, "%s/%s", xine_get_homedir(), relname);
-
+
+ const char *const homedir = xine_get_homedir();
+
+ asprintf(&cachefile, "%s/%s", homedir, relname);
+ asprintf(&cachefile_new, "%s.new", cachefile);
+
/* make sure homedir (~/.xine) exists */
- dirfile = (char *) xine_xmalloc(strlen(xine_get_homedir()) +
- strlen(dirname) + 2);
- sprintf(dirfile, "%s/%s", xine_get_homedir(), dirname);
+ asprintf(&dirfile, "%s/%s", homedir, dirname);
mkdir (dirfile, 0755);
free (dirfile);
- if( (fp = fopen(cachefile,"w")) != NULL ) {
+ 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);
for (i = 0; i < PLUGIN_TYPE_MAX; i++) {
save_plugin_list (fp, this->plugin_catalog->plugin_lists[i]);
}
- fclose(fp);
+ if (fclose(fp))
+ {
+ const char *err = strerror (errno);
+ xine_log (this, XINE_LOG_MSG,
+ _("failed to save catalogue cache: %s\n"), err);
+ goto do_unlink;
+ }
+ else if (rename (cachefile_new, cachefile))
+ {
+ const char *err = strerror (errno);
+ xine_log (this, XINE_LOG_MSG,
+ _("failed to replace catalogue cache: %s\n"), err);
+ do_unlink:
+ if (unlink (cachefile_new) && errno != ENOENT)
+ {
+ err = strerror (errno);
+ xine_log (this, XINE_LOG_MSG,
+ _("failed to remove new catalogue cache: %s\n"), err);
+ }
+ }
}
free(cachefile);
+ free(cachefile_new);
}
/*
@@ -1104,13 +1116,11 @@ static void save_catalog (xine_t *this) {
static void load_cached_catalog (xine_t *this) {
FILE *fp;
- char *cachefile;
+ char *cachefile;
const char *relname = CACHE_CATALOG_FILE;
-
- cachefile = (char *) xine_xmalloc(strlen(xine_get_homedir()) +
- strlen(relname) + 2);
- sprintf(cachefile, "%s/%s", xine_get_homedir(), relname);
-
+
+ asprintf(&cachefile, "%s/%s", xine_get_homedir(), relname);
+
if( (fp = fopen(cachefile,"r")) != NULL ) {
load_plugin_list (fp, this->plugin_catalog->cache_list);
fclose(fp);
@@ -1119,15 +1129,25 @@ static void load_cached_catalog (xine_t *this) {
}
+/* helper function for _x_scan_plugins */
+static void push_if_dir (xine_list_t *plugindirs, void *path)
+{
+ struct stat st;
+ if (!stat (path, &st) && S_ISDIR (st.st_mode))
+ xine_list_push_back (plugindirs, path);
+ else
+ free (path);
+}
+
/*
* initialize catalog, load all plugins into new catalog
*/
void _x_scan_plugins (xine_t *this) {
-
- char *homedir, *plugindir, *pluginpath;
- int i,j;
- int lenpluginpath;
-
+
+ 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) {
@@ -1140,45 +1160,49 @@ void _x_scan_plugins (xine_t *this) {
this->plugin_catalog = _new_catalog();
load_cached_catalog (this);
- if ((pluginpath = getenv("XINE_PLUGIN_PATH")) != NULL) {
- pluginpath = strdup(pluginpath);
+ if ((pluginpath = getenv("XINE_PLUGIN_PATH")) != NULL && *pluginpath) {
+ char *p = pluginpath;
+ while (p && p[0])
+ {
+ size_t len;
+ char *dir, *q;
+
+ q = p;
+ p = strchr (p, XINE_PATH_SEPARATOR_CHAR);
+ if (p) {
+ p++;
+ len = p - q;
+ } else
+ len = strlen(q);
+ if (q[0] == '~' && q[1] == '/')
+ asprintf (&dir, "%s%.*s", homedir, (int)(len - 1), q + 1);
+ else
+ dir = strndup (q, len);
+ push_if_dir (plugindirs, dir); /* store or free it */
+ }
} else {
- const char *str1, *str2;
- int len;
-
- str1 = "~/.xine/plugins";
- str2 = XINE_PLUGINDIR;
- len = strlen(str1) + strlen(str2) + 2;
- pluginpath = xine_xmalloc(len);
- snprintf(pluginpath, len, "%s" XINE_PATH_SEPARATOR_STRING "%s", str1, str2);
- }
- plugindir = xine_xmalloc(strlen(pluginpath)+strlen(homedir)+2);
- j=0;
- lenpluginpath = strlen(pluginpath);
- for (i=0; i <= lenpluginpath; ++i){
- switch (pluginpath[i]){
- case XINE_PATH_SEPARATOR_CHAR:
- case '\0':
- plugindir[j] = '\0';
- collect_plugins(this, plugindir);
- j = 0;
- break;
- case '~':
- if (j == 0){
- strcpy(plugindir, homedir);
- j = strlen(plugindir);
- break;
- }
- default:
- plugindir[j++] = pluginpath[i];
+ char *dir;
+ int i;
+ asprintf (&dir, "%s/.xine/plugins", homedir);
+ push_if_dir (plugindirs, dir);
+ for (i = 0; i <= XINE_LT_AGE; ++i)
+ {
+ asprintf (&dir, "%s.%d", XINE_PLUGINROOT, XINE_LT_AGE - i);
+ push_if_dir (plugindirs, dir);
}
}
- free(plugindir);
- free(pluginpath);
+ for (iter = xine_list_front (plugindirs); iter;
+ iter = xine_list_next (plugindirs, iter))
+ {
+ char *dir = xine_list_get_value (plugindirs, iter);
+ collect_plugins(this, dir);
+ free (dir);
+ }
+ xine_list_delete (plugindirs);
free(homedir);
save_catalog (this);
-
+
load_required_plugins (this);
map_decoders (this);
@@ -1208,7 +1232,7 @@ input_plugin_t *_x_find_input_plugin (xine_stream_t *stream, const char *mrl) {
plugin->node = node;
break;
}
- }
+ }
}
pthread_mutex_unlock (&catalog->lock);
@@ -1229,6 +1253,26 @@ void _x_free_input_plugin (xine_stream_t *stream, input_plugin_t *input) {
}
}
+static int probe_mime_type (xine_t *self, plugin_node_t *node, const char *mime_type)
+{
+ /* catalog->lock is expected to be locked */
+ if (node->plugin_class || _load_plugin_class(self, node, NULL))
+ {
+ const unsigned int mime_type_len = strlen (mime_type);
+ demux_class_t *cls = (demux_class_t *)node->plugin_class;
+ const char *mime = cls->get_mimetypes (cls);
+ while (mime)
+ {
+ while (*mime == ';' || isspace (*mime))
+ ++mime;
+ if (!strncasecmp (mime, mime_type, mime_type_len) &&
+ (!mime[mime_type_len] || mime[mime_type_len] == ':' || mime[mime_type_len] == ';'))
+ return 1;
+ mime = strchr (mime, ';');
+ }
+ }
+ return 0;
+}
static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int method2,
input_plugin_t *input) {
@@ -1251,8 +1295,6 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth
while (methods[i] != -1 && !plugin) {
int list_id, list_size;
- stream->content_detection_method = methods[i];
-
pthread_mutex_lock (&catalog->lock);
list_size = xine_sarray_size(catalog->plugin_lists[PLUGIN_DEMUX - 1]);
@@ -1264,6 +1306,25 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth
xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "load_plugins: probing demux '%s'\n", node->info->id);
if (node->plugin_class || _load_plugin_class(stream->xine, node, NULL)) {
+ const char *mime_type;
+
+ /* If detecting by MRL, try the MIME type first (but not text/plain)... */
+ stream->content_detection_method = METHOD_EXPLICIT;
+ if (methods[i] == METHOD_BY_EXTENSION &&
+ stream->input_plugin->get_optional_data &&
+ stream->input_plugin->get_optional_data (stream->input_plugin, NULL, INPUT_OPTIONAL_DATA_DEMUX_MIME_TYPE) != INPUT_OPTIONAL_UNSUPPORTED &&
+ stream->input_plugin->get_optional_data (stream->input_plugin, &mime_type, INPUT_OPTIONAL_DATA_MIME_TYPE) != INPUT_OPTIONAL_UNSUPPORTED &&
+ mime_type && strcasecmp (mime_type, "text/plain") &&
+ probe_mime_type (stream->xine, node, mime_type) &&
+ (plugin = ((demux_class_t *)node->plugin_class)->open_plugin (node->plugin_class, stream, input)))
+ {
+ inc_node_ref(node);
+ plugin->node = node;
+ break;
+ }
+
+ /* ... then try the extension */
+ stream->content_detection_method = methods[i];
if ((plugin = ((demux_class_t *)node->plugin_class)->open_plugin(node->plugin_class, stream, input))) {
inc_node_ref(node);
plugin->node = node;
@@ -1377,7 +1438,7 @@ 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 ((plugin = ((demux_class_t *)node->plugin_class)->open_plugin(node->plugin_class, stream, input))) {
@@ -1485,7 +1546,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)) {
@@ -1544,7 +1605,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]);
@@ -1592,7 +1653,7 @@ xine_video_port_t *xine_open_video_driver (xine_t *this,
}
port = _x_vo_new_port(this, driver, 0);
-
+
return port;
}
@@ -1631,7 +1692,7 @@ xine_video_port_t *xine_new_framegrab_video_port (xine_t *this) {
}
port = _x_vo_new_port(this, driver, 1);
-
+
return port;
}
@@ -1641,7 +1702,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);
@@ -1651,7 +1712,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);
@@ -1659,6 +1720,36 @@ const char *const *xine_list_video_output_plugins (xine_t *xine) {
return catalog->ids;
}
+const char *const *xine_list_video_output_plugins_typed(xine_t *xine, uint64_t typemask)
+{
+ 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]);
+
+ for (list_id = i = 0; list_id < list_size; list_id++)
+ {
+ node = xine_sarray_get (catalog->plugin_lists[PLUGIN_VIDEO_OUT - 1], list_id);
+ if (typemask & (1ULL << ((vo_info_t *)node->info->special_info)->visual_type))
+ {
+ const char *id = node->info->id;
+ int j = i;
+ while (--j >= 0)
+ if (!strcmp (catalog->ids[j], id))
+ goto ignore; /* already listed */
+ catalog->ids[i++] = id;
+ }
+ ignore: ;
+ }
+ catalog->ids[i] = NULL;
+
+ pthread_mutex_unlock (&catalog->lock);
+ return catalog->ids;
+}
+
static ao_driver_t *_load_audio_driver (xine_t *this, plugin_node_t *node,
void *data) {
@@ -1721,7 +1812,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;
@@ -1747,13 +1838,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;
}
@@ -1811,7 +1902,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;
@@ -1845,7 +1936,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;
@@ -1877,7 +1968,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] =
@@ -1893,9 +1984,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 */
@@ -1948,7 +2039,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] =
@@ -1964,7 +2055,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 {
@@ -2004,11 +2095,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;
@@ -2035,7 +2126,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;
@@ -2073,7 +2164,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
{
@@ -2135,7 +2226,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 {
@@ -2169,7 +2260,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);
@@ -2179,7 +2270,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);
@@ -2189,7 +2280,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);
@@ -2199,7 +2290,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);
@@ -2209,7 +2300,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);
@@ -2219,7 +2310,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);
@@ -2232,7 +2323,7 @@ const char *const *xine_list_post_plugins_typed(xine_t *xine, int type) {
plugin_node_t *node;
int i;
int list_id, list_size;
-
+
pthread_mutex_lock (&catalog->lock);
i = 0;
@@ -2287,25 +2378,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);
@@ -2314,12 +2405,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);
@@ -2337,7 +2428,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) {
@@ -2354,10 +2445,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,
@@ -2366,9 +2457,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 {
@@ -2384,73 +2475,67 @@ void xine_post_dispose(xine_t *xine, xine_post_t *post_gen) {
* their disposal if they are still in use => post.c handles the counting for us */
}
+/**
+ * @brief Concantenates an array of strings into a single
+ * string separated with a given string.
+ *
+ * @param strings Array of strings to concatenate.
+ * @param count Number of elements in the @p strings array.
+ * @param joining String to use to join the various strings together.
+ * @param final_length The pre-calculated final length of the string.
+ */
+static char *_x_concatenate_with_string(char const **strings, size_t count, char *joining, size_t final_length) {
+ size_t i;
+ char *const result = malloc(final_length+1); /* Better be safe */
+ char *str = result;
+
+ for(i = 0; i < count; i++, strings++) {
+ if ( *strings ) {
+ int offset = snprintf(str, final_length, "%s%s", *strings, joining);
+ str += offset;
+ final_length -= offset;
+ }
+ }
+
+ return result;
+}
+
/* 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) {
plugin_catalog_t *catalog = self->plugin_catalog;
- int len, pos;
- plugin_node_t *node;
- char *str;
- int list_id, list_size;
+ int list_id;
pthread_mutex_lock (&catalog->lock);
- /* calc length of output */
+ /* calc length of output string and create an array of strings to
+ concatenate */
+ size_t len = 0;
+ const int list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
+ const char **extensions = calloc(list_size, sizeof(char*));
- len = 0;
- list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
for (list_id = 0; list_id < list_size; list_id++) {
- demux_class_t *cls;
- const char *exts;
-
- node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
+ plugin_node_t *const node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
if (node->plugin_class || _load_plugin_class(self, node, NULL)) {
-
- cls = (demux_class_t *)node->plugin_class;
-
- if((exts = cls->get_extensions(cls)) && *exts)
- len += strlen(exts) + 1;
+ demux_class_t *const cls = (demux_class_t *)node->plugin_class;
+ if( (extensions[list_id] = cls->get_extensions(cls)) != NULL )
+ len += strlen(extensions[list_id]) +1;
}
}
- /* create output */
- str = malloc (len); /* '\0' space is already counted in the previous loop */
- pos = 0;
+ /* create output string */
+ char *const result = _x_concatenate_with_string(extensions, list_size, " ", len);
+ free(extensions);
- list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
- for (list_id = 0; list_id < list_size; list_id++) {
- demux_class_t *cls;
- const char *e;
- int l;
-
- node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
- if (node->plugin_class || _load_plugin_class(self, node, NULL)) {
+ /* Drop the last whitespace */
+ result[len-1] = '\0';
- cls = (demux_class_t *)node->plugin_class;
-
- if((e = cls->get_extensions (cls)) && *e) {
- l = strlen(e);
- memcpy (&str[pos], e, l);
-
- pos += l;
-
- /* Don't add ' ' char at the end of str */
- if((pos + 1) < len) {
- str[pos] = ' ';
- pos++;
- }
- }
- }
- }
-
- str[pos] = 0;
-
pthread_mutex_unlock (&catalog->lock);
- return str;
+ return result;
}
/* get a list of mime types supported by xine
@@ -2459,65 +2544,34 @@ char *xine_get_file_extensions (xine_t *self) {
char *xine_get_mime_types (xine_t *self) {
plugin_catalog_t *catalog = self->plugin_catalog;
- int len, pos;
- plugin_node_t *node;
- char *str;
- int list_id, list_size;
+ int list_id;
pthread_mutex_lock (&catalog->lock);
/* calc length of output */
- len = 0;
- list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
+ /* calc length of output string and create an array of strings to
+ concatenate */
+ 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*));
for (list_id = 0; list_id < list_size; list_id++) {
- demux_class_t *cls;
- const char *s;
-
- node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
+ plugin_node_t *const node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
if (node->plugin_class || _load_plugin_class(self, node, NULL)) {
-
- cls = (demux_class_t *)node->plugin_class;
-
- s = cls->get_mimetypes (cls);
- if (s)
- len += strlen(s);
+ demux_class_t *const cls = (demux_class_t *)node->plugin_class;
+ if( (mimetypes[list_id] = cls->get_mimetypes(cls)) != NULL )
+ len += strlen(mimetypes[list_id]);
}
}
- /* create output */
-
- str = malloc (len+1);
- pos = 0;
-
- list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
-
- for (list_id = 0; list_id < list_size; list_id++) {
- demux_class_t *cls;
- const char *s;
- int l;
-
- node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
- if (node->plugin_class || _load_plugin_class(self, node, NULL)) {
-
- cls = (demux_class_t *)node->plugin_class;
+ /* create output string */
+ char *const result = _x_concatenate_with_string(mimetypes, list_size, "", len);
+ free(mimetypes);
- s = cls->get_mimetypes (cls);
- if (s) {
- l = strlen(s);
- memcpy (&str[pos], s, l);
-
- pos += l;
- }
- }
- }
-
- str[pos] = 0;
-
pthread_mutex_unlock (&catalog->lock);
- return str;
+ return result;
}
@@ -2530,47 +2584,24 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) {
plugin_catalog_t *catalog = self->plugin_catalog;
plugin_node_t *node;
char *id = NULL;
- char *mime_arg, *mime_demux;
- char *s;
- const char *mt;
int list_id, list_size;
- /* create a copy and convert to lower case */
- mime_arg = strdup(mime_type);
- for(s=mime_arg; *s; s++)
- *s = tolower(*s);
-
pthread_mutex_lock (&catalog->lock);
list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]);
for (list_id = 0; (list_id < list_size) && !id; list_id++) {
- demux_class_t *cls;
node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id);
- if (node->plugin_class || _load_plugin_class(self, node, NULL)) {
-
- cls = (demux_class_t *)node->plugin_class;
-
- mt = cls->get_mimetypes (cls);
- if (mt) {
- mime_demux = strdup(mt);
-
- for(s=mime_demux; *s; s++)
- *s = tolower(*s);
-
- if( strstr(mime_demux, mime_arg) )
- id = strdup(node->info->id);
-
- free(mime_demux);
- }
+ if (probe_mime_type (self, node, mime_type))
+ {
+ free (id);
+ id = strdup(node->info->id);
}
}
pthread_mutex_unlock (&catalog->lock);
- free(mime_arg);
-
return id;
}
@@ -2582,7 +2613,7 @@ static void dispose_plugin_list (xine_sarray_t *list) {
int list_id, list_size;
if (list) {
-
+
list_size = xine_sarray_size (list);
for (list_id = 0; list_id < list_size; list_id++) {
@@ -2603,12 +2634,12 @@ static void dispose_plugin_list (xine_sarray_t *list) {
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 6da846a7c..89d4b2654 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,8 +29,8 @@ lrb_t *lrb_new (int max_num_entries,
fifo_buffer_t *fifo) {
lrb_t *this;
-
- this = xine_xmalloc (sizeof (lrb_t));
+
+ this = calloc(1, sizeof(lrb_t));
this->max_num_entries = max_num_entries;
this->cur_num_entries = 0;
@@ -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 491ae8843..f64e50eab 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 5d3e0a12d..8cd36f70f 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;
@@ -172,12 +172,11 @@ static void unixscr_exit (scr_plugin_t *scr) {
free(this);
}
-static scr_plugin_t* unixscr_init () {
+static scr_plugin_t *XINE_MALLOC unixscr_init () {
unixscr_t *this;
- this = (unixscr_t *) xine_xmalloc(sizeof(unixscr_t));
- memset(this, 0, sizeof(*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;
@@ -185,15 +184,15 @@ static scr_plugin_t* 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;
}
-
+
/*
* ****************************************
@@ -209,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;
}
@@ -244,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++)
@@ -268,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;
}
@@ -388,18 +387,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);
@@ -419,15 +418,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)
@@ -440,15 +439,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;
}
@@ -479,23 +478,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;
@@ -509,7 +508,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);
}
@@ -523,7 +522,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;
@@ -536,7 +535,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);
}
@@ -544,7 +543,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);
@@ -553,19 +552,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 {
@@ -574,11 +573,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;
@@ -588,34 +587,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;
}
@@ -629,7 +628,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 {
@@ -639,15 +638,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);
}
}
@@ -655,12 +654,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).
@@ -678,7 +677,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);
@@ -689,7 +688,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);
@@ -745,7 +744,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);
@@ -776,7 +775,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 */
@@ -794,7 +793,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);
@@ -811,7 +810,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;
}
@@ -833,19 +832,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);
}
@@ -855,13 +854,13 @@ static int metronom_sync_loop (metronom_clock_t *this) {
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);
@@ -889,7 +888,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);
@@ -909,7 +908,7 @@ static void metronom_clock_exit (metronom_clock_t *this) {
metronom_t * _x_metronom_init (int have_video, int have_audio, xine_t *xine) {
- metronom_t *this = xine_xmalloc (sizeof (metronom_t));
+ metronom_t *this = calloc(1, sizeof (metronom_t));
this->set_audio_rate = metronom_set_audio_rate;
this->got_video_frame = metronom_got_video_frame;
@@ -924,7 +923,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;
@@ -933,7 +932,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;
@@ -944,8 +943,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;
@@ -954,7 +953,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;
}
@@ -962,9 +961,9 @@ metronom_t * _x_metronom_init (int have_video, int have_audio, xine_t *xine) {
metronom_clock_t *_x_metronom_clock_init(xine_t *xine)
{
- metronom_clock_t *this = (metronom_clock_t *) xine_xmalloc(sizeof(metronom_clock_t));
+ 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;
@@ -976,19 +975,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,
- (void*(*)(void*)) metronom_sync_loop, this)) != 0)
+ (void*(*)(void*)) 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/metronom.h b/src/xine-engine/metronom.h
index 20e31117c..946aa0991 100644
--- a/src/xine-engine/metronom.h
+++ b/src/xine-engine/metronom.h
@@ -1,30 +1,30 @@
-/*
+/*
* 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
*
* metronom: general pts => virtual calculation/assoc
- *
+ *
* virtual pts: unit 1/90000 sec, always increasing
* can be used for synchronization
* video/audio frame with same pts also have same vpts
* but pts is likely to differ from vpts
*
- * the basic idea is:
+ * the basic idea is:
* video_pts + video_wrap_offset = video_vpts
* audio_pts + audio_wrap_offset = audio_vpts
*
@@ -67,8 +67,8 @@ typedef struct scr_plugin_s scr_plugin_t;
#define PREBUFFER_PTS_OFFSET 12000
/* see below */
-#define DISC_STREAMSTART 0
-#define DISC_RELATIVE 1
+#define DISC_STREAMSTART 0
+#define DISC_RELATIVE 1
#define DISC_ABSOLUTE 2
#define DISC_STREAMSEEK 3
@@ -91,9 +91,9 @@ struct metronom_s {
*
* this function will also update video_wrap_offset if a discontinuity
* is detected (read the comentaries below about discontinuities).
- *
+ *
*/
-
+
void (*got_video_frame) (metronom_t *self, vo_frame_t *frame);
/*
@@ -109,8 +109,8 @@ struct metronom_s {
*
*/
- int64_t (*got_audio_samples) (metronom_t *self, int64_t pts,
- int nsamples);
+ int64_t (*got_audio_samples) (metronom_t *self, int64_t pts,
+ int nsamples);
/*
* called by SPU decoder whenever a packet is delivered to it
@@ -134,7 +134,7 @@ struct metronom_s {
*
* DISC_STREAMSTART : new stream starts, expect pts values to start
* from zero immediately
- * DISC_RELATIVE : typically a wrap-around, expect pts with
+ * DISC_RELATIVE : typically a wrap-around, expect pts with
* a specified offset from the former ones soon
* DISC_ABSOLUTE : typically a new menu stream (nav packets)
* pts will start from given value soon
@@ -152,7 +152,7 @@ struct metronom_s {
*/
void (*set_option) (metronom_t *self, int option, int64_t value);
int64_t (*get_option) (metronom_t *self, int option);
-
+
/*
* set a master metronom
* this is currently useful to sync independently generated streams
@@ -160,7 +160,7 @@ struct metronom_s {
* metronom
*/
void (*set_master) (metronom_t *self, metronom_t *master);
-
+
void (*exit) (metronom_t *self);
#ifdef METRONOM_INTERNAL
@@ -168,7 +168,7 @@ struct metronom_s {
* metronom internal stuff
*/
xine_t *xine;
-
+
metronom_t *master;
int64_t pts_per_smpls;
@@ -182,7 +182,7 @@ struct metronom_s {
int64_t video_drift;
int64_t video_drift_step;
-
+
int audio_samples;
int64_t audio_drift_step;
@@ -223,7 +223,7 @@ struct metronom_s {
#define METRONOM_VPTS_OFFSET 6
#define METRONOM_PREBUFFER 7
-metronom_t *_x_metronom_init (int have_video, int have_audio, xine_t *xine) XINE_PROTECTED;
+metronom_t *_x_metronom_init (int have_video, int have_audio, xine_t *xine) XINE_MALLOC XINE_PROTECTED;
/* FIXME: reorder this structure on the next cleanup to remove the dummies */
struct metronom_clock_s {
@@ -293,9 +293,9 @@ struct metronom_clock_s {
#ifdef METRONOM_CLOCK_INTERNAL
void (*exit) (metronom_clock_t *self);
-
+
xine_t *xine;
-
+
scr_plugin_t *scr_master;
scr_plugin_t **scr_list;
pthread_t sync_thread;
@@ -310,7 +310,7 @@ struct metronom_clock_s {
int dummy10;
int dummy11;
#endif
-
+
int speed;
#ifdef METRONOM_CLOCK_INTERNAL
@@ -319,7 +319,7 @@ struct metronom_clock_s {
#endif
};
-metronom_clock_t *_x_metronom_clock_init(xine_t *xine) XINE_PROTECTED;
+metronom_clock_t *_x_metronom_clock_init(xine_t *xine) XINE_MALLOC XINE_PROTECTED;
/*
* clock options
@@ -337,8 +337,8 @@ struct scr_plugin_s
int (*get_priority) (scr_plugin_t *self);
- /*
- * set/get clock speed
+ /*
+ * set/get clock speed
*
* for speed constants see xine_internal.h
* returns actual speed
diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c
index ef888e7a4..94fc969bd 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
@@ -83,17 +83,6 @@
# define UCS2_ENCODING "UCS-2LE"
#endif
-#ifdef MAX
-#undef MAX
-#endif
-#define MAX(a,b) ( (a) > (b) ) ? (a) : (b)
-
-#ifdef MIN
-#undef MIN
-#endif
-#define MIN(a,b) ( (a) < (b) ) ? (a) : (b)
-
-
#if (FREETYPE_MAJOR > 2) || \
(FREETYPE_MAJOR == 2 && FREETYPE_MINOR > 1) || \
(FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 1 && FREETYPE_PATCH >= 3)
@@ -124,7 +113,7 @@ struct osd_font_s {
uint16_t size;
uint16_t num_fontchars;
uint16_t loaded;
-};
+};
#ifdef HAVE_FT2
struct osd_ft2context_s {
@@ -132,6 +121,20 @@ struct osd_ft2context_s {
FT_Face face;
int size;
};
+
+static void osd_free_ft2 (osd_object_t *osd)
+{
+ if( osd->ft2 ) {
+ if ( osd->ft2->face )
+ FT_Done_Face (osd->ft2->face);
+ if ( osd->ft2->library )
+ FT_Done_FreeType(osd->ft2->library);
+ free( osd->ft2 );
+ osd->ft2 = NULL;
+ }
+}
+#else
+static inline void osd_free_ft2 (osd_object_t *osd __attr_unused) {}
#endif
/*
@@ -143,28 +146,28 @@ struct osd_ft2context_s {
* for the sake of simplicity)
*/
-static osd_object_t *osd_new_object (osd_renderer_t *this, int width, int height) {
-
+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);
-
- osd = xine_xmalloc( sizeof(osd_object_t) );
+
+ pthread_mutex_lock (&this->osd_mutex);
+
+ osd = calloc(1, sizeof(osd_object_t));
osd->renderer = this;
osd->next = this->osds;
this->osds = osd;
-
+
osd->width = width;
osd->height = height;
- osd->area = xine_xmalloc( width * height );
-
+ osd->area = calloc(width, height);
+
osd->x1 = width;
osd->y1 = height;
osd->x2 = 0;
osd->y2 = 0;
- 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;
@@ -172,11 +175,11 @@ static osd_object_t *osd_new_object (osd_renderer_t *this, int width, int height
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;
}
@@ -193,7 +196,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;
@@ -201,21 +204,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)
@@ -229,13 +232,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) );
@@ -244,25 +247,25 @@ static int _osd_show (osd_object_t *osd, int64_t vpts, int unscaled ) {
this->event.object.overlay->y = osd->display_y + osd->y1;
this->event.object.overlay->width = osd->x2 - osd->x1;
this->event.object.overlay->height = osd->y2 - osd->y1;
-
+
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;
/* We will never need more rle objects than columns in any row
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 */
@@ -272,17 +275,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);
@@ -294,12 +297,12 @@ 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);
@@ -307,10 +310,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;
}
@@ -332,24 +335,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);
@@ -395,14 +398,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));
@@ -419,14 +422,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;
@@ -441,7 +444,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;
@@ -458,19 +461,19 @@ 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 );
-
+
dx = x2 - x1;
dy = y2 - y1;
-
+
/* unsort line */
if (swap_x) {
t = x1;
@@ -489,7 +492,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;
@@ -497,11 +500,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;
@@ -526,8 +529,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 ) {
@@ -552,17 +555,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;
@@ -574,7 +577,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 );
@@ -600,7 +603,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)
*/
@@ -619,7 +622,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]));
}
@@ -655,7 +658,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) {
@@ -663,47 +666,47 @@ 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 */
/* fixme: check for all read errors... */
if( (fp = gzopen(filename,"rb")) != NULL ) {
- font = xine_xmalloc( sizeof(osd_font_t) );
+ font = calloc(1, sizeof(osd_font_t));
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) &&
@@ -711,16 +714,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.
@@ -731,7 +734,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);
@@ -739,13 +742,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);
}
@@ -771,13 +774,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;
@@ -789,14 +792,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
@@ -818,7 +821,7 @@ static int osd_renderer_unload_font(osd_renderer_t *this, char *fontname ) {
#ifdef HAVE_FT2
static int osd_set_font_freetype2( osd_object_t *osd, const char *fontname, int size ) {
if (!osd->ft2) {
- osd->ft2 = xine_xmalloc(sizeof(osd_ft2context_t));
+ osd->ft2 = calloc(1, sizeof(osd_ft2context_t));
if(FT_Init_FreeType( &osd->ft2->library )) {
xprintf(osd->renderer->stream->xine, XINE_VERBOSITY_LOG,
_("osd: cannot initialize ft2 library\n"));
@@ -827,7 +830,12 @@ static int osd_set_font_freetype2( osd_object_t *osd, const char *fontname, int
return 0;
}
}
-
+
+ if (osd->ft2->face) {
+ FT_Done_Face (osd->ft2->face);
+ osd->ft2->face = NULL;
+ }
+
#ifdef HAVE_FONTCONFIG
do {
FcPattern *pat = NULL, *match = NULL;
@@ -840,7 +848,7 @@ static int osd_set_font_freetype2( osd_object_t *osd, const char *fontname, int
match = FcFontMatch(NULL, pat, &result);
FcPatternDestroy(pat);
-
+
if ( ! match ) {
FcFontSetDestroy(fs);
xprintf(osd->renderer->stream->xine, XINE_VERBOSITY_LOG,
@@ -870,7 +878,7 @@ static int osd_set_font_freetype2( osd_object_t *osd, const char *fontname, int
/* try load font from current directory */
if ( !FT_New_Face(osd->ft2->library, fontname, 0, &osd->ft2->face) )
goto end;
-
+
/* try load font from home directory */
snprintf(pathname, 1024, "%s/.xine/fonts/%s", xine_get_homedir(), fontname);
if ( !FT_New_Face(osd->ft2->library, pathname, 0, &osd->ft2->face) )
@@ -881,20 +889,18 @@ static int osd_set_font_freetype2( osd_object_t *osd, const char *fontname, int
if ( !FT_New_Face(osd->ft2->library, pathname, 0, &osd->ft2->face) )
goto end;
- xprintf(osd->renderer->stream->xine, XINE_VERBOSITY_LOG,
+ xprintf(osd->renderer->stream->xine, XINE_VERBOSITY_LOG,
_("osd: error loading font %s with ft2\n"), fontname);
}
- free(osd->ft2);
- osd->ft2 = NULL;
+ osd_free_ft2 (osd);
return 0;
end:
if (FT_Set_Pixel_Sizes(osd->ft2->face, 0, size)) {
xprintf(osd->renderer->stream->xine, XINE_VERBOSITY_LOG,
_("osd: error setting font size (no scalable font?)\n"));
- free(osd->ft2);
- osd->ft2 = NULL;
+ osd_free_ft2 (osd);
return 0;
}
@@ -907,11 +913,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
@@ -926,7 +932,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;
@@ -942,7 +948,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);
@@ -972,29 +978,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;
@@ -1046,7 +1052,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
@@ -1111,7 +1117,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;
@@ -1127,7 +1133,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);
@@ -1140,10 +1146,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];
@@ -1201,7 +1207,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++;
}
@@ -1220,15 +1226,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;
@@ -1240,7 +1246,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++;
}
@@ -1248,12 +1254,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
@@ -1285,7 +1291,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);
{
@@ -1295,7 +1301,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);
@@ -1308,10 +1314,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];
@@ -1402,7 +1408,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);
@@ -1410,21 +1416,18 @@ static void osd_preload_fonts (osd_renderer_t *this, char *path) {
if( p ) {
osd_font_t *font;
- char *pathname;
*p++ = '\0';
- font = xine_xmalloc( sizeof(osd_font_t) );
-
+ 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);
- pathname = (char *) xine_xmalloc(strlen(path) + strlen(entry->d_name) + 2);
- sprintf (pathname, "%s/%s", path, entry->d_name);
- font->filename = pathname;
-
+ asprintf (&font->filename, "%s/%s", path, entry->d_name);
+
font->next = this->fonts;
this->fonts = font;
}
@@ -1441,30 +1444,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;
@@ -1472,17 +1475,9 @@ static void osd_free_object (osd_object_t *osd_to_close) {
if ( osd == osd_to_close ) {
free( osd->area );
-#ifdef HAVE_FT2
- if( osd->ft2 ) {
- if ( osd->ft2->library )
- FT_Done_FreeType(osd->ft2->library);
-
- free( osd->ft2 );
- }
-#endif
-
+ osd_free_ft2 (osd);
osd_free_encoding(osd);
-
+
if( last )
last->next = osd->next;
else
@@ -1494,7 +1489,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) {
@@ -1552,7 +1547,7 @@ static void osd_draw_bitmap(osd_object_t *osd, uint8_t *bitmap,
}
static uint32_t osd_get_capabilities (osd_object_t *osd) {
-
+
osd_renderer_t *this = osd->renderer;
uint32_t capabilities = 0;
@@ -1565,8 +1560,8 @@ static uint32_t osd_get_capabilities (osd_object_t *osd) {
VO_CAP_UNSCALED_OVERLAY)
capabilities |= XINE_OSD_CAP_UNSCALED;
this->stream->xine->port_ticket->release(this->stream->xine->port_ticket, 1);
-
- return capabilities;
+
+ return capabilities;
}
@@ -1579,9 +1574,9 @@ osd_renderer_t *_x_osd_renderer_init( xine_stream_t *stream ) {
osd_renderer_t *this;
char str[1024];
- this = xine_xmalloc(sizeof(osd_renderer_t));
+ this = calloc(1, sizeof(osd_renderer_t));
this->stream = stream;
- this->event.object.overlay = xine_xmalloc( sizeof(vo_overlay_t) );
+ this->event.object.overlay = calloc(1, sizeof(vo_overlay_t));
pthread_mutex_init (&this->osd_mutex, NULL);
@@ -1597,13 +1592,13 @@ osd_renderer_t *_x_osd_renderer_init( xine_stream_t *stream ) {
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/osd.h b/src/xine-engine/osd.h
index 38b5d1fdd..768fcb418 100644
--- a/src/xine-engine/osd.h
+++ b/src/xine-engine/osd.h
@@ -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
@@ -48,11 +48,11 @@ struct osd_object_s {
int width, height; /* work area dimentions */
uint8_t *area; /* work area */
int display_x,display_y; /* where to display it in screen */
-
+
/* clipping box inside work area */
int x1, y1;
int x2, y2;
-
+
uint32_t color[OVL_PALETTE_SIZE]; /* color lookup table */
uint8_t trans[OVL_PALETTE_SIZE]; /* mixer key table */
@@ -62,7 +62,7 @@ struct osd_object_s {
iconv_t cd; /* iconv handle of encoding */
char *encoding; /* name of encoding */
#endif
-
+
osd_font_t *font;
osd_ft2context_t *ft2;
};
@@ -102,17 +102,17 @@ struct osd_renderer_s {
*/
int (*hide) (osd_object_t *osd, int64_t vpts );
- /*
+ /*
* draw point.
*/
void (*point) (osd_object_t *osd, int x, int y, int color);
-
+
/*
* Bresenham line implementation on osd object
*/
void (*line) (osd_object_t *osd,
int x1, int y1, int x2, int y2, int color );
-
+
/*
* filled rectangle
*/
@@ -125,7 +125,7 @@ struct osd_renderer_s {
void (*set_palette) (osd_object_t *osd, const uint32_t *color, const uint8_t *trans );
/*
- * set on existing text palette
+ * set on existing text palette
* (-1 to set used specified palette)
*
* color_base specifies the first color index to use for this text
@@ -136,11 +136,11 @@ struct osd_renderer_s {
*/
void (*set_text_palette) (osd_object_t *osd, int palette_number,
int color_base );
-
+
/*
* get palette (color and transparency)
*/
- void (*get_palette) (osd_object_t *osd, uint32_t *color,
+ void (*get_palette) (osd_object_t *osd, uint32_t *color,
uint8_t *trans);
/*
@@ -167,20 +167,20 @@ struct osd_renderer_s {
* no \n yet
*
* The text is assigned the colors starting at the index specified by
- * color_base up to the size of the text palette.
+ * color_base up to the size of the text palette.
*
* Use OSD_TEXT1, OSD_TEXT2, ... for some preasssigned color indices.
*/
- int (*render_text) (osd_object_t *osd, int x1, int y1,
+ int (*render_text) (osd_object_t *osd, int x1, int y1,
const char *text, int color_base);
/*
* get width and height of how text will be renderized
*/
- int (*get_text_size) (osd_object_t *osd, const char *text,
+ int (*get_text_size) (osd_object_t *osd, const char *text,
int *width, int *height);
- /*
+ /*
* close osd rendering engine
* loaded fonts are unloaded
* osd objects are closed
@@ -191,7 +191,7 @@ struct osd_renderer_s {
* clear an osd object (empty drawing area)
*/
void (*clear) (osd_object_t *osd );
-
+
/*
* paste a bitmap with optional palette mapping
*/
@@ -210,7 +210,7 @@ struct osd_renderer_s {
* see xine.h for defined XINE_OSD_CAP_ values.
*/
uint32_t (*get_capabilities) (osd_object_t *osd);
-
+
/* private stuff */
pthread_mutex_t osd_mutex;
@@ -218,7 +218,7 @@ struct osd_renderer_s {
osd_object_t *osds; /* instances of osd */
osd_font_t *fonts; /* loaded fonts */
int textpalette; /* default textpalette */
-
+
xine_stream_t *stream;
};
@@ -226,11 +226,11 @@ struct osd_renderer_s {
/*
* initialize the osd rendering engine
*/
-osd_renderer_t *_x_osd_renderer_init( xine_stream_t *stream );
+osd_renderer_t *_x_osd_renderer_init( xine_stream_t *stream ) XINE_MALLOC;
/*
- * The size of a text palette
+ * The size of a text palette
*/
#define TEXT_PALETTE_SIZE 11
@@ -251,29 +251,29 @@ osd_renderer_t *_x_osd_renderer_init( xine_stream_t *stream );
#define OSD_TEXT9 (8 * TEXT_PALETTE_SIZE)
#define OSD_TEXT10 (9 * TEXT_PALETTE_SIZE)
-/*
+/*
* Defined palettes for rendering osd text
* (more can be added later)
- */
+ */
#define NUMBER_OF_TEXT_PALETTES 4
#define TEXTPALETTE_WHITE_BLACK_TRANSPARENT 0
#define TEXTPALETTE_WHITE_NONE_TRANSPARENT 1
#define TEXTPALETTE_WHITE_NONE_TRANSLUCID 2
#define TEXTPALETTE_YELLOW_BLACK_TRANSPARENT 3
-
+
#ifdef __OSD_C__
-
+
/* This text descriptions are used for config screen */
static const char *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
@@ -284,10 +284,10 @@ static const char *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]
diff --git a/src/xine-engine/plugin_catalog.h b/src/xine-engine/plugin_catalog.h
index a28321760..010ec53bb 100644
--- a/src/xine-engine/plugin_catalog.h
+++ b/src/xine-engine/plugin_catalog.h
@@ -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
@@ -60,16 +60,16 @@ typedef struct {
struct plugin_catalog_s {
xine_sarray_t *plugin_lists[PLUGIN_TYPE_MAX];
-
+
xine_sarray_t *cache_list;
xine_list_t *file_list;
plugin_node_t *audio_decoder_map[DECODER_MAX][PLUGINS_PER_TYPE];
plugin_node_t *video_decoder_map[DECODER_MAX][PLUGINS_PER_TYPE];
plugin_node_t *spu_decoder_map[DECODER_MAX][PLUGINS_PER_TYPE];
-
+
const char *ids[PLUGIN_MAX];
-
+
/* memory block for the decoder priority config entry descriptions */
char *prio_desc[DECODER_MAX];
diff --git a/src/xine-engine/post.c b/src/xine-engine/post.c
index 5d8d67037..276934788 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
*/
@@ -30,13 +30,10 @@
void _x_post_init(post_plugin_t *post, int num_audio_inputs, int num_video_inputs) {
- int audio_inputs_size = (num_audio_inputs + 1) * sizeof(xine_audio_port_t *);
- int video_inputs_size = (num_video_inputs + 1) * sizeof(xine_video_port_t *);
-
post->input = xine_list_new();
post->output = xine_list_new();
- post->xine_post.audio_input = (xine_audio_port_t **)xine_xmalloc(audio_inputs_size);
- post->xine_post.video_input = (xine_video_port_t **)xine_xmalloc(video_inputs_size);
+ post->xine_post.audio_input = calloc(num_audio_inputs + 1, sizeof(xine_audio_port_t *));
+ post->xine_post.video_input = calloc(num_video_inputs + 1, sizeof(xine_video_port_t *));
}
@@ -44,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);
@@ -53,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);
@@ -62,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);
@@ -95,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);
@@ -113,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);
@@ -122,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 */
@@ -141,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);
@@ -151,7 +148,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);
@@ -161,7 +158,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);
@@ -171,7 +168,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);
@@ -186,32 +183,32 @@ 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->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);
-
+
return 1;
}
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 = (post_video_port_t *)xine_xmalloc(sizeof(post_video_port_t));
-
+ 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;
@@ -225,17 +222,17 @@ 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 = (post_in_t *)xine_xmalloc(sizeof(post_in_t));
+ *input = calloc(1, sizeof(post_in_t));
if (!*input) return port;
(*input)->xine_in.name = "video in";
(*input)->xine_in.type = XINE_POST_DATA_VIDEO;
@@ -243,9 +240,9 @@ 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 = (post_out_t *)xine_xmalloc(sizeof(post_out_t));
+ *output = calloc(1, sizeof(post_out_t));
if (!*output) return port;
(*output)->xine_out.name = "video out";
(*output)->xine_out.type = XINE_POST_DATA_VIDEO;
@@ -255,7 +252,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;
}
@@ -263,7 +260,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 */
@@ -282,7 +279,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);
@@ -292,7 +289,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);
@@ -302,7 +299,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);
@@ -313,7 +310,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);
@@ -324,7 +321,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++;
@@ -335,7 +332,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);
@@ -346,24 +343,24 @@ 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) {
new_frame = port->free_frame_slots;
port->free_frame_slots = new_frame->next;
} else {
- new_frame = (vo_frame_t *)xine_xmalloc(sizeof(vo_frame_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 =
@@ -380,7 +377,7 @@ vo_frame_t *_x_post_intercept_video_frame(vo_frame_t *frame, post_video_port_t *
port->new_frame->free ? port->new_frame->free : post_frame_free;
new_frame->dispose =
port->new_frame->dispose ? port->new_frame->dispose : post_frame_dispose;
-
+
if (!port->new_frame->draw) {
/* draw will most likely modify the frame, so the decoder
* should only request preprocessing when there is no new draw */
@@ -389,17 +386,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);
@@ -408,7 +405,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;
}
@@ -449,7 +446,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);
}
@@ -465,14 +462,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);
@@ -480,7 +477,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);
@@ -489,7 +486,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);
@@ -498,7 +495,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);
@@ -507,7 +504,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);
@@ -516,7 +513,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);
@@ -525,17 +522,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);
@@ -559,7 +556,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;
}
@@ -568,7 +565,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);
@@ -578,7 +575,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);
@@ -588,7 +585,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);
@@ -599,7 +596,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);
@@ -615,7 +612,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);
@@ -626,15 +623,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);
@@ -644,7 +641,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);
@@ -668,7 +665,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);
@@ -678,7 +675,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;
@@ -696,31 +693,31 @@ 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->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);
-
+
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 = (post_audio_port_t *)xine_xmalloc(sizeof(post_audio_port_t));
-
+ 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;
@@ -732,14 +729,14 @@ 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 = (post_in_t *)xine_xmalloc(sizeof(post_in_t));
+ *input = calloc(1, sizeof(post_in_t));
if (!*input) return port;
(*input)->xine_in.name = "audio in";
(*input)->xine_in.type = XINE_POST_DATA_AUDIO;
@@ -747,9 +744,9 @@ 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 = (post_out_t *)xine_xmalloc(sizeof(post_out_t));
+ *output = calloc(1, sizeof(post_out_t));
if (!*output) return port;
(*output)->xine_out.name = "audio out";
(*output)->xine_out.type = XINE_POST_DATA_AUDIO;
@@ -759,14 +756,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];
@@ -776,11 +773,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];
@@ -796,7 +793,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];
@@ -806,20 +803,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);
@@ -828,16 +825,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);
}
@@ -845,9 +842,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);
}
@@ -870,18 +867,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);
((plugin_node_t *)this->node)->ref--;
pthread_mutex_unlock(&this->xine->plugin_catalog->lock);
-
+
return 1;
}
-
+
return 0;
}
diff --git a/src/xine-engine/post.h b/src/xine-engine/post.h
index b06c7930a..d37c52908 100644
--- a/src/xine-engine/post.h
+++ b/src/xine-engine/post.h
@@ -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
@@ -53,14 +53,14 @@ struct post_class_s {
post_plugin_t* (*open_plugin) (post_class_t *this, int inputs,
xine_audio_port_t **audio_target,
xine_video_port_t **video_target);
-
+
/*
* return short, human readable identifier for this plugin class
*/
char* (*get_identifier) (post_class_t *this);
/*
- * return human readable (verbose = 1 line) description for
+ * return human readable (verbose = 1 line) description for
* this plugin class
*/
char* (*get_description) (post_class_t *this);
@@ -76,25 +76,25 @@ struct post_plugin_s {
/* public part of the plugin */
xine_post_t xine_post;
-
+
/*
* the connections announced by the plugin
* the plugin must fill these with xine_post_{in,out}_t on init
*/
xine_list_t *input;
xine_list_t *output;
-
+
/*
* close down, free all resources
*/
void (*dispose) (post_plugin_t *this);
-
+
/* has dispose been called */
int dispose_pending;
-
+
/* plugins don't have to init the stuff below */
-
- /*
+
+ /*
* the running ticket
*
* the plugin must assure to check for ticket revocation in
@@ -105,11 +105,11 @@ struct post_plugin_s {
* the running ticket is assigned to you by the engine
*/
xine_ticket_t *running_ticket;
-
+
/* this is needed by the engine to decrement the reference counter
* on disposal of the plugin, but since this is useful, we expose it */
xine_t *xine;
-
+
/* used when the user requests a list of all inputs/outputs */
const char **input_ids;
const char **output_ids;
@@ -125,10 +125,10 @@ struct post_in_s {
/* public part of the input */
xine_post_in_t xine_in;
-
+
/* backward reference so that you have access to the post plugin */
post_plugin_t *post;
-
+
/* you can fill this to your liking */
void *user_data;
};
@@ -137,10 +137,10 @@ struct post_out_s {
/* public part of the output */
xine_post_out_t xine_out;
-
+
/* backward reference so that you have access to the post plugin */
post_plugin_t *post;
-
+
/* you can fill this to your liking */
void *user_data;
};
@@ -164,52 +164,52 @@ struct post_video_port_s {
/* the new public port with replaced function pointers */
xine_video_port_t new_port;
-
+
/* the original port to call its functions from inside yours */
xine_video_port_t *original_port;
-
+
/* if you want to decide yourself, whether a given frame should
* be intercepted, fill in this function; get_frame() acts as
* a template method and asks your function; return a boolean;
* the default is to intercept all frames */
int (*intercept_frame)(post_video_port_t *self, vo_frame_t *frame);
-
+
/* the new frame function pointers */
vo_frame_t *new_frame;
-
+
/* if you want to decide yourself, whether the overlay manager should
* be intercepted, fill in this function; get_overlay_manager() acts as
* a template method and asks your function; return a boolean;
* the default is _not_ to intercept the overlay manager */
int (*intercept_ovl)(post_video_port_t *self);
-
+
/* the new public overlay manager with replaced function pointers */
video_overlay_manager_t *new_manager;
-
+
/* the original manager to call its functions from inside yours */
video_overlay_manager_t *original_manager;
-
+
/* usage counter: how many objects are floating around that need
* these pointers to exist */
int usage_count;
pthread_mutex_t usage_lock;
-
+
/* the stream we are being fed by; NULL means no stream is connected;
* this may be an anonymous stream */
xine_stream_t *stream;
-
+
/* point to a mutex here, if you need some synchronization */
pthread_mutex_t *port_lock;
pthread_mutex_t *frame_lock;
pthread_mutex_t *manager_lock;
-
+
/* backward reference so that you have access to the post plugin
* when the call only gives you the port */
post_plugin_t *post;
-
+
/* you can fill this to your liking */
void *user_data;
-
+
#ifdef POST_INTERNAL
/* some of the above members are to be directly included here, but
* adding the structures would mean that post_video_port_t becomes
@@ -217,13 +217,13 @@ struct post_video_port_s {
* above and have them point into the memory provided here;
* note that the overlay manager needs to be first so that we can
* reconstruct the post_video_port_t* from overlay manager calls */
-
+
/* any change here requires a change in _x_post_ovl_manager_to_port()
* below! */
-
+
video_overlay_manager_t manager_storage;
vo_frame_t frame_storage;
-
+
/* this is used to keep a linked list of free vo_frame_t's */
vo_frame_t *free_frame_slots;
pthread_mutex_t free_frames_lock;
@@ -283,31 +283,31 @@ struct post_audio_port_s {
/* the new public port with replaced function pointers */
xine_audio_port_t new_port;
-
+
/* the original port to call its functions from inside yours */
xine_audio_port_t *original_port;
-
+
/* usage counter: how many objects are floating around that need
* these pointers to exist */
int usage_count;
pthread_mutex_t usage_lock;
-
+
/* the stream we are being fed by; NULL means no stream is connected;
* this may be an anonymous stream */
xine_stream_t *stream;
-
+
/* some values remembered by port->open() */
uint32_t bits;
uint32_t rate;
uint32_t mode;
-
+
/* point to a mutex here, if you need some synchronization */
pthread_mutex_t *port_lock;
-
+
/* backward reference so that you have access to the post plugin
* when the call only gives you the port */
post_plugin_t *post;
-
+
/* you can fill this to your liking */
void *user_data;
};
@@ -369,7 +369,7 @@ do { \
} while(0)
-/* macros to create parameter descriptors */
+/* macros to create parameter descriptors */
#define START_PARAM_DESCR( param_t ) \
static param_t temp_s; \
diff --git a/src/xine-engine/refcounter.c b/src/xine-engine/refcounter.c
index 539abf3ed..23da4bdbc 100644
--- a/src/xine-engine/refcounter.c
+++ b/src/xine-engine/refcounter.c
@@ -1,28 +1,33 @@
/*
* 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
*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#define LOG_MODULE "refcounter"
#define LOG_VERBOSE
/*
#define LOG
*/
-
+
#include "xine_internal.h"
#include "refcounter.h"
@@ -30,7 +35,7 @@ refcounter_t* _x_new_refcounter(void *object, void (*destructor)(void *))
{
refcounter_t *new_refcounter;
- new_refcounter = (refcounter_t *) xine_xmalloc (sizeof (refcounter_t));
+ new_refcounter = (refcounter_t *) calloc(1, sizeof(refcounter_t));
new_refcounter->count = 1;
new_refcounter->object = object;
new_refcounter->destructor = destructor;
@@ -48,7 +53,7 @@ int _x_refcounter_inc(refcounter_t *refcounter)
_x_abort();
res = ++refcounter->count;
pthread_mutex_unlock(&refcounter->lock);
-
+
return res;
}
@@ -63,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/refcounter.h b/src/xine-engine/refcounter.h
index 87abd6321..f157d8b6c 100644
--- a/src/xine-engine/refcounter.h
+++ b/src/xine-engine/refcounter.h
@@ -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
@@ -20,10 +20,6 @@
#ifndef HAVE_REFCOUNTER_H
#define HAVE_REFCOUNTER_H
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <pthread.h>
typedef struct {
@@ -35,7 +31,7 @@ typedef struct {
typedef void (*refcounter_destructor)(void*);
-refcounter_t* _x_new_refcounter(void *object, refcounter_destructor destructor) XINE_PROTECTED;
+refcounter_t* _x_new_refcounter(void *object, refcounter_destructor destructor) XINE_MALLOC XINE_PROTECTED;
int _x_refcounter_inc(refcounter_t *refcounter) XINE_PROTECTED;
diff --git a/src/xine-engine/resample.c b/src/xine-engine/resample.c
index 43911c401..dcf14a215 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/resample.h b/src/xine-engine/resample.h
index 40b4de486..842434cf0 100644
--- a/src/xine-engine/resample.h
+++ b/src/xine-engine/resample.h
@@ -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
@@ -28,35 +28,35 @@
#define RESAMPLE_MAX_CHANNELS 6
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) XINE_PROTECTED;
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) XINE_PROTECTED;
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) XINE_PROTECTED;
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) XINE_PROTECTED;
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) XINE_PROTECTED;
-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) XINE_PROTECTED;
-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) XINE_PROTECTED;
-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) XINE_PROTECTED;
-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) XINE_PROTECTED;
-
+
#endif
diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c
index 38b606b84..39bb5927a 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
@@ -37,7 +37,7 @@
#include "xineutils.h"
#include "scratch.h"
-static void __attribute__((__format__(__printf__, 2, 0)))
+static void XINE_FORMAT_PRINTF(2, 0)
scratch_printf (scratch_buffer_t *this, const char *format, va_list argp)
{
time_t t;
@@ -50,12 +50,11 @@ static void __attribute__((__format__(__printf__, 2, 0)))
localtime_r (&t, &tm);
if ( ! this->lines[this->cur] )
- this->lines[this->cur] = xine_xmalloc(SCRATCH_LINE_LEN_MAX+1);
+ this->lines[this->cur] = malloc(SCRATCH_LINE_LEN_MAX+1);
if ( ! this->lines[this->cur] )
return;
- strftime (this->lines[this->cur], SCRATCH_LINE_LEN_MAX, "%X: ", &tm);
- l = strlen (this->lines[this->cur]);
+ l = strftime (this->lines[this->cur], SCRATCH_LINE_LEN_MAX, "%X: ", &tm);
vsnprintf (this->lines[this->cur] + l, SCRATCH_LINE_LEN_MAX - l, format, argp);
lprintf ("printing format %s to line %d\n", format, this->cur);
@@ -86,14 +85,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);
@@ -105,15 +104,11 @@ static void scratch_dispose (scratch_buffer_t *this) {
scratch_buffer_t *_x_new_scratch_buffer (int num_lines) {
scratch_buffer_t *this;
- int i;
-
- this = xine_xmalloc (sizeof (scratch_buffer_t));
- this->lines = xine_xmalloc (sizeof (char *) * (num_lines + 1));
- this->ordered = xine_xmalloc (sizeof (char *) * (num_lines + 1));
+ this = calloc(1, sizeof(scratch_buffer_t));
- for (i = 0; i <= num_lines; i++)
- this->lines[i] = this->ordered[i] = NULL;
+ this->lines = calloc ((num_lines + 1), sizeof(char*));
+ this->ordered = calloc ((num_lines + 1), sizeof(char*));
this->scratch_printf = scratch_printf;
this->get_content = scratch_get_content;
diff --git a/src/xine-engine/scratch.h b/src/xine-engine/scratch.h
index c0e591d31..c0c927b97 100644
--- a/src/xine-engine/scratch.h
+++ b/src/xine-engine/scratch.h
@@ -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
@@ -32,10 +32,7 @@ typedef struct scratch_buffer_s scratch_buffer_t;
struct scratch_buffer_s {
- void
-#if __GNUC__ >= 3
- __attribute__((__format__(__printf__, 2, 0)))
-#endif
+ void XINE_FORMAT_PRINTF(2, 0)
(*scratch_printf) (scratch_buffer_t *this, const char *format, va_list ap);
char **(*get_content) (scratch_buffer_t *this);
@@ -51,6 +48,6 @@ struct scratch_buffer_s {
pthread_mutex_t lock;
};
-scratch_buffer_t *_x_new_scratch_buffer (int num_lines) XINE_PROTECTED;
+scratch_buffer_t *_x_new_scratch_buffer (int num_lines) XINE_MALLOC XINE_PROTECTED;
#endif
diff --git a/src/xine-engine/spu_decoder.h b/src/xine-engine/spu_decoder.h
index 66ab5e54a..4897a32a2 100644
--- a/src/xine-engine/spu_decoder.h
+++ b/src/xine-engine/spu_decoder.h
@@ -4,7 +4,7 @@
* Copyright (C) James Courtier-Dutton James@superbug.demon.co.uk - July 2001
*
* This file is part of xine, a unix 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
@@ -14,10 +14,10 @@
* 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 GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation,
+ * the Free Software Foundation,
*
*/
@@ -47,30 +47,30 @@ struct spu_decoder_class_s {
* open a new instance of this plugin class
*/
spu_decoder_t* (*open_plugin) (spu_decoder_class_t *this, xine_stream_t *stream);
-
+
/*
* return short, human readable identifier for this plugin class
*/
char* (*get_identifier) (spu_decoder_class_t *this);
/*
- * return human readable (verbose = 1 line) description for
+ * return human readable (verbose = 1 line) description for
* this plugin class
*/
char* (*get_description) (spu_decoder_class_t *this);
-
+
/*
* free all class-related resources
*/
void (*dispose) (spu_decoder_class_t *this);
};
-
-
+
+
struct spu_decoder_s {
/*
* decode data from buf and feed the overlay to overlay manager
- */
+ */
void (*decode_data) (spu_decoder_t *this, buf_element_t *buf);
/*
@@ -78,7 +78,7 @@ struct spu_decoder_s {
* SPU data not related to recently decoded data)
*/
void (*reset) (spu_decoder_t *this);
-
+
/*
* inform decoder that a time reference discontinuity has happened.
* that is, it must forget any currently held pts value
diff --git a/src/xine-engine/tvmode.c b/src/xine-engine/tvmode.c
index 099bdb808..1d6660f4f 100644
--- a/src/xine-engine/tvmode.c
+++ b/src/xine-engine/tvmode.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
diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c
index c88e01714..0756fc5b2 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
@@ -45,13 +45,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);
@@ -63,27 +63,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 */
@@ -92,9 +92,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;
}
@@ -117,7 +117,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)
@@ -125,15 +125,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);
@@ -143,34 +143,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( !stream->gapless_switch )
- stream->metronom->handle_video_discontinuity (stream->metronom,
+
+ if( !(buf->decoder_flags & BUF_FLAG_GAPLESS_SW) )
+ 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. */
@@ -179,7 +179,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;
@@ -189,7 +189,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);
@@ -210,12 +210,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);
@@ -229,7 +229,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);
@@ -246,7 +246,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 */
@@ -261,7 +261,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;
@@ -297,7 +297,7 @@ static void *video_decoder_loop (void *stream_gen) {
running_ticket->release(running_ticket, 0);
}
break;
-
+
case BUF_CONTROL_DISCONTINUITY:
lprintf ("discontinuity ahead\n");
@@ -309,11 +309,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);
@@ -325,14 +325,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;
@@ -345,7 +345,7 @@ static void *video_decoder_loop (void *stream_gen) {
case BUF_CONTROL_NOP:
break;
-
+
default:
if ( (buf->type & 0xFF000000) == BUF_VIDEO_BASE ) {
@@ -354,43 +354,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);
@@ -401,7 +401,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 ) {
@@ -414,15 +414,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;
@@ -458,15 +458,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;
}
@@ -478,13 +478,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;
@@ -495,7 +495,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,
@@ -505,15 +505,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);
@@ -529,7 +529,7 @@ int _x_video_decoder_init (xine_stream_t *stream) {
pthread_attr_destroy(&pth_attrs);
return 0;
}
-
+
pthread_attr_destroy(&pth_attrs);
}
return 1;
@@ -561,7 +561,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_decoder.h b/src/xine-engine/video_decoder.h
index 7b13159a3..f7068cc13 100644
--- a/src/xine-engine/video_decoder.h
+++ b/src/xine-engine/video_decoder.h
@@ -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
@@ -47,14 +47,14 @@ struct video_decoder_class_s {
* open a new instance of this plugin class
*/
video_decoder_t* (*open_plugin) (video_decoder_class_t *this, xine_stream_t *stream);
-
+
/*
* return short, human readable identifier for this plugin class
*/
char* (*get_identifier) (video_decoder_class_t *this);
/*
- * return human readable (verbose = 1 line) description for
+ * return human readable (verbose = 1 line) description for
* this plugin class
*/
char* (*get_description) (video_decoder_class_t *this);
@@ -69,8 +69,8 @@ struct video_decoder_class_s {
struct video_decoder_s {
/*
- * decode data from buf and feed decoded frames to
- * video output
+ * decode data from buf and feed decoded frames to
+ * video output
*/
void (*decode_data) (video_decoder_t *this, buf_element_t *buf);
@@ -79,13 +79,13 @@ struct video_decoder_s {
* video data not related to recently decoded data)
*/
void (*reset) (video_decoder_t *this);
-
+
/*
* inform decoder that a time reference discontinuity has happened.
* that is, it must forget any currently held pts value
*/
void (*discontinuity) (video_decoder_t *this);
-
+
/*
* flush out any frames that are still stored in the decoder
*/
@@ -94,7 +94,7 @@ struct video_decoder_s {
/*
* close down, free all resources
*/
- void (*dispose) (video_decoder_t *this);
+ void (*dispose) (video_decoder_t *this);
void *node; /*used by plugin loader */
diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c
index a8464ac40..0b6d8f7a1 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;
@@ -139,11 +139,11 @@ typedef struct {
* frame queue (fifo) util functions
*/
-static img_buf_fifo_t *vo_new_img_buf_queue () {
+static img_buf_fifo_t *XINE_MALLOC vo_new_img_buf_queue () {
img_buf_fifo_t *queue;
- queue = (img_buf_fifo_t *) xine_xmalloc (sizeof (img_buf_fifo_t));
+ queue = (img_buf_fifo_t *) calloc(1, sizeof(img_buf_fifo_t));
if( queue ) {
queue->first = NULL;
queue->last = NULL;
@@ -215,7 +215,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) {
@@ -263,7 +263,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;
@@ -272,7 +272,7 @@ static vo_frame_t *vo_remove_from_img_buf_queue_int (img_buf_fifo_t *queue, int
queue->num_buffers--;
}
}
-
+
return img;
}
@@ -303,7 +303,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++;
@@ -312,11 +312,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);
@@ -333,11 +333,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];
@@ -362,7 +362,7 @@ static void vo_frame_driver_proc(vo_frame_t *img)
}
/*
- *
+ *
* functions called by video decoder:
*
* get_frame => alloc frame for rendering
@@ -393,7 +393,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;
@@ -418,11 +418,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;
@@ -439,11 +439,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 );
@@ -465,13 +465,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
@@ -497,7 +497,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
@@ -515,7 +515,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;
@@ -528,18 +528,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)) ) {
@@ -556,11 +556,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
*/
@@ -594,7 +594,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");
@@ -626,7 +626,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;
@@ -635,7 +635,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);
@@ -663,8 +663,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);
}
@@ -672,7 +672,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;
}
@@ -682,9 +682,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()
@@ -709,7 +709,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;
@@ -726,16 +726,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(
@@ -761,8 +761,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;
@@ -773,10 +773,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;
}
@@ -789,7 +789,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;
/*
@@ -806,7 +806,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 ) {
@@ -828,21 +828,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 );
@@ -851,21 +851,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");
@@ -875,20 +875,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);
}
@@ -897,16 +897,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:
*/
@@ -931,11 +931,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--;
@@ -967,13 +967,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 ||
@@ -989,7 +989,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);
@@ -997,7 +997,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;
@@ -1009,19 +1009,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);
}
@@ -1034,7 +1034,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
*/
@@ -1054,16 +1054,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;
}
@@ -1071,36 +1071,36 @@ static void check_redraw_needed (vos_t *this, int64_t vpts) {
/* 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 ) {
@@ -1109,16 +1109,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 );
xine_usec_sleep (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 );
@@ -1131,7 +1131,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
@@ -1145,7 +1145,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 ) {
@@ -1185,7 +1185,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)) {
@@ -1193,9 +1193,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;
@@ -1215,12 +1215,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);
@@ -1237,11 +1237,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)
xine_usec_sleep (usec_to_sleep);
@@ -1254,7 +1254,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) {
@@ -1297,9 +1297,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) {
@@ -1316,7 +1316,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);
@@ -1335,7 +1335,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;
@@ -1377,7 +1377,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;
@@ -1400,17 +1400,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)
*/
@@ -1426,7 +1426,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:
@@ -1444,12 +1444,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);
@@ -1463,7 +1463,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);
@@ -1473,19 +1473,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);
@@ -1515,32 +1515,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 );
@@ -1574,7 +1574,7 @@ static int vo_status (xine_video_port_t *this_gen, xine_stream_t *stream,
}
}
pthread_mutex_unlock(&this->streams_lock);
-
+
return ret;
}
@@ -1619,7 +1619,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);
@@ -1635,7 +1635,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) {
@@ -1645,7 +1645,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;
@@ -1678,7 +1678,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);
@@ -1688,7 +1688,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);
@@ -1703,29 +1703,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 */
@@ -1742,7 +1742,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;
@@ -1755,10 +1755,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;
}
@@ -1771,16 +1771,16 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabon
int num_frame_buffers;
- this = xine_xmalloc (sizeof (vos_t)) ;
+ this = calloc(1, sizeof(vos_t)) ;
this->xine = xine;
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;
@@ -1804,7 +1804,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;
@@ -1826,7 +1826,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.
@@ -1858,7 +1858,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;
@@ -1870,13 +1870,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 "
@@ -1903,14 +1903,14 @@ 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) {
- xprintf (this->xine, XINE_VERBOSITY_DEBUG, "video_out: can't create thread (%s)\n", strerror(err));
+ xprintf (this->xine, XINE_VERBOSITY_NONE, "video_out: can't create thread (%s)\n", strerror(err));
/* FIXME: how does this happen ? */
xprintf (this->xine, XINE_VERBOSITY_LOG,
_("video_out: sorry, this should not happen. please restart xine.\n"));
@@ -1918,7 +1918,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_out.h b/src/xine-engine/video_out.h
index 4d9c80565..b1a517565 100644
--- a/src/xine-engine/video_out.h
+++ b/src/xine-engine/video_out.h
@@ -1,24 +1,24 @@
/*
* 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
*
*
- * xine version of video_out.h
+ * xine version of video_out.h
*
* vo_frame : frame containing yuv data and timing info,
* transferred between video_decoder and video_output
@@ -36,10 +36,6 @@
extern "C" {
#endif
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#include <pthread.h>
#ifdef XINE_COMPILE
@@ -51,7 +47,7 @@ extern "C" {
#endif
-typedef struct vo_frame_s vo_frame_t;
+typedef struct vo_frame_s vo_frame_t;
typedef struct vo_driver_s vo_driver_t;
typedef struct video_driver_class_s video_driver_class_t;
typedef struct vo_overlay_s vo_overlay_t;
@@ -84,7 +80,7 @@ struct vo_frame_s {
/* tell video driver that the decoder starts a new field */
void (*field) (vo_frame_t *vo_img, int which_field);
- /* append this frame to the display queue,
+ /* append this frame to the display queue,
returns number of frames to skip if decoder is late */
/* when the frame does not originate from a stream, it is legal to pass an anonymous stream */
int (*draw) (vo_frame_t *vo_img, xine_stream_t *stream);
@@ -112,7 +108,7 @@ struct vo_frame_s {
/* yv12 (planar) base[0]: y, base[1]: u, base[2]: v */
/* yuy2 (interleaved) base[0]: yuyv..., base[1]: --, base[2]: -- */
- uint8_t *base[3];
+ uint8_t *base[3];
int pitches[3];
/* info that can be used for interlaced output (e.g. tv-out) */
@@ -123,13 +119,13 @@ struct vo_frame_s {
*/
int progressive_frame;
int picture_coding_type;
-
+
/* cropping to be done */
int crop_left, crop_right, crop_top, crop_bottom;
/* extra info coming from input or demuxers */
- extra_info_t *extra_info;
-
+ extra_info_t *extra_info;
+
/* additional information to be able to duplicate frames: */
int width, height;
double ratio; /* aspect ratio */
@@ -138,7 +134,7 @@ struct vo_frame_s {
int drawn; /* used by decoder, frame has already been drawn */
int flags; /* remember the frame flags */
int proc_called; /* track use of proc_*() methods */
-
+
/* Used to carry private data for accelerated plugins.*/
void *accel_data;
@@ -146,18 +142,18 @@ struct vo_frame_s {
xine_video_port_t *port;
vo_driver_t *driver;
xine_stream_t *stream;
-
+
/* displacement for overlays */
int overlay_offset_x, overlay_offset_y;
-
- /*
+
+ /*
* that part is used only by video_out.c for frame management
* obs: changing anything here will require recompiling vo drivers
*/
struct vo_frame_s *next;
int lock_counter;
pthread_mutex_t mutex; /* protect access to lock_count */
-
+
int id; /* debugging - track this frame */
int is_first;
};
@@ -177,8 +173,8 @@ struct xine_video_port_s {
* (e.g. you are a post plugin) it is legal to pass an anonymous stream */
void (*open) (xine_video_port_t *self, xine_stream_t *stream);
- /*
- * get_frame - allocate an image buffer from display driver
+ /*
+ * get_frame - allocate an image buffer from display driver
*
* params : width == width of video to display.
* height == height of video to display.
@@ -186,16 +182,16 @@ struct xine_video_port_s {
* format == FOURCC descriptor of image format
* flags == field/prediction flags
*/
- vo_frame_t* (*get_frame) (xine_video_port_t *self, uint32_t width,
- uint32_t height, double ratio,
+ vo_frame_t* (*get_frame) (xine_video_port_t *self, uint32_t width,
+ uint32_t height, double ratio,
int format, int flags);
/* retrieves the last displayed frame (useful for taking snapshots) */
vo_frame_t* (*get_last_frame) (xine_video_port_t *self);
-
+
/* overlay stuff */
void (*enable_ovl) (xine_video_port_t *self, int ovl_enable);
-
+
/* get overlay manager */
video_overlay_manager_t* (*get_overlay_manager) (xine_video_port_t *self);
@@ -208,11 +204,11 @@ struct xine_video_port_s {
*/
int (*get_property) (xine_video_port_t *self, int property);
int (*set_property) (xine_video_port_t *self, int property, int value);
-
+
/* return true if port is opened for this stream, stream can be anonymous */
- int (*status) (xine_video_port_t *self, xine_stream_t *stream,
+ int (*status) (xine_video_port_t *self, xine_stream_t *stream,
int *width, int *height, int64_t *img_duration);
-
+
/* video driver is no longer used by decoder => close */
/* when you are not a full-blown stream, but still need to close the port
* (e.g. you are a post plugin) it is legal to pass an anonymous stream */
@@ -235,9 +231,9 @@ struct xine_video_port_s {
#define VO_PROP_BRIGHTNESS 5
#define VO_PROP_COLORKEY 6
#define VO_PROP_AUTOPAINT_COLORKEY 7
-#define VO_PROP_ZOOM_X 8
-#define VO_PROP_PAN_SCAN 9
-#define VO_PROP_TVMODE 10
+#define VO_PROP_ZOOM_X 8
+#define VO_PROP_PAN_SCAN 9
+#define VO_PROP_TVMODE 10
#define VO_PROP_MAX_NUM_FRAMES 11
#define VO_PROP_ZOOM_Y 13
#define VO_PROP_DISCARD_FRAMES 14 /* not used by drivers */
@@ -303,7 +299,7 @@ struct vo_driver_s {
*/
vo_frame_t* (*alloc_frame) (vo_driver_t *self);
- /*
+ /*
* check if the given image fullfills the format specified
* (re-)allocate memory if necessary
*/
@@ -334,7 +330,7 @@ struct vo_driver_s {
* these can be used by the gui directly:
*/
int (*get_property) (vo_driver_t *self, int property);
- int (*set_property) (vo_driver_t *self,
+ int (*set_property) (vo_driver_t *self,
int property, int value);
void (*get_property_min_max) (vo_driver_t *self,
int property, int *min, int *max);
@@ -349,7 +345,7 @@ struct vo_driver_s {
void *data);
/* check if a redraw is needed (due to resize)
- * this is only used for still frames, normal video playback
+ * this is only used for still frames, normal video playback
* must call that inside display_frame() function.
*/
int (*redraw_needed) (vo_driver_t *self);
@@ -358,7 +354,7 @@ struct vo_driver_s {
* free all resources, close driver
*/
void (*dispose) (vo_driver_t *self);
-
+
void *node; /* needed by plugin_loader */
};
@@ -368,14 +364,14 @@ struct video_driver_class_s {
* open a new instance of this plugin class
*/
vo_driver_t* (*open_plugin) (video_driver_class_t *self, const void *visual);
-
+
/*
* return short, human readable identifier for this plugin class
*/
char* (*get_identifier) (video_driver_class_t *self);
/*
- * return human readable (verbose = 1 line) description for
+ * return human readable (verbose = 1 line) description for
* this plugin class
*/
char* (*get_description) (video_driver_class_t *self);
@@ -401,7 +397,7 @@ struct vo_overlay_s {
int y; /* y start of subpicture area */
int width; /* width of subpicture area */
int height; /* height of subpicture area */
-
+
uint32_t color[OVL_PALETTE_SIZE]; /* color lookup table */
uint8_t trans[OVL_PALETTE_SIZE]; /* mixer key table */
int rgb_clut; /* true if clut was converted to rgb */
@@ -414,7 +410,7 @@ struct vo_overlay_s {
uint32_t hili_color[OVL_PALETTE_SIZE];
uint8_t hili_trans[OVL_PALETTE_SIZE];
int hili_rgb_clut; /* true if clut was converted to rgb */
-
+
int unscaled; /* true if it should be blended unscaled */
};
@@ -427,20 +423,20 @@ struct vo_overlay_s {
*/
struct video_overlay_manager_s {
void (*init) (video_overlay_manager_t *this_gen);
-
+
void (*dispose) (video_overlay_manager_t *this_gen);
-
+
int32_t (*get_handle) (video_overlay_manager_t *this_gen, int object_type );
-
+
void (*free_handle) (video_overlay_manager_t *this_gen, int32_t handle);
-
+
int32_t (*add_event) (video_overlay_manager_t *this_gen, void *event);
-
+
void (*flush_events) (video_overlay_manager_t *this_gen );
-
+
int (*redraw_needed) (video_overlay_manager_t *this_gen, int64_t vpts );
-
- void (*multiple_overlay_blend) (video_overlay_manager_t *this_gen, int64_t vpts,
+
+ void (*multiple_overlay_blend) (video_overlay_manager_t *this_gen, int64_t vpts,
vo_driver_t *output, vo_frame_t *vo_img, int enabled);
};
@@ -448,7 +444,7 @@ struct video_overlay_manager_s {
* build a video_out_port from
* a given video driver
*/
-xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabonly) XINE_PROTECTED;
+xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabonly) XINE_MALLOC XINE_PROTECTED;
#ifdef __cplusplus
}
diff --git a/src/xine-engine/video_overlay.c b/src/xine-engine/video_overlay.c
index c189fa56b..3216950e8 100644
--- a/src/xine-engine/video_overlay.c
+++ b/src/xine-engine/video_overlay.c
@@ -1,23 +1,27 @@
/*
* 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
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -47,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;
@@ -63,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 );
}
@@ -90,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 );
}
@@ -106,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 );
}
@@ -145,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;
@@ -195,11 +199,11 @@ 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) {
- this->events[i].event = xine_xmalloc (sizeof(video_overlay_event_t));
+ this->events[i].event = calloc(1, sizeof(video_overlay_event_t));
#ifdef LOG_DEBUG
printf ("video_overlay: MALLOC2: this->events[%d].event %p, len=%d\n",
i,
@@ -208,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;
}
@@ -230,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);
}
@@ -252,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;
@@ -270,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");
@@ -283,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++) {
@@ -293,8 +297,8 @@ static int32_t video_overlay_add_event(video_overlay_manager_t *this_gen, void
event->object.overlay->hili_trans[i] = OVL_MAX_OPACITY;
}
- this->events[new_event].event->object.overlay = xine_xmalloc (sizeof(vo_overlay_t));
- xine_fast_memcpy(this->events[new_event].event->object.overlay,
+ this->events[new_event].event->object.overlay = calloc(1, sizeof(vo_overlay_t));
+ 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 */
@@ -307,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;
}
@@ -331,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
/*
@@ -343,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) ) {
@@ -371,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");
@@ -395,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);
@@ -419,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
@@ -429,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;
@@ -442,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
@@ -473,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;
}
@@ -571,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);
@@ -587,7 +591,7 @@ video_overlay_manager_t *_x_video_overlay_new_manager (xine_t *xine) {
video_overlay_t *this;
- this = (video_overlay_t *) xine_xmalloc (sizeof (video_overlay_t));
+ this = (video_overlay_t *) calloc(1, sizeof(video_overlay_t));
this->xine = xine;
this->video_overlay.init = video_overlay_init;
diff --git a/src/xine-engine/video_overlay.h b/src/xine-engine/video_overlay.h
index d580a1e83..f2deb8a2b 100644
--- a/src/xine-engine/video_overlay.h
+++ b/src/xine-engine/video_overlay.h
@@ -2,17 +2,17 @@
* 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
@@ -50,7 +50,7 @@
#define OVL_PALETTE_SIZE 256
typedef struct vo_buttons_s {
- int32_t type; /* 0:Button not valid,
+ int32_t type; /* 0:Button not valid,
1:Button Valid, no auto_action,
2:Button Valid, auto_action.
*/
@@ -61,10 +61,10 @@ typedef struct vo_buttons_s {
int32_t hili_bottom;
int32_t hili_left;
int32_t hili_right;
- int32_t up;
- int32_t down;
- int32_t left;
- int32_t right;
+ int32_t up;
+ int32_t down;
+ int32_t left;
+ int32_t right;
uint32_t select_color[OVL_PALETTE_SIZE];
uint8_t select_trans[OVL_PALETTE_SIZE];
xine_event_t select_event;
@@ -74,7 +74,7 @@ typedef struct vo_buttons_s {
int32_t hili_rgb_clut; /* true if clut was converted to rgb*/
/* FIXME: Probably not needed ^^^ */
} vo_buttons_t;
-
+
typedef struct video_overlay_object_s {
int32_t handle; /* Used to match Show and Hide events. */
uint32_t object_type; /* 0=Subtitle, 1=Menu */
@@ -98,6 +98,6 @@ typedef struct video_overlay_event_s {
video_overlay_object_t object; /* The image data. */
} video_overlay_event_t;
-video_overlay_manager_t *_x_video_overlay_new_manager(xine_t *) XINE_PROTECTED;
+video_overlay_manager_t *_x_video_overlay_new_manager(xine_t *) XINE_MALLOC XINE_PROTECTED;
#endif
diff --git a/src/xine-engine/vo_scale.c b/src/xine-engine/vo_scale.c
index ff30c47a6..e2b7ac9e4 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
@@ -22,6 +22,10 @@
* Takes into account aspect ratio correction and zooming.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <string.h>
#include <math.h>
@@ -49,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;
@@ -76,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)
@@ -85,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)
@@ -103,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;
@@ -124,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.
@@ -134,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;
@@ -147,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;
@@ -158,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;
@@ -170,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;
@@ -215,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;
@@ -248,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 );
@@ -273,7 +277,7 @@ int _x_vo_scale_redraw_needed (vo_scale_t *this) {
}
else
ret = this->force_redraw;
-
+
this->force_redraw = 0;
return ret;
}
@@ -302,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;
}
@@ -339,21 +343,21 @@ char *_x_vo_scale_aspect_ratio_name(int a) {
*/
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;
@@ -361,13 +365,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;
@@ -376,13 +380,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/vo_scale.h b/src/xine-engine/vo_scale.h
index 829405162..fe2594eeb 100644
--- a/src/xine-engine/vo_scale.h
+++ b/src/xine-engine/vo_scale.h
@@ -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
@@ -29,10 +29,6 @@
extern "C" {
#endif
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
#ifdef XINE_COMPILE
# include "configfile.h"
#else
@@ -48,22 +44,22 @@ struct vo_scale_s {
/* true if driver supports frame zooming */
int support_zoom;
-
+
/* forces direct mapping between frame pixels and screen pixels */
int scaling_disabled;
-
+
/* size / aspect ratio calculations */
- /*
+ /*
* "delivered" size:
* frame dimension / aspect as delivered by the decoder
* used (among other things) to detect frame size changes
* units: frame pixels
*/
- int delivered_width;
- int delivered_height;
+ int delivered_width;
+ int delivered_height;
double delivered_ratio;
-
+
/*
* required cropping:
* units: frame pixels
@@ -73,7 +69,7 @@ struct vo_scale_s {
int crop_top;
int crop_bottom;
- /*
+ /*
* displayed part of delivered images,
* taking zoom into account
* units: frame pixels
@@ -97,7 +93,7 @@ struct vo_scale_s {
int gui_x, gui_y;
int gui_width, gui_height;
int gui_win_x, gui_win_y;
-
+
/*
* video + display pixel aspect
* One pixel of height 1 has this width
@@ -117,11 +113,11 @@ struct vo_scale_s {
int output_height;
int output_xoffset;
int output_yoffset;
-
+
/* */
int force_redraw;
-
+
/* gui callbacks */
@@ -129,13 +125,13 @@ struct vo_scale_s {
void (*frame_output_cb) (void *user_data,
int video_width, int video_height,
double video_pixel_aspect,
- int *dest_x, int *dest_y,
+ int *dest_x, int *dest_y,
int *dest_width, int *dest_height,
double *dest_pixel_aspect,
int *win_x, int *win_y);
-
+
void (*dest_size_cb) (void *user_data,
- int video_width, int video_height,
+ int video_width, int video_height,
double video_pixel_aspect,
int *dest_width, int *dest_height,
double *dest_pixel_aspect);
@@ -149,10 +145,10 @@ struct vo_scale_s {
*/
double output_horizontal_position;
double output_vertical_position;
-
+
};
-typedef struct vo_scale_s vo_scale_t;
+typedef struct vo_scale_s vo_scale_t;
/*
@@ -179,7 +175,7 @@ int _x_vo_scale_redraw_needed (vo_scale_t *self) XINE_PROTECTED;
/*
*
*/
-
+
void _x_vo_scale_translate_gui2video(vo_scale_t *self,
int x, int y,
int *vid_x, int *vid_y) XINE_PROTECTED;
@@ -190,11 +186,11 @@ void _x_vo_scale_translate_gui2video(vo_scale_t *self,
char *_x_vo_scale_aspect_ratio_name(int a) XINE_PROTECTED;
-/*
+/*
* initialize rescaling struct
*/
-
-void _x_vo_scale_init(vo_scale_t *self, int support_zoom,
+
+void _x_vo_scale_init(vo_scale_t *self, int support_zoom,
int scaling_disabled, config_values_t *config ) XINE_PROTECTED;
#ifdef __cplusplus
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index eae13bec9..9f63d793c 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
@@ -36,6 +36,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
+#include <unistd.h>
#if defined (__linux__) || defined (__GLIBC__)
#include <endian.h>
#elif defined (__FreeBSD__)
@@ -92,7 +93,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;
@@ -132,7 +133,7 @@ static int acquire_allowed_to_block(xine_ticket_t *this) {
unsigned new_size;
for(entry = 0; entry < this->holder_thread_count; ++entry) {
- if(this->holder_threads[entry].holder == own_id) {
+ if(pthread_equal(this->holder_threads[entry].holder, own_id)) {
/* This thread may already hold this ticket */
this->holder_threads[entry].count++;
return (this->holder_threads[entry].count == 1);
@@ -150,7 +151,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);
@@ -159,15 +160,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()))
@@ -181,12 +182,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;
}
@@ -201,9 +202,9 @@ 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(this->holder_threads[entry].holder == own_id) {
+ if(pthread_equal(this->holder_threads[entry].holder, own_id)) {
this->holder_threads[entry].count--;
return this->holder_threads[entry].count == 0;
}
@@ -217,18 +218,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);
}
@@ -243,17 +244,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);
}
@@ -262,12 +263,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);
}
@@ -276,7 +277,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)
@@ -287,7 +288,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);
@@ -299,15 +300,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 *ticket_init(void) {
+static xine_ticket_t *XINE_MALLOC ticket_init(void) {
xine_ticket_t *port_ticket;
-
- port_ticket = (xine_ticket_t *) xine_xmalloc(sizeof(xine_ticket_t));
-
+
+ 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;
@@ -318,37 +319,44 @@ static xine_ticket_t *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_cond_init(&port_ticket->issued, NULL);
pthread_cond_init(&port_ticket->revoked, NULL);
-
+
return port_ticket;
}
static void set_speed_internal (xine_stream_t *stream, int speed) {
xine_t *xine = stream->xine;
+ int old_speed = xine->clock->speed;
- if (xine->clock->speed != XINE_SPEED_PAUSE && speed == XINE_SPEED_PAUSE)
+ 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 (xine->clock->speed == XINE_SPEED_PAUSE && speed != XINE_SPEED_PAUSE)
+
+ 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);
-
- stream->xine->clock->set_fine_speed (stream->xine->clock, speed);
+
+ 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);
}
@@ -398,18 +406,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);
}
@@ -418,6 +426,7 @@ void xine_stop (xine_stream_t *stream) {
static void close_internal (xine_stream_t *stream) {
int i ;
+ int gapless_switch = stream->gapless_switch;
if( stream->slave ) {
xine_close( stream->slave );
@@ -428,32 +437,32 @@ static void close_internal (xine_stream_t *stream) {
}
}
- if( !stream->gapless_switch ) {
+ if( !gapless_switch ) {
/* make sure that other threads cannot change the speed, especially pauseing the stream */
pthread_mutex_lock(&stream->speed_change_lock);
stream->ignore_speed_change = 1;
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( !stream->gapless_switch ) {
+
+ 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;
@@ -515,14 +524,14 @@ static int stream_rewire_audio(xine_post_out_t *output, void *data)
return 0;
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);
return 1;
@@ -534,25 +543,25 @@ 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->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);
return 1;
}
-void xine_dispose_internal (xine_stream_t *stream);
+static void xine_dispose_internal (xine_stream_t *stream);
xine_stream_t *xine_stream_new (xine_t *this,
xine_audio_port_t *ao, xine_video_port_t *vo) {
@@ -569,7 +578,7 @@ xine_stream_t *xine_stream_new (xine_t *this,
pthread_mutex_lock (&this->streams_lock);
- stream = (xine_stream_t *) xine_xmalloc (sizeof (xine_stream_t)) ;
+ stream = (xine_stream_t *) calloc (1, sizeof (xine_stream_t)) ;
stream->current_extra_info = malloc( sizeof( extra_info_t ) );
stream->audio_decoder_extra_info = malloc( sizeof( extra_info_t ) );
stream->video_decoder_extra_info = malloc( sizeof( extra_info_t ) );
@@ -595,30 +604,31 @@ xine_stream_t *xine_stream_new (xine_t *this,
stream->early_finish_event = 0;
stream->delay_finish_event = 0;
stream->gapless_switch = 0;
+ stream->keep_ao_driver_open = 0;
stream->video_out = vo;
if (vo)
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
*/
@@ -628,6 +638,7 @@ xine_stream_t *xine_stream_new (xine_t *this,
pthread_mutex_init (&stream->meta_mutex, NULL);
pthread_mutex_init (&stream->demux_lock, NULL);
pthread_mutex_init (&stream->demux_mutex, NULL);
+ pthread_cond_init (&stream->demux_resume, NULL);
pthread_mutex_init (&stream->event_queues_lock, NULL);
pthread_mutex_init (&stream->counter_lock, NULL);
pthread_cond_init (&stream->counter_changed, NULL);
@@ -652,7 +663,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
*/
@@ -723,22 +734,22 @@ 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;
}
void _x_mrl_unescape(char *mrl) {
- int i, len = strlen(mrl);
+ size_t i, len = strlen(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);
@@ -780,11 +791,25 @@ void _x_flush_events_queues (xine_stream_t *stream) {
pthread_mutex_unlock (&stream->event_queues_lock);
}
-/*static*/ int open_internal (xine_stream_t *stream, const char *mrl) {
+static inline int _x_path_looks_like_mrl (const char *path)
+{
+ if ((*path & 0xDF) < 'A' || (*path & 0xDF) > 'Z')
+ return 0;
+
+ for (++path; *path; ++path)
+ if ((*path != '-' && *path < '0') || (*path > '9' && *path < 'A') ||
+ (*path > 'Z' && *path < 'a') || *path > 'z')
+ break;
+
+ return path[0] == ':' && path[1] == '/';
+}
+
+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;
@@ -806,33 +831,50 @@ void _x_flush_events_queues (xine_stream_t *stream) {
/*
* look for a stream_setup in MRL and try finding an input plugin
*/
+ stream_setup = strchr (mrl, '#');
if (isalpha (*mrl))
{
- stream_setup = mrl + 1;
- while (isalnum (*stream_setup) || *stream_setup == '+' || *stream_setup == '-' || *stream_setup == '.')
- ++stream_setup;
- if (stream_setup[0] == ':' && stream_setup[1] == '/')
- stream_setup = strchr (mrl, '#');
- else
- stream_setup = NULL;
+ mrl_proto = mrl + 1;
+ while (isalnum (*mrl_proto) || *mrl_proto == '+' || *mrl_proto == '-' || *mrl_proto == '.')
+ ++mrl_proto;
+ 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 )
+ break;
+ stream_setup = strchr(stream_setup + 1, '#');
+ }
}
-
+
{
char *input_source = strndup (mrl, stream_setup ? stream_setup - mrl : strlen (mrl));
/*
* find an input plugin
*/
+ stream->input_plugin = _x_find_input_plugin (stream, input_source);
+ free(input_source);
- if ((stream->input_plugin = _x_find_input_plugin (stream, input_source))) {
+ if ( stream->input_plugin ) {
int res;
xine_log (stream->xine, XINE_LOG_MSG, _("xine: found input plugin : %s\n"),
stream->input_plugin->input_class->get_description(stream->input_plugin->input_class));
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->get_identifier (stream->input_plugin->input_class)));
res = (stream->input_plugin->open) (stream->input_plugin);
@@ -840,7 +882,6 @@ void _x_flush_events_queues (xine_stream_t *stream) {
case 1: /* Open successfull */
break;
case -1: /* Open unsuccessfull, but correct plugin */
- free(input_source);
stream->err = XINE_ERROR_INPUT_FAILED;
_x_flush_events_queues (stream);
return 0;
@@ -851,10 +892,8 @@ void _x_flush_events_queues (xine_stream_t *stream) {
stream->err = XINE_ERROR_INPUT_FAILED;
}
}
-
- free(input_source);
}
-
+
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;
@@ -917,11 +956,12 @@ void _x_flush_events_queues (xine_stream_t *stream) {
memcpy(filename, tmp, strlen(tmp));
filename[strlen(tmp)] = '\0';
}
+ _x_mrl_unescape(filename);
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 {
@@ -1091,13 +1131,15 @@ void _x_flush_events_queues (xine_stream_t *stream) {
memcpy(subtitle_mrl, tmp, strlen(tmp));
subtitle_mrl[strlen(tmp)] = '\0';
}
- _x_mrl_unescape(subtitle_mrl);
+ /* unescape for xine_open() if the MRL looks like a raw pathname */
+ if (!_x_path_looks_like_mrl(subtitle_mrl))
+ _x_mrl_unescape(subtitle_mrl);
stream->slave = xine_stream_new (stream->xine, NULL, stream->video_out );
stream->slave_affection = XINE_MASTER_SLAVE_PLAY | XINE_MASTER_SLAVE_STOP;
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 );
@@ -1152,6 +1194,27 @@ void _x_flush_events_queues (xine_stream_t *stream) {
/* enable buffered input plugin (request optimizer) */
stream->input_plugin = _x_cache_plugin_get_instance(stream, 0);
+ /* Let the plugin request a specific demuxer (if the user hasn't).
+ * This overrides find-by-content & find-by-extension.
+ */
+ if (!stream->demux_plugin)
+ {
+ char *default_demux = NULL;
+ stream->input_plugin->get_optional_data (stream->input_plugin, &default_demux, INPUT_OPTIONAL_DATA_DEMUXER);
+ if (default_demux)
+ {
+ stream->demux_plugin = _x_find_demux_plugin_by_name (stream, default_demux, stream->input_plugin);
+ if (stream->demux_plugin)
+ {
+ lprintf ("demux and input plugin found\n");
+ _x_meta_info_set_utf8 (stream, XINE_META_INFO_SYSTEMLAYER,
+ stream->demux_plugin->demux_class->get_identifier (stream->demux_plugin->demux_class));
+ }
+ else
+ xine_log (stream->xine, XINE_LOG_MSG, _("xine: couldn't load plugin-specified demux %s for >%s<\n"), default_demux, mrl);
+ }
+ }
+
if (!stream->demux_plugin) {
/*
@@ -1275,9 +1338,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 */
@@ -1286,25 +1349,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 */
@@ -1314,9 +1378,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;
@@ -1328,7 +1392,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 );
@@ -1351,7 +1415,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;
@@ -1365,26 +1429,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);
@@ -1399,11 +1463,11 @@ int xine_eject (xine_stream_t *stream) {
pthread_cleanup_pop (0);
pthread_mutex_unlock (&stream->frontend_lock);
-
+
return status;
}
-void xine_dispose_internal (xine_stream_t *stream) {
+static void xine_dispose_internal (xine_stream_t *stream) {
xine_list_iterator_t *ite;
@@ -1416,6 +1480,7 @@ void xine_dispose_internal (xine_stream_t *stream) {
pthread_mutex_destroy (&stream->current_extra_info_lock);
pthread_cond_destroy (&stream->counter_changed);
pthread_mutex_destroy (&stream->demux_mutex);
+ pthread_cond_destroy (&stream->demux_resume);
pthread_mutex_destroy (&stream->demux_lock);
pthread_mutex_destroy (&stream->first_frame_lock);
pthread_cond_destroy (&stream->first_frame_reached);
@@ -1430,7 +1495,7 @@ 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);
@@ -1448,7 +1513,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;
@@ -1456,7 +1521,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);
@@ -1488,13 +1553,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
@@ -1510,7 +1575,7 @@ xine_t *xine_new (void) {
int i_err;
#endif
- this = xine_xmalloc (sizeof (xine_t));
+ this = calloc(1, sizeof (xine_t));
if (!this)
_x_abort();
@@ -1552,7 +1617,7 @@ xine_t *xine_new (void) {
#endif /* WIN32 */
this->verbosity = XINE_VERBOSITY_NONE;
-
+
return this;
}
@@ -1599,18 +1664,17 @@ static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) {
xine_t *this = (xine_t *)this_gen;
char *homedir_trail_slash;
- homedir_trail_slash = (char *)malloc(strlen(xine_get_homedir()) + 2);
- sprintf(homedir_trail_slash, "%s/", xine_get_homedir());
+ asprintf(&homedir_trail_slash, "%s/", xine_get_homedir());
if (entry->str_value[0] &&
(entry->str_value[0] != '/' || strstr(entry->str_value, "/.") ||
strcmp(entry->str_value, xine_get_homedir()) == 0 ||
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);
@@ -1618,7 +1682,7 @@ static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) {
}
pthread_mutex_unlock(&this->streams_lock);
}
-
+
free(homedir_trail_slash);
this->save_path = entry->str_value;
}
@@ -1627,6 +1691,12 @@ void xine_init (xine_t *this) {
static const char *demux_strategies[] = {"default", "reverse", "content",
"extension", NULL};
+ /*
+ * locks
+ */
+ pthread_mutex_init (&this->streams_lock, NULL);
+ pthread_mutex_init (&this->log_lock, NULL);
+
/* initialize color conversion tables and functions */
init_yuv_conversion();
@@ -1666,7 +1736,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"
@@ -1674,7 +1744,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
*/
@@ -1708,19 +1778,13 @@ void xine_init (xine_t *this) {
this->streams = xine_list_new();
/*
- * locks
- */
- pthread_mutex_init (&this->streams_lock, NULL);
- pthread_mutex_init (&this->log_lock, NULL);
-
- /*
* start metronom clock
*/
this->clock = _x_metronom_clock_init(this);
this->clock->start_clock (this->clock, 0);
-
+
/*
* tickets
*/
@@ -1733,7 +1797,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;
@@ -1753,7 +1817,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);
}
@@ -1813,10 +1877,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);
}
@@ -1828,7 +1892,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;
@@ -1837,13 +1901,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 )
@@ -1899,50 +1963,98 @@ int xine_get_pos_length (xine_stream_t *stream, int *pos_stream,
return 1;
}
-int xine_get_current_frame (xine_stream_t *stream, int *width, int *height,
- int *ratio_code, int *format,
- uint8_t *img) {
+static int _x_get_current_frame_data (xine_stream_t *stream,
+ xine_current_frame_data_t *data,
+ int flags, int img_size_unknown) {
vo_frame_t *frame;
+ size_t required_size;
stream->xine->port_ticket->acquire(stream->xine->port_ticket, 0);
frame = stream->video_out->get_last_frame (stream->video_out);
stream->xine->port_ticket->release(stream->xine->port_ticket, 0);
-
- if (!frame)
+
+ if (!frame) {
+ data->img_size = 0;
return 0;
+ }
- *width = frame->width;
- *height = frame->height;
+ data->width = frame->width;
+ data->height = frame->height;
+ data->crop_left = frame->crop_left;
+ data->crop_right = frame->crop_right;
+ data->crop_top = frame->crop_top;
+ data->crop_bottom = frame->crop_bottom;
- *ratio_code = 10000.0 * frame->ratio;
+ data->ratio_code = 10000.0 * frame->ratio;
/* make ratio_code backward compatible */
#define RATIO_LIKE(a, b) ((b) - 1 <= (a) && (a) <= 1 + (b))
- if (RATIO_LIKE(*ratio_code, 10000))
- *ratio_code = XINE_VO_ASPECT_SQUARE;
- else if (RATIO_LIKE(*ratio_code, 13333))
- *ratio_code = XINE_VO_ASPECT_4_3;
- else if (RATIO_LIKE(*ratio_code, 17778))
- *ratio_code = XINE_VO_ASPECT_ANAMORPHIC;
- else if (RATIO_LIKE(*ratio_code, 21100))
- *ratio_code = XINE_VO_ASPECT_DVB;
-
- *format = frame->format;
-
- if (img){
+ if (RATIO_LIKE(data->ratio_code, 10000))
+ data->ratio_code = XINE_VO_ASPECT_SQUARE;
+ else if (RATIO_LIKE(data->ratio_code, 13333))
+ data->ratio_code = XINE_VO_ASPECT_4_3;
+ else if (RATIO_LIKE(data->ratio_code, 17778))
+ 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);
+
+ switch (frame->format) {
+
+ case XINE_IMGFMT_YV12:
+ required_size = frame->width * frame->height
+ + ((frame->width + 1) / 2) * ((frame->height + 1) / 2)
+ + ((frame->width + 1) / 2) * ((frame->height + 1) / 2);
+ break;
+
+ case XINE_IMGFMT_YUY2:
+ required_size = frame->width * frame->height
+ + ((frame->width + 1) / 2) * frame->height
+ + ((frame->width + 1) / 2) * frame->height;
+ break;
+
+ default:
+ if (data->img || (flags & XINE_FRAME_DATA_ALLOCATE_IMG)) {
+ xprintf (stream->xine, XINE_VERBOSITY_DEBUG,
+ "xine: error, snapshot function not implemented for format 0x%x\n", frame->format);
+ _x_abort ();
+ }
+
+ required_size = 0;
+ }
+
+ if (flags & XINE_FRAME_DATA_ALLOCATE_IMG) {
+ /* return allocated buffer size */
+ data->img_size = required_size;
+ /* allocate img or fail */
+ if (!(data->img = calloc(1, required_size)))
+ return 0;
+ } else {
+ /* fail if supplied buffer is to small */
+ if (data->img && !img_size_unknown && data->img_size < required_size) {
+ data->img_size = required_size;
+ return 0;
+ }
+ /* return used buffer size */
+ data->img_size = required_size;
+ }
+
+ if (data->img) {
switch (frame->format) {
case XINE_IMGFMT_YV12:
yv12_to_yv12(
/* Y */
frame->base[0], frame->pitches[0],
- img, frame->width,
+ data->img, frame->width,
/* U */
frame->base[1], frame->pitches[1],
- img+frame->width*frame->height, frame->width/2,
+ data->img+frame->width*frame->height, frame->width/2,
/* V */
frame->base[2], frame->pitches[2],
- img+frame->width*frame->height+frame->width*frame->height/4, frame->width/2,
+ data->img+frame->width*frame->height+frame->width*frame->height/4, frame->width/2,
/* width x height */
frame->width, frame->height);
break;
@@ -1952,13 +2064,13 @@ int xine_get_current_frame (xine_stream_t *stream, int *width, int *height,
/* src */
frame->base[0], frame->pitches[0],
/* dst */
- img, frame->width*2,
+ data->img, frame->width*2,
/* width x height */
frame->width, frame->height);
break;
default:
- 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);
_x_abort ();
}
@@ -1966,6 +2078,69 @@ int xine_get_current_frame (xine_stream_t *stream, int *width, int *height,
return 1;
}
+int xine_get_current_frame_data (xine_stream_t *stream,
+ xine_current_frame_data_t *data,
+ int flags) {
+
+ return _x_get_current_frame_data(stream, data, flags, 0);
+}
+
+int xine_get_current_frame_alloc (xine_stream_t *stream, int *width, int *height,
+ int *ratio_code, int *format,
+ uint8_t **img, int *img_size) {
+
+ int result;
+ xine_current_frame_data_t data;
+
+ memset(&data, 0, sizeof (data));
+
+ result = _x_get_current_frame_data(stream, &data, img ? XINE_FRAME_DATA_ALLOCATE_IMG : 0, 0);
+ if (width) *width = data.width;
+ if (height) *height = data.height;
+ if (ratio_code) *ratio_code = data.ratio_code;
+ if (format) *format = data.format;
+ if (img_size) *img_size = data.img_size;
+ if (img) *img = data.img;
+ return result;
+}
+
+int xine_get_current_frame_s (xine_stream_t *stream, int *width, int *height,
+ int *ratio_code, int *format,
+ uint8_t *img, int *img_size) {
+ int result;
+ xine_current_frame_data_t data;
+
+ memset(&data, 0, sizeof (data));
+ data.img = img;
+ if (img_size)
+ data.img_size = *img_size;
+
+ result = _x_get_current_frame_data(stream, &data, 0, 0);
+ if (width) *width = data.width;
+ if (height) *height = data.height;
+ if (ratio_code) *ratio_code = data.ratio_code;
+ if (format) *format = data.format;
+ if (img_size) *img_size = data.img_size;
+ return result;
+}
+
+int xine_get_current_frame (xine_stream_t *stream, int *width, int *height,
+ int *ratio_code, int *format,
+ uint8_t *img) {
+ int result;
+ xine_current_frame_data_t data;
+
+ memset(&data, 0, sizeof (data));
+ data.img = img;
+
+ result = _x_get_current_frame_data(stream, &data, 0, 1);
+ if (width) *width = data.width;
+ if (height) *height = data.height;
+ if (ratio_code) *ratio_code = data.ratio_code;
+ if (format) *format = data.format;
+ return result;
+}
+
int xine_get_video_frame (xine_stream_t *stream,
int timestamp, /* msec */
int *width, int *height,
@@ -2072,7 +2247,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);
@@ -2084,15 +2259,21 @@ 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);
this->log_buffers[buf]->scratch_printf(this->log_buffers[buf], format, args);
+
+ if (this->log_cb)
+ this->log_cb (this->log_cb_user_data, buf);
}
char *const *xine_get_log (xine_t *this, int buf) {
@@ -2107,12 +2288,10 @@ char *const *xine_get_log (xine_t *this, int buf) {
}
void xine_register_log_cb (xine_t *this, xine_log_cb_t cb, void *user_data) {
-
- printf ("xine: xine_register_log_cb: not implemented yet.\n");
- _x_abort();
+ this->log_cb = cb;
+ this->log_cb_user_data = user_data;
}
-
int xine_get_error (xine_stream_t *stream) {
return stream->err;
}
@@ -2139,13 +2318,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);
}
diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c
index 50d8796e8..e39c19817 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 "demuxers/demux.h"
#include "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) {
@@ -326,7 +326,7 @@ void xine_config_reset (xine_t *this) {
int xine_gui_send_vo_data (xine_stream_t *stream,
int type, void *data) {
- return stream->video_driver->gui_data_exchange (stream->video_driver,
+ return stream->video_driver->gui_data_exchange (stream->video_driver,
type, data);
}
#endif
@@ -334,7 +334,7 @@ int xine_gui_send_vo_data (xine_stream_t *stream,
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);
}
@@ -369,7 +369,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);
@@ -379,7 +379,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;
@@ -417,14 +417,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) {
@@ -464,8 +464,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;
@@ -495,15 +495,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;
@@ -516,23 +516,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) {
@@ -542,7 +545,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;
@@ -550,7 +553,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;
@@ -573,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_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:
@@ -582,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_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:
@@ -591,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_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:
@@ -600,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);
- 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:
@@ -609,7 +612,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:
@@ -626,9 +629,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:
@@ -652,17 +655,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;
@@ -670,22 +673,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;
@@ -739,6 +742,8 @@ uint32_t xine_get_stream_info (xine_stream_t *stream, int info) {
case XINE_STREAM_INFO_IGNORE_AUDIO:
case XINE_STREAM_INFO_IGNORE_SPU:
case XINE_STREAM_INFO_VIDEO_HAS_STILL:
+ case XINE_STREAM_INFO_SKIPPED_FRAMES:
+ case XINE_STREAM_INFO_DISCARDED_FRAMES:
case XINE_STREAM_INFO_VIDEO_AFD:
case XINE_STREAM_INFO_DVD_TITLE_NUMBER:
case XINE_STREAM_INFO_DVD_TITLE_COUNT:
@@ -753,7 +758,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);
@@ -774,11 +779,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);
@@ -866,7 +871,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);
@@ -880,7 +885,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);
@@ -931,7 +936,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) {
@@ -945,7 +950,7 @@ int _x_message(xine_stream_t *stream, int type, ...) {
xine_ui_message_data_t *data;
xine_event_t event;
const char *explanation;
- int size;
+ size_t size;
int n;
va_list ap;
char *s, *params;
@@ -988,14 +993,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 = xine_xmalloc( size );
+ 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;
@@ -1006,10 +1011,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_internal.h b/src/xine-engine/xine_internal.h
index 9b69f16f1..7566c83e0 100644
--- a/src/xine-engine/xine_internal.h
+++ b/src/xine-engine/xine_internal.h
@@ -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
@@ -96,11 +96,11 @@ typedef struct xine_ticket_s xine_ticket_t;
*/
struct xine_s {
-
+
config_values_t *config;
plugin_catalog_t *plugin_catalog;
-
+
int demux_strategy;
char *save_path;
@@ -111,12 +111,15 @@ struct xine_s {
xine_list_t *streams;
pthread_mutex_t streams_lock;
-
+
metronom_clock_t *clock;
#ifdef XINE_ENGINE_INTERNAL
xine_ticket_t *port_ticket;
pthread_mutex_t log_lock;
+
+ xine_log_cb_t log_cb;
+ void *log_cb_user_data;
#endif
};
@@ -131,34 +134,34 @@ struct xine_ticket_s {
* the ticket before any operation that might block
*
* you must never write to this member directly
- */
+ */
int ticket_revoked;
-
+
/* apply for a ticket; between acquire and relese of an irrevocable
* ticket (be sure to pair them properly!), it is guaranteed that you
* will never be blocked by ticket revocation */
void (*acquire)(xine_ticket_t *self, int irrevocable);
-
+
/* give a ticket back */
void (*release)(xine_ticket_t *self, int irrevocable);
-
+
/* renew a ticket, when it has been revoked, see ticket_revoked above;
* irrevocable must be set to one, if your thread might have acquired
* irrevocable tickets you don't know of; set it to zero only when
* you know that this is impossible */
void (*renew)(xine_ticket_t *self, int irrevocable);
-
+
#ifdef XINE_ENGINE_INTERNAL
/* allow handing out new tickets */
void (*issue)(xine_ticket_t *self, int atomic);
-
+
/* revoke all tickets and deny new ones;
* a pair of atomic revoke and issue cannot be interrupted by another
* revocation or by other threads acquiring tickets */
void (*revoke)(xine_ticket_t *self, int atomic);
-
+
/* behaves like acquire() but doesn't block the calling thread; when
- * the thread would have been blocked, 0 is returned otherwise 1
+ * the thread would have been blocked, 0 is returned otherwise 1
* this function acquires a ticket even if ticket revocation is active */
int (*acquire_nonblocking)(xine_ticket_t *self, int irrevocable);
@@ -167,7 +170,7 @@ struct xine_ticket_s {
void (*release_nonblocking)(xine_ticket_t *self, int irrevocable);
void (*dispose)(xine_ticket_t *self);
-
+
pthread_mutex_t lock;
pthread_mutex_t revoke_lock;
pthread_cond_t issued;
@@ -206,28 +209,28 @@ struct xine_event_queue_s {
*/
struct xine_stream_s {
-
+
/* reference to xine context */
xine_t *xine;
- /* metronom instance used by current stream */
+ /* metronom instance used by current stream */
metronom_t *metronom;
-
+
/* demuxers use input_plugin to read data */
input_plugin_t *input_plugin;
-
+
/* current content detection method, see METHOD_BY_xxx */
int content_detection_method;
/* used by video decoders */
xine_video_port_t *video_out;
-
+
/* demuxers send data to video decoders using this fifo */
fifo_buffer_t *video_fifo;
-
+
/* used by audio decoders */
xine_audio_port_t *audio_out;
-
+
/* demuxers send data to audio decoders using this fifo */
fifo_buffer_t *audio_fifo;
@@ -240,10 +243,10 @@ struct xine_stream_s {
/* input_dvd uses this one. is it possible to add helper functions instead? */
spu_decoder_t *spu_decoder_plugin;
-
+
/* dxr3 use this one, should be possible to fix to use the port instead */
vo_driver_t *video_driver;
-
+
/* these definitely should be made private! */
int audio_channel_auto;
int spu_decoder_streamtype;
@@ -251,10 +254,10 @@ struct xine_stream_s {
int spu_channel_auto;
int spu_channel_letterbox;
int spu_channel;
-
+
#ifdef XINE_ENGINE_INTERNAL
/* these are private variables, plugins must not access them */
-
+
int status;
/* lock controlling speed change access */
@@ -271,7 +274,7 @@ struct xine_stream_s {
int video_decoder_streamtype;
extra_info_t *video_decoder_extra_info;
int video_channel;
-
+
pthread_t audio_thread;
int audio_thread_created;
audio_decoder_t *audio_decoder_plugin;
@@ -318,21 +321,22 @@ struct xine_stream_s {
/* wait for headers sent / stream decoding finished */
pthread_mutex_t counter_lock;
pthread_cond_t counter_changed;
- int header_count_audio;
- int header_count_video;
- int finished_count_audio;
- int finished_count_video;
+ int header_count_audio;
+ int header_count_video;
+ int finished_count_audio;
+ int finished_count_video;
/* event mechanism */
xine_list_t *event_queues;
pthread_mutex_t event_queues_lock;
-
+
/* demux thread stuff */
pthread_t demux_thread;
int demux_thread_created;
int demux_thread_running;
pthread_mutex_t demux_lock;
int demux_action_pending;
+ pthread_cond_t demux_resume;
pthread_mutex_t demux_mutex; /* used in _x_demux_... functions to synchronize order of pairwise A/V buffer operations */
extra_info_t *current_extra_info;
@@ -341,14 +345,14 @@ struct xine_stream_s {
xine_post_out_t video_source;
xine_post_out_t audio_source;
-
+
int slave_is_subtitle; /* ... and will be automaticaly disposed */
int slave_affection; /* what operations need to be propagated down to the slave? */
-
+
int err;
-
+
broadcaster_t *broadcaster;
-
+
refcounter_t *refcounter;
int emergency_brake; /* something went really wrong and this stream must be
@@ -357,6 +361,7 @@ struct xine_stream_s {
int early_finish_event; /* do not wait fifos get empty before sending event */
int gapless_switch; /* next stream switch will be gapless */
int delay_finish_event; /* delay event in 1/10 sec units. 0=>no delay, -1=>forever */
+ int keep_ao_driver_open;
#endif
};
@@ -388,8 +393,8 @@ input_plugin_t *_x_find_input_plugin (xine_stream_t *stream, const char *mrl) XI
demux_plugin_t *_x_find_demux_plugin (xine_stream_t *stream, input_plugin_t *input) XINE_PROTECTED;
demux_plugin_t *_x_find_demux_plugin_by_name (xine_stream_t *stream, const char *name, input_plugin_t *input) XINE_PROTECTED;
demux_plugin_t *_x_find_demux_plugin_last_probe(xine_stream_t *stream, const char *last_demux_name, input_plugin_t *input) XINE_PROTECTED;
-input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *filename) XINE_PROTECTED;
-input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream, int readahead_size) XINE_PROTECTED;
+input_plugin_t *_x_rip_plugin_get_instance (xine_stream_t *stream, const char *filename) XINE_MALLOC XINE_PROTECTED;
+input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream, int readahead_size) XINE_MALLOC XINE_PROTECTED;
void _x_free_input_plugin (xine_stream_t *stream, input_plugin_t *input) XINE_PROTECTED;
void _x_free_demux_plugin (xine_stream_t *stream, demux_plugin_t *demux) XINE_PROTECTED;
@@ -407,11 +412,11 @@ void _x_extra_info_reset( extra_info_t *extra_info ) XINE_PROTECTED;
void _x_extra_info_merge( extra_info_t *dst, extra_info_t *src ) XINE_PROTECTED;
void _x_get_current_info (xine_stream_t *stream, extra_info_t *extra_info, int size) XINE_PROTECTED;
-
-
+
+
/* demuxer helper functions from demux.c */
-/*
+/*
* 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.
@@ -441,9 +446,9 @@ void _x_demux_send_data(fifo_buffer_t *fifo, uint8_t *data, int size,
int input_normpos, int input_time, int total_time,
uint32_t frame_number) XINE_PROTECTED;
-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 _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) XINE_PROTECTED;
@@ -456,7 +461,7 @@ void _x_demux_send_mrl_reference (xine_stream_t *stream, int alternative,
*/
void _x_mrl_unescape(char *mrl) XINE_PROTECTED;
-/*
+/*
* plugin_loader functions
*
*/
diff --git a/src/xine-engine/xine_plugin.h b/src/xine-engine/xine_plugin.h
index 74e7523e9..3aa236ceb 100644
--- a/src/xine-engine/xine_plugin.h
+++ b/src/xine-engine/xine_plugin.h
@@ -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
@@ -33,7 +33,7 @@
#define PLUGIN_VIDEO_OUT 7
#define PLUGIN_POST 8
-#define PLUGIN_TYPE_MAX PLUGIN_POST
+#define PLUGIN_TYPE_MAX PLUGIN_POST
/* this flag may be or'ed with type in order to force preloading the plugin.
* very useful to register config items on xine initialization.
diff --git a/src/xine-engine/xineintl.h b/src/xine-engine/xineintl.h
index 113a033fa..bb9c006ef 100644
--- a/src/xine-engine/xineintl.h
+++ b/src/xine-engine/xineintl.h
@@ -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