ogg123 -R doesn't reliably report the end of a file that has been playing
When using ogg123 with -R, it is difficult to determine the end of a song reliable.
mpg123 reports @P 0 when it is finished playing a song, which makes it possible to load a new file (almost) instantly. However, ogg123 doesn't report @P 0.
Now we can try to determine if the file is finished playing by reading the time left from the @F, which will eventually drop to 0.
However, it sometimes doesn't! It stays on 0,11 or 0,02 or 0,08, or whatever.
To fix this, a final report should be added after the last song is finished playing. I've found out that this would be done in ogg123.c, in the subroutine 'display_statistics_quick'. I've changed the code from
void display_statistics_quick (stat_format_t *stat_format,
buf_t *audio_buffer,
data_source_t *source,
decoder_t *decoder)
{
print_statistics_arg_t *pstats_arg;
pstats_arg = new_print_statistics_arg(stat_format,
source->transport->statistics(source),
decoder->format->statistics(decoder));
if (audio_buffer) {
print_statistics_action(audio_buffer, pstats_arg);
} else
print_statistics_action(NULL, pstats_arg);
}
to:
void display_statistics_quick (stat_format_t *stat_format,
buf_t *audio_buffer,
data_source_t *source,
decoder_t *decoder)
{
print_statistics_arg_t *pstats_arg;
pstats_arg = new_print_statistics_arg(stat_format,
source->transport->statistics(source),
decoder->format->statistics(decoder));
if (options.remote) {
/* Display statistics via the remote interface */
remote_time(pstats_arg->decoder_statistics->current_time,
pstats_arg->decoder_statistics->total_time);
} else {
if (audio_buffer) {
print_statistics_action(audio_buffer, pstats_arg);
} else
print_statistics_action(NULL, pstats_arg);
}
}