1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-22 22:03:25 +01:00

Makefile: little refactoring

This commit is contained in:
Ansa89 2014-07-22 09:59:44 +02:00
parent ac01d6d316
commit 1e0e93e5c6
2 changed files with 20 additions and 17 deletions

View File

@ -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)

View File

@ -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;
}
}