ladybird/Libraries/LibMedia/AudioDecoder.h
Zaggy1024 0ff330c906 LibMedia: Play audio through PlaybackManager using Providers/Sinks
This commit implements the functionality to play back audio through
PlaybackManager.

To decode the audio data, AudioDataProviders are created for each track
in the provided media data. These providers will fill their audio block
queue, then sit idle until their corresponding tracks are enabled.

In order to output the audio, one AudioMixingSink is created which
manages a PlaybackStream which requests audio blocks from multiple
AudioDataProviders and mixes them into one buffer with sample-perfect
precision.
2025-10-27 17:28:49 -07:00

30 lines
657 B
C++

/*
* Copyright (c) 2025, Gregory Bertilson <gregory@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/Time.h>
#include <AK/Vector.h>
#include <LibMedia/AudioBlock.h>
#include <LibMedia/DecoderError.h>
namespace Media {
class AudioDecoder {
public:
virtual ~AudioDecoder() { }
virtual DecoderErrorOr<void> receive_coded_data(AK::Duration timestamp, ReadonlyBytes coded_data) = 0;
// Writes all buffered audio samples to the provided block.
virtual DecoderErrorOr<void> write_next_block(AudioBlock&) = 0;
virtual void flush() = 0;
};
}