sdrangelove/include-gpl/audio/audiooutput.h

88 lines
2.6 KiB
C
Raw Normal View History

2012-10-29 20:42:52 +00:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// //
// 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 as version 3 of the License, or //
// //
// 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 V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_AUDIOOUTPUT_H
#define INCLUDE_AUDIOOUTPUT_H
2013-07-30 12:39:07 +00:00
#include <QIODevice>
#include <QThread>
2012-10-29 20:42:52 +00:00
#include <QMutex>
2013-07-30 12:39:07 +00:00
#include <QAudioOutput>
#include <list>
#include <vector>
2013-03-25 15:26:37 +00:00
#include "util/export.h"
2012-10-29 20:42:52 +00:00
class AudioFifo;
2013-07-30 12:39:07 +00:00
class AudioOutput;
2012-10-29 20:42:52 +00:00
2013-07-30 12:39:07 +00:00
class SoundThread : public QThread
{
Q_OBJECT
public:
explicit SoundThread(AudioOutput* out, QObject *parent = 0);
~SoundThread();
void run();
signals:
public slots:
void play();
void stop();
void kill();
private:
void playInt();
AudioOutput* m_generator;
QAudioOutput* m_audioOutput;
};
class SDRANGELOVE_API AudioOutput : public QIODevice{
Q_OBJECT
public:
AudioOutput();
~AudioOutput();
2013-07-30 12:39:07 +00:00
void start();
bool start(int device, int rate);
void stop();
void addFifo(AudioFifo* audioFifo);
void removeFifo(AudioFifo* audioFifo);
2013-07-30 12:39:07 +00:00
qint64 readData(char *data, qint64 maxlen);
qint64 writeData(const char *data, qint64 len);
//int bufferedSamples();
2012-10-29 20:42:52 +00:00
private:
QMutex m_mutex;
//AudioFifo* m_audioFifo;
typedef std::list<AudioFifo*> AudioFifos;
AudioFifos m_audioFifos;
std::vector<qint32> m_mixBuffer;
2012-10-29 20:42:52 +00:00
int m_sampleRate;
//PaTime m_streamStartTime;
2012-10-29 20:42:52 +00:00
2013-07-30 12:39:07 +00:00
SoundThread _sfxThread;
2012-10-29 20:42:52 +00:00
2013-07-30 12:39:07 +00:00
int callback(void* outputBuffer,
unsigned long framesPerBuffer);
2012-10-29 20:42:52 +00:00
};
#endif // INCLUDE_AUDIOOUTPUT_H