mirror of
https://github.com/Tha14/toxic.git
synced 2025-06-20 13:36:36 +02:00
Merge pull request #193 from Ansa89/makefile-fix
Makefile: little refactoring
This commit is contained in:
13
src/notify.c
13
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,21 +243,14 @@ 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);
|
||||
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) {
|
||||
@ -333,4 +328,4 @@ int notify(ToxWindow* self, Notification notif, uint64_t flags)
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user