1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-01 19:16:45 +02:00

Fixed sounds not playing

This commit is contained in:
mannol
2014-07-25 02:12:32 +02:00
parent 8d8df585ad
commit 3a1e23a3ff
3 changed files with 24 additions and 21 deletions

View File

@ -235,10 +235,12 @@ void terminate_notify()
#ifdef _SOUND_NOTIFY
int set_sound(Notification sound, const char* value)
{
if (sound == silent) return 0;
free(Control.sounds[sound]);
size_t len = strlen(value) + 1;
Control.sounds[sound] = calloc(1, len);
Control.sounds[sound] = calloc(len, 1);
memcpy(Control.sounds[sound], value, len);
struct stat buf;
@ -252,7 +254,7 @@ int play_sound_internal(Notification what, _Bool loop)
alGenSources(1, &source);
alGenBuffers(1, &buffer);
buffer = alutCreateBufferFromFile((const char*)Control.sounds[what]);
buffer = alutCreateBufferFromFile(Control.sounds[what]);
alSourcei(source, AL_BUFFER, buffer);
alSourcei(source, AL_LOOPING, loop);
@ -310,6 +312,13 @@ static int m_play_sound(Notification notif, uint64_t flags)
int notify(ToxWindow* self, Notification notif, uint64_t flags)
{
/* Consider colored notify as primary */
if (self && self->alert == WINDOW_ALERT_NONE) {
if (flags & NT_WNDALERT_0) self->alert = WINDOW_ALERT_0;
else if (flags & NT_WNDALERT_1) self->alert = WINDOW_ALERT_1;
else if (flags & NT_WNDALERT_2) self->alert = WINDOW_ALERT_2;
}
if (flags & NT_NOFOCUS && Control.this_window == get_focused_window_id())
return -1;
@ -325,11 +334,5 @@ int notify(ToxWindow* self, Notification notif, uint64_t flags)
/* TODO: pop notify window */
}
if (self && self->alert == WINDOW_ALERT_NONE) {
if (flags & NT_WNDALERT_0) self->alert = WINDOW_ALERT_0;
else if (flags & NT_WNDALERT_1) self->alert = WINDOW_ALERT_1;
else if (flags & NT_WNDALERT_2) self->alert = WINDOW_ALERT_2;
}
return rc;
}