nvidia: Assign to std::string_view& instead of swapping

For unknown reasons this results in an error only when the project is built within git-bash and with cmake. It does not occur with cmake-gui or VS itself.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2022-08-18 21:20:59 +02:00
parent 16a52ca126
commit cbddee5b90
2 changed files with 10 additions and 8 deletions

View file

@ -70,9 +70,9 @@ streamfx::nvidia::cv::result streamfx::nvidia::ar::feature::get(parameter_t para
cv::result res = get(param, cvalue); cv::result res = get(param, cvalue);
if (res == cv::result::SUCCESS) { if (res == cv::result::SUCCESS) {
if (cvalue) { if (cvalue) {
value.swap(std::string_view(cvalue)); value = std::string_view(cvalue);
} else { } else {
value.swap(std::string_view()); value = std::string_view();
} }
} }
return res; return res;

View file

@ -19,6 +19,7 @@
// SOFTWARE. // SOFTWARE.
#include "nvidia-vfx-effect.hpp" #include "nvidia-vfx-effect.hpp"
#include <string_view>
#include "obs/gs/gs-helper.hpp" #include "obs/gs/gs-helper.hpp"
#include "util/util-logging.hpp" #include "util/util-logging.hpp"
@ -38,7 +39,7 @@
using namespace ::streamfx::nvidia; using namespace ::streamfx::nvidia;
vfx::effect::~effect() streamfx::nvidia::vfx::effect::~effect()
{ {
auto gctx = ::streamfx::obs::gs::context(); auto gctx = ::streamfx::obs::gs::context();
auto cctx = cuda::obs::get()->get_context()->enter(); auto cctx = cuda::obs::get()->get_context()->enter();
@ -49,7 +50,8 @@ vfx::effect::~effect()
_nvcuda.reset(); _nvcuda.reset();
} }
vfx::effect::effect(effect_t effect) : _nvcuda(cuda::obs::get()), _nvcvi(cv::cv::get()), _nvvfx(vfx::vfx::get()), _fx() streamfx::nvidia::vfx::effect::effect(effect_t effect)
: _nvcuda(cuda::obs::get()), _nvcvi(cv::cv::get()), _nvvfx(vfx::vfx::get()), _fx()
{ {
auto gctx = ::streamfx::obs::gs::context(); auto gctx = ::streamfx::obs::gs::context();
auto cctx = cuda::obs::get()->get_context()->enter(); auto cctx = cuda::obs::get()->get_context()->enter();
@ -74,21 +76,21 @@ vfx::effect::effect(effect_t effect) : _nvcuda(cuda::obs::get()), _nvcvi(cv::cv:
} }
} }
cv::result vfx::effect::get(parameter_t param, std::string_view& value) cv::result streamfx::nvidia::vfx::effect::get(parameter_t param, std::string_view& value)
{ {
const char* cvalue = nullptr; const char* cvalue = nullptr;
cv::result res = get(param, cvalue); cv::result res = get(param, cvalue);
if (res == cv::result::SUCCESS) { if (res == cv::result::SUCCESS) {
if (cvalue) { if (cvalue) {
value.swap(std::string_view(cvalue)); value = std::string_view(cvalue);
} else { } else {
value.swap(std::string_view()); value = std::string_view();
} }
} }
return res; return res;
} }
cv::result vfx::effect::get(parameter_t param, std::string& value) cv::result streamfx::nvidia::vfx::effect::get(parameter_t param, std::string& value)
{ {
const char* cvalue = nullptr; const char* cvalue = nullptr;
cv::result res = get(param, cvalue); cv::result res = get(param, cvalue);