summaryrefslogtreecommitdiffstats
path: root/kttsd/players/artsplayer
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit00bb99ac80741fc50ef8a289719373032f2391eb (patch)
tree3a5a9bf72f942784b38bf77dd66c534662fab5f2 /kttsd/players/artsplayer
downloadtdeaccessibility-00bb99ac80741fc50ef8a289719373032f2391eb.tar.gz
tdeaccessibility-00bb99ac80741fc50ef8a289719373032f2391eb.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaccessibility@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kttsd/players/artsplayer')
-rw-r--r--kttsd/players/artsplayer/Makefile.am30
-rw-r--r--kttsd/players/artsplayer/artsplayer.cpp296
-rw-r--r--kttsd/players/artsplayer/artsplayer.h95
-rw-r--r--kttsd/players/artsplayer/artsplugin.cpp29
-rw-r--r--kttsd/players/artsplayer/kttsd_artsplugin.desktop91
5 files changed, 541 insertions, 0 deletions
diff --git a/kttsd/players/artsplayer/Makefile.am b/kttsd/players/artsplayer/Makefile.am
new file mode 100644
index 0000000..d5c6012
--- /dev/null
+++ b/kttsd/players/artsplayer/Makefile.am
@@ -0,0 +1,30 @@
+# Include paths. INCLUDES is maintained by KDevelop, AM_CPPFLAGS is the preferred variable,
+# so keep them synchronized.
+INCLUDES = \
+ -I$(kde_includes)/arts \
+ -I$(top_srcdir)/kttsd/libkttsd -I$(top_builddir)/kttsd/libkttsd \
+ $(all_includes)
+
+# Let automoc handle all of the metsource files (moc).
+METASOURCES = AUTO
+
+#########################################################################
+# LIBRARY SECTION
+#########################################################################
+# This is the library that gets installed. It's name is used for all
+# of the other Makefile.am variables.
+kde_module_LTLIBRARIES = libkttsd_artsplugin.la
+
+libkttsd_artsplugin_la_SOURCES = \
+ artsplugin.cpp \
+ artsplayer.cpp
+libkttsd_artsplugin_la_LDFLAGS = $(KDE_PLUGIN) $(all_libraries) -no-undefined
+libkttsd_artsplugin_la_LIBADD = $(top_builddir)/kttsd/libkttsd/libkttsd.la -lartskde
+
+# Header files that should not be installed.
+noinst_HEADERS = \
+ artsplayer.h
+
+# This library is installed as a plugin.
+services_DATA = kttsd_artsplugin.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/kttsd/players/artsplayer/artsplayer.cpp b/kttsd/players/artsplayer/artsplayer.cpp
new file mode 100644
index 0000000..512765a
--- /dev/null
+++ b/kttsd/players/artsplayer/artsplayer.cpp
@@ -0,0 +1,296 @@
+/***************************************************************************
+ begin : Sun Feb 17 2002
+ copyright : (C) 2002 - 2004 by Scott Wheeler
+ email : wheeler@kde.org
+
+ copyright : (C) 2003 by Matthias Kretz
+ email : kretz@kde.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. *
+ * *
+ ***************************************************************************/
+
+#include "artsplayer.h"
+
+#include <kdebug.h>
+#include <kconfig.h>
+#include <kstandarddirs.h>
+
+#include <qdir.h>
+#include <qapplication.h>
+
+#include <kartsserver.h>
+#include <kartsdispatcher.h>
+#include <kplayobject.h>
+#include <kplayobjectfactory.h>
+
+#include <sys/wait.h>
+
+#include <kmessagebox.h>
+#include <kaudiomanagerplay.h>
+#include <klocale.h>
+
+////////////////////////////////////////////////////////////////////////////////
+// public methods
+////////////////////////////////////////////////////////////////////////////////
+
+ArtsPlayer::ArtsPlayer(QObject* parent, const char* name, const QStringList& args) :
+ Player(parent, name, args),
+ m_dispatcher(0),
+ m_server(0),
+ m_factory(0),
+ m_playobject(0),
+ m_amanPlay(0),
+ m_volumeControl(Arts::StereoVolumeControl::null()),
+ m_currentVolume(1.0)
+{
+}
+
+ArtsPlayer::~ArtsPlayer()
+{
+ delete m_playobject;
+ delete m_factory;
+ delete m_amanPlay;
+ delete m_server;
+ delete m_dispatcher;
+}
+
+//void ArtsPlayer::play(const FileHandle &file)
+void ArtsPlayer::startPlay(const QString &file)
+{
+ if (!m_dispatcher)
+ setupPlayer();
+
+ // kdDebug(65432) << k_funcinfo << endl;
+ // Make sure that the server still exists, if it doesn't a new one should
+ // be started automatically and the factory and amanPlay are created again.
+
+ if(!file.isNull())
+// m_currentURL.setPath(file.absFilePath());
+ m_currentURL.setPath(file);
+
+ if(m_server->server().isNull()) {
+ KMessageBox::error(0, i18n("Cannot find the aRts soundserver."));
+ return;
+ }
+
+ if(!m_playobject || !file.isNull()) {
+ stop();
+
+ delete m_playobject;
+ m_playobject = m_factory->createPlayObject(m_currentURL, false);
+
+ if(m_playobject->object().isNull())
+ connect(m_playobject, SIGNAL(playObjectCreated()), SLOT(playObjectCreated()));
+ else
+ playObjectCreated();
+ }
+
+ m_playobject->play();
+}
+
+void ArtsPlayer::pause()
+{
+ // kdDebug(65432) << k_funcinfo << endl;
+ if(m_playobject)
+ m_playobject->pause();
+}
+
+void ArtsPlayer::stop()
+{
+ // kdDebug(65432) << k_funcinfo << endl;
+ if(m_playobject) {
+ m_playobject->halt();
+ delete m_playobject;
+ m_playobject = 0;
+ }
+ if(!m_volumeControl.isNull()) {
+ m_volumeControl.stop();
+ m_volumeControl = Arts::StereoVolumeControl::null();
+ }
+}
+
+void ArtsPlayer::setVolume(float volume)
+{
+ // kdDebug( 65432 ) << k_funcinfo << endl;
+
+ m_currentVolume = volume;
+
+ if(serverRunning() && m_playobject && !m_playobject->isNull()) {
+ if(m_volumeControl.isNull())
+ setupVolumeControl();
+ if(!m_volumeControl.isNull()) {
+ m_volumeControl.scaleFactor(volume);
+ // kdDebug( 65432 ) << "set volume to " << volume << endl;
+ }
+ }
+}
+
+float ArtsPlayer::volume() const
+{
+ return m_currentVolume;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+// player status functions
+/////////////////////////////////////////////////////////////////////////////////
+
+bool ArtsPlayer::playing() const
+{
+ if(serverRunning() && m_playobject && m_playobject->state() == Arts::posPlaying)
+ return true;
+ else
+ return false;
+}
+
+bool ArtsPlayer::paused() const
+{
+ if(serverRunning() && m_playobject && m_playobject->state() == Arts::posPaused)
+ return true;
+ else
+ return false;
+}
+
+int ArtsPlayer::totalTime() const
+{
+ if(serverRunning() && m_playobject)
+ return m_playobject->overallTime().seconds;
+ else
+ return -1;
+}
+
+int ArtsPlayer::currentTime() const
+{
+ if(serverRunning() && m_playobject &&
+ (m_playobject->state() == Arts::posPlaying ||
+ m_playobject->state() == Arts::posPaused))
+ {
+ return m_playobject->currentTime().seconds;
+ }
+ else
+ return -1;
+}
+
+int ArtsPlayer::position() const
+{
+ if(serverRunning() && m_playobject && m_playobject->state() == Arts::posPlaying) {
+ long total = m_playobject->overallTime().seconds * 1000 + m_playobject->overallTime().ms;
+ long current = m_playobject->currentTime().seconds * 1000 + m_playobject->currentTime().ms;
+
+ // add .5 to make rounding happen properly
+
+ return int(double(current) * 1000 / total + .5);
+ }
+ else
+ return -1;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+// player seek functions
+/////////////////////////////////////////////////////////////////////////////////
+
+void ArtsPlayer::seek(int seekTime)
+{
+ if(serverRunning() && m_playobject) {
+ Arts::poTime poSeekTime;
+ poSeekTime.custom = 0;
+ poSeekTime.ms = 0;
+ poSeekTime.seconds = seekTime;
+ m_playobject->object().seek(poSeekTime);
+ }
+}
+
+void ArtsPlayer::seekPosition(int position)
+{
+ if(serverRunning() && m_playobject) {
+ Arts::poTime poSeekTime;
+ long total = m_playobject->overallTime().seconds;
+ poSeekTime.custom = 0;
+ poSeekTime.ms = 0;
+ poSeekTime.seconds = long(double(total) * position / 1000 + .5);
+ m_playobject->object().seek(poSeekTime);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+// private
+/////////////////////////////////////////////////////////////////////////////////
+
+void ArtsPlayer::setupArtsObjects()
+{
+ // kdDebug( 65432 ) << k_funcinfo << endl;
+ delete m_factory;
+ delete m_amanPlay;
+ m_volumeControl = Arts::StereoVolumeControl::null();
+ m_factory = new KDE::PlayObjectFactory(m_server);
+ m_amanPlay = new KAudioManagerPlay(m_server);
+
+ if(m_amanPlay->isNull() || !m_factory) {
+ KMessageBox::error(0, i18n("Connecting/starting aRts soundserver failed. "
+ "Make sure that artsd is configured properly."));
+ qApp->exit(1);
+ }
+
+ m_amanPlay->setTitle(i18n("kttsd"));
+ m_amanPlay->setAutoRestoreID("kttsdAmanPlay");
+
+ m_factory->setAudioManagerPlay(m_amanPlay);
+}
+
+void ArtsPlayer::playObjectCreated()
+{
+ // kdDebug(65432) << k_funcinfo << endl;
+ setVolume(m_currentVolume);
+}
+
+void ArtsPlayer::setupPlayer()
+{
+ m_dispatcher = new KArtsDispatcher;
+ m_server = new KArtsServer;
+ setupArtsObjects();
+ connect(m_server, SIGNAL(restartedServer()), SLOT(setupArtsObjects()));
+}
+
+void ArtsPlayer::setupVolumeControl()
+{
+ // kdDebug( 65432 ) << k_funcinfo << endl;
+ m_volumeControl = Arts::DynamicCast(m_server->server().createObject("Arts::StereoVolumeControl"));
+ if(!m_volumeControl.isNull() && !m_playobject->isNull() && !m_playobject->object().isNull()) {
+ Arts::Synth_AMAN_PLAY ap = m_amanPlay->amanPlay();
+ Arts::PlayObject po = m_playobject->object();
+ ap.stop();
+ Arts::disconnect(po, "left" , ap, "left" );
+ Arts::disconnect(po, "right", ap, "right");
+
+ m_volumeControl.start();
+ ap.start();
+
+ Arts::connect(po, "left" , m_volumeControl, "inleft" );
+ Arts::connect(po, "right", m_volumeControl, "inright");
+ Arts::connect(m_volumeControl, "outleft" , ap, "left" );
+ Arts::connect(m_volumeControl, "outright", ap, "right");
+ // kdDebug( 65432 ) << "connected volume control" << endl;
+ }
+ else {
+ m_volumeControl = Arts::StereoVolumeControl::null();
+ kdDebug(65432) << "Could not initialize volume control!" << endl;
+ }
+}
+
+bool ArtsPlayer::serverRunning() const
+{
+ if(m_server)
+ return !(m_server->server().isNull());
+ else
+ return false;
+}
+
+#include "artsplayer.moc"
+
+// vim: sw=4 ts=8 et
diff --git a/kttsd/players/artsplayer/artsplayer.h b/kttsd/players/artsplayer/artsplayer.h
new file mode 100644
index 0000000..96d62f6
--- /dev/null
+++ b/kttsd/players/artsplayer/artsplayer.h
@@ -0,0 +1,95 @@
+/***************************************************************************
+ begin : Sun Feb 17 2002
+ copyright : (C) 2002 - 2004 by Scott Wheeler
+ email : wheeler@kde.org
+
+ copyright : (C) 2003 by Matthias Kretz
+ email : kretz@kde.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef ARTSPLAYER_H
+#define ARTSPLAYER_H
+
+#include <config.h>
+#include <kdemacros.h>
+#include "kdeexportfix.h"
+
+#include "player.h"
+
+#include <kurl.h>
+
+#include <qstring.h>
+#include <qobject.h>
+#include <artsflow.h>
+
+class KArtsDispatcher;
+class KArtsServer;
+class KAudioManagerPlay;
+
+namespace KDE {
+ class PlayObjectFactory;
+ class PlayObject;
+}
+
+class KDE_EXPORT ArtsPlayer : public Player
+{
+ Q_OBJECT
+
+public:
+ ArtsPlayer(QObject* parent = 0, const char* name = 0, const QStringList& args=QStringList());
+ ~ArtsPlayer();
+
+// virtual void play(const FileHandle &file = FileHandle::null());
+ virtual void startPlay(const QString& file);
+ virtual void pause();
+ virtual void stop();
+
+ virtual void setVolume(float volume = 1.0);
+ virtual float volume() const;
+
+ virtual bool playing() const;
+ virtual bool paused() const;
+
+ virtual int totalTime() const;
+ virtual int currentTime() const;
+ virtual int position() const; // in this case not really the percent
+
+ virtual void seek(int seekTime);
+ virtual void seekPosition(int position);
+
+private slots:
+ void setupArtsObjects();
+ void playObjectCreated();
+
+private:
+ void setupPlayer();
+ void setupVolumeControl();
+ bool serverRunning() const;
+
+ KArtsDispatcher *m_dispatcher;
+ KArtsServer *m_server;
+ KDE::PlayObjectFactory *m_factory;
+ KDE::PlayObject *m_playobject;
+ KAudioManagerPlay *m_amanPlay;
+
+ // This is a pretty heavy module for the needs that JuK has, it would probably
+ // be good to use two Synth_MUL instead or the one from Noatun.
+
+ Arts::StereoVolumeControl m_volumeControl;
+
+ KURL m_currentURL;
+ float m_currentVolume;
+};
+
+#endif
+
+// vim: sw=4 ts=8 et
diff --git a/kttsd/players/artsplayer/artsplugin.cpp b/kttsd/players/artsplayer/artsplugin.cpp
new file mode 100644
index 0000000..36f4517
--- /dev/null
+++ b/kttsd/players/artsplayer/artsplugin.cpp
@@ -0,0 +1,29 @@
+/***************************************************** vim:set ts=4 sw=4 sts=4:
+ Generating the factories so aRts can be used as an audio plug in.
+ -------------------
+ Copyright:
+ (C) 2004 by Gary Cramblitt <garycramblitt@comcast.net>
+ -------------------
+ Original author: Gary Cramblitt <garycramblitt@comcast.net>
+
+ 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 <kgenericfactory.h>
+
+#include "artsplayer.h"
+
+K_EXPORT_COMPONENT_FACTORY( libkttsd_artsplugin, KGenericFactory<ArtsPlayer>("kttsd_arts") )
+
diff --git a/kttsd/players/artsplayer/kttsd_artsplugin.desktop b/kttsd/players/artsplayer/kttsd_artsplugin.desktop
new file mode 100644
index 0000000..9eef151
--- /dev/null
+++ b/kttsd/players/artsplayer/kttsd_artsplugin.desktop
@@ -0,0 +1,91 @@
+[Desktop Entry]
+Name=KTTSD Arts Plugin
+Name[br]=Lugent Arts evit KTTSD
+Name[bs]=KTTSD Arts dodatak
+Name[ca]=Connector Arts pel KTTSD
+Name[cs]=KTTSD Arts modul
+Name[da]=KTTSD aRts-plugin
+Name[de]=KTTSD Arts-Modul
+Name[el]=KTTSD πρόσθετο Arts
+Name[es]=Complemento KTTSD Arts
+Name[et]=KTTSD Artsi plugin
+Name[eu]=KTTSD-ren Arts-plugina
+Name[fa]=وصلۀ KTTSD Arts
+Name[fi]=KTTSD Arts -liitännäinen
+Name[fr]=Module Arts pour KTTSD
+Name[ga]=Breiseán KTTSD Arts
+Name[gl]=Plugin Arts de KTTSD
+Name[hu]=KTTSD aRts hangmodul
+Name[is]=KTTSD Arts íforrit
+Name[it]=Plugin per Arts di KTTSD
+Name[ja]=KTTSD aRts プラグイン
+Name[ka]=KTTSD Arts მოდული
+Name[km]=កម្មវិធី​ជំនួយ Arts សម្រាប់ KTTSD
+Name[mk]=aRts-приклучок за KTTSD
+Name[nb]=Arts programtillegg for KTTSD
+Name[nds]=aRts-Moduul för KTTSD
+Name[ne]=KTTSD कला प्लगइन
+Name[nl]=KTTSD Arts-plugin
+Name[pa]=KTTSD Arts ਪਲੱਗਿੰਨ
+Name[pl]=Wtyczka aRts KTTSD
+Name[pt]='Plugin' Arts do KTTSD
+Name[pt_BR]=Plug-in do Arts para o KTTSD
+Name[ru]=Модуль Arts для KTTSD
+Name[sk]=Modul KTTSD Arts
+Name[sl]=Vstavek KTTSD za aRts
+Name[sr]=Arts као прикључак за KTTSD
+Name[sr@Latn]=Arts kao priključak za KTTSD
+Name[sv]=KTTSD-insticksprogram för aRts
+Name[ta]=KTTSD ஆர்ட்ஸ் சொருகுப்பொருள்
+Name[tg]=Модули Arts барои KTTSD
+Name[tr]=KTTSD Arts Eklentisi
+Name[uk]=Втулок Arts для KTTSD
+Name[vi]=Trình bổ sung KTTSD Arts
+Name[zh_TW]=KTTSd Arts 外掛程式
+Comment=KTTSD aRts audio plugin
+Comment[bg]=Аудио приставка на KTTSD за aRts
+Comment[br]=Lugent klevet Arts evit KTTSD
+Comment[ca]=Connector d'àudio aRts pel KTTSD
+Comment[cs]=KTTSD aRts zvukový modul
+Comment[da]=KTTSD aRts lyd-plugin
+Comment[de]=KTTSD aRts Audio-Modul
+Comment[el]=KTTSD πρόσθετο ήχου aRts
+Comment[es]=Complemento de audio KTTSD aRts
+Comment[et]=KTTSD aRts'i audioplugin
+Comment[eu]=KTTSD-ren aRts audio-plugina
+Comment[fa]=وصلۀ صوتی KTTSD aRts
+Comment[fi]=KTTSD aRts ääniliitännäinen
+Comment[fr]=Module audio Arts pour KTTSD
+Comment[ga]=Breiseán fuaime KTTSD aRts
+Comment[gl]=Plugin de áudio aRts para KTTSD
+Comment[hu]=KTTSD hangmodul az aRts hangrendszerhez
+Comment[is]=KTTSD aRts hljóð íforrit
+Comment[it]=Plugin audio per aRts di KTTSD
+Comment[ja]=KTTSD aRts オーディオプラグイン
+Comment[ka]=KTTSD aRts აუდიო მოდული
+Comment[km]=កម្មវិធី​ជំនួយ​អូឌីយ៉ូ aRts សម្រាប់ KTTSD
+Comment[mk]=aRts-аудиоприклучок за KTTSD
+Comment[ms]=Plugin audio aRts KTTSD
+Comment[nb]=aRts lyd-programtillegg for KTTSD
+Comment[nds]=aRts-Audiomoduul för KTTSD
+Comment[ne]=KTTSD कला अडियो प्लगइन
+Comment[nl]=KTTSD aRts-audioplugin
+Comment[pa]=KTTSD aRts ਆਡੀਓ ਪਲੱਗਿੰਨ
+Comment[pl]=Wtyczka dźwięku aRts dla KTTSD
+Comment[pt]='Plugin' áudio aRts do KTTSD
+Comment[pt_BR]=Plug-in de áudio do Arts para o KTTSD
+Comment[ru]=Модуль вывода звука KTTSD через aRts
+Comment[sk]=Modul KTTSD aRts audio
+Comment[sl]=Vstavek KTTSD za zvok v aRts
+Comment[sr]=Arts као аудио прикључак за KTTSD
+Comment[sr@Latn]=Arts kao audio priključak za KTTSD
+Comment[sv]=KTTSD-ljudinsticksprogram för aRts
+Comment[ta]=KTTSD aRts கேட்பொலி சொருகுப்பொருள்
+Comment[tg]=Модули барориши овози KTTSD ба воситаи aRts
+Comment[tr]=KTTSD aRts ses eklentisi
+Comment[uk]=Звуковий втулок aRts для KTTSD
+Comment[vi]=Trình bổ sung âm thanh KTTSD aRts
+Comment[zh_TW]=KTTSd aRts 語音外掛程式
+Type=Service
+ServiceTypes=KTTSD/AudioPlugin
+X-KDE-Library=libkttsd_artsplugin