mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-19 17:27:51 +03:00
LibAudio: Generalize an encoder interface
This interface is very simple for the time being and can be used to provide encoding functionality in a generalized way. Initialization and parameter setting are intentionally not abstracted for now, since this is usually very format-specific. We just need a general interface for writing samples and errorable finalization.
This commit is contained in:
parent
001ea22917
commit
513e000e86
Notes:
sideshowbarker
2024-07-16 23:59:28 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/513e000e86 Pull-request: https://github.com/SerenityOS/serenity/pull/19790 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/alimpfard
29
Userland/Libraries/LibAudio/Encoder.h
Normal file
29
Userland/Libraries/LibAudio/Encoder.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2023, kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Span.h>
|
||||
#include <LibAudio/Sample.h>
|
||||
|
||||
namespace Audio {
|
||||
|
||||
class Encoder {
|
||||
public:
|
||||
virtual ~Encoder() = default;
|
||||
|
||||
// Encodes the given samples and writes them to the output stream.
|
||||
// Note that due to format restrictions, not all samples might be written immediately, this is only guaranteed after a call to finalize().
|
||||
virtual ErrorOr<void> write_samples(ReadonlySpan<Sample> samples) = 0;
|
||||
|
||||
// Finalizes the stream, future calls to write_samples() will cause an error.
|
||||
// This method makes sure that all samples are encoded and written out.
|
||||
// This method is called in the destructor, but since this can error, you should call this function yourself before disposing of the decoder.
|
||||
virtual ErrorOr<void> finalize() = 0;
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user