mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-10 12:03:18 +02:00
avmodel: use ringtone index and cleanup
Change-Id: If1f76e4c33bfb067769b6d2d81871e156d256aaf
This commit is contained in:
parent
a2cba16f80
commit
5995d9b5d1
4 changed files with 27 additions and 41 deletions
|
@ -119,8 +119,16 @@ AudioDeviceModel::reset()
|
|||
int
|
||||
AudioDeviceModel::getCurrentIndex() const
|
||||
{
|
||||
auto currentId = type_ == Type::Record ? lrcInstance_->avModel().getInputDevice()
|
||||
: lrcInstance_->avModel().getOutputDevice();
|
||||
QString currentId;
|
||||
if (type_ != Type::Record) {
|
||||
if (type_ == Type::Ringtone) {
|
||||
currentId = lrcInstance_->avModel().getRingtoneDevice();
|
||||
} else {
|
||||
currentId = lrcInstance_->avModel().getOutputDevice();
|
||||
}
|
||||
} else {
|
||||
currentId = lrcInstance_->avModel().getInputDevice();
|
||||
}
|
||||
auto resultList = match(index(0, 0), Qt::DisplayRole, QVariant(currentId));
|
||||
return resultList.size() > 0 ? resultList[0].row() : 0;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ ColumnLayout {
|
|||
function populateAudioSettings() {
|
||||
inputComboBoxSetting.modelIndex = inputComboBoxSetting.comboModel.getCurrentIndex()
|
||||
outputComboBoxSetting.modelIndex = outputComboBoxSetting.comboModel.getCurrentIndex()
|
||||
ringtoneComboBoxSetting.modelIndex = outputComboBoxSetting.comboModel.getCurrentIndex()
|
||||
ringtoneComboBoxSetting.modelIndex = ringtoneComboBoxSetting.comboModel.getCurrentIndex()
|
||||
if(audioManagerComboBoxSetting.comboModel.rowCount() > 0) {
|
||||
audioManagerComboBoxSetting.modelIndex =
|
||||
audioManagerComboBoxSetting.comboModel.getCurrentSettingIndex()
|
||||
|
@ -77,9 +77,7 @@ ColumnLayout {
|
|||
|
||||
onActivated: {
|
||||
AvAdapter.stopAudioMeter()
|
||||
AVModel.setInputDevice(comboModel.data(
|
||||
comboModel.index(modelIndex, 0),
|
||||
AudioDeviceModel.RawDeviceName))
|
||||
AVModel.setInputDevice(modelIndex)
|
||||
AvAdapter.startAudioMeter()
|
||||
}
|
||||
}
|
||||
|
@ -116,9 +114,7 @@ ColumnLayout {
|
|||
|
||||
onActivated: {
|
||||
AvAdapter.stopAudioMeter()
|
||||
AVModel.setOutputDevice(comboModel.data(
|
||||
comboModel.index(modelIndex, 0),
|
||||
AudioDeviceModel.RawDeviceName))
|
||||
AVModel.setOutputDevice(modelIndex)
|
||||
AvAdapter.startAudioMeter()
|
||||
}
|
||||
}
|
||||
|
@ -142,9 +138,7 @@ ColumnLayout {
|
|||
|
||||
onActivated: {
|
||||
AvAdapter.stopAudioMeter()
|
||||
AVModel.setRingtoneDevice(comboModel.data(
|
||||
comboModel.index(modelIndex, 0),
|
||||
AudioDeviceModel.RawDeviceName))
|
||||
AVModel.setRingtoneDevice(modelIndex)
|
||||
AvAdapter.startAudioMeter()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,19 +170,19 @@ public:
|
|||
Q_INVOKABLE bool setAudioManager(const QString& name);
|
||||
/**
|
||||
* Set current ringtone device
|
||||
* @param name of the new ringtone device
|
||||
* @param idx of the new ringtone device
|
||||
*/
|
||||
Q_INVOKABLE void setRingtoneDevice(const QString& name);
|
||||
Q_INVOKABLE void setRingtoneDevice(int idx);
|
||||
/**
|
||||
* Set current output device
|
||||
* @param name of the new output device
|
||||
* @param idx of the new output device
|
||||
*/
|
||||
Q_INVOKABLE void setOutputDevice(const QString& name);
|
||||
Q_INVOKABLE void setOutputDevice(int idx);
|
||||
/**
|
||||
* Set current input device
|
||||
* @param name of the new input device
|
||||
* @param idx of the new input device
|
||||
*/
|
||||
Q_INVOKABLE void setInputDevice(const QString& name);
|
||||
Q_INVOKABLE void setInputDevice(int idx);
|
||||
/**
|
||||
* Stop local record at given path
|
||||
* @param path
|
||||
|
|
|
@ -427,23 +427,20 @@ AVModel::setAudioManager(const QString& name)
|
|||
}
|
||||
|
||||
void
|
||||
AVModel::setRingtoneDevice(const QString& name)
|
||||
AVModel::setRingtoneDevice(int idx)
|
||||
{
|
||||
int idx = ConfigurationManager::instance().getAudioOutputDeviceIndex(name);
|
||||
ConfigurationManager::instance().setAudioRingtoneDevice(idx);
|
||||
}
|
||||
|
||||
void
|
||||
AVModel::setOutputDevice(const QString& name)
|
||||
AVModel::setOutputDevice(int idx)
|
||||
{
|
||||
int idx = ConfigurationManager::instance().getAudioOutputDeviceIndex(name);
|
||||
ConfigurationManager::instance().setAudioOutputDevice(idx);
|
||||
}
|
||||
|
||||
void
|
||||
AVModel::setInputDevice(const QString& name)
|
||||
AVModel::setInputDevice(int idx)
|
||||
{
|
||||
int idx = ConfigurationManager::instance().getAudioInputDeviceIndex(name);
|
||||
ConfigurationManager::instance().setAudioInputDevice(idx);
|
||||
}
|
||||
|
||||
|
@ -805,24 +802,11 @@ AVModelPimpl::getDevice(int type) const
|
|||
return "";
|
||||
}
|
||||
auto deviceIdx = currentDevicesIdx[type].toInt();
|
||||
for (const auto& dev : devices) {
|
||||
int idx {-1};
|
||||
switch (type) {
|
||||
case 1: // INPUT
|
||||
idx = ConfigurationManager::instance().getAudioInputDeviceIndex(dev);
|
||||
break;
|
||||
case 0: // OUTPUT
|
||||
case 2: // RINGTONE
|
||||
idx = ConfigurationManager::instance().getAudioOutputDeviceIndex(dev);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (idx == deviceIdx) {
|
||||
return dev;
|
||||
}
|
||||
if (deviceIdx > devices.size()) {
|
||||
// Should not happen, but cannot retrieve current ringtone device
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
result = devices[deviceIdx];
|
||||
} catch (std::bad_alloc& ba) {
|
||||
qWarning() << "bad_alloc caught: " << ba.what();
|
||||
return "";
|
||||
|
|
Loading…
Add table
Reference in a new issue