- /* Start a rescan straight away if this is a new installation. This rescan
- * blocks; the point is that when it is finished we are in a good position to
- * choose a random track. */
- if(!trackdb_existing_database) {
- trackdb_rescan(0/*ev*/, 0/*check*/);
- /* No ev -> the rescan will block. Since we called reconfigure() already
- * any clients will also be forced to block. */
- }
- /* Start a second rescan, with length checking enabled, immediately after
- * startup. */
- rescan_after(1);
- /* periodically tidy up the database */
- dbgc_after(60);
- /* periodically check the volume */
- volumecheck_again(0, 0, 0);
- /* set initial state */
- add_random_track();
- play(ev);
+ /* Rescan immediately and then daily */
+ create_periodic(ev, periodic_rescan, 86400, 1/*immediate*/);
+ /* Tidy up the database once a minute */
+ create_periodic(ev, periodic_database_gc, 60, 0);
+ /* Check the volume immediately and then once a minute */
+ create_periodic(ev, periodic_volume_check, 60, 1);
+ /* Check for a playable track once a second */
+ create_periodic(ev, periodic_play_check, 1, 0);
+ /* Try adding a random track immediately and once every two seconds */
+ create_periodic(ev, periodic_add_random, 2, 1);