Added some updates
This commit is contained in:
parent
95e1e49fad
commit
c411324d8a
@ -26,6 +26,10 @@ function spawn_main_window(entry_point: string) {
|
|||||||
main_window = new BrowserWindow({
|
main_window = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
|
|
||||||
|
minHeight: 600,
|
||||||
|
minWidth: 600,
|
||||||
|
|
||||||
show: false,
|
show: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
webSecurity: false,
|
webSecurity: false,
|
||||||
|
@ -49,7 +49,7 @@ export namespace _audio {
|
|||||||
this.connection.client.update_voice_status(undefined);
|
this.connection.client.update_voice_status(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
recorder.callback_start = this.handleVoiceStarted.bind(this);
|
recorder.callback_start = this.on_voice_started.bind(this);
|
||||||
recorder.callback_stop = this.handleVoiceEnded.bind(this);
|
recorder.callback_stop = this.handleVoiceEnded.bind(this);
|
||||||
|
|
||||||
recorder.callback_support_change = () => {
|
recorder.callback_support_change = () => {
|
||||||
@ -88,10 +88,22 @@ export namespace _audio {
|
|||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleVoiceStarted() {
|
private on_voice_started() {
|
||||||
const chandler = this.connection.client;
|
const chandler = this.connection.client;
|
||||||
console.log(tr("Local voice started"));
|
if(chandler.client_status.input_muted) {
|
||||||
chandler.getClient().speaking = true;
|
/* evil hack due to the settings :D */
|
||||||
|
log.warn(LogCategory.VOICE, tr("Received local voice started event, even thou we're muted! Do not send any voice."));
|
||||||
|
if(this.handle) {
|
||||||
|
this.handle.enable_voice_send(false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info(LogCategory.VOICE, tr("Local voice started"));
|
||||||
|
this.handle.enable_voice_send(true);
|
||||||
|
|
||||||
|
const ch = chandler.getClient();
|
||||||
|
if(ch) ch.speaking = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
connected(): boolean {
|
connected(): boolean {
|
||||||
|
3
native/serverconnection/exports/exports.d.ts
vendored
3
native/serverconnection/exports/exports.d.ts
vendored
@ -42,6 +42,9 @@ declare module "teaclient_connection" {
|
|||||||
|
|
||||||
get_encoder_codec() : number;
|
get_encoder_codec() : number;
|
||||||
set_encoder_codec(codec: number);
|
set_encoder_codec(codec: number);
|
||||||
|
|
||||||
|
/* could may throw an exception when the underlying voice sender has been deallocated */
|
||||||
|
enable_voice_send(flag: boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NativeServerConnection {
|
export interface NativeServerConnection {
|
||||||
|
@ -53,6 +53,10 @@ bool VoiceSender::initialize_codec(std::string& error, connection::codec::value
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoiceSender::set_voice_send_enabled(bool flag) {
|
||||||
|
this->voice_send_enabled = flag;
|
||||||
|
}
|
||||||
|
|
||||||
void VoiceSender::send_data(const void *data, size_t samples, size_t rate, size_t channels) {
|
void VoiceSender::send_data(const void *data, size_t samples, size_t rate, size_t channels) {
|
||||||
unique_lock lock(this->_execute_lock);
|
unique_lock lock(this->_execute_lock);
|
||||||
if(!this->handle) {
|
if(!this->handle) {
|
||||||
@ -61,6 +65,10 @@ void VoiceSender::send_data(const void *data, size_t samples, size_t rate, size_
|
|||||||
}
|
}
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
|
if(!this->voice_send_enabled) {
|
||||||
|
log_warn(category::voice_connection, tr("Dropping raw audio frame because voice sending has been disabled!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto frame = make_unique<AudioFrame>();
|
auto frame = make_unique<AudioFrame>();
|
||||||
frame->sample_rate = rate;
|
frame->sample_rate = rate;
|
||||||
|
@ -31,6 +31,8 @@ namespace tc {
|
|||||||
void finalize();
|
void finalize();
|
||||||
void send_data(const void* /* buffer */, size_t /* samples */, size_t /* sample rate */, size_t /* channels */);
|
void send_data(const void* /* buffer */, size_t /* samples */, size_t /* sample rate */, size_t /* channels */);
|
||||||
void send_stop();
|
void send_stop();
|
||||||
|
|
||||||
|
void set_voice_send_enabled(bool /* flag */);
|
||||||
private:
|
private:
|
||||||
std::weak_ptr<VoiceSender> _ref;
|
std::weak_ptr<VoiceSender> _ref;
|
||||||
VoiceConnection* handle;
|
VoiceConnection* handle;
|
||||||
@ -79,6 +81,8 @@ namespace tc {
|
|||||||
std::mutex raw_audio_buffer_lock;
|
std::mutex raw_audio_buffer_lock;
|
||||||
std::deque<std::unique_ptr<AudioFrame>> raw_audio_buffers;
|
std::deque<std::unique_ptr<AudioFrame>> raw_audio_buffers;
|
||||||
|
|
||||||
|
bool voice_send_enabled = false;
|
||||||
|
|
||||||
void encode_raw_frame(const std::unique_ptr<AudioFrame>&);
|
void encode_raw_frame(const std::unique_ptr<AudioFrame>&);
|
||||||
void event_execute(const std::chrono::system_clock::time_point &point) override;
|
void event_execute(const std::chrono::system_clock::time_point &point) override;
|
||||||
};
|
};
|
||||||
|
@ -47,6 +47,8 @@ NAN_MODULE_INIT(VoiceConnectionWrap::Init) {
|
|||||||
Nan::SetPrototypeMethod(klass, "get_encoder_codec", VoiceConnectionWrap::_get_encoder_codec);
|
Nan::SetPrototypeMethod(klass, "get_encoder_codec", VoiceConnectionWrap::_get_encoder_codec);
|
||||||
Nan::SetPrototypeMethod(klass, "set_encoder_codec", VoiceConnectionWrap::_set_encoder_codec);
|
Nan::SetPrototypeMethod(klass, "set_encoder_codec", VoiceConnectionWrap::_set_encoder_codec);
|
||||||
|
|
||||||
|
Nan::SetPrototypeMethod(klass, "enable_voice_send", VoiceConnectionWrap::_enable_voice_send);
|
||||||
|
|
||||||
constructor().Reset(Nan::GetFunction(klass).ToLocalChecked());
|
constructor().Reset(Nan::GetFunction(klass).ToLocalChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +236,29 @@ NAN_METHOD(VoiceConnectionWrap::_set_encoder_codec) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->set_encoder_codec(info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0));
|
handle->set_encoder_codec((uint8_t) info[0]->NumberValue(Nan::GetCurrentContext()).FromMaybe(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
NAN_METHOD(VoiceConnectionWrap::_enable_voice_send) {
|
||||||
|
auto _this = ObjectWrap::Unwrap<VoiceConnectionWrap>(info.Holder());
|
||||||
|
auto handle = _this->handle.lock();
|
||||||
|
if(!handle) {
|
||||||
|
Nan::ThrowError("handle has been deallocated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(info.Length() != 1 || !info[0]->IsBoolean()) {
|
||||||
|
Nan::ThrowError("Invalid arguments");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sender = handle->voice_sender();
|
||||||
|
if(!sender) {
|
||||||
|
Nan::ThrowError("Voice sender has been deallocated");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender->set_voice_send_enabled(info[0]->BooleanValue(info.GetIsolate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ namespace tc {
|
|||||||
|
|
||||||
static NAN_METHOD(_get_encoder_codec);
|
static NAN_METHOD(_get_encoder_codec);
|
||||||
static NAN_METHOD(_set_encoder_codec);
|
static NAN_METHOD(_set_encoder_codec);
|
||||||
|
static NAN_METHOD(_enable_voice_send);
|
||||||
|
|
||||||
void release_recorder();
|
void release_recorder();
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"start": "electron --js-flags='--expose-gc' --debug --dev-tools --disable-hardware-acceleration .",
|
"start": "electron --js-flags='--expose-gc' --debug --dev-tools --disable-hardware-acceleration .",
|
||||||
"start-d": "electron . --disable-hardware-acceleration --debug -t -u http://clientapi.teaspeak.dev/",
|
"start-d": "electron . --disable-hardware-acceleration --debug -t -u http://clientapi.teaspeak.dev/",
|
||||||
"start-wd": "electron . --disable-hardware-acceleration --debug -t -su http://localhost/TeaWeb/client-api/environment/",
|
"start-wd": "electron . --disable-hardware-acceleration --debug -t -su http://localhost/TeaWeb/client-api/environment/",
|
||||||
"start-d1": "electron . --disable-hardware-acceleration --debug -t --gdb -su http://clientapi.teaspeak.de/ --updater-ui-loader_type=0",
|
"start-d1": "electron . --disable-hardware-acceleration --debug -t --gdb -su http://clientapi.teaspeak.dev/ --updater-ui-loader_type=0",
|
||||||
"start-n": "electron . -t --disable-hardware-acceleration --no-single-instance -u=https://clientapi.teaspeak.de/ -d --updater-ui-loader_type=0",
|
"start-n": "electron . -t --disable-hardware-acceleration --no-single-instance -u=https://clientapi.teaspeak.de/ -d --updater-ui-loader_type=0",
|
||||||
"start-01": "electron . --updater-channel=test -u=http://dev.clientapi.teaspeak.de/ -d --updater-ui-loader_type=0 --updater-local-version=1.0.1",
|
"start-01": "electron . --updater-channel=test -u=http://dev.clientapi.teaspeak.de/ -d --updater-ui-loader_type=0 --updater-local-version=1.0.1",
|
||||||
"compile-sass": "sass --update .:.",
|
"compile-sass": "sass --update .:.",
|
||||||
|
Loading…
Reference in New Issue
Block a user