static double rb_random_by_age_and_rating_get_entry_weight (RBRandomPlayOrder *rorder, RhythmDB *db, RhythmDBEntry *entry) { time_t now; gulong last_play; gulong seconds_since_last_play = 0; gdouble rating; RhythmDBEntry *playing_entry; /* This finds the log of the number of seconds since the last play. * It handles never played automatically, since now-0 is a valid * argument to log(). */ time (&now); playing_entry = rb_play_order_get_playing_entry (RB_PLAY_ORDER (rorder)); if (playing_entry != entry) { last_play = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_LAST_PLAYED); seconds_since_last_play = now - last_play; } if (playing_entry != NULL) rhythmdb_entry_unref (playing_entry); /* The lowest weight should be 0. */ if (seconds_since_last_play < 1) seconds_since_last_play = 1; rating = rhythmdb_entry_get_double (entry, RHYTHMDB_PROP_RATING); /* treat unrated as 2.5 for the purposes of probabilities */ if (rating < 0.01) rating = 2.5; return log (seconds_since_last_play) * (rating + 1.0); }
RBPlayOrder * rb_linear_play_order_new (RBShellPlayer *player) { RBLinearPlayOrder *lorder; lorder = g_object_new (RB_TYPE_LINEAR_PLAY_ORDER, "player", player, NULL); return RB_PLAY_ORDER (lorder); }
RBPlayOrder * rb_random_play_order_by_rating_new (RBShellPlayer *player) { RBRandomPlayOrderByRating *rorder; rorder = g_object_new (RB_TYPE_RANDOM_PLAY_ORDER_BY_RATING, "player", player, NULL); return RB_PLAY_ORDER (rorder); }