summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio_out/audio_fusionsound_out.c2
-rw-r--r--src/demuxers/demux_ogg.c61
-rw-r--r--src/input/input_cdda.c51
-rw-r--r--src/input/input_dvb.c9
-rw-r--r--src/input/input_dvd.c45
-rw-r--r--src/input/input_http.c45
-rw-r--r--src/input/input_pvr.c21
-rw-r--r--src/input/libreal/real.c2
-rw-r--r--src/input/libreal/sdpplin.c2
-rw-r--r--src/input/librtsp/rtsp.c2
-rw-r--r--src/input/mms.c6
-rw-r--r--src/input/mmsh.c4
-rw-r--r--src/input/pnm.c4
-rw-r--r--src/libspucmml/xine_cmml_decoder.c50
-rw-r--r--src/libsputext/demux_sputext.c3
-rw-r--r--src/libsputext/xine_sputext_decoder.c2
-rw-r--r--src/libw32dll/wine/win32.c1
-rw-r--r--src/libxineadec/xine_speex_decoder.c6
-rw-r--r--src/video_out/video_out_opengl.c4
-rw-r--r--src/video_out/video_out_xvmc.c2
-rw-r--r--src/video_out/video_out_xxmc.c2
-rw-r--r--src/xine-engine/demux.c2
-rw-r--r--src/xine-engine/info_helper.c4
-rw-r--r--src/xine-engine/input_rip.c7
-rw-r--r--src/xine-engine/load_plugins.c171
-rw-r--r--src/xine-engine/xine.c141
-rw-r--r--src/xine-engine/xine_interface.c2
-rw-r--r--src/xine-utils/list.c2
-rw-r--r--src/xine-utils/utils.c2
-rw-r--r--src/xine-utils/xmlparser.c3
30 files changed, 309 insertions, 349 deletions
diff --git a/src/audio_out/audio_fusionsound_out.c b/src/audio_out/audio_fusionsound_out.c
index 1480cd6d2..6c3a0ae33 100644
--- a/src/audio_out/audio_fusionsound_out.c
+++ b/src/audio_out/audio_fusionsound_out.c
@@ -389,7 +389,7 @@ static ao_driver_t* open_plugin(audio_driver_class_t *ao_class,
fusionsound_class_t *class = (fusionsound_class_t *) ao_class;
fusionsound_driver_t *this;
const char *args[] = { "xine", "--dfb:no-sighandler", "--fs:no-banner" };
- int argn = sizeof(args) / sizeof(args[0]);
+ const size_t argn = sizeof(args) / sizeof(args[0]);
char **argp = (char **) args;
DFBResult ret;
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c
index e0cddfcf4..16e6c40d9 100644
--- a/src/demuxers/demux_ogg.c
+++ b/src/demuxers/demux_ogg.c
@@ -304,10 +304,10 @@ static void send_ogg_packet (demux_ogg_t *this,
buf_element_t *buf;
int done=0,todo=op->bytes;
- int op_size = sizeof(ogg_packet);
+ const size_t op_size = sizeof(ogg_packet);
while (done<todo) {
- int offset=0;
+ size_t offset=0;
buf = fifo->buffer_pool_alloc (fifo);
buf->decoder_flags = decoder_flags;
if (done==0) {
@@ -531,34 +531,34 @@ static void update_chapter_display (demux_ogg_t *this, int stream_num, ogg_packe
chapter--;
if (chapter != this->chapter_info->current_chapter){
- xine_event_t uevent;
- xine_ui_data_t data;
- int title_len;
- char *title;
+ xine_ui_data_t data = {
+ .str = { 0, },
+ .str_len = 0
+ };
+ xine_event_t uevent = {
+ .type = XINE_EVENT_UI_SET_TITLE,
+ .stream = this->stream,
+ .data = &data,
+ .data_length = sizeof(data)
+ };
this->chapter_info->current_chapter = chapter;
- if (chapter >= 0) {
- char t_title[256];
+ if (chapter >= 0) {
if (this->title) {
- snprintf(t_title, sizeof (t_title), "%s / %s", this->title, this->chapter_info->entries[chapter].name);
+ data.str_len = snprintf(data.str, sizeof(data.str), "%s / %s", this->title, this->chapter_info->entries[chapter].name);
} else {
- snprintf(t_title, sizeof (t_title), "%s", this->chapter_info->entries[chapter].name);
+ strncpy(data.str, this->chapter_info->entries[chapter].name, sizeof(data.str)-1);
}
- title = t_title;
} else {
- title = this->title;
+ strncpy(data.str, this->title, sizeof(data.str));
}
- _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, title);
- lprintf("new TITLE: %s\n", title);
-
- uevent.type = XINE_EVENT_UI_SET_TITLE;
- uevent.stream = this->stream;
- uevent.data = &data;
- uevent.data_length = sizeof(data);
- title_len = strlen(title) + 1;
- memcpy(data.str, title, title_len);
- data.str_len = title_len;
+ if ( data.str_len == 0 )
+ data.str_len = strlen(data.str);
+
+ _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, data.str);
+ lprintf("new TITLE: %s\n", data.str);
+
xine_event_send(this->stream, &uevent);
}
}
@@ -1267,8 +1267,8 @@ static void decode_annodex_header (demux_ogg_t *this, const int stream_num, ogg_
static void decode_anxdata_header (demux_ogg_t *this, const int stream_num, ogg_packet *op) {
int64_t granule_rate_n, granule_rate_d;
uint32_t secondary_headers;
- char content_type[1024];
- int content_type_length;
+ const char *content_type = "";
+ size_t content_type_length = 0;
lprintf("AnxData stream detected\n");
@@ -1280,11 +1280,16 @@ static void decode_anxdata_header (demux_ogg_t *this, const int stream_num, ogg_
lprintf("granule_rate %" PRId64 "/%" PRId64 ", %d secondary headers\n",
granule_rate_n, granule_rate_d, secondary_headers);
- /* read "Content-Tyoe" MIME header */
- sscanf(&op->packet[28], "Content-Type: %1023s\r\n", content_type);
- content_type_length = strlen(content_type);
+ /* read "Content-Type" MIME header */
+ const char *startline = &op->packet[28];
+ const char *endline;
+ if ( strcmp(&op->packet[28], "Content-Type: ") == 0 &&
+ (endline = strstr(startline, "\r\n")) ) {
+ content_type = startline + sizeof("Content-Type: ");
+ content_type_length = startline - endline;
+ }
- lprintf("Content-Type: %s (length:%d)\n", content_type, content_type_length);
+ lprintf("Content-Type: %s (length:%td)\n", content_type, content_type_length);
/* how many header packets in the AnxData stream? */
this->si[stream_num]->headers = secondary_headers + 1;
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c
index 047916a07..92eca7559 100644
--- a/src/input/input_cdda.c
+++ b/src/input/input_cdda.c
@@ -1307,20 +1307,17 @@ static void _cdda_mkdir_recursive_safe(xine_t *xine, char *path) {
if(p && strlen(p)) {
#ifdef WIN32
- if (*buf2 != '\0') {
+ if (*buf2 != '\0') {
#endif
-
- int size = strlen(buf2);
- snprintf(buf2 + size, sizeof(buf2) - size, "/%s", p);
-
+ size_t size = strlen(buf2);
+ snprintf(buf2 + size, sizeof(buf2) - size, "/%s", p);
#ifdef WIN32
- }
- else {
- snprintf(buf2, sizeof(buf2), "%s", p);
- }
-
+ }
+ else {
+ snprintf(buf2, sizeof(buf2), "%s", p);
+ }
#endif /* WIN32 */
-
+
_cdda_mkdir_safe(xine, buf2);
}
}
@@ -1438,13 +1435,13 @@ static int _cdda_cddb_handle_code(char *buf) {
*/
static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) {
char cdir[XINE_PATH_MAX + XINE_NAME_MAX + 1];
+ size_t cdir_size = 0;
DIR *dir;
if(this == NULL)
return 0;
- memset(&cdir, 0, sizeof(cdir));
- snprintf(cdir, sizeof(cdir), "%s", this->cddb.cache_dir);
+ cdir_size = snprintf(cdir, sizeof(cdir), "%s", this->cddb.cache_dir);
if((dir = opendir(cdir)) != NULL) {
struct dirent *pdir;
@@ -1452,14 +1449,12 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) {
while((pdir = readdir(dir)) != NULL) {
char discid[9];
- memset(&discid, 0, sizeof(discid));
snprintf(discid, sizeof(discid), "%08lx", this->cddb.disc_id);
if(!strcasecmp(pdir->d_name, discid)) {
FILE *fd;
- int size = strlen(cdir);
- snprintf(cdir + size, sizeof(cdir) - size, "/%s", discid);
+ cdir_size += snprintf(cdir + cdir_size, sizeof(cdir) - cdir_size, "/%s", discid);
if((fd = fopen(cdir, "r")) == NULL) {
xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
"input_cdda: fopen(%s) failed: %s.\n", cdir, strerror(errno));
@@ -1537,14 +1532,9 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) {
int nyear;
y = strstr(buffer, "YEAR:");
- if(y) {
- if (sscanf(y+5, "%4d", &nyear) == 1) {
- char year[5];
-
- snprintf(year, 5, "%d", nyear);
- if (this->cddb.disc_year == NULL)
- this->cddb.disc_year = strdup(year);
- }
+ if (y && this->cddb.disc_year == NULL) {
+ if (sscanf(y+5, "%4d", &nyear) == 1)
+ asprintf(&this->cddb.disc_year, "%d", nyear);
}
}
}
@@ -1812,7 +1802,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) {
while (strcmp(buffer, ".")) {
char buf[2048];
int tnum;
- int bufsize = strlen(buffercache);
+ size_t bufsize = strlen(buffercache);
memset(&buffer, 0, sizeof(buffer));
_cdda_cddb_socket_read(this, buffer, sizeof(buffer) - 1);
@@ -1880,14 +1870,9 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) {
int nyear;
y = strstr(buffer, "YEAR:");
- if (y) {
- if (sscanf(y+5, "%4d", &nyear) == 1) {
- char year[5];
-
- snprintf(year, 5, "%d", nyear);
- if (this->cddb.disc_year == NULL)
- this->cddb.disc_year = strdup(year);
- }
+ if (y && this->cddb.disc_year == NULL) {
+ if (sscanf(y+5, "%4d", &nyear) == 1)
+ asprintf(&this->cddb.disc_year, "%d", nyear);
}
}
}
diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c
index 669cd1e14..69a413bac 100644
--- a/src/input/input_dvb.c
+++ b/src/input/input_dvb.c
@@ -884,7 +884,6 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch
channel_t *channels = NULL;
int num_channels = 0;
int num_alloc = 0;
- int i;
struct stat st;
snprintf(filename, BUFSIZE, "%s/.xine/channels.conf", xine_get_homedir());
@@ -909,8 +908,8 @@ static channel_t *load_channels(xine_t *xine, xine_stream_t *stream, int *num_ch
while ( fgets (str, BUFSIZE, f)) {
channel_t channel = {0};
- /* lose trailing spaces & control characters */
- i = strlen (str);
+ /* lose trailing spaces & control characters */
+ size_t i = strlen (str);
while (i && str[i - 1] <= ' ')
--i;
if (i == 0)
@@ -1660,7 +1659,7 @@ static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, char*
/* The line to be printed next. */
char text_line[512];
int text_width, text_height;
- int old_line_length, line_cursor;
+ size_t old_line_length, line_cursor;
char* bound, *old_bound;
*height = 0;
@@ -2816,7 +2815,7 @@ static int dvb_plugin_open(input_plugin_t * this_gen)
* that the channels have really ugly names, sometimes prefixed
* by numbers...
*/
- int chanlen = strlen(channame);
+ size_t chanlen = strlen(channame);
int offset = 0;
xprintf(this->class->xine, XINE_VERBOSITY_LOG,
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c
index 012d695ec..a845d7628 100644
--- a/src/input/input_dvd.c
+++ b/src/input/input_dvd.c
@@ -352,11 +352,14 @@ static void send_mouse_enter_leave_event(dvd_input_plugin_t *this, int direction
}
static int update_title_display(dvd_input_plugin_t *this) {
- char ui_title[MAX_STR_LEN + 1];
- xine_event_t uevent;
xine_ui_data_t data;
+ xine_event_t uevent = {
+ .type = XINE_EVENT_UI_SET_TITLE,
+ .stream = this->stream,
+ .data = &data,
+ .data_length = sizeof(data)
+ };
int tt=-1, pr=-1;
- size_t ui_str_length=0;
int num_tt = 0;
if(!this || !(this->stream))
@@ -386,15 +389,15 @@ static int update_title_display(dvd_input_plugin_t *this) {
dvdnav_get_number_of_parts(this->dvdnav, tt, &num_part);
dvdnav_get_angle_info(this->dvdnav, &cur_angle, &num_angle);
if(num_angle > 1) {
- snprintf(ui_title, MAX_STR_LEN,
- "Title %i, Chapter %i, Angle %i of %i",
- tt,pr,cur_angle, num_angle);
+ data.str_len = snprintf(data.str, sizeof(data.str),
+ "Title %i, Chapter %i, Angle %i of %i",
+ tt,pr,cur_angle, num_angle);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,cur_angle);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,num_angle);
} else {
- snprintf(ui_title, MAX_STR_LEN,
- "Title %i, Chapter %i",
- tt,pr);
+ data.str_len = snprintf(data.str, sizeof(data.str),
+ "Title %i, Chapter %i",
+ tt,pr);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,0);
}
@@ -403,9 +406,9 @@ static int update_title_display(dvd_input_plugin_t *this) {
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_NUMBER,pr);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_COUNT,num_part);
} else if (tt == 0 && dvdnav_menu_table[pr]) {
- snprintf(ui_title, MAX_STR_LEN,
- "DVD %s Menu",
- dvdnav_menu_table[pr]);
+ data.str_len = snprintf(data.str, sizeof(data.str),
+ "DVD %s Menu",
+ dvdnav_menu_table[pr]);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_NUMBER,tt);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_COUNT,num_tt);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_NUMBER,0);
@@ -413,7 +416,8 @@ static int update_title_display(dvd_input_plugin_t *this) {
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,0);
} else {
- strcpy(ui_title, "DVD Menu");
+ strcpy(data.str, "DVD Menu");
+ data.str_len = strlen(data.str);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_NUMBER,0);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_TITLE_COUNT,num_tt);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_CHAPTER_NUMBER,0);
@@ -421,22 +425,15 @@ static int update_title_display(dvd_input_plugin_t *this) {
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_NUMBER,0);
_x_stream_info_set(this->stream,XINE_STREAM_INFO_DVD_ANGLE_COUNT,0);
}
- ui_str_length = strlen(ui_title);
if (this->dvd_name && this->dvd_name[0] &&
- (ui_str_length + strlen(this->dvd_name) < MAX_STR_LEN)) {
- snprintf(ui_title+ui_str_length, MAX_STR_LEN - ui_str_length,
- ", %s", this->dvd_name);
+ (data.str_len + strlen(this->dvd_name) < sizeof(data.str))) {
+ data.str_len += snprintf(data.str+data.str_len, sizeof(data.str) - data.str_len,
+ ", %s", this->dvd_name);
}
#ifdef INPUT_DEBUG
- printf("input_dvd: Changing title to read '%s'\n", ui_title);
+ printf("input_dvd: Changing title to read '%s'\n", data.str);
#endif
- uevent.type = XINE_EVENT_UI_SET_TITLE;
- uevent.stream = this->stream;
- uevent.data = &data;
- uevent.data_length = sizeof(data);;
- memcpy(data.str, ui_title, strlen(ui_title) + 1);
- data.str_len = strlen(ui_title) + 1;
xine_event_send(this->stream, &uevent);
return 1;
diff --git a/src/input/input_http.c b/src/input/input_http.c
index deaaa0719..dab7310c3 100644
--- a/src/input/input_http.c
+++ b/src/input/input_http.c
@@ -651,7 +651,7 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
int done, len, linenum;
int httpcode;
int res;
- int buflen;
+ size_t buflen;
int use_proxy;
int proxyport;
int mpegurl_redirect = 0;
@@ -743,43 +743,38 @@ static int http_plugin_open (input_plugin_t *this_gen ) {
if (use_proxy) {
if (this->port != DEFAULT_HTTP_PORT) {
- snprintf (this->buf, BUFSIZE, "GET http://%s:%d%s HTTP/1.0\015\012",
- this->host, this->port, this->uri);
+ buflen = snprintf (this->buf, BUFSIZE, "GET http://%s:%d%s HTTP/1.0\015\012",
+ this->host, this->port, this->uri);
} else {
- snprintf (this->buf, BUFSIZE, "GET http://%s%s HTTP/1.0\015\012",
- this->host, this->uri);
+ buflen = snprintf (this->buf, BUFSIZE, "GET http://%s%s HTTP/1.0\015\012",
+ this->host, this->uri);
}
}
else
- snprintf (this->buf, BUFSIZE, "GET %s HTTP/1.0\015\012", this->uri);
+ buflen = snprintf (this->buf, BUFSIZE, "GET %s HTTP/1.0\015\012", this->uri);
- buflen = strlen(this->buf);
if (this->port != DEFAULT_HTTP_PORT)
- snprintf (this->buf + buflen, BUFSIZE - buflen, "Host: %s:%d\015\012",
- this->host, this->port);
+ buflen += snprintf (this->buf + buflen, BUFSIZE - buflen, "Host: %s:%d\015\012",
+ this->host, this->port);
else
- snprintf (this->buf + buflen, BUFSIZE - buflen, "Host: %s\015\012",
- this->host);
+ buflen += snprintf (this->buf + buflen, BUFSIZE - buflen, "Host: %s\015\012",
+ this->host);
- buflen = strlen(this->buf);
if (this_class->proxyuser && strlen(this_class->proxyuser)) {
- snprintf (this->buf + buflen, BUFSIZE - buflen,
- "Proxy-Authorization: Basic %s\015\012", this->proxyauth);
- buflen = strlen(this->buf);
+ buflen += snprintf (this->buf + buflen, BUFSIZE - buflen,
+ "Proxy-Authorization: Basic %s\015\012", this->proxyauth);
}
if (this->user && strlen(this->user)) {
- snprintf (this->buf + buflen, BUFSIZE - buflen,
- "Authorization: Basic %s\015\012", this->auth);
- buflen = strlen(this->buf);
+ buflen += snprintf (this->buf + buflen, BUFSIZE - buflen,
+ "Authorization: Basic %s\015\012", this->auth);
}
- snprintf(this->buf + buflen, BUFSIZE - buflen,
- "User-Agent: xine/%s\015\012"
- "Accept: */*\015\012"
- "Icy-MetaData: 1\015\012"
- "\015\012",
- VERSION);
- buflen = strlen(this->buf);
+ buflen += snprintf(this->buf + buflen, BUFSIZE - buflen,
+ "User-Agent: xine/%s\015\012"
+ "Accept: */*\015\012"
+ "Icy-MetaData: 1\015\012"
+ "\015\012",
+ VERSION);
if (_x_io_tcp_write (this->stream, this->fh, this->buf, buflen) != buflen) {
_x_message(this->stream, XINE_MSG_CONNECTION_REFUSED, "couldn't send request", NULL);
xprintf(this_class->xine, XINE_VERBOSITY_DEBUG, "input_http: couldn't send request\n");
diff --git a/src/input/input_pvr.c b/src/input/input_pvr.c
index e5c70c64d..af6070a9e 100644
--- a/src/input/input_pvr.c
+++ b/src/input/input_pvr.c
@@ -504,34 +504,24 @@ static void pvr_adjust_realtime_speed(pvr_input_plugin_t *this, fifo_buffer_t *f
}
#define PVR_FILENAME "%s%08d_%08d.vob"
-#define PVR_FILENAME_SIZE 1+8+1+8+4+1
static char *make_temp_name(pvr_input_plugin_t *this, int page) {
-
char *filename;
- int size = strlen(this->tmp_prefix)+PVR_FILENAME_SIZE;
- filename = malloc(size);
-
- snprintf(filename, size, PVR_FILENAME, this->tmp_prefix, this->session, page);
+ asprintf(&filename, PVR_FILENAME, this->tmp_prefix, this->session, page);
return filename;
}
#define SAVE_BASE_FILENAME "ch%03d %02d-%02d-%04d %02d:%02d:%02d"
-#define SAVE_BASE_FILENAME_SIZE 2+3+1+2+1+2+1+4+1+2+1+2+1+2+1
static char *make_base_save_name(int channel, time_t tm) {
-
struct tm rec_time;
char *filename;
- int size = SAVE_BASE_FILENAME_SIZE;
- filename = malloc(size);
-
localtime_r(&tm, &rec_time);
- snprintf(filename, size, SAVE_BASE_FILENAME,
+ asprintf(&filename, SAVE_BASE_FILENAME,
channel, rec_time.tm_mon+1, rec_time.tm_mday,
rec_time.tm_year+1900, rec_time.tm_hour, rec_time.tm_min,
rec_time.tm_sec);
@@ -539,16 +529,11 @@ static char *make_base_save_name(int channel, time_t tm) {
}
#define SAVE_FILENAME "%s%s_%04d.vob"
-#define SAVE_FILENAME_SIZE 1+4+4+1
static char *make_save_name(pvr_input_plugin_t *this, char *base, int page) {
-
char *filename;
- int size = strlen(this->save_prefix)+strlen(base)+SAVE_FILENAME_SIZE;
- filename = malloc(size);
-
- snprintf(filename, size, SAVE_FILENAME, this->save_prefix, base, page);
+ asprintf(&filename, SAVE_FILENAME, this->save_prefix, base, page);
return filename;
}
diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c
index dc3f00105..f4698a4fb 100644
--- a/src/input/libreal/real.c
+++ b/src/input/libreal/real.c
@@ -313,7 +313,7 @@ static void calc_response_string (char *result, char *challenge) {
void real_calc_response_and_checksum (char *response, char *chksum, char *challenge) {
- int ch_len, resp_len;
+ size_t ch_len, resp_len;
int i;
char *ptr;
char buf[128];
diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c
index 2596391f9..4c1687d41 100644
--- a/src/input/libreal/sdpplin.c
+++ b/src/input/libreal/sdpplin.c
@@ -99,7 +99,7 @@ static char *nl(char *data) {
static int filter(const char *in, const char *filter, char **out) {
- int flen=strlen(filter);
+ size_t flen=strlen(filter);
size_t len;
if (!in)
diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c
index 4e17c1e57..07769064a 100644
--- a/src/input/librtsp/rtsp.c
+++ b/src/input/librtsp/rtsp.c
@@ -127,7 +127,7 @@ static char *rtsp_get(rtsp_t *s) {
static void rtsp_put(rtsp_t *s, const char *string) {
- int len=strlen(string);
+ size_t len=strlen(string);
char *buf = malloc(sizeof(char)*len+2);
lprintf(">> '%s'", string);
diff --git a/src/input/mms.c b/src/input/mms.c
index 97a05dd89..ab1983955 100644
--- a/src/input/mms.c
+++ b/src/input/mms.c
@@ -771,12 +771,10 @@ mms_t *mms_connect (xine_stream_t *stream, const char *url, int bandwidth) {
/* command 0x5 */
{
mms_buffer_t command_buffer;
- char *path;
- int pathlen;
+ char *path = this->uri;
+ size_t pathlen = strlen(path);
/* remove the first '/' */
- path = this->uri;
- pathlen = strlen(path);
if (pathlen > 1) {
path++;
pathlen--;
diff --git a/src/input/mmsh.c b/src/input/mmsh.c
index 2feb7c37b..4ee7ed07d 100644
--- a/src/input/mmsh.c
+++ b/src/input/mmsh.c
@@ -190,11 +190,9 @@ struct mmsh_s {
};
static int send_command (mmsh_t *this, char *cmd) {
- int length;
-
lprintf ("send_command:\n%s\n", cmd);
- length = strlen(cmd);
+ const size_t length = strlen(cmd);
if (_x_io_tcp_write(this->stream, this->s, cmd, length) != length) {
xprintf (this->stream->xine, XINE_LOG_MSG, _("libmmsh: send error\n"));
return 0;
diff --git a/src/input/pnm.c b/src/input/pnm.c
index 5b8aa7c42..cbd245e7b 100644
--- a/src/input/pnm.c
+++ b/src/input/pnm.c
@@ -415,8 +415,8 @@ static void pnm_send_request(pnm_t *p, uint32_t bandwidth) {
*/
static void pnm_send_response(pnm_t *p, const char *response) {
-
- int size=strlen(response);
+ /** @TODO should check that sze is always < 256 */
+ size_t size=strlen(response);
p->buffer[0]=0x23;
p->buffer[1]=0;
diff --git a/src/libspucmml/xine_cmml_decoder.c b/src/libspucmml/xine_cmml_decoder.c
index 90a0ca64a..206d8c567 100644
--- a/src/libspucmml/xine_cmml_decoder.c
+++ b/src/libspucmml/xine_cmml_decoder.c
@@ -268,36 +268,30 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) {
for (title_node = packet_xml_root->child; title_node != NULL; title_node = title_node->next) {
- if (strcasecmp (title_node->name, "title") == 0) {
+ if (title_node->data &&
+ strcasecmp (title_node->name, "title") == 0) {
/* found a title node */
- xine_event_t uevent;
- char *title;
- int title_len;
-
- title = title_node->data;
-
- if (title)
- {
- xine_ui_data_t data;
- /* found a non-empty title */
- lprintf ("found title: \"%s\"\n", title);
-
- /* set xine meta-info */
- _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, strdup(title));
-
- /* and push out a new event signifying the title update on the event
- * queue */
- title_len = strlen(title) + 1;
- memcpy(data.str, title, title_len);
- data.str_len = title_len;
-
- uevent.type = XINE_EVENT_UI_SET_TITLE;
- uevent.stream = this->stream;
- uevent.data = &data;
- uevent.data_length = sizeof(data);
- xine_event_send(this->stream, &uevent);
- }
+ xine_ui_data_t data = {
+ .str_len = strlen(title_node->data) + 1
+ };
+ xine_event_t uevent = {
+ .type = XINE_EVENT_UI_SET_TITLE,
+ .stream = this->stream,
+ .data = &data,
+ .data_length = sizeof(data),
+ };
+ strncpy(data.str, title_node->data, sizeof(data.str)-1);
+
+ /* found a non-empty title */
+ lprintf ("found title: \"%s\"\n", data.str);
+
+ /* set xine meta-info */
+ _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, strdup(data.str));
+
+ /* and push out a new event signifying the title update on the event
+ * queue */
+ xine_event_send(this->stream, &uevent);
}
}
} else if (strcasecmp(packet_xml_root->name, "clip") == 0) {
diff --git a/src/libsputext/demux_sputext.c b/src/libsputext/demux_sputext.c
index f7cd5af83..741d0612b 100644
--- a/src/libsputext/demux_sputext.c
+++ b/src/libsputext/demux_sputext.c
@@ -129,7 +129,6 @@ static int eol(char p) {
}
static inline void trail_space(char *s) {
- int i;
while (isspace(*s)) {
char *copy = s;
do {
@@ -137,7 +136,7 @@ static inline void trail_space(char *s) {
copy++;
} while(*copy);
}
- i = strlen(s) - 1;
+ size_t i = strlen(s) - 1;
while (i > 0 && isspace(s[i]))
s[i--] = '\0';
}
diff --git a/src/libsputext/xine_sputext_decoder.c b/src/libsputext/xine_sputext_decoder.c
index 9d5a7cc29..55082476f 100644
--- a/src/libsputext/xine_sputext_decoder.c
+++ b/src/libsputext/xine_sputext_decoder.c
@@ -643,7 +643,7 @@ static void draw_subtitle(sputext_decoder_t *this, int64_t sub_start, int64_t su
buf[0] = 0;
for(line = 0; line < this->lines; line++) {
- int len = strlen(buf);
+ size_t len = strlen(buf);
if (len) {
buf[len] = ' ';
len++;
diff --git a/src/libw32dll/wine/win32.c b/src/libw32dll/wine/win32.c
index f908f1c2e..9d99e1a25 100644
--- a/src/libw32dll/wine/win32.c
+++ b/src/libw32dll/wine/win32.c
@@ -3492,6 +3492,7 @@ static HANDLE WINAPI expCreateFileA(LPCSTR cs1,DWORD i1,DWORD i2,
{
int result;
char* x=strrchr(cs1,'\\');
+ char* tmp;
asprintf(&tmp,"%s/%s",win32_def_path,x?(x+1):cs1);
// printf("### Open: %s -> %s\n",cs1,tmp);
result=open(tmp, O_RDONLY);
diff --git a/src/libxineadec/xine_speex_decoder.c b/src/libxineadec/xine_speex_decoder.c
index 1ae310d80..46ea3a9f9 100644
--- a/src/libxineadec/xine_speex_decoder.c
+++ b/src/libxineadec/xine_speex_decoder.c
@@ -170,16 +170,16 @@ void read_metadata (speex_decoder_t *this, char * comments, int length)
#endif
for (i = 0; speex_comment_keys[i].key != NULL; i++) {
+ size_t keylen = strlen(speex_comment_keys[i].key);
if ( !strncasecmp (speex_comment_keys[i].key, c,
- strlen(speex_comment_keys[i].key)) ) {
- int keylen = strlen(speex_comment_keys[i].key);
+ keylen) ) {
char meta_info[(len - keylen) + 1];
lprintf ("known metadata %d %d\n",
i, speex_comment_keys[i].xine_metainfo_index);
- snprintf(meta_info, (len - keylen), "%s", c + keylen);
+ strncpy(meta_info, &c[keylen], len-keylen);
_x_meta_info_set_utf8(this->stream, speex_comment_keys[i].xine_metainfo_index, meta_info);
}
}
diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c
index 9dcfd4f2e..af1093e91 100644
--- a/src/video_out/video_out_opengl.c
+++ b/src/video_out/video_out_opengl.c
@@ -669,8 +669,8 @@ static int render_image_envtex (opengl_driver_t *this, opengl_frame_t *frame) {
* Render setup functions
*/
static int render_help_verify_ext (opengl_driver_t *this, char *ext) {
- int ret = 0;
- int l = strlen (ext);
+ int ret = 0;
+ const size_t l = strlen (ext);
const char *e;
for (e = (char *) this->gl_exts; e && *e; e = strchr (e, ' ')) {
while (isspace (*e))
diff --git a/src/video_out/video_out_xvmc.c b/src/video_out/video_out_xvmc.c
index 890e079a6..79c2a80a3 100644
--- a/src/video_out/video_out_xvmc.c
+++ b/src/video_out/video_out_xvmc.c
@@ -556,7 +556,7 @@ static vo_frame_t *xvmc_alloc_frame (vo_driver_t *this_gen) {
lprintf ("xvmc_alloc_frame\n");
- frame = calloc(1, (sizeof (xvmc_frame_t));
+ frame = calloc(1, sizeof (xvmc_frame_t));
if (!frame)
return NULL;
diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c
index 0fedde6c6..b016a8bd1 100644
--- a/src/video_out/video_out_xxmc.c
+++ b/src/video_out/video_out_xxmc.c
@@ -162,7 +162,7 @@ static void xxmc_xvmc_surface_handler_construct(xxmc_driver_t *this)
xvmc_surface_handler_t *handler = &this->xvmc_surf_handler;
pthread_mutex_init(&handler->mutex,NULL);
- memset(handler->surfInUse, 0, sizeof(handler->surfInuse));
+ memset(handler->surfInUse, 0, sizeof(handler->surfInUse));
memset(handler->surfValid, 0, sizeof(handler->surfValid));
memset(handler->subInUse, 0, sizeof(handler->subInUse));
memset(handler->subValid, 0, sizeof(handler->subValid));
diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c
index 51ed5b39d..c116d407f 100644
--- a/src/xine-engine/demux.c
+++ b/src/xine-engine/demux.c
@@ -657,7 +657,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 = "";
diff --git a/src/xine-engine/info_helper.c b/src/xine-engine/info_helper.c
index e6d4df7e9..242805915 100644
--- a/src/xine-engine/info_helper.c
+++ b/src/xine-engine/info_helper.c
@@ -131,7 +131,7 @@ 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;
+ size_t i, len;
len = strlen(str);
if (!len)
@@ -358,7 +358,7 @@ 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;
diff --git a/src/xine-engine/input_rip.c b/src/xine-engine/input_rip.c
index 200721dca..8db7eaaf5 100644
--- a/src/xine-engine/input_rip.c
+++ b/src/xine-engine/input_rip.c
@@ -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--;
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index 80cfde12c..13f9b94c7 100644
--- a/src/xine-engine/load_plugins.c
+++ b/src/xine-engine/load_plugins.c
@@ -313,7 +313,6 @@ 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);
@@ -378,12 +377,11 @@ static void _insert_node (xine_t *this,
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] = strdup(desc);
+ asprintf(&catalog->prio_desc[i], _("priority for %s decoder"), info->id);
this->config->register_num (this->config,
key,
0,
@@ -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);
@@ -2416,6 +2409,32 @@ 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 **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;
+
+ size_t pos = 0;
+ 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
*
@@ -2423,66 +2442,35 @@ void xine_post_dispose(xine_t *xine, xine_post_t *post_gen) {
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;
-
- 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)) {
-
- 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;
+ /* create output string */
+ char *const result = _x_concatenate_with_string(extensions, list_size, " ", len);
+ free(extensions);
+ /* Drop the last whitespace */
+ result[len-1] = '\0';
+
pthread_mutex_unlock (&catalog->lock);
- return str;
+ return result;
}
/* get a list of mime types supported by xine
@@ -2491,65 +2479,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;
+ /* create output string */
+ char *const result = _x_concatenate_with_string(mimetypes, list_size, "", len);
+ free(mimetypes);
- 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) {
- l = strlen(s);
- memcpy (&str[pos], s, l);
-
- pos += l;
- }
- }
- }
-
- str[pos] = 0;
-
pthread_mutex_unlock (&catalog->lock);
- return str;
+ return result;
}
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index fd10a7401..558aa996e 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.c
@@ -735,7 +735,7 @@ xine_stream_t *xine_stream_new (xine_t *this,
}
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))) {
@@ -1933,9 +1933,9 @@ int xine_get_pos_length (xine_stream_t *stream, int *pos_stream,
return 1;
}
-static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *height,
- int *ratio_code, int *format,
- uint8_t **img, int *size, int alloc_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;
@@ -1944,42 +1944,49 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he
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;
+ 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;
- *format = frame->format;
+ data->format = frame->format;
+ data->interlaced = frame->progressive_frame ? 0 : (2 - frame->top_field_first);
- switch (*format) {
+ switch (frame->format) {
case XINE_IMGFMT_YV12:
- required_size = *width * *height
- + ((*width + 1) / 2) * ((*height + 1) / 2)
- + ((*width + 1) / 2) * ((*height + 1) / 2);
+ 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 = *width * *height
- + ((*width + 1) / 2) * *height
- + ((*width + 1) / 2) * *height;
+ required_size = frame->width * frame->height
+ + ((frame->width + 1) / 2) * frame->height
+ + ((frame->width + 1) / 2) * frame->height;
break;
default:
- if (*img || alloc_img) {
+ 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 ();
@@ -1988,38 +1995,36 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he
required_size = 0;
}
- if (alloc_img) {
- /* return size if requested */
- if (size)
- *size = required_size;
+ if (flags & XINE_FRAME_DATA_ALLOCATE_IMG) {
+ /* return allocated buffer size */
+ data->img_size = required_size;
/* allocate img or fail */
- if (!(*img = calloc(1, required_size)))
+ if (!(data->img = calloc(1, required_size)))
return 0;
} else {
/* fail if supplied buffer is to small */
- if (*img && size && *size < required_size) {
- *size = required_size;
+ if (data->img && !img_size_unknown && data->img_size < required_size) {
+ data->img_size = required_size;
return 0;
}
- /* return size if requested */
- if (size)
- *size = required_size;
+ /* return used buffer size */
+ data->img_size = required_size;
}
- if (*img) {
+ 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;
@@ -2029,7 +2034,7 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he
/* 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;
@@ -2043,23 +2048,67 @@ static int _x_get_current_frame_impl (xine_stream_t *stream, int *width, int *he
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 *size) {
- uint8_t *no_img = NULL;
- return _x_get_current_frame_impl(stream, width, height, ratio_code, format, img ? img : &no_img, size, img != NULL);
+ 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 *size) {
- return (!img || size) && _x_get_current_frame_impl(stream, width, height, ratio_code, format, &img, size, 0);
+ 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) {
- return _x_get_current_frame_impl(stream, width, height, ratio_code, format, &img, NULL, 0);
+ 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,
diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c
index 597608883..415ceec56 100644
--- a/src/xine-engine/xine_interface.c
+++ b/src/xine-engine/xine_interface.c
@@ -945,7 +945,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;
diff --git a/src/xine-utils/list.c b/src/xine-utils/list.c
index 65bdaec26..b157bda3f 100644
--- a/src/xine-utils/list.c
+++ b/src/xine-utils/list.c
@@ -69,7 +69,7 @@ struct xine_list_s {
*/
static xine_list_chunk_t *xine_list_alloc_chunk(size_t size) {
xine_list_chunk_t *new_chunk;
- size_t chunk_mem_size;;
+ size_t chunk_mem_size;
chunk_mem_size = sizeof(xine_list_chunk_t);
chunk_mem_size += sizeof(xine_list_elem_t) * size;
diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c
index 4085d65ee..9f5d122cb 100644
--- a/src/xine-utils/utils.c
+++ b/src/xine-utils/utils.c
@@ -525,7 +525,7 @@ void xine_hexdump (const char *buf, int length) {
static const lang_locale_t *_get_first_lang_locale(const char *lcal) {
const lang_locale_t *llocale;
- int lang_len;
+ size_t lang_len;
char *mod;
if(lcal && *lcal) {
diff --git a/src/xine-utils/xmlparser.c b/src/xine-utils/xmlparser.c
index 426643708..2922135e2 100644
--- a/src/xine-utils/xmlparser.c
+++ b/src/xine-utils/xmlparser.c
@@ -597,11 +597,10 @@ static void xml_parser_dump_node (const xml_node_t *node, int indent) {
xml_property_t *p;
xml_node_t *n;
- int l;
printf ("%*s<%s ", indent, "", node->name);
- l = strlen (node->name);
+ size_t l = strlen (node->name);
p = node->props;
while (p) {