summaryrefslogtreecommitdiffstats
path: root/akode_artsplugin
diff options
context:
space:
mode:
Diffstat (limited to 'akode_artsplugin')
-rw-r--r--akode_artsplugin/Makefile.am46
-rw-r--r--akode_artsplugin/akodeFFMPEGPlayObject.mcopclass7
-rw-r--r--akode_artsplugin/akodeFFMPEGPlayObject_impl.cpp31
-rw-r--r--akode_artsplugin/akodeFFMPEGPlayObject_impl.h34
-rw-r--r--akode_artsplugin/akodeMPCPlayObject.mcopclass7
-rw-r--r--akode_artsplugin/akodeMPCPlayObject_impl.cpp31
-rw-r--r--akode_artsplugin/akodeMPCPlayObject_impl.h34
-rw-r--r--akode_artsplugin/akodeMPEGPlayObject.mcopclass7
-rw-r--r--akode_artsplugin/akodeMPEGPlayObject_impl.cpp31
-rw-r--r--akode_artsplugin/akodeMPEGPlayObject_impl.h34
-rw-r--r--akode_artsplugin/akodePlayObject.mcopclass7
-rw-r--r--akode_artsplugin/akodePlayObject_impl.cpp487
-rw-r--r--akode_artsplugin/akodePlayObject_impl.h98
-rw-r--r--akode_artsplugin/akodeSpeexStreamPlayObject.mcopclass7
-rw-r--r--akode_artsplugin/akodeSpeexStreamPlayObject_impl.cpp49
-rw-r--r--akode_artsplugin/akodeSpeexStreamPlayObject_impl.h39
-rw-r--r--akode_artsplugin/akodeVorbisStreamPlayObject.mcopclass7
-rw-r--r--akode_artsplugin/akodeVorbisStreamPlayObject_impl.cpp49
-rw-r--r--akode_artsplugin/akodeVorbisStreamPlayObject_impl.h39
-rw-r--r--akode_artsplugin/akodeXiphPlayObject.mcopclass7
-rw-r--r--akode_artsplugin/akodeXiphPlayObject_impl.cpp31
-rw-r--r--akode_artsplugin/akodeXiphPlayObject_impl.h34
-rw-r--r--akode_artsplugin/akodearts.idl30
-rw-r--r--akode_artsplugin/arts_inputstream.h152
-rw-r--r--akode_artsplugin/configure.in.in16
25 files changed, 1314 insertions, 0 deletions
diff --git a/akode_artsplugin/Makefile.am b/akode_artsplugin/Makefile.am
new file mode 100644
index 00000000..230a6a01
--- /dev/null
+++ b/akode_artsplugin/Makefile.am
@@ -0,0 +1,46 @@
+INCLUDES= $(akode_includes) -I$(kde_includes)/arts $(all_includes)
+
+noinst_HEADERS = akodePlayObject_impl.h
+
+lib_LTLIBRARIES = libarts_akode.la
+
+libarts_akode_la_SOURCES = akodearts.cc akodePlayObject_impl.cpp \
+ akodeMPCPlayObject_impl.cpp akodeMPEGPlayObject_impl.cpp \
+ akodeFFMPEGPlayObject_impl.cpp akodeXiphPlayObject_impl.cpp \
+ akodeVorbisStreamPlayObject_impl.cpp akodeSpeexStreamPlayObject_impl.cpp
+libarts_akode_la_LDFLAGS = $(all_libraries) -module -no-undefined
+libarts_akode_la_LIBADD = $(akode_libs) -lkmedia2_idl -lsoundserver_idl -lartsflow
+libarts_akode_la_METASOURCES = AUTO
+libarts_akode_la_COMPILE_FIRST = akodearts.h
+
+$(srcdir)/akodePlayObject_impl.cpp: akodearts.h
+akodearts.mcopclass: akodearts.h
+akodearts.mcoptype: akodearts.h
+akodearts.cc akodearts.h: $(srcdir)/akodearts.idl
+ $(MCOPIDL) -t $(INCLUDES) $(srcdir)/akodearts.idl
+
+mcoptypedir = $(libdir)/mcop
+mcoptype_DATA = akodearts.mcoptype akodearts.mcopclass
+
+if include_akode_mpeg
+AKODE_MPEG=akodeMPEGPlayObject.mcopclass
+endif
+
+if include_akode_mpc
+AKODE_MPC=akodeMPCPlayObject.mcopclass
+endif
+
+if include_akode_xiph
+AKODE_XIPH=akodeXiphPlayObject.mcopclass akodeVorbisStreamPlayObject.mcopclass akodeSpeexStreamPlayObject.mcopclass
+endif
+
+if include_akode_ffmpeg
+AKODE_FFMPEG=akodeFFMPEGPlayObject.mcopclass
+endif
+
+mcopclassdir = $(libdir)/mcop
+mcopclass_DATA = akodePlayObject.mcopclass \
+ $(AKODE_MPC) $(AKODE_MPEG) $(AKODE_XIPH) $(AKODE_FFMPEG)
+
+CLEANFILES=akodearts.h akodearts.cc akodearts.mcopclass akodearts.mcoptype
+
diff --git a/akode_artsplugin/akodeFFMPEGPlayObject.mcopclass b/akode_artsplugin/akodeFFMPEGPlayObject.mcopclass
new file mode 100644
index 00000000..09f24118
--- /dev/null
+++ b/akode_artsplugin/akodeFFMPEGPlayObject.mcopclass
@@ -0,0 +1,7 @@
+Interface=akodeFFMPEGPlayObject,Arts::PlayObject,Arts::StreamPlayObject,Arts::PitchablePlayObject,Arts::SynthModule,Arts::Object
+Library=libarts_akode.la
+Language=C++
+Author=Allan Sandfeld Jensen <kde@carewolf.com>
+Extension=wma,ra,m4a,ram,aac,ac3,ogg
+MimeType=audio/mp4,audio/vnd.rn-realaudio,audio/x-pn-realaudio,audio/x-ms-wma,application/vnd.ms-asf,audio/ac3,audio/aac,audio/mpeg,audio/x-mp3,audio/x-mp2,audio/x-mp1,audio/vorbis,audio/x-vorbis,application/ogg,video/x-ms-asf
+Preference=5
diff --git a/akode_artsplugin/akodeFFMPEGPlayObject_impl.cpp b/akode_artsplugin/akodeFFMPEGPlayObject_impl.cpp
new file mode 100644
index 00000000..803dff73
--- /dev/null
+++ b/akode_artsplugin/akodeFFMPEGPlayObject_impl.cpp
@@ -0,0 +1,31 @@
+/* akodeFFMPEGPlayObject
+
+ Copyright (C) 2005 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "akodeFFMPEGPlayObject_impl.h"
+
+akodeFFMPEGPlayObject_impl::akodeFFMPEGPlayObject_impl()
+ : akodeFFMPEGPlayObject_skel(), akodePlayObject_impl("ffmpeg")
+{
+}
+
+REGISTER_IMPLEMENTATION(akodeFFMPEGPlayObject_impl);
+
+
+
diff --git a/akode_artsplugin/akodeFFMPEGPlayObject_impl.h b/akode_artsplugin/akodeFFMPEGPlayObject_impl.h
new file mode 100644
index 00000000..65f04296
--- /dev/null
+++ b/akode_artsplugin/akodeFFMPEGPlayObject_impl.h
@@ -0,0 +1,34 @@
+/* akodeFFMPEGPlayObject
+
+ Copyright (C) 2005 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _AKODEFFMPEGPLAYOBJECT_IMPL_H
+#define _AKODEFFMPEGPLAYOBJECT_IMPL_H
+
+#include "akodePlayObject_impl.h"
+#include "akodearts.h"
+
+class akodeFFMPEGPlayObject_impl
+ : virtual public akodeFFMPEGPlayObject_skel, public akodePlayObject_impl
+{
+public:
+ akodeFFMPEGPlayObject_impl();
+};
+
+#endif
diff --git a/akode_artsplugin/akodeMPCPlayObject.mcopclass b/akode_artsplugin/akodeMPCPlayObject.mcopclass
new file mode 100644
index 00000000..2cd1fe31
--- /dev/null
+++ b/akode_artsplugin/akodeMPCPlayObject.mcopclass
@@ -0,0 +1,7 @@
+Interface=akodeMPCPlayObject,Arts::PlayObject,Arts::PitchablePlayObject,Arts::SynthModule,Arts::Object
+Library=libarts_akode.la
+Language=C++
+Author=Allan Sandfeld Jensen <kde@carewolf.com>
+Extension=mpc,mpp,mp+
+MimeType=audio/x-musepack
+Preference=4
diff --git a/akode_artsplugin/akodeMPCPlayObject_impl.cpp b/akode_artsplugin/akodeMPCPlayObject_impl.cpp
new file mode 100644
index 00000000..8de09236
--- /dev/null
+++ b/akode_artsplugin/akodeMPCPlayObject_impl.cpp
@@ -0,0 +1,31 @@
+/* akodeMPCPlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "akodeMPCPlayObject_impl.h"
+
+akodeMPCPlayObject_impl::akodeMPCPlayObject_impl()
+ : akodeMPCPlayObject_skel(), akodePlayObject_impl("mpc")
+{
+}
+
+REGISTER_IMPLEMENTATION(akodeMPCPlayObject_impl);
+
+
+
diff --git a/akode_artsplugin/akodeMPCPlayObject_impl.h b/akode_artsplugin/akodeMPCPlayObject_impl.h
new file mode 100644
index 00000000..59a9eef9
--- /dev/null
+++ b/akode_artsplugin/akodeMPCPlayObject_impl.h
@@ -0,0 +1,34 @@
+/* akodeMPCPlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _AKODEMPCPLAYOBJECT_IMPL_H
+#define _AKODEMPCPLAYOBJECT_IMPL_H
+
+#include "akodePlayObject_impl.h"
+#include "akodearts.h"
+
+class akodeMPCPlayObject_impl
+ : virtual public akodeMPCPlayObject_skel, public akodePlayObject_impl
+{
+public:
+ akodeMPCPlayObject_impl();
+};
+
+#endif
diff --git a/akode_artsplugin/akodeMPEGPlayObject.mcopclass b/akode_artsplugin/akodeMPEGPlayObject.mcopclass
new file mode 100644
index 00000000..4e326b5f
--- /dev/null
+++ b/akode_artsplugin/akodeMPEGPlayObject.mcopclass
@@ -0,0 +1,7 @@
+Interface=akodeMPEGPlayObject,Arts::PlayObject,Arts::StreamPlayObject,Arts::PitchablePlayObject,Arts::SynthModule,Arts::Object
+Library=libarts_akode.la
+Language=C++
+Author=Allan Sandfeld Jensen <kde@carewolf.com>
+Extension=mp1,mp2,mp3
+MimeType=audio/mpeg,audio/x-mp3,audio/x-mp2,audio/x-mp1
+Preference=7
diff --git a/akode_artsplugin/akodeMPEGPlayObject_impl.cpp b/akode_artsplugin/akodeMPEGPlayObject_impl.cpp
new file mode 100644
index 00000000..1516ffe5
--- /dev/null
+++ b/akode_artsplugin/akodeMPEGPlayObject_impl.cpp
@@ -0,0 +1,31 @@
+/* akodeMPEGPlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "akodeMPEGPlayObject_impl.h"
+
+akodeMPEGPlayObject_impl::akodeMPEGPlayObject_impl()
+ : akodeMPEGPlayObject_skel(), akodePlayObject_impl("mpeg")
+{
+}
+
+REGISTER_IMPLEMENTATION(akodeMPEGPlayObject_impl);
+
+
+
diff --git a/akode_artsplugin/akodeMPEGPlayObject_impl.h b/akode_artsplugin/akodeMPEGPlayObject_impl.h
new file mode 100644
index 00000000..4b8744d9
--- /dev/null
+++ b/akode_artsplugin/akodeMPEGPlayObject_impl.h
@@ -0,0 +1,34 @@
+/* akodeMPEGPlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _AKODEMPEGPLAYOBJECT_IMPL_H
+#define _AKODEMPEGPLAYOBJECT_IMPL_H
+
+#include "akodePlayObject_impl.h"
+#include "akodearts.h"
+
+class akodeMPEGPlayObject_impl
+ : virtual public akodeMPEGPlayObject_skel, public akodePlayObject_impl
+{
+public:
+ akodeMPEGPlayObject_impl();
+};
+
+#endif
diff --git a/akode_artsplugin/akodePlayObject.mcopclass b/akode_artsplugin/akodePlayObject.mcopclass
new file mode 100644
index 00000000..28674e8f
--- /dev/null
+++ b/akode_artsplugin/akodePlayObject.mcopclass
@@ -0,0 +1,7 @@
+Interface=akodePlayObject,Arts::PlayObject,Arts::PitchablePlayObject,Arts::SynthModule,Arts::Object
+Library=libarts_akode.la
+Language=C++
+Author=Allan Sandfeld Jensen <kde@carewolf.com>
+Extension=wav
+MimeType=audio/x-wav
+Preference=3
diff --git a/akode_artsplugin/akodePlayObject_impl.cpp b/akode_artsplugin/akodePlayObject_impl.cpp
new file mode 100644
index 00000000..78708e13
--- /dev/null
+++ b/akode_artsplugin/akodePlayObject_impl.cpp
@@ -0,0 +1,487 @@
+/* akodePlayObject
+
+ Copyright (C) 2003-2005 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+//#define AKODEARTS_SINGLETHREADED
+//#define AKODEARTS_SRCRESAMPLING
+#define AKODEARTS_FRAMEBUFFER 32
+// The instream-buffer must be smaller than 64kbytes (1<<16)
+#define AKODEARTS_INSTREAMBUFFER (1<<14)
+
+#include <math.h>
+
+#include <soundserver.h>
+#include <audiosubsys.h>
+#include <debug.h>
+
+#include "config.h"
+
+#include <akode/audioframe.h>
+#include <akode/localfile.h>
+#include <akode/mmapfile.h>
+#include <akode/decoder.h>
+#include <akode/resampler.h>
+#include <akode/fast_resampler.h>
+#include <akode/wav_decoder.h>
+
+#include "arts_inputstream.h"
+
+#ifndef AKODEARTS_SINGLETHREADED
+ #include <akode/buffered_decoder.h>
+#endif
+
+#ifdef AKODEARTS_SRCRESAMPLING
+#define AKODEARTS_RESAMPLER "src"
+#else
+#define AKODEARTS_RESAMPLER "fast"
+#endif
+
+
+#include "akodePlayObject_impl.h"
+
+using namespace Arts;
+using namespace aKode;
+
+akodePlayObject_impl::akodePlayObject_impl(const string &plugin)
+ : source(0)
+ , frameDecoder(0)
+ , decoder(0)
+ , bufferedDecoder(0)
+ , resampler(0)
+ , buffer(0)
+ , inBuffer(0)
+ , buf_pos(0)
+ , mState(posIdle)
+ , mSpeed(1.0)
+ , m_packetQueue(0)
+ , m_bytebuffer(0)
+ , m_fading(false)
+ , decoderPlugin(plugin)
+ , resamplerPlugin(AKODEARTS_RESAMPLER)
+{
+ m_packetQueue = new queue<DataPacket<mcopbyte>*>;
+ if(!resamplerPlugin.isLoaded())
+ resamplerPlugin.load("fast");
+}
+
+akodePlayObject_impl::~akodePlayObject_impl()
+{
+ delete m_packetQueue;
+
+ unload();
+}
+
+bool akodePlayObject_impl::loadPlugin(const string &plugin)
+{
+ return decoderPlugin.load(plugin);
+}
+
+bool akodePlayObject_impl::streamMedia(Arts::InputStream inputstream)
+{
+ arts_debug("akode: opening input-stream");
+ m_bytebuffer = new aKode::ByteBuffer(AKODEARTS_INSTREAMBUFFER);
+ instream = inputstream;
+
+ Arts::StreamPlayObject self = Arts::StreamPlayObject::_from_base(_copy());
+ connect(instream, "outdata", self, "indata");
+
+ source = new Arts_InputStream(instream, m_bytebuffer);
+ return loadSource();
+}
+
+bool akodePlayObject_impl::loadMedia(const string &filename)
+{
+ arts_debug("akode: opening %s", filename.c_str());
+ source = new MMapFile(filename.c_str());
+ if (!source->openRO()) {
+ delete source;
+ source = new LocalFile(filename.c_str());
+ if (!source->openRO()) {
+ delete source;
+ source = 0;
+ return false;
+ }
+ }
+ source->close();
+ return loadSource();
+}
+
+bool akodePlayObject_impl::loadSource()
+{
+ if (!decoderPlugin.isLoaded()) {
+ return false;
+ }
+ frameDecoder = decoderPlugin.openDecoder(source);
+
+ if (!frameDecoder) {
+ delete source;
+ source = 0;
+ arts_warning("akode: Could not open frame-decoder");
+ return false;
+ }
+
+#ifndef AKODEARTS_SINGLETHREADED
+ bufferedDecoder = new BufferedDecoder();
+ bufferedDecoder->setBufferSize(AKODEARTS_FRAMEBUFFER);
+ bufferedDecoder->openDecoder(frameDecoder);
+ decoder = bufferedDecoder;
+#else
+ decoder = frameDecoder;
+#endif
+
+ return true;
+}
+
+string akodePlayObject_impl::description()
+{
+ return "akodePlayObject";
+}
+
+Arts::InputStream akodePlayObject_impl::inputStream() {
+ return instream;
+}
+
+string akodePlayObject_impl::mediaName()
+{
+ if (source)
+ return source->filename;
+ else
+ return string();
+}
+
+poCapabilities akodePlayObject_impl::capabilities()
+{
+ return (poCapabilities)(capPause | capSeek);
+}
+
+poState akodePlayObject_impl::state()
+{
+ return mState;
+}
+
+void akodePlayObject_impl::play()
+{
+ arts_debug("akode: play");
+
+ if (!decoder) {
+ arts_warning("akode: No media loaded");
+ return;
+ }
+
+ if (mState == posIdle) {
+ mState = posPlaying;
+
+ if (!inBuffer) inBuffer = new AudioFrame;
+ if (!buffer) buffer = inBuffer;
+
+
+ buf_pos = 0;
+ } else
+ mState = posPlaying;
+}
+
+void akodePlayObject_impl::pause()
+{
+ arts_debug("akode: pause");
+ mState = posPaused;
+}
+
+void akodePlayObject_impl::halt()
+{
+ arts_debug("akode: halt");
+ if (mState == posIdle) return;
+ mState = posIdle;
+ unload();
+}
+
+void akodePlayObject_impl::unload()
+{
+ arts_debug("akode: unload");
+ if (m_bytebuffer) m_bytebuffer->release();
+#ifndef AKODEARTS_SINGLETHREADED
+ if (bufferedDecoder) {
+ bufferedDecoder->stop();
+ bufferedDecoder->closeDecoder();
+ delete bufferedDecoder;
+ bufferedDecoder = 0;
+ }
+#endif
+ delete frameDecoder;
+ frameDecoder = 0;
+ decoder = 0;
+ if (buffer != inBuffer)
+ delete inBuffer;
+ delete buffer;
+ inBuffer = buffer = 0;
+ buf_pos = 0;
+
+ delete resampler;
+ resampler = 0;
+ delete source;
+ source = 0;
+#ifndef AKODEARTS_SINGLETHREADED
+ delete m_bytebuffer;
+ m_bytebuffer = 0;
+#endif
+}
+
+poTime akodePlayObject_impl::currentTime()
+{
+ poTime time;
+
+ long pos;
+ if (decoder) {
+ pos = decoder->position(); // decoder time
+ if (pos < 0 ) pos = 0;
+ else
+ if (samplingRate > 0 && buffer)
+ {
+ float lpos = (float)(buf_pos-buffer->length) / (float)samplingRate; // local time
+ pos += (long)(lpos*1000.0);
+ }
+ }
+ else
+ pos = 0;
+
+ time.seconds = pos / 1000 ;
+ time.ms = pos % 1000;
+
+ return time;
+}
+
+poTime akodePlayObject_impl::overallTime()
+{
+ poTime time;
+
+ long len;
+ if (decoder) {
+ len = decoder->length();
+ if (len < 0 ) len = 0;
+ }
+ else
+ len = 0;
+
+ time.seconds = len / 1000;
+ time.ms = len % 1000;
+
+ return time;
+}
+
+void akodePlayObject_impl::seek(const poTime &time)
+{
+ arts_debug("akode: seek");
+ if (!decoder) {
+ arts_warning("akode: No media loaded");
+ return;
+ }
+ long akode_pos = time.seconds*1000+time.ms;
+
+ if (decoder->seek(akode_pos) && buffer) {
+ buffer->length = 0; // force re-read
+ buf_pos = 0;
+ }
+}
+
+bool akodePlayObject_impl::readFrame()
+{
+ arts_debug("akode: readFrame");
+
+ if (!inBuffer || !decoder) return false;
+ if (m_bytebuffer) processQueue();
+ if(!decoder->readFrame(inBuffer)) {
+ if (decoder->eof()) {
+ arts_debug("akode: eof");
+ halt();
+ } else
+ if (decoder->error()) {
+ arts_debug("akode: error");
+ halt();
+ } else
+ buffer->length=0;
+ return false;
+ }
+
+ // Invalid frame from broken plugin
+ if (inBuffer->sample_rate == 0) return false;
+
+ if (samplingRate != inBuffer->sample_rate || mSpeed != 1.0) {
+ //arts_debug("akode: resampling to %d/%d", inBuffer->sample_rate, samplingRate);
+ if ( !buffer || buffer==inBuffer ) buffer = new AudioFrame;
+ if ( !resampler)
+ resampler = resamplerPlugin.openResampler();
+
+ resampler->setSampleRate(samplingRate);
+ resampler->setSpeed(mSpeed);
+
+ resampler->doFrame(inBuffer, buffer);
+ } else {
+ if ( buffer !=inBuffer) delete buffer;
+ buffer = inBuffer;
+ }
+
+ buf_pos = 0;
+ return true;
+}
+
+bool akodePlayObject_impl::eof()
+{
+ if (!decoder || !buffer) return true;
+ else
+ return buf_pos>=buffer->length && decoder->eof();
+}
+
+// GCC's lack of good template support means this is easyist done using DEFINE
+#define SEND_BLOCK(T) \
+ T* data = (T*)buffer->data[0]; \
+ j = i; bp = buf_pos; \
+ while (bp < buffer->length && j<count) { \
+ left[j] = data[bp]*scale; \
+ j++; bp++; \
+ } \
+ if (buffer->channels > 1) \
+ data = (T*)buffer->data[1]; \
+ j = i; bp = buf_pos; \
+ while (bp < buffer->length && j<count) { \
+ right[j] = data[bp]*scale; \
+ j++; bp++; \
+ }
+
+
+void akodePlayObject_impl::calculateBlock(unsigned long cnt)
+{
+ long count = (long)cnt;
+// arts_debug("akode: calculateBlock");
+ long i = 0, j, bp;
+
+ if (!decoder) {
+ arts_warning("akode: No media loaded");
+ goto fill_out;
+ }
+
+ if (!buffer)
+ // Not playing yet
+ goto fill_out;
+
+ while ((mState == posPlaying || m_fading) && i<count) {
+ if (buf_pos >= buffer->length) {
+ buf_pos = 0;
+ if (!readFrame()) {
+ break;
+ }
+ }
+ if (buffer->channels > 2 || buffer->sample_width > 24 || buffer->sample_width == 0) {
+ arts_warning("akode: Incompatible media");
+ halt();
+ break;
+ }
+
+ signed char width = buffer->sample_width;
+ float scale = (float)(1<<(width-1));
+ if (width >= 0) {
+ scale = 1/scale;
+ if (width <= 8) {
+ SEND_BLOCK(int8_t);
+ i=j;
+ buf_pos=bp;
+ }
+ else if (width <= 16) {
+ SEND_BLOCK(int16_t);
+ i=j;
+ buf_pos=bp;
+ }
+ else {
+ SEND_BLOCK(int32_t);
+ i=j;
+ buf_pos=bp;
+ }
+ }
+ else {
+ scale = 1.0;
+ SEND_BLOCK(float);
+ i=j;
+ buf_pos=bp;
+ }
+ }
+
+ // fill-out the rest with silence
+fill_out:
+ for (; i < count; i++) {
+ left[i] = right[i] = 0;
+ }
+
+}
+
+void akodePlayObject_impl::streamInit()
+{
+ arts_debug("akode: streamInit");
+}
+
+void akodePlayObject_impl::streamStart()
+{
+ arts_debug("akode: streamStart");
+#ifndef AKODEARTS_SINGLETHREADED
+ bufferedDecoder->start();
+#endif
+}
+
+void akodePlayObject_impl::streamEnd()
+{
+ arts_debug("akode: streamEnd");
+ mState = posIdle;
+ if (decoder) unload();
+}
+
+void akodePlayObject_impl::speed(float newValue)
+{
+ mSpeed = newValue;
+}
+
+float akodePlayObject_impl::speed()
+{
+ return mSpeed;
+}
+
+void akodePlayObject_impl::process_indata(DataPacket<mcopbyte> *inpacket) {
+ arts_debug("akode: process_indata");
+ m_packetQueue->push(inpacket);
+ if (!m_bytebuffer) return;
+ processQueue();
+}
+
+void akodePlayObject_impl::processQueue()
+{
+ while (!m_packetQueue->empty()) {
+ long freespace = m_bytebuffer->space();
+
+ DataPacket<mcopbyte> *inpacket = m_packetQueue->front();
+ if (!inpacket) return;
+
+ if (freespace >= inpacket->size) {
+ if (m_bytebuffer->write((char*)inpacket->contents, inpacket->size, false)) {
+ m_packetQueue->pop();
+ inpacket->processed();
+ }
+ } else
+ return;
+ }
+ if (instream.eof()) m_bytebuffer->close();
+}
+
+
+REGISTER_IMPLEMENTATION(akodePlayObject_impl);
diff --git a/akode_artsplugin/akodePlayObject_impl.h b/akode_artsplugin/akodePlayObject_impl.h
new file mode 100644
index 00000000..e603681b
--- /dev/null
+++ b/akode_artsplugin/akodePlayObject_impl.h
@@ -0,0 +1,98 @@
+/* akodePlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _AKODEPLAYOBJECT_IMPL_H
+#define _AKODEPLAYOBJECT_IMPL_H
+
+#include <akode/resampler.h>
+#include <akode/audioframe.h>
+#include <akode/decoder.h>
+#include <akode/resampler.h>
+
+#include <stdsynthmodule.h>
+#include <kmedia2.h>
+#include <queue>
+#include "akodearts.h"
+
+using std::string;
+using std::queue;
+
+namespace aKode {
+ class BufferedDecoder;
+ class File;
+ class ByteBuffer;
+}
+
+class akodePlayObject_impl
+ : virtual public akodePlayObject_skel
+ , virtual public Arts::StdSynthModule
+{
+public:
+ akodePlayObject_impl(const string &plugin = "wav");
+ ~akodePlayObject_impl();
+
+ virtual bool loadMedia(const string &);
+ virtual bool streamMedia(Arts::InputStream instream);
+ virtual bool loadSource();
+ string description();
+ string mediaName();
+ Arts::InputStream inputStream();
+ Arts::poCapabilities capabilities();
+ Arts::poState state();
+ void play();
+ void pause();
+ void halt();
+ void seek(const Arts::poTime &);
+ Arts::poTime currentTime();
+ Arts::poTime overallTime();
+
+ void streamInit();
+ void streamStart();
+ void calculateBlock(unsigned long samples);
+ void streamEnd();
+
+ void speed(float newValue);
+ float speed();
+
+ void process_indata(Arts::DataPacket<Arts::mcopbyte>*);
+ void processQueue();
+
+protected:
+ bool loadPlugin(const string &plugin);
+ bool readFrame();
+ bool eof();
+ void unload();
+ Arts::InputStream instream;
+ aKode::File *source;
+ aKode::Decoder *frameDecoder, *decoder;
+ aKode::BufferedDecoder *bufferedDecoder;
+ aKode::Resampler *resampler;
+ aKode::AudioFrame *buffer, *inBuffer;
+ int buf_pos;
+ Arts::poState mState;
+ float mSpeed;
+ queue<Arts::DataPacket<Arts::mcopbyte>*> *m_packetQueue;
+ aKode::ByteBuffer *m_bytebuffer;
+ bool m_fading;
+ aKode::DecoderPluginHandler decoderPlugin;
+ aKode::ResamplerPluginHandler resamplerPlugin;
+};
+
+#endif
diff --git a/akode_artsplugin/akodeSpeexStreamPlayObject.mcopclass b/akode_artsplugin/akodeSpeexStreamPlayObject.mcopclass
new file mode 100644
index 00000000..06cfdf5b
--- /dev/null
+++ b/akode_artsplugin/akodeSpeexStreamPlayObject.mcopclass
@@ -0,0 +1,7 @@
+Interface=akodeSpeexStreamPlayObject,Arts::StreamPlayObject,Arts::PitchablePlayObject,Arts::SynthModule,Arts::Object
+Library=libarts_akode.la
+Language=C++
+Author=Allan Sandfeld Jensen <kde@carewolf.com>
+Extension=
+MimeType=audio/x-speex
+Preference=6
diff --git a/akode_artsplugin/akodeSpeexStreamPlayObject_impl.cpp b/akode_artsplugin/akodeSpeexStreamPlayObject_impl.cpp
new file mode 100644
index 00000000..9bba35d7
--- /dev/null
+++ b/akode_artsplugin/akodeSpeexStreamPlayObject_impl.cpp
@@ -0,0 +1,49 @@
+/* akodeSpeexStreamPlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "akodeSpeexStreamPlayObject_impl.h"
+
+#include <akode/decoder.h>
+#include <akode/buffered_decoder.h>
+
+akodeSpeexStreamPlayObject_impl::akodeSpeexStreamPlayObject_impl()
+ : akodeSpeexStreamPlayObject_skel(), akodePlayObject_impl("xiph")
+{
+ speex_plugin = (aKode::DecoderPlugin*)decoderPlugin.loadPlugin("speex_decoder");
+}
+
+
+bool akodeSpeexStreamPlayObject_impl::loadSource()
+{
+ frameDecoder = speex_plugin->openDecoder(source);
+#ifndef SINGLETHREADED_AKODE_PLUGIN
+ bufferedDecoder = new aKode::BufferedDecoder();
+ bufferedDecoder->openDecoder(frameDecoder);
+ decoder = bufferedDecoder;
+#else
+ decoder = frameDecoder;
+#endif
+ return true;
+}
+
+REGISTER_IMPLEMENTATION(akodeSpeexStreamPlayObject_impl);
+
+
+
diff --git a/akode_artsplugin/akodeSpeexStreamPlayObject_impl.h b/akode_artsplugin/akodeSpeexStreamPlayObject_impl.h
new file mode 100644
index 00000000..b033938d
--- /dev/null
+++ b/akode_artsplugin/akodeSpeexStreamPlayObject_impl.h
@@ -0,0 +1,39 @@
+/* akodeSpeexStreamPlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _AKODESPEEXSTREAMPLAYOBJECT_IMPL_H
+#define _AKODESPEEXSTREAMPLAYOBJECT_IMPL_H
+
+#include "akodePlayObject_impl.h"
+#include "akodearts.h"
+
+#include <akode/decoder.h>
+
+class akodeSpeexStreamPlayObject_impl
+ : virtual public akodeSpeexStreamPlayObject_skel, public akodePlayObject_impl
+{
+public:
+ akodeSpeexStreamPlayObject_impl();
+ bool loadSource();
+protected:
+ aKode::DecoderPlugin *speex_plugin;
+};
+
+#endif
diff --git a/akode_artsplugin/akodeVorbisStreamPlayObject.mcopclass b/akode_artsplugin/akodeVorbisStreamPlayObject.mcopclass
new file mode 100644
index 00000000..810bf319
--- /dev/null
+++ b/akode_artsplugin/akodeVorbisStreamPlayObject.mcopclass
@@ -0,0 +1,7 @@
+Interface=akodeVorbisStreamPlayObject,Arts::StreamPlayObject,Arts::PitchablePlayObject,Arts::SynthModule,Arts::Object
+Library=libarts_akode.la
+Language=C++
+Author=Allan Sandfeld Jensen <kde@carewolf.com>
+Extension=
+MimeType=audio/x-vorbis,audio/vorbis,application/ogg
+Preference=6
diff --git a/akode_artsplugin/akodeVorbisStreamPlayObject_impl.cpp b/akode_artsplugin/akodeVorbisStreamPlayObject_impl.cpp
new file mode 100644
index 00000000..5fcc6690
--- /dev/null
+++ b/akode_artsplugin/akodeVorbisStreamPlayObject_impl.cpp
@@ -0,0 +1,49 @@
+/* akodeVorbisStreamPlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "akodeVorbisStreamPlayObject_impl.h"
+
+#include <akode/decoder.h>
+#include <akode/buffered_decoder.h>
+
+akodeVorbisStreamPlayObject_impl::akodeVorbisStreamPlayObject_impl()
+ : akodeVorbisStreamPlayObject_skel(), akodePlayObject_impl("xiph")
+{
+ vorbis_plugin = (aKode::DecoderPlugin*)decoderPlugin.loadPlugin("vorbis_decoder");
+}
+
+
+bool akodeVorbisStreamPlayObject_impl::loadSource()
+{
+ frameDecoder = vorbis_plugin->openDecoder(source);
+#ifndef SINGLETHREADED_AKODE_PLUGIN
+ bufferedDecoder = new aKode::BufferedDecoder();
+ bufferedDecoder->openDecoder(frameDecoder);
+ decoder = bufferedDecoder;
+#else
+ decoder = frameDecoder;
+#endif
+ return true;
+}
+
+REGISTER_IMPLEMENTATION(akodeVorbisStreamPlayObject_impl);
+
+
+
diff --git a/akode_artsplugin/akodeVorbisStreamPlayObject_impl.h b/akode_artsplugin/akodeVorbisStreamPlayObject_impl.h
new file mode 100644
index 00000000..d2ad76e5
--- /dev/null
+++ b/akode_artsplugin/akodeVorbisStreamPlayObject_impl.h
@@ -0,0 +1,39 @@
+/* akodeVorbisStreamPlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _AKODEVORBISSTREAMPLAYOBJECT_IMPL_H
+#define _AKODEVORBISSTREAMPLAYOBJECT_IMPL_H
+
+#include "akodePlayObject_impl.h"
+#include "akodearts.h"
+
+#include <akode/decoder.h>
+
+class akodeVorbisStreamPlayObject_impl
+ : virtual public akodeVorbisStreamPlayObject_skel, public akodePlayObject_impl
+{
+public:
+ akodeVorbisStreamPlayObject_impl();
+ bool loadSource();
+protected:
+ aKode::DecoderPlugin *vorbis_plugin;
+};
+
+#endif
diff --git a/akode_artsplugin/akodeXiphPlayObject.mcopclass b/akode_artsplugin/akodeXiphPlayObject.mcopclass
new file mode 100644
index 00000000..3927f766
--- /dev/null
+++ b/akode_artsplugin/akodeXiphPlayObject.mcopclass
@@ -0,0 +1,7 @@
+Interface=akodeXiphPlayObject,Arts::PlayObject,Arts::PitchablePlayObject,Arts::SynthModule,Arts::Object
+Library=libarts_akode.la
+Language=C++
+Author=Allan Sandfeld Jensen <kde@carewolf.com>
+Extension=flac,ogg,spx
+MimeType=audio/x-flac,audio/x-oggflac,audio/x-speex,audio/x-vorbis,audio/vorbis,application/ogg
+Preference=6
diff --git a/akode_artsplugin/akodeXiphPlayObject_impl.cpp b/akode_artsplugin/akodeXiphPlayObject_impl.cpp
new file mode 100644
index 00000000..86f59ffe
--- /dev/null
+++ b/akode_artsplugin/akodeXiphPlayObject_impl.cpp
@@ -0,0 +1,31 @@
+/* akodeXiphPlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "akodeXiphPlayObject_impl.h"
+
+akodeXiphPlayObject_impl::akodeXiphPlayObject_impl()
+ : akodeXiphPlayObject_skel(), akodePlayObject_impl("xiph")
+{
+}
+
+REGISTER_IMPLEMENTATION(akodeXiphPlayObject_impl);
+
+
+
diff --git a/akode_artsplugin/akodeXiphPlayObject_impl.h b/akode_artsplugin/akodeXiphPlayObject_impl.h
new file mode 100644
index 00000000..3d9b9e7a
--- /dev/null
+++ b/akode_artsplugin/akodeXiphPlayObject_impl.h
@@ -0,0 +1,34 @@
+/* akodeXiphPlayObject
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _AKODEXIPHPLAYOBJECT_IMPL_H
+#define _AKODEXIPHPLAYOBJECT_IMPL_H
+
+#include "akodePlayObject_impl.h"
+#include "akodearts.h"
+
+class akodeXiphPlayObject_impl
+ : virtual public akodeXiphPlayObject_skel, public akodePlayObject_impl
+{
+public:
+ akodeXiphPlayObject_impl();
+};
+
+#endif
diff --git a/akode_artsplugin/akodearts.idl b/akode_artsplugin/akodearts.idl
new file mode 100644
index 00000000..a2686288
--- /dev/null
+++ b/akode_artsplugin/akodearts.idl
@@ -0,0 +1,30 @@
+#include <kmedia2.idl>
+#include <soundserver.idl>
+
+interface akodePlayObject : Arts::StreamPlayObject, Arts::SynthModule, Arts::PitchablePlayObject
+{
+ async in byte stream indata;
+
+ out audio stream left, right;
+};
+
+interface akodeMPCPlayObject : akodePlayObject
+{};
+
+interface akodeMPEGPlayObject : akodePlayObject
+{};
+
+interface akodeFFMPEGPlayObject : akodePlayObject
+{};
+
+interface akodeXiphPlayObject : akodePlayObject
+{};
+
+interface akodeFAADPlayObject : akodePlayObject
+{};
+
+interface akodeVorbisStreamPlayObject : akodePlayObject
+{};
+
+interface akodeSpeexStreamPlayObject : akodePlayObject
+{};
diff --git a/akode_artsplugin/arts_inputstream.h b/akode_artsplugin/arts_inputstream.h
new file mode 100644
index 00000000..71f8797d
--- /dev/null
+++ b/akode_artsplugin/arts_inputstream.h
@@ -0,0 +1,152 @@
+/* aKode: aRts InputStream
+
+ Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef _AKODE_ARTS_INPUTSTREAM_H
+#define _AKODE_ARTS_INPUTSTREAM_H
+
+extern "C" {
+#include <stdio.h>
+#include <fcntl.h>
+}
+
+#include <arts/dispatcher.h>
+
+#include <akode/file.h>
+#include <akode/bytebuffer.h>
+
+class Arts_InputStream : public aKode::File
+{
+protected:
+ // m_instream is mutable because Arts::InputStream has not marked const functions
+ mutable Arts::InputStream m_instream;
+ aKode::ByteBuffer *m_buffer;
+ bool m_open, m_seekable;
+ long m_pos;
+ long m_len;
+public:
+ Arts_InputStream(Arts::InputStream inputstream, aKode::ByteBuffer *buffer)
+ : File("arts_inputstream"),
+ m_instream(inputstream), m_buffer(buffer),
+ m_open(false), m_seekable(false),
+ m_pos(-1), m_len(-1)
+ {
+ m_instream.streamInit();
+ };
+ virtual ~Arts_InputStream() {
+ }
+ bool openRO() {
+ m_open = true;
+ m_pos = 0;
+// Arts::Dispatcher::lock();
+ m_len = m_instream.size();
+ m_seekable = m_instream.seekOk();
+ m_instream.streamStart();
+// Arts::Dispatcher::unlock();
+ return true;
+ }
+ void close() {
+ m_open = false;
+ m_instream.streamEnd();
+ }
+ long read(char* ptr, long num) {
+ if (!m_open) return -1;
+ if (num<=0) return 0;
+ long n = m_buffer->read(ptr,num,true);
+ m_pos += n;
+ return n;
+ }
+ long write(const char*, long) {
+ return -1;
+ }
+ bool seek(long to, int whence) {
+ if(!m_open || !seekable()) return false;
+
+ arts_debug("akode: InputStream seeking");
+
+ long newpos = 0;
+ switch (whence) {
+ case SEEK_SET:
+ newpos = to;
+ break;
+ case SEEK_CUR:
+ newpos = m_pos + to;
+ break;
+ case SEEK_END:
+ if (m_len < 0) return false;
+ newpos = m_len + to;
+ break;
+ default:
+ return false;
+ }
+
+ long s = m_instream.seek(newpos);
+ if (s >= 0) {
+ m_pos = s;
+ m_buffer->flush();
+ return true;
+ }
+ else
+ return false;
+ }
+
+ long position() const {
+ if(!m_open) return -1;
+ return m_pos;
+ }
+
+ long length() const {
+ if(!m_open) return -1;
+ return m_len;
+ }
+
+ bool seekable() const {
+ return m_seekable;
+ }
+
+ bool readable() const {
+ return true;
+ }
+
+ bool writeable() const {
+ return false;
+ }
+ // Arts-call needs to be protected since
+ // the member-functions here are called by another thread
+ bool eof() const {
+ if(!m_open) return true;
+ bool res = false;
+ if (m_buffer->empty()) {
+ Arts::Dispatcher::lock();
+ res = m_instream.eof();
+ Arts::Dispatcher::unlock();
+ }
+ return res;
+ }
+
+ bool error() const {
+ return (!m_open);
+ }
+
+ void fadvise() {
+ return;
+ }
+};
+
+#endif
diff --git a/akode_artsplugin/configure.in.in b/akode_artsplugin/configure.in.in
new file mode 100644
index 00000000..5456ac39
--- /dev/null
+++ b/akode_artsplugin/configure.in.in
@@ -0,0 +1,16 @@
+if test x$build_arts != xyes || test x$have_akode != xyes
+then
+ DO_NOT_COMPILE="$DO_NOT_COMPILE akode_artsplugin"
+else
+ KDE_CHECK_LIB(akode_mpeg_decoder, mpeg_decoder, have_akode_mpeg=yes, have_akode_mpeg=no, -lakode)
+ KDE_CHECK_LIB(akode_mpc_decoder, mpc_decoder, have_akode_mpc=yes, have_akode_mpc=no, -lakode)
+ KDE_CHECK_LIB(akode_xiph_decoder, xiph_decoder, have_akode_xiph=yes, have_akode_xiph=no, -lakode)
+ KDE_CHECK_LIB(akode_ffmpeg_decoder, ffmpeg_decoder, have_akode_ffmpeg=yes, have_akode_ffmpeg=no, -lakode)
+fi
+
+# This must always be called to handle the --without-akode case, as autoconf
+# will check these conditionals values it seems.
+AM_CONDITIONAL(include_akode_mpeg, test x$have_akode_mpeg = xyes)
+AM_CONDITIONAL(include_akode_mpc, test x$have_akode_mpc = xyes)
+AM_CONDITIONAL(include_akode_xiph, test x$have_akode_xiph = xyes)
+AM_CONDITIONAL(include_akode_ffmpeg, test x$have_akode_ffmpeg = xyes)