Paraslash Audio Streaming | |
About News Download Documentation Development |
Scoring functions to determine the audio file streaming order. More...
#include <regex.h>
#include <osl.h>
#include <lopsub.h>
#include "para.h"
#include "error.h"
#include "string.h"
#include "afh.h"
#include "afs.h"
#include "list.h"
Enumerations | |
enum | score_table_columns { SCORECOL_AFT_ROW, SCORECOL_SCORE, NUM_SCORE_COLUMNS } |
The score table consists of two columns: The aft_row column contains pointers to the rows of the audio file table, and the score column contains the current score of the audio file associated with that row. More... | |
Functions | |
int | score_add (const struct osl_row *aft_row, long score, struct osl_table *t) |
Add a (row, score) pair to the score table. More... | |
int | score_update (const struct osl_row *aft_row, long percent) |
Replace a row of the score table. More... | |
int | get_score_and_aft_row (struct osl_row *score_row, long *score, struct osl_row **aft_row) |
Given an admissible file, get the corresponding row in the aft and the score. More... | |
int | score_loop (osl_rbtree_loop_func *func, struct osl_table *t, void *data) |
Call the given function for each row of the score table. More... | |
int | score_get_best (struct osl_row **aft_row, long *score) |
Get the admissible audio file with highest score. More... | |
int | score_delete (const struct osl_row *aft_row) |
Remove an entry from the rbtree of admissible files. More... | |
bool | row_belongs_to_score_table (const struct osl_row *aft_row) |
Find out whether an audio file is contained in the score table. More... | |
void | score_close (struct osl_table *t) |
Free all volatile objects, then close the table. More... | |
void | score_open (struct osl_table **result) |
Allocate a score table instance. More... | |
void | score_clear (void) |
Remove all entries from the score table, but keep the table open. More... | |
Variables | |
const struct afs_table_operations | score_ops |
The score table stores (aft row, score) pairs in memory. More... | |
Scoring functions to determine the audio file streaming order.
enum score_table_columns |
The score table consists of two columns: The aft_row column contains pointers to the rows of the audio file table, and the score column contains the current score of the audio file associated with that row.
Enumerator | |
---|---|
SCORECOL_AFT_ROW | The row of the audio file. |
SCORECOL_SCORE | The score. |
NUM_SCORE_COLUMNS | This table has two columns. |
int score_add | ( | const struct osl_row * | aft_row, |
long | score, | ||
struct osl_table * | t | ||
) |
Add a (row, score) pair to the score table.
aft_row | Identifies the audio file to be added. |
score | The score value of the audio file. |
t | NULL means to operate on the currently active table. |
References NUM_SCORE_COLUMNS.
int score_update | ( | const struct osl_row * | aft_row, |
long | percent | ||
) |
Replace a row of the score table.
aft_row | Determines the audio file to change. |
percent | The position to re-insert the audio 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.
References osl().
int get_score_and_aft_row | ( | struct osl_row * | score_row, |
long * | score, | ||
struct osl_row ** | aft_row | ||
) |
Given an admissible file, get the corresponding row in the aft and the score.
score_row | Determines the admissible file. |
score | Result pointer. |
aft_row | Result pointer. |
int score_loop | ( | osl_rbtree_loop_func * | func, |
struct osl_table * | t, | ||
void * | data | ||
) |
Call the given function for each row of the score table.
func | Callback, called once per row. |
t | NULL means to use the currently active score table. |
data | Passed verbatim to the callback. |
References osl().
Referenced by mood_loop(), and playlist_loop().
int score_get_best | ( | struct osl_row ** | aft_row, |
long * | score | ||
) |
Get the admissible audio file with highest score.
aft_row | Points to the row in the aft of the "best" audio file. |
score | Highest score value in the score table. |
References osl().
int score_delete | ( | const struct osl_row * | aft_row | ) |
Remove an entry from the rbtree of admissible files.
aft_row | The file which is no longer admissible. |
bool row_belongs_to_score_table | ( | const struct osl_row * | aft_row | ) |
Find out whether an audio file is contained in the score table.
aft_row | The row of the audio file table. |
void score_close | ( | struct osl_table * | t | ) |
Free all volatile objects, then close the table.
t | As returned from score_open(). |
This either succeeds or terminates the calling process.
Referenced by playlist_unload().
void score_open | ( | struct osl_table ** | result | ) |
Allocate a score table instance.
result | NULL means to open the currently active score table. |
Since the score table does no filesystem I/O, this function always succeeds.
References osl().
Referenced by playlist_load().
void score_clear | ( | void | ) |
Remove all entries from the score table, but keep the table open.
const struct afs_table_operations score_ops |
The score table stores (aft row, score) pairs in memory.