mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
Add audio device settings
Summary: Up to now, the audio device settings were not persistent. With this commit, the last audio device will be restored after application start. Reviewers: kbasan, msutcliffe Reviewed By: msutcliffe Differential Revision: https://dev.swift-project.org/D7
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f0bfad40b7
commit
862794cb02
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "blackmisc/settingscache.h"
|
#include "blackmisc/settingscache.h"
|
||||||
#include "blackmisc/audio/audiosettings.h"
|
#include "blackmisc/audio/audiosettings.h"
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
@@ -28,6 +29,21 @@ namespace BlackCore
|
|||||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||||
static bool isValid(const BlackMisc::Audio::CSettings &value) { Q_UNUSED(value); return true; }
|
static bool isValid(const BlackMisc::Audio::CSettings &value) { Q_UNUSED(value); return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Audio input device settings
|
||||||
|
struct TInputDevice : public BlackMisc::TSettingTrait<QString>
|
||||||
|
{
|
||||||
|
//! \copydoc BlackMisc::TSettingTrait::key
|
||||||
|
static const char *key() { return "audio/inputdevice"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Audio input device settings
|
||||||
|
struct TOutputDevice : public BlackMisc::TSettingTrait<QString>
|
||||||
|
{
|
||||||
|
//! \copydoc BlackMisc::TSettingTrait::key
|
||||||
|
static const char *key() { return "audio/outputdevice"; }
|
||||||
|
};
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ namespace BlackCore
|
|||||||
m_unusedVoiceChannels.push_back(m_channel2);
|
m_unusedVoiceChannels.push_back(m_channel2);
|
||||||
|
|
||||||
m_selcalPlayer = new CSelcalPlayer(QAudioDeviceInfo::defaultOutputDevice(), this);
|
m_selcalPlayer = new CSelcalPlayer(QAudioDeviceInfo::defaultOutputDevice(), this);
|
||||||
|
|
||||||
|
changeDeviceSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
CContextAudio *CContextAudio::registerWithDBus(CDBusServer *server)
|
CContextAudio *CContextAudio::registerWithDBus(CDBusServer *server)
|
||||||
@@ -207,6 +209,10 @@ namespace BlackCore
|
|||||||
this->m_voiceInputDevice->setInputDevice(audioDevice);
|
this->m_voiceInputDevice->setInputDevice(audioDevice);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
if (m_inputDeviceSetting.get() != audioDevice.getName())
|
||||||
|
{
|
||||||
|
m_inputDeviceSetting.set(audioDevice.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -215,6 +221,10 @@ namespace BlackCore
|
|||||||
this->m_voiceOutputDevice->setOutputDevice(audioDevice);
|
this->m_voiceOutputDevice->setOutputDevice(audioDevice);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
if (m_outputDeviceSetting.get() != audioDevice.getName())
|
||||||
|
{
|
||||||
|
m_outputDeviceSetting.set(audioDevice.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
@@ -549,6 +559,35 @@ namespace BlackCore
|
|||||||
emit this->changedVoiceRoomMembers();
|
emit this->changedVoiceRoomMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextAudio::changeDeviceSettings()
|
||||||
|
{
|
||||||
|
QString inputDeviceName = m_inputDeviceSetting.get();
|
||||||
|
if (!inputDeviceName.isEmpty())
|
||||||
|
{
|
||||||
|
for (auto device : m_voiceInputDevice->getInputDevices())
|
||||||
|
{
|
||||||
|
if (device.getName() == inputDeviceName)
|
||||||
|
{
|
||||||
|
setCurrentAudioDevice(device);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString outputDeviceName = m_outputDeviceSetting.get();
|
||||||
|
if (!outputDeviceName.isEmpty())
|
||||||
|
{
|
||||||
|
for (auto device : m_voiceOutputDevice->getOutputDevices())
|
||||||
|
{
|
||||||
|
if (device.getName() == outputDeviceName)
|
||||||
|
{
|
||||||
|
setCurrentAudioDevice(device);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QSharedPointer<IVoiceChannel> CContextAudio::getVoiceChannelBy(const CVoiceRoom &voiceRoom)
|
QSharedPointer<IVoiceChannel> CContextAudio::getVoiceChannelBy(const CVoiceRoom &voiceRoom)
|
||||||
{
|
{
|
||||||
QSharedPointer<IVoiceChannel> voiceChannel;
|
QSharedPointer<IVoiceChannel> voiceChannel;
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ namespace BlackCore
|
|||||||
//! Connection in transition
|
//! Connection in transition
|
||||||
bool inTransitionState() const;
|
bool inTransitionState() const;
|
||||||
|
|
||||||
|
void changeDeviceSettings();
|
||||||
|
|
||||||
//! Voice channel by room
|
//! Voice channel by room
|
||||||
QSharedPointer<IVoiceChannel> getVoiceChannelBy(const BlackMisc::Audio::CVoiceRoom &voiceRoom);
|
QSharedPointer<IVoiceChannel> getVoiceChannelBy(const BlackMisc::Audio::CVoiceRoom &voiceRoom);
|
||||||
|
|
||||||
@@ -156,6 +158,8 @@ namespace BlackCore
|
|||||||
|
|
||||||
// settings
|
// settings
|
||||||
BlackMisc::CSetting<BlackCore::Audio::TSettings> m_audioSettings { this };
|
BlackMisc::CSetting<BlackCore::Audio::TSettings> m_audioSettings { this };
|
||||||
|
BlackMisc::CSetting<BlackCore::Audio::TInputDevice> m_inputDeviceSetting { this, &CContextAudio::changeDeviceSettings };
|
||||||
|
BlackMisc::CSetting<BlackCore::Audio::TOutputDevice> m_outputDeviceSetting { this, &CContextAudio::changeDeviceSettings };
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user