diff options
author | Chris Robinson <[email protected]> | 2019-10-28 23:47:30 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-10-28 23:47:30 -0700 |
commit | 2741a94e58ed2f9a17d05fd2499e1a3ea4ac43e8 (patch) | |
tree | 3037a809e35d731af83469f07d8b10df5caa0a99 /alc | |
parent | d37a294d4ce66ea3e5816042457923b72d1bc7c1 (diff) |
Use rotate to reorder the default list entry
Diffstat (limited to 'alc')
-rw-r--r-- | alc/hrtf.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp index f353e09b..ac1a19e1 100644 --- a/alc/hrtf.cpp +++ b/alc/hrtf.cpp @@ -1283,8 +1283,6 @@ al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname) pathlist = next; } } - else if(ConfigValueExists(devname, nullptr, "hrtf_tables")) - ERR("The hrtf_tables option is deprecated, please use hrtf-paths instead.\n"); if(usedefaults) { @@ -1298,23 +1296,15 @@ al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname) AddBuiltInEntry(list, "Built-In 48000hz", IDR_DEFAULT_48000_MHR); } - if(!list.empty()) + if(auto defhrtfopt = ConfigValueStr(devname, nullptr, "default-hrtf")) { - if(auto defhrtfopt = ConfigValueStr(devname, nullptr, "default-hrtf")) - { - auto iter = std::find_if(list.begin(), list.end(), - [&defhrtfopt](const EnumeratedHrtf &entry) -> bool - { return entry.name == *defhrtfopt; } - ); - if(iter == list.end()) - WARN("Failed to find default HRTF \"%s\"\n", defhrtfopt->c_str()); - else if(iter != list.begin()) - { - EnumeratedHrtf entry{std::move(*iter)}; - list.erase(iter); - list.insert(list.begin(), std::move(entry)); - } - } + auto find_entry = [&defhrtfopt](const EnumeratedHrtf &entry) -> bool + { return entry.name == *defhrtfopt; }; + auto iter = std::find_if(list.begin(), list.end(), find_entry); + if(iter == list.end()) + WARN("Failed to find default HRTF \"%s\"\n", defhrtfopt->c_str()); + else if(iter != list.begin()) + std::rotate(list.begin(), iter, iter+1); } return list; |