2013-08-05 09:57:55 -04:00
|
|
|
#ifndef SOUNDOUT_H__
|
|
|
|
#define SOUNDOUT_H__
|
2013-07-31 20:49:58 -04:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2013-08-05 09:57:55 -04:00
|
|
|
#include <QAudioOutput>
|
|
|
|
|
|
|
|
#include "Modulator.hpp"
|
2013-07-31 20:49:58 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
class QAudioDeviceInfo;
|
2013-07-31 20:49:58 -04:00
|
|
|
|
|
|
|
// An instance of this sends audio data to a specified soundcard.
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-07-31 20:49:58 -04:00
|
|
|
class SoundOutput : public QObject
|
2012-05-22 13:09:48 -04:00
|
|
|
{
|
2013-07-31 20:49:58 -04:00
|
|
|
Q_OBJECT;
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-07-31 20:49:58 -04:00
|
|
|
Q_PROPERTY(bool running READ isRunning);
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY (SoundOutput);
|
|
|
|
|
|
|
|
public:
|
|
|
|
SoundOutput ()
|
|
|
|
: m_active(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
~SoundOutput ();
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-07-31 20:49:58 -04:00
|
|
|
bool isRunning() const {return m_active;}
|
2013-08-05 09:57:55 -04:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
bool start(QAudioDeviceInfo const& device, QIODevice * source);
|
2013-07-31 20:49:58 -04:00
|
|
|
void stop();
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
Q_SIGNALS:
|
|
|
|
void error (QString message) const;
|
|
|
|
void status (QString message) const;
|
|
|
|
|
2012-05-22 13:09:48 -04:00
|
|
|
private:
|
2013-08-05 09:57:55 -04:00
|
|
|
bool audioError () const;
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void handleStateChanged (QAudio::State) const;
|
2013-07-31 20:49:58 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
private:
|
|
|
|
QScopedPointer<QAudioOutput> m_stream;
|
|
|
|
|
|
|
|
bool m_active;
|
2012-05-22 13:09:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|