This commit is contained in:
WolverinDEV 2019-10-19 11:59:49 +02:00
commit 566006f8ca
15 changed files with 44 additions and 36 deletions

View File

@ -85,7 +85,10 @@ include_directories(${ed25519_INCLUDE_DIR})
find_package(ThreadPool REQUIRED)
include_directories(${ThreadPool_INCLUDE_DIR})
if (WIN32)
add_compile_options(/NODEFAULTLIB:ThreadPoolStatic)
add_definitions(-DWINDOWS) #Required by ThreadPool
add_definitions(-D_CRT_SECURE_NO_WARNINGS) # Let windows allow strerror
add_definitions(-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING) # For the FMT library
endif ()
find_package(Soxr REQUIRED)

View File

@ -69,7 +69,7 @@ bool AudioInput::open_device(std::string& error, PaDeviceIndex index) {
parameters.sampleFormat = paFloat32;
parameters.suggestedLatency = this->_current_device->defaultLowOutputLatency;
auto err = Pa_OpenStream(&this->input_stream, &parameters, nullptr, this->_sample_rate, paFramesPerBufferUnspecified, paClipOff, &AudioInput::_audio_callback, this);
auto err = Pa_OpenStream(&this->input_stream, &parameters, nullptr, (double) this->_sample_rate, paFramesPerBufferUnspecified, paClipOff, &AudioInput::_audio_callback, this);
if(err != paNoError) {
error = "Pa_OpenStream returned " + to_string(err);
return false;

View File

@ -34,7 +34,7 @@ ssize_t AudioOutputSource::pop_samples(void *buffer, size_t samples) {
}
sample_count -= sc;
buf->sample_index += sc;
buf->sample_index += (uint16_t) sc;
if(buf->sample_index == buf->sample_size)
this->sample_buffers.pop_front();
@ -258,7 +258,7 @@ bool AudioOutput::open_device(std::string& error, PaDeviceIndex index) {
output_parameters.sampleFormat = paFloat32;
output_parameters.suggestedLatency = this->_current_device->defaultLowOutputLatency;
auto err = Pa_OpenStream(&output_stream, nullptr, &output_parameters, this->_sample_rate, paFramesPerBufferUnspecified, paClipOff, &AudioOutput::_audio_callback, this);
auto err = Pa_OpenStream(&output_stream, nullptr, &output_parameters, (double) this->_sample_rate, paFramesPerBufferUnspecified, paClipOff, &AudioOutput::_audio_callback, this);
if(err != paNoError) {
error = "Pa_OpenStream returned " + to_string(err);
return false;

View File

@ -9,7 +9,7 @@ using namespace tc::audio;
AudioResampler::AudioResampler(size_t irate, size_t orate, size_t channels) : _input_rate(irate), _output_rate(orate), _channels(channels) {
if(this->input_rate() != this->output_rate()) {
soxr_error_t error;
this->soxr_handle = soxr_create(this->_input_rate, this->_output_rate, (unsigned) this->_channels, &error, nullptr, nullptr, nullptr);
this->soxr_handle = soxr_create((double) this->_input_rate, (double) this->_output_rate, (unsigned) this->_channels, &error, nullptr, nullptr, nullptr);
if(!this->soxr_handle) {
log_error(category::audio, tr("Failed to create soxr resampler: {}. Input: {}; Output: {}; Channels: {}"), error, this->_input_rate, this->_output_rate, this->_channels);

View File

@ -81,7 +81,7 @@ ssize_t OpusConverter::decode_lost(std::string &error, size_t packets) {
auto buffer = (float*) malloc(this->_frame_size * this->_channels * sizeof(float));
while (packets-- > 0) {
auto result = opus_decode_float(this->decoder, nullptr, 0, buffer, this->_frame_size, false);
auto result = opus_decode_float(this->decoder, nullptr, 0, buffer, (int) this->_frame_size, false);
if(result < OPUS_OK)
log_warn(category::audio, tr("Opus decode lost resulted in error: {}"), result);
}

View File

@ -21,7 +21,7 @@ namespace tc {
void reset_decoder() override;
ssize_t encode(std::string & /* error */, const void * /* source */, void * /* target */, size_t /* target size */) override;
ssize_t decode(std::string & /* error */, const void */* source */, size_t /* source size */, void *pVoid1) override;
ssize_t decode(std::string & /* error */, const void * /* source */, size_t /* source size */, void *pVoid1) override;
ssize_t decode_lost(std::string &string, size_t /* packets */) override;

View File

@ -46,9 +46,9 @@ bool ThresholdFilter::process(const void *_buffer) {
auto percentage = this->analyze(_buffer, channel);
if(channel == 0)
value = percentage;
value = (float) percentage;
else
value = merge_ab(value, percentage, 100);
value = merge_ab(value, (float) percentage, 100);
}
auto last_level = this->_current_level;

View File

@ -33,12 +33,12 @@ bool VadFilter::initialize(std::string &error, size_t mode, size_t margin) {
return false;
}
if(fvad_set_sample_rate(this->_vad_handle, this->_sample_rate) != 0) {
if(fvad_set_sample_rate(this->_vad_handle, (int) this->_sample_rate) != 0) {
error = "invalid sample rate. Sample rate must be one of [8000, 16000, 32000 and 48000]";
return false;
}
if(fvad_set_mode(this->_vad_handle, mode) != 0) {
if(fvad_set_mode(this->_vad_handle, (int) mode) != 0) {
error = "failed to set mode";
return false;
}

View File

@ -63,7 +63,7 @@ namespace tc {
inline std::shared_ptr<AudioConsumer> native_consumer() { return this->_handle; }
std::mutex native_read_callback_lock;
std::function<void(const void */* buffer */, size_t /* samples */)> native_read_callback;
std::function<void(const void * /* buffer */, size_t /* samples */)> native_read_callback;
private:
AudioRecorderWrapper* _recorder;

View File

@ -76,7 +76,7 @@ NAN_MODULE_INIT(init) {
#ifndef WIN32
logger::info(category::general, tr("Hello World from C. PPID: {}, PID: {}"), getppid(), getpid());
#else
logger::info(category::general, tr("Hello World from C."), getppid(), getpid());
logger::info(category::general, tr("Hello World from C. PID: {}"), _getpid());
#endif
/*

View File

@ -126,7 +126,7 @@ void ServerConnection::initialize() {
argv[0] = Nan::New<v8::Number>(error_id);
if(this->callback_connect)
this->callback_connect->Call(1, argv);
Nan::Call(*this->callback_connect, 1, argv);
this->callback_connect = nullptr;
}
});
@ -138,7 +138,7 @@ void ServerConnection::initialize() {
argv[0] = Nan::New<v8::Number>(error_id);
if(this->callback_disconnect)
this->callback_disconnect->Call(1, argv);
Nan::Call(*this->callback_disconnect, 1, argv);
this->callback_disconnect = nullptr;
});
@ -253,7 +253,7 @@ NAN_METHOD(ServerConnection::connect) {
if(identity_key->IsString()) {
auto& identity = this->protocol_handler->get_identity_key();
auto key = base64::decode(*Nan::Utf8String(identity_key->ToString(Nan::GetCurrentContext()).ToLocalChecked()));
if(ecc_import((u_char*) key.data(), key.length(), &identity) != CRYPT_OK) {
if(ecc_import((u_char*) key.data(), (unsigned long) key.length(), &identity) != CRYPT_OK) {
Nan::ThrowError(tr("failed to import identity"));
return;
}
@ -272,7 +272,7 @@ NAN_METHOD(ServerConnection::connect) {
sockaddr_storage remote_address{};
/* resolve address */
{
addrinfo hints{}, *result, *p;
addrinfo hints{}, *result;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
@ -355,7 +355,7 @@ NAN_METHOD(ServerConnection::error_message) {
return;
}
auto error = this->errors.get_message(info[0]->IntegerValue(Nan::GetCurrentContext()).FromMaybe(0));
auto error = this->errors.get_message((ErrorHandler::error_id) info[0]->IntegerValue(Nan::GetCurrentContext()).FromMaybe(0));
info.GetReturnValue().Set(Nan::New<v8::String>(error).ToLocalChecked());
}
@ -404,7 +404,7 @@ NAN_METHOD(ServerConnection::send_command) {
ts::Command cmd(*Nan::Utf8String(command));
for(size_t index = 0; index < arguments->Length(); index++) {
auto object = arguments->Get(index);
auto object = arguments->Get((uint32_t) index);
if(!object->IsObject()) {
Nan::ThrowError(Nan::New<v8::String>("invalid parameter (" + to_string(index) + ")").ToLocalChecked());
return;
@ -435,7 +435,7 @@ NAN_METHOD(ServerConnection::send_command) {
for(size_t index = 0; index < switches->Length(); index++) {
auto object = switches->Get(index);
auto object = switches->Get((uint32_t) index);
if(!object->IsString()) {
Nan::ThrowError(Nan::New<v8::String>("invalid switch (" + to_string(index) + ")").ToLocalChecked());
return;
@ -638,7 +638,7 @@ void ServerConnection::_execute_callback_commands() {
v8::Local<v8::Value> arguments[3];
arguments[0] = Nan::New<v8::String>(next_command->command()).ToLocalChecked();
auto parameters = Nan::New<v8::Array>(next_command->bulkCount());
auto parameters = Nan::New<v8::Array>((int) next_command->bulkCount());
for(size_t index = 0; index < next_command->bulkCount(); index++) {
auto object = Nan::New<v8::Object>();
auto& bulk = next_command->operator[](index);
@ -646,15 +646,15 @@ void ServerConnection::_execute_callback_commands() {
for(const auto& key : bulk.keys())
Nan::Set(object, Nan::New<v8::String>(key).ToLocalChecked(), Nan::New<v8::String>(bulk[key].string()).ToLocalChecked());
parameters->Set(index, object);
parameters->Set((uint32_t) index, object);
}
arguments[1] = parameters;
auto switched = Nan::New<v8::Array>(next_command->parms().size());
auto switched = Nan::New<v8::Array>((int) next_command->parms().size());
for(size_t index = 0; index < next_command->parms().size(); index++) {
auto& key = next_command->parms()[index];
parameters->Set(index, Nan::New<v8::String>(key).ToLocalChecked());
parameters->Set((uint32_t) index, Nan::New<v8::String>(key).ToLocalChecked());
}
arguments[2] = switched;

View File

@ -11,7 +11,7 @@ namespace tc {
}
class AudioResampler;
struct AudioOutputSource;
class AudioOutputSource;
}
namespace connection {

View File

@ -39,7 +39,7 @@ bool Transfer::initialize(std::string &error) {
/* resolve address */
{
addrinfo hints{}, *result, *p;
addrinfo hints{}, *result;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
@ -63,7 +63,7 @@ bool Transfer::initialize(std::string &error) {
}
log_info(category::file_transfer, tr("Setting remote port to {}"), this->_options->remote_port);
this->_socket = ::socket(this->remote_address.ss_family, SOCK_STREAM | SOCK_NONBLOCK, 0);
this->_socket = (int) ::socket(this->remote_address.ss_family, SOCK_STREAM | SOCK_NONBLOCK, 0);
if(this->_socket < 0) {
this->finalize();
error = tr("failed to spawn socket");
@ -225,7 +225,7 @@ void Transfer::callback_read(short flags) {
int64_t buffer_length = 1024;
char buffer[1024];
buffer_length = recv(this->_socket, buffer, buffer_length, MSG_DONTWAIT);
buffer_length = recv(this->_socket, buffer, (int) buffer_length, MSG_DONTWAIT);
if(buffer_length < 0) {
#ifdef WIN32
auto error = WSAGetLastError();

View File

@ -104,9 +104,14 @@ using namespace std;
//https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
int get_uuid(uint8_t* uuid) {
#ifdef WIN32
typedef DWORD api_size_t;
#else
typedef size_t api_size_t;
#endif
unique_ptr<SMBIOSDataHeader, decltype(::free)*> smbios_data{ nullptr, ::free };
size_t smbios_size = 0;
size_t bytes_written = 0;
api_size_t smbios_size = 0;
api_size_t bytes_written = 0;
// Query size of SMBIOS data.
smbios_size = GetSystemFirmwareTable('RSMB', 0, nullptr, 0);
@ -141,7 +146,7 @@ int get_uuid(uint8_t* uuid) {
}
ptr = ptr + header->length; // point to struct end
while (0 != (*ptr | *(ptr + 1)) && *ptr < (uint8_t) &*smbios_data + smbios_data->length)
while (0 != (*ptr | *(ptr + 1)) && ptr + 1 < (uint8_t*) &*smbios_data + smbios_data->length)
ptr++; // skip string area
ptr += 2;
@ -181,7 +186,7 @@ inline bool generate_uuid(std::string& result, uint32_t& check_sum) {
{
crc32_state state;
crc32_init(&state);
crc32_update(&state, (u_char*) result.data(), result.length());
crc32_update(&state, (uint8_t*) result.data(), (unsigned long) result.length());
crc32_finish(&state, &check_sum, sizeof(check_sum));
}
@ -192,7 +197,7 @@ inline bool generate_uuid(std::string& result, uint32_t& check_sum) {
inline bool check_uuid(std::string& uuid, uint32_t check_sum) {
crc32_state state;
crc32_init(&state);
crc32_update(&state, (uint8_t*) uuid.data(), uuid.length());
crc32_update(&state, (uint8_t*) uuid.data(), (unsigned long) uuid.length());
uint32_t result;
crc32_finish(&state, &result, sizeof(result));

View File

@ -27,7 +27,7 @@
"@types/electron-packager": "8.7.2",
"@types/fs-extra": "^8.0.0",
"@types/jquery": "^3.3.31",
"@types/request": "^2.48.2",
"@types/request": "^2.48.3",
"@types/request-promise": "^4.1.44",
"@types/tar-stream": "^1.6.1",
"asar": "^2.0.1",
@ -36,8 +36,8 @@
"electron-packager": "8.7.2",
"nodemon": "^1.19.2",
"platform-dependent-modules": "0.0.14",
"sass": "^1.22.10",
"typescript": "^3.6.2"
"sass": "^1.22.12",
"typescript": "^3.6.3"
},
"dependencies": {
"@types/minimist": "^1.2.0",
@ -64,7 +64,7 @@
"nan": "^2.14.0",
"node-ssh": "^6.0.0",
"only": "0.0.2",
"psl": "^1.3.1",
"psl": "^1.4.0",
"pure-uuid": "^1.5.7",
"rc": "^1.2.8",
"rcedit": "^1.1.2",