From 4aed2c8219774f5d797760606b8489a92ddc5163 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- khotkeys/arts/Makefile.am | 11 +++ khotkeys/arts/soundrecorder_arts.cpp | 141 +++++++++++++++++++++++++++++++++++ khotkeys/arts/soundrecorder_arts.h | 63 ++++++++++++++++ khotkeys/arts/voicerecorder_arts.cpp | 40 ++++++++++ 4 files changed, 255 insertions(+) create mode 100644 khotkeys/arts/Makefile.am create mode 100644 khotkeys/arts/soundrecorder_arts.cpp create mode 100644 khotkeys/arts/soundrecorder_arts.h create mode 100644 khotkeys/arts/voicerecorder_arts.cpp (limited to 'khotkeys/arts') diff --git a/khotkeys/arts/Makefile.am b/khotkeys/arts/Makefile.am new file mode 100644 index 000000000..0aa5929c1 --- /dev/null +++ b/khotkeys/arts/Makefile.am @@ -0,0 +1,11 @@ +kde_module_LTLIBRARIES = khotkeys_arts.la + +khotkeys_arts_la_SOURCES = soundrecorder_arts.cpp voicerecorder_arts.cpp +khotkeys_arts_la_LIBADD = ../shared/libkhotkeys_shared.la $(LIB_ARTS) +khotkeys_arts_la_LDFLAGS = $(all_libraries) $(X_LDFLAGS) -module -avoid-version -no-undefined + +INCLUDES = $(all_includes) -I$(srcdir)/../shared/ -I$(srcdir)/../kcontrol -I../kcontrol + +noinst_HEADERS = soundrecorder_arts.h + +METASOURCES = AUTO diff --git a/khotkeys/arts/soundrecorder_arts.cpp b/khotkeys/arts/soundrecorder_arts.cpp new file mode 100644 index 000000000..db3ea77d8 --- /dev/null +++ b/khotkeys/arts/soundrecorder_arts.cpp @@ -0,0 +1,141 @@ +/*************************************************************************** + * Copyright (C) 2005 by Olivier Goffart * + * ogoffart@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. * + * * + * 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_ARTS + +#include "soundrecorder_arts.h" + +#include +#include +#include + +#include +#include +#include + + +#define FS 11025 +#define BITS 16 + +#define ABS(X) ( ((X)>0) ? (X) : -(X) ) + +extern "C" +KDE_EXPORT +KHotKeys::SoundRecorder* khotkeys_soundrecorder_create( QObject* parent, const char* name ) +{ + return new KHotKeys::SoundRecorderArts( parent, name ); +} + +namespace KHotKeys +{ + + +SoundRecorderArts::SoundRecorderArts(QObject *parent, const char *name) + : SoundRecorder(parent, name) , + m_dis(new KArtsDispatcher( this) ), + m_server( new KArtsServer( this ) ) , + m_recStream( new KAudioRecordStream( m_server, i18n("khotkeys"), m_server ) ) +{ + create_ptr check = khotkeys_soundrecorder_create; // check the type matches + ( void ) check; + + m_recStream->usePolling( false ); + connect( m_recStream, SIGNAL(data (QByteArray &)), this, SLOT(slotDataReceived(QByteArray& ))); +} + +SoundRecorderArts::~SoundRecorderArts() +{ + delete m_recStream; + delete m_server; + delete m_dis; +} + +void SoundRecorderArts::start() +{ + m_recStream->start(FS,BITS,2); + m_data.resize(0); +} + +void SoundRecorderArts::stop() +{ + m_recStream->stop(); + QTimer::singleShot(400,this,SLOT(slotEmitSignal())); +} + +void SoundRecorderArts::abort() +{ + m_recStream->stop(); + m_data.resize(0); +} + + +Sound SoundRecorderArts::sound() +{ + Sound s; + uint BytePS=BITS/8; + uint length=m_data.size()/BytePS; + QMemArray da(length); + s.max=0; + s._fs=FS; + for(uint f=0;f +#include "sound.h" + +class KAudioRecordStream ; +class KArtsServer; + +namespace KHotKeys +{ + + + +/** +@author Olivier Goffart +*/ +class SoundRecorderArts : public SoundRecorder +{ +Q_OBJECT +public: + SoundRecorderArts(QObject *parent = 0, const char *name = 0); + virtual ~SoundRecorderArts(); + + virtual void start(); + virtual void stop(); + virtual void abort(); + virtual Sound sound(); + +private slots: + void slotDataReceived(QByteArray &data); + void slotEmitSignal(); + +private: + QByteArray m_data; + QObject *m_dis; + KArtsServer *m_server; + KAudioRecordStream *m_recStream; +}; + +} + +#endif diff --git a/khotkeys/arts/voicerecorder_arts.cpp b/khotkeys/arts/voicerecorder_arts.cpp new file mode 100644 index 000000000..39cd38cfa --- /dev/null +++ b/khotkeys/arts/voicerecorder_arts.cpp @@ -0,0 +1,40 @@ +/**************************************************************************** + + KHotKeys + + Copyright (C) 2005 Olivier Goffgart + + Distributed under the terms of the GNU General Public License version 2. + +****************************************************************************/ + +#include +#include + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "voicerecorder.h" + +#ifdef HAVE_ARTS + +#include +#include +#include +#include + +extern "C" +KDE_EXPORT +void khotkeys_voicerecorder_arts_play( const QString& file ) +{ + KHotKeys::VoiceRecorder::arts_play_fun check = khotkeys_voicerecorder_arts_play; // check the type matches + ( void ) check; + KArtsDispatcher dispatcher; + KArtsServer server; + KDE::PlayObjectFactory factory( server.server() ); + KDE::PlayObject* playobj = factory.createPlayObject( file, true ); + playobj->play(); +} + +#endif -- cgit v1.2.1