save default video device

Now setting the default video device will update the order of the
video preferences and then save the config. This ensures that the
default video device setting persists between dring sessions as
the order of the video preferences in dring.yml is used to determine
the default device when launching dring.

Reviewed-by: Alexandre Viau <alexandre.viau@savoirfairelinux.com>
Change-Id: I7af715c80db58b83eaf4b7584b34ca2279023a2c
Tuleap: #1035
This commit is contained in:
Stepan Salenikovich
2016-10-12 13:49:31 -04:00
committed by Alexandre Viau
parent 10f592d549
commit 918c67d9d0
2 changed files with 15 additions and 3 deletions

View File

@ -79,6 +79,7 @@ setDefaultDevice(const std::string& name)
{
RING_DBG("Setting default device to %s", name.c_str());
ring::Manager::instance().getVideoManager().videoDeviceMonitor.setDefaultDevice(name);
ring::Manager::instance().saveConfig();
}
std::map<std::string, std::string>

View File

@ -109,9 +109,20 @@ VideoDeviceMonitor::getMRLForDefaultDevice() const
void
VideoDeviceMonitor::setDefaultDevice(const std::string& name)
{
const auto it = findDeviceByName(name);
if (it != devices_.end())
defaultDevice_ = it->name;
const auto itDev = findDeviceByName(name);
if (itDev != devices_.end()) {
defaultDevice_ = itDev->name;
// place it at the begining of the prefs
auto itPref = findPreferencesByName(name);
if (itPref != preferences_.end()) {
auto settings = *itPref;
preferences_.erase(itPref);
preferences_.insert(preferences_.begin(), settings);
} else {
preferences_.insert(preferences_.begin(), itDev->getSettings());
}
}
}
DeviceParams