From 6393d79f54a1a13300c5117bd3eecd44b909ecc3 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 18 Apr 2020 00:05:39 +0200 Subject: [PATCH] Small audio related updates --- github | 2 +- modules/renderer/connection/ServerConnection.ts | 7 ++++--- modules/renderer/version.ts | 2 +- native/CMakeLists.txt | 4 ++-- .../src/connection/audio/VoiceClient.cpp | 9 +++++++-- package.json | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/github b/github index 2af3e58..eb310aa 160000 --- a/github +++ b/github @@ -1 +1 @@ -Subproject commit 2af3e5879d9c5435896812710d1216df2d87c713 +Subproject commit eb310aa0eafd254324a6f921f1c055c664bf48cc diff --git a/modules/renderer/connection/ServerConnection.ts b/modules/renderer/connection/ServerConnection.ts index d429942..fd59e2e 100644 --- a/modules/renderer/connection/ServerConnection.ts +++ b/modules/renderer/connection/ServerConnection.ts @@ -65,9 +65,6 @@ class ErrorCommandHandler extends AbstractCommandHandler { return_listener["_clientinit"](new CommandResult({id: 0, message: ""})); delete return_listener["_clientinit"]; } - - if(this._handle.onconnectionstatechanged) - this._handle.onconnectionstatechanged(ConnectionState.INITIALISING, ConnectionState.CONNECTING); } else if(command.command == "notifyconnectioninforequest") { this._handle.send_command("setconnectioninfo", { @@ -171,6 +168,8 @@ export class ServerConnection extends AbstractServerConnection { } connect(address: ServerAddress, handshake: HandshakeHandler, timeout?: number): Promise { + this.updateConnectionState(ConnectionState.CONNECTING); + this._remote_address = address; this._handshake_handler = handshake; this._do_teamspeak = false; @@ -189,11 +188,13 @@ export class ServerConnection extends AbstractServerConnection { if(error != 0) { /* required to notify the handle, just a promise reject does not work */ this.client.handleDisconnect(DisconnectReason.CONNECT_FAILURE, error); + this.updateConnectionState(ConnectionState.UNCONNECTED); reject(this._native_handle.error_message(error)); return; } else { resolve(); } + this.updateConnectionState(ConnectionState.AUTHENTICATING); console.log("Remote server type: %o (%s)", this._native_handle.server_type, ServerType[this._native_handle.server_type]); if(this._native_handle.server_type == ServerType.TEAMSPEAK || this._do_teamspeak) { diff --git a/modules/renderer/version.ts b/modules/renderer/version.ts index db314ea..6047c25 100644 --- a/modules/renderer/version.ts +++ b/modules/renderer/version.ts @@ -1,4 +1,4 @@ -//FIXME! +//FIXME: This works in general, but is not a good thing namespace native { const remote = require('electron').remote; export async function client_version() : Promise { diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index a239ec3..d0678f8 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -24,8 +24,8 @@ function(setup_nodejs) set(NODEJS_URL "https://atom.io/download/atom-shell") set(NODEJS_VERSION "v8.0.0") - set(NODEJS_URL "https://nodejs.org/download/release/") - set(NODEJS_VERSION "v12.13.0") + #set(NODEJS_URL "https://nodejs.org/download/release/") + #set(NODEJS_VERSION "v12.13.0") find_package(NodeJS REQUIRED) diff --git a/native/serverconnection/src/connection/audio/VoiceClient.cpp b/native/serverconnection/src/connection/audio/VoiceClient.cpp index 0d8861f..afaafa9 100644 --- a/native/serverconnection/src/connection/audio/VoiceClient.cpp +++ b/native/serverconnection/src/connection/audio/VoiceClient.cpp @@ -465,7 +465,7 @@ void VoiceClient::event_execute(const std::chrono::system_clock::time_point &sch assert(!replay_head); /* could not be set, else prv_head would be set */ //No packet found here, test if we've more than n packets in a row somewhere -#define SKIP_SEQ_LENGTH (1) +#define SKIP_SEQ_LENGTH (3) EncodedBuffer* skip_ptr[SKIP_SEQ_LENGTH + 1]; memset(skip_ptr, 0, sizeof(skip_ptr)); skip_ptr[0] = audio_codec.pending_buffers; @@ -484,7 +484,7 @@ void VoiceClient::event_execute(const std::chrono::system_clock::time_point &sch } if(skip_ptr[SKIP_SEQ_LENGTH]) { - /* we've tree packets in a row */ + /* we've three packets in a row */ replay_head = audio_codec.pending_buffers; audio_codec.pending_buffers = skip_ptr[SKIP_SEQ_LENGTH]; skip_ptr[SKIP_SEQ_LENGTH - 1]->next = nullptr; @@ -542,6 +542,8 @@ void VoiceClient::event_execute(const std::chrono::system_clock::time_point &sch if(replay_head->buffer.empty()) { this->set_state(state::stopping); log_debug(category::voice_connection, tr("Client {} send a stop signal. Flushing stream and stopping"), this->_client_id); + } else if(local_last_pid > replay_head->packet_id) { + log_debug(category::voice_connection, tr("Client {} tried to replay too old voice chunk. Current id is {}, attempted chunk id is {}. Dropping buffer."), this->_client_id, local_last_pid, replay_head->packet_id); } else { auto lost_packets = packet_id_diff(local_last_pid, replay_head->packet_id) - 1; if(lost_packets > 6) { @@ -567,7 +569,10 @@ void VoiceClient::event_execute(const std::chrono::system_clock::time_point &sch } local_last_pid = replay_head->packet_id; + + auto last_head = replay_head; replay_head = replay_head->next; + delete last_head; } lock.lock(); //Check for more packets //TODO: Check for timeout? diff --git a/package.json b/package.json index 14126b2..d666e34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "TeaClient", - "version": "1.4.5", + "version": "1.4.5-2", "description": "", "main": "main.js", "scripts": {