home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / arts / kaudioplaystream.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.3 KB  |  128 lines

  1. /*  This file is part of the KDE project
  2.     Copyright (C) 2003 Arnold Krille <arnold@arnoldarts.de>
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License version 2 as published by the Free Software Foundation.
  7.  
  8.     This library is distributed in the hope that it will be useful,
  9.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.     Library General Public License for more details.
  12.  
  13.     You should have received a copy of the GNU Library General Public License
  14.     along with this library; see the file COPYING.LIB.  If not, write to
  15.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.     Boston, MA 02110-1301, USA.
  17.  
  18. */
  19.  
  20. #ifndef KAUDIOPLAYSTREAM_H
  21. #define KAUDIOPLAYSTREAM_H
  22.  
  23. #include <qobject.h>
  24.  
  25. #include <qcstring.h>
  26. #include <stdsynthmodule.h>
  27.  
  28. #include <kdelibs_export.h>
  29.  
  30. class KArtsServer;
  31. namespace Arts { class StereoEffectStack; }
  32.  
  33. class KAudioPlayStreamPrivate;
  34.  
  35. /**
  36.  * @brief A wrapper around ByteSoundProducer/ByteStreamToAudio/Synth_AMAN_PLAY.
  37.  *
  38.  * @author Arnold Krille <arnold@arnoldarts.de>
  39.  * @since 3.2
  40. */
  41.  
  42. class KDE_ARTS_EXPORT KAudioPlayStream : public QObject {
  43.    Q_OBJECT
  44. public:
  45.     /**
  46.      * Creates a KAudioPlayStream on server with a title. You should pass the KArtsServer also
  47.      * as parent to be sure this object is deleted before the server is.
  48.      *
  49.      * @param server The server where it should play to.
  50.      * @param title The title that is shown in the AudioManager.
  51.      * @param parent You will propably want to pass the server as parent to so this stream gets deleted before the server disappears.
  52.      * @param name The name of the stream.
  53.     */
  54.     KAudioPlayStream( KArtsServer* server, const QString title, QObject* parent=0, const char* name=0 );
  55.     /**
  56.      * Destructs the KAudioPlayStream.
  57.     */
  58.     ~KAudioPlayStream();
  59.  
  60.     /**
  61.      * Controls wether this Stream should poll the data from you via the signal requestData()
  62.      * or you use write() to fill the inputbuffer.
  63.      *
  64.      * Default is true
  65.     */
  66.     void setPolling( bool );
  67.     /**
  68.      * Returns the polling state.
  69.      * @see setPolling
  70.     */
  71.     bool polling() const;
  72.  
  73.     /**
  74.      * @return wether this stream is running ("on air") or not.
  75.     */
  76.     bool running() const;
  77.  
  78.     /**
  79.      * @return The Arts::StereoEffectStack right before the Synth_AMAN_PLAY.
  80.     */
  81.     Arts::StereoEffectStack effectStack() const;
  82. public slots:
  83.     /**
  84.      * Start the stream.
  85.      * @param samplingRate how many samples per second ( typically 11000/22050/44100/48000 )
  86.      * @param bits how many bits per sample ( 8 / 16 )
  87.      * @param channels how many channels ( 1 or 2 )
  88.     */
  89.     void start( int samplingRate, int bits, int channels );
  90.     /**
  91.      * Stops the stream.
  92.     */
  93.     void stop();
  94.  
  95.     /**
  96.      * Write data into the inputbuffer.
  97.      * If you ignore the signal noData() it will play 0 ( silence ).
  98.     */
  99.     void write( QByteArray& data );
  100. signals:
  101.     /**
  102.      * This signal is emitted when audio should be played.
  103.      * You have to fill the array with data.
  104.     */
  105.     void requestData( QByteArray& );
  106.  
  107.     /**
  108.      * Is emitted when the state changes.
  109.     */
  110.     void running( bool );
  111.  
  112.     /**
  113.      * Is emitted if the inputbuffer runs dry and polling os off.
  114.     */
  115.     void noData();
  116. public:
  117.     /**
  118.      * @internal
  119.     */
  120.     void fillData( Arts::DataPacket<Arts::mcopbyte> *packet );
  121. private:
  122.     KAudioPlayStreamPrivate* d;
  123. };
  124.  
  125. #endif // KAUDIOPLAYSTREAM_H
  126.  
  127. // vim: sw=4 ts=4 tw=80
  128.