Add Qt prefixes to audio class implementations
This commit is contained in:
parent
339f0075c8
commit
e4771d0d1c
@ -32,11 +32,11 @@ namespace autoapp
|
|||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
class AudioInput: public QObject, public IAudioInput
|
class QtAudioInput: public QObject, public IAudioInput
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AudioInput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate);
|
QtAudioInput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate);
|
||||||
|
|
||||||
bool open() override;
|
bool open() override;
|
||||||
bool isActive() const override;
|
bool isActive() const override;
|
@ -32,12 +32,12 @@ namespace autoapp
|
|||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
class AudioOutput: public QObject, public IAudioOutput
|
class QtAudioOutput: public QObject, public IAudioOutput
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate);
|
QtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate);
|
||||||
bool open() override;
|
bool open() override;
|
||||||
void write(const aasdk::common::DataConstBuffer& buffer) override;
|
void write(const aasdk::common::DataConstBuffer& buffer) override;
|
||||||
void start() override;
|
void start() override;
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <f1x/openauto/autoapp/Projection/AudioInput.hpp>
|
#include <f1x/openauto/autoapp/Projection/QtAudioInput.hpp>
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
@ -29,7 +29,7 @@ namespace autoapp
|
|||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
AudioInput::AudioInput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate)
|
QtAudioInput::QtAudioInput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate)
|
||||||
: ioDevice_(nullptr)
|
: ioDevice_(nullptr)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<IAudioInput::StartPromise::Pointer>("StartPromise::Pointer");
|
qRegisterMetaType<IAudioInput::StartPromise::Pointer>("StartPromise::Pointer");
|
||||||
@ -42,32 +42,32 @@ AudioInput::AudioInput(uint32_t channelCount, uint32_t sampleSize, uint32_t samp
|
|||||||
audioFormat_.setSampleType(QAudioFormat::SignedInt);
|
audioFormat_.setSampleType(QAudioFormat::SignedInt);
|
||||||
|
|
||||||
this->moveToThread(QApplication::instance()->thread());
|
this->moveToThread(QApplication::instance()->thread());
|
||||||
connect(this, &AudioInput::startRecording, this, &AudioInput::onStartRecording, Qt::QueuedConnection);
|
connect(this, &QtAudioInput::startRecording, this, &QtAudioInput::onStartRecording, Qt::QueuedConnection);
|
||||||
connect(this, &AudioInput::stopRecording, this, &AudioInput::onStopRecording, Qt::QueuedConnection);
|
connect(this, &QtAudioInput::stopRecording, this, &QtAudioInput::onStopRecording, Qt::QueuedConnection);
|
||||||
QMetaObject::invokeMethod(this, "createAudioInput", Qt::BlockingQueuedConnection);
|
QMetaObject::invokeMethod(this, "createAudioInput", Qt::BlockingQueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInput::createAudioInput()
|
void QtAudioInput::createAudioInput()
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(debug) << "[AudioInput] create.";
|
OPENAUTO_LOG(debug) << "[AudioInput] create.";
|
||||||
audioInput_ = (std::make_unique<QAudioInput>(QAudioDeviceInfo::defaultInputDevice(), audioFormat_));
|
audioInput_ = (std::make_unique<QAudioInput>(QAudioDeviceInfo::defaultInputDevice(), audioFormat_));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioInput::open()
|
bool QtAudioInput::open()
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
|
||||||
return ioDevice_ == nullptr;
|
return ioDevice_ == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioInput::isActive() const
|
bool QtAudioInput::isActive() const
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
|
||||||
return ioDevice_ != nullptr;
|
return ioDevice_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInput::read(ReadPromise::Pointer promise)
|
void QtAudioInput::read(ReadPromise::Pointer promise)
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
|
||||||
@ -85,32 +85,32 @@ void AudioInput::read(ReadPromise::Pointer promise)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInput::start(StartPromise::Pointer promise)
|
void QtAudioInput::start(StartPromise::Pointer promise)
|
||||||
{
|
{
|
||||||
emit startRecording(std::move(promise));
|
emit startRecording(std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInput::stop()
|
void QtAudioInput::stop()
|
||||||
{
|
{
|
||||||
emit stopRecording();
|
emit stopRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AudioInput::getSampleSize() const
|
uint32_t QtAudioInput::getSampleSize() const
|
||||||
{
|
{
|
||||||
return audioFormat_.sampleSize();
|
return audioFormat_.sampleSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AudioInput::getChannelCount() const
|
uint32_t QtAudioInput::getChannelCount() const
|
||||||
{
|
{
|
||||||
return audioFormat_.channelCount();
|
return audioFormat_.channelCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AudioInput::getSampleRate() const
|
uint32_t QtAudioInput::getSampleRate() const
|
||||||
{
|
{
|
||||||
return audioFormat_.sampleRate();
|
return audioFormat_.sampleRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInput::onStartRecording(StartPromise::Pointer promise)
|
void QtAudioInput::onStartRecording(StartPromise::Pointer promise)
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ void AudioInput::onStartRecording(StartPromise::Pointer promise)
|
|||||||
|
|
||||||
if(ioDevice_ != nullptr)
|
if(ioDevice_ != nullptr)
|
||||||
{
|
{
|
||||||
connect(ioDevice_, &QIODevice::readyRead, this, &AudioInput::onReadyRead, Qt::QueuedConnection);
|
connect(ioDevice_, &QIODevice::readyRead, this, &QtAudioInput::onReadyRead, Qt::QueuedConnection);
|
||||||
promise->resolve();
|
promise->resolve();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -127,7 +127,7 @@ void AudioInput::onStartRecording(StartPromise::Pointer promise)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInput::onStopRecording()
|
void QtAudioInput::onStopRecording()
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ void AudioInput::onStopRecording()
|
|||||||
audioInput_->stop();
|
audioInput_->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioInput::onReadyRead()
|
void QtAudioInput::onReadyRead()
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <f1x/openauto/autoapp/Projection/AudioOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/QtAudioOutput.hpp>
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
@ -29,7 +29,7 @@ namespace autoapp
|
|||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
AudioOutput::AudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate)
|
QtAudioOutput::QtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate)
|
||||||
: playbackStarted_(false)
|
: playbackStarted_(false)
|
||||||
{
|
{
|
||||||
audioFormat_.setChannelCount(channelCount);
|
audioFormat_.setChannelCount(channelCount);
|
||||||
@ -40,79 +40,78 @@ AudioOutput::AudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sa
|
|||||||
audioFormat_.setSampleType(QAudioFormat::SignedInt);
|
audioFormat_.setSampleType(QAudioFormat::SignedInt);
|
||||||
|
|
||||||
this->moveToThread(QApplication::instance()->thread());
|
this->moveToThread(QApplication::instance()->thread());
|
||||||
connect(this, &AudioOutput::startPlayback, this, &AudioOutput::onStartPlayback);
|
connect(this, &QtAudioOutput::startPlayback, this, &QtAudioOutput::onStartPlayback);
|
||||||
connect(this, &AudioOutput::suspendPlayback, this, &AudioOutput::onSuspendPlayback);
|
connect(this, &QtAudioOutput::suspendPlayback, this, &QtAudioOutput::onSuspendPlayback);
|
||||||
connect(this, &AudioOutput::stopPlayback, this, &AudioOutput::onStopPlayback);
|
connect(this, &QtAudioOutput::stopPlayback, this, &QtAudioOutput::onStopPlayback);
|
||||||
|
|
||||||
QMetaObject::invokeMethod(this, "createAudioOutput", Qt::BlockingQueuedConnection);
|
QMetaObject::invokeMethod(this, "createAudioOutput", Qt::BlockingQueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioOutput::createAudioOutput()
|
void QtAudioOutput::createAudioOutput()
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(debug) << "[AudioOutput] create.";
|
OPENAUTO_LOG(debug) << "[QtAudioOutput] create.";
|
||||||
audioOutput_ = std::make_unique<QAudioOutput>(QAudioDeviceInfo::defaultOutputDevice(), audioFormat_);
|
audioOutput_ = std::make_unique<QAudioOutput>(QAudioDeviceInfo::defaultOutputDevice(), audioFormat_);
|
||||||
|
|
||||||
// Setting this category switching to the low latency mode
|
|
||||||
// See: http://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/plugins/pulseaudio/qaudiooutput_pulse.cpp?h=5.7#n58
|
|
||||||
audioOutput_->setCategory("game");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioOutput::open()
|
bool QtAudioOutput::open()
|
||||||
{
|
{
|
||||||
return audioBuffer_.open(QIODevice::ReadWrite);
|
return audioBuffer_.open(QIODevice::ReadWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioOutput::write(const aasdk::common::DataConstBuffer& buffer)
|
void QtAudioOutput::write(const aasdk::common::DataConstBuffer& buffer)
|
||||||
{
|
{
|
||||||
audioBuffer_.write(reinterpret_cast<const char*>(buffer.cdata), buffer.size);
|
audioBuffer_.write(reinterpret_cast<const char*>(buffer.cdata), buffer.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioOutput::start()
|
void QtAudioOutput::start()
|
||||||
{
|
{
|
||||||
emit startPlayback();
|
emit startPlayback();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioOutput::stop()
|
void QtAudioOutput::stop()
|
||||||
{
|
{
|
||||||
emit stopPlayback();
|
emit stopPlayback();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioOutput::suspend()
|
void QtAudioOutput::suspend()
|
||||||
{
|
{
|
||||||
emit suspendPlayback();
|
emit suspendPlayback();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AudioOutput::getSampleSize() const
|
uint32_t QtAudioOutput::getSampleSize() const
|
||||||
{
|
{
|
||||||
return audioFormat_.sampleSize();
|
return audioFormat_.sampleSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AudioOutput::getChannelCount() const
|
uint32_t QtAudioOutput::getChannelCount() const
|
||||||
{
|
{
|
||||||
return audioFormat_.channelCount();
|
return audioFormat_.channelCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AudioOutput::getSampleRate() const
|
uint32_t QtAudioOutput::getSampleRate() const
|
||||||
{
|
{
|
||||||
return audioFormat_.sampleRate();
|
return audioFormat_.sampleRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioOutput::onStartPlayback()
|
void QtAudioOutput::onStartPlayback()
|
||||||
{
|
{
|
||||||
if(!playbackStarted_)
|
if(!playbackStarted_)
|
||||||
{
|
{
|
||||||
audioOutput_->start(&audioBuffer_);
|
audioOutput_->start(&audioBuffer_);
|
||||||
playbackStarted_ = true;
|
playbackStarted_ = true;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
void AudioOutput::onSuspendPlayback()
|
|
||||||
{
|
{
|
||||||
// QAudioOutput is in pull mode so suspending/resuming are not needed.
|
audioOutput_->resume();
|
||||||
// Keep this interface for any further purposes
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioOutput::onStopPlayback()
|
void QtAudioOutput::onSuspendPlayback()
|
||||||
|
{
|
||||||
|
audioOutput_->suspend();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtAudioOutput::onStopPlayback()
|
||||||
{
|
{
|
||||||
if(playbackStarted_)
|
if(playbackStarted_)
|
||||||
{
|
{
|
@ -32,8 +32,8 @@
|
|||||||
#include <f1x/openauto/autoapp/Projection/InputService.hpp>
|
#include <f1x/openauto/autoapp/Projection/InputService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/QtVideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/QtVideoOutput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AudioOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/QtAudioOutput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AudioInput.hpp>
|
#include <f1x/openauto/autoapp/Projection/QtAudioInput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/InputDevice.hpp>
|
#include <f1x/openauto/autoapp/Projection/InputDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/LocalBluetoothDevice.hpp>
|
#include <f1x/openauto/autoapp/Projection/LocalBluetoothDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/RemoteBluetoothDevice.hpp>
|
#include <f1x/openauto/autoapp/Projection/RemoteBluetoothDevice.hpp>
|
||||||
@ -59,22 +59,22 @@ ServiceList ServiceFactory::create(aasdk::messenger::IMessenger::Pointer messeng
|
|||||||
{
|
{
|
||||||
ServiceList serviceList;
|
ServiceList serviceList;
|
||||||
|
|
||||||
IAudioInput::Pointer audioInput(new AudioInput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
IAudioInput::Pointer audioInput(new QtAudioInput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||||
serviceList.emplace_back(std::make_shared<AudioInputService>(ioService_, messenger, std::move(audioInput)));
|
serviceList.emplace_back(std::make_shared<AudioInputService>(ioService_, messenger, std::move(audioInput)));
|
||||||
|
|
||||||
if(configuration_->musicAudioChannelEnabled())
|
if(configuration_->musicAudioChannelEnabled())
|
||||||
{
|
{
|
||||||
IAudioOutput::Pointer mediaAudioOutput(new AudioOutput(2, 16, 48000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
IAudioOutput::Pointer mediaAudioOutput(new QtAudioOutput(2, 16, 48000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||||
serviceList.emplace_back(std::make_shared<MediaAudioService>(ioService_, messenger, std::move(mediaAudioOutput)));
|
serviceList.emplace_back(std::make_shared<MediaAudioService>(ioService_, messenger, std::move(mediaAudioOutput)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(configuration_->speechAudioChannelEnabled())
|
if(configuration_->speechAudioChannelEnabled())
|
||||||
{
|
{
|
||||||
IAudioOutput::Pointer speechAudioOutput(new AudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
IAudioOutput::Pointer speechAudioOutput(new QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||||
serviceList.emplace_back(std::make_shared<SpeechAudioService>(ioService_, messenger, std::move(speechAudioOutput)));
|
serviceList.emplace_back(std::make_shared<SpeechAudioService>(ioService_, messenger, std::move(speechAudioOutput)));
|
||||||
}
|
}
|
||||||
|
|
||||||
IAudioOutput::Pointer systemAudioOutput(new AudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
IAudioOutput::Pointer systemAudioOutput(new QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||||
serviceList.emplace_back(std::make_shared<SystemAudioService>(ioService_, messenger, std::move(systemAudioOutput)));
|
serviceList.emplace_back(std::make_shared<SystemAudioService>(ioService_, messenger, std::move(systemAudioOutput)));
|
||||||
|
|
||||||
serviceList.emplace_back(std::make_shared<SensorService>(ioService_, messenger));
|
serviceList.emplace_back(std::make_shared<SensorService>(ioService_, messenger));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user