typedef struct raop_s raop_t;
-typedef void (*raop_log_callback_t)(int level, const char *msg);
+typedef void (*raop_log_callback_t)(void *cls, int level, const char *msg);
struct raop_callbacks_s {
void* cls;
RAOP_API raop_t *raop_init_from_keyfile(int max_clients, raop_callbacks_t *callbacks, const char *keyfile);
RAOP_API void raop_set_log_level(raop_t *raop, int level);
-RAOP_API void raop_set_log_callback(raop_t *raop, raop_log_callback_t callback);
+RAOP_API void raop_set_log_callback(raop_t *raop, raop_log_callback_t callback, void *cls);
RAOP_API int raop_start(raop_t *raop, unsigned short *port, const char *hwaddr, int hwaddrlen, const char *password);
RAOP_API int raop_is_running(raop_t *raop);
mutex_handle_t cb_mutex;
int level;
+ void *cls;
logger_callback_t callback;
};
}
void
-logger_set_callback(logger_t *logger, logger_callback_t callback)
+logger_set_callback(logger_t *logger, logger_callback_t callback, void *cls)
{
assert(logger);
MUTEX_LOCK(logger->cb_mutex);
+ logger->cls = cls;
logger->callback = callback;
MUTEX_UNLOCK(logger->cb_mutex);
}
MUTEX_LOCK(logger->cb_mutex);
if (logger->callback) {
- logger->callback(level, buffer);
+ logger->callback(logger->cls, level, buffer);
MUTEX_UNLOCK(logger->cb_mutex);
} else {
char *local;
#define LOGGER_INFO 6 /* informational */
#define LOGGER_DEBUG 7 /* debug-level messages */
-typedef void (*logger_callback_t)(int level, const char *msg);
+typedef void (*logger_callback_t)(void *cls, int level, const char *msg);
typedef struct logger_s logger_t;
void logger_destroy(logger_t *logger);
void logger_set_level(logger_t *logger, int level);
-void logger_set_callback(logger_t *logger, logger_callback_t callback);
+void logger_set_callback(logger_t *logger, logger_callback_t callback, void *cls);
void logger_log(logger_t *logger, int level, const char *fmt, ...);
}
void
-raop_set_log_callback(raop_t *raop, raop_log_callback_t callback)
+raop_set_log_callback(raop_t *raop, raop_log_callback_t callback, void *cls)
{
assert(raop);
- logger_set_callback(raop->logger, callback);
+ logger_set_callback(raop->logger, callback, cls);
}
int
}
static void
-raop_log_callback(int level, const char *msg)
+raop_log_callback(void *cls, int level, const char *msg)
{
printf("RAOP LOG(%d): %s\n", level, msg);
}
raop = raop_init_from_keyfile(10, &raop_cbs, "airport.key");
raop_set_log_level(raop, RAOP_LOG_DEBUG);
- raop_set_log_callback(raop, &raop_log_callback);
+ raop_set_log_callback(raop, &raop_log_callback, NULL);
raop_start(raop, &raop_port, hwaddr, sizeof(hwaddr), "test");
dnssd = dnssd_init(NULL);