From 3ed086bfd3deca46445b918806f2e0129bb35ab0 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 19 Jul 2010 19:27:50 +0100 Subject: Explicitly report unhandled codecs (in Matroska). --- src/demuxers/demux_matroska.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c index edce2039d..0f83c73f8 100644 --- a/src/demuxers/demux_matroska.c +++ b/src/demuxers/demux_matroska.c @@ -1445,7 +1445,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { track->buf_type = BUF_SPU_HDMV; init_codec = init_codec_spu; } else { - lprintf("unknown codec\n"); + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "unknown codec %s\n", track->codec_id); } if (track->buf_type) { -- cgit v1.2.3 From 88682e14a4c89caa499fedad2a3faab316f72dda Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 19 Jul 2010 19:53:14 +0100 Subject: Fix a potential freeing of unallocated memory. --- src/demuxers/asfheader.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/demuxers/asfheader.c b/src/demuxers/asfheader.c index e9a36fc29..1482ac982 100644 --- a/src/demuxers/asfheader.c +++ b/src/demuxers/asfheader.c @@ -300,6 +300,9 @@ static int asf_header_parse_stream_properties(asf_header_t *header, uint8_t *buf if (!asf_stream) goto exit_error; + asf_stream->private_data = NULL; + asf_stream->error_correction_data = NULL; + asf_reader_init(&reader, buffer, buffer_len); asf_reader_get_guid(&reader, &guid); -- cgit v1.2.3 From dec217438b63373fefd6f50c85664f57148efe50 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 19 Jul 2010 19:56:48 +0100 Subject: Fix a few small memory leaks. --- src/input/pnm.c | 1 + src/libspucmml/xine_cmml_decoder.c | 11 ++++++----- src/post/goom/gfontlib.c | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/input/pnm.c b/src/input/pnm.c index bf24e5f8f..1bbc93fb6 100644 --- a/src/input/pnm.c +++ b/src/input/pnm.c @@ -712,6 +712,7 @@ pnm_t *pnm_connect(xine_stream_t *stream, const char *mrl) { if (strncmp(mrl,"pnm://",6)) { + free (mrl_ptr); return NULL; } diff --git a/src/libspucmml/xine_cmml_decoder.c b/src/libspucmml/xine_cmml_decoder.c index ed7e99ae1..87edcfbfe 100644 --- a/src/libspucmml/xine_cmml_decoder.c +++ b/src/libspucmml/xine_cmml_decoder.c @@ -331,9 +331,9 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { /* how many lines does the anchor text take up? */ this->lines=0; { - int i = 0; - while (*anchor_text) { - if (*anchor_text == '\r' || *anchor_text == '\n') { + int i = 0, index = 0; + while (anchor_text[index]) { + if (anchor_text[index] == '\r' || anchor_text[index] == '\n') { if (i) { /* match a newline and there are chars on the current line ... */ this->text[ this->lines ][i] = '\0'; @@ -342,11 +342,11 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { } } else { /* found a normal (non-line-ending) character */ - this->text[ this->lines ][i] = *anchor_text; + this->text[ this->lines ][i] = anchor_text[index]; if (ilines++; } } + free (anchor_text); /* initialize decoder if needed */ if( !this->cached_width || !this->cached_height || !this->cached_img_duration || !this->osd ) { diff --git a/src/post/goom/gfontlib.c b/src/post/goom/gfontlib.c index 2bc366305..f538aad34 100644 --- a/src/post/goom/gfontlib.c +++ b/src/post/goom/gfontlib.c @@ -127,6 +127,7 @@ void gfont_load (void) { font_chars [32] = 0; small_font_chars [32] = 0; free(font_pos); + free(gfont); } void goom_draw_text (Pixel * buf,int resolx,int resoly, -- cgit v1.2.3 From 58c991b313911b85d323ec78a4d6de9a5e022a68 Mon Sep 17 00:00:00 2001 From: Matthias Drochner Date: Tue, 20 Jul 2010 18:18:32 +0100 Subject: Missing mutex init --- src/post/audio/upmix.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/post/audio/upmix.c b/src/post/audio/upmix.c index 9cf68b365..76cf8f1b2 100644 --- a/src/post/audio/upmix.c +++ b/src/post/audio/upmix.c @@ -396,6 +396,8 @@ static post_plugin_t *upmix_open_plugin(post_class_t *class_gen, int inputs, _x_post_init(&this->post, 1, 0); + pthread_mutex_init(&this->lock, 0); + this->params.cut_off_freq = 100; port = _x_post_intercept_audio_port(&this->post, audio_target[0], &input, &output); -- cgit v1.2.3 From 06d09abeaa81336476845e1cc5db2a474ceaa9ad Mon Sep 17 00:00:00 2001 From: Matthias Drochner Date: Wed, 21 Jul 2010 14:23:25 +0000 Subject: Normalize timeval In demux_loop(), a time value is calculated by adding to the fractional part. In case a second barrier is crossed, the value is not in its canonical form anymore - the fractional part is larger than 10^9-1. It should be normalized for portability. While I haven't found a formal requirement for this in POSIX, NetBSD's libpthread checks for it and complains. --- src/xine-engine/demux.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c index bbc130988..68fedbcf4 100644 --- a/src/xine-engine/demux.c +++ b/src/xine-engine/demux.c @@ -349,6 +349,10 @@ static void *demux_loop (void *stream_gen) { gettimeofday(&tv, NULL); ts.tv_sec = tv.tv_sec; ts.tv_nsec = (tv.tv_usec + 100000) * 1000; + if (ts.tv_nsec >= 1000000000) { + ts.tv_nsec -= 1000000000; + ts.tv_sec += 1; + } pthread_cond_timedwait (&stream->demux_resume, &stream->demux_lock, &ts); } -- cgit v1.2.3 From ba6e40bee872673f4af4e32836d633b28e634997 Mon Sep 17 00:00:00 2001 From: Matthias Drochner Date: Wed, 21 Jul 2010 15:10:23 +0000 Subject: Advance buffer pointer after read In dvd_input.c:file_read(), if the read is not done in a single access, the buffer pointer doesn't get advanced so that the second read overwrites the data of the first. I actually don't remember under which circumstances this could happen, but the flaw in the code is obvious. The patch is from NetBSD's pkgsrc, and this patch is attributed to an "unnamed contributor" in the CVS log. --- src/input/libdvdnav/dvd_input.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/input/libdvdnav/dvd_input.c b/src/input/libdvdnav/dvd_input.c index 7b35f5eef..8eea51412 100644 --- a/src/input/libdvdnav/dvd_input.c +++ b/src/input/libdvdnav/dvd_input.c @@ -319,6 +319,7 @@ static int file_read(dvd_input_t dev, void *buffer, int blocks, int flags) return (int) (bytes / DVD_VIDEO_LB_LEN); } + buffer += ret; len -= ret; } -- cgit v1.2.3 From e9c4a618fbc47dae2cdd82d4d09ade8ec020bfe1 Mon Sep 17 00:00:00 2001 From: Matthias Drochner Date: Wed, 21 Jul 2010 15:27:33 +0000 Subject: Add _POSIX_THREAD_PRIORITY_SCHEDULING #ifdefs This is optional, and some systems don't support it. POSIX defines the _POSIX_THREAD_PRIORITY_SCHEDULING to tell that support is present. --- src/xine-engine/audio_decoder.c | 4 ++++ src/xine-engine/audio_out.c | 2 ++ src/xine-engine/video_decoder.c | 8 ++++++++ src/xine-engine/video_out.c | 2 ++ 4 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index dd15bf696..3d5ef7e6f 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/audio_decoder.c @@ -463,7 +463,9 @@ static void *audio_decoder_loop (void *stream_gen) { int _x_audio_decoder_init (xine_stream_t *stream) { pthread_attr_t pth_attrs; +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING struct sched_param pth_params; +#endif int err; if (stream->audio_out == NULL) { @@ -501,10 +503,12 @@ int _x_audio_decoder_init (xine_stream_t *stream) { */ pthread_attr_init(&pth_attrs); +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_attr_getschedparam(&pth_attrs, &pth_params); 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); +#endif stream->audio_thread_created = 1; if ((err = pthread_create (&stream->audio_thread, diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 0a141e014..b9738595b 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -2284,7 +2284,9 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, this->audio_loop_running = 1; pthread_attr_init(&pth_attrs); +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_attr_setscope(&pth_attrs, PTHREAD_SCOPE_SYSTEM); +#endif this->audio_thread_created = 1; if ((err = pthread_create (&this->audio_thread, diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index 0756fc5b2..f70bb82bb 100644 --- a/src/xine-engine/video_decoder.c +++ b/src/xine-engine/video_decoder.c @@ -41,6 +41,10 @@ #define SPU_SLEEP_INTERVAL (90000/2) +#ifndef SCHED_OTHER +#define SCHED_OTHER 0 +#endif + static void update_spu_decoder (xine_stream_t *stream, int type) { @@ -486,7 +490,9 @@ int _x_video_decoder_init (xine_stream_t *stream) { } else { pthread_attr_t pth_attrs; +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING struct sched_param pth_params; +#endif int err, num_buffers; /* The fifo size is based on dvd playback where buffers are filled * with 2k of data. With 500 buffers and a typical video data rate @@ -515,10 +521,12 @@ int _x_video_decoder_init (xine_stream_t *stream) { stream->spu_track_map_entries = 0; pthread_attr_init(&pth_attrs); +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_attr_getschedparam(&pth_attrs, &pth_params); 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); +#endif stream->video_thread_created = 1; if ((err = pthread_create (&stream->video_thread, diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index cd73233c3..26ad98290 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.c @@ -1911,7 +1911,9 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabon this->grab_only = 0; pthread_attr_init(&pth_attrs); +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_attr_setscope(&pth_attrs, PTHREAD_SCOPE_SYSTEM); +#endif if ((err = pthread_create (&this->video_thread, &pth_attrs, video_out_loop, this)) != 0) { -- cgit v1.2.3 From 1c9cf7069230ea1016879161d5530fbbd5721d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Merz?= Date: Sun, 18 Jul 2010 14:47:16 +0000 Subject: Fix metronome not getting audio PTS The xine libmad adaptor seemed not to forward the pts to the metronome: It buffers the MPEG audio packets until a threshold is reached (MAD_MIN_SIZE: 2889 bytes) and then has libmad decode the packets which is send to audio out. The pts of the last audio packet is forwarded on to metronome which can then sync video with audio. For the channel4 channels MPEG audio packets have a size of 576 bytes which means it takes five packets to fill the buffer enough for processing. In the stream every fifth audio packet contains a pts. The result of this is: If after a seek, the last audio packet is the one with the pts, video and audio are in sync. If the pts is in any of the four previous ones no pts will reach metronome and video and audio will never be synced before a new seek and even then there's a one in five chance that video and audio are not synced. Other channels did not show this behaviour because e.g. BBC One has an audio packet size of about 750 bytes and send a pts every fifth packet as well. This means that not every pts from the stream gets through to metronome but some do. This also means that syncing after a seek is probably not as quick as it could be but it will sync. My workaround to this problem is to start decoding not only when a the buffer has reached a threshold but also when a pts != 0 arrives. This does mean however that the buffer isn't always filled to the theshold and decoding might not perform as well as it could. --HG-- extra : transplant_source : %EC%90%EB%AA%8A%C7%BD%A4%B7%EE%F5%E9%E8SY%89S%9D0s --- src/libmad/xine_mad_decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libmad/xine_mad_decoder.c b/src/libmad/xine_mad_decoder.c index c9067a676..6fb56dbd1 100644 --- a/src/libmad/xine_mad_decoder.c +++ b/src/libmad/xine_mad_decoder.c @@ -190,7 +190,7 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { mad_stream_buffer (&this->stream, this->buffer, this->bytes_in_buffer); - if (this->bytes_in_buffer < MAD_MIN_SIZE) + if (this->bytes_in_buffer < MAD_MIN_SIZE && buf->pts == 0) return; if (!this->needs_more_data) { -- cgit v1.2.3 From 99995e9829efc897518c2cf3265dbcac7149c90d Mon Sep 17 00:00:00 2001 From: Matthias Drochner Date: Wed, 21 Jul 2010 15:46:13 +0000 Subject: Add NetBSD support to the VCD input plugin --HG-- extra : rebase_source : cfee1d5353fa3cacf4df8712fde15cd94e2ee3d4 --- src/input/input_vcd.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c index 43980bd52..3e65f7203 100644 --- a/src/input/input_vcd.c +++ b/src/input/input_vcd.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #ifdef HAVE_LINUX_CDROM_H @@ -92,7 +93,7 @@ typedef struct { #if defined (__linux__) || defined(__sun) struct cdrom_tochdr tochdr; struct cdrom_tocentry tocent[100]; -#elif defined (__FreeBSD_kernel__) || defined (__OpenBSD__) +#elif (defined(BSD) && BSD >= 199306) struct ioc_toc_header tochdr; struct cd_toc_entry *tocent; off_t cur_sec; @@ -117,7 +118,7 @@ typedef struct { int cur_track; -#if defined (__linux__) || defined(__sun) || defined (__FreeBSD_kernel__) || defined (__OpenBSD__) +#if defined (__linux__) || defined(__sun) || (defined(BSD) && BSD >= 199306) uint8_t cur_min, cur_sec, cur_frame; #endif @@ -177,7 +178,7 @@ static int input_vcd_read_toc (vcd_input_class_t *this, int fd) { return 0; } -#elif defined (__FreeBSD_kernel__) || defined (__OpenBSD__) +#elif (defined(BSD) && BSD >= 199306) static int input_vcd_read_toc (vcd_input_class_t *this, int fd) { struct ioc_read_toc_entry te; @@ -393,7 +394,7 @@ static off_t vcd_plugin_read (input_plugin_t *this_gen, memcpy (buf, data.data, VCDSECTORSIZE); /* FIXME */ return VCDSECTORSIZE; } -#elif defined (__FreeBSD_kernel__) || defined (__OpenBSD__) +#elif (defined(BSD) && BSD >= 199306) static off_t vcd_plugin_read (input_plugin_t *this_gen, char *buf, off_t nlen) { vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; @@ -531,7 +532,7 @@ static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, memcpy (buf->mem, data.data, VCDSECTORSIZE); /* FIXME */ return buf; } -#elif defined (__FreeBSD_kernel__) || defined (__OpenBSD__) +#elif (defined(BSD) && BSD >= 199306) static buf_element_t *vcd_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t nlen) { @@ -690,7 +691,7 @@ static off_t vcd_plugin_seek (input_plugin_t *this_gen, return offset ; /* FIXME */ } -#elif defined (__FreeBSD_kernel__) || defined (__OpenBSD__) +#elif (defined(BSD) && BSD >= 199306) static off_t vcd_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) { @@ -764,7 +765,7 @@ static off_t vcd_plugin_get_length (input_plugin_t *this_gen) { return (off_t) 0; } -#elif defined (__FreeBSD_kernel__) || defined (__OpenBSD__) +#elif (defined(BSD) && BSD >= 199306) static off_t vcd_plugin_get_length (input_plugin_t *this_gen) { vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; off_t len ; @@ -859,7 +860,7 @@ static int vcd_plugin_open (input_plugin_t *this_gen) { this->cur_min = this->cls->tocent[this->cur_track].cdte_addr.msf.minute; this->cur_sec = this->cls->tocent[this->cur_track].cdte_addr.msf.second; this->cur_frame = this->cls->tocent[this->cur_track].cdte_addr.msf.frame; -#elif defined (__OpenBSD__) +#elif defined (__OpenBSD__) || defined(__NetBSD__) this->cur_min = this->cls->tocent[this->cur_track + 1 - this->cls->tochdr.starting_track].addr.msf.minute; this->cur_sec = this->cls->tocent[this->cur_track + 1 - this->cls->tochdr.starting_track].addr.msf.second; this->cur_frame = this->cls->tocent[this->cur_track + 1 - this->cls->tochdr.starting_track].addr.msf.frame; -- cgit v1.2.3 From 5444a0ac73c01b7dabfce3bb81ac6094c44fb5ab Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 21 Jul 2010 19:32:07 +0100 Subject: =?UTF-8?q?0=20=E2=86=92=20NULL=20for=20consistency.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/post/audio/upmix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/post/audio/upmix.c b/src/post/audio/upmix.c index 76cf8f1b2..f4ea9544a 100644 --- a/src/post/audio/upmix.c +++ b/src/post/audio/upmix.c @@ -396,7 +396,7 @@ static post_plugin_t *upmix_open_plugin(post_class_t *class_gen, int inputs, _x_post_init(&this->post, 1, 0); - pthread_mutex_init(&this->lock, 0); + pthread_mutex_init(&this->lock, NULL); this->params.cut_off_freq = 100; -- cgit v1.2.3 From 7e21b7edcf1cbb074c2d9939e9bf318251822604 Mon Sep 17 00:00:00 2001 From: Lorenzo Desole Date: Wed, 21 Jul 2010 20:51:10 +0200 Subject: Remove duplicate code --- src/xine-engine/demux.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src') diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c index 68fedbcf4..87cc18011 100644 --- a/src/xine-engine/demux.c +++ b/src/xine-engine/demux.c @@ -343,17 +343,8 @@ static void *demux_loop (void *stream_gen) { /* someone may want to interrupt us */ if( stream->demux_action_pending ) { - struct timeval tv; struct timespec ts; - - gettimeofday(&tv, NULL); - ts.tv_sec = tv.tv_sec; - ts.tv_nsec = (tv.tv_usec + 100000) * 1000; - if (ts.tv_nsec >= 1000000000) { - ts.tv_nsec -= 1000000000; - ts.tv_sec += 1; - } - + ts = _x_compute_interval(100); pthread_cond_timedwait (&stream->demux_resume, &stream->demux_lock, &ts); } } -- cgit v1.2.3