Commit b9ec6278 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Ming Rui Zhang

audiometer: allow metering during calls

Change-Id: I82c8d1a573cfc078e1c5e460a0f407015e1ca1cd
parent 01c69521
......@@ -703,8 +703,9 @@ AdvancedSIPSettingsWidget::lineEditVoiceMailDialCodeEditFinished()
}
bool
AdvancedSIPSettingsWidget::eventFilter(QObject * object, QEvent * event)
AdvancedSIPSettingsWidget::eventFilter(QObject* object, QEvent* event)
{
Q_UNUSED(object);
if (event->type() == QEvent::Wheel) {
return true;
}
......
......@@ -50,6 +50,7 @@
#include <QRegularExpression>
#include <QPixmap>
#include <QBuffer>
#include <QtConcurrent/QtConcurrent>
#include <memory>
......@@ -304,6 +305,35 @@ public:
return instance().netWorkManager_.get();
}
static void startAudioMeter(bool async)
{
auto f = [] {
if (!LRCInstance::getActiveCalls().size()) {
LRCInstance::avModel().startAudioDevice();
}
LRCInstance::avModel().setAudioMeterState(true);
};
if (async) {
QtConcurrent::run(f);
} else {
f();
}
}
static void stopAudioMeter(bool async)
{
auto f = [] {
if (!LRCInstance::getActiveCalls().size()) {
LRCInstance::avModel().stopAudioDevice();
}
LRCInstance::avModel().setAudioMeterState(false);
};
if (async) {
QtConcurrent::run(f);
} else {
f();
}
}
signals:
void accountListChanged();
......
......@@ -995,11 +995,7 @@ void SettingsWidget::populateAVSettings()
this, &SettingsWidget::slotAudioInputIndexChanged);
connect(&LRCInstance::avModel(), &lrc::api::AVModel::audioMeter,
[this](const std::string& id, float level) {
if (id == "audiolayer_id") {
ui->audioInputMeter->setLevel(level);
}
});
this, &SettingsWidget::slotAudioMeter, Qt::UniqueConnection);
// audio output devices
disconnect(ui->outputComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
......@@ -1132,38 +1128,25 @@ SettingsWidget::slotVideoDeviceListChanged()
populateVideoSettings();
}
void SettingsWidget::startAudioMeter(bool async)
void
SettingsWidget::slotAudioMeter(const std::string& id, float level)
{
if (LRCInstance::getActiveCalls().size()) {
return;
if (id == "audiolayer_id") {
qDebug() << "audioMeter: " << level;
ui->audioInputMeter->setLevel(level);
}
}
void SettingsWidget::startAudioMeter(bool async)
{
ui->audioInputMeter->start();
auto f = [this] {
LRCInstance::avModel().startAudioDevice();
LRCInstance::avModel().setAudioMeterState(true);
};
if (async) {
QtConcurrent::run(f);
} else {
f();
}
LRCInstance::startAudioMeter(async);
}
void SettingsWidget::stopAudioMeter(bool async)
{
if (LRCInstance::getActiveCalls().size()) {
return;
}
ui->audioInputMeter->stop();
auto f = [this] {
LRCInstance::avModel().stopAudioDevice();
LRCInstance::avModel().setAudioMeterState(false);
};
if (async) {
QtConcurrent::run(f);
} else {
f();
}
LRCInstance::stopAudioMeter(async);
}
void
......
......@@ -147,5 +147,6 @@ private slots:
void slotFormatBoxCurrentIndexChanged(int index);
void slotSetHardwareAccel(bool state);
void slotVideoDeviceListChanged();
void slotAudioMeter(const std::string& id, float level);
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment