From 1e0e93e5c6299529c9787ac98c1cf174fb7d30e9 Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Tue, 22 Jul 2014 09:59:44 +0200 Subject: [PATCH 1/3] Makefile: little refactoring --- build/Makefile | 20 +++++++++----------- src/notify.c | 17 +++++++++++------ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/build/Makefile b/build/Makefile index 01f0486..ed4e06f 100644 --- a/build/Makefile +++ b/build/Makefile @@ -29,16 +29,14 @@ OBJ = chat.o chat_commands.o configdir.o dns.o execute.o file_senders.o notify.o OBJ += friendlist.o global_commands.o groupchat.o line_info.o input.o help.o autocomplete.o OBJ += log.o misc_tools.o prompt.o settings.o toxic.o toxic_strings.o windows.o -# Variables for audio support +# Variables for audio call support AUDIO_LIBS = libtoxav openal AUDIO_CFLAGS = -D_AUDIO -AUDIO_OBJ = device.o audio_call.o -AV_LOADED = 0 +AUDIO_OBJ = audio_call.o # Variables for sound notify support SND_NOTIFY_LIBS = openal freealut SND_NOTIFY_CFLAGS = -D_SOUND_NOTIFY -SND_NOTIFY_OBJ = # Check on wich system we are running UNAME_S = $(shell uname -s) @@ -81,7 +79,7 @@ ifneq ($(CHECK_AUDIO_LIBS), error) LIBS += $(AUDIO_LIBS) CFLAGS += $(AUDIO_CFLAGS) OBJ += $(AUDIO_OBJ) - AV_LOADED = 1 + NEED_AV = 1 else ifneq ($(MAKECMDGOALS), clean) MISSING_AUDIO_LIBS = $(shell for lib in $(AUDIO_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done) @@ -98,12 +96,7 @@ CHECK_NOTIFY_LIBS = $(shell pkg-config $(SND_NOTIFY_LIBS) || echo -n "error") ifneq ($(CHECK_NOTIFY_LIBS), error) LIBS += $(SND_NOTIFY_LIBS) CFLAGS += $(SND_NOTIFY_CFLAGS) - -# device.o is needed for both audio calls and notifications but should only be loaded once -ifneq ($(AV_LOADED), 1) - SND_NOTIFY_OBJ += device.o -endif - OBJ += $(SND_NOTIFY_OBJ) + NEED_AV = 1 else ifneq ($(MAKECMDGOALS), clean) @@ -115,6 +108,11 @@ endif endif endif +# device.o is needed for both audio calls and notifications but should only be loaded once +ifeq ($(NEED_AV), 1) + OBJ += device.o +endif + # Check if we can build Toxic CHECK_LIBS = $(shell pkg-config $(LIBS) || echo -n "error") ifneq ($(CHECK_LIBS), error) diff --git a/src/notify.c b/src/notify.c index f4f7a01..b5b903d 100644 --- a/src/notify.c +++ b/src/notify.c @@ -241,27 +241,32 @@ void set_sound(Notification sound, const char* value) int play_sound_internal(Notification what, _Bool loop) { - char* data; + /*char* data; int format; int clockrate; int buffer_size; - char loop_; + char loop_;*/ uint32_t source; uint32_t buffer; - alutLoadWAVFile((signed char*)Control.sounds[what], &format, (void**)&data, &buffer_size, &clockrate, &loop_); + //alutLoadWAVFile((signed char*)Control.sounds[what], &format, (void**)&data, &buffer_size, &clockrate, &loop_); alGenSources(1, &source); alGenBuffers(1, &buffer); - alBufferData(buffer, format, data, buffer_size, clockrate); + /*alBufferData(buffer, format, data, buffer_size, clockrate); + alSourcei(source, AL_BUFFER, buffer); + alSourcei(source, AL_LOOPING, loop); + alutUnloadWAV(format, data, buffer_size, clockrate);*/ + alutInitWithoutContext(NULL, NULL); + buffer = alutCreateBufferFromFile((const char*)Control.sounds[what]); alSourcei(source, AL_BUFFER, buffer); alSourcei(source, AL_LOOPING, loop); - alutUnloadWAV(format, data, buffer_size, clockrate); int rc = play_source(source, buffer, loop); if (rc < 0) { alSourceStop(source); alDeleteSources(1, &source); alDeleteBuffers(1,&buffer); + alutExit(); return -1; } @@ -331,4 +336,4 @@ int notify(ToxWindow* self, Notification notif, uint64_t flags) } return rc; -} \ No newline at end of file +} From 196af10d01cfc58c5d3713b354650909e5334fae Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Tue, 22 Jul 2014 12:30:35 +0200 Subject: [PATCH 2/3] Move init and exit in right place --- src/notify.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/notify.c b/src/notify.c index b5b903d..ea38b56 100644 --- a/src/notify.c +++ b/src/notify.c @@ -191,6 +191,7 @@ int play_source(uint32_t source, uint32_t buffer, _Bool looping) int init_notify(int login_cooldown) { #ifdef _SOUND_NOTIFY + alutInitWithoutContext(NULL, NULL); if (open_primary_device(output, &Control.device_idx, 48000, 20) != de_None) return -1; @@ -226,6 +227,7 @@ void terminate_notify() graceful_clear(); close_device(output, Control.device_idx); + alutExit(); #endif /* _SOUND_NOTIFY */ } @@ -241,22 +243,11 @@ void set_sound(Notification sound, const char* value) int play_sound_internal(Notification what, _Bool loop) { - /*char* data; - int format; - int clockrate; - int buffer_size; - char loop_;*/ uint32_t source; uint32_t buffer; - //alutLoadWAVFile((signed char*)Control.sounds[what], &format, (void**)&data, &buffer_size, &clockrate, &loop_); alGenSources(1, &source); alGenBuffers(1, &buffer); - /*alBufferData(buffer, format, data, buffer_size, clockrate); - alSourcei(source, AL_BUFFER, buffer); - alSourcei(source, AL_LOOPING, loop); - alutUnloadWAV(format, data, buffer_size, clockrate);*/ - alutInitWithoutContext(NULL, NULL); buffer = alutCreateBufferFromFile((const char*)Control.sounds[what]); alSourcei(source, AL_BUFFER, buffer); alSourcei(source, AL_LOOPING, loop); @@ -266,7 +257,6 @@ int play_sound_internal(Notification what, _Bool loop) alSourceStop(source); alDeleteSources(1, &source); alDeleteBuffers(1,&buffer); - alutExit(); return -1; } From 1131b732994e615ea1d2418cc31050860af53657 Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Tue, 22 Jul 2014 16:38:20 +0200 Subject: [PATCH 3/3] Update toxic.conf.5 manpage --- doc/toxic.conf.5 | 249 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 214 insertions(+), 35 deletions(-) diff --git a/doc/toxic.conf.5 b/doc/toxic.conf.5 index 3fb553f..60edd8b 100644 --- a/doc/toxic.conf.5 +++ b/doc/toxic.conf.5 @@ -8,38 +8,62 @@ file is the main configuration file for .BR toxic (1) client. .SH SYNTAX -.IB : ; +.I
+.B = { .PP -Lines starting with "#" are comments and will be ignored. +.IB : ; +.br +.IB = ; +.br + ... +.PP +.B }; +.PP +Uses syntax accepted by libconfig. +.br +Lines starting with "//" are comments and will be ignored. +.PP +Sections: +.PP +.B ui +.RS +Configurations related to user interface. .PP Keys: -.PP -.B time -.RS -Select between 24 and 12 hour time. .br -Values: 24, 12 -.RE -.PP .B timestamps .RS Enable or disable timestamps. .br -Values: 1 to enable, 0 to disable -.RE -.PP -.B autolog -.RS -Enable or disable autologging. -.br -Values: 1 to enable, 0 to disable +Values: 'true' to enable, 'false' to disable .RE .PP .B alerts .RS Enable or disable terminal alerts on events. .br -Values: 1 to enable, 0 to disable +Values: 'true' to enable, 'false' to disable +.RE +.PP +.B native_colors +.RS +Select between native terminal colors and toxic color theme. +.br +Values: 'true' for terminal colours, 'false' for toxic colours +.RE +.PP +.B autolog +.RS +Enable or disable autologging. +.br +Values: 'true' to enable, 'false' to disable +.RE +.PP +.B time_format +.RS +Select between 24 and 12 hour time. +.br +Values: 24, 12 .RE .PP .B history_size @@ -48,54 +72,209 @@ Maximum lines for chat window history. .br Values: (for example: 700) .RE -.PP -.B colour_theme -.RS -Select between toxic colour theme and native terminal colours. -.br -Values: 0 for toxic colours, 1 for terminal colours .RE .PP -.B audio_in_dev +.B audio +.RS +Configurations related to audio devices. +.PP +Keys: +.br +.B input_device .RS Audio input device. .br Values: (number correspond to "/lsdev in") .RE .PP -.B audio_out_dev +.B output_device .RS Audio output device. .br Values: (number correspond to "/lsdev out") .RE .PP +.B VAD_treshold +.RS +Voice Activity Detection treshold. +.br +Values: (recommended values are around 40.0) +.RE +.RE +.PP +.B tox +.RS +Configurations related to file transfer. +.PP +Keys: +.br .B download_path .RS Default path for downloads. .br Values: (absolute path where to store downloaded files) .RE +.RE +.PP +.B sounds +.RS +Configurations related to notification sounds. +.PP +Keys: +.br +.B error +.RS +Sound to play when an error occurs. +.br +Values: (sound file absolute path) +.RE +.PP +.B self_log_in +.RS +Sound to play when you log in. +.br +Values: (sound file absolute path) +.RE +.PP +.B self_log_out +.RS +Sound to play when you log out. +.br +Values: (sound file absolute path) +.RE +.PP +.B user_log_in +.RS +Sound to play when a contact become online. +.br +Values: (sound file absolute path) +.RE +.PP +.B user_log_out +.RS +Sound to play when a contact become offline. +.br +Values: (sound file absolute path) +.RE +.PP +.B call_incoming +.RS +Sound to play when you receive an incoming call. +.br +Values: (sound file absolute path) +.RE +.PP +.B call_outgoing +.RS +Sound to play when you start a call. +.br +Values: (sound file absolute path) +.RE +.PP +.B generic_message +.RS +Sound to play when an event occurs. +.br +Values: (sound file absolute path) +.RE +.PP +.B transfer_pending +.RS +Sound to play when you receive a file transfer request. +.br +Values: (sound file absolute path) +.RE +.PP +.B transfer_completed +.RS +Sound to play when a file transfer is completed. +.br +Values: (sound file absolute path) +.RE +.RE .SH EXAMPLES Default settings from __DATADIR__/toxic.conf.exmaple: .PP -time:24; +// SAMPLE TOXIC CONFIGURATION .br -timestamps:1; +// USES LIBCONFIG-ACCEPTED SYNTAX .br -autolog:0; +ui = { .br -alerts:1; + // true to enable timestamps, false to disable .br -history_size:700; + timestamps:true; .br -colour_theme:0; .br -audio_in_dev:0; + // true to enable terminal alerts on messages, false to disable .br -audio_out_dev:0; + alerts:true; .br -download_path:/home/USERNAME/Downloads/; + // true to use native terminal colours, false to use toxic default colour theme +.br + native_colors:false; +.br + // true to enable autologging, false to disable +.br + autolog:false; +.br + // 24 or 12 hour time +.br + time_format=24; +.br + // maximum lines for chat window history +.br + history_size=700; +.br +}; +.br +audio = { +.br + // preferred audio input device; numbers correspond to /lsdev in +.br + input_device=2; +.br + // preferred audio output device; numbers correspond to /lsdev out +.br + output_device=0; +.br + // default VAD treshold; float (recommended values are around 40) +.br + VAD_treshold=40.0; +.br +}; +.br +tox = { +.br + // where to store received files +.br + // download_path="/home/USERNAME/Downloads/"; +.br +}; +.br +sounds = { +.br + error="__DATADIR__/sounds/Error.wav"; +.br + self_log_in="__DATADIR__/sounds/LogIn.wav"; +.br + self_log_out="__DATADIR__/sounds/LogOut.wav"; +.br + user_log_in="__DATADIR__/sounds/ContactLogsIn.wav"; +.br + user_log_out="__DATADIR__/sounds/ContactLogsOut.wav"; +.br + call_incoming="__DATADIR__/sounds/IncomingCall.wav"; +.br + call_outgoing="__DATADIR__/sounds/OutgoingCall.wav"; +.br + generic_message="__DATADIR__/sounds/NewMessage.wav"; +.br + transfer_pending="__DATADIR__/sounds/TransferPending.wav"; +.br + transfer_completed="__DATADIR__/sounds/TransferComplete.wav"; +.br +}; .SH FILES .IP ~/.config/tox/toxic.conf Main configuration file.