decoder/mpg123: move code to GetDuration()
This commit is contained in:
parent
de9f0dc910
commit
55d0bbade2
@ -243,6 +243,16 @@ mpd_mpg123_meta(DecoderClient &client, mpg123_handle *const handle)
|
|||||||
mpd_mpg123_id3v2(client, *v2);
|
mpd_mpg123_id3v2(client, *v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[gnu::pure]]
|
||||||
|
static SignedSongTime
|
||||||
|
GetDuration(mpg123_handle &handle, const AudioFormat &audio_format) noexcept
|
||||||
|
{
|
||||||
|
const off_t num_samples = mpg123_length(&handle);
|
||||||
|
|
||||||
|
return SongTime::FromScale<uint64_t>(num_samples,
|
||||||
|
audio_format.sample_rate);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Decode(DecoderClient &client, mpg123_handle &handle, const bool seekable)
|
Decode(DecoderClient &client, mpg123_handle &handle, const bool seekable)
|
||||||
{
|
{
|
||||||
@ -250,13 +260,9 @@ Decode(DecoderClient &client, mpg123_handle &handle, const bool seekable)
|
|||||||
if (!GetAudioFormat(handle, audio_format))
|
if (!GetAudioFormat(handle, audio_format))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const off_t num_samples = mpg123_length(&handle);
|
|
||||||
|
|
||||||
/* tell MPD core we're ready */
|
/* tell MPD core we're ready */
|
||||||
|
|
||||||
const auto duration =
|
const auto duration = GetDuration(handle, audio_format);
|
||||||
SongTime::FromScale<uint64_t>(num_samples,
|
|
||||||
audio_format.sample_rate);
|
|
||||||
|
|
||||||
client.Ready(audio_format, seekable, duration);
|
client.Ready(audio_format, seekable, duration);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user