Buffering callbacks rework. There is now one callback for all the events that can occur. Callbacks are now registred only once instead of being removed after having been called.

Fix FS#8092 by flushing the audio when a rebuffer is needed.
Also add some comments here and there.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15816 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nicolas Pennequin 2007-11-26 21:13:08 +00:00
parent fa92f1b763
commit e24454f8b3
3 changed files with 70 additions and 36 deletions

View file

@ -35,6 +35,14 @@ enum data_type {
TYPE_UNKNOWN,
};
enum callback_event {
EVENT_DEFAULT,
EVENT_BUFFER_LOW,
EVENT_HANDLE_REBUFFER,
EVENT_HANDLE_CLOSED,
EVENT_HANDLE_MOVED,
};
/* Error return values */
#define ERR_HANDLE_NOT_FOUND -1
#define ERR_BUFFER_FULL -2
@ -98,7 +106,7 @@ size_t buf_used(void);
* CALLBACK UTILITIES
* ==================
*
* register_buffer_low_callback, unregister_buffer_low_callback:
* register_buffering_callback, unregister_buffering_callback:
*
* Register/Unregister callback functions that will get executed when the buffer
* goes below the low watermark. They are executed once, then forgotten.
@ -108,9 +116,9 @@ size_t buf_used(void);
****************************************************************************/
#define MAX_BUF_CALLBACKS 4
typedef void (*buffer_low_callback)(void);
bool register_buffer_low_callback(buffer_low_callback func);
void unregister_buffer_low_callback(buffer_low_callback func);
typedef void (*buffering_callback)(enum callback_event ev, int value);
bool register_buffering_callback(buffering_callback func);
void unregister_buffering_callback(buffering_callback func);
/* Settings */
enum {