mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 21:23:01 +01:00
Makefile: little refactoring
This commit is contained in:
parent
ac01d6d316
commit
1e0e93e5c6
@ -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 += 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
|
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_LIBS = libtoxav openal
|
||||||
AUDIO_CFLAGS = -D_AUDIO
|
AUDIO_CFLAGS = -D_AUDIO
|
||||||
AUDIO_OBJ = device.o audio_call.o
|
AUDIO_OBJ = audio_call.o
|
||||||
AV_LOADED = 0
|
|
||||||
|
|
||||||
# Variables for sound notify support
|
# Variables for sound notify support
|
||||||
SND_NOTIFY_LIBS = openal freealut
|
SND_NOTIFY_LIBS = openal freealut
|
||||||
SND_NOTIFY_CFLAGS = -D_SOUND_NOTIFY
|
SND_NOTIFY_CFLAGS = -D_SOUND_NOTIFY
|
||||||
SND_NOTIFY_OBJ =
|
|
||||||
|
|
||||||
# Check on wich system we are running
|
# Check on wich system we are running
|
||||||
UNAME_S = $(shell uname -s)
|
UNAME_S = $(shell uname -s)
|
||||||
@ -81,7 +79,7 @@ ifneq ($(CHECK_AUDIO_LIBS), error)
|
|||||||
LIBS += $(AUDIO_LIBS)
|
LIBS += $(AUDIO_LIBS)
|
||||||
CFLAGS += $(AUDIO_CFLAGS)
|
CFLAGS += $(AUDIO_CFLAGS)
|
||||||
OBJ += $(AUDIO_OBJ)
|
OBJ += $(AUDIO_OBJ)
|
||||||
AV_LOADED = 1
|
NEED_AV = 1
|
||||||
else
|
else
|
||||||
ifneq ($(MAKECMDGOALS), clean)
|
ifneq ($(MAKECMDGOALS), clean)
|
||||||
MISSING_AUDIO_LIBS = $(shell for lib in $(AUDIO_LIBS) ; do if ! pkg-config $$lib ; then echo $$lib ; fi ; done)
|
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)
|
ifneq ($(CHECK_NOTIFY_LIBS), error)
|
||||||
LIBS += $(SND_NOTIFY_LIBS)
|
LIBS += $(SND_NOTIFY_LIBS)
|
||||||
CFLAGS += $(SND_NOTIFY_CFLAGS)
|
CFLAGS += $(SND_NOTIFY_CFLAGS)
|
||||||
|
NEED_AV = 1
|
||||||
# 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)
|
|
||||||
|
|
||||||
else
|
else
|
||||||
ifneq ($(MAKECMDGOALS), clean)
|
ifneq ($(MAKECMDGOALS), clean)
|
||||||
@ -115,6 +108,11 @@ endif
|
|||||||
endif
|
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 if we can build Toxic
|
||||||
CHECK_LIBS = $(shell pkg-config $(LIBS) || echo -n "error")
|
CHECK_LIBS = $(shell pkg-config $(LIBS) || echo -n "error")
|
||||||
ifneq ($(CHECK_LIBS), error)
|
ifneq ($(CHECK_LIBS), error)
|
||||||
|
15
src/notify.c
15
src/notify.c
@ -241,27 +241,32 @@ void set_sound(Notification sound, const char* value)
|
|||||||
|
|
||||||
int play_sound_internal(Notification what, _Bool loop)
|
int play_sound_internal(Notification what, _Bool loop)
|
||||||
{
|
{
|
||||||
char* data;
|
/*char* data;
|
||||||
int format;
|
int format;
|
||||||
int clockrate;
|
int clockrate;
|
||||||
int buffer_size;
|
int buffer_size;
|
||||||
char loop_;
|
char loop_;*/
|
||||||
uint32_t source;
|
uint32_t source;
|
||||||
uint32_t buffer;
|
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);
|
alGenSources(1, &source);
|
||||||
alGenBuffers(1, &buffer);
|
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_BUFFER, buffer);
|
||||||
alSourcei(source, AL_LOOPING, loop);
|
alSourcei(source, AL_LOOPING, loop);
|
||||||
alutUnloadWAV(format, data, buffer_size, clockrate);
|
|
||||||
|
|
||||||
int rc = play_source(source, buffer, loop);
|
int rc = play_source(source, buffer, loop);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
alSourceStop(source);
|
alSourceStop(source);
|
||||||
alDeleteSources(1, &source);
|
alDeleteSources(1, &source);
|
||||||
alDeleteBuffers(1,&buffer);
|
alDeleteBuffers(1,&buffer);
|
||||||
|
alutExit();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user