mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:27:45 +00:00
LibAudio: Use NonnullOwnPtr
to keep track of LoaderPlugin streams
This doesn't have any immediate uses, but this adapts the code a bit more to `Core::Stream` conventions (as most functions there use NonnullOwnPtr to handle streams) and it makes it a bit clearer that this pointer isn't actually supposed to be null. In fact, MP3LoaderPlugin and FlacLoaderPlugin apparently forgot to check for that completely before starting to decode data.
This commit is contained in:
parent
c57be0f474
commit
312a41fddf
8 changed files with 9 additions and 15 deletions
|
@ -18,7 +18,7 @@ namespace Audio {
|
|||
|
||||
static constexpr size_t const maximum_wav_size = 1 * GiB; // FIXME: is there a more appropriate size limit?
|
||||
|
||||
WavLoaderPlugin::WavLoaderPlugin(OwnPtr<Core::Stream::SeekableStream> stream)
|
||||
WavLoaderPlugin::WavLoaderPlugin(NonnullOwnPtr<Core::Stream::SeekableStream> stream)
|
||||
: LoaderPlugin(move(stream))
|
||||
{
|
||||
}
|
||||
|
@ -142,9 +142,6 @@ LoaderSamples WavLoaderPlugin::samples_from_pcm_data(Bytes const& data, size_t s
|
|||
|
||||
LoaderSamples WavLoaderPlugin::get_more_samples(size_t max_samples_to_read_from_input)
|
||||
{
|
||||
if (!m_stream)
|
||||
return LoaderError { LoaderError::Category::Internal, static_cast<size_t>(m_loaded_samples), "No stream; initialization failed" };
|
||||
|
||||
auto remaining_samples = m_total_samples - m_loaded_samples;
|
||||
if (remaining_samples <= 0)
|
||||
return FixedArray<Sample> {};
|
||||
|
@ -189,9 +186,6 @@ MaybeLoaderError WavLoaderPlugin::seek(int sample_index)
|
|||
// Specification reference: http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html
|
||||
MaybeLoaderError WavLoaderPlugin::parse_header()
|
||||
{
|
||||
if (!m_stream)
|
||||
return LoaderError { LoaderError::Category::Internal, 0, "No stream" };
|
||||
|
||||
bool ok = true;
|
||||
size_t bytes_read = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue