X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=score.c;h=894e8ca3deae39f21552a6cd331237551e9c7a1b;hp=23c1276d01b09add834201699460e5b4d00bf67b;hb=f0b8296a0635e74aaa58767e513eed226504ec34;hpb=1cefe6a503c74d609db4e99e689d46575a5e40fd diff --git a/score.c b/score.c index 23c1276d..894e8ca3 100644 --- a/score.c +++ b/score.c @@ -1,12 +1,9 @@ -/* - * Copyright (C) 2007-2012 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 2007 Andre Noll , see file COPYING. */ /** \file score.c Scoring functions to determine the audio file streaming order. */ #include #include +#include #include "para.h" #include "error.h" @@ -24,17 +21,11 @@ static int ptr_compare(const struct osl_object *obj1, const struct osl_object *o return NUM_COMPARE(d1, d2); } -/** - * Compare the score of two audio files - * - * \param obj1 Pointer to the first score object. - * \param obj2 Pointer to the second score object. - * - * This function first compares the score values as usual integers. If they compare as - * equal, the address of \a obj1 and \a obj2 are compared. So this compare function - * returns zero if and only if \a obj1 and \a obj2 point to the same memory area. - * - * \sa osl_compare_function. +/* + * This function first compares the score values. If they are equal, the + * addresses of the two objects are compared. Thus, the function returns + * "equal" only if the two objects alias each other, i.e., point to the same + * memory address. */ static int score_compare(const struct osl_object *obj1, const struct osl_object *obj2) { @@ -71,7 +62,7 @@ static struct osl_column_description score_cols[] = { }, [SCORECOL_SCORE] = { .storage_type = OSL_NO_STORAGE, - .storage_flags = OSL_RBTREE | OSL_FIXED_SIZE, + .storage_flags = OSL_RBTREE | OSL_FIXED_SIZE | OSL_UNIQUE, .name = "score", .compare_function = score_compare, .data_size = sizeof(long) @@ -91,24 +82,13 @@ static struct osl_table_description score_table_desc = { * \param num Result is returned here. * * \return Positive on success, negative on errors. - * - * \sa osl_get_num_rows(). */ int get_num_admissible_files(unsigned *num) { return osl(osl_get_num_rows(score_table, num)); } -/** - * Get the score of the audio file associated with given row of the score table. - * - * \param score_row Pointer to the row in the score table. - * \param score Result is returned here on success. - * - * On errors (negative return value) the content of \a score is undefined. - * - * \return The return value of the underlying call to osl_get_object(). - */ +/* On errors (negative return value) the content of score is undefined. */ static int get_score_of_row(void *score_row, long *score) { struct osl_object obj; @@ -168,13 +148,11 @@ static int get_nth_score(unsigned n, long *score) * \param aft_row Determines the audio file to change. * \param percent The position to re-insert the audio file. * - * The percent parameter must be between \p 0 and 100 and. A value of zero - * means to re-insert the audio file into the score table with a score lower - * than any other admissible file. + * The percent parameter must be between 0 and 100. A value of zero means to + * re-insert the audio file into the score table with a score lower than any + * other admissible file. * - * \return Positive on success, negative on errors. Possible errors: Errors - * returned by osl_get_row(), get_num_admissible_files(), osl_get_nth_row(), - * osl_get_object(), osl_update_object(). + * \return Positive on success, negative on errors. */ int score_update(const struct osl_row *aft_row, long percent) { @@ -211,8 +189,7 @@ int score_update(const struct osl_row *aft_row, long percent) * \param score Result pointer. * \param aft_row Result pointer. * - * \return Negative on errors, positive on success. Possible errors: Errors - * returned by osl_get_object(). + * \return Standard. */ int get_score_and_aft_row(struct osl_row *score_row, long *score, struct osl_row **aft_row) @@ -247,37 +224,19 @@ static int get_score_row_from_aft_row(const struct osl_row *aft_row, * * This is used for the ls command. The \a data parameter is passed as the * second argument to \a func. - * - * \sa admissible_file_loop_reverse(). */ int admissible_file_loop(void *data, osl_rbtree_loop_func *func) { return osl(osl_rbtree_loop(score_table, SCORECOL_SCORE, data, func)); } -/** - * Loop over all files in the score table in reverse order. - * - * \param data As in admissible_file_loop(). - * \param func As in admissible_file_loop(). - * - * \return Same return value as admissible_file_loop(). - * - * \sa admissible_file_loop(), osl_rbtree_loop_reverse(). - */ -int admissible_file_loop_reverse(void *data, osl_rbtree_loop_func *func) -{ - return osl(osl_rbtree_loop_reverse(score_table, SCORECOL_SCORE, data, func)); -} - /** * Get the admissible audio file with highest score. * * \param aft_row Points to the row in the aft of the "best" audio file. * \param score Highest score value in the score table. * - * \return Positive on success, negative on errors. Possible errors: Errors - * returned by osl_rbtree_last_row(), osl_get_object(). + * \return Standard. */ int score_get_best(struct osl_row **aft_row, long *score) { @@ -299,10 +258,9 @@ int score_get_best(struct osl_row **aft_row, long *score) * * \param aft_row The file which is no longer admissible. * - * \return Positive on success, negative on errors. Possible errors: - * Errors returned by osl_get_row() and osl_del_row(). + * \return Standard. * - * \sa score_add(), score_shutdown(). + * \sa \ref score_add(). */ int score_delete(const struct osl_row *aft_row) { @@ -341,20 +299,12 @@ int row_belongs_to_score_table(const struct osl_row *aft_row, unsigned *rank) return 1; } -/* Close the score table. */ static void score_close(void) { osl_close_table(score_table, OSL_FREE_VOLATILE); score_table = NULL; } -/** - * Open the score table. - * - * \param dir Unused. - * - * \return The return value of the underlying call to osl_open_table(). - */ static int score_open(__a_unused const char *dir) { score_table_desc.dir = NULL; /* this table has only volatile columns */