diff --git a/sunshine/nvhttp.cpp b/sunshine/nvhttp.cpp index 261ec05d..9fcd038e 100644 --- a/sunshine/nvhttp.cpp +++ b/sunshine/nvhttp.cpp @@ -168,7 +168,15 @@ void update_id_client(const std::string &uniqueID, std::string &&cert, op_e op) } void getservercert(pair_session_t &sess, pt::ptree &tree, const std::string &pin) { - auto salt = util::from_hex>(sess.async_insert_pin.salt, true); + if(sess.async_insert_pin.salt.size() < 32) { + tree.put("root.paired", 0); + tree.put("root..status_code", 400); + return; + } + + std::string_view salt_view { sess.async_insert_pin.salt.data(), 32 }; + + auto salt = util::from_hex>(salt_view, true); auto key = crypto::gen_aes_key(*salt, pin); sess.cipher_key = std::make_unique(key); @@ -484,7 +492,7 @@ void serverinfo(std::shared_ptr::Response> res auto current_appid = proc::proc.running(); tree.put("root.PairStatus", pair_status); tree.put("root.currentgame", current_appid >= 0 ? current_appid + 1 : 0); - tree.put("root.state", "_SERVER_BUSY"); + tree.put("root.state", current_appid >= 0 ? "_SERVER_BUSY" : "_SERVER_FREE"); std::ostringstream data; diff --git a/sunshine/utility.h b/sunshine/utility.h index e3dec5e0..19f9a985 100644 --- a/sunshine/utility.h +++ b/sunshine/utility.h @@ -451,7 +451,7 @@ public: other._own_ptr = false; } - wrap_ptr &operator=(wrap_ptr &&other) { + wrap_ptr &operator=(wrap_ptr &&other) noexcept { if(_own_ptr) { delete _p; } @@ -484,6 +484,14 @@ public: return *this; } + ~wrap_ptr() { + if(_own_ptr) { + delete _p; + } + + _own_ptr = false; + } + const reference operator*() const { return *_p; } diff --git a/sunshine/video.cpp b/sunshine/video.cpp index 1325bce4..6ed2085d 100644 --- a/sunshine/video.cpp +++ b/sunshine/video.cpp @@ -545,7 +545,7 @@ std::optional make_session(const encoder_t &encoder, const config_t & ctx->keyint_min = ctx->gop_size; if(config.numRefFrames == 0) { - ctx->refs = video_format[encoder_t::REF_FRAMES_AUTOSELECT] ? 0 : 1; + ctx->refs = video_format[encoder_t::REF_FRAMES_AUTOSELECT] ? 0 : 16; } else { // Some client decoders have limits on the number of reference frames @@ -987,6 +987,7 @@ void capture_async( int frame_nr = 1; int key_frame_nr = 1; + while(!shutdown_event->peek() && images->running()) { // Wait for the display to be ready std::shared_ptr display; @@ -1028,7 +1029,8 @@ void capture( idr_event_t idr_events, config_t config, void *channel_data) { - + + idr_events->raise(std::make_pair(0, 1)); if(encoders.front().system_memory) { capture_async(shutdown_event, packets, idr_events, config, channel_data); }