소스 검색

LibAudio: Don't return a seek point if it is after the desired sample

If the seek table was incomplete, without any seek points available
before the target point, `SeekTable::seek_point_before()` would instead
return the first seek point after the target. Check whether the seek
point is before the target before returning it.
Zaggy1024 2 년 전
부모
커밋
a8dc97d95d
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      Userland/Libraries/LibAudio/GenericTypes.cpp

+ 2 - 0
Userland/Libraries/LibAudio/GenericTypes.cpp

@@ -40,6 +40,8 @@ Optional<SeekPoint const&> SeekTable::seek_point_before(u64 sample_index) const
         ++nearby_seek_point_index;
     while (nearby_seek_point_index > 0 && m_seek_points[nearby_seek_point_index].sample_index > sample_index)
         --nearby_seek_point_index;
+    if (m_seek_points[nearby_seek_point_index].sample_index > sample_index)
+        return {};
     return m_seek_points[nearby_seek_point_index];
 }