소스 검색

LibAudio: Set MP3 seek points to their frame's first sample

Seek points were being created after adding to the sample count in
`build_seek_table()`, meaning that they would be offset forward by
`MP3::frame_size` samples.

This also allows us to remove the hardcoded sample 0 seek point that
was previously added, since a seek point at sample 0 will now be added
by the loop.
Zaggy1024 1 년 전
부모
커밋
2dc75a37d2
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      Userland/Libraries/LibAudio/MP3Loader.cpp

+ 3 - 3
Userland/Libraries/LibAudio/MP3Loader.cpp

@@ -146,7 +146,6 @@ MaybeLoaderError MP3LoaderPlugin::build_seek_table()
     int sample_count = 0;
     size_t frame_count = 0;
     m_seek_table = {};
-    TRY(m_seek_table.insert_seek_point({ 0, 0 }));
 
     m_bitstream->align_to_byte_boundary();
 
@@ -157,12 +156,13 @@ MaybeLoaderError MP3LoaderPlugin::build_seek_table()
         if (error_or_header.is_error() || error_or_header.value().id != 1 || error_or_header.value().layer != 3) {
             continue;
         }
-        frame_count++;
-        sample_count += MP3::frame_size;
 
         if (frame_count % 10 == 0)
             TRY(m_seek_table.insert_seek_point({ static_cast<u64>(sample_count), frame_pos }));
 
+        frame_count++;
+        sample_count += MP3::frame_size;
+
         TRY(m_stream->seek(error_or_header.value().frame_size - 6, SeekMode::FromCurrentPosition));
 
         // TODO: This is just here to clear the bitstream buffer.