js8call/NotificationAudio.cpp

29 lines
648 B
C++
Raw Normal View History

2019-10-08 14:33:38 -04:00
#include "NotificationAudio.h"
2019-10-15 13:52:30 -04:00
NotificationAudio::NotificationAudio(QObject *parent):
QObject(parent)
2019-10-08 14:33:38 -04:00
{
2019-10-15 13:52:30 -04:00
m_stream = new SoundOutput();
m_decoder = new AudioDecoder(this);
2019-10-08 14:33:38 -04:00
}
NotificationAudio::~NotificationAudio(){
stop();
}
2019-10-15 13:52:30 -04:00
void NotificationAudio::setDevice(const QAudioDeviceInfo &device, unsigned channels, unsigned msBuffer){
m_stream->setFormat(device, channels, msBuffer);
m_decoder->init(m_stream->format());
2019-10-08 14:33:38 -04:00
}
void NotificationAudio::play(const QString &filePath){
2019-10-15 13:52:30 -04:00
m_decoder->start(filePath);
m_stream->restart(m_decoder);
2019-10-08 14:33:38 -04:00
}
2019-10-15 13:52:30 -04:00
void NotificationAudio::stop(){
m_decoder->stop();
m_stream->stop();
}