Fixed some audio related issues with the client

canary
WolverinDEV 2020-02-09 21:42:49 +01:00
parent b4433a0609
commit eae62b98f7
4 changed files with 21 additions and 37 deletions

View File

@ -40,7 +40,7 @@ namespace events {
off(handler_or_events, handler?) {
if(typeof handler_or_events === "function") {
for(const key of Object.keys(this.handler))
this.handler[key].remove(handler);
this.handler[key].remove(handler_or_events);
} else {
if(!Array.isArray(handler_or_events))
handler_or_events = [handler_or_events];

View File

@ -147,15 +147,20 @@ async function initialize_app() {
if(!audio.player.initialize())
console.warn(tr("Failed to initialize audio controller!"));
if(audio.player.set_master_volume)
audio.player.set_master_volume(settings.global(Settings.KEY_SOUND_MASTER) / 100);
else
log.warn(LogCategory.GENERAL, tr("Client does not support audio.player.set_master_volume()... May client is too old?"));
if(audio.recorder.device_refresh_available())
await audio.recorder.refresh_devices();
audio.player.on_ready(() => {
if(audio.player.set_master_volume)
audio.player.on_ready(() => audio.player.set_master_volume(settings.global(Settings.KEY_SOUND_MASTER) / 100));
else
log.warn(LogCategory.GENERAL, tr("Client does not support audio.player.set_master_volume()... May client is too old?"));
if(audio.recorder.device_refresh_available())
audio.recorder.refresh_devices();
});
default_recorder = new RecorderProfile("default");
await default_recorder.initialize();
default_recorder.initialize().catch(error => {
log.error(LogCategory.AUDIO, tr("Failed to initialize default recorder: %o"), error);
});
sound.initialize().then(() => {
log.info(LogCategory.AUDIO, tr("Sounds initialized"));

View File

@ -51,8 +51,6 @@ class RecorderProfile {
this.name = name;
this.volatile = typeof(volatile) === "boolean" ? volatile : false;
this.initialize_input();
this._ppt_hook = {
callback_release: () => {
if(this._ppt_timeout)
@ -80,18 +78,11 @@ class RecorderProfile {
}
async initialize() : Promise<void> {
await this.load();
await this.reinitialize_filter();
//Why we started directly after initialize?
//After we connect to a server the ConnectionHandler will automatically
//start the VoiceRecorder as soon we've a voice bridge.
/*
try {
await this.input.start();
} catch(error) {
console.warn(tr("Failed to start recorder after initialize (%o)"), error);
}
*/
audio.player.on_ready(async () => {
this.initialize_input();
await this.load();
await this.reinitialize_filter();
});
}
private initialize_input() {
@ -107,19 +98,6 @@ class RecorderProfile {
if(this.callback_stop)
this.callback_stop();
};
/*
this.input.callback_state_change = () => {
const new_state = this.input.current_state() === audio.recorder.InputState.RECORDING || this.input.current_state() === audio.recorder.InputState.DRY;
if(new_state === this.record_supported)
return;
this.record_supported = new_state;
if(this.callback_support_change)
this.callback_support_change();
}
*/
}
private async load() {
@ -163,12 +141,13 @@ class RecorderProfile {
}
private save(enforce?: boolean) {
if(enforce || !this.volatile) {
if(enforce || !this.volatile)
settings.changeGlobal(Settings.FN_PROFILE_RECORD(this.name), this.config);
}
}
private async reinitialize_filter() {
if(!this.input) return;
this.input.clear_filter();
if(this._ppt_hook_registered) {
ppt.unregister_key_hook(this._ppt_hook);