diff options
-rw-r--r-- | AUTHORS | 3 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/liblpcm/Makefile.am | 50 | ||||
-rw-r--r-- | src/liblpcm/xine_decoder.c | 136 |
5 files changed, 191 insertions, 1 deletions
@@ -110,6 +110,9 @@ Contributions Bill Fink <billfink@capu.net> powerpc patches + Gert Vervoort <Gert.Vervoort@wxs.nl> + LPCM audio decoder plugin + (let us know if we've forgotten anyone) diff --git a/configure.in b/configure.in index bb4e3c2c4..c21d9738d 100644 --- a/configure.in +++ b/configure.in @@ -571,6 +571,7 @@ src/demuxers/Makefile src/dxr3/Makefile src/libmpeg2/Makefile src/libac3/Makefile +src/liblpcm/Makefile src/libmpg123/Makefile src/libw32dll/Makefile src/libw32dll/wine/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index e3d17ac45..c452cb82c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ SUBDIRS = audio_out video_out dxr3 input libmpeg2 libspudec demuxers \ - libac3 libmpg123 libw32dll xine-engine + libac3 libmpg123 liblpcm libw32dll xine-engine debug: @list='$(SUBDIRS)'; for subdir in $$list; do \ diff --git a/src/liblpcm/Makefile.am b/src/liblpcm/Makefile.am new file mode 100644 index 000000000..a382669f2 --- /dev/null +++ b/src/liblpcm/Makefile.am @@ -0,0 +1,50 @@ +CFLAGS = @GLOBAL_CFLAGS@ + +LIBTOOL = $(SHELL) $(top_builddir)/libtool-nofpic + +libdir = $(XINE_PLUGINDIR) + +lib_LTLIBRARIES = xineplug_decode_lpcm.la + +xineplug_decode_lpcm_la_SOURCES = xine_decoder.c +xineplug_decode_lpcm_la_LDFLAGS = -avoid-version -module + +noinst_HEADERS = + + +## +## Install header files (default=$includedir/xine) +## +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(includedir)/xine + @list='$(include_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/xine/$$p"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/xine/$$p; \ + done + + +## +## Remove them +## +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + list='$(include_HEADERS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(includedir)/xine/$$p; \ + done + + +debug: + @$(MAKE) CFLAGS="$(DEBUG_CFLAGS)" + +install-debug: debug + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +mostlyclean-generic: + -rm -f *~ \#* .*~ .\#* + +maintainer-clean-generic: + -@echo "This command is intended for maintainers to use;" + -@echo "it deletes files that may require special tools to rebuild." + -rm -f Makefile.in diff --git a/src/liblpcm/xine_decoder.c b/src/liblpcm/xine_decoder.c new file mode 100644 index 000000000..59644f339 --- /dev/null +++ b/src/liblpcm/xine_decoder.c @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: xine_decoder.c,v 1.1 2001/08/04 20:14:54 guenter Exp $ + * + * stuff needed to turn libac3 into a xine decoder plugin + */ + + +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <netinet/in.h> /* ntohs */ + +#include "audio_out.h" +#include "buffer.h" +#include "xine_internal.h" + + +typedef struct lpcm_decoder_s { + audio_decoder_t audio_decoder; + + uint32_t pts; + uint32_t last_pts; + + ao_functions_t *audio_out; + int output_open; + +} lpcm_decoder_t; + +int lpcm_can_handle (audio_decoder_t *this_gen, int buf_type) { + return ((buf_type & 0xFFFF0000) == BUF_AUDIO_LPCM) ; +} + + +void lpcm_init (audio_decoder_t *this_gen, ao_functions_t *audio_out) { + + lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; + + this->audio_out = audio_out; + this->output_open = 0; + this->pts = 0; + this->last_pts = 0; +} + + +void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { + + lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; + int16_t *p=(int16_t *)buf->content; + int i; + + if (buf->decoder_info[0] == 0) + return; + + if (buf->PTS) + this->pts = buf->PTS; + + if (!this->output_open) { + this->output_open = (this->audio_out->open (this->audio_out, 16, + 48000, + AO_CAP_MODE_STEREO)); + } + + if (!this->output_open) + return; + + for(i=0; i<buf->size/2; i++) + p[i] = ntohs(p[i]); + + this->audio_out->write_audio_data (this->audio_out, + buf->content, + buf->size/4, + this->pts); + + +} + +void lpcm_close (audio_decoder_t *this_gen) { + + lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; + + if (this->output_open) + this->audio_out->close (this->audio_out); + + this->output_open = 0; +} + +static char *lpcm_get_id(void) { + return "lpcm"; +} + +audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *cfg) { + + lpcm_decoder_t *this ; + + if (iface_version != 2) { + printf( "liblpcm: plugin doesn't support plugin API version %d.\n" + "liblpcm: this means there's a version mismatch between xine and this " + "liblpcm: decoder plugin.\nInstalling current plugins should help.\n", + iface_version); + return NULL; + } + + this = (lpcm_decoder_t *) malloc (sizeof (lpcm_decoder_t)); + + this->audio_decoder.interface_version = 2; + this->audio_decoder.can_handle = lpcm_can_handle; + this->audio_decoder.init = lpcm_init; + this->audio_decoder.decode_data = lpcm_decode_data; + this->audio_decoder.close = lpcm_close; + this->audio_decoder.get_identifier = lpcm_get_id; + this->audio_decoder.priority = 1; + + return (audio_decoder_t *) this; +} + |