diff options
67 files changed, 529 insertions, 734 deletions
@@ -24,8 +24,8 @@ config.log config.sub config.status config.status.lineno -config.h -config.h.in +include/configure.h +include/configure.h.in depcomp install-sh libtool diff --git a/.hgsigs b/.hgsigs new file mode 100644 index 000000000..a1901b37f --- /dev/null +++ b/.hgsigs @@ -0,0 +1 @@ +5e6d0656ac4efdc1a89ed0fc32f11050f4a22970 0 iD8DBQBGZ207sBKtjPGfWZ8RAhdEAKCrkwiBT6bTof7ro5QQwewRfF/dMACffsvfK42+ahQrjpSfQxEp6k7RpCI= @@ -60,3 +60,4 @@ fd12068ebd3fab2438f77b06e312c4244e97950a DXR3_095 4a4f4e8bb768b6598c02a59929019866a40b4edc nopadding_no_abi_change 204b8e92463b592e5c220b56f186a6d4d1007cf9 xine-lib-1_1_5-release 7b60f85a95345c41fb074dc5e3f7355d9e72968e xine-lib-1_1_6-release +ab1531337553ad5eac24a69ac665eae33916b423 xine-lib-1_1_7-release @@ -8,7 +8,7 @@ xine-lib (1.1.90) (Unreleased) * Use FFmpeg's own buildsystem, rather than wrapping automake around its sources; this allows to enable/disable FFmpeg features easily, and allow to properly support --disable-ffmpeg-(uncommon|popular)-codecs. - * Update libmpcdec (formerly libmusepack) to version 1.2.5 (newer than the + * Update libmpcdec (formerly libmusepack) to version 1.2.6 (newer than the previous Subversion snapshot) and contestually move it to contrib/libmpcdec to separate from xine's own code. * Save plugins' cache in the defined cache home directory as per XDG Base @@ -28,8 +28,12 @@ xine-lib (1.1.90) (Unreleased) initialisation, even for audio files that nothing have to do with modplug. * Collapse the Ogg demuxer, and the Theora, Vorbis and Speex decoders in the same 'xiph' plugin. + * Remove aRTs output plugin; ALSA's DMix can allow to run both xine and aRTs + at the same time for Linux, and if other operating systems lacks a proper + software mixing facility you can consider alternative daemons. Note: aRTs + will not be present in KDE 4. -xine-lib (1.1.7) (unreleased) +xine-lib (1.1.7) * Support libdca (new name for libdts) by shuffling around the dts.h file. * Add support for MDHD version 1 atom in demux_qt. [bug #1679398] * Handle single-quoted attribute values in XML. @@ -49,6 +53,16 @@ xine-lib (1.1.7) (unreleased) * Use the integer versions of Speex decoding functions, this avoids an iteration over the decoded frames to transform them to integers, and also avoids an improper saturation. + * Prioritize the musepack demuxer over mpgaudio, as sometimes the latter can + misfire and report a good file as unplayable. + * Fix an mmap problem with huge files on 32-bit systems. + * Improved MPEG PES stream handling: specifically, misdetection of data + streams as PES streams. + * Handle unplugged ALSA device (fixes crashes) and if the frontend does not + handle the event continue playback to the none output. + * Disable aRTs output plugin by default, it's deprecated and will be removed + in 1.2 series. + * Fix a colour format conversion crash in the fb video output driver. xine-lib (1.1.6) * Split the DirectFB plugin into X11 and non-X versions. diff --git a/Makefile.am b/Makefile.am index fb5c98316..424bbcbaa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,8 +29,6 @@ EXTRA_DIST = config.rpath autogen.sh \ depcomp \ CREDITS -noinst_HEADERS = config.h - CONFIG_CLEAN_FILES = libtool docs: @@ -84,7 +82,7 @@ install-data-hook: mostlyclean-generic: -rm -f *~ \#* .*~ .\#* - -rm -f $(PACKAGE)_$(VERSION).tar.gz + -rm -f $(PACKAGE)_$(VERSION).tar.gz $(PACKAGE)_$(VERSION).tar.bz2 -rm -f $(distdir).tar.gz $(PACKAGE).tgz package_descriptions -rm -rf $(distdir) @@ -93,7 +91,7 @@ maintainer-clean-generic: -@echo "This command is intended for maintainers to use;" -@echo "it deletes files that may require special tools to rebuild." -rm -f Makefile.in configure acinclude.m4 aclocal.m4 - -rm -f config.h.in stamp-h.in ltconfig ltmain.sh + -rm -f stamp-h.in ltconfig ltmain.sh -rm -f config.guess config.sub install-sh missing mkinstalldirs -rm -f depcomp config.log diff --git a/configure.ac b/configure.ac index c42e75c78..f4863ce40 100644 --- a/configure.ac +++ b/configure.ac @@ -12,7 +12,7 @@ AC_INIT([xine-lib], XINE_VERSION_SPEC, [xine-bugs@lists.sourceforge.net]) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([src/xine-engine/xine.c]) AC_CONFIG_LIBOBJ_DIR([lib]) -AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_HEADERS([include/configure.h]) AM_MAINTAINER_MODE AH_TOP([#ifndef __XINE_LIB_CONFIG_H__ @@ -24,9 +24,6 @@ AH_BOTTOM([#ifdef ASMALIGN_1SLN # define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\n\t" #endif -/* include internal system specific header */ -#include "os_internal.h" - #endif /* __XINE_LIB_CONFIG_H__ */ ]) @@ -74,7 +71,7 @@ AC_SUBST(XINE_LT_REVISION) XINE_LT_AGE=__XINE_LT_AGE AC_SUBST(XINE_LT_AGE) -LIBNAME="libxine${XINE_MAJOR}" +LIBNAME="libxine$(($XINE_LT_CURRENT-$XINE_LT_AGE))" AC_SUBST(LIBNAME) AC_DEFINE_UNQUOTED([XINE_TEXTDOMAIN], "$LIBNAME", [catalog message text domain]) diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 2258d2fd2..a61af87e0 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -70,16 +70,19 @@ configure_options =\ --disable-shared --enable-static --disable-demuxers --disable-muxers --disable-strip \ --enable-gpl --enable-pthreads --disable-ffmpeg --disable-ffserver --disable-ffplay -if DEBUG_BUILD -configure_options += --enable-debug -else +# --enable-debug --disable-opts breaks the build of ffmpeg on x86: +# i386/mpegvideo_mmx_template.c:108: error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’ +# pending a real fix --enable-debug for libxine does not enable debugging options for ffmpeg for now +#if DEBUG_BUILD +#configure_options += --enable-debug +#else configure_options += --disable-debug -endif +#endif if PROFILING_BUILD configure_options += --enable-gprof endif if DISABLE_OPTIMIZATIONS -configure_options += --disable-opts +#configure_options += --disable-opts endif if HAVE_MLIB configure_options += --enable-sunmlib diff --git a/contrib/libfaad/common.h b/contrib/libfaad/common.h index 47832e648..8244a8143 100644 --- a/contrib/libfaad/common.h +++ b/contrib/libfaad/common.h @@ -36,7 +36,7 @@ extern "C" { #define __STRICT_ANSI__ #endif -#include "../config.h" +#include "../include/config.h" #define INLINE __inline #if 0 //defined(_WIN32) && !defined(_WIN32_WCE) diff --git a/contrib/libmpcdec/mpc_decoder.c b/contrib/libmpcdec/mpc_decoder.c index 0617869c8..a7b31c970 100644 --- a/contrib/libmpcdec/mpc_decoder.c +++ b/contrib/libmpcdec/mpc_decoder.c @@ -244,8 +244,8 @@ mpc_decoder_reset_globals(mpc_decoder *d) memset(d->Y_L , 0, sizeof d->Y_L ); memset(d->Y_R , 0, sizeof d->Y_R ); - memset(d->SCF_Index_L , 1, sizeof d->SCF_Index_L ); - memset(d->SCF_Index_R , 1, sizeof d->SCF_Index_R ); + memset(d->SCF_Index_L , 0, sizeof d->SCF_Index_L ); + memset(d->SCF_Index_R , 0, sizeof d->SCF_Index_R ); memset(d->Res_L , 0, sizeof d->Res_L ); memset(d->Res_R , 0, sizeof d->Res_R ); memset(d->SCFI_L , 0, sizeof d->SCFI_L ); @@ -1185,7 +1185,7 @@ mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si) mpc_decoder_seek(d, get_initial_fpos(d)); d->seeking_pwr = 0; - while (d->OverallFrames > (SEEKING_TABLE_SIZE << d->seeking_pwr)) + while( d->OverallFrames > ((mpc_int64_t) SEEKING_TABLE_SIZE << d->seeking_pwr) ) d->seeking_pwr++; d->seeking_table_frames = 0; d->seeking_table[0] = get_initial_fpos(d); diff --git a/debian/control b/debian/control index fc7bf047c..a831ad8c7 100644 --- a/debian/control +++ b/debian/control @@ -22,11 +22,11 @@ Build-Depends: debhelper (>= 5.0.1), binutils (>= 2.12.90.0.9), pkg-config, Build-Conflicts: libdvdnav-dev, libvcdinfo-dev Standards-Version: 3.7.2 -Package: libxine-dev +Package: libxine2-dev Architecture: any Section: libdevel Depends: libxine2 (= ${Source-Version}), libc6-dev, zlib1g-dev | libz-dev, libslang2-dev | slang1-dev, libfreetype6-dev -Conflicts: xine-ui (<< 0.9.10) +Conflicts: xine-ui (<< 0.9.10), libxine-dev Description: the xine video player library, development packages This contains development files (headers, documentation and the like) for the xine library (libxine). @@ -42,10 +42,26 @@ Description: the xine video player library, development packages The xine-ui and gxine packages each provide one for your convenience, so you can just start watching your VCDs ;-) +Package: libxine2-doc +Architecture: all +Section: libdevel +Provides: libxine-doc +Conflicts: libxine1-doc +Replaces: libxine1-doc +Description: the xine video player library, development packages + This contains documentation for the xine library (libxine). + . + Libxine provides the complete infrastructure for a video/media player. It + supports MPEG 1/2 and some AVI and Quicktime videos out of the box, so you + can use it to play DVDs, (S)VCDs and most video files out there. It + supports network streams, subtitles and even MP3 or Ogg files. It's + extensible to your heart's content via plugins for audio and video output, + input media, demuxers (stream types), audio/video and subtitle codecs. + Package: libxine2 Architecture: any Depends: ${shlibs:Depends} -Recommends: ${shlibs:Recommends} +Recommends: ${shlibs:Recommends}, libxine2-doc | libxine-doc Suggests: ${shlibs:Suggests}, libartsc0 Description: the xine video/media player library, binary files This is the xine media player library (libxine). diff --git a/debian/libxine-dev.install b/debian/libxine2-dev.install index 6fadf7dc5..6fadf7dc5 100644 --- a/debian/libxine-dev.install +++ b/debian/libxine2-dev.install diff --git a/debian/libxine2-doc.docs b/debian/libxine2-doc.docs new file mode 100644 index 000000000..3df629bbf --- /dev/null +++ b/debian/libxine2-doc.docs @@ -0,0 +1,8 @@ +debian/tmp/usr/share/doc/libxine2/faq/* +debian/tmp/usr/share/doc/libxine2/README_xxmc.html +debian/tmp/usr/share/doc/libxine2/README +debian/tmp/usr/share/doc/libxine2/faq.* +debian/tmp/usr/share/doc/libxine2/README.syncfb* +debian/tmp/usr/share/doc/libxine2/README.opengl* +debian/tmp/usr/share/doc/libxine2/README.dxr3* +debian/tmp/usr/share/doc/libxine2/README.dvb* diff --git a/debian/libxine2-doc.manpages b/debian/libxine2-doc.manpages new file mode 100644 index 000000000..23e59ea93 --- /dev/null +++ b/debian/libxine2-doc.manpages @@ -0,0 +1 @@ +debian/tmp/usr/share/man/man5/xine.5 diff --git a/debian/libxine2.install b/debian/libxine2.install index 42f7937c2..8c97ee196 100644 --- a/debian/libxine2.install +++ b/debian/libxine2.install @@ -4,8 +4,5 @@ usr/lib/xine/plugins/*/*.so usr/lib/xine/plugins/*/vidix/*.so usr/share/locale usr/share/xine-lib -usr/share/man/man5/xine.5 -usr/share/doc/libxine2/faq/* -usr/share/doc/libxine2/README* usr/share/doc/libxine2/hackersguide/* usr/share/bug/libxine2/presubj diff --git a/debian/rules b/debian/rules index 5082cc75a..c3ae26899 100755 --- a/debian/rules +++ b/debian/rules @@ -103,7 +103,7 @@ clean: -$(MAKE) distclean # remove more cruft leftover by autohell rm -f doc/faq/faq.html doc/faq/faq.txt doc/hackersguide/hackersguide.html m4/caca.m4 - -test -f .noauto || find . -name Makefile.in -print | xargs rm + -test -f .noauto || find . -name Makefile.in -print | xargs -r rm test -f .noauto || rm -rf compile config.guess configure depcomp install-sh ltmain.sh missing aclocal.m4 config.h.in dh_clean diff --git a/include/Makefile.am b/include/Makefile.am index 621bd423c..673f508fa 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -6,6 +6,8 @@ endif include_HEADERS = xine.h +noinst_HEADERS = config.h configure.h + CONFIG_CLEAN_FILES = xine.h $(inttypes_h) mostlyclean-generic: @@ -14,7 +16,7 @@ mostlyclean-generic: maintainer-clean-generic: -@echo "This command is intended for maintainers to use;" -@echo "it deletes files that may require special tools to rebuild." - -rm -f Makefile.in + -rm -f Makefile.in configure.h.in install-data-local: install-includeHEADERS sed -e '/^\/\*_x_/d' xine.h > $(DESTDIR)$(includedir)/xine.h diff --git a/include/config.h b/include/config.h new file mode 100644 index 000000000..3cf680b1c --- /dev/null +++ b/include/config.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2007 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public Licence as published by the Free + * Software Foundation; either version 2 of the Licence, or (at your option) + * any later version. + * + * xine is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public Licence for more + * details. + * + * You should have received a copy of the GNU General Public Licence along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + */ + +#include "configure.h" +#include "os_internal.h" diff --git a/lib/os_internal.h b/lib/os_internal.h index 1e536b9fa..4b00882b7 100644 --- a/lib/os_internal.h +++ b/lib/os_internal.h @@ -81,6 +81,8 @@ #include <inttypes.h> #include <pthread.h> +#include "../src/xine-utils/attributes.h" + #if defined(WIN32) || defined(__CYGWIN__) # define XINE_PATH_SEPARATOR_STRING ";" diff --git a/m4/audio_out.m4 b/m4/audio_out.m4 index cdfe8b65d..4288c32d5 100644 --- a/m4/audio_out.m4 +++ b/m4/audio_out.m4 @@ -7,7 +7,6 @@ AC_DEFUN([XINE_AUDIO_OUT_PLUGINS], [ dnl explicitly requested to do so on other operating systems. dnl Notes: dnl - Alsa is Linux only - dnl - aRts is Linux only dnl - CoreAudio is Mac OS X only dnl - EsounD is reported to be available on most platforms dnl - FusionSound is Linux only, but don't enable it by default @@ -22,7 +21,6 @@ AC_DEFUN([XINE_AUDIO_OUT_PLUGINS], [ default_enable_sunaudio=disable default_with_alsa=without - default_with_arts=without default_with_esound=with default_with_fusionsound=without default_with_jack=without @@ -47,7 +45,6 @@ AC_DEFUN([XINE_AUDIO_OUT_PLUGINS], [ ;; linux*) default_with_alsa=with - default_with_arts=with default_with_jack=with default_with_pulseaudio=with ;; @@ -81,22 +78,6 @@ AC_DEFUN([XINE_AUDIO_OUT_PLUGINS], [ AM_CONDITIONAL([ENABLE_ALSA], [test x"$have_alsa" = x"yes"]) - dnl aRts support - AC_ARG_WITH([arts], - [AS_HELP_STRING([--with-arts], [Build with aRts audio output support])], - [test x"$withval" != x"no" && with_arts="yes"], - [test $default_with_arts = without && with_arts="no"]) - if test x"$with_arts" != x"no"; then - ACX_PACKAGE_CHECK([ARTS], [0.9.5], [artsc-config], [have_arts=yes], [have_arts=no]) - if test x"$with_arts" = x"yes" && test x"$have_arts" != x"yes"; then - AC_MSG_ERROR([aRts support requested, but aRts not found]) - elif test x"$have_arts" = x"yes"; then - AC_DEFINE([HAVE_ARTS], 1, [Define this if you have aRts (libartsc) installed]) - fi - fi - AM_CONDITIONAL([ENABLE_ARTS], [test x"$have_arts" = x"yes"]) - - dnl CoreAudio for Mac OS X AC_ARG_ENABLE([coreaudio], [AS_HELP_STRING([--enable-coreaudio], [Enable support for Mac OS X CoreAudio])], diff --git a/m4/summary.m4 b/m4/summary.m4 index 792c5d319..19c8ff479 100644 --- a/m4/summary.m4 +++ b/m4/summary.m4 @@ -274,7 +274,6 @@ AC_DEFUN([XINE_LIB_SUMMARY], [ dnl Audio plugins echo " * audio driver plugins:" test x"$have_alsa" = x"yes" && echo " - alsa (ALSA - Advanced Linux Sound Architecture)" - test x"$have_arts" = x"yes" && echo " - arts (aRts - KDE soundserver)" test x"$have_coreaudio" = x"yes" && echo " - CoreAudio (Mac OS X audio driver)" test x"$have_directx" = x"yes" && echo " - directx (DirectX audio driver)" test x"$have_esound" = x"yes" && echo " - esd (Enlightened Sound Daemon)" @@ -5139,10 +5139,10 @@ msgstr "" msgid "load_plugins: plugin %s found\n" msgstr "load_plugins: trovato plugin %s\n" -#: src/xine-engine/load_plugins.c:502 -#, fuzzy, c-format +#: src/xine-engine/load_plugins.c:499 +#, c-format msgid "load_plugins: static plugin found\n" -msgstr "load_plugins: trovato plugin statico %s\n" +msgstr "load_plugins: trovato plugin statico\n" #: src/xine-engine/load_plugins.c:509 #, c-format diff --git a/po/libxine1.pot b/po/libxine2.pot index c41c486d3..c41c486d3 100644 --- a/po/libxine1.pot +++ b/po/libxine2.pot diff --git a/src/audio_out/Makefile.am b/src/audio_out/Makefile.am index 8759b123f..cb3eb79d3 100644 --- a/src/audio_out/Makefile.am +++ b/src/audio_out/Makefile.am @@ -32,10 +32,6 @@ endif #irixal_module = xineplug_ao_out_irixal.la #endif -if ENABLE_ARTS -arts_module = xineplug_ao_out_arts.la -endif - if ENABLE_DIRECTX directx_module = xineplug_ao_out_directx.la directx2_module = xineplug_ao_out_directx2.la @@ -63,7 +59,6 @@ xineplug_LTLIBRARIES = \ $(oss_module) \ $(alsa_module) \ $(sun_module) \ - $(arts_module) \ $(esd_module) \ $(directx_module) \ $(coreaudio_module) \ @@ -96,10 +91,6 @@ xineplug_ao_out_sun_la_LIBADD = $(XINE_LIB) #xineplug_ao_out_irixal_la_LIBADD = $(IRIXAL_LIBS) #xineplug_ao_out_irixal_la_CFLAGS = $(AM_CFLAGS) $(IRIXAL_CFLAGS) -xineplug_ao_out_arts_la_SOURCES = audio_arts_out.c -xineplug_ao_out_arts_la_LIBADD = $(ARTS_LIBS) $(XINE_LIB) -xineplug_ao_out_arts_la_CFLAGS = $(AM_CFLAGS) $(ARTS_CFLAGS) - xineplug_ao_out_directx_la_SOURCES = audio_directx_out.c xineplug_ao_out_directx_la_LIBADD = $(DIRECTX_AUDIO_LIBS) $(XINE_LIB) xineplug_ao_out_directx_la_CPPFLAGS = $(AM_CPPFLAGS) $(DIRECTX_CPPFLAGS) diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index 6ad78da2a..ce3e7fb2b 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -752,6 +752,9 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) { if (res < 0) return 0; state = snd_pcm_state(this->audio_fd); + } else if (state == SND_PCM_STATE_DISCONNECTED) { + /* the device is gone. audio_out.c handles it if we return something < 0 */ + return -1; } if (state == SND_PCM_STATE_XRUN) { #ifdef LOG_DEBUG @@ -784,11 +787,11 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) { #endif snd_pcm_status(this->audio_fd, pcm_stat); if ( snd_pcm_status_get_avail(pcm_stat) < number_of_frames) { - wait_result = snd_pcm_wait(this->audio_fd, 1000000); + wait_result = snd_pcm_wait(this->audio_fd, 1000); #ifdef LOG_DEBUG printf("audio_alsa_out:write:loop:wait_result=%d\n",wait_result); #endif - if (wait_result < 0) return 0; + if (wait_result <= 0) return 0; } } if (this->mmap != 0) { @@ -808,7 +811,10 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) { return 0; continue; } - if ( (state != SND_PCM_STATE_PREPARED) && + if (state == SND_PCM_STATE_DISCONNECTED) { + /* the device is gone. audio_out.c handles it if we return something < 0 */ + return -1; + } else if ( (state != SND_PCM_STATE_PREPARED) && (state != SND_PCM_STATE_RUNNING) && (state != SND_PCM_STATE_DRAINING) ) { xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, diff --git a/src/audio_out/audio_arts_out.c b/src/audio_out/audio_arts_out.c deleted file mode 100644 index f38575aff..000000000 --- a/src/audio_out/audio_arts_out.c +++ /dev/null @@ -1,418 +0,0 @@ -/* - * Copyright (C) 2000-2003 the xine project - * - * This file is part of xine, a free video player. - * - * xine is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * xine is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * $Id: audio_arts_out.c,v 1.32 2006/07/16 16:18:09 dsalt Exp $ - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <fcntl.h> -#include <math.h> -#include <unistd.h> -#include <inttypes.h> -#include <artsc.h> - -#include "xine_internal.h" -#include "xineutils.h" -#include "audio_out.h" -#include "bswap.h" - -#define AO_OUT_ARTS_IFACE_VERSION 8 - -#define AUDIO_NUM_FRAGMENTS 15 -#define AUDIO_FRAGMENT_SIZE 8192 - -#define GAP_TOLERANCE AO_MAX_GAP - -typedef struct arts_driver_s { - - ao_driver_t ao_driver; - - xine_t *xine; - - arts_stream_t audio_stream; - int capabilities; - int mode; - - int32_t sample_rate; - uint32_t num_channels; - uint32_t bits_per_sample; - uint32_t bytes_per_frame; - - uint32_t latency; - - struct { - int volume; - int mute; - int vol_scale; - int v_mixer; - } mixer; - -} arts_driver_t; - -typedef struct { - audio_driver_class_t driver_class; - - xine_t *xine; - int inited; -} arts_class_t; - -/* - * Software stereo volume control..... - * Igor Mokrushin <igor@avtomir.ru> - */ -static void ao_arts_volume(void *buffer, int length, int volume) { - int v; - short *data = (short *)buffer; - - while (length--) { - v=(int) ((*(data) * volume) / 100); - *(data)=(v>32767) ? 32767 : ((v<-32768) ? -32768 : v); - *(data)=LE_16(data); - data++; - } -} -/* End volume control */ - -/* - * open the audio device for writing to - */ -static int ao_arts_open(ao_driver_t *this_gen, - uint32_t bits, uint32_t rate, int mode) -{ - arts_driver_t *this = (arts_driver_t *) this_gen; - - xprintf (this->xine, XINE_VERBOSITY_DEBUG, - "audio_arts_out: ao_open bits=%d rate=%d, mode=%d\n", bits, rate, mode); - - if ( (mode & this->capabilities) == 0 ) { - xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_arts_out: unsupported mode %08x\n", mode); - return 0; - } - - if (this->audio_stream) { - - if ( (mode == this->mode) && (rate == this->sample_rate) ) - return this->sample_rate; - - sleep(2); /* arts might segfault if we are still playing */ - arts_close_stream(this->audio_stream); - } - - this->mode = mode; - this->sample_rate = rate; - this->bits_per_sample = bits; - - switch (mode) { - case AO_CAP_MODE_MONO: - this->num_channels = 1; - break; - case AO_CAP_MODE_STEREO: - this->num_channels = 2; - break; - } - - this->bytes_per_frame=(this->bits_per_sample*this->num_channels)/8; - - xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_arts_out: %d channels output\n", this->num_channels); - - this->audio_stream=arts_play_stream(this->sample_rate, bits, this->num_channels, "xine"); - - this->latency = arts_stream_get (this->audio_stream, ARTS_P_TOTAL_LATENCY); - - /* try to keep latency low, if we don't do this we might end - with very high latencies for low quality sound and audio_out will - try to fill gaps every time...(values in ms) */ - if( this->latency > 800 ) - { - this->latency = 800 - arts_stream_get (this->audio_stream, ARTS_P_SERVER_LATENCY); - if( this->latency < 100 ) - this->latency = 100; - arts_stream_set( this->audio_stream, ARTS_P_BUFFER_TIME, this->latency ); - this->latency = arts_stream_get (this->audio_stream, ARTS_P_TOTAL_LATENCY); - } - - xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_arts_out : latency %d ms\n", this->latency); - - return this->sample_rate; -} - - -static int ao_arts_num_channels(ao_driver_t *this_gen) -{ - arts_driver_t *this = (arts_driver_t *) this_gen; - return this->num_channels; -} - -static int ao_arts_bytes_per_frame(ao_driver_t *this_gen) -{ - arts_driver_t *this = (arts_driver_t *) this_gen; - return this->bytes_per_frame; -} - -static int ao_arts_get_gap_tolerance (ao_driver_t *this_gen) -{ - return GAP_TOLERANCE; -} - -static int ao_arts_write(ao_driver_t *this_gen, int16_t *data, - uint32_t num_frames) -{ - arts_driver_t *this = (arts_driver_t *) this_gen; - int size = num_frames * this->bytes_per_frame; - - ao_arts_volume(data, num_frames * this->num_channels, this->mixer.vol_scale ); - arts_write(this->audio_stream, data, size ); - - return 1; -} - - -static int ao_arts_delay (ao_driver_t *this_gen) -{ - arts_driver_t *this = (arts_driver_t *) this_gen; - - /* Just convert latency (ms) to frame units. - please note that there is no function in aRts C API to - get the current buffer utilization. This is, at best, - a very roughly aproximation. - */ - - return this->latency * this->sample_rate / 1000; -} - -static void ao_arts_close(ao_driver_t *this_gen) -{ - arts_driver_t *this = (arts_driver_t *) this_gen; - - if (this->audio_stream) { - sleep(2); /* arts might segfault if we are still playing */ - arts_close_stream(this->audio_stream); - this->audio_stream = NULL; - } -} - -static uint32_t ao_arts_get_capabilities (ao_driver_t *this_gen) { - arts_driver_t *this = (arts_driver_t *) this_gen; - return this->capabilities; -} - -static void ao_arts_exit(ao_driver_t *this_gen) -{ - arts_driver_t *this = (arts_driver_t *) this_gen; - - ao_arts_close(this_gen); - /* FIXME: arts_free() freezes on BSD, so don't use it there */ -#if !defined(__OpenBSD__) && !defined (__FreeBSD__) && !defined(__NetBSD__) - arts_free(); -#endif - - free (this); -} - -static int ao_arts_get_property (ao_driver_t *this_gen, int property) { - - arts_driver_t *this = (arts_driver_t *) this_gen; - - switch(property) { - case AO_PROP_PCM_VOL: - case AO_PROP_MIXER_VOL: - if(!this->mixer.mute) - this->mixer.volume = this->mixer.vol_scale; - return this->mixer.volume; - break; - case AO_PROP_MUTE_VOL: - return this->mixer.mute; - break; - } - return 0; -} - -static int ao_arts_set_property (ao_driver_t *this_gen, int property, int value) { - - arts_driver_t *this = (arts_driver_t *) this_gen; - int mute = (value) ? 1 : 0; - - switch(property) { - case AO_PROP_PCM_VOL: - case AO_PROP_MIXER_VOL: - if(!this->mixer.mute) - this->mixer.volume = value; - this->mixer.vol_scale = this->mixer.volume; - return this->mixer.volume; - break; - case AO_PROP_MUTE_VOL: - if(mute) { - this->mixer.v_mixer = this->mixer.volume; - this->mixer.volume = 0; - this->mixer.vol_scale = this->mixer.volume; - } else { - this->mixer.volume = this->mixer.v_mixer; - this->mixer.vol_scale = this->mixer.volume; - } - this->mixer.mute = mute; - return value; - break; - } - - return ~value; -} - -static int ao_arts_ctrl(ao_driver_t *this_gen, int cmd, ...) { - /*arts_driver_t *this = (arts_driver_t *) this_gen;*/ - - switch (cmd) { - - case AO_CTRL_PLAY_PAUSE: - break; - - case AO_CTRL_PLAY_RESUME: - break; - - case AO_CTRL_FLUSH_BUFFERS: - break; - } - - return 0; -} - -static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *data) { - arts_class_t *class = (arts_class_t *) class_gen; - arts_driver_t *this; - int rc; - - lprintf ("audio_arts_out: open_plugin called\n"); - - this = (arts_driver_t *) xine_xmalloc (sizeof (arts_driver_t)); - if (!this) - return NULL; - - this->xine = class->xine; - - if (class->inited == 0) { - rc = arts_init(); - class->inited++; - } else { - xprintf (this->xine, XINE_VERBOSITY_LOG, "audio_arts_out: not trying to initialise a second time\n"); - free(this); - return NULL; - } - - if (rc < 0) { - xprintf (this->xine, XINE_VERBOSITY_DEBUG,"audio_arts_out: arts_init failed: %s\n", arts_error_text(rc)); - free(this); - return NULL; - } - - /* - * set volume control - */ - this->mixer.mute = 0; - this->mixer.vol_scale = 60; - this->mixer.v_mixer = 0; - /* - * set capabilities - */ - this->capabilities = 0; - xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_arts_out : supported modes are "); - this->capabilities |= AO_CAP_MODE_MONO | AO_CAP_MIXER_VOL | AO_CAP_PCM_VOL | AO_CAP_MUTE_VOL; - xprintf (this->xine, XINE_VERBOSITY_DEBUG, "mono "); - this->capabilities |= AO_CAP_MODE_STEREO | AO_CAP_MIXER_VOL | AO_CAP_PCM_VOL | AO_CAP_MUTE_VOL; - xprintf (this->xine, XINE_VERBOSITY_DEBUG, "stereo "); - - this->sample_rate = 0; - this->audio_stream = NULL; - - this->ao_driver.get_capabilities = ao_arts_get_capabilities; - this->ao_driver.get_property = ao_arts_get_property; - this->ao_driver.set_property = ao_arts_set_property; - this->ao_driver.open = ao_arts_open; - this->ao_driver.num_channels = ao_arts_num_channels; - this->ao_driver.bytes_per_frame = ao_arts_bytes_per_frame; - this->ao_driver.delay = ao_arts_delay; - this->ao_driver.write = ao_arts_write; - this->ao_driver.close = ao_arts_close; - this->ao_driver.exit = ao_arts_exit; - this->ao_driver.get_gap_tolerance = ao_arts_get_gap_tolerance; - this->ao_driver.control = ao_arts_ctrl; - - return &this->ao_driver; -} - -/* - * class functions - */ - -static char* get_identifier (audio_driver_class_t *this_gen) { - return "arts"; -} - -static char* get_description (audio_driver_class_t *this_gen) { - return _("xine audio output plugin using kde artsd"); -} - -static void dispose_class (audio_driver_class_t *this_gen) { - - arts_class_t *this = (arts_class_t *) this_gen; - - free (this); -} - -static void *init_class (xine_t *xine, void *data) { - - arts_class_t *this; - - lprintf ("audio_arts_out: init class\n"); - - this = (arts_class_t *) xine_xmalloc (sizeof (arts_class_t)); - if (!this) - return NULL; - - this->inited = 0; - - this->driver_class.open_plugin = open_plugin; - this->driver_class.get_identifier = get_identifier; - this->driver_class.get_description = get_description; - this->driver_class.dispose = dispose_class; - - this->xine = xine; - - return this; -} - -static ao_info_t ao_info_arts = { - 5 -}; - -/* - * exported plugin catalog entry - */ - -const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ - { PLUGIN_AUDIO_OUT, AO_OUT_ARTS_IFACE_VERSION, "arts", XINE_VERSION_CODE, &ao_info_arts, init_class }, - { PLUGIN_NONE, 0, "", 0, NULL, NULL } -}; - diff --git a/src/audio_out/audio_pulse_out.c b/src/audio_out/audio_pulse_out.c index 9e6089730..cd80318b6 100644 --- a/src/audio_out/audio_pulse_out.c +++ b/src/audio_out/audio_pulse_out.c @@ -626,12 +626,6 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da this->pa_class = class; return &this->ao_driver; - - fail: - pthread_mutex_unlock(&this->pa_class->pa_mutex); - free(this); - xprintf (class->xine, XINE_VERBOSITY_DEBUG, "audio_pulse_out: open_plugin failed.\n"); - return NULL; } /* diff --git a/src/audio_out/audio_sun_out.c b/src/audio_out/audio_sun_out.c index 5923eb658..ca91a8fe6 100644 --- a/src/audio_out/audio_sun_out.c +++ b/src/audio_out/audio_sun_out.c @@ -248,13 +248,11 @@ static int realtime_samplecounter_available(xine_t *xine, char *dev) error: if (silence != NULL) free(silence); if (fd >= 0) { -#ifdef __svr4__ /* * remove the 0 bytes from the above measurement from the * audio driver's STREAMS queue */ ioctl(fd, I_FLUSH, FLUSHW); -#endif close(fd); } @@ -334,7 +332,7 @@ find_close_samplerate_match(int dev, int sample_rate) #else int i, err; - int audiocs_rates[] = { + static const int audiocs_rates[] = { 5510, 6620, 8000, 9600, 11025, 16000, 18900, 22050, 27420, 32000, 33075, 37800, 44100, 48000, 0 }; diff --git a/src/combined/Makefile.am b/src/combined/Makefile.am index c1e590fd7..47a42039f 100644 --- a/src/combined/Makefile.am +++ b/src/combined/Makefile.am @@ -28,7 +28,7 @@ xineplug_flac_la_SOURCES = flac_demuxer.c flac_decoder.c xineplug_flac_la_LIBADD = $(XINE_LIB) $(LIBFLAC_LIBS) xineplug_flac_la_CFLAGS = $(AM_CFLAGS) $(LIBFLAC_CFLAGS) -xineplug_nsf_la_SOURCES = nsf_decoder.c nsf_demuxer.c nsf_combined.c +xineplug_nsf_la_SOURCES = nsf_decoder.c nsf_demuxer.c nsf_combined.c nsf_combined.h xineplug_nsf_la_LIBADD = $(XINE_LIB) $(top_builddir)/contrib/nosefart/libnosefart.la -lm xineplug_nsf_la_CFLAGS = $(AM_CFLAGS) -fno-strict-aliasing xineplug_nsf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNSF_PLAYER -I$(top_srcdir)/contrib/nosefart -I$(top_srcdir)/src/demuxers diff --git a/src/combined/nsf_combined.c b/src/combined/nsf_combined.c index 855b8d2a5..474064213 100644 --- a/src/combined/nsf_combined.c +++ b/src/combined/nsf_combined.c @@ -21,9 +21,7 @@ */ #include "xine_internal.h" - -void *decoder_nsf_init_plugin (xine_t *xine, void *data); -void *demux_nsf_init_plugin (xine_t *xine, void *data); +#include "nsf_combined.h" static const demuxer_info_t demux_info_nsf = { 10 /* priority */ diff --git a/src/combined/nsf_combined.h b/src/combined/nsf_combined.h new file mode 100644 index 000000000..36a0abe71 --- /dev/null +++ b/src/combined/nsf_combined.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +void *decoder_nsf_init_plugin (xine_t *xine, void *data); +void *demux_nsf_init_plugin (xine_t *xine, void *data); diff --git a/src/combined/nsf_decoder.c b/src/combined/nsf_decoder.c index e8b5dd96a..01884f267 100644 --- a/src/combined/nsf_decoder.c +++ b/src/combined/nsf_decoder.c @@ -39,6 +39,8 @@ #include "types.h" #include "nsf.h" +#include "nsf_combined.h" + typedef struct { audio_decoder_class_t decoder_class; } nsf_class_t; diff --git a/src/combined/nsf_demuxer.c b/src/combined/nsf_demuxer.c index b598b9e1c..3ebacc217 100644 --- a/src/combined/nsf_demuxer.c +++ b/src/combined/nsf_demuxer.c @@ -54,6 +54,8 @@ #include "demux.h" #include "bswap.h" +#include "nsf_combined.h" + #define NSF_HEADER_SIZE 0x80 #define NSF_SAMPLERATE 44100 #define NSF_BITS 8 diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c index 1b82a288d..bfacd1410 100644 --- a/src/demuxers/demux_qt.c +++ b/src/demuxers/demux_qt.c @@ -110,6 +110,8 @@ typedef unsigned int qt_atom; #define UDTA_ATOM QT_ATOM('u', 'd', 't', 'a') #define META_ATOM QT_ATOM('m', 'e', 't', 'a') +#define HDLR_ATOM QT_ATOM('h', 'd', 'l', 'r') +#define ILST_ATOM QT_ATOM('i', 'l', 's', 't') #define NAM_ATOM QT_ATOM(0xA9, 'n', 'a', 'm') #define CPY_ATOM QT_ATOM(0xA9, 'c', 'p', 'y') #define DES_ATOM QT_ATOM(0xA9, 'd', 'e', 's') @@ -406,6 +408,10 @@ typedef struct { * demuxer is sending off to the audio decoder */ #define DEBUG_AUDIO_DEMUX 0 +/* define DEBUG_META_LOAD as 1 to see details about the metadata chunks the + * demuxer is reading from the file */ +#define DEBUG_META_LOAD 0 + /* Define DEBUG_DUMP_MOOV as 1 to dump the raw moov atom to disk. This is * particularly useful in debugging a file with a compressed moov (cmov) * atom. The atom will be dumped to the filename specified as @@ -443,6 +449,12 @@ static inline void XINE_FORMAT_PRINTF(1, 2) debug_video_demux(const char *format static inline void XINE_FORMAT_PRINTF(1, 2) debug_audio_demux(const char *format, ...) {} #endif +#if DEBUG_META_LOAD +#define debug_meta_load printf +#else +static inline void XINE_FORMAT_PRINTF(1, 2) debug_meta_load(const char *format, ...) {} +#endif + static inline void dump_moov_atom(unsigned char *moov_atom, int moov_atom_size) { #if DEBUG_DUMP_MOOV @@ -727,52 +739,114 @@ static int is_qt_file(input_plugin_t *qt_file) { } } +static char *parse_data_atom(unsigned char *data_atom) { + const uint32_t data_atom_size = BE_32(&data_atom[0]); + + static const int data_atom_max_version = 0; + const int data_atom_version = data_atom[8]; + + const size_t alloc_size = data_atom_size - 8 + 1; + char *alloc_str = NULL; + + if ( data_atom_version > data_atom_max_version ) { + debug_meta_load("demux_qt: version %d for data atom is higher than the highest supported version (%d)\n", + data_atom_version, data_atom_max_version); + return NULL; + } + + alloc_str = xine_xmalloc(alloc_size); + xine_fast_memcpy(alloc_str, &data_atom[16], alloc_size-1); + alloc_str[alloc_size-1] = '\0'; + + debug_meta_load("demux_qt: got a string of size %zd (%s)\n", alloc_size, alloc_str); + + return alloc_str; +} + /* parse out a meta data atom */ static void parse_meta_atom(qt_info *info, unsigned char *meta_atom) { - int i; - unsigned int meta_atom_size = BE_32(&meta_atom[0]); - qt_atom current_atom; - int string_size; - - for (i = 0; i < meta_atom_size - 4; i++) { - current_atom = BE_32(&meta_atom[i]); - - if (current_atom == ART_ATOM) { - string_size = BE_32(&meta_atom[i + 4]) - 16 + 1; - info->artist = xine_xmalloc(string_size); - strncpy(info->artist, &meta_atom[i + 20], string_size - 1); - info->artist[string_size - 1] = 0; - } else if (current_atom == NAM_ATOM) { - string_size = BE_32(&meta_atom[i + 4]) - 16 + 1; - info->name = xine_xmalloc(string_size); - strncpy(info->name, &meta_atom[i + 20], string_size - 1); - info->name[string_size - 1] = 0; - } else if (current_atom == ALB_ATOM) { - string_size = BE_32(&meta_atom[i + 4]) - 16 + 1; - info->album = xine_xmalloc(string_size); - strncpy(info->album, &meta_atom[i + 20], string_size - 1); - info->album[string_size - 1] = 0; - } else if (current_atom == GEN_ATOM) { - string_size = BE_32(&meta_atom[i + 4]) - 16 + 1; - info->genre = xine_xmalloc(string_size); - strncpy(info->genre, &meta_atom[i + 20], string_size - 1); - info->genre[string_size - 1] = 0; - } else if (current_atom == TOO_ATOM) { - string_size = BE_32(&meta_atom[i + 4]) - 16 + 1; - info->comment = xine_xmalloc(string_size); - strncpy(info->comment, &meta_atom[i + 20], string_size - 1); - info->comment[string_size - 1] = 0; - } else if (current_atom == WRT_ATOM) { - string_size = BE_32(&meta_atom[i + 4]) - 16 + 1; - info->composer = xine_xmalloc(string_size); - strncpy(info->composer, &meta_atom[i + 20], string_size - 1); - info->composer[string_size - 1] = 0; - } else if (current_atom == DAY_ATOM) { - string_size = BE_32(&meta_atom[i + 4]) - 16 + 1; - info->year = xine_xmalloc(string_size); - strncpy(info->year, &meta_atom[i + 20], string_size - 1); - info->year[string_size - 1] = 0; + static const uint32_t meta_atom_preamble_size = 12; + + const uint32_t meta_atom_size = BE_32(&meta_atom[0]); + + static const int meta_atom_max_version = 0; + const int meta_atom_version = meta_atom[8]; + /* const uint32_t flags = BE_24(&meta_atom[9]); */ + + uint32_t i = meta_atom_preamble_size; + + if ( meta_atom_version > meta_atom_max_version ) { + debug_meta_load("demux_qt: version %d for meta atom is higher than the highest supported version (%d)\n", + meta_atom_version, meta_atom_max_version); + return; + } + + while ( i < meta_atom_size ) { + const uint8_t *const current_atom = &meta_atom[i]; + const qt_atom current_atom_code = BE_32(¤t_atom[4]); + const uint32_t current_atom_size = BE_32(¤t_atom[0]); + uint32_t handler_type = 0; + + switch (current_atom_code) { + case HDLR_ATOM: { + static const int hdlr_atom_max_version = 0; + const int hdlr_atom_version = current_atom[8]; + + /* const uint32_t hdlr_atom_flags = BE_24(¤t_atom[9]); */ + + if ( hdlr_atom_version > hdlr_atom_max_version ) { + debug_meta_load("demux_qt: version %d for hdlr atom is higher than the highest supported version (%d)\n", + hdlr_atom_version, hdlr_atom_max_version); + return; + } + + handler_type = BE_32(¤t_atom[12]); + } + break; + + case ILST_ATOM: { + uint32_t j = i + 8; + while ( j < current_atom_size ) { + const uint8_t *const sub_atom = &meta_atom[j]; + const qt_atom sub_atom_code = BE_32(&sub_atom[4]); + const uint32_t sub_atom_size = BE_32(&sub_atom[0]); + + switch(sub_atom_code) { + case ART_ATOM: + info->artist = parse_data_atom(&sub_atom[8]); + break; + case NAM_ATOM: + info->name = parse_data_atom(&sub_atom[8]); + break; + case ALB_ATOM: + info->album = parse_data_atom(&sub_atom[8]); + break; + case GEN_ATOM: + info->genre = parse_data_atom(&sub_atom[8]); + break; + case CMT_ATOM: + info->comment = parse_data_atom(&sub_atom[8]); + break; + case WRT_ATOM: + info->composer = parse_data_atom(&sub_atom[8]); + break; + case DAY_ATOM: + info->year = parse_data_atom(&sub_atom[8]); + break; + default: + debug_meta_load("unknown atom %08x in ilst\n", sub_atom_code); + } + + j += sub_atom_size; + } + } + break; + + default: + debug_meta_load("unknown atom %08x in meta\n", current_atom_code); } + + i += current_atom_size; } } @@ -814,25 +888,11 @@ static qt_error parse_trak_atom (qt_trak *trak, unsigned char *trak_atom) { int i, j, k; - unsigned int trak_atom_size = BE_32(&trak_atom[0]); - qt_atom current_atom; - unsigned int current_atom_size; + const unsigned int trak_atom_size = BE_32(&trak_atom[0]); unsigned int atom_pos; unsigned int properties_offset; - unsigned int current_stsd_atom_size; qt_error last_error = QT_OK; - /* for palette traversal */ - int color_depth; - int color_flag; - int color_start; - int color_count; - int color_end; - int color_index; - int color_dec; - int color_greyscale; - const unsigned char *color_table; - /* initialize trak structure */ trak->edit_list_count = 0; trak->edit_list_table = NULL; @@ -863,12 +923,13 @@ static qt_error parse_trak_atom (qt_trak *trak, /* search for media type atoms */ for (i = ATOM_PREAMBLE_SIZE; i < trak_atom_size - 4; i++) { - current_atom = BE_32(&trak_atom[i]); + const qt_atom current_atom = BE_32(&trak_atom[i]); - if (current_atom == VMHD_ATOM) { + switch (current_atom) { + case VMHD_ATOM: trak->type = MEDIA_VIDEO; break; - } else if (current_atom == SMHD_ATOM) { + case SMHD_ATOM: trak->type = MEDIA_AUDIO; break; } @@ -880,13 +941,15 @@ static qt_error parse_trak_atom (qt_trak *trak, /* search for the useful atoms */ for (i = ATOM_PREAMBLE_SIZE; i < trak_atom_size - 4; i++) { - current_atom_size = BE_32(&trak_atom[i - 4]); - current_atom = BE_32(&trak_atom[i]); + const current_atom_size = BE_32(&trak_atom[i - 4]); + const current_atom = BE_32(&trak_atom[i]); - if (current_atom == TKHD_ATOM) { + switch(current_atom) { + case TKHD_ATOM: trak->flags = BE_16(&trak_atom[i + 6]); - } else if (current_atom == ELST_ATOM) { + break; + case ELST_ATOM: /* there should only be one edit list table */ if (trak->edit_list_table) { last_error = QT_HEADER_TROUBLE; @@ -916,17 +979,19 @@ static qt_error parse_trak_atom (qt_trak *trak, trak->edit_list_table[j].track_duration, trak->edit_list_table[j].media_time); } + break; - } else if (current_atom == MDHD_ATOM) { - int version; + case MDHD_ATOM: debug_atom_load ("demux_qt: mdhd atom\n"); - - version = trak_atom[i+4]; - if ( version > 1 ) continue; /* unsupported, undocumented */ + { + const int version = trak_atom[i+4]; + if ( version > 1 ) continue; /* unsupported, undocumented */ - trak->timescale = BE_32(&trak_atom[i + (version == 0 ? 0x10 : 0x18) ]); - } else if (current_atom == STSD_ATOM) { + trak->timescale = BE_32(&trak_atom[i + (version == 0 ? 0x10 : 0x18) ]); + } + break; + case STSD_ATOM: debug_atom_load ("demux_qt: stsd atom\n"); #if DEBUG_ATOM_LOAD xine_hexdump (&trak_atom[i], current_atom_size); @@ -944,7 +1009,18 @@ static qt_error parse_trak_atom (qt_trak *trak, properties_offset = 0x0C; for (k = 0; k < trak->stsd_atoms_count; k++) { - current_stsd_atom_size = BE_32(&trak_atom[atom_pos - 4]); + const uint32_t current_stsd_atom_size = BE_32(&trak_atom[atom_pos - 4]); + + /* for palette traversal */ + int color_depth; + int color_flag; + int color_start; + int color_count; + int color_end; + int color_index; + int color_dec; + int color_greyscale; + const unsigned char *color_table; if (trak->type == MEDIA_VIDEO) { @@ -1225,7 +1301,7 @@ static qt_error parse_trak_atom (qt_trak *trak, (BE_32(&trak_atom[atom_pos + 0x34]) == WAVE_ATOM) && (BE_32(&trak_atom[atom_pos + 0x3C]) == FRMA_ATOM) && (ME_32(&trak_atom[atom_pos + 0x48]) == trak->stsd_atoms[k].audio.codec_fourcc)) { - int wave_size = BE_32(&trak_atom[atom_pos + 0x44]) - 8; + const int wave_size = BE_32(&trak_atom[atom_pos + 0x44]) - 8; if ((wave_size >= sizeof(xine_waveformatex)) && (current_atom_size >= (0x4C + wave_size))) { @@ -1275,15 +1351,15 @@ static qt_error parse_trak_atom (qt_trak *trak, atom_pos += current_stsd_atom_size; properties_offset += current_stsd_atom_size; } - - } else if (current_atom == ESDS_ATOM) { - - uint32_t len; + break; + + case ESDS_ATOM: debug_atom_load(" qt/mpeg-4 esds atom\n"); if ((trak->type == MEDIA_VIDEO) || (trak->type == MEDIA_AUDIO)) { + uint32_t len; j = i + 8; if( trak_atom[j++] == 0x03 ) { @@ -1306,17 +1382,17 @@ static qt_error parse_trak_atom (qt_trak *trak, } } } + break; - } else if (current_atom == AVCC_ATOM) { - + case AVCC_ATOM: debug_atom_load(" avcC atom\n"); trak->decoder_config_len = current_atom_size - 8; trak->decoder_config = realloc(trak->decoder_config, trak->decoder_config_len); memcpy(trak->decoder_config, &trak_atom[i + 4], trak->decoder_config_len); + break; - } else if (current_atom == STSZ_ATOM) { - + case STSZ_ATOM: /* there should only be one of these atoms */ if (trak->sample_size_table) { last_error = QT_HEADER_TROUBLE; @@ -1348,9 +1424,9 @@ static qt_error parse_trak_atom (qt_trak *trak, /* set the pointer to non-NULL to indicate that the atom type has * already been seen for this trak atom */ trak->sample_size_table = (void *)-1; + break; - } else if (current_atom == STSS_ATOM) { - + case STSS_ATOM: /* there should only be one of these atoms */ if (trak->sync_sample_table) { last_error = QT_HEADER_TROUBLE; @@ -1377,9 +1453,9 @@ static qt_error parse_trak_atom (qt_trak *trak, j, trak->sync_sample_table[j], trak->sync_sample_table[j] - 1); } + break; - } else if (current_atom == STCO_ATOM) { - + case STCO_ATOM: /* there should only be one of either stco or co64 */ if (trak->chunk_offset_table) { last_error = QT_HEADER_TROUBLE; @@ -1405,9 +1481,9 @@ static qt_error parse_trak_atom (qt_trak *trak, debug_atom_load(" chunk %d @ 0x%"PRIX64"\n", j, trak->chunk_offset_table[j]); } + break; - } else if (current_atom == CO64_ATOM) { - + case CO64_ATOM: /* there should only be one of either stco or co64 */ if (trak->chunk_offset_table) { last_error = QT_HEADER_TROUBLE; @@ -1436,9 +1512,9 @@ static qt_error parse_trak_atom (qt_trak *trak, debug_atom_load(" chunk %d @ 0x%"PRIX64"\n", j, trak->chunk_offset_table[j]); } + break; - } else if (current_atom == STSC_ATOM) { - + case STSC_ATOM: /* there should only be one of these atoms */ if (trak->sample_to_chunk_table) { last_error = QT_HEADER_TROUBLE; @@ -1471,9 +1547,9 @@ static qt_error parse_trak_atom (qt_trak *trak, trak->sample_to_chunk_table[j].first_chunk - 1, trak->sample_to_chunk_table[j].media_id); } + break; - } else if (current_atom == STTS_ATOM) { - + case STTS_ATOM: /* there should only be one of these atoms */ if (trak->time_to_sample_table) { last_error = QT_HEADER_TROUBLE; @@ -1533,9 +1609,7 @@ static qt_error parse_reference_atom (reference_t *ref, char *base_mrl) { int i, j; - unsigned int ref_atom_size = BE_32(&ref_atom[0]); - qt_atom current_atom; - unsigned int current_atom_size; + const unsigned int ref_atom_size = BE_32(&ref_atom[0]); /* initialize reference atom */ ref->url = NULL; @@ -1544,11 +1618,11 @@ static qt_error parse_reference_atom (reference_t *ref, /* traverse through the atom looking for the key atoms */ for (i = ATOM_PREAMBLE_SIZE; i < ref_atom_size - 4; i++) { + const uint32_t current_atom_size = BE_32(&ref_atom[i - 4]); + const qt_atom current_atom = BE_32(&ref_atom[i]); - current_atom_size = BE_32(&ref_atom[i - 4]); - current_atom = BE_32(&ref_atom[i]); - - if (current_atom == RDRF_ATOM) { + switch (current_atom) { + case RDRF_ATOM: /* if the URL starts with "http://", copy it */ if (strncmp(&ref_atom[i + 16], "http://", 7) == 0 @@ -1577,17 +1651,17 @@ static qt_error parse_reference_atom (reference_t *ref, } debug_atom_load(" qt rdrf URL reference:\n %s\n", ref->url); + break; - } else if (current_atom == RMDR_ATOM) { - + case RMDR_ATOM: /* load the data rate */ ref->data_rate = BE_32(&ref_atom[i + 8]); ref->data_rate *= 10; debug_atom_load(" qt rmdr data rate = %"PRId64"\n", ref->data_rate); + break; - } else if (current_atom == RMVC_ATOM) { - + case RMVC_ATOM: debug_atom_load(" qt rmvc atom\n"); /* search the rmvc atom for 'qtim'; 2 bytes will follow the qtim @@ -1915,7 +1989,6 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom, int64_t bandwidth) { int i, j; unsigned int moov_atom_size = BE_32(&moov_atom[0]); - qt_atom current_atom; int string_size, error; unsigned int max_video_frames = 0; unsigned int max_audio_frames = 0; @@ -1930,15 +2003,17 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom, /* prowl through the moov atom looking for very specific targets */ for (i = ATOM_PREAMBLE_SIZE + 4; i < moov_atom_size - 4; i += BE_32(&moov_atom[i - 4])) { - current_atom = BE_32(&moov_atom[i]); + const qt_atom current_atom = BE_32(&moov_atom[i]); - if (current_atom == MVHD_ATOM) { + switch (current_atom) { + case MVHD_ATOM: parse_mvhd_atom(info, &moov_atom[i - 4]); if (info->last_error != QT_OK) return; - } else if (current_atom == TRAK_ATOM) { + break; + case TRAK_ATOM: /* create a new trak structure */ info->trak_count++; info->traks = (qt_trak *)realloc(info->traks, @@ -1950,44 +2025,50 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom, info->trak_count--; return; } + break; + + case UDTA_ATOM: + parse_meta_atom(info, &moov_atom[i + 4]); + if (info->last_error != QT_OK) + return; + break; - } else if (current_atom == META_ATOM) { - + case META_ATOM: parse_meta_atom(info, &moov_atom[i - 4]); if (info->last_error != QT_OK) return; + break; - } else if (current_atom == NAM_ATOM) { - + case NAM_ATOM: string_size = BE_16(&moov_atom[i + 4]) + 1; info->name = realloc (info->name, string_size); strncpy(info->name, &moov_atom[i + 8], string_size - 1); info->name[string_size - 1] = 0; + break; - } else if (current_atom == CPY_ATOM) { - + case CPY_ATOM: string_size = BE_16(&moov_atom[i + 4]) + 1; info->copyright = realloc (info->copyright, string_size); strncpy(info->copyright, &moov_atom[i + 8], string_size - 1); info->copyright[string_size - 1] = 0; + break; - } else if (current_atom == DES_ATOM) { - + case DES_ATOM: string_size = BE_16(&moov_atom[i + 4]) + 1; info->description = realloc (info->description, string_size); strncpy(info->description, &moov_atom[i + 8], string_size - 1); info->description[string_size - 1] = 0; + break; - } else if (current_atom == CMT_ATOM) { - + case CMT_ATOM: string_size = BE_16(&moov_atom[i + 4]) + 1; info->comment = realloc (info->comment, string_size); strncpy(info->comment, &moov_atom[i + 8], string_size - 1); info->comment[string_size - 1] = 0; + break; - } else if (current_atom == RMDA_ATOM || - current_atom == RMRA_ATOM) { - + case RMDA_ATOM: + case RMRA_ATOM: /* create a new reference structure */ info->reference_count++; info->references = (reference_t *)realloc(info->references, @@ -1995,8 +2076,9 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom, parse_reference_atom(&info->references[info->reference_count - 1], &moov_atom[i - 4], info->base_mrl); + break; - } else { + default: debug_atom_load(" qt: unknown atom into the moov atom (0x%08X)\n", current_atom); } } diff --git a/src/demuxers/demux_realaudio.c b/src/demuxers/demux_realaudio.c index bf8de0dad..0f8528a22 100644 --- a/src/demuxers/demux_realaudio.c +++ b/src/demuxers/demux_realaudio.c @@ -313,8 +313,6 @@ static int demux_ra_get_status (demux_plugin_t *this_gen) { /* return the approximate length in miliseconds */ static int demux_ra_get_stream_length (demux_plugin_t *this_gen) { - demux_ra_t *this = (demux_ra_t *) this_gen; - return 0; } diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index b40c7d49f..2b3f77d11 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -180,6 +180,8 @@ #define MAX_PES_BUF_SIZE 2048 +#define CORRUPT_PES_THRESHOLD 10 + #define NULL_PID 0x1fff #define INVALID_PID ((unsigned int)(-1)) #define INVALID_PROGRAM ((unsigned int)(-1)) @@ -913,12 +915,17 @@ static void demux_ts_buffer_pes(demux_ts_t*this, unsigned char *ts, m->buf = m->fifo->buffer_pool_alloc(m->fifo); if (!demux_ts_parse_pes_header(this->stream->xine, m, ts, len, this->stream)) { - m->corrupted_pes = 1; m->buf->free_buffer(m->buf); m->buf = NULL; - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + + if (m->corrupted_pes > CORRUPT_PES_THRESHOLD) { + if (this->videoPid == m->pid) + this->videoPid = INVALID_PID; + } else { + m->corrupted_pes++; + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_ts: PID 0x%.4x: corrupted pes encountered\n", m->pid); - + } } else { m->corrupted_pes = 0; @@ -1298,7 +1305,6 @@ printf("Program Number is %i, looking for %i\n",program_number,this->program_num case ISO_13818_PES_PRIVATE: for (i = 5; i < coded_length; i += stream[i+1] + 2) { if ((stream[i] == 0x6a) && (this->audio_tracks_count < MAX_AUDIO_TRACKS)) { - uint32_t format_identifier=0; int i, found = 0; for(i = 0; i < this->audio_tracks_count; i++) { if(this->audio_tracks[i].pid == pid) { @@ -1784,13 +1790,27 @@ static void demux_ts_parse_packet (demux_ts_t*this) { if ( (pes_stream_id >= VIDEO_STREAM_S) && (pes_stream_id <= VIDEO_STREAM_E) ) { if ( this->videoPid == INVALID_PID) { - - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, - "demux_ts: auto-detected video pid 0x%.4x\n", pid); - - this->videoPid = pid; - this->videoMedia = this->media_num; - demux_ts_pes_new(this, this->media_num++, pid, this->video_fifo, pes_stream_id); + int i, found = 0; + for(i = 0; i < this->media_num; i++) { + if (this->media[i].pid == pid) { + found = 1; + break; + } + } + + if (found && (this->media[i].corrupted_pes == 0)) { + this->videoPid = pid; + this->videoMedia = i; + } else if (!found) { + this->videoPid = pid; + this->videoMedia = this->media_num; + demux_ts_pes_new(this, this->media_num++, pid, this->video_fifo, pes_stream_id); + } + + if (this->videoPid != INVALID_PID) { + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + "demux_ts: auto-detected video pid 0x%.4x\n", pid); + } } } else if ( (pes_stream_id >= AUDIO_STREAM_S) && (pes_stream_id <= AUDIO_STREAM_E) ) { if (this->audio_tracks_count < MAX_AUDIO_TRACKS) { @@ -2060,7 +2080,6 @@ static int demux_ts_get_optional_data(demux_plugin_t *this_gen, demux_ts_t *this = (demux_ts_t *) this_gen; char *str = data; int channel = *((int *)data); - int track_num; /* be a bit paranoid */ if (this == NULL || this->stream == NULL) diff --git a/src/demuxers/demux_tta.c b/src/demuxers/demux_tta.c index 724404a5b..4d53c5d3f 100644 --- a/src/demuxers/demux_tta.c +++ b/src/demuxers/demux_tta.c @@ -32,6 +32,7 @@ #include "buffer.h" #include "bswap.h" #include "group_audio.h" +#include "attributes.h" typedef struct { demux_plugin_t demux_plugin; @@ -56,7 +57,7 @@ typedef struct { uint32_t samplerate; uint32_t data_length; uint32_t crc32; - } __attribute__((__packed__)) tta; + } XINE_PACKED tta; uint8_t buffer[22]; /* This is the size of the header */ } header; } demux_tta_t; diff --git a/src/demuxers/group_audio.c b/src/demuxers/group_audio.c index 8c1efdde6..449c2ad12 100644 --- a/src/demuxers/group_audio.c +++ b/src/demuxers/group_audio.c @@ -68,7 +68,7 @@ static const demuxer_info_t demux_info_mpgaudio = { }; static const demuxer_info_t demux_info_mpc = { - 0 /* priority */ + 1 /* priority */ }; static const demuxer_info_t demux_info_realaudio = { diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index b85bc534e..029658fe1 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -1566,7 +1566,6 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { */ static void _cdda_save_cached_cddb_infos(cdda_input_plugin_t *this, char *filecontent) { FILE *fd; - DIR *dir; char *cfile; const char *const xdg_cache_home = xdgCacheHome(this->stream->xine->basedir_handle); @@ -2243,7 +2242,7 @@ static uint32_t cdda_plugin_get_capabilities (input_plugin_t *this_gen) { } -static off_t cdda_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) { +static off_t cdda_plugin_read (input_plugin_t *this_gen, void *buf, off_t len) { /* only allow reading in block-sized chunks */ diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c index 50162c7db..38ad0be82 100644 --- a/src/input/input_dvb.c +++ b/src/input/input_dvb.c @@ -2468,8 +2468,10 @@ static void ts_rewrite_packets (dvb_input_plugin_t *this, unsigned char * origin } static off_t dvb_plugin_read (input_plugin_t *this_gen, - char *buf, off_t len) { + void *buf_gen, off_t len) { dvb_input_plugin_t *this = (dvb_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; + off_t n=0, total=0; int have_mutex=0; struct pollfd pfd; diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index 1a8861289..dc38ceecd 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -853,8 +853,9 @@ static buf_element_t *dvd_plugin_read_block (input_plugin_t *this_gen, return buf; } -static off_t dvd_plugin_read (input_plugin_t *this_gen, char *ch_buf, off_t len) { +static off_t dvd_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len) { /* dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; */ + char *ch_buf = (char *)buf_gen; /* FIXME: Tricking the demux_mpeg_block plugin */ ch_buf[0] = 0; diff --git a/src/input/input_file.c b/src/input/input_file.c index 0ec25e1f8..cc1e55c87 100644 --- a/src/input/input_file.c +++ b/src/input/input_file.c @@ -144,7 +144,7 @@ static int check_mmap_file(file_input_plugin_t *this) { } #endif -static off_t file_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) { +static off_t file_plugin_read (input_plugin_t *this_gen, void *buf, off_t len) { file_input_plugin_t *this = (file_input_plugin_t *) this_gen; #ifdef HAVE_MMAP @@ -359,6 +359,9 @@ static int file_plugin_open (input_plugin_t *this_gen ) { file_input_plugin_t *this = (file_input_plugin_t *) this_gen; char *filename; struct stat sbuf; +#ifdef HAVE_MMAP + size_t tmp_size; +#endif lprintf("file_plugin_open\n"); @@ -423,10 +426,14 @@ static int file_plugin_open (input_plugin_t *this_gen ) { } #ifdef HAVE_MMAP - if ( (this->mmap_base = mmap(NULL, sbuf.st_size, PROT_READ, MAP_SHARED, this->fh, 0)) != (void*)-1 ) { + tmp_size = sbuf.st_size; /* may cause truncation - if it does, DON'T mmap! */ + if ((tmp_size == sbuf.st_size) && + ( (this->mmap_base = mmap(NULL, tmp_size, PROT_READ, MAP_SHARED, this->fh, 0)) != (void*)-1 )) { this->mmap_on = 1; this->mmap_curr = this->mmap_base; this->mmap_len = sbuf.st_size; + } else { + this->mmap_base = NULL; } #endif diff --git a/src/input/input_gnome_vfs.c b/src/input/input_gnome_vfs.c index 540abd0f4..1fe29fbcd 100644 --- a/src/input/input_gnome_vfs.c +++ b/src/input/input_gnome_vfs.c @@ -75,8 +75,9 @@ gnomevfs_plugin_get_capabilities (input_plugin_t *this_gen) #define SSH_BUFFER_SIZE 256 * 1024 static off_t -gnomevfs_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) +gnomevfs_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len) { + char *buf = (char *)buf_gen; gnomevfs_input_t *this = (gnomevfs_input_t *) this_gen; off_t n, num_bytes; diff --git a/src/input/input_http.c b/src/input/input_http.c index d1202ae14..3db5af002 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -404,8 +404,9 @@ error: } static off_t http_plugin_read (input_plugin_t *this_gen, - char *buf, off_t nlen) { + void *buf_gen, off_t nlen) { http_input_plugin_t *this = (http_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; off_t n, num_bytes; num_bytes = 0; diff --git a/src/input/input_mms.c b/src/input/input_mms.c index 739d81a59..23102ac18 100644 --- a/src/input/input_mms.c +++ b/src/input/input_mms.c @@ -98,8 +98,9 @@ typedef struct { } mms_input_class_t; static off_t mms_plugin_read (input_plugin_t *this_gen, - char *buf, off_t len) { + void *buf_gen, off_t len) { mms_input_plugin_t *this = (mms_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; off_t n = 0; lprintf ("mms_plugin_read: %"PRId64" bytes ...\n", len); diff --git a/src/input/input_net.c b/src/input/input_net.c index 0ce2e1340..dd318c37c 100644 --- a/src/input/input_net.c +++ b/src/input/input_net.c @@ -249,8 +249,9 @@ static int host_connect(const char *host, int port, xine_t *xine) { #define HIGH_WATER_MARK 100 static off_t net_plugin_read (input_plugin_t *this_gen, - char *buf, off_t len) { + void *buf_gen, off_t len) { net_input_plugin_t *this = (net_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; off_t n, total; lprintf("reading %" PRIdMAX " bytes...\n", (intmax_t)len); diff --git a/src/input/input_plugin.h b/src/input/input_plugin.h index 11e1303e7..66b3abbb9 100644 --- a/src/input/input_plugin.h +++ b/src/input/input_plugin.h @@ -118,7 +118,7 @@ struct input_plugin_s { * Should block until some bytes available for read; * a return value of 0 indicates no data available */ - off_t (*read) (input_plugin_t *this, char *buf, off_t nlen); + off_t (*read) (input_plugin_t *this, void *buf, off_t nlen); /* diff --git a/src/input/input_pnm.c b/src/input/input_pnm.c index e1413b0f7..29d65da2d 100644 --- a/src/input/input_pnm.c +++ b/src/input/input_pnm.c @@ -76,8 +76,9 @@ typedef struct { static off_t pnm_plugin_read (input_plugin_t *this_gen, - char *buf, off_t len) { + void *buf_gen, off_t len) { pnm_input_plugin_t *this = (pnm_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; off_t n; lprintf ("pnm_plugin_read: %"PRId64" bytes ...\n", len); diff --git a/src/input/input_pvr.c b/src/input/input_pvr.c index bcf93af2b..48b69c8f5 100644 --- a/src/input/input_pvr.c +++ b/src/input/input_pvr.c @@ -423,8 +423,9 @@ static uint32_t pvr_plugin_get_capabilities (input_plugin_t *this_gen) { } -static off_t pvr_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) { +static off_t pvr_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len) { /*pvr_input_plugin_t *this = (pvr_input_plugin_t *) this_gen;*/ + char *buf = (char *)buf_gen; /* FIXME: Tricking the demux_mpeg_block plugin */ buf[0] = 0; diff --git a/src/input/input_rtp.c b/src/input/input_rtp.c index d4ba804c6..2c6c581c2 100644 --- a/src/input/input_rtp.c +++ b/src/input/input_rtp.c @@ -432,8 +432,9 @@ static void * input_plugin_read_loop(void *arg) { /* ***************************************************************** */ static off_t rtp_plugin_read (input_plugin_t *this_gen, - char *buf, off_t length) { + void *buf_gen, off_t length) { rtp_input_plugin_t *this = (rtp_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; struct timeval tv; struct timespec timeout; diff --git a/src/input/input_rtsp.c b/src/input/input_rtsp.c index 693e8af66..cd2209baa 100644 --- a/src/input/input_rtsp.c +++ b/src/input/input_rtsp.c @@ -77,7 +77,7 @@ typedef struct { static off_t rtsp_plugin_read (input_plugin_t *this_gen, - char *buf, off_t len) { + void *buf, off_t len) { rtsp_input_plugin_t *this = (rtsp_input_plugin_t *) this_gen; off_t n; diff --git a/src/input/input_smb.c b/src/input/input_smb.c index 4cacebf89..87f2a81fa 100644 --- a/src/input/input_smb.c +++ b/src/input/input_smb.c @@ -66,9 +66,10 @@ smb_plugin_get_capabilities (input_plugin_t *this_gen) static off_t -smb_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) +smb_plugin_read (input_plugin_t *this_gen, void *buf_gen, off_t len) { smb_input_t *this = (smb_input_t *) this_gen; + char *buf = (char *)buf_gen; off_t n, num_bytes; num_bytes = 0; diff --git a/src/input/input_stdin_fifo.c b/src/input/input_stdin_fifo.c index 939f56f25..2b3cf1376 100644 --- a/src/input/input_stdin_fifo.c +++ b/src/input/input_stdin_fifo.c @@ -81,9 +81,10 @@ static off_t stdin_plugin_get_current_pos (input_plugin_t *this_gen); static off_t stdin_plugin_read (input_plugin_t *this_gen, - char *buf, off_t len) { + void *buf_gen, off_t len) { stdin_input_plugin_t *this = (stdin_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; off_t n, total; lprintf ("reading %"PRId64" bytes...\n", len); diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c index 6829470ff..959874b14 100644 --- a/src/input/input_v4l.c +++ b/src/input/input_v4l.c @@ -1192,7 +1192,7 @@ static int v4l_adjust_realtime_speed(v4l_input_plugin_t *this, fifo_buffer_t *fi * Plugin read. * This function is not supported by the plugin. */ -static off_t v4l_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) { +static off_t v4l_plugin_read (input_plugin_t *this_gen, void *buf, off_t len) { lprintf("Read not supported\n"); return 0; } diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c index bcd50ecc1..7d2ea0063 100644 --- a/src/input/input_vcd.c +++ b/src/input/input_vcd.c @@ -340,9 +340,10 @@ static int sun_vcd_read(vcd_input_plugin_t *this, long lba, cdsector_t *data) #if defined (__linux__) static off_t vcd_plugin_read (input_plugin_t *this_gen, - char *buf, off_t nlen) { + void *buf_gen, off_t nlen) { vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; static struct cdrom_msf msf ; static cdsector_t data; struct cdrom_msf0 *end_msf; @@ -398,8 +399,9 @@ static off_t vcd_plugin_read (input_plugin_t *this_gen, } #elif defined (__FreeBSD__) static off_t vcd_plugin_read (input_plugin_t *this_gen, - char *buf, off_t nlen) { + void *buf_gen, off_t nlen) { vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; static cdsector_t data; int bsize = 2352; @@ -422,9 +424,10 @@ static off_t vcd_plugin_read (input_plugin_t *this_gen, } #elif defined (__sun) static off_t vcd_plugin_read (input_plugin_t *this_gen, - char *buf, off_t nlen) { + void *buf_gen, off_t nlen) { vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; static cdsector_t data; struct cdrom_msf0 *end_msf; long lba; diff --git a/src/libreal/real_common.c b/src/libreal/real_common.c index 22c33aa03..e2a4ee3d6 100644 --- a/src/libreal/real_common.c +++ b/src/libreal/real_common.c @@ -79,7 +79,7 @@ void _x_real_codecs_init(xine_t *const xine) { struct stat s; #define try_real_path(path) \ - if (!stat (path "/dvrc.so", &s)) \ + if (!stat (path "/drvc.so", &s)) \ default_real_codecs_path = path; #define try_real_subpath(path) \ try_real_path("/usr/" path) \ @@ -114,7 +114,7 @@ void _x_real_codecs_init(xine_t *const xine) { "how to install the codecs."), 10, NULL, NULL); - lprintf ("real codecs path : %s\n", real_codec_path); + lprintf ("real codecs path : %s\n", real_codecs_path); } void *_x_real_codec_open(xine_stream_t *const stream, const char *const path, diff --git a/src/vdr/input_vdr.c b/src/vdr/input_vdr.c index 1f82def28..97da8e834 100644 --- a/src/vdr/input_vdr.c +++ b/src/vdr/input_vdr.c @@ -1308,9 +1308,10 @@ static int internal_write_event_play_external(vdr_input_plugin_t *this, uint32_t } static off_t vdr_plugin_read(input_plugin_t *this_gen, - char *buf, off_t len) + void *buf_gen, off_t len) { vdr_input_plugin_t *this = (vdr_input_plugin_t *) this_gen; + char *buf = (char *)buf_gen; off_t n, total; #ifdef LOG_READ lprintf ("reading %lld bytes...\n", len); diff --git a/src/video_out/video_out_fb.c b/src/video_out/video_out_fb.c index e2672e2a1..c6b8f597a 100644 --- a/src/video_out/video_out_fb.c +++ b/src/video_out/video_out_fb.c @@ -99,7 +99,6 @@ typedef struct fb_frame_s yuv2rgb_t *yuv2rgb; /* yuv2rgb converter for this frame */ uint8_t *rgb_dst; int yuv_stride; - int stripe_height, stripe_inc; int bytes_per_line; @@ -182,7 +181,6 @@ static void fb_frame_proc_slice(vo_frame_t *vo_img, uint8_t **src) else frame->yuv2rgb->yuy22rgb_fun(frame->yuv2rgb, frame->rgb_dst, src[0]); - frame->rgb_dst += frame->stripe_inc; } static void fb_frame_field(vo_frame_t *vo_img, int which_field) @@ -193,21 +191,18 @@ static void fb_frame_field(vo_frame_t *vo_img, int which_field) { case VO_TOP_FIELD: frame->rgb_dst = frame->data; - frame->stripe_inc = 2*frame->stripe_height * - frame->bytes_per_line; break; case VO_BOTTOM_FIELD: frame->rgb_dst = frame->data + frame->bytes_per_line ; - frame->stripe_inc = 2*frame->stripe_height * - frame->bytes_per_line; break; case VO_BOTH_FIELDS: frame->rgb_dst = frame->data; break; } + frame->yuv2rgb->next_slice (frame->yuv2rgb, NULL); } static void fb_frame_dispose(vo_frame_t *vo_img) @@ -304,11 +299,11 @@ static void setup_colorspace_converter(fb_frame_t *frame, int flags) frame->yuv2rgb-> configure(frame->yuv2rgb, frame->sc.delivered_width, - 16, + frame->sc.delivered_height, 2 * frame->vo_frame.pitches[0], 2 * frame->vo_frame.pitches[1], frame->sc.output_width, - frame->stripe_height, + frame->sc.output_height, frame->bytes_per_line * 2); frame->yuv_stride = frame->bytes_per_line * 2; break; @@ -317,42 +312,17 @@ static void setup_colorspace_converter(fb_frame_t *frame, int flags) frame->yuv2rgb-> configure(frame->yuv2rgb, frame->sc.delivered_width, - 16, + frame->sc.delivered_height, frame->vo_frame.pitches[0], frame->vo_frame.pitches[1], frame->sc.output_width, - frame->stripe_height, + frame->sc.output_height, frame->bytes_per_line); frame->yuv_stride = frame->bytes_per_line; break; } } -static void reset_dest_pointers(fb_frame_t *frame, int flags) -{ - switch(flags) - { - case VO_TOP_FIELD: - frame->rgb_dst = frame->data; - frame->stripe_inc = 2 * frame->stripe_height * - frame->bytes_per_line; - break; - - case VO_BOTTOM_FIELD: - frame->rgb_dst = frame->data + - frame->bytes_per_line ; - frame->stripe_inc = 2 * frame->stripe_height * - frame->bytes_per_line; - break; - - case VO_BOTH_FIELDS: - frame->rgb_dst = frame->data; - frame->stripe_inc = frame->stripe_height * - frame->bytes_per_line; - break; - } -} - static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame, uint32_t width, uint32_t height, int format) { @@ -445,8 +415,6 @@ static void fb_update_frame_format(vo_driver_t *this_gen, frame_reallocate(this, frame, width, height, format); - frame->stripe_height = 16 * frame->sc.output_height / - frame->sc.delivered_height; if(this->use_zero_copy) frame->bytes_per_line = this->fb_bytes_per_line; else @@ -456,7 +424,7 @@ static void fb_update_frame_format(vo_driver_t *this_gen, setup_colorspace_converter(frame, flags); } - reset_dest_pointers(frame, flags); + fb_frame_field(frame_gen, flags); } static void fb_overlay_clut_yuv2rgb(fb_driver_t *this, diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 66e28d80d..75cef4ce6 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -1211,13 +1211,27 @@ static void *ao_loop (void *this_gen) { } if( result < 0 ) { - /* FIXME: USB device unplugged. - * We should get the card into a closed state here, that involves closing - * the PCM as well as the MIXER. - * Maybe we should pause the stream until the USB device is plugged in again. - * Return values 0 happen even if usb not unplugged, so needs further investigation. - */ - xprintf(this->xine, XINE_VERBOSITY_LOG, _("write to sound card failed. Was a USB device unplugged ?\n")); + /* device unplugged. */ + xprintf(this->xine, XINE_VERBOSITY_LOG, _("write to sound card failed. Assuming the device was unplugged.\n")); + _x_message (in_buf->stream, XINE_MSG_AUDIO_OUT_UNAVAILABLE, NULL); + + pthread_mutex_lock( &this->driver_lock ); + if(this->driver_open) { + this->driver->close(this->driver); + this->driver_open = 0; + this->driver->exit(this->driver); + this->driver = _x_load_audio_output_plugin (this->xine, "none"); + if (this->driver && !in_buf->stream->emergency_brake && + ao_change_settings(this, + in_buf->format.bits, + in_buf->format.rate, + in_buf->format.mode) == 0) { + in_buf->stream->emergency_brake = 1; + _x_message (in_buf->stream, XINE_MSG_AUDIO_OUT_UNAVAILABLE, NULL); + } + } + pthread_mutex_unlock( &this->driver_lock ); + /* closing the driver will result in XINE_MSG_AUDIO_OUT_UNAVAILABLE to be emitted */ } lprintf ("loop: next buf from fifo\n"); diff --git a/src/xine-engine/input_cache.c b/src/xine-engine/input_cache.c index 75c4beb43..7537c4d16 100644 --- a/src/xine-engine/input_cache.c +++ b/src/xine-engine/input_cache.c @@ -62,8 +62,9 @@ typedef struct { /* * read data from input plugin and write it into file */ -static off_t cache_plugin_read(input_plugin_t *this_gen, char *buf, off_t len) { +static off_t cache_plugin_read(input_plugin_t *this_gen, void *buf_gen, off_t len) { cache_input_plugin_t *this = (cache_input_plugin_t *)this_gen; + char *buf = (char *)buf_gen; off_t read_len = 0; off_t main_read; diff --git a/src/xine-engine/input_rip.c b/src/xine-engine/input_rip.c index 56850ba2d..774ef82c5 100644 --- a/src/xine-engine/input_rip.c +++ b/src/xine-engine/input_rip.c @@ -100,8 +100,9 @@ static off_t min_off(off_t a, off_t b) { /* * read data from input plugin and write it into file */ -static off_t rip_plugin_read(input_plugin_t *this_gen, char *buf, off_t len) { +static off_t rip_plugin_read(input_plugin_t *this_gen, void *buf_gen, off_t len) { rip_input_plugin_t *this = (rip_input_plugin_t *)this_gen; + char *buf = (char *)buf_gen; off_t retlen, npreview, nread, nwrite, nread_orig, nread_file; lprintf("reading %"PRId64" bytes (curpos = %"PRId64", savepos = %"PRId64")\n", len, this->curpos, this->savepos); diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index ca1f87c7a..750ec21e7 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -1721,6 +1721,38 @@ static ao_driver_t *_load_audio_driver (xine_t *this, plugin_node_t *node, return driver; } +ao_driver_t *_x_load_audio_output_plugin (xine_t *this, const char *id) +{ + plugin_node_t *node; + ao_driver_t *driver = NULL; + ao_info_t *ao_info; + plugin_catalog_t *catalog = this->plugin_catalog; + int list_id, list_size; + + pthread_mutex_lock (&catalog->lock); + + list_size = xine_sarray_size (this->plugin_catalog->plugin_lists[PLUGIN_AUDIO_OUT - 1]); + for (list_id = 0; list_id < list_size; list_id++) { + + node = xine_sarray_get (this->plugin_catalog->plugin_lists[PLUGIN_AUDIO_OUT - 1], list_id); + + ao_info = (ao_info_t *)node->info->special_info; + + if (!strcasecmp(node->info->id, id)) { + driver = _load_audio_driver (this, node, NULL); + break; + } + } + + pthread_mutex_unlock (&catalog->lock); + + if (!driver) { + xprintf (this, XINE_VERBOSITY_LOG, + _("load_plugins: failed to load audio output plugin <%s>\n"), id); + } + return driver; +} + xine_audio_port_t *xine_open_audio_driver (xine_t *this, const char *id, void *data) { diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index fa33da9e1..50720e157 100644 --- a/src/xine-engine/metronom.c +++ b/src/xine-engine/metronom.c @@ -851,7 +851,8 @@ static void metronom_unregister_scr (metronom_clock_t *this, scr_plugin_t *scr) this->scr_master = get_master_scr(this); } -static int metronom_sync_loop (metronom_clock_t *this) { +static void *metronom_sync_loop (void *const this_gen) { + metronom_clock_t *const this = (metronom_clock_t *const)this_gen; struct timeval tv; struct timespec ts; @@ -874,7 +875,7 @@ static int metronom_sync_loop (metronom_clock_t *this) { pthread_mutex_unlock (&this->lock); } - return 0; + return NULL; } static void metronom_exit (metronom_t *this) { @@ -990,7 +991,7 @@ metronom_clock_t *_x_metronom_clock_init(xine_t *xine) this->thread_running = 1; if ((err = pthread_create(&this->sync_thread, NULL, - (void*(*)(void*)) metronom_sync_loop, this)) != 0) + metronom_sync_loop, this)) != 0) xprintf(this->xine, XINE_VERBOSITY_NONE, "cannot create sync thread (%s)\n", strerror(err)); diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c index 4b694699f..ddca0cfaf 100644 --- a/src/xine-engine/scratch.c +++ b/src/xine-engine/scratch.c @@ -108,7 +108,6 @@ static void scratch_dispose (scratch_buffer_t *this) { scratch_buffer_t *_x_new_scratch_buffer (int num_lines) { scratch_buffer_t *this; - int i; this = xine_xmalloc (sizeof (scratch_buffer_t)); diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 208ef7647..fc142d44b 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -500,7 +500,7 @@ vo_driver_t *_x_load_video_output_plugin(xine_t *this, * load a specific audio output plugin */ -ao_driver_t *_x_load_audio_output_plugin (xine_t *self, char *id) XINE_PROTECTED; +ao_driver_t *_x_load_audio_output_plugin (xine_t *self, const char *id) XINE_PROTECTED; void _x_set_speed (xine_stream_t *stream, int speed) XINE_PROTECTED; diff --git a/src/xine-utils/attributes.h b/src/xine-utils/attributes.h index 280fd3685..000008753 100644 --- a/src/xine-utils/attributes.h +++ b/src/xine-utils/attributes.h @@ -33,7 +33,7 @@ #endif #ifdef XINE_COMPILE -# include "config.h" +# include "configure.h" #endif /* Export protected only for libxine functions */ diff --git a/src/xine-utils/cpu_accel.c b/src/xine-utils/cpu_accel.c index b32733fba..06ee90cd3 100644 --- a/src/xine-utils/cpu_accel.c +++ b/src/xine-utils/cpu_accel.c @@ -24,9 +24,10 @@ #include <stdio.h> #include <stdlib.h> #include <inttypes.h> -#include <signal.h> -#include <setjmp.h> + +#if defined(HAVE_MLIB) && defined(MLIB_LAZYLOAD) #include <dlfcn.h> +#endif #if defined (__SVR4) && defined (__sun) #include <sys/systeminfo.h> @@ -40,22 +41,32 @@ #include "xineutils.h" -#if defined(ARCH_X86) || defined(ARCH_X86_64) +#if defined(__i386__) || defined(__x86_64__) + +#ifndef __x86_64__ +#include <signal.h> +#include <setjmp.h> static jmp_buf sigill_return; static void sigill_handler (int n) { longjmp(sigill_return, 1); } +#endif static uint32_t arch_accel (void) { uint32_t caps; -#ifdef __x86_64__ +#if defined(__x86_64__) || \ + ( defined(__SSE__) && defined(__SSE2__) && defined(__MMX__) ) /* No need to test for this on AMD64, we know what the platform has. */ - caps = MM_ACCEL_X86_MMX | MM_ACCEL_X86_SSE | MM_ACCEL_X86_MMXEXT | MM_ACCEL_X86_SSE2; + caps = MM_ACCEL_X86_MMX | MM_ACCEL_X86_SSE | MM_ACCEL_X86_MMXEXT | MM_ACCEL_X86_SSE2 +# if defined(__3dNOW__) + | MM_ACCEL_X86_3DNOW +# endif + ; #else #ifndef _MSC_VER @@ -148,6 +159,9 @@ static uint32_t arch_accel (void) caps = 0; #endif /* _MSC_VER */ +#endif /* x86_64 or built-in options */ + +#ifndef __x86_64__ /* test OS support for SSE */ if (caps & MM_ACCEL_X86_SSE) { void (*old_sigill_handler)(int); @@ -169,9 +183,12 @@ static uint32_t arch_accel (void) return caps; } -#endif /* ARCH_X86 */ +#endif /* i386 or x86_64 */ #if defined(ARCH_PPC) && defined(ENABLE_ALTIVEC) +#include <signal.h> +#include <setjmp.h> + static sigjmp_buf jmpbuf; static volatile sig_atomic_t canjump = 0; @@ -256,6 +273,9 @@ static uint32_t arch_accel (void) return flags; } #else +#include <signal.h> +#include <setjmp.h> + static sigjmp_buf jmpbuf; static volatile sig_atomic_t canjump = 0; @@ -326,7 +346,7 @@ uint32_t xine_mm_accel (void) #endif #endif -#if defined(ARCH_X86) || defined(ARCH_X86_64) || (defined(ARCH_PPC) && defined(ENABLE_ALTIVEC)) || (defined(ARCH_SPARC) && defined(ENABLE_VIS)) +#if defined(__i386__) || defined(__x86_64__) || (defined(ARCH_PPC) && defined(ENABLE_ALTIVEC)) || (defined(ARCH_SPARC) && defined(ENABLE_VIS)) accel |= arch_accel(); #endif diff --git a/version.sh b/version.sh index 2d9438379..37649ecda 100755 --- a/version.sh +++ b/version.sh @@ -6,32 +6,31 @@ # 3. Adjust the values of XINE_LT_CURRENT, XINE_LT_REVISION, and XINE_LT_AGE # according to the following rules: # -# If the interface is totally unchanged from the previous release, -# increment XINE_LT_REVISION by one. Otherwise: -# 1. XINE_LT_REVISION=0 -# 2. Increment XINE_LT_CURRENT by one. -# 3. If any interfaces have been ADDED since the last release, -# increment XINE_LT_AGE by one. If any interfaces have been -# REMOVED or incompatibly changed, XINE_LT_AGE=0 +# 1. Increment XINE_LT_REVISION. +# 2. If any interfaces have been added, removed, or changed, set +# XINE_LT_REVISION to 0 and increment XINE_LT_CURRENT. +# 3. If any interfaces have been added, increment XINE_LT_AGE. +# 4. If any interfaces have been removed or incompatibly changed, +# set XINE_LT_AGE to 0, and rename po/libxine*.pot accordingly +# (use "hg rename"). # -# Regarding libtool versioning, here are some details, but see the info page for -# libtool for the whole story. The most important thing to keep in mind is that -# the libtool version numbers DO NOT MATCH the xine-lib version numbers, and you -# should NEVER try to make them match. +# The most important thing to keep in mind is that the libtool version +# numbers DO NOT MATCH the xine-lib version numbers, and you should NEVER +# try to make them match. +# +# See the libtool documentation for more information. # # XINE_LT_CURRENT the current API version -# XINE_LT_REVISION an internal revision number that is increased when the -# API does not change in any way -# XINE_LT_AGE the number of previous API versions still supported by -# this version +# XINE_LT_REVISION the current revision of the current API +# XINE_LT_AGE the number of previous API versions still supported XINE_VERSION_MAJOR=1 XINE_VERSION_MINOR=1 XINE_VERSION_SUB=90 -XINE_LT_CURRENT=19 +XINE_LT_CURRENT=2 XINE_LT_REVISION=0 -XINE_LT_AGE=17 +XINE_LT_AGE=0 test -f "`dirname $0`/.cvsversion" && XINE_VERSION_SUFFIX="hg" XINE_VERSION_SPEC="${XINE_VERSION_MAJOR}.${XINE_VERSION_MINOR}.${XINE_VERSION_SUB}${XINE_VERSION_SUFFIX}" |