js8call/NotificationAudio.h

53 lines
1.1 KiB
C
Raw Normal View History

2019-10-08 14:33:38 -04:00
#ifndef NOTIFICATIONAUDIO_H
#define NOTIFICATIONAUDIO_H
#include <QIODevice>
#include <QBuffer>
#include <QAudioDeviceInfo>
#include <QAudioFormat>
#include <QAudioOutput>
#include <QFile>
#include <QPair>
2019-10-15 13:52:30 -04:00
#include <QPointer>
#include <QByteArray>
#include <QCache>
#include <QScopedPointer>
2019-10-08 14:33:38 -04:00
2019-10-15 13:52:30 -04:00
#include "AudioDevice.hpp"
#include "AudioDecoder.h"
#include "Audio/BWFFile.hpp"
2019-10-15 13:52:30 -04:00
#include "soundout.h"
2019-10-15 13:52:30 -04:00
class NotificationAudio :
public QObject
2019-10-08 14:33:38 -04:00
{
Q_OBJECT
public:
NotificationAudio(QObject * parent=nullptr);
~NotificationAudio();
2019-10-08 14:33:38 -04:00
public slots:
void status(QString message);
void error(QString message);
2019-10-15 13:52:30 -04:00
void setDevice(const QAudioDeviceInfo &device, unsigned channels, unsigned msBuffer=0);
2019-10-08 14:33:38 -04:00
void play(const QString &filePath);
void stop();
private:
void playBytes(const QAudioFormat &format, QByteArray *bytes);
private:
QMap<QString, QPair<QAudioFormat, QByteArray*>> m_cache;
2019-10-15 13:52:30 -04:00
QPointer<SoundOutput> m_stream;
QPointer<AudioDecoder> m_decoder;
QPointer<BWFFile> m_file;
QAudioDeviceInfo m_device;
QBuffer m_buffer;
unsigned m_channels;
unsigned m_msBuffer;
2019-10-08 14:33:38 -04:00
};
#endif // NOTIFICATIONAUDIO_H