Fixed some stiff for windows

This commit is contained in:
WolverinDEV 2019-12-07 22:27:20 +01:00
parent 86640da695
commit f01c9caf2d
No known key found for this signature in database
GPG Key ID: 77A6C15085150EEB
15 changed files with 65 additions and 47 deletions

View File

@ -58,7 +58,7 @@ function compile_native() {
[[ ! -z "$traroot_library" ]] && _arguments="${_arguments} -DLIBRARY_PATH=\"$traroot_library\""
local _generator=""
[[ ${build_os_type} == "win32" ]] && _generator='-G"Visual Studio 15 2017 Win64"'
[[ ${build_os_type} == "win32" ]] && _generator='-G"Visual Studio 16 2019"'
_command="cmake ../../ ${_generator} -DCMAKE_BUILD_TYPE=RelWithDebInfo ${_arguments}"
echo "Executing cmake command $_command"
@ -117,8 +117,8 @@ function deploy_client() {
end_task "${project_name}_package" "Client successfully deployed!"
}
install_npm
compile_scripts
#install_npm
#compile_scripts
compile_native
package_client
deploy_client

View File

@ -110,6 +110,7 @@ if (MSVC)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
add_compile_options("/MTd")
add_compile_options("/EHsc") #We require exception handling
else()
#This is a bad thing here!

View File

@ -44,9 +44,6 @@ NAN_METHOD(finalize) {
tc::signal::finalize();
}
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
NAN_METHOD(crash) {
std::thread([] {
while (true) {

View File

@ -2,11 +2,14 @@
#ifdef WIN32
#include <Windows.h>
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <client/linux/handler/exception_handler.h>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
#include <experimental/filesystem>
#include <iostream>
#include <thread>
#include "base64.h"
@ -14,7 +17,6 @@
using namespace std;
using namespace tc;
using namespace tc::signal;
namespace fs = std::experimental::filesystem;
#ifndef WIN32
unique_ptr<google_breakpad::ExceptionHandler> global_crash_handler;

View File

@ -1,6 +1,5 @@
#pragma once
#include <string>
#include <memory>

View File

@ -4,10 +4,14 @@
#include <string>
#include <algorithm>
#include <strsafe.h>
#include <iostream>
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#ifdef WIN32
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
using namespace std;
extern void win_crash_callback(const fs::path& source_file, const std::string& error, bool success);

View File

@ -9,7 +9,7 @@ namespace Nan {
inline v8::Local<v8::String> LocalStringUTF8(std::string_view buffer) {
auto isolate = Nan::GetCurrentContext()->GetIsolate();
v8::EscapableHandleScope scope{isolate};
auto data = v8::String::NewFromUtf8(isolate, buffer.data(), v8::NewStringType::kNormal, buffer.length());
auto data = v8::String::NewFromUtf8(isolate, buffer.data(), v8::NewStringType::kNormal, (int) buffer.length());
v8::Local<v8::String> response{};
if(!data.ToLocal(&response))
@ -34,7 +34,7 @@ namespace Nan {
inline v8::Local<v8::String> LocalString(std::string_view buffer) {
auto isolate = Nan::GetCurrentContext()->GetIsolate();
//v8::EscapableHandleScope scope{isolate};
auto data = v8::String::NewFromOneByte(isolate, (uint8_t*) buffer.data(), v8::NewStringType::kNormal, buffer.length());
auto data = v8::String::NewFromOneByte(isolate, (uint8_t*) buffer.data(), v8::NewStringType::kNormal, (int) buffer.length());
v8::Local<v8::String> response{};
if(!data.ToLocal(&response))
@ -60,7 +60,7 @@ namespace Nan {
inline v8::Local<v8::String> LocalString(std::wstring_view buffer) {
auto isolate = Nan::GetCurrentContext()->GetIsolate();
v8::EscapableHandleScope scope{isolate};
auto data = v8::String::NewFromTwoByte(isolate, (uint16_t*) buffer.data(), v8::NewStringType::kNormal, buffer.length());
auto data = v8::String::NewFromTwoByte(isolate, (uint16_t*) buffer.data(), v8::NewStringType::kNormal, (int) buffer.length());
v8::Local<v8::String> response{};
if(!data.ToLocal(&response))

View File

@ -4,5 +4,5 @@
#include "include/NanGet.h"
int main() {
auto str = Nan::StringUTF8("Hello World");
auto str = Nan::StringUTF8("Hello World");
}

View File

@ -21,10 +21,11 @@ namespace tc {
return std::unique_lock<std::timed_mutex>(this->_execute_mutex);
else {
auto lock = std::unique_lock<std::timed_mutex>(this->_execute_mutex, std::defer_lock);
if(this->execute_lock_timeout.count() > 0)
lock.try_lock_for(this->execute_lock_timeout);
else
lock.try_lock();
if(this->execute_lock_timeout.count() > 0) {
(void) lock.try_lock_for(this->execute_lock_timeout);
} else {
(void) lock.try_lock();
}
return lock;
}
}

View File

@ -30,14 +30,14 @@ bool UDPSocket::initialize() {
if(this->file_descriptor > 0)
return false;
this->file_descriptor = socket(this->_remote_address.ss_family, SOCK_DGRAM | SOCK_NONBLOCK, 0);
this->file_descriptor = (int) socket(this->_remote_address.ss_family, SOCK_DGRAM | SOCK_NONBLOCK, 0);
if(this->file_descriptor < 2) {
this->file_descriptor = 0;
return false;
}
#ifdef WIN32
u_long enabled = 0;
u_long enabled = 1;
auto non_block_rs = ioctlsocket(this->file_descriptor, FIONBIO, &enabled);
if (non_block_rs != NO_ERROR) {
log_warn(category::connection, tr("Failed to enable noblock!"));
@ -130,8 +130,9 @@ void UDPSocket::_io_execute(void *_ptr_socket) {
void UDPSocket::io_execute() {
while(this->io_base) {
event_base_loop(this->io_base, 0);
event_base_loop(this->io_base, EVLOOP_NO_EXIT_ON_EMPTY);
}
logger::trace(category::socket, tr("Socket IO loop exited"));
}
void UDPSocket::callback_read(evutil_socket_t fd) {
sockaddr source_address{};
@ -144,7 +145,7 @@ void UDPSocket::callback_read(evutil_socket_t fd) {
size_t read_count = 0;
while(true) { //TODO: Some kind of timeout
source_address_length = sizeof(sockaddr);
read_length = recvfrom(fd, (char*) buffer, buffer_length, MSG_DONTWAIT, &source_address, &source_address_length);
read_length = recvfrom(fd, (char*) buffer, (int) buffer_length, MSG_DONTWAIT, &source_address, &source_address_length);
if(read_length <= 0) {
if(errno == EAGAIN)
break;
@ -153,6 +154,7 @@ void UDPSocket::callback_read(evutil_socket_t fd) {
break; /* this should never happen! */
}
//logger::trace(category::socket, tr("Read {} bytes"), read_length);
read_count++;
if(this->on_data)
this->on_data(pipes::buffer_view{buffer, (size_t) read_length});
@ -168,7 +170,7 @@ void UDPSocket::callback_write(evutil_socket_t fd) {
this->write_queue.pop_front();
lock.unlock();
auto written = sendto(fd, buffer.data_ptr<char>(), buffer.length(), MSG_DONTWAIT, (sockaddr*) &this->_remote_address, sizeof(this->_remote_address));
auto written = sendto(fd, buffer.data_ptr<char>(), (int) buffer.length(), MSG_DONTWAIT, (sockaddr*) &this->_remote_address, sizeof(this->_remote_address));
if(written != buffer.length()) {
if(errno == EAGAIN) {
lock.lock();
@ -179,7 +181,9 @@ void UDPSocket::callback_write(evutil_socket_t fd) {
}
return; /* this should never happen! */
}
} else {
//logger::trace(category::socket, tr("Wrote {} bytes"), buffer.length());
}
lock.lock();
if(!this->write_queue.empty() && this->event_write)
@ -191,6 +195,9 @@ void UDPSocket::send_message(const pipes::buffer_view &buffer) {
unique_lock lock(this->io_lock);
this->write_queue.push_back(buf);
if(this->event_write)
event_add(this->event_write, nullptr);
if(this->event_write) {
event_add(this->event_write, nullptr);
} else {
logger::warn(category::socket, tr("Dropping write event schedule because we have no write event."));
}
}

View File

@ -14,7 +14,7 @@ using namespace tc::connection;
VoiceSender::VoiceSender(tc::connection::VoiceConnection *handle) : handle(handle) {}
VoiceSender::~VoiceSender() {
audio::encode_event_loop->cancel(static_pointer_cast<event::EventEntry>(this->_ref.lock()));
audio::encode_event_loop->cancel(dynamic_pointer_cast<event::EventEntry>(this->_ref.lock()));
this->clear_buffer(); /* buffer might be accessed within encode_raw_frame, but this could not be trigered while this will be deallocated! */
}
@ -81,7 +81,7 @@ void VoiceSender::send_data(const void *data, size_t samples, size_t rate, size_
this->raw_audio_buffers.push_back(move(frame));
}
audio::encode_event_loop->schedule(static_pointer_cast<event::EventEntry>(this->_ref.lock()));
audio::encode_event_loop->schedule(dynamic_pointer_cast<event::EventEntry>(this->_ref.lock()));
}
void VoiceSender::send_stop() {
@ -104,7 +104,7 @@ void VoiceSender::send_stop() {
this->raw_audio_buffers.push_back(move(frame));
}
audio::encode_event_loop->schedule(static_pointer_cast<event::EventEntry>(this->_ref.lock()));
audio::encode_event_loop->schedule(dynamic_pointer_cast<event::EventEntry>(this->_ref.lock()));
}
void VoiceSender::finalize() {
@ -137,7 +137,7 @@ void VoiceSender::event_execute(const std::chrono::system_clock::time_point &poi
if(reschedule) {
log_warn(category::voice_connection, tr("Audio data decode will take longer than {} us. Enqueueing for later"), chrono::duration_cast<chrono::microseconds>(max_time).count());
audio::decode_event_loop->schedule(static_pointer_cast<event::EventEntry>(this->_ref.lock()));
audio::decode_event_loop->schedule(dynamic_pointer_cast<event::EventEntry>(this->_ref.lock()));
}
}

View File

@ -227,7 +227,7 @@ VoiceClient::VoiceClient(const std::shared_ptr<VoiceConnection>&, uint16_t clien
this->set_state(state::buffering);
}
audio::decode_event_loop->schedule(static_pointer_cast<event::EventEntry>(this->ref()));
audio::decode_event_loop->schedule(dynamic_pointer_cast<event::EventEntry>(this->ref()));
}
}
@ -368,7 +368,7 @@ void VoiceClient::process_packet(uint16_t packet_id, const pipes::buffer_view& b
codec_data.process_pending = true;
}
audio::decode_event_loop->schedule(static_pointer_cast<event::EventEntry>(this->ref()));
audio::decode_event_loop->schedule(dynamic_pointer_cast<event::EventEntry>(this->ref()));
}
void VoiceClient::cancel_replay() {
@ -376,7 +376,7 @@ void VoiceClient::cancel_replay() {
this->output_source->clear();
this->set_state(state::stopped);
audio::decode_event_loop->cancel(static_pointer_cast<event::EventEntry>(this->ref()));
audio::decode_event_loop->cancel(dynamic_pointer_cast<event::EventEntry>(this->ref()));
auto execute_lock = this->execute_lock(true);
for(auto& codec : this->codec) {
@ -549,7 +549,7 @@ void VoiceClient::event_execute(const std::chrono::system_clock::time_point &sch
if(reschedule) {
log_warn(category::voice_connection, tr("Audio data decode will take longer than {} us. Enqueueing for later"),
chrono::duration_cast<chrono::microseconds>(max_time).count());
audio::decode_event_loop->schedule(static_pointer_cast<event::EventEntry>(this->ref()));
audio::decode_event_loop->schedule(dynamic_pointer_cast<event::EventEntry>(this->ref()));
}
}

View File

@ -2,9 +2,14 @@
#include "../../logger.h"
#include <iostream>
#include <experimental/filesystem>
#ifdef WIN32
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
namespace fs = std::experimental::filesystem;
using namespace tc;
using namespace tc::ft;
using namespace std;

View File

@ -7,12 +7,14 @@
#endif
using namespace std;
#define EXPERIMENTAL_FS
#ifndef WIN32
#define EXPERIMENTAL_FS
#endif
#ifdef EXPERIMENTAL_FS
#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
#include <iostream>
namespace fs = std::experimental::filesystem;
#else
#include <filesystem>
namespace fs = std::filesystem;

View File

@ -37,9 +37,14 @@
"asar": "^2.0.1",
"cmake-js": "^4.0.1",
"ejs": "^2.7.1",
"electron-installer-windows": "^1.1.1",
"electron-packager": "8.7.2",
"electron-winstaller": "^2.7.0",
"electron-wix-msi": "^2.2.0",
"nodemon": "^1.19.4",
"platform-dependent-modules": "0.0.14",
"rc": "^1.2.8",
"rcedit": "^1.1.2",
"sass": "^1.23.2",
"typescript": "^3.7.2"
},
@ -52,11 +57,8 @@
"aws-sign2": "^0.7.0",
"aws4": "^1.8.0",
"electron": "7.1.2",
"electron-installer-windows": "^1.1.1",
"electron-navigation": "^1.5.8",
"electron-rebuild": "^1.8.6",
"electron-winstaller": "^2.7.0",
"electron-wix-msi": "^2.2.0",
"extend": "^3.0.2",
"extsprintf": "^1.4.0",
"fs-extra": "^8.1.0",
@ -70,8 +72,6 @@
"only": "0.0.2",
"psl": "^1.4.0",
"pure-uuid": "^1.5.7",
"rc": "^1.2.8",
"rcedit": "^1.1.2",
"request": "^2.47.1",
"request-progress": "^3.0.0",
"request-promise": "^4.2.5",