2015-02-21 00:04:17 -05:00
|
|
|
|
|
|
|
#ifndef __LISTENER_H__
|
|
|
|
#define __LISTENER_H__
|
|
|
|
|
|
|
|
enum listener_event_type
|
|
|
|
{
|
2015-05-21 01:57:18 -04:00
|
|
|
/* The player has been started, stopped or seeked */
|
2015-05-18 14:12:18 -04:00
|
|
|
LISTENER_PLAYER = (1 << 0),
|
2015-05-21 01:57:18 -04:00
|
|
|
/* The current playlist has been modified */
|
2015-05-18 14:12:18 -04:00
|
|
|
LISTENER_PLAYLIST = (1 << 1),
|
2015-05-21 01:57:18 -04:00
|
|
|
/* The volume has been changed */
|
2015-05-18 14:12:18 -04:00
|
|
|
LISTENER_VOLUME = (1 << 2),
|
2015-05-21 01:57:18 -04:00
|
|
|
/* A speaker has been enabled or disabled */
|
2015-05-18 14:12:18 -04:00
|
|
|
LISTENER_SPEAKER = (1 << 3),
|
2015-05-21 01:57:18 -04:00
|
|
|
/* Options like repeat, random has been changed */
|
2015-05-18 14:12:18 -04:00
|
|
|
LISTENER_OPTIONS = (1 << 4),
|
2015-05-21 01:57:18 -04:00
|
|
|
/* The library has been modified */
|
2015-05-18 14:12:18 -04:00
|
|
|
LISTENER_DATABASE = (1 << 5),
|
2015-02-21 00:04:17 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (*notify)(enum listener_event_type type);
|
|
|
|
|
2015-05-21 01:57:18 -04:00
|
|
|
/*
|
|
|
|
* Registers the given callback function to the given event types.
|
|
|
|
* This function is not thread safe. Listeners must be added once at startup.
|
|
|
|
*
|
|
|
|
* @param notify_cb Callback function
|
|
|
|
* @param events Event mask, one or more of LISTENER_*
|
|
|
|
* @return 0 on success, -1 on failure
|
|
|
|
*/
|
2015-02-21 00:04:17 -05:00
|
|
|
int
|
2015-05-18 14:12:18 -04:00
|
|
|
listener_add(notify notify_cb, short events);
|
2015-02-21 00:04:17 -05:00
|
|
|
|
2015-05-21 01:57:18 -04:00
|
|
|
/*
|
|
|
|
* Removes the given callback function
|
|
|
|
* This function is not thread safe. Listeners must be removed once at shutdown.
|
|
|
|
*
|
|
|
|
* @param notify_cb Callback function
|
|
|
|
* @return 0 on success, -1 if the callback was not registered
|
|
|
|
*/
|
2015-05-03 02:18:26 -04:00
|
|
|
int
|
|
|
|
listener_remove(notify notify_cb);
|
|
|
|
|
2015-05-21 01:57:18 -04:00
|
|
|
/*
|
|
|
|
* Calls the callback function of the registered listeners listening for the
|
|
|
|
* given type of event.
|
|
|
|
*
|
|
|
|
* @param type The event type, on of the LISTENER_* values
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
2015-02-21 00:04:17 -05:00
|
|
|
listener_notify(enum listener_event_type type);
|
|
|
|
|
|
|
|
#endif /* !__LISTENER_H__ */
|