Fixed windows build
This commit is contained in:
parent
17d2d7ae56
commit
65dad8e9cb
@ -8,10 +8,12 @@
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <any>
|
||||
#include <array>
|
||||
|
||||
#include "misc/spin_lock.h"
|
||||
#include "converters/converter.h"
|
||||
@ -466,9 +468,17 @@ namespace ts {
|
||||
*/
|
||||
|
||||
namespace impl {
|
||||
template <typename... Properties>
|
||||
constexpr auto make_property_array(Properties&&... props) noexcept {
|
||||
return std::array<std::common_type_t<Properties...>, sizeof...(Properties)>{std::forward<Properties>(props)...};
|
||||
constexpr inline auto property_count() {
|
||||
size_t result{0};
|
||||
result += VIRTUALSERVER_ENDMARKER;
|
||||
result += CHANNEL_ENDMARKER;
|
||||
result += CLIENT_ENDMARKER;
|
||||
result += GROUP_ENDMARKER;
|
||||
result += SERVERINSTANCE_ENDMARKER;
|
||||
result += CONNECTION_ENDMARKER;
|
||||
result += PLAYLIST_ENDMARKER;
|
||||
result += UNKNOWN_ENDMARKER;
|
||||
return result;
|
||||
}
|
||||
|
||||
extern bool validateInput(const std::string& input, ValueType type);
|
||||
@ -539,19 +549,7 @@ namespace ts {
|
||||
};
|
||||
|
||||
#ifdef EXTERNALIZE_PROPERTY_DEFINITIONS
|
||||
constexpr inline auto property_count() {
|
||||
size_t result{0};
|
||||
result += VIRTUALSERVER_ENDMARKER;
|
||||
result += CHANNEL_ENDMARKER;
|
||||
result += CLIENT_ENDMARKER;
|
||||
result += GROUP_ENDMARKER;
|
||||
result += SERVERINSTANCE_ENDMARKER;
|
||||
result += CONNECTION_ENDMARKER;
|
||||
result += PLAYLIST_ENDMARKER;
|
||||
result += UNKNOWN_ENDMARKER;
|
||||
return result;
|
||||
}
|
||||
extern std::array<PropertyDescription, property_count()> property_list;
|
||||
extern std::array<PropertyDescription, impl::property_count()> property_list;
|
||||
#else
|
||||
#include "./PropertyDefinition.h"
|
||||
|
||||
@ -784,7 +782,7 @@ namespace ts {
|
||||
|
||||
[[nodiscard]] const property::PropertyDescription& type() const { return *this->data_ptr->description; }
|
||||
[[nodiscard]] std::string value() const {
|
||||
std::lock_guard lock(this->data_ptr->value_lock);
|
||||
std::lock_guard lock{this->data_ptr->value_lock};
|
||||
return this->data_ptr->value;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ decltype(property::property_list) property::
|
||||
#else
|
||||
constexpr auto
|
||||
#endif
|
||||
property_list = property::impl::make_property_array(
|
||||
property_list = std::array<PropertyDescription, impl::property_count()>{
|
||||
PropertyDescription{UNKNOWN_UNDEFINED, "undefined", "", TYPE_UNKNOWN, 0},
|
||||
|
||||
/* virtual server properties */
|
||||
@ -347,7 +347,7 @@ property_list = property::impl::make_property_array(
|
||||
PropertyDescription{PLAYLIST_FLAG_FINISHED, "playlist_flag_finished", "0", TYPE_BOOL, FLAG_PLAYLIST_VARIABLE | FLAG_USER_EDITABLE | FLAG_SAVE},
|
||||
PropertyDescription{PLAYLIST_REPLAY_MODE, "playlist_replay_mode", "0", TYPE_UNSIGNED_NUMBER, FLAG_PLAYLIST_VARIABLE | FLAG_USER_EDITABLE | FLAG_SAVE},
|
||||
PropertyDescription{PLAYLIST_CURRENT_SONG_ID, "playlist_current_song_id", "0", TYPE_UNSIGNED_NUMBER, FLAG_PLAYLIST_VARIABLE | FLAG_SAVE}
|
||||
);
|
||||
};
|
||||
|
||||
#undef str_
|
||||
#undef V
|
||||
|
@ -1,4 +1,7 @@
|
||||
#ifndef NO_OPEN_SSL
|
||||
#define NO_OPEN_SSL
|
||||
#endif
|
||||
|
||||
#include "./digest.h"
|
||||
#include <tomcrypt.h>
|
||||
|
||||
|
@ -5,8 +5,10 @@
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifdef WIN32
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS /* gethostbyname is deprecated for windows */
|
||||
#include <WS2tcpip.h>
|
||||
#include <WinSock2.h>
|
||||
#include <Windows.h>
|
||||
|
@ -72,7 +72,7 @@ namespace str_obf {
|
||||
static_assert(sizeof(char_t) == 1, "Currently only 8 bit supported");
|
||||
if(length == 0) return;
|
||||
if(key.size() == 0) _invalid_key_size();
|
||||
if(key.size() & (key.size() - 1)) _invalid_key_size(); /* key must be an power of 2 */
|
||||
if(key.size() & (key.size() - 1UL)) _invalid_key_size(); /* key must be an power of 2 */
|
||||
|
||||
auto left = length;
|
||||
size_t key_index{0};
|
||||
@ -140,7 +140,7 @@ namespace str_obf {
|
||||
length = (std::uint64_t) ((internal::rng32_next(rng_base, (uint32_t) seed) >> 12UL) & 0xFFUL);
|
||||
} while(length == 0 || length > power2);
|
||||
|
||||
return 1U << length;
|
||||
return uint64_t{1} << length;
|
||||
}
|
||||
|
||||
template <uint64_t line_number, std::uint64_t message_size>
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "AcknowledgeManager.h"
|
||||
#include <cmath>
|
||||
#include <misc/endianness.h>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace ts;
|
||||
using namespace ts::connection;
|
||||
@ -107,7 +108,7 @@ ssize_t AcknowledgeManager::execute_resend(const system_clock::time_point& now ,
|
||||
}
|
||||
} else {
|
||||
if(entry->next_resend <= now) {
|
||||
entry->next_resend = now + std::chrono::milliseconds{(int64_t) min(ceil(this->rto), 1500.f)};
|
||||
entry->next_resend = now + std::chrono::milliseconds{(int64_t) std::min(ceil(this->rto), 1500.f)};
|
||||
need_resend.push_back(entry);
|
||||
entry->resend_count++;
|
||||
entry->send_count++;
|
||||
@ -139,7 +140,7 @@ ssize_t AcknowledgeManager::execute_resend(const system_clock::time_point& now ,
|
||||
/* we're not taking the clock granularity into account because its nearly 1ms and it would only add more branches */
|
||||
void AcknowledgeManager::update_rto(size_t r) {
|
||||
if(srtt == -1) {
|
||||
this->srtt = r;
|
||||
this->srtt = (float) r;
|
||||
this->rttvar = r / 2.f;
|
||||
this->rto = srtt + 4 * this->rttvar;
|
||||
} else {
|
||||
|
@ -15,22 +15,22 @@ void UnorderedPacketLossCalculator::packet_received(uint32_t packet_id) {
|
||||
|
||||
if(age < this->packet_history.max_bits()) {
|
||||
const auto received = this->packet_history.shift_in_bounds(age).count();
|
||||
this->received_packets_ += received;
|
||||
this->received_packets_total_ += received;
|
||||
this->received_packets_ += (uint32_t) received;
|
||||
this->received_packets_total_ += (uint32_t) received;
|
||||
|
||||
this->lost_packets_ += age - received;
|
||||
this->lost_packets_total_ += age - received;
|
||||
this->lost_packets_ += (uint32_t) (age - received);
|
||||
this->lost_packets_total_ += (uint32_t) (age - received);
|
||||
} else {
|
||||
const auto received = this->packet_history.clear().count();
|
||||
this->received_packets_ += received;
|
||||
this->received_packets_total_ += received;
|
||||
this->lost_packets_ += this->packet_history.max_bits() - received;
|
||||
this->lost_packets_total_ += this->packet_history.max_bits() - received;
|
||||
this->received_packets_ += (uint32_t) received;
|
||||
this->received_packets_total_ += (uint32_t) received;
|
||||
this->lost_packets_ += (uint32_t) (this->packet_history.max_bits() - received);
|
||||
this->lost_packets_total_ += (uint32_t) (this->packet_history.max_bits() - received);
|
||||
|
||||
if(age >= this->packet_history.max_bits() * 2) {
|
||||
this->packet_history.set_unchecked(0);
|
||||
this->lost_packets_ += age - this->packet_history.max_bits() * 2;
|
||||
this->lost_packets_total_ += age - this->packet_history.max_bits() * 2;
|
||||
this->lost_packets_ += (uint32_t) (age - this->packet_history.max_bits() * 2);
|
||||
this->lost_packets_total_ += (uint32_t) (age - this->packet_history.max_bits() * 2);
|
||||
} else {
|
||||
this->packet_history.set_unchecked(age - this->packet_history.max_bits());
|
||||
}
|
||||
@ -60,8 +60,8 @@ void UnorderedPacketLossCalculator::short_stats() {
|
||||
if(packets_passed < target_interval) return;
|
||||
|
||||
const auto factor = .5;
|
||||
this->received_packets_ *= factor;
|
||||
this->lost_packets_ *= factor;
|
||||
this->received_packets_ = (uint32_t) (this->received_packets_ * factor);
|
||||
this->lost_packets_ = (uint32_t) (this->lost_packets_ * factor);
|
||||
this->last_history_offset = this->packet_history_offset;
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@ namespace ts::protocol {
|
||||
[[nodiscard]] inline uint32_t received_packets_total() const { return this->received_packets_total_; }
|
||||
[[nodiscard]] inline uint32_t lost_packets_total() const { return this->lost_packets_total_; }
|
||||
|
||||
[[nodiscard]] inline uint32_t unconfirmed_received_packets() const { return this->packet_history.count(); };
|
||||
[[nodiscard]] inline uint32_t unconfirmed_lost_packets() const { return this->packet_history.max_bits() - this->packet_history.count(); };
|
||||
[[nodiscard]] inline uint32_t unconfirmed_received_packets() const { return (uint32_t) this->packet_history.count(); };
|
||||
[[nodiscard]] inline uint32_t unconfirmed_lost_packets() const { return (uint32_t) (this->packet_history.max_bits() - this->packet_history.count()); };
|
||||
|
||||
private:
|
||||
uint32_t received_packets_{0}, received_packets_total_{0}, lost_packets_{0}, lost_packets_total_{0};
|
||||
|
Loading…
Reference in New Issue
Block a user