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>
|
2013-08-07 19:09:13 -04:00
|
|
|
#include <QAudioDeviceInfo>
|
2013-08-05 09:57:55 -04:00
|
|
|
|
2013-08-07 19:09:13 -04:00
|
|
|
class QAudioDeviceInfo;
|
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:
|
2013-08-07 19:09:13 -04:00
|
|
|
SoundOutput (QIODevice * source);
|
2013-08-05 09:57:55 -04:00
|
|
|
~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
|
|
|
|
2013-08-07 19:09:13 -04:00
|
|
|
public Q_SLOTS:
|
|
|
|
void startStream (QAudioDeviceInfo const& device);
|
|
|
|
void suspend ();
|
|
|
|
void resume ();
|
|
|
|
void stopStream ();
|
2012-05-22 13:09:48 -04:00
|
|
|
|
2013-08-07 19:09:13 -04:00
|
|
|
Q_SIGNALS:
|
2013-08-05 09:57:55 -04:00
|
|
|
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;
|
|
|
|
|
2013-08-07 19:09:13 -04:00
|
|
|
private Q_SLOTS:
|
|
|
|
void handleStateChanged (QAudio::State);
|
2013-07-31 20:49:58 -04:00
|
|
|
|
2013-08-05 09:57:55 -04:00
|
|
|
private:
|
|
|
|
QScopedPointer<QAudioOutput> m_stream;
|
|
|
|
|
2013-08-07 19:09:13 -04:00
|
|
|
QIODevice * m_source;
|
|
|
|
bool volatile m_active;
|
|
|
|
QAudioDeviceInfo m_currentDevice;
|
2012-05-22 13:09:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|