static int searchStatsInDirectory(struct song *song, void *data) { SearchStats *stats = data; if (locate_song_match(song, stats->criteria)) { stats->numberOfSongs++; stats->playTime += song_get_duration(song); } return 0; }
static bool stats_visitor_song(struct song *song, void *data, G_GNUC_UNUSED GError **error_r) { SearchStats *stats = data; if (locate_song_match(song, stats->criteria)) { stats->numberOfSongs++; stats->playTime += song_get_duration(song); } return true; }
/** * After the decoder has been started asynchronously, wait for the * "START" command to finish. The decoder may not be initialized yet, * i.e. there is no audio_format information yet. * * The player lock is not held. */ static bool player_wait_for_decoder(struct player *player) { struct player_control *pc = player->pc; struct decoder_control *dc = player->dc; assert(player->queued || pc->command == PLAYER_COMMAND_SEEK); assert(pc->next_song != NULL); player->queued = false; GError *error = dc_lock_get_error(dc); if (error != NULL) { player_lock(pc); pc_set_error(pc, PLAYER_ERROR_DECODER, error); song_free(pc->next_song); pc->next_song = NULL; player_unlock(pc); return false; } if (player->song != NULL) song_free(player->song); player->song = pc->next_song; player->elapsed_time = 0.0; /* set the "starting" flag, which will be cleared by player_check_decoder_startup() */ player->decoder_starting = true; player_lock(pc); /* update player_control's song information */ pc->total_time = song_get_duration(pc->next_song); pc->bit_rate = 0; audio_format_clear(&pc->audio_format); /* clear the queued song */ pc->next_song = NULL; player_unlock(pc); /* call syncPlaylistWithQueue() in the main thread */ event_pipe_emit(PIPE_EVENT_PLAYLIST); return true; }
/** * Returns the real duration of the song, comprising the duration * indicated by the decoder plugin. */ static double real_song_duration(const struct song *song, double decoder_duration) { assert(song != NULL); if (decoder_duration <= 0.0) /* the decoder plugin didn't provide information; fall back to song_get_duration() */ return song_get_duration(song); if (song->end_ms > 0 && song->end_ms / 1000.0 < decoder_duration) return (song->end_ms - song->start_ms) / 1000.0; return decoder_duration - song->start_ms / 1000.0; }
/** * After the decoder has been started asynchronously, wait for the * "START" command to finish. The decoder may not be initialized yet, * i.e. there is no audio_format information yet. * * The player lock is not held. */ static bool player_wait_for_decoder(struct player *player) { struct decoder_control *dc = player->dc; assert(player->queued || pc.command == PLAYER_COMMAND_SEEK); assert(pc.next_song != NULL); player->queued = false; if (decoder_lock_has_failed(dc)) { player_lock(); pc.errored_song = dc->song; pc.error = PLAYER_ERROR_FILE; pc.next_song = NULL; player_unlock(); return false; } player->song = pc.next_song; player->elapsed_time = 0.0; /* set the "starting" flag, which will be cleared by player_check_decoder_startup() */ player->decoder_starting = true; player_lock(); /* update player_control's song information */ pc.total_time = song_get_duration(pc.next_song); pc.bit_rate = 0; audio_format_clear(&pc.audio_format); /* clear the queued song */ pc.next_song = NULL; player_unlock(); /* call syncPlaylistWithQueue() in the main thread */ event_pipe_emit(PIPE_EVENT_PLAYLIST); return true; }