X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=mood.c;h=c892ff5c15fcfb8abfe8a11fe0a85911f073c740;hp=89ad80d956af3b7107f7ae4883619e689d3d2582;hb=4744d937c4160898d1fe151257606430750e580c;hpb=5bf80b0268b0afb3984aea74d41eddef34d50d03 diff --git a/mood.c b/mood.c index 89ad80d9..c892ff5c 100644 --- a/mood.c +++ b/mood.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2010 Andre Noll + * Copyright (C) 2007-2012 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -79,13 +79,13 @@ struct mood { static struct mood *current_mood; /** - * Rough approximation to sqrt. + * Rough approximation to sqrt. * - * \param x Integer of which to calculate the sqrt. + * \param x Integer of which to calculate the sqrt. * - * \return An integer res with res * res <= x. + * \return An integer res with res * res <= x. */ -static uint64_t int_sqrt(uint64_t x) +__a_const static uint64_t int_sqrt(uint64_t x) { uint64_t op, res, one = 1; op = x; @@ -364,8 +364,10 @@ static int load_mood(const struct osl_row *mood_row, struct mood **m) char *mood_name; struct osl_object mood_def; struct mood_line_parser_data mlpd = {.line_num = 0}; - int ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def); + int ret; + *m = NULL; + ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def); if (ret < 0) return ret; if (!*mood_name) @@ -422,9 +424,11 @@ out: void mood_check_callback(int fd, __a_unused const struct osl_object *query) { struct para_buffer pb = { - .max_size = SHMMAX, - .private_data = &fd, - .max_size_handler = pass_buffer_as_shm + .max_size = shm_get_shmmax(), + .private_data = &(struct afs_max_size_handler_data) { + .fd = fd, + }, + .max_size_handler = afs_max_size_handler }; int ret = para_printf(&pb, "checking moods...\n"); @@ -904,6 +908,8 @@ static int reload_current_mood(void) int moods_event_handler(enum afs_events event, __a_unused struct para_buffer *pb, void *data) { + int ret; + if (!current_mood) return 0; switch (event) { @@ -916,6 +922,10 @@ int moods_event_handler(enum afs_events event, __a_unused struct para_buffer *pb case BLOB_ADD: if (data == moods_table || data == playlists_table) return 1; /* no reload necessary for these */ + ret = clear_score_table(); + if (ret < 0) + PARA_CRIT_LOG("clear score table returned %s\n", + para_strerror(-ret)); return reload_current_mood(); /* these also require reload of the score table */ case ATTRIBUTE_ADD: