AudioFormat: add TimeToSize(), SizeToTime()

This commit is contained in:
Max Kellermann
2018-09-21 19:32:35 +02:00
parent 1a2012a97e
commit d3d1d37782
5 changed files with 28 additions and 6 deletions

View File

@@ -532,8 +532,7 @@ DecoderBridge::SubmitData(InputStream *is,
data = (const uint8_t *)data + nbytes;
length -= nbytes;
timestamp += FloatDuration((double)nbytes /
dc.out_audio_format.GetTimeToSize());
timestamp += dc.out_audio_format.SizeToTime<FloatDuration>(nbytes);
}
absolute_frame += data_frames;

View File

@@ -183,7 +183,7 @@ HybridDsdDecode(DecoderClient &client, InputStream &input)
try {
auto result = FindHybridDsdData(client, input);
auto duration = SignedSongTime::FromS(result.second / result.first.GetTimeToSize());
auto duration = result.first.SizeToTime<SignedSongTime>(result.second);
client.Ready(result.first, true, duration);
frame_size = result.first.GetFrameSize();
kbit_rate = frame_size * result.first.sample_rate /

View File

@@ -264,8 +264,7 @@ mpd_mpg123_file_decode(DecoderClient &client, Path path_fs)
client.SeekError();
else {
client.CommandFinished();
client.SubmitTimestamp(FloatDuration(c)
/ audio_format.sample_rate);
client.SubmitTimestamp(audio_format.FramesToTime<FloatDuration>(c));
}
cmd = DecoderCommand::NONE;