소스 검색

LibAudio: Don't assume that a non-full span means EOF

Especially if buffered streams are involved, not filling the span
completely can also mean that we just ran out of filled buffer space and
we need to refill it on the beginning of the next read call.
Tim Schumacher 2 년 전
부모
커밋
1caad457ef
1개의 변경된 파일1개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 2
      Userland/Libraries/LibAudio/MP3Loader.cpp

+ 1 - 2
Userland/Libraries/LibAudio/MP3Loader.cpp

@@ -233,8 +233,7 @@ ErrorOr<MP3::MP3Frame, LoaderError> MP3LoaderPlugin::read_frame_data(MP3::Header
     auto& buffer = maybe_buffer.value();
 
     size_t old_reservoir_size = m_bit_reservoir.size();
-    if (LOADER_TRY(m_bitstream->read(buffer)).size() != buffer.size())
-        return LoaderError { LoaderError::Category::IO, m_loaded_samples, "Could not find another whole frame." };
+    LOADER_TRY(m_bitstream->read_entire_buffer(buffer));
     if (m_bit_reservoir.write(buffer) != header.slot_count)
         return LoaderError { LoaderError::Category::IO, m_loaded_samples, "Could not write frame into bit reservoir." };