diff --git a/src/account.cpp b/src/account.cpp index 29eb4588125d96992fdcba7c7f4d95730c35c817..1c7a0a9b68c307bd38670686af5e08e75b01ef56 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -285,6 +285,16 @@ Account::unserialize(const YAML::Node& node) parseValue(node, RINGTONE_ENABLED_KEY, ringtoneEnabled_); if (ringtonePath_.empty()) { ringtonePath_ = DEFAULT_RINGTONE_PATH; + } else { + // If the user defined a custom ringtone, the file may not exists + // In this case, fallback on the default ringtone path (this will be set during the next + // setAccountDetails) + auto pathRingtone = std::string(JAMI_DATADIR) + DIR_SEPARATOR_STR + RINGDIR + + DIR_SEPARATOR_STR + ringtonePath_; + if (!fileutils::isFile(pathRingtone)) { + JAMI_WARN("Ringtone %s is not a valid file", pathRingtone.c_str()); + ringtonePath_ = DEFAULT_RINGTONE_PATH; + } } parseValue(node, UPNP_ENABLED_KEY, upnpEnabled_); diff --git a/src/account.h b/src/account.h index e88f0a2aac903348d7caf406dec6864e862f4b6f..95df7ecab3f56a925aba058336c635d2fc1233c7 100644 --- a/src/account.h +++ b/src/account.h @@ -63,6 +63,7 @@ class Value; namespace jami { static constexpr uint64_t JAMI_ID_MAX_VAL = 9007199254740992; +constexpr static const char RINGDIR[] = "ringtones"; namespace upnp { class Controller; diff --git a/src/manager.cpp b/src/manager.cpp index dbe0fa338efad627d73c3fe31966bd20eb001964..006656411a657d381337516ae39c98340417cac8 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -2111,7 +2111,6 @@ Manager::playRingtone(const std::string& accountID) if (ringtone.find(DIR_SEPARATOR_CH) == std::string::npos) { // A base file name was provided (such as the default); try to // resolve it from Jami's data installation prefix. - static const char* const RINGDIR = "ringtones"; ringtone = std::string(JAMI_DATADIR) + DIR_SEPARATOR_STR + RINGDIR + DIR_SEPARATOR_STR + ringtone; } @@ -3060,10 +3059,11 @@ Manager::createSinkClient(const std::string& id, bool mixer) } void -Manager::createSinkClients(const std::string& callId, - const ConfInfo& infos, - const std::vector<std::shared_ptr<video::VideoFrameActiveWriter>>& videoStreams, - std::map<std::string, std::shared_ptr<video::SinkClient>>& sinksMap) +Manager::createSinkClients( + const std::string& callId, + const ConfInfo& infos, + const std::vector<std::shared_ptr<video::VideoFrameActiveWriter>>& videoStreams, + std::map<std::string, std::shared_ptr<video::SinkClient>>& sinksMap) { std::lock_guard<std::mutex> lk(pimpl_->sinksMutex_); std::set<std::string> sinkIdsList {}; @@ -3087,7 +3087,7 @@ Manager::createSinkClients(const std::string& callId, newSink->setCrop(participant.x, participant.y, participant.w, participant.h); newSink->setFrameSize(participant.w, participant.h); - for (auto& videoStream: videoStreams) + for (auto& videoStream : videoStreams) videoStream->attach(newSink.get()); sinksMap.emplace(sinkId, newSink); @@ -3100,7 +3100,7 @@ Manager::createSinkClients(const std::string& callId, // remove any non used video sink for (auto it = sinksMap.begin(); it != sinksMap.end();) { if (sinkIdsList.find(it->first) == sinkIdsList.end()) { - for (auto& videoStream: videoStreams) + for (auto& videoStream : videoStreams) videoStream->detach(it->second.get()); it->second->stop(); it = sinksMap.erase(it);