From 15b6ed2951acc37eb76037ebb786ab827a2c8031 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 28 Sep 2008 17:55:09 +0200 Subject: Fix xine_usec_sleep for mingw+msys Bug was found and fixed by Carlo Bramini. select() does not work on mingw+msys causing xine_usec_sleep to sleep much longer than requested which completely broke audio playback --- src/xine-utils/utils.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c index 57a92623c..689b68502 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -456,23 +456,22 @@ char *xine_chomp(char *str) { * a thread-safe usecond sleep */ void xine_usec_sleep(unsigned usec) { -#if 0 -#if HAVE_NANOSLEEP +#ifdef WIN32 + /* select does not work on win32 */ + Sleep(usec / 1000); +#else +# if 0 +# if HAVE_NANOSLEEP /* nanosleep is prefered on solaris, because it's mt-safe */ struct timespec ts, remaining; - ts.tv_sec = usec / 1000000; ts.tv_nsec = (usec % 1000000) * 1000; while (nanosleep (&ts, &remaining) == -1 && errno == EINTR) ts = remaining; -#else -# if WIN32 - Sleep(usec / 1000); -# else +# else usleep(usec); -# endif -#endif -#else +# endif +# else if (usec < 10000) { usec = 10000; } @@ -480,6 +479,7 @@ void xine_usec_sleep(unsigned usec) { tm.tv_sec = usec / 1000000; tm.tv_usec = usec % 1000000; select(0, 0, 0, 0, &tm); +# endif #endif } -- cgit v1.2.3 From 40353375aa0e812ed14900552b007dfab2f21a1f Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 17 Oct 2008 11:43:43 +0200 Subject: Replace configure test for PulseAudio version by cpp test Version 0.9.6 has PA_PROTOCOL_VERSION 10, version 0.9.7 has 11. This simplifies configure and limits the knowledge about PA versions to the audio output plug-in. This time, the patch includes configure.ac, too. --- src/audio_out/audio_pulse_out.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/audio_out/audio_pulse_out.c b/src/audio_out/audio_pulse_out.c index dfae98c31..4b66fbaed 100644 --- a/src/audio_out/audio_pulse_out.c +++ b/src/audio_out/audio_pulse_out.c @@ -218,7 +218,8 @@ static void __xine_pa_sink_info_callback(pa_context *c, const pa_sink_input_info this->cvolume = info->volume; this->swvolume = pa_cvolume_avg(&info->volume); -#ifdef HAVE_PULSEAUDIO_0_9_7 +#if PA_PROTOCOL_VERSION >= 11 + /* PulseAudio 0.9.7 and newer */ this->muted = info->mute; #else this->muted = pa_cvolume_is_muted (&this->cvolume); @@ -665,7 +666,8 @@ static int ao_pulse_set_property (ao_driver_t *this_gen, int property, int value this->muted = value; -#ifdef HAVE_PULSEAUDIO_0_9_7 +#if PA_PROTOCOL_VERSION >= 11 + /* PulseAudio 0.9.7 and newer */ o = pa_context_set_sink_input_mute(this->context, pa_stream_get_index(this->stream), value, __xine_pa_context_success_callback, this); #else -- cgit v1.2.3 From b0d9d49638c1b738ed36afb6713ba6a1ff63e172 Mon Sep 17 00:00:00 2001 From: Maximilian Schwerin Date: Wed, 3 Sep 2008 09:14:53 +0200 Subject: Adding ID3 tag TDRC to replace/complement the deprecated tag TYER. --- src/demuxers/id3.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c index 3c03fdc68..ba8f50676 100644 --- a/src/demuxers/id3.c +++ b/src/demuxers/id3.c @@ -767,6 +767,7 @@ static int id3v24_interp_frame(input_plugin_t *input, break; case ( FOURCC_TAG('T', 'Y', 'E', 'R') ): + case ( FOURCC_TAG('T', 'D', 'R', 'C') ): _x_meta_info_set_generic(stream, XINE_META_INFO_YEAR, buf + 1, id3_encoding[enc]); break; -- cgit v1.2.3 From 0b674723578edf84ba9823927c89034b0630a7f8 Mon Sep 17 00:00:00 2001 From: Maximilian Schwerin Date: Fri, 7 Nov 2008 13:58:41 +0000 Subject: Composer meta-tag Date: Sat, 28 Jun 2008 17:29:59 +0200 This patch adds this to the FLAC demuxer. --- src/demuxers/demux_flac.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c index e6d6f6376..0cc2fc6b6 100644 --- a/src/demuxers/demux_flac.c +++ b/src/demuxers/demux_flac.c @@ -232,6 +232,9 @@ static int open_flac_file(demux_flac_t *flac) { } else if ((strncasecmp ("ARTIST=", comment, 7) == 0) && (length - 7 > 0)) { _x_meta_info_set_utf8 (flac->stream, XINE_META_INFO_ARTIST, comment + 7); + } else if ((strncasecmp ("COMPOSER=", comment, 9) == 0) + && (length - 9 > 0)) { + _x_meta_info_set_utf8 (flac->stream, XINE_META_INFO_COMPOSER, comment + 9); } else if ((strncasecmp ("ALBUM=", comment, 6) == 0) && (length - 6 > 0)) { _x_meta_info_set_utf8 (flac->stream, XINE_META_INFO_ALBUM, comment + 6); -- cgit v1.2.3 From f2b3546e6dd920f2bb737f270adf78e04f5c7df6 Mon Sep 17 00:00:00 2001 From: Matthias Dahl Date: Fri, 7 Nov 2008 14:00:17 +0000 Subject: aac channel ordering for multi-channel audio Date: Sun, 28 Sep 2008 20:17:54 +0200 The channel order of aac 5.1 audio is wrong during playback. IIRC, the internal channels order for this kind of streams is the same as dts: dts output is reordered according to alsa specs (and ac3 5.1 also works), but aac is not and - for instance - front center is send to front left. The audio channels configuration table should be something like this ## --------------------- ## | Config: 5.1 Ch | ## ---- ---------------- -------------- -------------- ## | Ch | AAC/DTS | ALSA | AC3 | ## ---- ---------------- --------------- -------------- ## | 00 | Center front | Left front | Left front | ## | 01 | Left front | Right front | Center | ## | 02 | Right front | Left back | Right front | ## | 03 | Left back | Right back | Left back | ## | 04 | Right back | Center | Right back | ## | 05 | LFE | LFE | LFE | ## ---- ---------------- --------------- -------------- --- src/libfaad/xine_faad_decoder.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libfaad/xine_faad_decoder.c b/src/libfaad/xine_faad_decoder.c index ae71af155..9c657610e 100644 --- a/src/libfaad/xine_faad_decoder.c +++ b/src/libfaad/xine_faad_decoder.c @@ -275,7 +275,32 @@ static void faad_decode_audio ( faad_decoder_t *this, int end_frame ) { lprintf("decoded %d/%d output %ld\n", used, this->size, this->faac_finfo.samples ); - + + /* Performing necessary channel reordering because aac uses a different + * layout than alsa: + * + * aac 5.1 channel layout: c l r ls rs lfe + * alsa 5.1 channel layout: l r ls rs c lfe + * + * Reordering is only necessary for 5.0 and above. Currently only 5.0 + * and 5.1 is being taken care of, the rest will stay in the wrong order + * for now. + * + * WARNING: the following needs a output format of 16 bits per sample. + * TODO: - reorder while copying (in the while() loop) and optimizing + */ + if(this->num_channels == 5 || this->num_channels == 6) + { + int i = 0; + uint16_t* buf = (uint16_t*)(sample_buffer); + + for(; i < this->faac_finfo.samples; i += this->num_channels) { + uint16_t center = buf[i]; + *((uint64_t*)(buf + i)) = *((uint64_t*)(buf + i + 1)); + buf[i + 4] = center; + } + } + while( decoded ) { audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); -- cgit v1.2.3 From 3186621e53a1c78ea093cf6ae9672cc7166b6ac7 Mon Sep 17 00:00:00 2001 From: Christophe Thommeret Date: Fri, 7 Nov 2008 17:05:55 +0000 Subject: voraw minor fix let raw video out plugin handle cropping. --HG-- extra : transplant_source : %F3l%EFUI%28%2C%A0%0C%3E%AD%EA%EC%80%D1%9A%C0/%20%E5 --- src/video_out/video_out_raw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/video_out/video_out_raw.c b/src/video_out/video_out_raw.c index 45cfc1eda..0d4bf445a 100644 --- a/src/video_out/video_out_raw.c +++ b/src/video_out/video_out_raw.c @@ -473,7 +473,7 @@ static int raw_gui_data_exchange (vo_driver_t *this_gen, int data_type, void *da static uint32_t raw_get_capabilities (vo_driver_t *this_gen) { - uint32_t capabilities = VO_CAP_YV12 | VO_CAP_YUY2; + uint32_t capabilities = VO_CAP_YV12 | VO_CAP_YUY2 | VO_CAP_CROP; return capabilities; } -- cgit v1.2.3 From 2c5aa1b2a0964a6df110d3cad0946b0870c62c0c Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sun, 19 Oct 2008 16:55:34 +0200 Subject: Pass native HWND through xine to SDL To place SDL output inside an existing window, the SDL_WINDOWID environement variable has to be set. This was done by the SDL video out pluging if HAVE_X11 was defined, but not for WIN32, where it works as well. --HG-- extra : transplant_source : E%169%A2%B4%93%3CY%07%A9%9F%1C%E0%B8-%14m4%A2%11 --- src/video_out/video_out_sdl.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_sdl.c b/src/video_out/video_out_sdl.c index b53d1d31c..89150f5d0 100644 --- a/src/video_out/video_out_sdl.c +++ b/src/video_out/video_out_sdl.c @@ -469,9 +469,11 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi sdl_driver_t *this; const SDL_VideoInfo *vidInfo; -#ifdef HAVE_X11 +#if defined(HAVE_X11) || defined(WIN32) static char SDL_windowhack[32]; x11_visual_t *visual = (x11_visual_t *) visual_gen; +#endif +#ifdef HAVE_X11 XWindowAttributes window_attributes; #endif @@ -502,14 +504,18 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi _x_vo_scale_init( &this->sc, 0, 0, config); this->sc.frame_output_cb = visual->frame_output_cb; this->sc.user_data = visual->user_data; - - /* set SDL to use our existing X11 window */ - sprintf(SDL_windowhack,"SDL_WINDOWID=0x%x", (uint32_t) this->drawable ); - putenv(SDL_windowhack); #else _x_vo_scale_init( &this->sc, 0, 0, config ); #endif +#if defined(HAVE_X11) || defined(WIN32) + /* set SDL to use our existing X11/win32 window */ + if (visual->d){ + sprintf(SDL_windowhack,"SDL_WINDOWID=0x%x", (uint32_t) visual->d); + putenv(SDL_windowhack); + } +#endif + if ((SDL_Init (SDL_INIT_VIDEO)) < 0) { xprintf (this->xine, XINE_VERBOSITY_DEBUG, "video_out_sdl: open_plugin - sdl video initialization failed.\n"); return NULL; -- cgit v1.2.3 From a1a7416f7c6cac2dd7d5b7262e3b494dd2c451d3 Mon Sep 17 00:00:00 2001 From: Christophe Thommeret Date: Fri, 7 Nov 2008 17:12:03 +0000 Subject: Fix resuming video after corrupted pes. Without this patch, the video freezes. Available corrupted sample: http://hftom.free.fr/video_samples/corrupted_video.m2t --HG-- extra : transplant_source : %86g%9A%B1%AF%12L%7E%3EN%8C%0FT%D2%D8%3B%7Dv%F0%14 --- src/demuxers/demux_ts.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index 6c2adc67f..55e06c033 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -249,6 +249,7 @@ typedef struct { int64_t packet_count; int corrupted_pes; uint32_t buffered_bytes; + int autodetected; } demux_ts_media; @@ -932,9 +933,11 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, m->buf->free_buffer(m->buf); m->buf = NULL; - if (m->corrupted_pes > CORRUPT_PES_THRESHOLD) { - if (this->videoPid == m->pid) + if (m->corrupted_pes > CORRUPT_PES_THRESHOLD && m->autodetected) { + if (this->videoPid == m->pid) { this->videoPid = INVALID_PID; + this->last_pmt_crc = 0; + } } else { m->corrupted_pes++; xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, @@ -1855,6 +1858,7 @@ static void demux_ts_parse_packet (demux_ts_t*this) { } else if (!found) { this->videoPid = pid; this->videoMedia = this->media_num; + this->media[this->videoMedia].autodetected = 1; demux_ts_pes_new(this, this->media_num++, pid, this->video_fifo, 0x100 + pes_stream_id); } @@ -2269,6 +2273,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, for (i = 0; i < MAX_PIDS; i++) { this->media[i].pid = INVALID_PID; this->media[i].buf = NULL; + this->media[i].autodetected = 0; } for (i = 0; i < MAX_PMTS; i++) { -- cgit v1.2.3 From 9620f841cbb1aa8284b1c8aa40ddcb18611c056c Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 30 Oct 2008 21:57:36 +0100 Subject: Create secondary buffer with correct pixelformat If neither YV12 nor YUV2 format is supported by DirectX, a secondary buffer with the same pixelformat as the primary buffer is used. However, the pixel format of the primary was not passed to CreateSurface, instead a 16 bit pixelformat was created, which is the reason why the video was broken on 24bit or 32bit desktops. --HG-- extra : transplant_source : %A6-%ADwyY%EE%C8%26%E2%5E%2A%83%0A%0B/%CBM%23%0F --- src/video_out/video_out_directx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_directx.c b/src/video_out/video_out_directx.c index f1136eab0..529968bec 100644 --- a/src/video_out/video_out_directx.c +++ b/src/video_out/video_out_directx.c @@ -117,7 +117,7 @@ typedef struct { yuv2rgb_t *yuv2rgb; /* used for format conversion */ int mode; /* rgb mode */ int bytespp; /* rgb bits per pixel */ - + DDPIXELFORMAT primary_pixel_format; alphablend_t alphablend_extra_data; } win32_driver_t; @@ -367,8 +367,9 @@ static boolean CreateSecondary( win32_driver_t * win32_driver, int width, int he lprintf("CreateSecondary() - Falling back to back buffer same as primary\n"); lprintf("CreateSecondary() - act_format = (NATIVE) %d\n", IMGFMT_NATIVE); - ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; + ddsd.ddpfPixelFormat = win32_driver->primary_pixel_format; win32_driver->act_format = IMGFMT_NATIVE; if( IDirectDraw_CreateSurface( win32_driver->ddobj, &ddsd, &win32_driver->secondary, 0 ) == DD_OK ) @@ -429,6 +430,10 @@ static boolean CheckPixelFormat( win32_driver_t * win32_driver ) Error( 0, "IDirectDrawSurface_GetPixelFormat ( CheckPixelFormat ) : error 0x%lx", result ); return 0; } + + /* store pixel format for CreateSecondary */ + + win32_driver->primary_pixel_format = ddpf; /* TODO : support paletized video modes */ @@ -478,6 +483,7 @@ static boolean CheckPixelFormat( win32_driver_t * win32_driver ) win32_driver->mode = MODE_15_BGR; } + lprintf("win32 mode: %u\n", win32_driver->mode); return TRUE; } -- cgit v1.2.3 From 486e615e6b15f85c209fd2050f24d1188c6e4291 Mon Sep 17 00:00:00 2001 From: "mringwal@vs22.inf.ethz.ch" Date: Wed, 5 Nov 2008 19:49:42 +0100 Subject: Simpler code, no gaps during playback in DirectX(2) audio output The playback pointer did occasionally overrun the write pointer, which results in audible gaps in playback. To solve this, the slotted ringbuffer was replaced by a simple ringbuffer and the service threads now checks periodically if there is still data in the buffer instead of checking at the slots borders. --HG-- extra : transplant_source : %A1%12%60%B9%E4%AB%E7%7C%D7%D6%BD%7C%C6M%C9%94s%7F%BE%91 --- src/audio_out/audio_directx2_out.c | 460 ++++++++++++++++--------------------- 1 file changed, 203 insertions(+), 257 deletions(-) (limited to 'src') diff --git a/src/audio_out/audio_directx2_out.c b/src/audio_out/audio_directx2_out.c index 5fffd1e2d..e91e919fc 100644 --- a/src/audio_out/audio_directx2_out.c +++ b/src/audio_out/audio_directx2_out.c @@ -31,6 +31,9 @@ * * Authors: * - Frantisek Dvorak + * - Original version with slotted ring buffer + * - Matthias Ringald + * - non-slotted simpler version for ring buffer handling * * Inspiration: * - mplayer for workarounding -lguid idea @@ -55,8 +58,8 @@ #define LOG_MODULE "audio_directx2_out" #define LOG_VERBOSE /* -#define LOG -*/ + #define LOG + */ #include "xine_internal.h" #include "audio_out.h" @@ -64,29 +67,33 @@ #define AO_OUT_DIRECTX2_IFACE_VERSION 8 + +/* + * If GAP_TOLERANCE is lower than AO_MAX_GAP, xine will + * try to smooth playback without skipping frames or + * inserting silence. + */ +#define GAP_TOLERANCE (AO_MAX_GAP/3) + /* * buffer size in miliseconds * (one second takes 11-192 KB) */ #define BUFFER_MS 1000 -/* - * number of parts in the buffer, - * one is always locked for playing +/* + * buffer below this threshold is considered a buffer underrun */ -#define PARTS 3 +#define BUFFER_MIN_MS 200 /* * base power factor for volume remapping */ #define FACTOR 60.0 - -/* experiments */ -/*#define EXACT_WAIT*/ -/*#define EXACT_SLEEP*/ -/*#define PANIC_OVERRUN*/ - +/* + * buffer handler status + */ #define STATUS_START 0 #define STATUS_WAIT 1 #define STATUS_RUNNING 2 @@ -108,12 +115,14 @@ typedef struct { LPDIRECTSOUND ds; /* DirectSound device */ LPDIRECTSOUNDBUFFER dsbuffer; /* DirectSound buffer */ - DSBPOSITIONNOTIFY events[PARTS]; /* position events */ - LPDIRECTSOUNDNOTIFY notify; /* notify interface */ size_t buffer_size; /* size of the buffer */ - size_t part_size; /* second half of buffer */ - size_t read_size; /* size of prepared data */ + size_t write_pos; /* positition in ring buffer for writing*/ + + int status; /* current status of the driver */ + int paused; /* paused mode */ + int finished; /* driver finished */ + int failed; /* don't open modal dialog again */ uint32_t bits; uint32_t rate; @@ -123,12 +132,6 @@ typedef struct { int volume; int muted; - int status; /* current status of the driver */ - int paused; /* paused mode */ - int finished; /* driver finished */ - int failed; /* don't open modal dialog again */ - int count; /* current free part number */ - pthread_t buffer_service; /* service thread for operating with DSB */ pthread_cond_t data_cond; /* signals on data */ pthread_mutex_t data_mutex; /* data lock */ @@ -141,16 +144,14 @@ typedef struct { * the linking stage. *****************************************************************************/ static const GUID IID_IDirectSoundNotify = { - 0xB0210783, 0x89CD, 0x11D0, {0xAF, 0x08, 0x00, 0xA0, 0xC9, 0x25, 0xCD, 0x16} +0xB0210783, 0x89CD, 0x11D0, {0xAF, 0x08, 0x00, 0xA0, 0xC9, 0x25, 0xCD, 0x16} }; -static int buffer_ready(dx2_driver_t *this); - /* popup a dialog with error */ static void XINE_FORMAT_PRINTF(1, 2) - error_message(const char *fmt, ...) { +error_message(const char *fmt, ...) { char message[256]; va_list ap; @@ -214,7 +215,7 @@ static LPDIRECTSOUND dsound_create() { /* destroy direct sound object */ static void dsound_destroy(LPDIRECTSOUND ds) { - IDirectSound_Release(ds); + IDirectSound_Release(ds); } @@ -266,12 +267,10 @@ static int audio_create_buffers(dx2_driver_t *this) { HRESULT err; size_t buffer_size; - buffer_size = this->rate * this->frame_size * BUFFER_MS / 1000; + buffer_size = this->rate * BUFFER_MS / 1000 * this->frame_size; if (buffer_size > DSBSIZE_MAX) buffer_size = DSBSIZE_MAX; if (buffer_size < DSBSIZE_MIN) buffer_size = DSBSIZE_MIN; - this->part_size = (buffer_size / PARTS / this->frame_size) * this->frame_size; - if (!this->part_size) this->part_size = this->frame_size; - this->buffer_size = this->part_size * PARTS; + this->buffer_size = buffer_size; flags = DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY; dsound_fill_wfx(&wfx, this->bits, this->rate, this->channels, this->frame_size); @@ -282,7 +281,7 @@ static int audio_create_buffers(dx2_driver_t *this) { return 0; } - lprintf("created direct sound buffer, size = %u, part = %u\n", this->buffer_size, this->part_size); + lprintf("created direct sound buffer, size = %u\n", this->buffer_size); return 1; } @@ -293,43 +292,6 @@ static void audio_destroy_buffers(dx2_driver_t *this) { } -/* create position events */ -static int audio_create_events(dx2_driver_t *this) { - HANDLE handle[PARTS]; - HRESULT err; - int i; - - for (i = 0; i < PARTS; i++) { - handle[i] = CreateEvent(NULL, FALSE, FALSE, NULL); - if (!handle[i]) { - error_message(_("Unable to create buffer position events.")); - return 0; - } - this->events[i].dwOffset = i * this->part_size; - this->events[i].hEventNotify = handle[i]; - } - - if ((err = IDirectSoundBuffer_QueryInterface(this->dsbuffer, &IID_IDirectSoundNotify, (void **)&this->notify)) != DS_OK) { - audio_error(this, err, _("Unable to get notification interface")); - return 0; - } - - if ((err = IDirectSoundNotify_SetNotificationPositions(this->notify, PARTS, this->events)) != DS_OK) { - audio_error(this, err, _("Unable to set notification positions")); - IDirectSoundNotify_Release(this->notify); - return 0; - } - - return 1; -} - - -/* destroy notification interface */ -static void audio_destroy_events(dx2_driver_t *this) { - IDirectSoundNotify_Release(this->notify); -} - - /* start playback */ static int audio_play(dx2_driver_t *this) { HRESULT err; @@ -385,8 +347,7 @@ static int audio_seek(dx2_driver_t *this, size_t pos) { /* flush audio buffers */ static int audio_flush(dx2_driver_t *this) { this->status = STATUS_WAIT; - this->count = 0; - this->read_size = 0; + this->write_pos = 0; return audio_seek(this, 0); } @@ -421,12 +382,12 @@ static int audio_fill(dx2_driver_t *this, char *data, size_t size) { HRESULT err; /* lock a part of the buffer, begin position on free space */ - err = IDirectSoundBuffer_Lock(this->dsbuffer, (this->count * this->part_size + this->read_size) % this->buffer_size, size, &ptr1, &size1, &ptr2, &size2, 0); + err = IDirectSoundBuffer_Lock(this->dsbuffer, this->write_pos, size, &ptr1, &size1, &ptr2, &size2, 0); /* try to restore the buffer, if necessary */ if (err == DSERR_BUFFERLOST) { xine_log(this->class->xine, XINE_LOG_MSG, _(LOG_MODULE ": buffer lost, tryig to restore\n")); IDirectSoundBuffer_Restore(this->dsbuffer); - err = IDirectSoundBuffer_Lock(this->dsbuffer, (this->count * this->part_size + this->read_size) % this->buffer_size, size, &ptr1, &size1, &ptr2, &size2, 0); } + err = IDirectSoundBuffer_Lock(this->dsbuffer, this->write_pos, size, &ptr1, &size1, &ptr2, &size2, 0); } if (err != DS_OK) { audio_error(this, err, _("Couldn't lock direct sound buffer")); return 0; @@ -436,19 +397,15 @@ static int audio_fill(dx2_driver_t *this, char *data, size_t size) { if (ptr1 && size1) xine_fast_memcpy(ptr1, data, size1); if (ptr2 && size2) xine_fast_memcpy(ptr2, data + size1, size2); - this->read_size += size; + // this->read_size += size; + this->write_pos = (this->write_pos + size ) % this->buffer_size; + lprintf("size %u, write_pos %u\n", size, this->write_pos); if ((err = IDirectSoundBuffer_Unlock(this->dsbuffer, ptr1, size1, ptr2, size2)) != DS_OK) { audio_error(this, err, _("Couldn't unlock direct sound buffer")); return 0; } - /* signal, if are waiting and need wake up */ - if ((this->status == STATUS_WAIT) && buffer_ready(this)) { - lprintf("buffer ready, waking up\n"); - pthread_cond_signal(&this->data_cond); - } - return 1; } @@ -458,28 +415,28 @@ static int mode2channels(uint32_t mode) { int channels; switch(mode) { - case AO_CAP_MODE_MONO: - channels = 1; - break; - - case AO_CAP_MODE_STEREO: - channels = 2; - break; - - case AO_CAP_MODE_4CHANNEL: - channels = 4; - break; - - case AO_CAP_MODE_5CHANNEL: - channels = 5; - break; - - case AO_CAP_MODE_5_1CHANNEL: - channels = 6; - break; - - default: - return 0; + case AO_CAP_MODE_MONO: + channels = 1; + break; + + case AO_CAP_MODE_STEREO: + channels = 2; + break; + + case AO_CAP_MODE_4CHANNEL: + channels = 4; + break; + + case AO_CAP_MODE_5CHANNEL: + channels = 5; + break; + + case AO_CAP_MODE_5_1CHANNEL: + channels = 6; + break; + + default: + return 0; } return channels; @@ -556,109 +513,96 @@ static int test_capabilities(dx2_driver_t *this) { /* size of free space in the ring buffer */ static size_t buffer_free_size(dx2_driver_t *this) { - size_t used_full_size; + + int ret; + size_t play_pos; + size_t free_space; - used_full_size = this->read_size + ((this->status != STATUS_WAIT) ? this->part_size : 0); - _x_assert(used_full_size <= this->buffer_size); - return this->buffer_size - used_full_size; + // get current play pos + ret = audio_tell(this, &play_pos); + if (!ret) + return 0; + + // calc free space (-1) + free_space = (this->buffer_size + play_pos - this->write_pos - 1) % this->buffer_size; + + return free_space; } -/* enough data in the ring buffer for playing next part? */ -static int buffer_ready(dx2_driver_t *this) { - return this->read_size >= this->part_size; +/* size of occupied space in the ring buffer */ +static size_t buffer_occupied_size(dx2_driver_t *this) { + int ret; + size_t play_pos; + size_t used_space; + + // get current play pos + ret = audio_tell(this, &play_pos); + if (!ret) return 0; + + // calc used space + used_space = (this->buffer_size + this->write_pos - play_pos) % this->buffer_size; + + return used_space; } /* service thread working with direct sound buffer */ static void *buffer_service(void *data) { dx2_driver_t *this = (dx2_driver_t *)data; - HANDLE handles[PARTS]; DWORD ret; - int i; -#if defined(EXACT_SLEEP) || defined(EXACT_WAIT) - size_t play_pos, req_delay; -#endif + size_t play_pos; + size_t buffer_min; + size_t data_in_buffer; /* prepare empty buffer */ audio_flush(this); - for (i = 0; i < PARTS; i++) handles[i] = this->events[i].hEventNotify; - + /* prepare min buffer fill */ + buffer_min = BUFFER_MIN_MS * this->rate / 1000 * this->frame_size; + /* we live! */ pthread_mutex_lock(&this->data_mutex); pthread_cond_signal(&this->data_cond); pthread_mutex_unlock(&this->data_mutex); while (!this->finished) { + pthread_mutex_lock(&this->data_mutex); - if (!buffer_ready(this)) { - if (!audio_stop(this)) goto fail; - lprintf("no data (count=%d,free=%" PRIsizet ",avail=%" PRIsizet "), sleeping...\n", this->count, buffer_free_size(this), this->read_size); - this->status = STATUS_WAIT; - pthread_cond_wait(&this->data_cond, &this->data_mutex); - lprintf("wake up (count=%d,free=%" PRIsizet "--,avail=%" PRIsizet ")\n", this->count, buffer_free_size(this), this->read_size); - if (this->finished) goto finished; - if (!audio_seek(this, this->count * this->part_size)) goto fail; - if (!this->paused) { - if (!audio_play(this)) goto fail; - } - this->status = STATUS_RUNNING; - this->count = (this->count + 1) % PARTS; - this->read_size -= this->part_size; - pthread_mutex_unlock(&this->data_mutex); - lprintf("wait for playback (newcount=%d,free=%" PRIsizet ",avail=%" PRIsizet ")\n", this->count, buffer_free_size(this), this->read_size); - do { - ret = WaitForMultipleObjects(PARTS, handles, FALSE, 250) - WAIT_OBJECT_0; + switch( this->status){ + + case STATUS_WAIT: + + // pre: stop/buffer flushed + lprintf("no data, sleeping...\n"); + pthread_cond_wait(&this->data_cond, &this->data_mutex); + lprintf("woke up (write_pos=%d,free=%" PRIsizet")\n", this->write_pos, buffer_free_size(this)); if (this->finished) goto finished; - } while (ret > PARTS); - lprintf("playback started (newcount=%d,ev=%d,free=%" PRIsizet ",avail=%" PRIsizet ")\n", this->count, ret, buffer_free_size(this), this->read_size); - _x_assert(ret == ((PARTS + this->count - 1) % PARTS)); - } else { - this->count = (this->count + 1) % PARTS; - this->read_size -= this->part_size; - pthread_mutex_unlock(&this->data_mutex); - } - lprintf("waiting for sound event(count=%d,free=%" PRIsizet ",avail=%" PRIsizet ")...\n", this->count, buffer_free_size(this), this->read_size); - do { - ret = WaitForMultipleObjects(PARTS, handles, FALSE, 250) - WAIT_OBJECT_0; - if (this->finished) goto finished; - } while (ret > PARTS); - lprintf("end wait(ev=%" PRIdword ",count=%d,free=%" PRIsizet ",avail=%" PRIsizet ")\n", ret, this->count, buffer_free_size(this), this->read_size); -#ifdef PANIC_OVERRUN - _x_abort(ret == this->count); -#else - if (ret != this->count) { - xine_log(this->class->xine, XINE_LOG_MSG, _(LOG_MODULE ": play cursor overran, flushing buffers\n")); - pthread_mutex_lock(&this->data_mutex); - if (!audio_stop(this)) goto fail; - if (!audio_flush(this)) goto fail; - pthread_mutex_unlock(&this->data_mutex); - } -#endif - -#if defined(EXACT_SLEEP) || defined(EXACT_WAIT) - /* ugly hack: wait for right time, + little over for sure */ - pthread_mutex_lock(&this->data_mutex); - if (!audio_tell(this, &play_pos)) goto fail; - req_delay = (this->buffer_size + play_pos - this->count * this->part_size) % this->buffer_size; - pthread_mutex_unlock(&this->data_mutex); - if (req_delay > (this->buffer_size >> 1)) { - long delay; - - delay = 1000 * (this->buffer_size - req_delay) / (this->frame_size * this->rate) + 1 + BUFFER_MS / PARTS / 4; - xine_log(this->class->xine, XINE_LOG_MSG, _(LOG_MODULE ": delayed by %ld msec\n"), delay); - printf("should be delayed %ld msec\n", delay); -#ifdef EXACT_SLEEP - xine_usec_sleep(delay * 1000); -#endif -#ifdef EXACT_WAIT - WaitForMultipleObjects(PARTS, handles, FALSE, delay); -#endif + if (!audio_seek(this, 0)) goto fail; + if (!this->paused) { + if (!audio_play(this)) goto fail; + } + this->status = STATUS_RUNNING; + pthread_mutex_unlock(&this->data_mutex); + break; + + case STATUS_RUNNING: + + // check for buffer underrun + data_in_buffer = buffer_occupied_size(this); + if ( data_in_buffer < buffer_min){ + xine_log(this->class->xine, XINE_LOG_MSG, _(LOG_MODULE ": play cursor overran (data %u, min %u), flushing buffers\n"), + data_in_buffer, buffer_min); + if (!audio_stop(this)) goto fail; + if (!audio_flush(this)) goto fail; + } + pthread_mutex_unlock(&this->data_mutex); + + // just wait BUFFER_MIN_MS before next check + xine_usec_sleep(BUFFER_MIN_MS * 1000); + break; } -#endif } - return NULL; fail: @@ -683,15 +627,15 @@ static int ao_dx2_get_property(ao_driver_t *this_gen, int property) { switch(property) { - case AO_PROP_MIXER_VOL: - case AO_PROP_PCM_VOL: - return this->volume; + case AO_PROP_MIXER_VOL: + case AO_PROP_PCM_VOL: + return this->volume; - case AO_PROP_MUTE_VOL: - return this->muted; + case AO_PROP_MUTE_VOL: + return this->muted; - default: - return 0; + default: + return 0; } } @@ -702,26 +646,26 @@ static int ao_dx2_set_property(ao_driver_t *this_gen, int property, int value) { switch(property) { - case AO_PROP_MIXER_VOL: - case AO_PROP_PCM_VOL: - lprintf("set volume to %d\n", value); - pthread_mutex_lock(&this->data_mutex); - if (!this->muted) { - if (this->dsbuffer && !audio_set_volume(this, value)) return ~value; - } - this->volume = value; - pthread_mutex_unlock(&this->data_mutex); - break; + case AO_PROP_MIXER_VOL: + case AO_PROP_PCM_VOL: + lprintf("set volume to %d\n", value); + pthread_mutex_lock(&this->data_mutex); + if (!this->muted) { + if (this->dsbuffer && !audio_set_volume(this, value)) return ~value; + } + this->volume = value; + pthread_mutex_unlock(&this->data_mutex); + break; - case AO_PROP_MUTE_VOL: - pthread_mutex_lock(&this->data_mutex); - if (this->dsbuffer && !audio_set_volume(this, value ? 0 : this->volume)) return ~value; - this->muted = value; - pthread_mutex_unlock(&this->data_mutex); - break; + case AO_PROP_MUTE_VOL: + pthread_mutex_lock(&this->data_mutex); + if (this->dsbuffer && !audio_set_volume(this, value ? 0 : this->volume)) return ~value; + this->muted = value; + pthread_mutex_unlock(&this->data_mutex); + break; - default: - return ~value; + default: + return ~value; } @@ -747,18 +691,17 @@ static int ao_dx2_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int this->status = STATUS_START; if (!audio_create_buffers(this)) return 0; - if (!audio_create_events(this)) goto fail_buffers; - if (!audio_set_volume(this, this->volume)) goto fail_events; + if (!audio_set_volume(this, this->volume)) goto fail_buffers; if (pthread_cond_init(&this->data_cond, NULL) != 0) { xine_log(this->class->xine, XINE_LOG_MSG, _(LOG_MODULE ": can't create pthread condition: %s\n"), strerror(errno)); - goto fail_events; + goto fail_buffers; } if (pthread_mutex_init(&this->data_mutex, NULL) != 0) { xine_log(this->class->xine, XINE_LOG_MSG, _(LOG_MODULE ": can't create pthread mutex: %s\n"), strerror(errno)); goto fail_cond; } - + /* creating the service thread and waiting for its signal */ pthread_mutex_lock(&this->data_mutex); if (pthread_create(&this->buffer_service, NULL, buffer_service, this) != 0) { @@ -775,8 +718,6 @@ fail_mutex: pthread_mutex_destroy(&this->data_mutex); fail_cond: pthread_cond_destroy(&this->data_cond); -fail_events: - audio_destroy_events(this); fail_buffers: audio_destroy_buffers(this); return 0; @@ -803,22 +744,26 @@ static int ao_dx2_bytes_per_frame(ao_driver_t *this_gen) { static int ao_dx2_delay(ao_driver_t *this_gen) { dx2_driver_t *this = (dx2_driver_t *)this_gen; - int frames; - size_t final_pos, play_pos; - - if (this->status != STATUS_RUNNING) return this->read_size / this->frame_size; + int frames = 0; + int ret; + size_t play_pos; pthread_mutex_lock(&this->data_mutex); - if (!audio_tell(this, &play_pos)) { - pthread_mutex_unlock(&this->data_mutex); - return 0; - } - final_pos = this->read_size + (((PARTS + this->count - 1) % PARTS) + 1) * this->part_size - 1; - frames = (this->buffer_size + final_pos - play_pos) % this->buffer_size / this->frame_size; + + if (this->status != STATUS_RUNNING){ + frames = this->write_pos / this->frame_size; + } else { + ret = audio_tell(this, &play_pos); + if (ret){ + frames = buffer_occupied_size(this) / this->frame_size; + } + } + pthread_mutex_unlock(&this->data_mutex); #ifdef LOG - if ((rand() % 10) == 0) lprintf("frames=%d, play_pos=%" PRIdword ", block=%" PRIsizet "..%" PRIsizet "\n", frames, play_pos, final_pos - this->part_size + 1, final_pos); + if ((rand() % 10) == 0) + lprintf("frames=%d, play_pos=%" PRIdword ", write_pos=%u\n", frames, play_pos, this->write_pos); #endif return frames; @@ -840,7 +785,7 @@ static int ao_dx2_write(ao_driver_t *this_gen, int16_t* audio_data, uint32_t num while (((free_size = buffer_free_size(this)) == 0) && !this->finished) { lprintf("buffer full, waiting\n"); pthread_mutex_unlock(&this->data_mutex); - xine_usec_sleep(1000 * BUFFER_MS / PARTS / 5); + xine_usec_sleep(1000 * BUFFER_MS / 10); pthread_mutex_lock(&this->data_mutex); } if (free_size >= input_size) size = input_size; @@ -856,6 +801,12 @@ static int ao_dx2_write(ao_driver_t *this_gen, int16_t* audio_data, uint32_t num input_size -= size; } + /* signal, if are waiting and need wake up */ + if ((this->status == STATUS_WAIT) && (buffer_occupied_size(this) > BUFFER_MIN_MS * this->rate / 1000 * this->frame_size)) { + lprintf("buffer ready, waking up\n"); + pthread_cond_signal(&this->data_cond); + } + return 1; } @@ -881,7 +832,6 @@ static void ao_dx2_close(ao_driver_t *this_gen) { if (pthread_mutex_destroy(&this->data_mutex) != 0) { xine_log(this->class->xine, XINE_LOG_MSG, _(LOG_MODULE ": can't destroy pthread mutex: %s\n"), strerror(errno)); } - audio_destroy_events(this); audio_destroy_buffers(this); } @@ -896,12 +846,8 @@ static void ao_dx2_exit(ao_driver_t *this_gen) { } -/* - * TODO: check - */ static int ao_dx2_get_gap_tolerance(ao_driver_t *this_gen) { - /* half of part of the buffer in pts (1 msec = 90 pts) */ - return (90 * (BUFFER_MS / PARTS)) >> 1; + return GAP_TOLERANCE; } @@ -910,36 +856,36 @@ static int ao_dx2_control(ao_driver_t *this_gen, int cmd, ...) { switch(cmd) { - case AO_CTRL_PLAY_PAUSE: - lprintf("control pause\n"); - pthread_mutex_lock(&this->data_mutex); - if (!this->paused) { - audio_stop(this); - this->paused = 1; - } - pthread_mutex_unlock(&this->data_mutex); - break; + case AO_CTRL_PLAY_PAUSE: + lprintf("control pause\n"); + pthread_mutex_lock(&this->data_mutex); + if (!this->paused) { + audio_stop(this); + this->paused = 1; + } + pthread_mutex_unlock(&this->data_mutex); + break; - case AO_CTRL_PLAY_RESUME: - lprintf("control resume\n"); - pthread_mutex_lock(&this->data_mutex); - if (this->paused) { - if (this->status != STATUS_WAIT) audio_play(this); - this->paused = 0; - } - pthread_mutex_unlock(&this->data_mutex); - break; - - case AO_CTRL_FLUSH_BUFFERS: - lprintf("control flush\n"); - pthread_mutex_lock(&this->data_mutex); - audio_stop(this); - audio_flush(this); - pthread_mutex_unlock(&this->data_mutex); - break; + case AO_CTRL_PLAY_RESUME: + lprintf("control resume\n"); + pthread_mutex_lock(&this->data_mutex); + if (this->paused) { + if (this->status != STATUS_WAIT) audio_play(this); + this->paused = 0; + } + pthread_mutex_unlock(&this->data_mutex); + break; + + case AO_CTRL_FLUSH_BUFFERS: + lprintf("control flush\n"); + pthread_mutex_lock(&this->data_mutex); + audio_stop(this); + audio_flush(this); + pthread_mutex_unlock(&this->data_mutex); + break; - default: - xine_log(this->class->xine, XINE_LOG_MSG, _(LOG_MODULE ": unknown control command %d\n"), cmd); + default: + xine_log(this->class->xine, XINE_LOG_MSG, _(LOG_MODULE ": unknown control command %d\n"), cmd); } -- cgit v1.2.3 From ce74fa96710338ac97c935cd6cf9c834f9e01701 Mon Sep 17 00:00:00 2001 From: Christophe Thommeret Date: Fri, 7 Nov 2008 17:14:54 +0000 Subject: some spudvb fixes This fixes several bugs/incompatibilities in spudvb decoder. You can find various test samples at http://hftom.free.fr/video_samples/ --HG-- extra : transplant_source : %CD%CE%3A%3F%B6%8BN%FD2%5D%DB%9A%AB%AF%C2%E1%2B%1A%B1%23 --- src/libspudvb/xine_spudvb_decoder.c | 46 ++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/libspudvb/xine_spudvb_decoder.c b/src/libspudvb/xine_spudvb_decoder.c index 957374799..8a4fe6926 100644 --- a/src/libspudvb/xine_spudvb_decoder.c +++ b/src/libspudvb/xine_spudvb_decoder.c @@ -48,6 +48,7 @@ typedef struct { } page_t; typedef struct { + int version_number; int width, height; int empty; int depth; @@ -166,20 +167,18 @@ static void update_region (dvb_spu_decoder_t * this, int region_id, int region_w lprintf( "can't allocate mem for region %d\n", region_id ); return; } - fill_color = 15; fill = 1; } - + if ( fill ) { memset( reg->img, fill_color, region_width*region_height ); reg->empty = 1; #ifdef LOG - printf("SPUDVB : FILL REGION %d\n", region_id); + printf("SPUDVB : FILL REGION %d\n", region_id); #endif } reg->width = region_width; reg->height = region_height; - page->regions[region_id].is_visible = 1; } @@ -409,17 +408,18 @@ static void process_page_composition_segment (dvb_spu_decoder_t * this) const int j = dvbsub->i + segment_length; dvbsub->page.page_time_out = dvbsub->buf[dvbsub->i++]; + if ( dvbsub->page.page_time_out>6 ) /* some timeout are insane, e.g. 65s ! */ + dvbsub->page.page_time_out = 6; - dvbsub->page.page_version_number = (dvbsub->buf[dvbsub->i] & 0xf0) >> 4; + int version = (dvbsub->buf[dvbsub->i] & 0xf0) >> 4; + if ( version == dvbsub->page.page_version_number ) + return; + dvbsub->page.page_version_number = version; dvbsub->page.page_state = (dvbsub->buf[dvbsub->i] & 0x0c) >> 2; dvbsub->i++; - if (dvbsub->page.page_state==2) { - int r; - for (r=0; rpage.regions[r].is_visible = 0; - } - else if ( dvbsub->page.page_state!=0 && dvbsub->page.page_state!=1 ) { - return; + int r; + for (r=0; rpage.regions[r].is_visible = 0; } while (dvbsub->i < j) { @@ -432,6 +432,7 @@ static void process_page_composition_segment (dvb_spu_decoder_t * this) dvbsub->page.regions[region_id].x = region_x; dvbsub->page.regions[region_id].y = region_y; + dvbsub->page.regions[region_id].is_visible = 1; } } @@ -465,6 +466,11 @@ static void process_region_composition_segment (dvb_spu_decoder_t * this) if(region_id>=MAX_REGIONS) return; + + if ( dvbsub->regions[region_id].version_number == region_version_number ) + return; + + dvbsub->regions[region_id].version_number = region_version_number; /* Check if region size has changed and fill background. */ update_region (this, region_id, region_width, region_height, region_fill_flag, region_4_bit_pixel_code); @@ -673,6 +679,9 @@ static void draw_subtitles (dvb_spu_decoder_t * this) printf("SPUDVB: this->vpts=%llu\n",this->vpts); #endif for ( r=0; rdvbsub->page.regions[r].is_visible, this->dvbsub->regions[r].osd?1:0, this->dvbsub->regions[r].empty ); +#endif if ( this->dvbsub->page.regions[r].is_visible && this->dvbsub->regions[r].osd && !this->dvbsub->regions[r].empty ) { this->stream->osd_renderer->set_position( this->dvbsub->regions[r].osd, this->dvbsub->page.regions[r].x, this->dvbsub->page.regions[r].y ); this->stream->osd_renderer->show( this->dvbsub->regions[r].osd, this->vpts ); @@ -761,6 +770,9 @@ static void spudec_decode_data (spu_decoder_t * this_gen, buf_element_t * buf) this->vpts = vpts; } + /* completely ignore pts since it makes a lot of problems with various providers */ + this->vpts = 0; + /* process the pes section */ const int PES_packet_length = this->pes_pkt_size; @@ -791,10 +803,10 @@ static void spudec_decode_data (spu_decoder_t * this_gen, buf_element_t * buf) /* SEGMENT_DATA_FIELD */ switch (segment_type) { case 0x10: - process_page_composition_segment (this); + process_page_composition_segment(this); break; case 0x11: - process_region_composition_segment (this); + process_region_composition_segment(this); break; case 0x12: process_CLUT_definition_segment(this); @@ -802,8 +814,8 @@ static void spudec_decode_data (spu_decoder_t * this_gen, buf_element_t * buf) case 0x13: process_object_data_segment (this); break; - case 0x80: /* Page is now completely rendered */ - draw_subtitles( this ); + case 0x80: + draw_subtitles( this ); /* Page is now completely rendered */ break; default: return; @@ -824,7 +836,9 @@ static void spudec_reset (spu_decoder_t * this_gen) for ( i=0; idvbsub->regions[i].osd ) this->stream->osd_renderer->hide(this->dvbsub->regions[i].osd, 0); + this->dvbsub->regions[i].version_number = -1; } + this->dvbsub->page.page_version_number = -1; pthread_mutex_unlock(&this->dvbsub_osd_mutex); } -- cgit v1.2.3 From d21d61e759acc7a390f5e755277d28bea14cf242 Mon Sep 17 00:00:00 2001 From: "valtri@funny.zcu.cz" Date: Fri, 7 Nov 2008 18:56:51 +0100 Subject: Recognise H.264 codec with "XiWave" fourcc too. --- src/xine-engine/buffer_types.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/xine-engine/buffer_types.c b/src/xine-engine/buffer_types.c index 911e123ed..8bee0e791 100644 --- a/src/xine-engine/buffer_types.c +++ b/src/xine-engine/buffer_types.c @@ -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, -- cgit v1.2.3 From aeb0a48595f6bb5c63e7f1d1d54f21c136c6c249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Fri, 7 Nov 2008 19:49:54 +0100 Subject: Fixed segfault on start when using XINE_PLUGIN_PATH. --- src/xine-engine/load_plugins.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 3d1c0e4a8..d8f77c464 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -1140,15 +1140,23 @@ void _x_scan_plugins (xine_t *this) { load_cached_catalog (this); if ((pluginpath = getenv("XINE_PLUGIN_PATH")) != NULL && *pluginpath) { - char *p = pluginpath - 1; - while (p[1]) + char *p = pluginpath; + while (p && p[0]) { - char *dir, *q = p; - p = strchr (p + 1, XINE_PATH_SEPARATOR_CHAR); + 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)(p - q - 1), q + 1); + asprintf (&dir, "%s%.*s", homedir, (int)(len - 1), q + 1); else - dir = strndup (q, p - q); + dir = strndup (q, len); push_if_dir (plugindirs, dir); /* store or free it */ } } else { @@ -1393,7 +1401,6 @@ demux_plugin_t *_x_find_demux_plugin_last_probe(xine_stream_t *stream, const cha i = 0; while (methods[i] != -1 && !plugin) { int list_id, list_size; - const char *mime_type; stream->content_detection_method = methods[i]; @@ -2461,7 +2468,6 @@ static char *_x_concatenate_with_string(char **strings, size_t count, char *join 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); -- cgit v1.2.3 From e471818f3f16ac2fabaad225be70b38382da8e9b Mon Sep 17 00:00:00 2001 From: Frantisek Dvorak Date: Sun, 9 Nov 2008 20:42:27 +0100 Subject: Matroska and FLI demuxers warning and valgrind fixes --- src/demuxers/demux_fli.c | 2 +- src/demuxers/demux_matroska.c | 6 +++--- src/demuxers/matroska.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_fli.c b/src/demuxers/demux_fli.c index fabc2c788..12ae81609 100644 --- a/src/demuxers/demux_fli.c +++ b/src/demuxers/demux_fli.c @@ -244,7 +244,7 @@ static void demux_fli_send_headers(demux_plugin_t *this_gen) { BUF_FLAG_FRAME_END; buf->decoder_info[0] = this->frame_pts_inc; /* initial video_step */ buf->size = this->bih.biSize; - memcpy(buf->content, &this->bih, sizeof(xine_bmiheader) + this->bih.biSize); + memcpy(buf->content, &this->bih, this->bih.biSize); buf->type = BUF_VIDEO_FLI; this->video_fifo->put (this->video_fifo, buf); } diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c index a8af6c44f..e6dd564a6 100644 --- a/src/demuxers/demux_matroska.c +++ b/src/demuxers/demux_matroska.c @@ -1298,7 +1298,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { lprintf("MATROSKA_CODEC_ID_V_MPEG4_*\n"); /* create a bitmap info header struct for MPEG 4 */ - bih = malloc(sizeof(xine_bmiheader) + track->codec_private_len); + bih = calloc(1, sizeof(xine_bmiheader) + track->codec_private_len); bih->biSize = sizeof(xine_bmiheader) + track->codec_private_len; bih->biCompression = ME_FOURCC('M', 'P', '4', 'S'); bih->biWidth = track->video_track->pixel_width; @@ -1319,7 +1319,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { lprintf("MATROSKA_CODEC_ID_V_MPEG4_AVC\n"); /* create a bitmap info header struct for h264 */ - bih = malloc(sizeof(xine_bmiheader) + track->codec_private_len); + bih = calloc(1, sizeof(xine_bmiheader) + track->codec_private_len); bih->biSize = sizeof(xine_bmiheader) + track->codec_private_len; bih->biCompression = ME_FOURCC('a', 'v', 'c', '1'); bih->biWidth = track->video_track->pixel_width; @@ -1896,7 +1896,7 @@ static int parse_block (demux_matroska_t *this, size_t block_size, lprintf("no lacing\n"); block_size_left = (this->block_data + block_size) - data; - lprintf("size: %d, block_size: %" PRIu64 "\n", block_size_left, block_size); + lprintf("size: %d, block_size: %u\n", block_size_left, block_size); if (track->handle_content != NULL) { track->handle_content((demux_plugin_t *)this, track, diff --git a/src/demuxers/matroska.h b/src/demuxers/matroska.h index 6806c207d..23af84af0 100644 --- a/src/demuxers/matroska.h +++ b/src/demuxers/matroska.h @@ -235,7 +235,7 @@ struct matroska_track_s { void (*handle_content) (demux_plugin_t *this_gen, matroska_track_t *track, int decoder_flags, - uint8_t *data, int data_len, + uint8_t *data, size_t data_len, int64_t data_pts, int data_duration, int input_normpos, int input_time); }; -- cgit v1.2.3 From 80738bd4f54bd6c73a68789303e8c34fa47d7dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Tue, 18 Nov 2008 21:13:55 +0100 Subject: Fix of the two opened CACA windows in cacaxine (xine-ui). There is needed some ui<->lib interaction: used caca display is optionally delivered from ui to the caca vo plugin. --- src/video_out/video_out_caca.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_caca.c b/src/video_out/video_out_caca.c index 3eec45211..65ebf707e 100644 --- a/src/video_out/video_out_caca.c +++ b/src/video_out/video_out_caca.c @@ -276,6 +276,7 @@ static int caca_redraw_needed (vo_driver_t *this_gen) { static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *visual_gen) { caca_class_t *class = (caca_class_t *) class_gen; + caca_display_t *dp = (caca_display_t *)visual_gen; caca_driver_t *this; this = calloc(1, sizeof (caca_driver_t)); @@ -300,8 +301,13 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi this->yuv2rgb_factory = yuv2rgb_factory_init(MODE_32_RGB, 0, NULL); this->yuv2rgb_factory->set_csc_levels(this->yuv2rgb_factory, 0, 128, 128); - this->cv = cucul_create_canvas(0, 0); - this->dp = caca_create_display(this->cv); + if (dp) { + this->cv = caca_get_canvas(dp); + this->dp = dp; + } else { + this->cv = cucul_create_canvas(0, 0); + this->dp = caca_create_display(this->cv); + } caca_refresh_display(this->dp); return &this->vo_driver; -- cgit v1.2.3 From 2ba1e128cbb791cfdb2829895a854bb664018912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 20 Nov 2008 20:39:50 +0100 Subject: Fix using of the pointers, leak fixes in configfile. --- src/audio_out/audio_oss_out.c | 4 ++-- src/video_out/video_out_raw.c | 4 ++-- src/xine-engine/configfile.c | 34 +++++++++++++++++++++------------- 3 files changed, 25 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/audio_out/audio_oss_out.c b/src/audio_out/audio_oss_out.c index 2ae116970..ba1044ed4 100644 --- a/src/audio_out/audio_oss_out.c +++ b/src/audio_out/audio_oss_out.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -666,7 +666,7 @@ static int probe_audio_devices(oss_driver_t *this) { int base_num, i; int audio_fd, rate; int best_rate; - char *devname[30]; + char devname[30]; strcpy(this->audio_dev, "auto"); diff --git a/src/video_out/video_out_raw.c b/src/video_out/video_out_raw.c index 0d4bf445a..99e2c0004 100644 --- a/src/video_out/video_out_raw.c +++ b/src/video_out/video_out_raw.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 the xine project + * Copyright (C) 2007-2008 the xine project * * This file is part of xine, a free video player. * @@ -212,7 +212,7 @@ static void raw_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) if ( !this->ovl_changed ) return; - this->raw_overlay_cb( this->user_data, this->ovl_changed-1, &this->overlays ); + this->raw_overlay_cb( this->user_data, this->ovl_changed-1, this->overlays ); this->ovl_changed = 0; } diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index cfe6f6a35..81acab348 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. * @@ -356,21 +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")) { - asprintf (&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... */ @@ -385,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,14 +398,18 @@ static void config_lookup_entry_int (config_values_t *this, const char *key, *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; + } } } @@ -747,7 +753,7 @@ 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; @@ -755,14 +761,14 @@ static int config_register_enum (config_values_t *this, 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); @@ -861,7 +867,7 @@ static void config_update_string (config_values_t *this, /* 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; } @@ -943,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) { -- cgit v1.2.3 From ea2b5508e35f5125fd65730822b30bb8895ad87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 20 Nov 2008 20:56:19 +0100 Subject: Some warning fixes: XINE_FORMAT_SCANF, statics in headers, consts, ... Add warning flags to the DEBUG_CFLAGS too. --- src/demuxers/demux_dts.c | 8 +++++++- src/demuxers/demux_mpeg_pes.c | 3 +-- src/demuxers/demux_real.c | 6 +++--- src/demuxers/demux_str.c | 5 ++--- src/demuxers/demux_wav.c | 8 +++++--- src/input/input_cdda.c | 18 +++++++++--------- src/input/input_dvb.c | 3 +-- src/input/input_smb.c | 12 ++++++------ src/input/input_v4l.c | 12 ++++-------- src/input/input_vcd.c | 4 +--- src/input/vcd/xineplug_inp_vcd.c | 8 ++++---- src/libmad/bit.c | 3 ++- src/libmad/layer12.c | 3 ++- src/libmad/layer3.c | 3 ++- src/libmpeg2/mpeg2.h | 6 ++++-- src/libreal/xine_real_audio_decoder.c | 3 +-- src/libreal/xine_real_video_decoder.c | 3 +-- src/libspucc/cc_decoder.h | 8 ++------ src/libspucc/xine_cc_decoder.c | 10 ++++++++-- src/libspucmml/xine_cmml_decoder.c | 4 ++-- src/libspudec/xine_spu_decoder.c | 3 +-- src/libspudvb/xine_spudvb_decoder.c | 7 +++---- src/libw32dll/wine/win32.c | 7 +++---- src/post/audio/filter.c | 2 +- src/post/audio/filter.h | 2 +- src/post/audio/volnorm.c | 3 +-- src/post/planar/eq2.c | 4 +--- src/video_out/deinterlace.c | 14 +++++++++++++- src/video_out/deinterlace.h | 13 ++----------- src/video_out/video_out_xv.c | 2 +- src/video_out/video_out_xvmc.c | 2 ++ src/video_out/video_out_xxmc.c | 7 +++---- src/xine-engine/buffer.h | 6 +++--- src/xine-engine/buffer_types.c | 6 +++--- src/xine-engine/load_plugins.c | 4 ++-- src/xine-utils/attributes.h | 6 ++++-- src/xine-utils/monitor.c | 3 +-- 37 files changed, 112 insertions(+), 109 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_dts.c b/src/demuxers/demux_dts.c index 24a31c1cb..0606586cb 100644 --- a/src/demuxers/demux_dts.c +++ b/src/demuxers/demux_dts.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 the xine project + * Copyright (C) 2005-2008 the xine project * * This file is part of xine, a free video player. * @@ -199,6 +199,12 @@ static int open_dts_file(demux_dts_t *this) { sfreq = peak[this->data_start+8] & 0x0f; break; + default: + xprintf (this->stream->xine, XINE_VERBOSITY_LOG, + LOG_MODULE ": unsupported DTS bitstream encoding %d\n", + dts_version); + return 0; + } if ((sfreq > sizeof(dts_sample_rates)/sizeof(int)) || diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c index 32dd2cb51..d9ac952d8 100644 --- a/src/demuxers/demux_mpeg_pes.c +++ b/src/demuxers/demux_mpeg_pes.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. * @@ -257,7 +257,6 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) uint8_t *p; int32_t result; off_t i; - int32_t n; uint8_t buf6[ 6 ]; this->scr = 0; diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index 32b516537..aa4dfc26b 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2005 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -1067,7 +1067,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { /* read the packet information */ const uint16_t stream = _X_BE_16(&header[4]); - const off_t offset = this->input->get_current_pos(this->input); + const off_t offset __attr_unused = this->input->get_current_pos(this->input); uint16_t size = _X_BE_16(&header[2]) - DATA_PACKET_HEADER_SIZE; const uint32_t timestamp= _X_BE_32(&header[6]); int64_t pts = (int64_t) timestamp * 90; @@ -1111,7 +1111,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { * seems to be a very short header * 2 bytes, purpose of the second byte yet unknown */ - const int bummer = stream_read_char (this); + const int bummer __attr_unused = stream_read_char (this); lprintf ("bummer == %02X\n",bummer); vpkg_offset = 0; diff --git a/src/demuxers/demux_str.c b/src/demuxers/demux_str.c index a49084ba7..442bffadc 100644 --- a/src/demuxers/demux_str.c +++ b/src/demuxers/demux_str.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -139,8 +139,7 @@ #define CD_RAW_SECTOR_SIZE 2352 -static const uint8_t STR_MAGIC = - { 0x60, 0x01, 0x01, 0x80 }; +#define STR_MAGIC "\x60\x01\x01\x80" #define STR_MAX_CHANNELS 32 #define CDXA_TYPE_MASK 0x0E diff --git a/src/demuxers/demux_wav.c b/src/demuxers/demux_wav.c index 4a1cc78ec..5fbec7b69 100644 --- a/src/demuxers/demux_wav.c +++ b/src/demuxers/demux_wav.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2005 the xine project + * Copyright (C) 2001-2008 the xine project * * This file is part of xine, a free video player. * @@ -112,6 +112,7 @@ static int find_chunk_by_tag(demux_wav_t *this, const uint32_t given_chunk_tag, static int open_wav_file(demux_wav_t *this) { uint8_t signature[WAV_SIGNATURE_SIZE]; off_t wave_pos; + uint32_t wave_size; /* check the signature */ if (_x_demux_read_header(this->input, signature, WAV_SIGNATURE_SIZE) != WAV_SIGNATURE_SIZE) @@ -122,8 +123,9 @@ static int open_wav_file(demux_wav_t *this) { /* search for the 'fmt ' chunk first */ wave_pos = 0; - if (find_chunk_by_tag(this, fmt_TAG, &this->wave_size, &wave_pos)==0) + if (find_chunk_by_tag(this, fmt_TAG, &wave_size, &wave_pos)==0) return 0; + this->wave_size = wave_size; this->input->seek(this->input, wave_pos, SEEK_SET); this->wave = malloc( this->wave_size ); @@ -146,7 +148,7 @@ static int open_wav_file(demux_wav_t *this) { /* search for the 'data' chunk */ this->data_start = this->data_size = 0; - if (find_chunk_by_tag(this, data_TAG, &this->data_size, &this->data_start)==0) + if (find_chunk_by_tag(this, data_TAG, NULL, &this->data_start)==0) { free (this->wave); return 0; diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index 06ab9d626..996460832 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2005 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -1033,13 +1033,13 @@ network_command( xine_stream_t *stream, int socket, char *data_buf, char *msg, . #ifndef WIN32 -static int network_connect(xine_stream_t *stream, char *url ) +static int network_connect(xine_stream_t *stream, const char *got_url ) { - char *host; + char *host, *url; int port; int fd; - url = strdup(url); + url = strdup(got_url); parse_url(url, &host, &port); if( !host || !strlen(host) || !port ) @@ -1450,7 +1450,7 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { while((pdir = readdir(dir)) != NULL) { char discid[9]; - snprintf(discid, sizeof(discid), "%08lx", this->cddb.disc_id); + snprintf(discid, sizeof(discid), "%08" PRIx32, this->cddb.disc_id); if(!strcasecmp(pdir->d_name, discid)) { FILE *fd; @@ -1549,7 +1549,7 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { } } xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, - "input_cdda: cached entry for disc ID %08lx not found.\n", this->cddb.disc_id); + "input_cdda: cached entry for disc ID %08" PRIx32 " not found.\n", this->cddb.disc_id); closedir(dir); } @@ -1573,7 +1573,7 @@ static void _cdda_save_cached_cddb_infos(cdda_input_plugin_t *this, char *fileco _cdda_mkdir_recursive_safe(this->stream->xine, cfile); - snprintf(cfile, sizeof(cfile), "%s/%08lx", this->cddb.cache_dir, this->cddb.disc_id); + snprintf(cfile, sizeof(cfile), "%s/%08" PRIx32 , this->cddb.cache_dir, this->cddb.disc_id); if((fd = fopen(cfile, "w")) == NULL) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, @@ -1712,7 +1712,7 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { /* Send query command */ memset(&buffer, 0, sizeof(buffer)); - size_t size = sprintf(buffer, "cddb query %08lx %d ", this->cddb.disc_id, this->cddb.num_tracks); + size_t size = sprintf(buffer, "cddb query %08" PRIx32 " %d ", this->cddb.disc_id, this->cddb.num_tracks); for (i = 0; i < this->cddb.num_tracks; i++) { size += snprintf(buffer + size, sizeof(buffer) - size, "%d ", this->cddb.track[i].start); } @@ -2004,7 +2004,7 @@ static void _cdda_free_cddb_info(cdda_input_plugin_t *this) { */ static int cdda_open(cdda_input_plugin_t *this_gen, - char *cdda_device, cdrom_toc *toc, int *fdd) { + const char *cdda_device, cdrom_toc *toc, int *fdd) { #ifndef WIN32 int fd = -1; diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c index 19b479a06..0fa5ba971 100644 --- a/src/input/input_dvb.c +++ b/src/input/input_dvb.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2005 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -3196,7 +3196,6 @@ static char **dvb_class_get_autoplay_list(input_class_t * this_gen, { dvb_input_class_t *class = (dvb_input_class_t *) this_gen; channel_t *channels=NULL; - char foobuffer[BUFSIZE]; int ch, apch, num_channels = 0; int default_channel = -1; xine_cfg_entry_t lastchannel_enable = {0}; diff --git a/src/input/input_smb.c b/src/input/input_smb.c index dbab772c9..3d495f04e 100644 --- a/src/input/input_smb.c +++ b/src/input/input_smb.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 the xine project + * Copyright (C) 2008 the xine project * * This file is part of xine, a free video player. * @@ -51,7 +51,7 @@ typedef struct { xine_stream_t *stream; /* File */ - char *mrl; + const char *mrl; int fd; } smb_input_t; @@ -138,7 +138,7 @@ smb_plugin_get_length (input_plugin_t *this_gen) return st.st_size; } -static char* +static const char* smb_plugin_get_mrl (input_plugin_t *this_gen) { smb_input_t *this = (smb_input_t *) this_gen; @@ -150,7 +150,7 @@ static uint32_t smb_plugin_get_blocksize (input_plugin_t *this_gen) { return 0; } -static char +static const char *smb_class_get_description (input_class_t *this_gen) { return _("CIFS/SMB input plugin based on libsmbclient"); @@ -280,7 +280,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = mrl_file | mrl_file_directory; dir_files[num_dir_files].origin = strdup("smb:/"); - asprintf(*(dir_files[num_dir_files].mrl), "%s/%s", "smb:/", pdirent->name); + asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", "smb:/", pdirent->name); dir_files[num_dir_files].size = pdirent->dirlen; num_dir_files ++; } else if (pdirent->smbc_type == SMBC_FILE_SHARE){ @@ -423,7 +423,7 @@ smb_plugin_dispose (input_plugin_t *this_gen ) if (this->fd>=0) smbc_close(this->fd); if (this->mrl) - free (this->mrl); + free ((char *)this->mrl); free (this); } diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c index b97f11ace..3a020bd69 100644 --- a/src/input/input_v4l.c +++ b/src/input/input_v4l.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2004 the xine project + * Copyright (C) 2003-2008 the xine project * Copyright (C) 2003 J.Asselman * * This file is part of xine, a free video player. @@ -100,10 +100,6 @@ static const resolution_t resolutions[] = { static char *tv_standard_names[] = { "AUTO", "PAL", "NTSC", "SECAM", "OLD", NULL }; static int tv_standard_values[] = { VIDEO_MODE_AUTO, VIDEO_MODE_PAL, VIDEO_MODE_NTSC, VIDEO_MODE_SECAM, -1 }; -#if !defined(NDELAY) && defined(O_NDELAY) -#define FNDELAY O_NDELAY -#endif - typedef struct pvrscr_s pvrscr_t; typedef struct { @@ -844,7 +840,7 @@ static int open_video_capture_device(v4l_input_plugin_t *this) { int found = 0; int tuner_found = 0; - int i, ret; + int ret; unsigned int j; cfg_entry_t *entry; @@ -1870,11 +1866,11 @@ static input_plugin_t *v4l_class_get_radio_instance (input_class_t *cls_gen, * v4l input plugin class stuff */ -static char *v4l_class_get_video_description (input_class_t *this_gen) { +static const char *v4l_class_get_video_description (input_class_t *this_gen) { return _("v4l tv input plugin"); } -static char *v4l_class_get_radio_description (input_class_t *this_gen) { +static const char *v4l_class_get_radio_description (input_class_t *this_gen) { return _("v4l radio input plugin"); } diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c index 90f6fcc70..760910a01 100644 --- a/src/input/input_vcd.c +++ b/src/input/input_vcd.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. * @@ -939,7 +939,6 @@ static void vcd_filelist_dispose(vcd_input_class_t *this) { static void vcd_class_dispose (input_class_t *this_gen) { vcd_input_class_t *this = (vcd_input_class_t *) this_gen; - int i; config_values_t *config = this->xine->config; config->unregister_callback(config, "media.vcd.device"); @@ -1068,7 +1067,6 @@ static void *init_class (xine_t *xine, void *data) { vcd_input_class_t *this; config_values_t *config = xine->config; - int i; this = calloc(1, sizeof (vcd_input_class_t)); diff --git a/src/input/vcd/xineplug_inp_vcd.c b/src/input/vcd/xineplug_inp_vcd.c index f4f823918..55b7f9b84 100644 --- a/src/input/vcd/xineplug_inp_vcd.c +++ b/src/input/vcd/xineplug_inp_vcd.c @@ -966,7 +966,7 @@ vcd_class_eject_media (input_class_t *this_gen) * From spec: * return current MRL */ -static char * +static const char * vcd_plugin_get_mrl (input_plugin_t *this_gen) { vcd_input_plugin_t *t = (vcd_input_plugin_t *) this_gen; @@ -987,7 +987,7 @@ vcd_plugin_get_mrl (input_plugin_t *this_gen) /* Bad type. */ LOG_ERR("%s %d", _("Invalid current entry type"), vcdplayer->play_item.type); - return strdup(""); + return ""; } else { n += offset; if (n < t->class->num_mrls) { @@ -995,7 +995,7 @@ vcd_plugin_get_mrl (input_plugin_t *this_gen) t->class->mrls[n]->mrl); return t->class->mrls[n]->mrl; } else { - return strdup(""); + return ""; } } } @@ -1005,7 +1005,7 @@ vcd_plugin_get_mrl (input_plugin_t *this_gen) return human readable (verbose = 1 line) description for this plugin */ -static char * +static const char * vcd_class_get_description (input_class_t *this_gen) { dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT), "called\n"); diff --git a/src/libmad/bit.c b/src/libmad/bit.c index 8d9571e8f..cd0fe4904 100644 --- a/src/libmad/bit.c +++ b/src/libmad/bit.c @@ -27,7 +27,8 @@ # ifdef HAVE_LIMITS_H # include -# else +# endif +# ifndef CHAR_BIT # define CHAR_BIT 8 # endif diff --git a/src/libmad/layer12.c b/src/libmad/layer12.c index 25fd04d70..76def1189 100644 --- a/src/libmad/layer12.c +++ b/src/libmad/layer12.c @@ -27,7 +27,8 @@ # ifdef HAVE_LIMITS_H # include -# else +# endif +#ifndef CHAR_BIT # define CHAR_BIT 8 # endif diff --git a/src/libmad/layer3.c b/src/libmad/layer3.c index c5d46e8d1..899102e0d 100644 --- a/src/libmad/layer3.c +++ b/src/libmad/layer3.c @@ -34,7 +34,8 @@ # ifdef HAVE_LIMITS_H # include -# else +#endif +# ifndef CHAR_BIT # define CHAR_BIT 8 # endif diff --git a/src/libmpeg2/mpeg2.h b/src/libmpeg2/mpeg2.h index 253f300a2..ae69688f5 100644 --- a/src/libmpeg2/mpeg2.h +++ b/src/libmpeg2/mpeg2.h @@ -31,7 +31,8 @@ typedef struct mpeg2dec_s { uint32_t frame_format; /* this is where we keep the state of the decoder */ - struct picture_s * picture, *picture_base; + struct picture_s * picture; + void *picture_base; uint32_t shift; int new_sequence; @@ -45,7 +46,8 @@ typedef struct mpeg2dec_s { /* which is 224K for MP@ML streams. */ /* (we make no pretenses of decoding anything more than that) */ /* allocated in init - gcc has problems allocating such big structures */ - uint8_t * chunk_buffer, *chunk_base; + uint8_t * chunk_buffer; + void *chunk_base; /* pointer to current position in chunk_buffer */ uint8_t * chunk_ptr; /* last start code ? */ diff --git a/src/libreal/xine_real_audio_decoder.c b/src/libreal/xine_real_audio_decoder.c index 7f4942cc5..20f67a984 100644 --- a/src/libreal/xine_real_audio_decoder.c +++ b/src/libreal/xine_real_audio_decoder.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -510,7 +510,6 @@ static void dispose_class (audio_decoder_class_t *this) { void *init_realadec (xine_t *xine, void *data) { real_class_t *this; - config_values_t *config = xine->config; this = (real_class_t *) calloc(1, sizeof(real_class_t)); diff --git a/src/libreal/xine_real_video_decoder.c b/src/libreal/xine_real_video_decoder.c index e048b04d6..3c575d0a8 100644 --- a/src/libreal/xine_real_video_decoder.c +++ b/src/libreal/xine_real_video_decoder.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. * @@ -533,7 +533,6 @@ static void dispose_class (video_decoder_class_t *this) { void *init_realvdec (xine_t *xine, void *data) { real_class_t *this; - config_values_t *config = xine->config; this = (real_class_t *) calloc(1, sizeof(real_class_t)); diff --git a/src/libspucc/cc_decoder.h b/src/libspucc/cc_decoder.h index 8698189a6..47703b6d1 100644 --- a/src/libspucc/cc_decoder.h +++ b/src/libspucc/cc_decoder.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project + * Copyright (C) 2000-2008 the xine project * * Copyright (C) Christian Vogler * cvogler@gradient.cis.upenn.edu - December 2001 @@ -31,11 +31,7 @@ typedef struct cc_decoder_s cc_decoder_t; typedef struct cc_renderer_s cc_renderer_t; #define NUM_CC_PALETTES 2 -static const char *cc_schemes[NUM_CC_PALETTES + 1] = { - "White/Gray/Translucent", - "White/Black/Solid", - NULL -}; +extern const char *cc_schemes[]; #define CC_FONT_MAX 256 diff --git a/src/libspucc/xine_cc_decoder.c b/src/libspucc/xine_cc_decoder.c index 0018bfa1e..1d9c87366 100644 --- a/src/libspucc/xine_cc_decoder.c +++ b/src/libspucc/xine_cc_decoder.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -33,6 +33,12 @@ #define LOG_DEBUG 1 */ +const char *cc_schemes[NUM_CC_PALETTES + 1] = { + "White/Gray/Translucent", + "White/Black/Solid", + NULL +}; + typedef struct spucc_decoder_s { spu_decoder_t spu_decoder; @@ -193,7 +199,7 @@ static void spucc_register_cfg_vars(spucc_class_t *this, cc_vars->cc_scheme = xine_cfg->register_enum(xine_cfg, "subtitles.closedcaption.scheme", 0, - cc_schemes, + (char **)cc_schemes, _("closed-captioning foreground/background scheme"), _("Choose your favourite rendering of the closed " "captions."), diff --git a/src/libspucmml/xine_cmml_decoder.c b/src/libspucmml/xine_cmml_decoder.c index 1a8f65e14..c3da1b0fd 100644 --- a/src/libspucmml/xine_cmml_decoder.c +++ b/src/libspucmml/xine_cmml_decoder.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -446,7 +446,7 @@ static spu_decoder_t *spucmml_class_open_plugin (spu_decoder_class_t *class_gen, this->spu_decoder.set_button = NULL; this->spu_decoder.dispose = spudec_dispose; - this->class = class_gen; + this->class = class; this->stream = stream; this->event_queue = xine_event_new_queue (this->stream); diff --git a/src/libspudec/xine_spu_decoder.c b/src/libspudec/xine_spu_decoder.c index e63bdf8b9..02bae6ac9 100644 --- a/src/libspudec/xine_spu_decoder.c +++ b/src/libspudec/xine_spu_decoder.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2004 the xine project + * Copyright (C) 2000-2008 the xine project * * Copyright (C) James Courtier-Dutton James@superbug.demon.co.uk - July 2001 * @@ -70,7 +70,6 @@ static const clut_t default_clut[] = { static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { spudec_decoder_t *this = (spudec_decoder_t *) this_gen; const uint8_t stream_id = buf->type & 0x1f ; - spudec_seq_t *cur_seq = &this->spudec_stream_state[stream_id].ra_seq; #ifdef LOG_DEBUG printf("libspudec:got buffer type = %x\n", buf->type); diff --git a/src/libspudvb/xine_spudvb_decoder.c b/src/libspudvb/xine_spudvb_decoder.c index 8a4fe6926..e6e885e1f 100644 --- a/src/libspudvb/xine_spudvb_decoder.c +++ b/src/libspudvb/xine_spudvb_decoder.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004 the xine project + * Copyright (C) 2008 the xine project * * This file is part of xine, a free video player. * @@ -515,7 +515,6 @@ static void process_object_data_segment (dvb_spu_decoder_t * this) dvbsub->i += 2; const uint16_t segment_length = _X_BE_16(&dvbsub->buf[dvbsub->i]); dvbsub->i += 2; - const int j = dvbsub->i + segment_length; const uint16_t object_id = _X_BE_16(&dvbsub->buf[dvbsub->i]); dvbsub->i += 2; @@ -779,7 +778,6 @@ static void spudec_decode_data (spu_decoder_t * this_gen, buf_element_t * buf) this->dvbsub->buf = this->pes_pkt; - int PES_header_data_length = 0; this->dvbsub->i = 0; const uint8_t data_identifier = this->dvbsub->buf[this->dvbsub->i++]; @@ -875,6 +873,7 @@ static void spudec_dispose (spu_decoder_t * this_gen) static spu_decoder_t *dvb_spu_class_open_plugin (spu_decoder_class_t * class_gen, xine_stream_t * stream) { dvb_spu_decoder_t *this = calloc(1, sizeof (dvb_spu_decoder_t)); + dvb_spu_class_t *class = (dvb_spu_class_t *)class_gen; this->spu_decoder.decode_data = spudec_decode_data; this->spu_decoder.reset = spudec_reset; @@ -883,7 +882,7 @@ static spu_decoder_t *dvb_spu_class_open_plugin (spu_decoder_class_t * class_gen this->spu_decoder.get_interact_info = NULL; this->spu_decoder.set_button = NULL; - this->class = class_gen; + this->class = class; this->stream = stream; this->pes_pkt = calloc(65, 1024); diff --git a/src/libw32dll/wine/win32.c b/src/libw32dll/wine/win32.c index 9d99e1a25..d9744ae35 100644 --- a/src/libw32dll/wine/win32.c +++ b/src/libw32dll/wine/win32.c @@ -1430,7 +1430,7 @@ static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c) } static int WINAPI expGetCurrentThreadId() { - dbgprintf("GetCurrentThreadId() => %ld\n", pthread_self()); + dbgprintf("GetCurrentThreadId() => %ld\n", (long int)pthread_self()); return (int)pthread_self(); } static int WINAPI expGetCurrentProcess() @@ -2134,7 +2134,6 @@ static const char* WINAPI expGetCommandLineA() dbgprintf("GetCommandLineA() => \"c:\\aviplay.exe\"\n"); return "c:\\aviplay.exe"; } -static short envs[]={'p', 'a', 't', 'h', ' ', 'c', ':', '\\', 0, 0}; static LPWSTR WINAPI expGetEnvironmentStringsW() { dbgprintf("GetEnvironmentStringsW() => 0\n"); @@ -3998,7 +3997,7 @@ static int XINE_FORMAT_PRINTF(2, 3) expsprintf(char* str, const char* format, .. va_end(args); return r; } -static int XINE_FORMAT_PRINTF(2, 3) expsscanf(const char* str, const char* format, ...) +static int XINE_FORMAT_SCANF(2, 3) expsscanf(const char* str, const char* format, ...) { va_list args; int r; @@ -4162,7 +4161,7 @@ static void* expmemset(void* dest, int c, size_t n) static time_t exptime(time_t* t) { time_t result = time(t); - dbgprintf("time(%p) => %ld\n", t, result); + dbgprintf("time(%p) => %ld\n", t, (long int)result); return result; } diff --git a/src/post/audio/filter.c b/src/post/audio/filter.c index c5602736c..55d75e1e4 100644 --- a/src/post/audio/filter.c +++ b/src/post/audio/filter.c @@ -414,7 +414,7 @@ void bilinear(_ftype_t* a, _ftype_t* b, _ftype_t* k, _ftype_t fs, _ftype_t *coef * * return -1 if fail 0 if success. */ -int szxform(_ftype_t* a, _ftype_t* b, _ftype_t Q, _ftype_t fc, _ftype_t fs, _ftype_t *k, _ftype_t *coef) +int szxform(const _ftype_t* a, const _ftype_t* b, _ftype_t Q, _ftype_t fc, _ftype_t fs, _ftype_t *k, _ftype_t *coef) { _ftype_t at[3]; _ftype_t bt[3]; diff --git a/src/post/audio/filter.h b/src/post/audio/filter.h index 0b0ce1c1b..0e08aa2b9 100644 --- a/src/post/audio/filter.h +++ b/src/post/audio/filter.h @@ -55,7 +55,7 @@ extern int design_pfir(unsigned int n, unsigned int k, _ftype_t* w, _ftype_t** p extern void prewarp(_ftype_t* a, _ftype_t fc, _ftype_t fs); void bilinear(_ftype_t* a, _ftype_t* b, _ftype_t* k, _ftype_t fs, _ftype_t *coef); -extern int szxform(_ftype_t* a, _ftype_t* b, _ftype_t Q, _ftype_t fc, _ftype_t fs, _ftype_t *k, _ftype_t *coef); +extern int szxform(const _ftype_t* a, const _ftype_t* b, _ftype_t Q, _ftype_t fc, _ftype_t fs, _ftype_t *k, _ftype_t *coef); /* Add new data to circular queue designed to be used with a FIR * filter. xq is the circular queue, in pointing at the new sample, xi diff --git a/src/post/audio/volnorm.c b/src/post/audio/volnorm.c index 4fdb7dbfc..792618322 100644 --- a/src/post/audio/volnorm.c +++ b/src/post/audio/volnorm.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2005 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -412,7 +412,6 @@ static post_plugin_t *volnorm_open_plugin(post_class_t *class_gen, int inputs, post_out_t *output; xine_post_in_t *input_api; post_audio_port_t *port; - int i; if (!this || !audio_target || !audio_target[0] ) { free(this); diff --git a/src/post/planar/eq2.c b/src/post/planar/eq2.c index 0ead54f55..a1c208919 100644 --- a/src/post/planar/eq2.c +++ b/src/post/planar/eq2.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. * @@ -432,8 +432,6 @@ static post_plugin_t *eq2_open_plugin(post_class_t *class_gen, int inputs, xine_post_in_t *input_api; post_out_t *output; post_video_port_t *port; - vf_eq2_t *eq2; - int i; if (!this || !video_target || !video_target[0]) { free(this); diff --git a/src/video_out/deinterlace.c b/src/video_out/deinterlace.c index 8ba161ebb..263160808 100644 --- a/src/video_out/deinterlace.c +++ b/src/video_out/deinterlace.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001 the xine project + * Copyright (C) 2001-2008 the xine project * * This file is part of xine, a free video player. * @@ -37,6 +37,18 @@ #include "xineutils.h" +const char *deinterlace_methods[] = { + "none", + "bob", + "weave", + "greedy", + "onefield", + "onefield_xv", + "linearblend", + NULL +}; + + /* DeinterlaceFieldBob algorithm Based on Virtual Dub plugin by Gunnar Thalin diff --git a/src/video_out/deinterlace.h b/src/video_out/deinterlace.h index 2ebbf53d9..d7712f581 100644 --- a/src/video_out/deinterlace.h +++ b/src/video_out/deinterlace.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001 the xine project + * Copyright (C) 2001-2008 the xine project * * This file is part of xine, a free video player. * @@ -41,15 +41,6 @@ void deinterlace_yuv( uint8_t *pdst, uint8_t *psrc[], #define DEINTERLACE_ONEFIELDXV 5 #define DEINTERLACE_LINEARBLEND 6 -static const char *deinterlace_methods[] = { - "none", - "bob", - "weave", - "greedy", - "onefield", - "onefield_xv", - "linearblend", - NULL -}; +extern const char *deinterlace_methods[]; #endif diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 6a11ebc34..b71518958 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -1093,7 +1093,7 @@ static int xv_gui_data_exchange (vo_driver_t *this_gen, return 0; } -static void xv_store_port_attribute(xv_driver_t *this, char *name) { +static void xv_store_port_attribute(xv_driver_t *this, const char *name) { Atom atom; xv_portattribute_t *attr; diff --git a/src/video_out/video_out_xvmc.c b/src/video_out/video_out_xvmc.c index 366a03859..c2560ccc0 100644 --- a/src/video_out/video_out_xvmc.c +++ b/src/video_out/video_out_xvmc.c @@ -699,6 +699,7 @@ static cxid_t *xvmc_set_context (xvmc_driver_t *this, return NULL; } +#if 0 static XvImage *create_ximage (xvmc_driver_t *this, XShmSegmentInfo *shminfo, int width, int height, int format) { unsigned int xvmc_format; @@ -754,6 +755,7 @@ static void dispose_ximage (xvmc_driver_t *this, lprintf ("dispose_ximage\n"); XFree(myimage); } +#endif static void xvmc_update_frame_format (vo_driver_t *this_gen, vo_frame_t *frame_gen, diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index b8d6abf83..b3ac39697 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -159,7 +159,6 @@ static void xxmc_xvmc_dump_subpictures(xxmc_driver_t *this) static void xxmc_xvmc_surface_handler_construct(xxmc_driver_t *this) { - int i; xvmc_surface_handler_t *handler = &this->xvmc_surf_handler; pthread_mutex_init(&handler->mutex,NULL); @@ -1608,8 +1607,8 @@ static void xxmc_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) * other than 100 %, so let's disable deinterlacing at all for this frame */ if (this->deinterlace_enabled && this->bob) { - disable_deinterlace = this->disable_bob_for_progressive_frames && frame->vo_frame.progressive_frame - || this->disable_bob_for_scaled_osd && this->scaled_osd_active + disable_deinterlace = (this->disable_bob_for_progressive_frames && frame->vo_frame.progressive_frame) + || (this->disable_bob_for_scaled_osd && this->scaled_osd_active) || !frame->vo_frame.stream || xine_get_param(frame->vo_frame.stream, XINE_PARAM_FINE_SPEED) != XINE_FINE_SPEED_NORMAL; if (!disable_deinterlace) { @@ -2406,7 +2405,7 @@ static vo_driver_t *open_plugin (video_driver_class_t *class_gen, const void *vi x11_visual_t *visual = (x11_visual_t *) visual_gen; XColor dummy; XvImage *myimage; - unsigned int adaptors, j; + unsigned int adaptors; unsigned int ver,rel,req,ev,err; XShmSegmentInfo myshminfo; XvPortID xv_port; diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index 9a30ea7e8..04fa030bf 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.h @@ -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. * @@ -622,13 +622,13 @@ 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 SUPPORT_ATTRIBUTE_PACKED diff --git a/src/xine-engine/buffer_types.c b/src/xine-engine/buffer_types.c index 8bee0e791..b7571d1d7 100644 --- a/src/xine-engine/buffer_types.c +++ b/src/xine-engine/buffer_types.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2005 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -1200,7 +1200,7 @@ 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; @@ -1234,7 +1234,7 @@ 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; diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index d8f77c464..4f7492c65 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. * @@ -2463,7 +2463,7 @@ void xine_post_dispose(xine_t *xine, xine_post_t *post_gen) { * @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) { +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; diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h index 3819818d5..d7a0e2f1e 100644 --- a/src/xine-utils/attributes.h +++ b/src/xine-utils/attributes.h @@ -1,7 +1,7 @@ /* * attributes.h * Copyright (C) 1999-2000 Aaron Holtzman - * Copyright (C) 2001-2007 xine developers + * Copyright (C) 2001-2008 xine developers * * This file was originally part of mpeg2dec, a free MPEG-2 video stream * decoder. @@ -72,7 +72,7 @@ # define XINE_SENTINEL #endif -#ifdef SUPPORT_ATTRIBUTE_DEPRECATED +#if defined(SUPPORT_ATTRIBUTE_DEPRECATED) && !defined(XINE_COMPILE) # define XINE_DEPRECATED __attribute__((__deprecated__)) #else # define XINE_DEPRECATED @@ -89,8 +89,10 @@ /* Format attributes */ #ifdef SUPPORT_ATTRIBUTE_FORMAT # define XINE_FORMAT_PRINTF(fmt,var) __attribute__((__format__(__printf__, fmt, var))) +# define XINE_FORMAT_SCANF(fmt,var) __attribute__((__format__(__scanf__, fmt, var))) #else # define XINE_FORMAT_PRINTF(fmt,var) +# define XINE_FORMAT_SCANF(fmt,var) #endif #ifdef SUPPORT_ATTRIBUTE_FORMAT_ARG # define XINE_FORMAT_PRINTF_ARG(fmt) __attribute__((__format_arg__(fmt))) diff --git a/src/xine-utils/monitor.c b/src/xine-utils/monitor.c index 301d6c22f..650c10f99 100644 --- a/src/xine-utils/monitor.c +++ b/src/xine-utils/monitor.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2003 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -38,7 +38,6 @@ static long profiler_calls[MAX_ID] ; static const char *profiler_label[MAX_ID] ; void xine_profiler_init () { - int i; memset(profiler_times, 0, sizeof(profiler_times)); memset(profiler_start, 0, sizeof(profiler_start)); memset(profiler_calls, 0, sizeof(profiler_calls)); -- cgit v1.2.3 From d654aee31f58dd481ded257d89d0ee293b68661f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 20 Nov 2008 21:01:27 +0100 Subject: Memory access fixes: - goom initialization - matroska playing recent files with AAC - replace free() by ffmpeg's av_free() in ff decoders --- src/combined/ffmpeg/ff_audio_decoder.c | 4 ++-- src/combined/ffmpeg/ff_video_decoder.c | 6 +++--- src/demuxers/demux_matroska.c | 8 +++++-- src/post/goom/convolve_fx.c | 2 +- src/post/goom/diff_against_release.patch | 37 ++++++++++++++++++++++++++++++++ src/post/goom/goom_core.c | 8 +++---- 6 files changed, 53 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c index c2e3740e3..e0d294113 100644 --- a/src/combined/ffmpeg/ff_audio_decoder.c +++ b/src/combined/ffmpeg/ff_audio_decoder.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2005 the xine project + * Copyright (C) 2001-2008 the xine project * * This file is part of xine, a free video player. * @@ -443,7 +443,7 @@ static void ff_audio_dispose (audio_decoder_t *this_gen) { free(this->context->extradata); if(this->context) - free(this->context); + av_free(this->context); free (this_gen); } diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c index ac101d77e..a04d2feb6 100644 --- a/src/combined/ffmpeg/ff_video_decoder.c +++ b/src/combined/ffmpeg/ff_video_decoder.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2007 the xine project + * Copyright (C) 2001-2008 the xine project * * This file is part of xine, a free video player. * @@ -1530,10 +1530,10 @@ static void ff_dispose (video_decoder_t *this_gen) { free_yuv_planes(&this->yuv); if( this->context ) - free( this->context ); + av_free( this->context ); if( this->av_frame ) - free( this->av_frame ); + av_free( this->av_frame ); if (this->buf) free(this->buf); diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c index e6dd564a6..ec75cb97a 100644 --- a/src/demuxers/demux_matroska.c +++ b/src/demuxers/demux_matroska.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2007 the xine project + * Copyright (C) 2000-2008 the xine project * * This file is part of xine, a free video player. * @@ -676,7 +676,11 @@ static void init_codec_aac(demux_matroska_t *this, matroska_track_t *track) { /* Create a DecoderSpecificInfo for initialising libfaad */ sr_index = aac_get_sr_index(atrack->sampling_freq); - if (!strncmp (&track->codec_id[12], "MAIN", 4)) + /* newer specification with appended CodecPrivate */ + if (strlen(track->codec_id) <= 12) + profile = 3; + /* older specification */ + else if (!strncmp (&track->codec_id[12], "MAIN", 4)) profile = 0; else if (!strncmp (&track->codec_id[12], "LC", 2)) profile = 1; diff --git a/src/post/goom/convolve_fx.c b/src/post/goom/convolve_fx.c index c394f3bf8..ee36dfd0b 100644 --- a/src/post/goom/convolve_fx.c +++ b/src/post/goom/convolve_fx.c @@ -73,7 +73,7 @@ static void set_motif(ConvData *data, Motif motif) static void convolve_init(VisualFX *_this, PluginInfo *info) { ConvData *data; - data = (ConvData*)malloc(sizeof(ConvData)); + data = (ConvData*)calloc(1, sizeof(ConvData)); _this->fx_data = (void*)data; data->light = secure_f_param("Screen Brightness"); diff --git a/src/post/goom/diff_against_release.patch b/src/post/goom/diff_against_release.patch index bde85c285..a5e84b8d1 100644 --- a/src/post/goom/diff_against_release.patch +++ b/src/post/goom/diff_against_release.patch @@ -653,3 +653,40 @@ diff -u -p -r1.2 -r1.3 #endif +diff -r 96c7f8460d61 src/post/goom/convolve_fx.c +--- convolve_fx.c Mon Nov 10 16:33:51 2008 +0100 ++++ convolve_fx.c Sun Nov 16 21:14:29 2008 +0100 +@@ -73,7 +73,7 @@ static void set_motif(ConvData *data, Mo + + static void convolve_init(VisualFX *_this, PluginInfo *info) { + ConvData *data; +- data = (ConvData*)malloc(sizeof(ConvData)); ++ data = (ConvData*)calloc(1, sizeof(ConvData)); + _this->fx_data = (void*)data; + + data->light = secure_f_param("Screen Brightness"); +diff -r 96c7f8460d61 src/post/goom/goom_core.c +--- goom_core.c Mon Nov 10 16:33:51 2008 +0100 ++++ goom_core.c Sun Nov 16 21:14:29 2008 +0100 +@@ -76,6 +76,10 @@ PluginInfo *goom_init (guint32 resx, gui + goomInfo->tentacles_fx = tentacle_fx_create(); + goomInfo->tentacles_fx.init(&goomInfo->tentacles_fx, goomInfo); + ++ goomInfo->screen.width = resx; ++ goomInfo->screen.height = resy; ++ goomInfo->screen.size = resx * resy; ++ + goomInfo->convolve_fx = convolve_create(); + goomInfo->convolve_fx.init(&goomInfo->convolve_fx, goomInfo); + +@@ -83,10 +87,6 @@ PluginInfo *goom_init (guint32 resx, gui + plugin_info_add_visual (goomInfo, 1, &goomInfo->tentacles_fx); + plugin_info_add_visual (goomInfo, 2, &goomInfo->star_fx); + plugin_info_add_visual (goomInfo, 3, &goomInfo->convolve_fx); +- +- goomInfo->screen.width = resx; +- goomInfo->screen.height = resy; +- goomInfo->screen.size = resx * resy; + + init_buffers(goomInfo, goomInfo->screen.size); + goomInfo->gRandom = goom_random_init((uintptr_t)goomInfo->pixel); diff --git a/src/post/goom/goom_core.c b/src/post/goom/goom_core.c index 35fd7fc35..62d9a27b6 100644 --- a/src/post/goom/goom_core.c +++ b/src/post/goom/goom_core.c @@ -76,6 +76,10 @@ PluginInfo *goom_init (guint32 resx, guint32 resy) goomInfo->tentacles_fx = tentacle_fx_create(); goomInfo->tentacles_fx.init(&goomInfo->tentacles_fx, goomInfo); + goomInfo->screen.width = resx; + goomInfo->screen.height = resy; + goomInfo->screen.size = resx * resy; + goomInfo->convolve_fx = convolve_create(); goomInfo->convolve_fx.init(&goomInfo->convolve_fx, goomInfo); @@ -84,10 +88,6 @@ PluginInfo *goom_init (guint32 resx, guint32 resy) plugin_info_add_visual (goomInfo, 2, &goomInfo->star_fx); plugin_info_add_visual (goomInfo, 3, &goomInfo->convolve_fx); - goomInfo->screen.width = resx; - goomInfo->screen.height = resy; - goomInfo->screen.size = resx * resy; - init_buffers(goomInfo, goomInfo->screen.size); goomInfo->gRandom = goom_random_init((uintptr_t)goomInfo->pixel); -- cgit v1.2.3 From 8b028895638903ad165125f43180d137778940bb Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 22 Nov 2008 14:04:03 +0000 Subject: Fix linkage failure caused by the av_free() changes in the ffmpeg decoders. --- src/combined/ffmpeg/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/combined/ffmpeg/Makefile.am b/src/combined/ffmpeg/Makefile.am index 3c78fa9d3..4d7e70423 100644 --- a/src/combined/ffmpeg/Makefile.am +++ b/src/combined/ffmpeg/Makefile.am @@ -4,7 +4,7 @@ DEFAULT_INCLUDES = -I. if HAVE_FFMPEG ff_cppflags = $(FFMPEG_CFLAGS) $(FFMPEG_POSTPROC_CFLAGS) -link_ffmpeg = $(FFMPEG_LIBS) $(FFMPEG_POSTPROC_LIBS) +link_ffmpeg = $(FFMPEG_LIBS) $(FFMPEG_UTIL_LIBS) $(FFMPEG_POSTPROC_LIBS) else ff_cppflags = -I$(top_builddir)/src/libffmpeg -I$(top_srcdir)/src/libffmpeg/libavcodec -I$(top_srcdir)/src/libffmpeg/libavutil link_ffmpeg = \ -- cgit v1.2.3 From 6602e33cf3ffd421d68e17c0259375956ae5ef3c Mon Sep 17 00:00:00 2001 From: Lorenzo Desole Date: Sat, 22 Nov 2008 12:20:00 +0100 Subject: Add position-based seeking independent from seekpoints. When it comes to FLAC audio files, seeking relies on seekpoints which are not always present, and even when they are, sometimes it fails. Also, as far as I can see, xine is unable to play a FLAC stream starting at an arbitrary position. Other players (namely mplayer) do not rely on seekpoints when they handle FLAC files and they don't suffer from these problems. With this patch, time-based seeking doesn't change, while position-based seeking is completely independent from seekpoints. --- src/demuxers/demux_flac.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c index 0cc2fc6b6..c14536040 100644 --- a/src/demuxers/demux_flac.c +++ b/src/demuxers/demux_flac.c @@ -393,12 +393,13 @@ static int demux_flac_seek (demux_plugin_t *this_gen, demux_flac_t *this = (demux_flac_t *) this_gen; int seekpoint_index = 0; int64_t start_pts; + unsigned char buf[4]; start_pos = (off_t) ( (double) start_pos / 65535 * this->data_size ); /* if thread is not running, initialize demuxer */ - if( !playing ) { + if( !playing && !start_pos) { /* send new pts */ _x_demux_control_newpts(this->stream, 0, 0); @@ -406,28 +407,39 @@ static int demux_flac_seek (demux_plugin_t *this_gen, this->status = DEMUX_OK; } else { - if (this->seekpoints == NULL) { + if (this->seekpoints == NULL && !start_pos) { /* cannot seek if there is no seekpoints */ this->status = DEMUX_OK; return this->status; } - /* do a lazy, linear seek based on the assumption that there are not - * that many seek points */ + /* Don't use seekpoints if start_pos != 0. This allows smooth seeking */ if (start_pos) { /* offset-based seek */ - if (start_pos < this->seekpoints[0].offset) - seekpoint_index = 0; - else { - for (seekpoint_index = 0; seekpoint_index < this->seekpoint_count - 1; - seekpoint_index++) { - if (start_pos < this->seekpoints[seekpoint_index + 1].offset) { - break; - } - } + this->status = DEMUX_OK; + start_pos += this->data_start; + this->input->seek(this->input, start_pos, SEEK_SET); + while(1){ /* here we try to find something that resembles a frame header */ + + if (this->input->read(this->input, buf, 2) != 2){ + this->status = DEMUX_FINISHED; /* we sought past the end of stream ? */ + break; + } + + if (buf[0] == 0xff && buf[1] == 0xf8) + break; /* this might be the frame header... or it may be not. We pass it to the decoder + * to decide, but this way we reduce the number of warnings */ + start_pos +=2; } + + _x_demux_flush_engine(this->stream); + this->input->seek(this->input, start_pos, SEEK_SET); + _x_demux_control_newpts(this->stream, 0, BUF_FLAG_SEEK); + return this->status; + } else { - /* time-based seek */ + /* do a lazy, linear seek based on the assumption that there are not + * that many seek points; time-based seek */ start_pts = start_time; start_pts *= 90; if (start_pts < this->seekpoints[0].pts) -- cgit v1.2.3