mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 02:27:44 +00:00
AK: Move memory streams from LibCore
This commit is contained in:
parent
11550f582b
commit
093cf428a3
46 changed files with 213 additions and 203 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <AK/Format.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <AK/Math.h>
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/Try.h>
|
||||
|
@ -20,7 +21,6 @@
|
|||
#include <LibAudio/FlacTypes.h>
|
||||
#include <LibAudio/LoaderError.h>
|
||||
#include <LibAudio/Resampler.h>
|
||||
#include <LibCore/MemoryStream.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
||||
namespace Audio {
|
||||
|
@ -42,7 +42,7 @@ Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> FlacLoaderPlugin::create(St
|
|||
|
||||
Result<NonnullOwnPtr<FlacLoaderPlugin>, LoaderError> FlacLoaderPlugin::create(Bytes buffer)
|
||||
{
|
||||
auto stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(buffer));
|
||||
auto stream = LOADER_TRY(FixedMemoryStream::construct(buffer));
|
||||
auto loader = make<FlacLoaderPlugin>(move(stream));
|
||||
|
||||
LOADER_TRY(loader->initialize());
|
||||
|
@ -78,7 +78,7 @@ MaybeLoaderError FlacLoaderPlugin::parse_header()
|
|||
// Receive the streaminfo block
|
||||
auto streaminfo = TRY(next_meta_block(*bit_input));
|
||||
FLAC_VERIFY(streaminfo.type == FlacMetadataBlockType::STREAMINFO, LoaderError::Category::Format, "First block must be STREAMINFO");
|
||||
auto streaminfo_data_memory = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(streaminfo.data.bytes()));
|
||||
auto streaminfo_data_memory = LOADER_TRY(FixedMemoryStream::construct(streaminfo.data.bytes()));
|
||||
auto streaminfo_data = LOADER_TRY(BigEndianInputBitStream::construct(MaybeOwned<AK::Stream>(*streaminfo_data_memory)));
|
||||
|
||||
// 11.10 METADATA_BLOCK_STREAMINFO
|
||||
|
@ -149,7 +149,7 @@ MaybeLoaderError FlacLoaderPlugin::parse_header()
|
|||
// 11.19. METADATA_BLOCK_PICTURE
|
||||
MaybeLoaderError FlacLoaderPlugin::load_picture(FlacRawMetadataBlock& block)
|
||||
{
|
||||
auto memory_stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(block.data.bytes()));
|
||||
auto memory_stream = LOADER_TRY(FixedMemoryStream::construct(block.data.bytes()));
|
||||
auto picture_block_bytes = LOADER_TRY(BigEndianInputBitStream::construct(MaybeOwned<AK::Stream>(*memory_stream)));
|
||||
|
||||
PictureData picture {};
|
||||
|
@ -186,7 +186,7 @@ MaybeLoaderError FlacLoaderPlugin::load_picture(FlacRawMetadataBlock& block)
|
|||
// 11.13. METADATA_BLOCK_SEEKTABLE
|
||||
MaybeLoaderError FlacLoaderPlugin::load_seektable(FlacRawMetadataBlock& block)
|
||||
{
|
||||
auto memory_stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(block.data.bytes()));
|
||||
auto memory_stream = LOADER_TRY(FixedMemoryStream::construct(block.data.bytes()));
|
||||
auto seektable_bytes = LOADER_TRY(BigEndianInputBitStream::construct(MaybeOwned<AK::Stream>(*memory_stream)));
|
||||
for (size_t i = 0; i < block.length / 18; ++i) {
|
||||
// 11.14. SEEKPOINT
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <AK/Error.h>
|
||||
#include <AK/Span.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibCore/MemoryStream.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
||||
namespace Audio {
|
||||
|
|
|
@ -31,7 +31,7 @@ Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> MP3LoaderPlugin::create(Stri
|
|||
|
||||
Result<NonnullOwnPtr<MP3LoaderPlugin>, LoaderError> MP3LoaderPlugin::create(Bytes buffer)
|
||||
{
|
||||
auto stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(buffer));
|
||||
auto stream = LOADER_TRY(FixedMemoryStream::construct(buffer));
|
||||
auto loader = make<MP3LoaderPlugin>(move(stream));
|
||||
|
||||
LOADER_TRY(loader->initialize());
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include "Loader.h"
|
||||
#include "MP3Types.h"
|
||||
#include <AK/BitStream.h>
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <AK/Tuple.h>
|
||||
#include <LibCore/MemoryStream.h>
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibDSP/MDCT.h>
|
||||
|
||||
|
@ -73,7 +73,7 @@ private:
|
|||
AK::Optional<MP3::MP3Frame> m_current_frame;
|
||||
u32 m_current_frame_read;
|
||||
OwnPtr<BigEndianInputBitStream> m_bitstream;
|
||||
Core::Stream::AllocatingMemoryStream m_bit_reservoir;
|
||||
AllocatingMemoryStream m_bit_reservoir;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#include <AK/Debug.h>
|
||||
#include <AK/Endian.h>
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <AK/Try.h>
|
||||
#include <LibCore/MemoryStream.h>
|
||||
|
||||
namespace Audio {
|
||||
|
||||
|
@ -35,7 +35,7 @@ Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::create(Stri
|
|||
|
||||
Result<NonnullOwnPtr<WavLoaderPlugin>, LoaderError> WavLoaderPlugin::create(Bytes buffer)
|
||||
{
|
||||
auto stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(buffer));
|
||||
auto stream = LOADER_TRY(FixedMemoryStream::construct(buffer));
|
||||
auto loader = make<WavLoaderPlugin>(move(stream));
|
||||
|
||||
LOADER_TRY(loader->initialize());
|
||||
|
@ -115,7 +115,7 @@ static ErrorOr<double> read_sample(AK::Stream& stream)
|
|||
LoaderSamples WavLoaderPlugin::samples_from_pcm_data(Bytes const& data, size_t samples_to_read) const
|
||||
{
|
||||
FixedArray<Sample> samples = LOADER_TRY(FixedArray<Sample>::create(samples_to_read));
|
||||
auto stream = LOADER_TRY(Core::Stream::FixedMemoryStream::construct(move(data)));
|
||||
auto stream = LOADER_TRY(FixedMemoryStream::construct(move(data)));
|
||||
|
||||
switch (m_sample_format) {
|
||||
case PcmSampleFormat::Uint8:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue