int score_update(const struct osl_row *aft_row, long new_score);
int score_delete(const struct osl_row *aft_row);
int clear_score_table(void);
-int row_belongs_to_score_table(const struct osl_row *aft_row, unsigned *rank);
+bool row_belongs_to_score_table(const struct osl_row *aft_row);
/* attribute */
void attribute_init(struct afs_table *t);
}
/**
- * Delete one entry from the statistics and from the score table.
+ * Delete an audio file from the score table and update mood statistics.
*
- * \param aft_row The audio file which is no longer admissible.
+ * \param aft_row Identifies the row to delete.
*
- * \return Positive on success, negative on errors.
+ * \return Standard.
*
* \sa \ref score_delete().
*/
static int mood_delete_audio_file(const struct osl_row *aft_row)
{
- int ret;
-
- ret = row_belongs_to_score_table(aft_row, NULL);
- if (ret < 0)
- return ret;
- if (!ret) /* not admissible, nothing to do */
- return 1;
+ if (!row_belongs_to_score_table(aft_row))
+ return 0;
return delete_from_statistics_and_score_table(aft_row);
}
int ret;
bool is_admissible, was_admissible;
struct afs_info afsi;
- unsigned rank;
if (!current_mood)
return 1; /* nothing to do */
- ret = row_belongs_to_score_table(aft_row, &rank);
- if (ret < 0)
- return ret;
- was_admissible = ret;
+ was_admissible = row_belongs_to_score_table(aft_row);
is_admissible = mp_eval_row(aft_row, current_mood->parser_context);
if (!was_admissible && !is_admissible)
return 1;
percent = 100;
else if (percent < 0)
percent = 0;
- PARA_DEBUG_LOG("moving from rank %u to %li%%\n", rank, percent);
+ PARA_DEBUG_LOG("moving to %li%%\n", percent);
return score_update(aft_row, percent);
}
char *new_path;
const struct osl_row *row = data;
- if (event == AUDIO_FILE_RENAME) {
- ret = row_belongs_to_score_table(row, NULL);
- if (ret < 0)
- return ret;
- was_admissible = ret;
- }
+ if (event == AUDIO_FILE_RENAME)
+ was_admissible = row_belongs_to_score_table(row);
ret = get_audio_file_path_of_row(row, &new_path);
if (ret < 0)
return ret;
int playlists_event_handler(enum afs_events event,
__a_unused struct para_buffer *pb, void *data)
{
- int ret;
struct afsi_change_event_data *aced = data;
if (!current_playlist.name)
case AUDIO_FILE_ADD:
return handle_audio_file_event(event, data);
case AUDIO_FILE_REMOVE:
- ret = row_belongs_to_score_table(data, NULL);
- if (ret < 0)
- return ret;
- if (!ret)
+ if (!row_belongs_to_score_table(data))
return 1;
current_playlist.length--;
return score_delete(data);
* Find out whether an audio file is contained in the score table.
*
* \param aft_row The row of the audio file table.
- * \param rank Result pointer
*
- * \return Positive, if \a aft_row belongs to the audio file table,
- * zero if not, negative on errors. If \a aft_row was found, and \a rank
- * is not \p NULL, the rank of \a aft_row is returned in \a rank.
+ * \return If the lookup operation fails for any other reason than "not found",
+ * the function aborts the current process (afs), since this is considered a
+ * fatal error that should never happen.
*/
-int row_belongs_to_score_table(const struct osl_row *aft_row, unsigned *rank)
+bool row_belongs_to_score_table(const struct osl_row *aft_row)
{
struct osl_row *score_row;
int ret = get_score_row_from_aft_row(aft_row, &score_row);
if (ret == -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND))
- return 0;
- if (ret < 0)
- return ret;
- if (!rank)
- return 1;
- ret = osl(osl_get_rank(score_table, score_row, SCORECOL_SCORE, rank));
- if (ret < 0)
- return ret;
- return 1;
+ return false;
+ assert(ret >= 0);
+ return true;
}
static void score_close(void)