- Build libvlc from src/ rather than top
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 19 Feb 2006 13:11:21 +0000 (13:11 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 19 Feb 2006 13:11:21 +0000 (13:11 +0000)
  so that it is cleanly built before all modules
  (step toward buildable shared libvlc on Win32)
- Don't build position dependant code when building shared libvlc
  (that was a big waste of time)
- Link builtin modules with vlc rather than libvlc

13 files changed:
Makefile.am
bootstrap
configure.ac
src/Makefile.am [new file with mode: 0644]
src/audio_output/ainput.c [new file with mode: 0644]
src/audio_output/input.c [deleted file]
src/control/control_input.c [new file with mode: 0644]
src/control/control_playlist.c [new file with mode: 0644]
src/control/control_vlm.c [new file with mode: 0644]
src/control/input.c [deleted file]
src/control/playlist.c [deleted file]
src/control/vlm.c [deleted file]
toolbox

index fb76cd2..3acbca0 100644 (file)
@@ -12,7 +12,7 @@ NULL =
 #  - . should come before mozilla/bindings because the plugin needs libvlc_pic.a
 #  - po should come before . because VLC.app needs the pofiles
 #  - loader should come before modules because some plugins need it
-SUBDIRS = intl loader modules po . mozilla bindings activex share m4 doc
+SUBDIRS = intl loader src modules po . mozilla bindings activex share m4 doc
 DIST_SUBDIRS = $(SUBDIRS) debian ipkg lib
 
 EXTRA_DIST = \
@@ -23,23 +23,16 @@ EXTRA_DIST = \
        MAINTAINERS \
        README.MacOSX.rtf \
        bootstrap \
-       src/extras/COPYING \
        toolbox \
        vlc-api.pl \
        vlc-config.in.in \
        vlc.spec \
        vlc.spec.mdk \
        vlc.win32.nsi \
-       src/misc/modules_builtin.h.in \
        $(NULL)
 
 BUILT_SOURCES_distclean = vlc-config compile
-BUILT_SOURCES_clean = \
-       stamp-api \
-       macosx-sdk \
-       src/misc/modules_builtin.h \
-       src/misc/version.c \
-       $(NULL)
+BUILT_SOURCES_clean = macosx-sdk
 
 BUILT_SOURCES = $(BUILT_SOURCES_distclean) $(BUILT_SOURCES_clean)
 
@@ -55,116 +48,6 @@ ACLOCAL_AMFLAGS = -I m4
 # because old versions of automake don't support them in configure.ac.
 AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects
 
-###############################################################################
-# Headers
-###############################################################################
-
-pkgincludedir = $(includedir)/vlc
-
-dist_pkginclude_HEADERS = \
-       include/vlc/vlc.h \
-       include/vlc/libvlc.h \
-       include/vlc/aout.h \
-       include/vlc/vout.h \
-       include/vlc/sout.h \
-       include/vlc/decoder.h \
-       include/vlc/input.h \
-       include/vlc/intf.h \
-       include/vlc/mediacontrol.h \
-       include/vlc/mediacontrol_structures.h \
-       $(NULL)
-
-noinst_HEADERS = $(HEADERS_include)
-noinst_DATA = $(DATA_noinst_beos) $(DATA_noinst_libvlc)
-
-HEADERS_include = \
-       include/aout_internal.h \
-       include/audio_output.h \
-       include/beos_specific.h \
-       include/charset.h \
-       include/codecs.h \
-       include/configuration.h \
-       include/darwin_specific.h \
-       include/intf_eject.h \
-       include/iso_lang.h \
-       include/main.h \
-       include/mmx.h \
-       include/modules.h \
-       include/modules_inner.h \
-       include/mtime.h \
-       include/network.h \
-       include/os_specific.h \
-       include/snapshot.h \
-       include/stream_output.h \
-       include/variables.h \
-       include/video_output.h \
-       include/vlc_access.h \
-       include/vlc_acl.h \
-       include/vlc_bits.h \
-       include/vlc_block.h \
-       include/vlc_block_helper.h \
-       include/vlc_codec.h \
-       include/vlc_common.h \
-       include/vlc_config.h \
-       include/vlc_cpu.h \
-       include/vlc_demux.h \
-       include/vlc_error.h \
-       include/vlc_es.h \
-       include/vlc_es_out.h \
-       include/vlc_filter.h \
-       include/vlc_config_cat.h \
-       include/vlc_httpd.h \
-       include/vlc_tls.h \
-       include/vlc_md5.h \
-       include/vlc_image.h \
-       include/vlc_input.h \
-       include/vlc_interaction.h \
-       include/vlc_interface.h \
-       include/vlc_keys.h \
-       include/vlc_messages.h \
-       include/vlc_meta.h \
-       include/vlc_objects.h \
-       include/vlc_osd.h \
-       include/vlc_playlist.h \
-       include/vlc_spu.h \
-       include/vlc_stream.h \
-       include/vlc_symbols.h \
-       include/vlc_threads_funcs.h \
-       include/vlc_threads.h \
-       include/vlc_update.h \
-       include/vlc_video.h \
-       include/vlc_vlm.h \
-       include/vlc_vod.h \
-       include/vlc_xml.h \
-       include/vout_synchro.h \
-       include/win32_specific.h \
-       include/libvlc_internal.h \
-       include/mediacontrol_internal.h
-       $(NULL)
-
-src/misc/modules_builtin.h: Makefile src/misc/modules_builtin.h.in vlc-config
-       srcdir=$(srcdir) $(srcdir)/toolbox --update-includes
-       touch $@
-
-src/misc/modules.c: src/misc/modules_builtin.h
-
-src/misc/version.c: FORCE
-       srcdir=$(srcdir) $(srcdir)/toolbox --update-version
-
-# These dependencies are mandatory
-$(SOURCES_libvlc): $(LIB_intl)
-
-###############################################################################
-# Optional libintl - FIXME, bad dependencies
-###############################################################################
-
-intl/libintl.a: FORCE
-       cd $(top_builddir)/intl && $(MAKE) $(AM_MAKEFLAGS)
-
-if BUILD_INTL
-LIB_intl = intl/libintl.a
-endif
-
 ###############################################################################
 # MacOS X project
 ###############################################################################
@@ -307,197 +190,9 @@ vlc-config: $(top_builddir)/config.status $(top_builddir)/vlc-config.in
 vlc-config.in: vlc-config.in.in
        ./config.status --recheck
 
-MOSTLYCLEANFILES = $(DATA_noinst_libvlc)
 CLEANFILES = $(BUILT_SOURCES_clean) stamp-builtin
 DISTCLEANFILES = $(BUILT_SOURCES_distclean) vlc-config.in compile
 
-lib_LIBRARIES = lib/libvlc.a $(lib_PICLIBRARIES)
-if HAVE_WIN32
-else
-if BUILD_PIC
-lib_PICLIBRARIES = lib/libvlc_pic.a
-endif
-endif
-
-lib_libvlc_a_SOURCES = $(SOURCES_libvlc)
-lib_libvlc_a_CFLAGS = `$(VLC_CONFIG) --cflags vlc`
-lib_libvlc_a_CXXFLAGS = `$(VLC_CONFIG) --cxxflags vlc`
-lib_libvlc_a_OBJCFLAGS = `$(VLC_CONFIG) --objcflags vlc`
-
-lib_libvlc_pic_a_SOURCES = $(SOURCES_libvlc)
-lib_libvlc_pic_a_CFLAGS = `$(VLC_CONFIG) --cflags vlc pic`
-lib_libvlc_pic_a_CXXFLAGS = `$(VLC_CONFIG) --cxxflags vlc pic`
-lib_libvlc_pic_a_OBJCFLAGS = `$(VLC_CONFIG) --objcflags vlc pic`
-
-if HAVE_BEOS
-OPT_SOURCES_libvlc_beos = $(SOURCES_libvlc_beos)
-endif
-if HAVE_DARWIN
-OPT_SOURCES_libvlc_darwin = $(SOURCES_libvlc_darwin)
-endif
-if HAVE_WIN32
-OPT_SOURCES_libvlc_win32 = $(SOURCES_libvlc_win32)
-endif
-if HAVE_WINCE
-OPT_SOURCES_libvlc_win32 = $(SOURCES_libvlc_win32)
-endif
-if BUILD_DIRENT
-OPT_SOURCES_libvlc_dirent = $(SOURCES_libvlc_dirent)
-endif
-if BUILD_GETOPT
-OPT_SOURCES_libvlc_getopt = $(SOURCES_libvlc_getopt)
-endif
-
-# Build libvlc as a shared library
-if BUILD_SHARED
-DATA_noinst_libvlc = libvlc$(LIBEXT)
-if HAVE_WIN32
-OBJECTS_libvlc_so = $(lib_libvlc_a_OBJECTS)
-else
-OBJECTS_libvlc_so = $(lib_libvlc_pic_a_OBJECTS)
-endif
-endif
-
-libvlc$(LIBEXT): $(OBJECTS_libvlc_so)
-       @ldfl="`$(VLC_CONFIG) --libs plugin vlc $(pic) builtin`" ; \
-       case `$(VLC_CONFIG) --linkage vlc` in \
-         c++)  ld="$(CXXLINK)" ;; \
-         objc) ld="$(OBJCLINK)" ;; \
-         c|*)  ld="$(LINK)" ;; \
-       esac ; \
-       echo $$ld $(OBJECTS_libvlc_so) $$ldfl ; \
-       $$ld $(OBJECTS_libvlc_so) $$ldfl
-
-EXTRA_DIST += \
-       $(SOURCES_libvlc_beos) \
-       $(SOURCES_libvlc_darwin) \
-       $(SOURCES_libvlc_win32) \
-       $(SOURCES_libvlc_dirent) \
-       $(SOURCES_libvlc_getopt) \
-       $(NULL)
-
-SOURCES_libvlc_beos = \
-       src/misc/beos_specific.cpp \
-       $(NULL)
-
-SOURCES_libvlc_darwin = \
-       src/misc/darwin_specific.m \
-       $(NULL)
-
-SOURCES_libvlc_win32 = \
-       src/misc/win32_specific.c \
-       $(NULL)
-
-SOURCES_libvlc_dirent = \
-       src/extras/dirent.c \
-       $(NULL)
-
-SOURCES_libvlc_getopt = \
-       src/extras/getopt.c \
-       src/extras/getopt.h \
-       src/extras/getopt1.c \
-       $(NULL)
-
-SOURCES_libvlc_common = \
-       src/libvlc.c \
-       src/libvlc.h \
-       src/interface/interface.c \
-       src/interface/intf_eject.c \
-       src/interface/interaction.c \
-       src/playlist/playlist.c \
-       src/playlist/sort.c \
-       src/playlist/loadsave.c \
-       src/playlist/view.c \
-       src/playlist/item.c \
-       src/playlist/item-ext.c \
-       src/playlist/services_discovery.c \
-       src/input/access.c \
-       src/input/clock.c \
-       src/input/control.c \
-       src/input/decoder.c \
-       src/input/demux.c \
-       src/input/es_out.c \
-       src/input/input.c \
-       src/input/input_internal.h \
-       src/input/stream.c \
-       src/input/mem_stream.c \
-       src/input/subtitles.c \
-       src/input/var.c \
-       src/video_output/video_output.c \
-       src/video_output/vout_pictures.c \
-       src/video_output/vout_pictures.h \
-       src/video_output/video_text.c \
-       src/video_output/video_widgets.c \
-       src/video_output/vout_subpictures.c \
-       src/video_output/vout_synchro.c \
-       src/video_output/vout_intf.c \
-       src/audio_output/common.c \
-       src/audio_output/dec.c \
-       src/audio_output/filters.c \
-       src/audio_output/input.c \
-       src/audio_output/mixer.c \
-       src/audio_output/output.c \
-       src/audio_output/intf.c \
-       src/stream_output/stream_output.c \
-       src/stream_output/announce.c \
-       src/stream_output/sap.c \
-       src/osd/osd.c \
-       src/osd/osd_parser.c \
-       src/osd/osd_text.c \
-       src/osd/osd_widgets.c \
-       src/network/acl.c \
-       src/network/getaddrinfo.c \
-       src/network/io.c \
-       src/network/tcp.c \
-       src/network/udp.c \
-       src/network/httpd.c \
-       src/network/rootwrap.c \
-       src/network/tls.c \
-       src/misc/charset.c \
-       src/misc/md5.c \
-       src/misc/mtime.c \
-       src/misc/block.c \
-       src/misc/modules.c \
-       src/misc/threads.c \
-       src/misc/stats.c \
-       src/misc/unicode.c \
-       src/misc/cpu.c \
-       src/misc/configuration.c \
-       src/misc/image.c \
-       src/misc/iso_lang.c \
-       src/misc/iso-639_def.h \
-       src/misc/messages.c \
-       src/misc/objects.c \
-       src/misc/variables.c \
-       src/misc/error.c \
-       src/misc/update.c \
-       src/misc/vlm.c \
-       src/misc/xml.c \
-       src/misc/hashtables.c \
-       src/misc/version.c \
-       src/extras/libc.c \
-       src/control/core.c \
-       src/control/playlist.c \
-       src/control/vlm.c \
-       src/control/input.c \
-       src/control/video.c \
-       src/control/mediacontrol_core.c \
-       src/control/mediacontrol_util.c \
-       src/control/mediacontrol_audio_video.c \
-       $(NULL)
-
-# These should be distributed, but not compiled
-EXTRA_DIST += src/control/mediacontrol_init.c src/control/mediacontrol_plugin.c
-
-SOURCES_libvlc = \
-       $(SOURCES_libvlc_common) \
-       $(OPT_SOURCES_libvlc_beos) \
-       $(OPT_SOURCES_libvlc_darwin) \
-       $(OPT_SOURCES_libvlc_win32) \
-       $(OPT_SOURCES_libvlc_dirent) \
-       $(OPT_SOURCES_libvlc_getopt) \
-       $(NULL)
-
 ###############################################################################
 # Building vlc
 ###############################################################################
@@ -505,6 +200,8 @@ SOURCES_libvlc = \
 bin_PROGRAMS = vlc
 
 vlc_SOURCES = src/vlc.c
+# Ugly kludge so that automake defines $(CXXLINK)
+EXTRA_vlc_SOURCES = extras/zsh.cpp
 
 # Work around a bug in the arm-wince-pe linker
 if HAVE_WINCE
@@ -512,22 +209,19 @@ vlc_WORKAROUNDLDFLAGS = $(LIB_libvlc)
 endif
 
 if BUILD_SHARED
-### libvlc.so cannot be created into lib/
-LIB_libvlc = libvlc$(LIBEXT)
-LDFLAGS_libvlc =
+LIB_libvlc = src/libvlc$(LIBEXT)
 #-Wl,-rpath $(libdir)
 else
-LIB_libvlc = lib/libvlc.a
-LDFLAGS_libvlc = `$(VLC_CONFIG) --libs vlc builtin` 
+LIB_libvlc = src/libvlc.a
 endif
 
-vlc_LDFLAGS = $(LDFLAGS_libvlc) $(vlc_WORKAROUNDLDFLAGS)
+vlc_LDFLAGS = `$(VLC_CONFIG) --libs vlc builtin` $(vlc_WORKAROUNDLDFLAGS)
 vlc_LDADD = $(LIB_libvlc) $(DATA_win32_rc) $(LIB_intl)
 vlc_CFLAGS = `$(VLC_CONFIG) --cflags vlc`
 
 # We use DEPENDENCIES_vlc instead of vlc_DEPENDENCIES because of an
 # old automake-1.5 bug (automake/279).
-DEPENDENCIES_vlc = $(LIB_libvlc) $(DATA_win32_rc) $(LIB_intl)
+DEPENDENCIES_vlc = $(LIB_libvlc) $(DATA_win32_rc)
 
 vlc$(EXEEXT): $(vlc_OBJECTS) $(DEPENDENCIES_vlc) stamp-builtin
        @rm -f vlc$(EXEEXT)
@@ -572,14 +266,12 @@ install-exec-local:
          rm -f "$(DESTDIR)$(bindir)/$$i" && \
          ln -sf vlc "$(DESTDIR)$(bindir)/$$i" ; \
        fi ; done
-       test -z "$(DATA_noinst_libvlc)" || $(INSTALL_PROGRAM) "$(DATA_noinst_libvlc)" "$(DESTDIR)$(libdir)"
 
 # the opposite of install-{data,exec}-local
 uninstall-local:
        for i in "" $(ALIASES) ; do if test -n "$$i" ; then \
          rm -f "$(DESTDIR)$(bindir)/$$i" ; \
        fi ; done
-       test -z "$(DATA_noinst_libvlc)" || rm -f "$(DESTDIR)$(libdir)/$(DATA_noinst_libvlc)"
 
 if HAVE_DARWIN
 # Create the MacOS X app
@@ -1191,11 +883,6 @@ stamp-builtin: FORCE
        done
        @if test ! -f $@; then printf "" > $@; fi
 
-stamp-api: Makefile.in $(HEADERS_include) vlc-config vlc-api.pl
-       ( cd $(srcdir) && cat $(HEADERS_include) ) | \
-         top_srcdir="$(top_srcdir)" perl $(top_srcdir)/vlc-api.pl
-       touch stamp-api
-
 ###############################################################################
 # Enforce Mac OS X deployment target environment variable
 ###############################################################################
index ef78ae2..d109472 100755 (executable)
--- a/bootstrap
+++ b/bootstrap
@@ -208,7 +208,7 @@ EXTRA_LIBRARIES = ${extra_libs}
 include Modules.am
 
 if BUILD_SHARED
-LIBVLC = \$(top_builddir)/libvlc\$(LIBEXT)
+LIBVLC = \$(top_builddir)/src/libvlc\$(LIBEXT)
 if HAVE_WIN32
 LIBADD = \$(LIBVLC)
 endif
index 85d1dda..bba8aae 100644 (file)
@@ -5298,6 +5298,7 @@ AC_CONFIG_FILES([
   m4/Makefile
   po/Makefile.in
   share/Makefile
+  src/Makefile
 ])
 
 AC_CONFIG_FILES([
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..477deaf
--- /dev/null
@@ -0,0 +1,344 @@
+###############################################################################
+# Automake targets and declarations
+###############################################################################
+
+NULL =
+SUBDIRS =
+
+EXTRA_DIST = extras/COPYING misc/modules_builtin.h.in
+
+BUILT_SOURCES = $(DISTCLEANFILES) $(CLEANFILES)
+DISTCLEANFILES = stamp-api
+CLEANFILES = misc/modules_builtin.h misc/version.c
+MOSTLYCLEANFILES = $(DATA_noinst_libvlc)
+
+TOOLBOX = srcdir=$(top_srcdir) builddir=$(top_builddir) $(top_srcdir)/toolbox
+
+###############################################################################
+# Headers
+###############################################################################
+
+pkgincludedir = $(includedir)/vlc
+
+dist_pkginclude_HEADERS = \
+       ../include/vlc/vlc.h \
+       ../include/vlc/libvlc.h \
+       ../include/vlc/aout.h \
+       ../include/vlc/vout.h \
+       ../include/vlc/sout.h \
+       ../include/vlc/decoder.h \
+       ../include/vlc/input.h \
+       ../include/vlc/intf.h \
+       ../include/vlc/mediacontrol.h \
+       ../include/vlc/mediacontrol_structures.h \
+       $(NULL)
+
+noinst_HEADERS = $(HEADERS_include)
+noinst_DATA = $(DATA_noinst_libvlc)
+
+HEADERS_include = \
+       ../include/aout_internal.h \
+       ../include/audio_output.h \
+       ../include/beos_specific.h \
+       ../include/charset.h \
+       ../include/codecs.h \
+       ../include/configuration.h \
+       ../include/darwin_specific.h \
+       ../include/intf_eject.h \
+       ../include/iso_lang.h \
+       ../include/main.h \
+       ../include/mmx.h \
+       ../include/modules.h \
+       ../include/modules_inner.h \
+       ../include/mtime.h \
+       ../include/network.h \
+       ../include/os_specific.h \
+       ../include/snapshot.h \
+       ../include/stream_output.h \
+       ../include/variables.h \
+       ../include/video_output.h \
+       ../include/vlc_access.h \
+       ../include/vlc_acl.h \
+       ../include/vlc_bits.h \
+       ../include/vlc_block.h \
+       ../include/vlc_block_helper.h \
+       ../include/vlc_codec.h \
+       ../include/vlc_common.h \
+       ../include/vlc_config.h \
+       ../include/vlc_cpu.h \
+       ../include/vlc_demux.h \
+       ../include/vlc_error.h \
+       ../include/vlc_es.h \
+       ../include/vlc_es_out.h \
+       ../include/vlc_filter.h \
+       ../include/vlc_config_cat.h \
+       ../include/vlc_httpd.h \
+       ../include/vlc_tls.h \
+       ../include/vlc_md5.h \
+       ../include/vlc_image.h \
+       ../include/vlc_input.h \
+       ../include/vlc_interaction.h \
+       ../include/vlc_interface.h \
+       ../include/vlc_keys.h \
+       ../include/vlc_messages.h \
+       ../include/vlc_meta.h \
+       ../include/vlc_objects.h \
+       ../include/vlc_osd.h \
+       ../include/vlc_playlist.h \
+       ../include/vlc_spu.h \
+       ../include/vlc_stream.h \
+       ../include/vlc_symbols.h \
+       ../include/vlc_threads_funcs.h \
+       ../include/vlc_threads.h \
+       ../include/vlc_update.h \
+       ../include/vlc_video.h \
+       ../include/vlc_vlm.h \
+       ../include/vlc_vod.h \
+       ../include/vlc_xml.h \
+       ../include/vout_synchro.h \
+       ../include/win32_specific.h \
+       ../include/libvlc_internal.h \
+       ../include/mediacontrol_internal.h
+       $(NULL)
+
+misc/modules_builtin.h: Makefile misc/modules_builtin.h.in ../vlc-config
+       $(TOOLBOX) --update-includes
+       touch $@
+
+misc/modules.c: misc/modules_builtin.h
+
+misc/version.c: FORCE
+       $(TOOLBOX) --update-version
+
+# These dependencies are mandatory
+$(SOURCES_libvlc): $(LIB_intl)
+
+###############################################################################
+# Optional libintl - FIXME, bad dependencies
+###############################################################################
+
+../intl/libintl.a: FORCE
+       cd $(top_builddir)/intl && $(MAKE) $(AM_MAKEFLAGS)
+
+if BUILD_INTL
+LIB_intl = ../intl/libintl.a
+endif
+
+###############################################################################
+# Building libvlc
+###############################################################################
+
+LIBRARIES_nopic = libvlc.a
+LIBRARIES_pic = libvlc_pic.a
+if HAVE_WIN32
+lib_LIBRARIES = $(LIBRARIES_nopic)
+else
+if BUILD_SHARED
+lib_LIBRARIES = $(LIBRARIES_pic)
+else
+lib_LIBRARIES = $(LIBRARIES_nopic)
+if BUILD_PIC
+lib_LIBRARIES += $(LIBRARIES_pic)
+endif
+endif
+endif
+
+libvlc_a_SOURCES = $(SOURCES_libvlc)
+libvlc_a_CFLAGS = `$(VLC_CONFIG) --cflags vlc`
+libvlc_a_CXXFLAGS = `$(VLC_CONFIG) --cxxflags vlc`
+libvlc_a_OBJCFLAGS = `$(VLC_CONFIG) --objcflags vlc`
+
+libvlc_pic_a_SOURCES = $(SOURCES_libvlc)
+libvlc_pic_a_CFLAGS = `$(VLC_CONFIG) --cflags vlc pic`
+libvlc_pic_a_CXXFLAGS = `$(VLC_CONFIG) --cxxflags vlc pic`
+libvlc_pic_a_OBJCFLAGS = `$(VLC_CONFIG) --objcflags vlc pic`
+
+if HAVE_BEOS
+OPT_SOURCES_libvlc_beos = $(SOURCES_libvlc_beos)
+endif
+if HAVE_DARWIN
+OPT_SOURCES_libvlc_darwin = $(SOURCES_libvlc_darwin)
+endif
+if HAVE_WIN32
+OPT_SOURCES_libvlc_win32 = $(SOURCES_libvlc_win32)
+endif
+if HAVE_WINCE
+OPT_SOURCES_libvlc_win32 = $(SOURCES_libvlc_win32)
+endif
+if BUILD_DIRENT
+OPT_SOURCES_libvlc_dirent = $(SOURCES_libvlc_dirent)
+endif
+if BUILD_GETOPT
+OPT_SOURCES_libvlc_getopt = $(SOURCES_libvlc_getopt)
+endif
+
+# Build libvlc as a shared library
+if BUILD_SHARED
+DATA_noinst_libvlc = libvlc$(LIBEXT)
+if HAVE_WIN32
+OBJECTS_libvlc_so = $(libvlc_a_OBJECTS)
+else
+OBJECTS_libvlc_so = $(libvlc_pic_a_OBJECTS)
+endif
+endif
+
+libvlc$(LIBEXT): $(OBJECTS_libvlc_so)
+       @ldfl="`$(VLC_CONFIG) --libs plugin vlc $(pic)`" ; \
+       case `$(VLC_CONFIG) --linkage vlc` in \
+         c++)  ld="$(CXXLINK)" ;; \
+         objc) ld="$(OBJCLINK)" ;; \
+         c|*)  ld="$(LINK)" ;; \
+       esac ; \
+       echo $$ld $(OBJECTS_libvlc_so) $$ldfl ; \
+       $$ld $(OBJECTS_libvlc_so) $$ldfl
+
+EXTRA_DIST += \
+       $(SOURCES_libvlc_beos) \
+       $(SOURCES_libvlc_darwin) \
+       $(SOURCES_libvlc_win32) \
+       $(SOURCES_libvlc_dirent) \
+       $(SOURCES_libvlc_getopt) \
+       $(NULL)
+
+SOURCES_libvlc_beos = \
+       misc/beos_specific.cpp \
+       $(NULL)
+
+SOURCES_libvlc_darwin = \
+       misc/darwin_specific.m \
+       $(NULL)
+
+SOURCES_libvlc_win32 = \
+       misc/win32_specific.c \
+       $(NULL)
+
+SOURCES_libvlc_dirent = \
+       extras/dirent.c \
+       $(NULL)
+
+SOURCES_libvlc_getopt = \
+       extras/getopt.c \
+       extras/getopt.h \
+       extras/getopt1.c \
+       $(NULL)
+
+SOURCES_libvlc_common = \
+       libvlc.c \
+       libvlc.h \
+       interface/interface.c \
+       interface/intf_eject.c \
+       interface/interaction.c \
+       playlist/playlist.c \
+       playlist/sort.c \
+       playlist/loadsave.c \
+       playlist/view.c \
+       playlist/item.c \
+       playlist/item-ext.c \
+       playlist/services_discovery.c \
+       input/access.c \
+       input/clock.c \
+       input/control.c \
+       input/decoder.c \
+       input/demux.c \
+       input/es_out.c \
+       input/input.c \
+       input/input_internal.h \
+       input/stream.c \
+       input/mem_stream.c \
+       input/subtitles.c \
+       input/var.c \
+       video_output/video_output.c \
+       video_output/vout_pictures.c \
+       video_output/vout_pictures.h \
+       video_output/video_text.c \
+       video_output/video_widgets.c \
+       video_output/vout_subpictures.c \
+       video_output/vout_synchro.c \
+       video_output/vout_intf.c \
+       audio_output/common.c \
+       audio_output/dec.c \
+       audio_output/filters.c \
+       audio_output/ainput.c \
+       audio_output/mixer.c \
+       audio_output/output.c \
+       audio_output/intf.c \
+       stream_output/stream_output.c \
+       stream_output/announce.c \
+       stream_output/sap.c \
+       osd/osd.c \
+       osd/osd_parser.c \
+       osd/osd_text.c \
+       osd/osd_widgets.c \
+       network/acl.c \
+       network/getaddrinfo.c \
+       network/io.c \
+       network/tcp.c \
+       network/udp.c \
+       network/httpd.c \
+       network/rootwrap.c \
+       network/tls.c \
+       misc/charset.c \
+       misc/md5.c \
+       misc/mtime.c \
+       misc/block.c \
+       misc/modules.c \
+       misc/threads.c \
+       misc/stats.c \
+       misc/unicode.c \
+       misc/cpu.c \
+       misc/configuration.c \
+       misc/image.c \
+       misc/iso_lang.c \
+       misc/iso-639_def.h \
+       misc/messages.c \
+       misc/objects.c \
+       misc/variables.c \
+       misc/error.c \
+       misc/update.c \
+       misc/vlm.c \
+       misc/xml.c \
+       misc/hashtables.c \
+       misc/version.c \
+       extras/libc.c \
+       control/core.c \
+       control/control_playlist.c \
+       control/control_vlm.c \
+       control/control_input.c \
+       control/video.c \
+       control/mediacontrol_core.c \
+       control/mediacontrol_util.c \
+       control/mediacontrol_audio_video.c \
+       $(NULL)
+
+# These should be distributed, but not compiled
+EXTRA_DIST += control/mediacontrol_init.c control/mediacontrol_plugin.c
+
+SOURCES_libvlc = \
+       $(SOURCES_libvlc_common) \
+       $(OPT_SOURCES_libvlc_beos) \
+       $(OPT_SOURCES_libvlc_darwin) \
+       $(OPT_SOURCES_libvlc_win32) \
+       $(OPT_SOURCES_libvlc_dirent) \
+       $(OPT_SOURCES_libvlc_getopt) \
+       $(NULL)
+
+# Install the symlinks and shared libvlc
+install-exec-local:
+       test -z "$(DATA_noinst_libvlc)" || $(INSTALL_PROGRAM) "$(DATA_noinst_libvlc)" "$(DESTDIR)$(libdir)"
+
+# the opposite of install-{data,exec}-local
+uninstall-local:
+       test -z "$(DATA_noinst_libvlc)" || rm -f "$(DESTDIR)$(libdir)/$(DATA_noinst_libvlc)"
+
+###############################################################################
+# Stamp rules
+###############################################################################
+stamp-api: Makefile.in $(HEADERS_include) ../vlc-api.pl
+       ( cd $(srcdir) && cat $(HEADERS_include) ) | \
+         top_srcdir="$(top_srcdir)" perl $(top_srcdir)/vlc-api.pl
+       touch stamp-api
+
+###############################################################################
+# Force rule
+###############################################################################
+FORCE:
diff --git a/src/audio_output/ainput.c b/src/audio_output/ainput.c
new file mode 100644 (file)
index 0000000..555913f
--- /dev/null
@@ -0,0 +1,771 @@
+/*****************************************************************************
+ * input.c : internal management of input streams for the audio output
+ *****************************************************************************
+ * Copyright (C) 2002-2004 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
+ *
+ * This program 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include <stdlib.h>                            /* calloc(), malloc(), free() */
+#include <string.h>
+
+#include <vlc/vlc.h>
+#include <vlc/input.h>                 /* for input_thread_t and i_pts_delay */
+
+#ifdef HAVE_ALLOCA_H
+#   include <alloca.h>
+#endif
+
+#include "audio_output.h"
+#include "aout_internal.h"
+
+static void inputFailure( aout_instance_t *, aout_input_t *, char * );
+static int VisualizationCallback( vlc_object_t *, char const *,
+                                  vlc_value_t, vlc_value_t, void * );
+static int EqualizerCallback( vlc_object_t *, char const *,
+                              vlc_value_t, vlc_value_t, void * );
+
+/*****************************************************************************
+ * aout_InputNew : allocate a new input and rework the filter pipeline
+ *****************************************************************************/
+int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
+{
+    audio_sample_format_t chain_input_format;
+    audio_sample_format_t chain_output_format;
+    vlc_value_t val, text;
+    char * psz_filters, *psz_visual;
+    int i_visual;
+
+    aout_FormatPrint( p_aout, "input", &p_input->input );
+
+    p_input->i_nb_filters = 0;
+
+    /* Prepare FIFO. */
+    aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
+    p_input->p_first_byte_to_mix = NULL;
+
+    /* Prepare format structure */
+    memcpy( &chain_input_format, &p_input->input,
+            sizeof(audio_sample_format_t) );
+    memcpy( &chain_output_format, &p_aout->mixer.mixer,
+            sizeof(audio_sample_format_t) );
+    chain_output_format.i_rate = p_input->input.i_rate;
+    aout_FormatPrepare( &chain_output_format );
+
+    /* Now add user filters */
+    if( var_Type( p_aout, "visual" ) == 0 )
+    {
+        module_t *p_module;
+        var_Create( p_aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
+        text.psz_string = _("Visualizations");
+        var_Change( p_aout, "visual", VLC_VAR_SETTEXT, &text, NULL );
+        val.psz_string = ""; text.psz_string = _("Disable");
+        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
+        val.psz_string = "spectrometer"; text.psz_string = _("Spectrometer");
+        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
+        val.psz_string = "scope"; text.psz_string = _("Scope");
+        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
+        val.psz_string = "spectrum"; text.psz_string = _("Spectrum");
+        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
+
+        /* Look for goom plugin */
+        p_module = config_FindModule( VLC_OBJECT(p_aout), "goom" );
+        if( p_module )
+        {
+            val.psz_string = "goom"; text.psz_string = "Goom";
+            var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
+        }
+
+        /* Look for galaktos plugin */
+        p_module = config_FindModule( VLC_OBJECT(p_aout), "galaktos" );
+        if( p_module )
+        {
+            val.psz_string = "galaktos"; text.psz_string = "GaLaktos";
+            var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
+        }
+
+        if( var_Get( p_aout, "effect-list", &val ) == VLC_SUCCESS )
+        {
+            var_Set( p_aout, "visual", val );
+            if( val.psz_string ) free( val.psz_string );
+        }
+        var_AddCallback( p_aout, "visual", VisualizationCallback, NULL );
+    }
+
+    if( var_Type( p_aout, "equalizer" ) == 0 )
+    {
+        module_config_t *p_config;
+        int i;
+
+        p_config = config_FindConfig( VLC_OBJECT(p_aout), "equalizer-preset" );
+        if( p_config && p_config->i_list )
+        {
+               var_Create( p_aout, "equalizer",
+                           VLC_VAR_STRING | VLC_VAR_HASCHOICE );
+            text.psz_string = _("Equalizer");
+            var_Change( p_aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL );
+
+            val.psz_string = ""; text.psz_string = _("Disable");
+            var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text );
+
+            for( i = 0; i < p_config->i_list; i++ )
+            {
+                val.psz_string = p_config->ppsz_list[i];
+                text.psz_string = p_config->ppsz_list_text[i];
+                var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE,
+                            &val, &text );
+            }
+
+            var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL );
+        }
+    }
+
+    if( var_Type( p_aout, "audio-filter" ) == 0 )
+    {
+        var_Create( p_aout, "audio-filter",
+                    VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+        text.psz_string = _("Audio filters");
+        var_Change( p_aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL );
+    }
+    if( var_Type( p_aout, "audio-visual" ) == 0 )
+    {
+        var_Create( p_aout, "audio-visual",
+                    VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+        text.psz_string = _("Audio visualizations");
+        var_Change( p_aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL );
+    }
+
+    var_Get( p_aout, "audio-filter", &val );
+    psz_filters = val.psz_string;
+    var_Get( p_aout, "audio-visual", &val );
+    psz_visual = val.psz_string;
+
+    /* parse user filter lists */
+    for( i_visual = 0; i_visual < 2; i_visual++ )
+    {
+        char *psz_next = NULL;
+        char *psz_parser = i_visual ? psz_visual : psz_filters;
+
+        if( psz_parser == NULL || !*psz_parser )
+            continue;
+        
+        while( psz_parser && *psz_parser )
+        {
+            aout_filter_t * p_filter = NULL;
+
+            if( p_input->i_nb_filters >= AOUT_MAX_FILTERS )
+            {
+                msg_Dbg( p_aout, "max filter reached (%d)", AOUT_MAX_FILTERS );
+                break;
+            }
+
+            while( *psz_parser == ' ' && *psz_parser == ':' )
+            {
+                psz_parser++;
+            }
+            if( ( psz_next = strchr( psz_parser , ':'  ) ) )
+            {
+                *psz_next++ = '\0';
+            }
+            if( *psz_parser =='\0' )
+            {
+                break;
+            }
+
+            /* Create a VLC object */
+            p_filter = vlc_object_create( p_aout, sizeof(aout_filter_t) );
+            if( p_filter == NULL )
+            {
+                msg_Err( p_aout, "cannot add user filter %s (skipped)",
+                         psz_parser );
+                psz_parser = psz_next;
+                continue;
+            }
+
+            vlc_object_attach( p_filter , p_aout );
+
+            /* try to find the requested filter */
+            if( i_visual == 1 ) /* this can only be a visualization module */
+            {
+                /* request format */
+                memcpy( &p_filter->input, &chain_output_format,
+                        sizeof(audio_sample_format_t) );
+                memcpy( &p_filter->output, &chain_output_format,
+                        sizeof(audio_sample_format_t) );
+                        
+                p_filter->p_module = module_Need( p_filter, "visualization",
+                                                  psz_parser, VLC_TRUE );
+            }
+            else /* this can be a audio filter module as well as a visualization module */
+            {
+                /* request format */
+                memcpy( &p_filter->input, &chain_input_format,
+                        sizeof(audio_sample_format_t) );
+                memcpy( &p_filter->output, &chain_output_format,
+                        sizeof(audio_sample_format_t) );
+
+                p_filter->p_module = module_Need( p_filter, "audio filter",
+                                              psz_parser, VLC_TRUE );
+
+                if ( p_filter->p_module == NULL )
+                {
+                    /* if the filter requested a special format, retry */
+                    if ( !( AOUT_FMTS_IDENTICAL( &p_filter->input,
+                                                 &chain_input_format )
+                            && AOUT_FMTS_IDENTICAL( &p_filter->output,
+                                                    &chain_output_format ) ) )
+                    {
+                        aout_FormatPrepare( &p_filter->input );
+                        aout_FormatPrepare( &p_filter->output );
+                        p_filter->p_module = module_Need( p_filter, "audio filter",
+                                                          psz_parser, VLC_TRUE );
+                    }
+                    /* try visual filters */
+                    else
+                    {
+                        memcpy( &p_filter->input, &chain_output_format,
+                                sizeof(audio_sample_format_t) );
+                        memcpy( &p_filter->output, &chain_output_format,
+                                sizeof(audio_sample_format_t) );
+                        p_filter->p_module = module_Need( p_filter, "visualization",
+                                                          psz_parser, VLC_TRUE );
+                    }
+                }
+            }
+
+            /* failure */
+            if ( p_filter->p_module == NULL )
+            {
+                msg_Err( p_aout, "cannot add user filter %s (skipped)",
+                         psz_parser );
+
+                vlc_object_detach( p_filter );
+                vlc_object_destroy( p_filter );
+
+                psz_parser = psz_next;
+                continue;
+            }
+
+            /* complete the filter chain if necessary */
+            if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &p_filter->input ) )
+            {
+                if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
+                                                 &p_input->i_nb_filters,
+                                                 &chain_input_format,
+                                                 &p_filter->input ) < 0 )
+                {
+                    msg_Err( p_aout, "cannot add user filter %s (skipped)",
+                             psz_parser );
+
+                    module_Unneed( p_filter, p_filter->p_module );
+                    vlc_object_detach( p_filter );
+                    vlc_object_destroy( p_filter );
+
+                    psz_parser = psz_next;
+                    continue;
+                }
+            }
+
+            /* success */
+            p_filter->b_continuity = VLC_FALSE;
+            p_input->pp_filters[p_input->i_nb_filters++] = p_filter;
+            memcpy( &chain_input_format, &p_filter->output,
+                    sizeof( audio_sample_format_t ) );
+
+            /* next filter if any */
+            psz_parser = psz_next;
+        }
+    }
+    if( psz_filters ) free( psz_filters );
+    if( psz_visual ) free( psz_visual );
+
+    /* complete the filter chain if necessary */
+    if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &chain_output_format ) )
+    {
+        if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
+                                         &p_input->i_nb_filters,
+                                         &chain_input_format,
+                                         &chain_output_format ) < 0 )
+        {
+            inputFailure( p_aout, p_input, "couldn't set an input pipeline" );
+            return -1;
+        }
+    }
+
+    /* Prepare hints for the buffer allocator. */
+    p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
+    p_input->input_alloc.i_bytes_per_sec = -1;
+
+    /* Create resamplers. */
+    if ( AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) )
+    {
+        p_input->i_nb_resamplers = 0;
+    }
+    else
+    {
+        chain_output_format.i_rate = (__MAX(p_input->input.i_rate,
+                                            p_aout->mixer.mixer.i_rate)
+                                 * (100 + AOUT_MAX_RESAMPLING)) / 100;
+        if ( chain_output_format.i_rate == p_aout->mixer.mixer.i_rate )
+        {
+            /* Just in case... */
+            chain_output_format.i_rate++;
+        }
+        p_input->i_nb_resamplers = 0;
+        if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_resamplers,
+                                         &p_input->i_nb_resamplers,
+                                         &chain_output_format,
+                                         &p_aout->mixer.mixer ) < 0 )
+        {
+            inputFailure( p_aout, p_input, "couldn't set a resampler pipeline");
+            return -1;
+        }
+
+        aout_FiltersHintBuffers( p_aout, p_input->pp_resamplers,
+                                 p_input->i_nb_resamplers,
+                                 &p_input->input_alloc );
+        p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
+
+        /* Setup the initial rate of the resampler */
+        p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
+    }
+    p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
+
+    aout_FiltersHintBuffers( p_aout, p_input->pp_filters,
+                             p_input->i_nb_filters,
+                             &p_input->input_alloc );
+    p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
+
+    /* i_bytes_per_sec is still == -1 if no filters */
+    p_input->input_alloc.i_bytes_per_sec = __MAX(
+                                    p_input->input_alloc.i_bytes_per_sec,
+                                    (int)(p_input->input.i_bytes_per_frame
+                                     * p_input->input.i_rate
+                                     / p_input->input.i_frame_length) );
+
+    /* Success */
+    p_input->b_error = VLC_FALSE;
+    p_input->b_restart = VLC_FALSE;
+
+    return 0;
+}
+
+/*****************************************************************************
+ * aout_InputDelete : delete an input
+ *****************************************************************************
+ * This function must be entered with the mixer lock.
+ *****************************************************************************/
+int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
+{
+    if ( p_input->b_error ) return 0;
+
+    aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
+                                 p_input->i_nb_filters );
+    p_input->i_nb_filters = 0;
+    aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
+                                 p_input->i_nb_resamplers );
+    p_input->i_nb_resamplers = 0;
+    aout_FifoDestroy( p_aout, &p_input->fifo );
+
+    return 0;
+}
+
+/*****************************************************************************
+ * aout_InputPlay : play a buffer
+ *****************************************************************************
+ * This function must be entered with the input lock.
+ *****************************************************************************/
+int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
+                    aout_buffer_t * p_buffer )
+{
+    mtime_t start_date;
+
+    if( p_input->b_restart )
+    {
+        aout_fifo_t fifo, dummy_fifo;
+        byte_t      *p_first_byte_to_mix;
+
+        vlc_mutex_lock( &p_aout->mixer_lock );
+
+        /* A little trick to avoid loosing our input fifo */
+        aout_FifoInit( p_aout, &dummy_fifo, p_aout->mixer.mixer.i_rate );
+        p_first_byte_to_mix = p_input->p_first_byte_to_mix;
+        fifo = p_input->fifo;
+        p_input->fifo = dummy_fifo;
+        aout_InputDelete( p_aout, p_input );
+        aout_InputNew( p_aout, p_input );
+        p_input->p_first_byte_to_mix = p_first_byte_to_mix;
+        p_input->fifo = fifo;
+
+        vlc_mutex_unlock( &p_aout->mixer_lock );
+    }
+
+    /* We don't care if someone changes the start date behind our back after
+     * this. We'll deal with that when pushing the buffer, and compensate
+     * with the next incoming buffer. */
+    vlc_mutex_lock( &p_aout->input_fifos_lock );
+    start_date = aout_FifoNextStart( p_aout, &p_input->fifo );
+    vlc_mutex_unlock( &p_aout->input_fifos_lock );
+
+    if ( start_date != 0 && start_date < mdate() )
+    {
+        /* The decoder is _very_ late. This can only happen if the user
+         * pauses the stream (or if the decoder is buggy, which cannot
+         * happen :). */
+        msg_Warn( p_aout, "computed PTS is out of range ("I64Fd"), "
+                  "clearing out", mdate() - start_date );
+        vlc_mutex_lock( &p_aout->input_fifos_lock );
+        aout_FifoSet( p_aout, &p_input->fifo, 0 );
+        p_input->p_first_byte_to_mix = NULL;
+        vlc_mutex_unlock( &p_aout->input_fifos_lock );
+        if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
+            msg_Warn( p_aout, "timing screwed, stopping resampling" );
+        p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
+        if ( p_input->i_nb_resamplers != 0 )
+        {
+            p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
+            p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
+        }
+        start_date = 0;
+        if( p_input->p_input_thread )
+        {
+            stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1,
+                                 NULL );
+        }
+    }
+
+    if ( p_buffer->start_date < mdate() + AOUT_MIN_PREPARE_TIME )
+    {
+        /* The decoder gives us f*cked up PTS. It's its business, but we
+         * can't present it anyway, so drop the buffer. */
+        msg_Warn( p_aout, "PTS is out of range ("I64Fd"), dropping buffer",
+                  mdate() - p_buffer->start_date );
+        if( p_input->p_input_thread )
+        {
+            stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1,
+                                 NULL );
+        }
+        aout_BufferFree( p_buffer );
+        p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
+        if ( p_input->i_nb_resamplers != 0 )
+        {
+            p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
+            p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
+        }
+        return 0;
+    }
+
+    /* If the audio drift is too big then it's not worth trying to resample
+     * the audio. */
+    if ( start_date != 0 &&
+         ( start_date < p_buffer->start_date - 3 * AOUT_PTS_TOLERANCE ) )
+    {
+        msg_Warn( p_aout, "audio drift is too big ("I64Fd"), clearing out",
+                  start_date - p_buffer->start_date );
+        vlc_mutex_lock( &p_aout->input_fifos_lock );
+        aout_FifoSet( p_aout, &p_input->fifo, 0 );
+        p_input->p_first_byte_to_mix = NULL;
+        vlc_mutex_unlock( &p_aout->input_fifos_lock );
+        if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
+            msg_Warn( p_aout, "timing screwed, stopping resampling" );
+        p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
+        if ( p_input->i_nb_resamplers != 0 )
+        {
+            p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
+            p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
+        }
+        start_date = 0;
+    }
+    else if ( start_date != 0 &&
+              ( start_date > p_buffer->start_date + 3 * AOUT_PTS_TOLERANCE ) )
+    {
+        msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer",
+                  start_date - p_buffer->start_date );
+        aout_BufferFree( p_buffer );
+        if( p_input->p_input_thread )
+        {
+            stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1,
+                                 NULL );
+        }
+        return 0;
+    }
+
+    if ( start_date == 0 ) start_date = p_buffer->start_date;
+
+    /* Run pre-filters. */
+
+    aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters,
+                      &p_buffer );
+
+    /* Run the resampler if needed.
+     * We first need to calculate the output rate of this resampler. */
+    if ( ( p_input->i_resampling_type == AOUT_RESAMPLING_NONE ) &&
+         ( start_date < p_buffer->start_date - AOUT_PTS_TOLERANCE
+           || start_date > p_buffer->start_date + AOUT_PTS_TOLERANCE ) &&
+         p_input->i_nb_resamplers > 0 )
+    {
+        /* Can happen in several circumstances :
+         * 1. A problem at the input (clock drift)
+         * 2. A small pause triggered by the user
+         * 3. Some delay in the output stage, causing a loss of lip
+         *    synchronization
+         * Solution : resample the buffer to avoid a scratch.
+         */
+        mtime_t drift = p_buffer->start_date - start_date;
+
+        p_input->i_resamp_start_date = mdate();
+        p_input->i_resamp_start_drift = (int)drift;
+
+        if ( drift > 0 )
+            p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
+        else
+            p_input->i_resampling_type = AOUT_RESAMPLING_UP;
+
+        msg_Warn( p_aout, "buffer is "I64Fd" %s, triggering %ssampling",
+                          drift > 0 ? drift : -drift,
+                          drift > 0 ? "in advance" : "late",
+                          drift > 0 ? "down" : "up");
+    }
+
+    if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
+    {
+        /* Resampling has been triggered previously (because of dates
+         * mismatch). We want the resampling to happen progressively so
+         * it isn't too audible to the listener. */
+
+        if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
+        {
+            p_input->pp_resamplers[0]->input.i_rate += 2; /* Hz */
+        }
+        else
+        {
+            p_input->pp_resamplers[0]->input.i_rate -= 2; /* Hz */
+        }
+
+        /* Check if everything is back to normal, in which case we can stop the
+         * resampling */
+        if( p_input->pp_resamplers[0]->input.i_rate ==
+              p_input->input.i_rate )
+        {
+            p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
+            msg_Warn( p_aout, "resampling stopped after "I64Fi" usec "
+                      "(drift: "I64Fi")",
+                      mdate() - p_input->i_resamp_start_date,
+                      p_buffer->start_date - start_date);
+        }
+        else if( abs( (int)(p_buffer->start_date - start_date) ) <
+                 abs( p_input->i_resamp_start_drift ) / 2 )
+        {
+            /* if we reduced the drift from half, then it is time to switch
+             * back the resampling direction. */
+            if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
+                p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
+            else
+                p_input->i_resampling_type = AOUT_RESAMPLING_UP;
+            p_input->i_resamp_start_drift = 0;
+        }
+        else if( p_input->i_resamp_start_drift &&
+                 ( abs( (int)(p_buffer->start_date - start_date) ) >
+                   abs( p_input->i_resamp_start_drift ) * 3 / 2 ) )
+        {
+            /* If the drift is increasing and not decreasing, than something
+             * is bad. We'd better stop the resampling right now. */
+            msg_Warn( p_aout, "timing screwed, stopping resampling" );
+            p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
+            p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
+        }
+    }
+
+    /* Adding the start date will be managed by aout_FifoPush(). */
+    p_buffer->end_date = start_date +
+        (p_buffer->end_date - p_buffer->start_date);
+    p_buffer->start_date = start_date;
+
+    /* Actually run the resampler now. */
+    if ( p_input->i_nb_resamplers > 0 )
+    {
+        aout_FiltersPlay( p_aout, p_input->pp_resamplers,
+                          p_input->i_nb_resamplers,
+                          &p_buffer );
+    }
+
+    vlc_mutex_lock( &p_aout->input_fifos_lock );
+    aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
+    vlc_mutex_unlock( &p_aout->input_fifos_lock );
+
+    return 0;
+}
+
+/*****************************************************************************
+ * static functions
+ *****************************************************************************/
+
+static void inputFailure( aout_instance_t * p_aout, aout_input_t * p_input,
+                          char * psz_error_message )
+{
+    /* error message */
+    msg_Err( p_aout, "couldn't set an input pipeline" );
+
+    /* clean up */
+    aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
+                                 p_input->i_nb_filters );
+    aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
+                                 p_input->i_nb_resamplers );
+    aout_FifoDestroy( p_aout, &p_input->fifo );
+    var_Destroy( p_aout, "visual" );
+    var_Destroy( p_aout, "equalizer" );
+    var_Destroy( p_aout, "audio-filter" );
+    var_Destroy( p_aout, "audio-visual" );
+
+    /* error flag */
+    p_input->b_error = 1;
+}
+
+static int ChangeFiltersString( aout_instance_t * p_aout, char* psz_variable,
+                                 char *psz_name, vlc_bool_t b_add )
+{
+    vlc_value_t val;
+    char *psz_parser;
+
+    var_Get( p_aout, psz_variable, &val );
+
+    if( !val.psz_string ) val.psz_string = strdup("");
+
+    psz_parser = strstr( val.psz_string, psz_name );
+
+    if( b_add )
+    {
+        if( !psz_parser )
+        {
+            psz_parser = val.psz_string;
+            asprintf( &val.psz_string, (*val.psz_string) ? "%s:%s" : "%s%s",
+                      val.psz_string, psz_name );
+            free( psz_parser );
+        }
+        else
+        {
+            return 0;
+        }
+    }
+    else
+    {
+        if( psz_parser )
+        {
+            memmove( psz_parser, psz_parser + strlen(psz_name) +
+                     (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
+                     strlen(psz_parser + strlen(psz_name)) + 1 );
+        }
+        else
+        {
+            free( val.psz_string );
+            return 0;
+        }
+    }
+
+    var_Set( p_aout, psz_variable, val );
+    free( val.psz_string );
+    return 1;
+}
+
+static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
+                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+    aout_instance_t *p_aout = (aout_instance_t *)p_this;
+    char *psz_mode = newval.psz_string;
+    vlc_value_t val;
+    int i;
+
+    if( !psz_mode || !*psz_mode )
+    {
+        ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
+        ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
+        ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE );
+    }
+    else
+    {
+        if( !strcmp( "goom", psz_mode ) )
+        {
+            ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
+            ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_TRUE );
+            ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
+        }
+        else if( !strcmp( "galaktos", psz_mode ) )
+        {
+            ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
+            ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
+            ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_TRUE );
+        }
+        else
+        {
+            val.psz_string = psz_mode;
+            var_Create( p_aout, "effect-list", VLC_VAR_STRING );
+            var_Set( p_aout, "effect-list", val );
+
+            ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
+            ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_TRUE );
+            ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
+        }
+    }
+
+    /* That sucks */
+    for( i = 0; i < p_aout->i_nb_inputs; i++ )
+    {
+        p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
+    }
+
+    return VLC_SUCCESS;
+}
+
+static int EqualizerCallback( vlc_object_t *p_this, char const *psz_cmd,
+                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+    aout_instance_t *p_aout = (aout_instance_t *)p_this;
+    char *psz_mode = newval.psz_string;
+    vlc_value_t val;
+    int i;
+    int i_ret;
+
+    if( !psz_mode || !*psz_mode )
+    {
+        i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
+                                     VLC_FALSE );
+    }
+    else
+    {
+        val.psz_string = psz_mode;
+        var_Create( p_aout, "equalizer-preset", VLC_VAR_STRING );
+        var_Set( p_aout, "equalizer-preset", val );
+        i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
+                                     VLC_TRUE );
+
+    }
+
+    /* That sucks */
+    if( i_ret == 1 )
+    {
+        for( i = 0; i < p_aout->i_nb_inputs; i++ )
+        {
+            p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
+        }
+    }
+
+    return VLC_SUCCESS;
+}
diff --git a/src/audio_output/input.c b/src/audio_output/input.c
deleted file mode 100644 (file)
index 555913f..0000000
+++ /dev/null
@@ -1,771 +0,0 @@
-/*****************************************************************************
- * input.c : internal management of input streams for the audio output
- *****************************************************************************
- * Copyright (C) 2002-2004 the VideoLAN team
- * $Id$
- *
- * Authors: Christophe Massiot <massiot@via.ecp.fr>
- *
- * This program 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-#include <stdlib.h>                            /* calloc(), malloc(), free() */
-#include <string.h>
-
-#include <vlc/vlc.h>
-#include <vlc/input.h>                 /* for input_thread_t and i_pts_delay */
-
-#ifdef HAVE_ALLOCA_H
-#   include <alloca.h>
-#endif
-
-#include "audio_output.h"
-#include "aout_internal.h"
-
-static void inputFailure( aout_instance_t *, aout_input_t *, char * );
-static int VisualizationCallback( vlc_object_t *, char const *,
-                                  vlc_value_t, vlc_value_t, void * );
-static int EqualizerCallback( vlc_object_t *, char const *,
-                              vlc_value_t, vlc_value_t, void * );
-
-/*****************************************************************************
- * aout_InputNew : allocate a new input and rework the filter pipeline
- *****************************************************************************/
-int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
-{
-    audio_sample_format_t chain_input_format;
-    audio_sample_format_t chain_output_format;
-    vlc_value_t val, text;
-    char * psz_filters, *psz_visual;
-    int i_visual;
-
-    aout_FormatPrint( p_aout, "input", &p_input->input );
-
-    p_input->i_nb_filters = 0;
-
-    /* Prepare FIFO. */
-    aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate );
-    p_input->p_first_byte_to_mix = NULL;
-
-    /* Prepare format structure */
-    memcpy( &chain_input_format, &p_input->input,
-            sizeof(audio_sample_format_t) );
-    memcpy( &chain_output_format, &p_aout->mixer.mixer,
-            sizeof(audio_sample_format_t) );
-    chain_output_format.i_rate = p_input->input.i_rate;
-    aout_FormatPrepare( &chain_output_format );
-
-    /* Now add user filters */
-    if( var_Type( p_aout, "visual" ) == 0 )
-    {
-        module_t *p_module;
-        var_Create( p_aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
-        text.psz_string = _("Visualizations");
-        var_Change( p_aout, "visual", VLC_VAR_SETTEXT, &text, NULL );
-        val.psz_string = ""; text.psz_string = _("Disable");
-        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
-        val.psz_string = "spectrometer"; text.psz_string = _("Spectrometer");
-        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
-        val.psz_string = "scope"; text.psz_string = _("Scope");
-        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
-        val.psz_string = "spectrum"; text.psz_string = _("Spectrum");
-        var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
-
-        /* Look for goom plugin */
-        p_module = config_FindModule( VLC_OBJECT(p_aout), "goom" );
-        if( p_module )
-        {
-            val.psz_string = "goom"; text.psz_string = "Goom";
-            var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
-        }
-
-        /* Look for galaktos plugin */
-        p_module = config_FindModule( VLC_OBJECT(p_aout), "galaktos" );
-        if( p_module )
-        {
-            val.psz_string = "galaktos"; text.psz_string = "GaLaktos";
-            var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text );
-        }
-
-        if( var_Get( p_aout, "effect-list", &val ) == VLC_SUCCESS )
-        {
-            var_Set( p_aout, "visual", val );
-            if( val.psz_string ) free( val.psz_string );
-        }
-        var_AddCallback( p_aout, "visual", VisualizationCallback, NULL );
-    }
-
-    if( var_Type( p_aout, "equalizer" ) == 0 )
-    {
-        module_config_t *p_config;
-        int i;
-
-        p_config = config_FindConfig( VLC_OBJECT(p_aout), "equalizer-preset" );
-        if( p_config && p_config->i_list )
-        {
-               var_Create( p_aout, "equalizer",
-                           VLC_VAR_STRING | VLC_VAR_HASCHOICE );
-            text.psz_string = _("Equalizer");
-            var_Change( p_aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL );
-
-            val.psz_string = ""; text.psz_string = _("Disable");
-            var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text );
-
-            for( i = 0; i < p_config->i_list; i++ )
-            {
-                val.psz_string = p_config->ppsz_list[i];
-                text.psz_string = p_config->ppsz_list_text[i];
-                var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE,
-                            &val, &text );
-            }
-
-            var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL );
-        }
-    }
-
-    if( var_Type( p_aout, "audio-filter" ) == 0 )
-    {
-        var_Create( p_aout, "audio-filter",
-                    VLC_VAR_STRING | VLC_VAR_DOINHERIT );
-        text.psz_string = _("Audio filters");
-        var_Change( p_aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL );
-    }
-    if( var_Type( p_aout, "audio-visual" ) == 0 )
-    {
-        var_Create( p_aout, "audio-visual",
-                    VLC_VAR_STRING | VLC_VAR_DOINHERIT );
-        text.psz_string = _("Audio visualizations");
-        var_Change( p_aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL );
-    }
-
-    var_Get( p_aout, "audio-filter", &val );
-    psz_filters = val.psz_string;
-    var_Get( p_aout, "audio-visual", &val );
-    psz_visual = val.psz_string;
-
-    /* parse user filter lists */
-    for( i_visual = 0; i_visual < 2; i_visual++ )
-    {
-        char *psz_next = NULL;
-        char *psz_parser = i_visual ? psz_visual : psz_filters;
-
-        if( psz_parser == NULL || !*psz_parser )
-            continue;
-        
-        while( psz_parser && *psz_parser )
-        {
-            aout_filter_t * p_filter = NULL;
-
-            if( p_input->i_nb_filters >= AOUT_MAX_FILTERS )
-            {
-                msg_Dbg( p_aout, "max filter reached (%d)", AOUT_MAX_FILTERS );
-                break;
-            }
-
-            while( *psz_parser == ' ' && *psz_parser == ':' )
-            {
-                psz_parser++;
-            }
-            if( ( psz_next = strchr( psz_parser , ':'  ) ) )
-            {
-                *psz_next++ = '\0';
-            }
-            if( *psz_parser =='\0' )
-            {
-                break;
-            }
-
-            /* Create a VLC object */
-            p_filter = vlc_object_create( p_aout, sizeof(aout_filter_t) );
-            if( p_filter == NULL )
-            {
-                msg_Err( p_aout, "cannot add user filter %s (skipped)",
-                         psz_parser );
-                psz_parser = psz_next;
-                continue;
-            }
-
-            vlc_object_attach( p_filter , p_aout );
-
-            /* try to find the requested filter */
-            if( i_visual == 1 ) /* this can only be a visualization module */
-            {
-                /* request format */
-                memcpy( &p_filter->input, &chain_output_format,
-                        sizeof(audio_sample_format_t) );
-                memcpy( &p_filter->output, &chain_output_format,
-                        sizeof(audio_sample_format_t) );
-                        
-                p_filter->p_module = module_Need( p_filter, "visualization",
-                                                  psz_parser, VLC_TRUE );
-            }
-            else /* this can be a audio filter module as well as a visualization module */
-            {
-                /* request format */
-                memcpy( &p_filter->input, &chain_input_format,
-                        sizeof(audio_sample_format_t) );
-                memcpy( &p_filter->output, &chain_output_format,
-                        sizeof(audio_sample_format_t) );
-
-                p_filter->p_module = module_Need( p_filter, "audio filter",
-                                              psz_parser, VLC_TRUE );
-
-                if ( p_filter->p_module == NULL )
-                {
-                    /* if the filter requested a special format, retry */
-                    if ( !( AOUT_FMTS_IDENTICAL( &p_filter->input,
-                                                 &chain_input_format )
-                            && AOUT_FMTS_IDENTICAL( &p_filter->output,
-                                                    &chain_output_format ) ) )
-                    {
-                        aout_FormatPrepare( &p_filter->input );
-                        aout_FormatPrepare( &p_filter->output );
-                        p_filter->p_module = module_Need( p_filter, "audio filter",
-                                                          psz_parser, VLC_TRUE );
-                    }
-                    /* try visual filters */
-                    else
-                    {
-                        memcpy( &p_filter->input, &chain_output_format,
-                                sizeof(audio_sample_format_t) );
-                        memcpy( &p_filter->output, &chain_output_format,
-                                sizeof(audio_sample_format_t) );
-                        p_filter->p_module = module_Need( p_filter, "visualization",
-                                                          psz_parser, VLC_TRUE );
-                    }
-                }
-            }
-
-            /* failure */
-            if ( p_filter->p_module == NULL )
-            {
-                msg_Err( p_aout, "cannot add user filter %s (skipped)",
-                         psz_parser );
-
-                vlc_object_detach( p_filter );
-                vlc_object_destroy( p_filter );
-
-                psz_parser = psz_next;
-                continue;
-            }
-
-            /* complete the filter chain if necessary */
-            if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &p_filter->input ) )
-            {
-                if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
-                                                 &p_input->i_nb_filters,
-                                                 &chain_input_format,
-                                                 &p_filter->input ) < 0 )
-                {
-                    msg_Err( p_aout, "cannot add user filter %s (skipped)",
-                             psz_parser );
-
-                    module_Unneed( p_filter, p_filter->p_module );
-                    vlc_object_detach( p_filter );
-                    vlc_object_destroy( p_filter );
-
-                    psz_parser = psz_next;
-                    continue;
-                }
-            }
-
-            /* success */
-            p_filter->b_continuity = VLC_FALSE;
-            p_input->pp_filters[p_input->i_nb_filters++] = p_filter;
-            memcpy( &chain_input_format, &p_filter->output,
-                    sizeof( audio_sample_format_t ) );
-
-            /* next filter if any */
-            psz_parser = psz_next;
-        }
-    }
-    if( psz_filters ) free( psz_filters );
-    if( psz_visual ) free( psz_visual );
-
-    /* complete the filter chain if necessary */
-    if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &chain_output_format ) )
-    {
-        if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
-                                         &p_input->i_nb_filters,
-                                         &chain_input_format,
-                                         &chain_output_format ) < 0 )
-        {
-            inputFailure( p_aout, p_input, "couldn't set an input pipeline" );
-            return -1;
-        }
-    }
-
-    /* Prepare hints for the buffer allocator. */
-    p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
-    p_input->input_alloc.i_bytes_per_sec = -1;
-
-    /* Create resamplers. */
-    if ( AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) )
-    {
-        p_input->i_nb_resamplers = 0;
-    }
-    else
-    {
-        chain_output_format.i_rate = (__MAX(p_input->input.i_rate,
-                                            p_aout->mixer.mixer.i_rate)
-                                 * (100 + AOUT_MAX_RESAMPLING)) / 100;
-        if ( chain_output_format.i_rate == p_aout->mixer.mixer.i_rate )
-        {
-            /* Just in case... */
-            chain_output_format.i_rate++;
-        }
-        p_input->i_nb_resamplers = 0;
-        if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_resamplers,
-                                         &p_input->i_nb_resamplers,
-                                         &chain_output_format,
-                                         &p_aout->mixer.mixer ) < 0 )
-        {
-            inputFailure( p_aout, p_input, "couldn't set a resampler pipeline");
-            return -1;
-        }
-
-        aout_FiltersHintBuffers( p_aout, p_input->pp_resamplers,
-                                 p_input->i_nb_resamplers,
-                                 &p_input->input_alloc );
-        p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
-
-        /* Setup the initial rate of the resampler */
-        p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
-    }
-    p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
-
-    aout_FiltersHintBuffers( p_aout, p_input->pp_filters,
-                             p_input->i_nb_filters,
-                             &p_input->input_alloc );
-    p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
-
-    /* i_bytes_per_sec is still == -1 if no filters */
-    p_input->input_alloc.i_bytes_per_sec = __MAX(
-                                    p_input->input_alloc.i_bytes_per_sec,
-                                    (int)(p_input->input.i_bytes_per_frame
-                                     * p_input->input.i_rate
-                                     / p_input->input.i_frame_length) );
-
-    /* Success */
-    p_input->b_error = VLC_FALSE;
-    p_input->b_restart = VLC_FALSE;
-
-    return 0;
-}
-
-/*****************************************************************************
- * aout_InputDelete : delete an input
- *****************************************************************************
- * This function must be entered with the mixer lock.
- *****************************************************************************/
-int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input )
-{
-    if ( p_input->b_error ) return 0;
-
-    aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
-                                 p_input->i_nb_filters );
-    p_input->i_nb_filters = 0;
-    aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
-                                 p_input->i_nb_resamplers );
-    p_input->i_nb_resamplers = 0;
-    aout_FifoDestroy( p_aout, &p_input->fifo );
-
-    return 0;
-}
-
-/*****************************************************************************
- * aout_InputPlay : play a buffer
- *****************************************************************************
- * This function must be entered with the input lock.
- *****************************************************************************/
-int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
-                    aout_buffer_t * p_buffer )
-{
-    mtime_t start_date;
-
-    if( p_input->b_restart )
-    {
-        aout_fifo_t fifo, dummy_fifo;
-        byte_t      *p_first_byte_to_mix;
-
-        vlc_mutex_lock( &p_aout->mixer_lock );
-
-        /* A little trick to avoid loosing our input fifo */
-        aout_FifoInit( p_aout, &dummy_fifo, p_aout->mixer.mixer.i_rate );
-        p_first_byte_to_mix = p_input->p_first_byte_to_mix;
-        fifo = p_input->fifo;
-        p_input->fifo = dummy_fifo;
-        aout_InputDelete( p_aout, p_input );
-        aout_InputNew( p_aout, p_input );
-        p_input->p_first_byte_to_mix = p_first_byte_to_mix;
-        p_input->fifo = fifo;
-
-        vlc_mutex_unlock( &p_aout->mixer_lock );
-    }
-
-    /* We don't care if someone changes the start date behind our back after
-     * this. We'll deal with that when pushing the buffer, and compensate
-     * with the next incoming buffer. */
-    vlc_mutex_lock( &p_aout->input_fifos_lock );
-    start_date = aout_FifoNextStart( p_aout, &p_input->fifo );
-    vlc_mutex_unlock( &p_aout->input_fifos_lock );
-
-    if ( start_date != 0 && start_date < mdate() )
-    {
-        /* The decoder is _very_ late. This can only happen if the user
-         * pauses the stream (or if the decoder is buggy, which cannot
-         * happen :). */
-        msg_Warn( p_aout, "computed PTS is out of range ("I64Fd"), "
-                  "clearing out", mdate() - start_date );
-        vlc_mutex_lock( &p_aout->input_fifos_lock );
-        aout_FifoSet( p_aout, &p_input->fifo, 0 );
-        p_input->p_first_byte_to_mix = NULL;
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
-        if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
-            msg_Warn( p_aout, "timing screwed, stopping resampling" );
-        p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
-        if ( p_input->i_nb_resamplers != 0 )
-        {
-            p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
-            p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
-        }
-        start_date = 0;
-        if( p_input->p_input_thread )
-        {
-            stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1,
-                                 NULL );
-        }
-    }
-
-    if ( p_buffer->start_date < mdate() + AOUT_MIN_PREPARE_TIME )
-    {
-        /* The decoder gives us f*cked up PTS. It's its business, but we
-         * can't present it anyway, so drop the buffer. */
-        msg_Warn( p_aout, "PTS is out of range ("I64Fd"), dropping buffer",
-                  mdate() - p_buffer->start_date );
-        if( p_input->p_input_thread )
-        {
-            stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1,
-                                 NULL );
-        }
-        aout_BufferFree( p_buffer );
-        p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
-        if ( p_input->i_nb_resamplers != 0 )
-        {
-            p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
-            p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
-        }
-        return 0;
-    }
-
-    /* If the audio drift is too big then it's not worth trying to resample
-     * the audio. */
-    if ( start_date != 0 &&
-         ( start_date < p_buffer->start_date - 3 * AOUT_PTS_TOLERANCE ) )
-    {
-        msg_Warn( p_aout, "audio drift is too big ("I64Fd"), clearing out",
-                  start_date - p_buffer->start_date );
-        vlc_mutex_lock( &p_aout->input_fifos_lock );
-        aout_FifoSet( p_aout, &p_input->fifo, 0 );
-        p_input->p_first_byte_to_mix = NULL;
-        vlc_mutex_unlock( &p_aout->input_fifos_lock );
-        if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
-            msg_Warn( p_aout, "timing screwed, stopping resampling" );
-        p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
-        if ( p_input->i_nb_resamplers != 0 )
-        {
-            p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
-            p_input->pp_resamplers[0]->b_continuity = VLC_FALSE;
-        }
-        start_date = 0;
-    }
-    else if ( start_date != 0 &&
-              ( start_date > p_buffer->start_date + 3 * AOUT_PTS_TOLERANCE ) )
-    {
-        msg_Warn( p_aout, "audio drift is too big ("I64Fd"), dropping buffer",
-                  start_date - p_buffer->start_date );
-        aout_BufferFree( p_buffer );
-        if( p_input->p_input_thread )
-        {
-            stats_UpdateInteger( p_input->p_input_thread, STATS_LOST_ABUFFERS, 1,
-                                 NULL );
-        }
-        return 0;
-    }
-
-    if ( start_date == 0 ) start_date = p_buffer->start_date;
-
-    /* Run pre-filters. */
-
-    aout_FiltersPlay( p_aout, p_input->pp_filters, p_input->i_nb_filters,
-                      &p_buffer );
-
-    /* Run the resampler if needed.
-     * We first need to calculate the output rate of this resampler. */
-    if ( ( p_input->i_resampling_type == AOUT_RESAMPLING_NONE ) &&
-         ( start_date < p_buffer->start_date - AOUT_PTS_TOLERANCE
-           || start_date > p_buffer->start_date + AOUT_PTS_TOLERANCE ) &&
-         p_input->i_nb_resamplers > 0 )
-    {
-        /* Can happen in several circumstances :
-         * 1. A problem at the input (clock drift)
-         * 2. A small pause triggered by the user
-         * 3. Some delay in the output stage, causing a loss of lip
-         *    synchronization
-         * Solution : resample the buffer to avoid a scratch.
-         */
-        mtime_t drift = p_buffer->start_date - start_date;
-
-        p_input->i_resamp_start_date = mdate();
-        p_input->i_resamp_start_drift = (int)drift;
-
-        if ( drift > 0 )
-            p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
-        else
-            p_input->i_resampling_type = AOUT_RESAMPLING_UP;
-
-        msg_Warn( p_aout, "buffer is "I64Fd" %s, triggering %ssampling",
-                          drift > 0 ? drift : -drift,
-                          drift > 0 ? "in advance" : "late",
-                          drift > 0 ? "down" : "up");
-    }
-
-    if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
-    {
-        /* Resampling has been triggered previously (because of dates
-         * mismatch). We want the resampling to happen progressively so
-         * it isn't too audible to the listener. */
-
-        if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
-        {
-            p_input->pp_resamplers[0]->input.i_rate += 2; /* Hz */
-        }
-        else
-        {
-            p_input->pp_resamplers[0]->input.i_rate -= 2; /* Hz */
-        }
-
-        /* Check if everything is back to normal, in which case we can stop the
-         * resampling */
-        if( p_input->pp_resamplers[0]->input.i_rate ==
-              p_input->input.i_rate )
-        {
-            p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
-            msg_Warn( p_aout, "resampling stopped after "I64Fi" usec "
-                      "(drift: "I64Fi")",
-                      mdate() - p_input->i_resamp_start_date,
-                      p_buffer->start_date - start_date);
-        }
-        else if( abs( (int)(p_buffer->start_date - start_date) ) <
-                 abs( p_input->i_resamp_start_drift ) / 2 )
-        {
-            /* if we reduced the drift from half, then it is time to switch
-             * back the resampling direction. */
-            if( p_input->i_resampling_type == AOUT_RESAMPLING_UP )
-                p_input->i_resampling_type = AOUT_RESAMPLING_DOWN;
-            else
-                p_input->i_resampling_type = AOUT_RESAMPLING_UP;
-            p_input->i_resamp_start_drift = 0;
-        }
-        else if( p_input->i_resamp_start_drift &&
-                 ( abs( (int)(p_buffer->start_date - start_date) ) >
-                   abs( p_input->i_resamp_start_drift ) * 3 / 2 ) )
-        {
-            /* If the drift is increasing and not decreasing, than something
-             * is bad. We'd better stop the resampling right now. */
-            msg_Warn( p_aout, "timing screwed, stopping resampling" );
-            p_input->i_resampling_type = AOUT_RESAMPLING_NONE;
-            p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate;
-        }
-    }
-
-    /* Adding the start date will be managed by aout_FifoPush(). */
-    p_buffer->end_date = start_date +
-        (p_buffer->end_date - p_buffer->start_date);
-    p_buffer->start_date = start_date;
-
-    /* Actually run the resampler now. */
-    if ( p_input->i_nb_resamplers > 0 )
-    {
-        aout_FiltersPlay( p_aout, p_input->pp_resamplers,
-                          p_input->i_nb_resamplers,
-                          &p_buffer );
-    }
-
-    vlc_mutex_lock( &p_aout->input_fifos_lock );
-    aout_FifoPush( p_aout, &p_input->fifo, p_buffer );
-    vlc_mutex_unlock( &p_aout->input_fifos_lock );
-
-    return 0;
-}
-
-/*****************************************************************************
- * static functions
- *****************************************************************************/
-
-static void inputFailure( aout_instance_t * p_aout, aout_input_t * p_input,
-                          char * psz_error_message )
-{
-    /* error message */
-    msg_Err( p_aout, "couldn't set an input pipeline" );
-
-    /* clean up */
-    aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
-                                 p_input->i_nb_filters );
-    aout_FiltersDestroyPipeline( p_aout, p_input->pp_resamplers,
-                                 p_input->i_nb_resamplers );
-    aout_FifoDestroy( p_aout, &p_input->fifo );
-    var_Destroy( p_aout, "visual" );
-    var_Destroy( p_aout, "equalizer" );
-    var_Destroy( p_aout, "audio-filter" );
-    var_Destroy( p_aout, "audio-visual" );
-
-    /* error flag */
-    p_input->b_error = 1;
-}
-
-static int ChangeFiltersString( aout_instance_t * p_aout, char* psz_variable,
-                                 char *psz_name, vlc_bool_t b_add )
-{
-    vlc_value_t val;
-    char *psz_parser;
-
-    var_Get( p_aout, psz_variable, &val );
-
-    if( !val.psz_string ) val.psz_string = strdup("");
-
-    psz_parser = strstr( val.psz_string, psz_name );
-
-    if( b_add )
-    {
-        if( !psz_parser )
-        {
-            psz_parser = val.psz_string;
-            asprintf( &val.psz_string, (*val.psz_string) ? "%s:%s" : "%s%s",
-                      val.psz_string, psz_name );
-            free( psz_parser );
-        }
-        else
-        {
-            return 0;
-        }
-    }
-    else
-    {
-        if( psz_parser )
-        {
-            memmove( psz_parser, psz_parser + strlen(psz_name) +
-                     (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
-                     strlen(psz_parser + strlen(psz_name)) + 1 );
-        }
-        else
-        {
-            free( val.psz_string );
-            return 0;
-        }
-    }
-
-    var_Set( p_aout, psz_variable, val );
-    free( val.psz_string );
-    return 1;
-}
-
-static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
-                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
-{
-    aout_instance_t *p_aout = (aout_instance_t *)p_this;
-    char *psz_mode = newval.psz_string;
-    vlc_value_t val;
-    int i;
-
-    if( !psz_mode || !*psz_mode )
-    {
-        ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
-        ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
-        ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE );
-    }
-    else
-    {
-        if( !strcmp( "goom", psz_mode ) )
-        {
-            ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
-            ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_TRUE );
-            ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
-        }
-        else if( !strcmp( "galaktos", psz_mode ) )
-        {
-            ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_FALSE );
-            ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
-            ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_TRUE );
-        }
-        else
-        {
-            val.psz_string = psz_mode;
-            var_Create( p_aout, "effect-list", VLC_VAR_STRING );
-            var_Set( p_aout, "effect-list", val );
-
-            ChangeFiltersString( p_aout, "audio-visual", "goom", VLC_FALSE );
-            ChangeFiltersString( p_aout, "audio-visual", "visual", VLC_TRUE );
-            ChangeFiltersString( p_aout, "audio-visual", "galaktos", VLC_FALSE);
-        }
-    }
-
-    /* That sucks */
-    for( i = 0; i < p_aout->i_nb_inputs; i++ )
-    {
-        p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
-    }
-
-    return VLC_SUCCESS;
-}
-
-static int EqualizerCallback( vlc_object_t *p_this, char const *psz_cmd,
-                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
-{
-    aout_instance_t *p_aout = (aout_instance_t *)p_this;
-    char *psz_mode = newval.psz_string;
-    vlc_value_t val;
-    int i;
-    int i_ret;
-
-    if( !psz_mode || !*psz_mode )
-    {
-        i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
-                                     VLC_FALSE );
-    }
-    else
-    {
-        val.psz_string = psz_mode;
-        var_Create( p_aout, "equalizer-preset", VLC_VAR_STRING );
-        var_Set( p_aout, "equalizer-preset", val );
-        i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer",
-                                     VLC_TRUE );
-
-    }
-
-    /* That sucks */
-    if( i_ret == 1 )
-    {
-        for( i = 0; i < p_aout->i_nb_inputs; i++ )
-        {
-            p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
-        }
-    }
-
-    return VLC_SUCCESS;
-}
diff --git a/src/control/control_input.c b/src/control/control_input.c
new file mode 100644 (file)
index 0000000..7a27b13
--- /dev/null
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * input.c: Libvlc new API input management functions
+ *****************************************************************************
+ * Copyright (C) 2005 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *
+ * This program 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include <libvlc_internal.h>
+#include <vlc/libvlc.h>
+
+#include <vlc/intf.h>
+
+void libvlc_input_free( libvlc_input_t *p_input )
+{
+    if( p_input )
+        free( p_input );
+}
+
+/**************************************************************************
+ * Getters for stream information
+ **************************************************************************/
+vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
+                             libvlc_exception_t *p_exception )
+{
+    input_thread_t *p_input_thread;
+    vlc_value_t val;
+
+    if( !p_input )
+    {
+        libvlc_exception_raise( p_exception, "Input is NULL" );
+        return -1;
+    }
+
+    p_input_thread = (input_thread_t*)vlc_object_get(
+                                 p_input->p_instance->p_vlc,
+                                 p_input->i_input_id );
+    if( !p_input_thread )
+    {
+        libvlc_exception_raise( p_exception, "Input does not exist" );
+        return -1;
+    }
+    var_Get( p_input_thread, "length", &val );
+    vlc_object_release( p_input_thread );
+
+    return val.i_time / 1000;
+}
+
+vlc_int64_t libvlc_input_get_time( libvlc_input_t *p_input,
+                           libvlc_exception_t *p_exception )
+{
+    input_thread_t *p_input_thread;
+    vlc_value_t val;
+
+    if( !p_input )
+    {
+        libvlc_exception_raise( p_exception, "Input is NULL" );
+        return -1;
+    }
+
+    p_input_thread = (input_thread_t*)vlc_object_get(
+                                 p_input->p_instance->p_vlc,
+                                 p_input->i_input_id );
+    if( !p_input_thread )
+    {
+        libvlc_exception_raise( p_exception, "Input does not exist" );
+        return -1;
+    }
+    var_Get( p_input_thread , "time", &val );
+    vlc_object_release( p_input_thread );
+
+    return val.i_time / 1000;
+}
+
+float libvlc_input_get_position( libvlc_input_t *p_input,
+                                 libvlc_exception_t *p_exception )
+{
+    input_thread_t *p_input_thread;
+    vlc_value_t val;
+
+    if( !p_input )
+    {
+        libvlc_exception_raise( p_exception, "Input is NULL" );
+        return -1;
+    }
+
+    p_input_thread = (input_thread_t*)vlc_object_get(
+                            p_input->p_instance->p_vlc,
+                            p_input->i_input_id );
+    if( !p_input_thread )
+    {
+        libvlc_exception_raise( p_exception, "Input does not exist" );
+        return -1.0;
+    }
+    var_Get( p_input_thread, "position", &val );
+    vlc_object_release( p_input_thread );
+
+    return val.f_float;
+}
diff --git a/src/control/control_playlist.c b/src/control/control_playlist.c
new file mode 100644 (file)
index 0000000..ffdb55e
--- /dev/null
@@ -0,0 +1,169 @@
+/*****************************************************************************
+ * playlist.c: libvlc new API playlist handling functions
+ *****************************************************************************
+ * Copyright (C) 2005 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *
+ * This program 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include <libvlc_internal.h>
+#include <vlc/libvlc.h>
+
+#include <vlc/intf.h>
+
+void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
+                           int i_options, char **ppsz_options,
+                           libvlc_exception_t *p_exception )
+{
+    ///\todo Handle additionnal options
+
+    if( p_instance->p_playlist->i_size == 0 )
+    {
+        libvlc_exception_raise( p_exception, "Empty playlist" );
+        return;
+    }
+    if( i_id > 0 )
+    {
+        /* Always use the current view when using libvlc */
+        playlist_view_t *p_view;
+        playlist_item_t *p_item;
+
+        if( p_instance->p_playlist->status.i_view == -1 )
+        {
+            playlist_Control( p_instance->p_playlist, PLAYLIST_GOTO,
+                              i_id );
+        }
+        p_view = playlist_ViewFind( p_instance->p_playlist,
+                                    p_instance->p_playlist->status.i_view );
+        if( !p_view )
+        {
+             libvlc_exception_raise( p_exception,
+                                     "Unable to find current playlist view ");
+             return;
+        }
+
+        p_item = playlist_ItemGetById( p_instance->p_playlist, i_id );
+
+        if( !p_item )
+        {
+            libvlc_exception_raise( p_exception, "Unable to find item " );
+            return;
+        }
+
+        playlist_Control( p_instance->p_playlist, PLAYLIST_VIEWPLAY,
+                          p_instance->p_playlist->status.i_view,
+                          p_view->p_root, p_item );
+    }
+    else
+    {
+        playlist_Play( p_instance->p_playlist );
+    }
+}
+
+void libvlc_playlist_stop( libvlc_instance_t *p_instance,
+                           libvlc_exception_t *p_exception )
+{
+    if( playlist_Stop( p_instance->p_playlist ) != VLC_SUCCESS )
+    {
+        libvlc_exception_raise( p_exception, "Empty playlist" );
+    }
+}
+
+void libvlc_playlist_clear( libvlc_instance_t *p_instance,
+                           libvlc_exception_t *p_exception )
+{
+    playlist_Clear( p_instance->p_playlist );
+}
+
+void libvlc_playlist_next( libvlc_instance_t *p_instance,
+                           libvlc_exception_t *p_exception )
+{
+    if( playlist_Next( p_instance->p_playlist ) != VLC_SUCCESS )
+    {
+        libvlc_exception_raise( p_exception, "Empty playlist" );
+    }
+}
+
+void libvlc_playlist_prev( libvlc_instance_t *p_instance,
+                           libvlc_exception_t *p_exception )
+{
+    if( playlist_Prev( p_instance->p_playlist ) != VLC_SUCCESS )
+    {
+        libvlc_exception_raise( p_exception, "Empty playlist" );
+    }
+}
+
+int libvlc_playlist_add( libvlc_instance_t *p_instance, const char *psz_uri,
+                         const char *psz_name, libvlc_exception_t *p_exception )
+{
+    return libvlc_playlist_add_extended( p_instance, psz_uri, psz_name,
+                                         0, NULL, p_exception );
+}
+
+int libvlc_playlist_add_extended( libvlc_instance_t *p_instance,
+                                  const char *psz_uri, const char *psz_name,
+                                  int i_options, const char **ppsz_options,
+                                  libvlc_exception_t *p_exception )
+{
+    return playlist_AddExt( p_instance->p_playlist, psz_uri, psz_name,
+                            PLAYLIST_INSERT, PLAYLIST_END, -1, ppsz_options,
+                            i_options );
+}
+
+int libvlc_playlist_isplaying( libvlc_instance_t *p_instance,
+                               libvlc_exception_t *p_exception )
+{
+    if( !p_instance->p_playlist )
+    {
+        libvlc_exception_raise( p_exception, "No playlist" );
+        return 0;
+    }
+    return playlist_IsPlaying( p_instance->p_playlist );
+}
+
+int libvlc_playlist_items_count( libvlc_instance_t *p_instance,
+                                 libvlc_exception_t *p_exception )
+{
+    if( !p_instance->p_playlist )
+    {
+        libvlc_exception_raise( p_exception, "No playlist" );
+        return 0;
+    }
+    return p_instance->p_playlist->i_size;
+}
+
+libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
+                                            libvlc_exception_t *p_exception )
+{
+    libvlc_input_t *p_input;
+
+    vlc_mutex_lock( &p_instance->p_playlist->object_lock );
+    if( p_instance->p_playlist->p_input == NULL )
+    {
+        libvlc_exception_raise( p_exception, "No active input" );
+        vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
+        return NULL;
+    }
+    p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
+
+    p_input->i_input_id = p_instance->p_playlist->p_input->i_object_id;
+    p_input->p_instance = p_instance;
+    vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
+
+    return p_input;
+}
diff --git a/src/control/control_vlm.c b/src/control/control_vlm.c
new file mode 100644 (file)
index 0000000..c4e3069
--- /dev/null
@@ -0,0 +1,230 @@
+/*****************************************************************************
+ * vlm.c: libvlc new API VLM handling functions
+ *****************************************************************************
+ * Copyright (C) 2005 the VideoLAN team
+ * $Id: playlist.c 14265 2006-02-12 17:31:39Z zorglub $
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *
+ * This program 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include <libvlc_internal.h>
+#include <vlc/libvlc.h>
+
+#include <vlc/vlc.h>
+#include <vlc_input.h>
+#include <vlc_vlm.h>
+
+void InitVLM( libvlc_instance_t *p_instance )
+{
+#ifdef ENABLE_VLM
+    if( p_instance->p_vlm ) return;
+    p_instance->p_vlm = vlm_New( p_instance->p_vlc );
+#else
+    p_instance->p_vlm = NULL;
+#endif
+}
+
+#define CHECK_VLM { if( !p_instance->p_vlm ) InitVLM( p_instance ); \
+                    if( !p_instance->p_vlm ) {\
+                  libvlc_exception_raise( p_exception, \
+                  "Unable to create VLM. It might be disabled." ); return; } }
+
+#define GET_MEDIA { p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name );\
+                   if( !p_media ) \
+                   { \
+                        libvlc_exception_raise( p_exception, \
+                                                "Media %s does not exist", \
+                                                psz_name ); return; } }
+
+void libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance, char *psz_name,
+                               char *psz_input, char *psz_output,
+                               int i_options, char **ppsz_options,
+                               int b_enabled, int b_loop,
+                               libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    CHECK_VLM;
+
+    p_media = vlm_MediaNew( p_instance->p_vlm, psz_name, BROADCAST_TYPE );
+    if( !p_media )
+    {
+        libvlc_exception_raise( p_exception, "Media %s creation failed",
+                                psz_name );
+        return;
+    }
+    libvlc_vlm_change_media( p_instance, psz_name, psz_input, psz_output,
+                             i_options, ppsz_options, b_enabled, b_loop,
+                             p_exception );
+
+}
+
+void libvlc_vlm_del_media( libvlc_instance_t *p_instance, char *psz_name,
+                           libvlc_exception_t *p_exception )
+{
+    char *psz_message;
+    vlm_message_t *answer;
+    CHECK_VLM;
+#ifdef ENABLE_VLM
+    asprintf( &psz_message, "del %s", psz_name );
+    vlm_ExecuteCommand( p_instance->p_vlm, psz_message, &answer );
+    if( answer->psz_value )
+    {
+        libvlc_exception_raise( p_exception, "Unable to delete %s",
+                                psz_name );
+    }
+    free( psz_message);
+#endif
+}
+
+void libvlc_vlm_set_enabled( libvlc_instance_t *p_instance, char *psz_name,
+                             int b_enabled, libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    CHECK_VLM;
+#ifdef ENABLE_VLM
+    GET_MEDIA;
+    if( b_enabled != 0 ) b_enabled = 1;
+    p_media->b_enabled = b_enabled;
+#endif
+}
+
+void libvlc_vlm_set_loop( libvlc_instance_t *p_instance, char *psz_name,
+                          int b_loop, libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    CHECK_VLM;
+#ifdef ENABLE_VLM
+    GET_MEDIA;
+    if( b_loop != 0 ) b_loop = 1;
+    p_media->b_loop = b_loop;
+#endif
+}
+
+void libvlc_vlm_set_output( libvlc_instance_t *p_instance, char *psz_name,
+                            char *psz_output,  libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    int i_ret;
+    CHECK_VLM;
+#ifdef ENABLE_VLM
+    GET_MEDIA;
+
+    vlc_mutex_lock( &p_instance->p_vlm->lock );
+    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output );
+    if( i_ret )
+    {
+         libvlc_exception_raise( p_exception, "Unable to set output" );
+         vlc_mutex_unlock( &p_instance->p_vlm->lock );return;
+    }
+    vlc_mutex_unlock( &p_instance->p_vlm->lock );
+#endif
+}
+
+void libvlc_vlm_set_input( libvlc_instance_t *p_instance, char *psz_name,
+                           char *psz_input,  libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    int i_ret;
+    CHECK_VLM;
+#ifdef ENABLE_VLM
+    vlc_mutex_lock( &p_instance->p_vlm->lock );
+    GET_MEDIA;
+
+    vlm_MediaSetup( p_instance->p_vlm, p_media, "inputdel", "all" );
+    if( i_ret )
+    {
+         libvlc_exception_raise( p_exception, "Unable to change input" );
+         vlc_mutex_unlock( &p_instance->p_vlm->lock );return;
+    }
+    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input );
+    if( i_ret )
+    {
+        libvlc_exception_raise( p_exception, "Unable to change input" );
+        vlc_mutex_unlock( &p_instance->p_vlm->lock );return;
+    }
+    vlc_mutex_unlock( &p_instance->p_vlm->lock );
+#endif
+}
+
+void libvlc_vlm_add_input( libvlc_instance_t *p_instance, char *psz_name,
+                           char *psz_input,  libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    int i_ret;
+    CHECK_VLM;
+#ifdef ENABLE_VLM
+    vlc_mutex_lock( &p_instance->p_vlm->lock );
+    GET_MEDIA;
+
+    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input );
+    if( i_ret )
+    {
+         libvlc_exception_raise( p_exception, "Unable to change input" );
+         vlc_mutex_unlock( &p_instance->p_vlm->lock ); return;
+    }
+
+    vlc_mutex_unlock( &p_instance->p_vlm->lock );
+#endif
+}
+
+
+void libvlc_vlm_change_media( libvlc_instance_t *p_instance, char *psz_name,
+                              char *psz_input, char *psz_output, int i_options,
+                              char **ppsz_options, int b_enabled, int b_loop,
+                              libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    int i_ret;
+    CHECK_VLM;
+#ifdef ENABLE_VLM
+    vlc_mutex_lock( &p_instance->p_vlm->lock );
+    GET_MEDIA;
+    if( b_enabled != 0 ) b_enabled = 1;
+    if( b_loop != 0 ) b_loop = 1;
+
+    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output );
+    if( i_ret )
+    {
+        libvlc_exception_raise( p_exception, "Unable to set output" );
+        vlc_mutex_unlock( &p_instance->p_vlm->lock );
+        return;
+    }
+    p_media->b_enabled = b_enabled;
+    p_media->b_loop = b_loop;
+
+    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output );
+    if( i_ret )
+    {
+        libvlc_exception_raise( p_exception, "Unable to set output" );
+        vlc_mutex_unlock( &p_instance->p_vlm->lock ); return;
+    }
+    vlm_MediaSetup( p_instance->p_vlm, p_media, "inputdel", "all" );
+    if( i_ret )
+    {
+        libvlc_exception_raise( p_exception, "Unable to change input" );
+        vlc_mutex_unlock( &p_instance->p_vlm->lock ); return;
+    }
+    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input );
+    if( i_ret )
+    {
+        libvlc_exception_raise( p_exception, "Unable to change input" );
+        vlc_mutex_unlock( &p_instance->p_vlm->lock );return;
+    }
+
+    vlc_mutex_unlock( &p_instance->p_vlm->lock );
+#endif
+}
diff --git a/src/control/input.c b/src/control/input.c
deleted file mode 100644 (file)
index 7a27b13..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*****************************************************************************
- * input.c: Libvlc new API input management functions
- *****************************************************************************
- * Copyright (C) 2005 the VideoLAN team
- * $Id$
- *
- * Authors: Clément Stenac <zorglub@videolan.org>
- *
- * This program 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#include <libvlc_internal.h>
-#include <vlc/libvlc.h>
-
-#include <vlc/intf.h>
-
-void libvlc_input_free( libvlc_input_t *p_input )
-{
-    if( p_input )
-        free( p_input );
-}
-
-/**************************************************************************
- * Getters for stream information
- **************************************************************************/
-vlc_int64_t libvlc_input_get_length( libvlc_input_t *p_input,
-                             libvlc_exception_t *p_exception )
-{
-    input_thread_t *p_input_thread;
-    vlc_value_t val;
-
-    if( !p_input )
-    {
-        libvlc_exception_raise( p_exception, "Input is NULL" );
-        return -1;
-    }
-
-    p_input_thread = (input_thread_t*)vlc_object_get(
-                                 p_input->p_instance->p_vlc,
-                                 p_input->i_input_id );
-    if( !p_input_thread )
-    {
-        libvlc_exception_raise( p_exception, "Input does not exist" );
-        return -1;
-    }
-    var_Get( p_input_thread, "length", &val );
-    vlc_object_release( p_input_thread );
-
-    return val.i_time / 1000;
-}
-
-vlc_int64_t libvlc_input_get_time( libvlc_input_t *p_input,
-                           libvlc_exception_t *p_exception )
-{
-    input_thread_t *p_input_thread;
-    vlc_value_t val;
-
-    if( !p_input )
-    {
-        libvlc_exception_raise( p_exception, "Input is NULL" );
-        return -1;
-    }
-
-    p_input_thread = (input_thread_t*)vlc_object_get(
-                                 p_input->p_instance->p_vlc,
-                                 p_input->i_input_id );
-    if( !p_input_thread )
-    {
-        libvlc_exception_raise( p_exception, "Input does not exist" );
-        return -1;
-    }
-    var_Get( p_input_thread , "time", &val );
-    vlc_object_release( p_input_thread );
-
-    return val.i_time / 1000;
-}
-
-float libvlc_input_get_position( libvlc_input_t *p_input,
-                                 libvlc_exception_t *p_exception )
-{
-    input_thread_t *p_input_thread;
-    vlc_value_t val;
-
-    if( !p_input )
-    {
-        libvlc_exception_raise( p_exception, "Input is NULL" );
-        return -1;
-    }
-
-    p_input_thread = (input_thread_t*)vlc_object_get(
-                            p_input->p_instance->p_vlc,
-                            p_input->i_input_id );
-    if( !p_input_thread )
-    {
-        libvlc_exception_raise( p_exception, "Input does not exist" );
-        return -1.0;
-    }
-    var_Get( p_input_thread, "position", &val );
-    vlc_object_release( p_input_thread );
-
-    return val.f_float;
-}
diff --git a/src/control/playlist.c b/src/control/playlist.c
deleted file mode 100644 (file)
index ffdb55e..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*****************************************************************************
- * playlist.c: libvlc new API playlist handling functions
- *****************************************************************************
- * Copyright (C) 2005 the VideoLAN team
- * $Id$
- *
- * Authors: Clément Stenac <zorglub@videolan.org>
- *
- * This program 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#include <libvlc_internal.h>
-#include <vlc/libvlc.h>
-
-#include <vlc/intf.h>
-
-void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
-                           int i_options, char **ppsz_options,
-                           libvlc_exception_t *p_exception )
-{
-    ///\todo Handle additionnal options
-
-    if( p_instance->p_playlist->i_size == 0 )
-    {
-        libvlc_exception_raise( p_exception, "Empty playlist" );
-        return;
-    }
-    if( i_id > 0 )
-    {
-        /* Always use the current view when using libvlc */
-        playlist_view_t *p_view;
-        playlist_item_t *p_item;
-
-        if( p_instance->p_playlist->status.i_view == -1 )
-        {
-            playlist_Control( p_instance->p_playlist, PLAYLIST_GOTO,
-                              i_id );
-        }
-        p_view = playlist_ViewFind( p_instance->p_playlist,
-                                    p_instance->p_playlist->status.i_view );
-        if( !p_view )
-        {
-             libvlc_exception_raise( p_exception,
-                                     "Unable to find current playlist view ");
-             return;
-        }
-
-        p_item = playlist_ItemGetById( p_instance->p_playlist, i_id );
-
-        if( !p_item )
-        {
-            libvlc_exception_raise( p_exception, "Unable to find item " );
-            return;
-        }
-
-        playlist_Control( p_instance->p_playlist, PLAYLIST_VIEWPLAY,
-                          p_instance->p_playlist->status.i_view,
-                          p_view->p_root, p_item );
-    }
-    else
-    {
-        playlist_Play( p_instance->p_playlist );
-    }
-}
-
-void libvlc_playlist_stop( libvlc_instance_t *p_instance,
-                           libvlc_exception_t *p_exception )
-{
-    if( playlist_Stop( p_instance->p_playlist ) != VLC_SUCCESS )
-    {
-        libvlc_exception_raise( p_exception, "Empty playlist" );
-    }
-}
-
-void libvlc_playlist_clear( libvlc_instance_t *p_instance,
-                           libvlc_exception_t *p_exception )
-{
-    playlist_Clear( p_instance->p_playlist );
-}
-
-void libvlc_playlist_next( libvlc_instance_t *p_instance,
-                           libvlc_exception_t *p_exception )
-{
-    if( playlist_Next( p_instance->p_playlist ) != VLC_SUCCESS )
-    {
-        libvlc_exception_raise( p_exception, "Empty playlist" );
-    }
-}
-
-void libvlc_playlist_prev( libvlc_instance_t *p_instance,
-                           libvlc_exception_t *p_exception )
-{
-    if( playlist_Prev( p_instance->p_playlist ) != VLC_SUCCESS )
-    {
-        libvlc_exception_raise( p_exception, "Empty playlist" );
-    }
-}
-
-int libvlc_playlist_add( libvlc_instance_t *p_instance, const char *psz_uri,
-                         const char *psz_name, libvlc_exception_t *p_exception )
-{
-    return libvlc_playlist_add_extended( p_instance, psz_uri, psz_name,
-                                         0, NULL, p_exception );
-}
-
-int libvlc_playlist_add_extended( libvlc_instance_t *p_instance,
-                                  const char *psz_uri, const char *psz_name,
-                                  int i_options, const char **ppsz_options,
-                                  libvlc_exception_t *p_exception )
-{
-    return playlist_AddExt( p_instance->p_playlist, psz_uri, psz_name,
-                            PLAYLIST_INSERT, PLAYLIST_END, -1, ppsz_options,
-                            i_options );
-}
-
-int libvlc_playlist_isplaying( libvlc_instance_t *p_instance,
-                               libvlc_exception_t *p_exception )
-{
-    if( !p_instance->p_playlist )
-    {
-        libvlc_exception_raise( p_exception, "No playlist" );
-        return 0;
-    }
-    return playlist_IsPlaying( p_instance->p_playlist );
-}
-
-int libvlc_playlist_items_count( libvlc_instance_t *p_instance,
-                                 libvlc_exception_t *p_exception )
-{
-    if( !p_instance->p_playlist )
-    {
-        libvlc_exception_raise( p_exception, "No playlist" );
-        return 0;
-    }
-    return p_instance->p_playlist->i_size;
-}
-
-libvlc_input_t * libvlc_playlist_get_input( libvlc_instance_t *p_instance,
-                                            libvlc_exception_t *p_exception )
-{
-    libvlc_input_t *p_input;
-
-    vlc_mutex_lock( &p_instance->p_playlist->object_lock );
-    if( p_instance->p_playlist->p_input == NULL )
-    {
-        libvlc_exception_raise( p_exception, "No active input" );
-        vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
-        return NULL;
-    }
-    p_input = (libvlc_input_t *)malloc( sizeof( libvlc_input_t ) );
-
-    p_input->i_input_id = p_instance->p_playlist->p_input->i_object_id;
-    p_input->p_instance = p_instance;
-    vlc_mutex_unlock( &p_instance->p_playlist->object_lock );
-
-    return p_input;
-}
diff --git a/src/control/vlm.c b/src/control/vlm.c
deleted file mode 100644 (file)
index c4e3069..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*****************************************************************************
- * vlm.c: libvlc new API VLM handling functions
- *****************************************************************************
- * Copyright (C) 2005 the VideoLAN team
- * $Id: playlist.c 14265 2006-02-12 17:31:39Z zorglub $
- *
- * Authors: Clément Stenac <zorglub@videolan.org>
- *
- * This program 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#include <libvlc_internal.h>
-#include <vlc/libvlc.h>
-
-#include <vlc/vlc.h>
-#include <vlc_input.h>
-#include <vlc_vlm.h>
-
-void InitVLM( libvlc_instance_t *p_instance )
-{
-#ifdef ENABLE_VLM
-    if( p_instance->p_vlm ) return;
-    p_instance->p_vlm = vlm_New( p_instance->p_vlc );
-#else
-    p_instance->p_vlm = NULL;
-#endif
-}
-
-#define CHECK_VLM { if( !p_instance->p_vlm ) InitVLM( p_instance ); \
-                    if( !p_instance->p_vlm ) {\
-                  libvlc_exception_raise( p_exception, \
-                  "Unable to create VLM. It might be disabled." ); return; } }
-
-#define GET_MEDIA { p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name );\
-                   if( !p_media ) \
-                   { \
-                        libvlc_exception_raise( p_exception, \
-                                                "Media %s does not exist", \
-                                                psz_name ); return; } }
-
-void libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance, char *psz_name,
-                               char *psz_input, char *psz_output,
-                               int i_options, char **ppsz_options,
-                               int b_enabled, int b_loop,
-                               libvlc_exception_t *p_exception )
-{
-    vlm_media_t *p_media;
-    CHECK_VLM;
-
-    p_media = vlm_MediaNew( p_instance->p_vlm, psz_name, BROADCAST_TYPE );
-    if( !p_media )
-    {
-        libvlc_exception_raise( p_exception, "Media %s creation failed",
-                                psz_name );
-        return;
-    }
-    libvlc_vlm_change_media( p_instance, psz_name, psz_input, psz_output,
-                             i_options, ppsz_options, b_enabled, b_loop,
-                             p_exception );
-
-}
-
-void libvlc_vlm_del_media( libvlc_instance_t *p_instance, char *psz_name,
-                           libvlc_exception_t *p_exception )
-{
-    char *psz_message;
-    vlm_message_t *answer;
-    CHECK_VLM;
-#ifdef ENABLE_VLM
-    asprintf( &psz_message, "del %s", psz_name );
-    vlm_ExecuteCommand( p_instance->p_vlm, psz_message, &answer );
-    if( answer->psz_value )
-    {
-        libvlc_exception_raise( p_exception, "Unable to delete %s",
-                                psz_name );
-    }
-    free( psz_message);
-#endif
-}
-
-void libvlc_vlm_set_enabled( libvlc_instance_t *p_instance, char *psz_name,
-                             int b_enabled, libvlc_exception_t *p_exception )
-{
-    vlm_media_t *p_media;
-    CHECK_VLM;
-#ifdef ENABLE_VLM
-    GET_MEDIA;
-    if( b_enabled != 0 ) b_enabled = 1;
-    p_media->b_enabled = b_enabled;
-#endif
-}
-
-void libvlc_vlm_set_loop( libvlc_instance_t *p_instance, char *psz_name,
-                          int b_loop, libvlc_exception_t *p_exception )
-{
-    vlm_media_t *p_media;
-    CHECK_VLM;
-#ifdef ENABLE_VLM
-    GET_MEDIA;
-    if( b_loop != 0 ) b_loop = 1;
-    p_media->b_loop = b_loop;
-#endif
-}
-
-void libvlc_vlm_set_output( libvlc_instance_t *p_instance, char *psz_name,
-                            char *psz_output,  libvlc_exception_t *p_exception )
-{
-    vlm_media_t *p_media;
-    int i_ret;
-    CHECK_VLM;
-#ifdef ENABLE_VLM
-    GET_MEDIA;
-
-    vlc_mutex_lock( &p_instance->p_vlm->lock );
-    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output );
-    if( i_ret )
-    {
-         libvlc_exception_raise( p_exception, "Unable to set output" );
-         vlc_mutex_unlock( &p_instance->p_vlm->lock );return;
-    }
-    vlc_mutex_unlock( &p_instance->p_vlm->lock );
-#endif
-}
-
-void libvlc_vlm_set_input( libvlc_instance_t *p_instance, char *psz_name,
-                           char *psz_input,  libvlc_exception_t *p_exception )
-{
-    vlm_media_t *p_media;
-    int i_ret;
-    CHECK_VLM;
-#ifdef ENABLE_VLM
-    vlc_mutex_lock( &p_instance->p_vlm->lock );
-    GET_MEDIA;
-
-    vlm_MediaSetup( p_instance->p_vlm, p_media, "inputdel", "all" );
-    if( i_ret )
-    {
-         libvlc_exception_raise( p_exception, "Unable to change input" );
-         vlc_mutex_unlock( &p_instance->p_vlm->lock );return;
-    }
-    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input );
-    if( i_ret )
-    {
-        libvlc_exception_raise( p_exception, "Unable to change input" );
-        vlc_mutex_unlock( &p_instance->p_vlm->lock );return;
-    }
-    vlc_mutex_unlock( &p_instance->p_vlm->lock );
-#endif
-}
-
-void libvlc_vlm_add_input( libvlc_instance_t *p_instance, char *psz_name,
-                           char *psz_input,  libvlc_exception_t *p_exception )
-{
-    vlm_media_t *p_media;
-    int i_ret;
-    CHECK_VLM;
-#ifdef ENABLE_VLM
-    vlc_mutex_lock( &p_instance->p_vlm->lock );
-    GET_MEDIA;
-
-    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input );
-    if( i_ret )
-    {
-         libvlc_exception_raise( p_exception, "Unable to change input" );
-         vlc_mutex_unlock( &p_instance->p_vlm->lock ); return;
-    }
-
-    vlc_mutex_unlock( &p_instance->p_vlm->lock );
-#endif
-}
-
-
-void libvlc_vlm_change_media( libvlc_instance_t *p_instance, char *psz_name,
-                              char *psz_input, char *psz_output, int i_options,
-                              char **ppsz_options, int b_enabled, int b_loop,
-                              libvlc_exception_t *p_exception )
-{
-    vlm_media_t *p_media;
-    int i_ret;
-    CHECK_VLM;
-#ifdef ENABLE_VLM
-    vlc_mutex_lock( &p_instance->p_vlm->lock );
-    GET_MEDIA;
-    if( b_enabled != 0 ) b_enabled = 1;
-    if( b_loop != 0 ) b_loop = 1;
-
-    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output );
-    if( i_ret )
-    {
-        libvlc_exception_raise( p_exception, "Unable to set output" );
-        vlc_mutex_unlock( &p_instance->p_vlm->lock );
-        return;
-    }
-    p_media->b_enabled = b_enabled;
-    p_media->b_loop = b_loop;
-
-    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output );
-    if( i_ret )
-    {
-        libvlc_exception_raise( p_exception, "Unable to set output" );
-        vlc_mutex_unlock( &p_instance->p_vlm->lock ); return;
-    }
-    vlm_MediaSetup( p_instance->p_vlm, p_media, "inputdel", "all" );
-    if( i_ret )
-    {
-        libvlc_exception_raise( p_exception, "Unable to change input" );
-        vlc_mutex_unlock( &p_instance->p_vlm->lock ); return;
-    }
-    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input );
-    if( i_ret )
-    {
-        libvlc_exception_raise( p_exception, "Unable to change input" );
-        vlc_mutex_unlock( &p_instance->p_vlm->lock );return;
-    }
-
-    vlc_mutex_unlock( &p_instance->p_vlm->lock );
-#endif
-}
diff --git a/toolbox b/toolbox
index e8e848d..fd7bbe6 100755 (executable)
--- a/toolbox
+++ b/toolbox
@@ -552,7 +552,7 @@ then
   if test -z "${builddir}"; then
     builddir="`sed -ne 's/^top_builddir *= *//p' < Makefile`"
   fi
-  BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' vlc-config`
+  BUILTINS=`sed -ne 's/.*builtins *= *" *\([^"]*\)".*/\1/p' ${builddir}/vlc-config`
 
   file="${builddir}/src/misc/modules_builtin.h"