Skip to content
Snippets Groups Projects
Commit 4fd0c334 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

avsettings: use a more declarative approach for the level meter

- prevents a slurry of calls to stop/startAudioMeter

Gitlab: #120
Gitlab: #124
Change-Id: I6118baab1a3f3e08e72a60a35682ce753e05e2eb
parent eac59e52
No related branches found
No related tags found
No related merge requests found
......@@ -247,18 +247,6 @@ AccountAdapter::savePassword(const QString& accountId,
return LRCInstance::accountModel().changeAccountPassword(accountId, oldPassword, newPassword);
}
void
AccountAdapter::startAudioMeter(bool async)
{
LRCInstance::startAudioMeter(async);
}
void
AccountAdapter::stopAudioMeter(bool async)
{
LRCInstance::stopAudioMeter(async);
}
void
AccountAdapter::startPreviewing(bool force, bool async)
{
......
......@@ -97,8 +97,7 @@ public:
Q_INVOKABLE bool savePassword(const QString& accountId,
const QString& oldPassword,
const QString& newPassword);
Q_INVOKABLE void startAudioMeter(bool async);
Q_INVOKABLE void stopAudioMeter(bool async);
Q_INVOKABLE void startPreviewing(bool force = false, bool async = true);
Q_INVOKABLE void stopPreviewing(bool async = true);
Q_INVOKABLE bool hasVideoCall();
......
......@@ -126,3 +126,15 @@ AvAdapter::shareScreenArea(int screenNumber, int x, int y, int width, int height
width < 128 ? 128 : width,
height < 128 ? 128 : height);
}
void
AvAdapter::startAudioMeter(bool async)
{
LRCInstance::startAudioMeter(async);
}
void
AvAdapter::stopAudioMeter(bool async)
{
LRCInstance::stopAudioMeter(async);
}
......@@ -64,4 +64,7 @@ protected:
* Select screen area to display.
*/
Q_INVOKABLE void shareScreenArea(int screenNumber, int x, int y, int width, int height);
Q_INVOKABLE void startAudioMeter(bool async);
Q_INVOKABLE void stopAudioMeter(bool async);
};
......@@ -51,40 +51,25 @@ Rectangle {
switch(sel) {
case SettingsView.Account:
pageIdCurrentAccountSettings.connectCurrentAccount()
settingsViewRect.stopAudioMeter()
settingsViewRect.stopPreviewing()
selectedMenu = sel
if(pageIdCurrentAccountSettings.isPhotoBoothOpened())
{
settingsViewRect.setAvatar()
}
pageIdCurrentAccountSettings.updateAccountInfoDisplayed()
break
case SettingsView.General:
try{
settingsViewRect.stopAudioMeter()
settingsViewRect.stopPreviewing()
} catch(erro) {}
settingsViewRect.stopPreviewing()
selectedMenu = sel
break
case SettingsView.Media:
selectedMenu = sel
settingsViewRect.stopPreviewing()
avSettings.populateAVSettings()
settingsViewRect.startAudioMeter()
break
case SettingsView.Plugin:
try{
settingsViewRect.stopAudioMeter()
settingsViewRect.stopPreviewing()
} catch(erro) {}
settingsViewRect.stopPreviewing()
selectedMenu = sel
pluginSettings.populatePluginSettings()
break
......@@ -102,7 +87,6 @@ Rectangle {
// slots
function leaveSettingsSlot(showMainView) {
settingsViewRect.stopAudioMeter()
settingsViewRect.stopPreviewing()
settingsViewRect.stopBooth()
if (showMainView)
......@@ -137,8 +121,6 @@ Rectangle {
anchors.fill: root
signal stopAudioMeter
signal startAudioMeter
signal stopPreviewing
signal stopBooth
signal setAvatar
......
......@@ -41,29 +41,6 @@ ColumnLayout {
AUDIOMANAGER
}
Connections {
target: settingsViewRect
function onStopAudioMeter() {
stopAudioMeter()
}
function onStartAudioMeter() {
startAudioMeter()
}
}
Connections{
target: AVModel
enabled: root.visible
function onAudioMeter(id, level) {
if (id === "audiolayer_id") {
audioInputMeter.setLevel(level)
}
}
}
function populateAudioSettings() {
inputComboBoxSetting.comboModel.reset()
audioOutputDeviceModel.reset()
......@@ -79,16 +56,6 @@ ColumnLayout {
audioManagerComboBoxSetting.visible = (audioManagerComboBoxSetting.comboModel.rowCount() > 0)
}
function stopAudioMeter(async = true){
audioInputMeter.stop()
AccountAdapter.stopAudioMeter(async)
}
function startAudioMeter(async = true){
audioInputMeter.start()
AccountAdapter.startAudioMeter(async)
}
AudioOutputDeviceModel{
id: audioOutputDeviceModel
}
......@@ -117,12 +84,12 @@ ColumnLayout {
role: "ID_UTF8"
onIndexChanged: {
stopAudioMeter(false)
AvAdapter.stopAudioMeter(false)
var selectedInputDeviceName = comboModel.data(
comboModel.index(modelIndex, 0),
AudioInputDeviceModel.Device_ID)
AVModel.setInputDevice(selectedInputDeviceName)
startAudioMeter(false)
AvAdapter.startAudioMeter(false)
}
}
......@@ -154,12 +121,12 @@ ColumnLayout {
role: "ID_UTF8"
onIndexChanged: {
stopAudioMeter(false)
AvAdapter.stopAudioMeter(false)
var selectedOutputDeviceName = audioOutputDeviceModel.data(
audioOutputDeviceModel.index(modelIndex, 0),
AudioOutputDeviceModel.Device_ID)
AVModel.setOutputDevice(selectedOutputDeviceName)
startAudioMeter(false)
AvAdapter.startAudioMeter(false)
}
}
......@@ -178,12 +145,12 @@ ColumnLayout {
role: "ID_UTF8"
onIndexChanged: {
stopAudioMeter(false)
AvAdapter.stopAudioMeter(false)
var selectedRingtoneDeviceName = audioOutputDeviceModel.data(
audioOutputDeviceModel.index(modelIndex, 0),
AudioOutputDeviceModel.Device_ID)
AVModel.setRingtoneDevice(selectedRingtoneDeviceName)
startAudioMeter(false)
AvAdapter.startAudioMeter(false)
}
}
......@@ -201,11 +168,11 @@ ColumnLayout {
role: "ID_UTF8"
onIndexChanged: {
stopAudioMeter(false)
AvAdapter.stopAudioMeter(false)
var selectedAudioManager = comboModel.data(
comboModel.index(modelIndex, 0), AudioManagerListModel.AudioManagerID)
AVModel.setAudioManager(selectedAudioManager)
startAudioMeter(false)
AvAdapter.startAudioMeter(false)
populateAudioSettings()
}
}
......
......@@ -38,7 +38,6 @@ Rectangle {
onVisibleChanged: {
if (!visible) {
videoSettings.stopPreviewing()
audioSettings.stopAudioMeter()
}
}
......
......@@ -18,30 +18,38 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import net.jami.Models 1.0
import net.jami.Adapters 1.0
ProgressBar {
id: root
property real rmsLevel: 0
value: {
return clamp(rmsLevel * 300.0, 0.0, 100.0)
}
property real rmsLevel: 0
function clamp(num,a,b) {
return Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b))
onVisibleChanged: {
if (visible) {
rmsLevel = 0
AvAdapter.startAudioMeter(true)
} else
AvAdapter.stopAudioMeter(true)
}
function start() {
rmsLevel = 0
function clamp(num, a, b) {
return Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b))
}
function stop() {
}
Connections{
target: AVModel
enabled: root.visible
function setLevel(rmsLevelIn) {
rmsLevel = rmsLevelIn
function onAudioMeter(id, level) {
if (id === "audiolayer_id") {
rmsLevel = level
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment