allow removing of listeners

This commit is contained in:
chme 2015-05-03 08:18:26 +02:00
parent 1714f3dee4
commit 7097dd15eb
3 changed files with 34 additions and 0 deletions

View File

@ -45,6 +45,35 @@ listener_add(notify notify_cb)
return 0;
}
int
listener_remove(notify notify_cb)
{
struct listener *listener;
struct listener *prev;
listener = listener_list;
prev = NULL;
while (listener)
{
if (listener->notify_cb == notify_cb)
{
if (prev)
prev->next = listener->next;
else
listener_list = NULL;
free(listener);
return 0;
}
prev = listener;
listener = listener->next;
}
return -1;
}
int
listener_notify(enum listener_event_type type)
{

View File

@ -14,6 +14,9 @@ typedef void (*notify)(enum listener_event_type type);
int
listener_add(notify notify_cb);
int
listener_remove(notify notify_cb);
int
listener_notify(enum listener_event_type type);

View File

@ -4098,6 +4098,8 @@ void mpd_deinit(void)
return;
}
listener_remove(mpd_listener_cb);
while (idle_clients)
{
temp = idle_clients;