LibAudio: Always insert a seek point at sample 0 if not present
Previously, the calculation of the distance to the previous seekpoint would always behave as if a seek point existed at sample 0, meaning that it would never place a seek point there. If we instead treat it as the maximum distance if no sample is present, a seek point will be placed.
This commit is contained in:
parent
a8dc97d95d
commit
ee1903e641
Notes:
sideshowbarker
2024-07-17 16:42:19 +09:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/SerenityOS/serenity/commit/ee1903e641 Pull-request: https://github.com/SerenityOS/serenity/pull/19802 Reviewed-by: https://github.com/kleinesfilmroellchen ✅
1 changed files with 2 additions and 1 deletions
|
@ -325,7 +325,8 @@ bool FlacLoaderPlugin::should_insert_seekpoint_at(u64 sample_index) const
|
|||
auto const max_seekpoint_distance = (maximum_seekpoint_distance_ms * m_sample_rate) / 1000;
|
||||
auto const seek_tolerance = (seek_tolerance_ms * m_sample_rate) / 1000;
|
||||
auto const current_seekpoint_distance = m_seektable.seek_point_sample_distance_around(sample_index).value_or(NumericLimits<u64>::max());
|
||||
auto const distance_to_previous_seekpoint = sample_index - m_seektable.seek_point_before(sample_index).value_or({ 0, 0 }).sample_index;
|
||||
auto const previous_seekpoint = m_seektable.seek_point_before(sample_index);
|
||||
auto const distance_to_previous_seekpoint = previous_seekpoint.has_value() ? sample_index - previous_seekpoint->sample_index : NumericLimits<u64>::max();
|
||||
|
||||
// We insert a seekpoint only under two conditions:
|
||||
// - The seek points around us are spaced too far for what the loader recommends.
|
||||
|
|
Loading…
Add table
Reference in a new issue