summaryrefslogtreecommitdiff
path: root/src/codecs/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/codecs/include')
-rw-r--r--src/codecs/include/codec.hpp4
-rw-r--r--src/codecs/include/dr_flac.hpp (renamed from src/codecs/include/miniflac.hpp)23
-rw-r--r--src/codecs/include/mad.hpp4
-rw-r--r--src/codecs/include/opus.hpp4
-rw-r--r--src/codecs/include/source_buffer.hpp1
-rw-r--r--src/codecs/include/vorbis.hpp4
-rw-r--r--src/codecs/include/wav.hpp4
7 files changed, 14 insertions, 30 deletions
diff --git a/src/codecs/include/codec.hpp b/src/codecs/include/codec.hpp
index 8aa391b6..e48e3c58 100644
--- a/src/codecs/include/codec.hpp
+++ b/src/codecs/include/codec.hpp
@@ -117,7 +117,7 @@ class ICodec {
* Decodes metadata or headers from the given input stream, and returns the
* format for the samples that will be decoded from it.
*/
- virtual auto OpenStream(std::shared_ptr<IStream> input)
+ virtual auto OpenStream(std::shared_ptr<IStream> input,uint32_t offset)
-> cpp::result<OutputFormat, Error> = 0;
struct OutputInfo {
@@ -130,8 +130,6 @@ class ICodec {
*/
virtual auto DecodeTo(cpp::span<sample::Sample> destination)
-> cpp::result<OutputInfo, Error> = 0;
-
- virtual auto SeekTo(size_t target_sample) -> cpp::result<void, Error> = 0;
};
auto CreateCodecForType(StreamType type) -> std::optional<ICodec*>;
diff --git a/src/codecs/include/miniflac.hpp b/src/codecs/include/dr_flac.hpp
index d57b08a3..547876f4 100644
--- a/src/codecs/include/miniflac.hpp
+++ b/src/codecs/include/dr_flac.hpp
@@ -6,7 +6,6 @@
#pragma once
-#include <sys/_stdint.h>
#include <cstddef>
#include <cstdint>
#include <memory>
@@ -14,7 +13,7 @@
#include <string>
#include <utility>
-#include "miniflac.h"
+#include "dr_flac.h"
#include "sample.hpp"
#include "source_buffer.hpp"
#include "span.hpp"
@@ -23,29 +22,23 @@
namespace codecs {
-class MiniFlacDecoder : public ICodec {
+class DrFlacDecoder : public ICodec {
public:
- MiniFlacDecoder();
- ~MiniFlacDecoder();
+ DrFlacDecoder();
+ ~DrFlacDecoder();
- auto OpenStream(std::shared_ptr<IStream> input)
+ auto OpenStream(std::shared_ptr<IStream> input,uint32_t offset)
-> cpp::result<OutputFormat, Error> override;
auto DecodeTo(cpp::span<sample::Sample> destination)
-> cpp::result<OutputInfo, Error> override;
- auto SeekTo(std::size_t target_sample) -> cpp::result<void, Error> override;
-
- MiniFlacDecoder(const MiniFlacDecoder&) = delete;
- MiniFlacDecoder& operator=(const MiniFlacDecoder&) = delete;
+ DrFlacDecoder(const DrFlacDecoder&) = delete;
+ DrFlacDecoder& operator=(const DrFlacDecoder&) = delete;
private:
std::shared_ptr<IStream> input_;
- SourceBuffer buffer_;
-
- std::unique_ptr<miniflac_t> flac_;
- std::array<int32_t*, 2> samples_by_channel_;
- std::optional<size_t> current_sample_;
+ drflac *flac_;
};
} // namespace codecs
diff --git a/src/codecs/include/mad.hpp b/src/codecs/include/mad.hpp
index 813aa86d..ead0b2a2 100644
--- a/src/codecs/include/mad.hpp
+++ b/src/codecs/include/mad.hpp
@@ -26,14 +26,12 @@ class MadMp3Decoder : public ICodec {
MadMp3Decoder();
~MadMp3Decoder();
- auto OpenStream(std::shared_ptr<IStream> input)
+ auto OpenStream(std::shared_ptr<IStream> input,uint32_t offset)
-> cpp::result<OutputFormat, Error> override;
auto DecodeTo(cpp::span<sample::Sample> destination)
-> cpp::result<OutputInfo, Error> override;
- auto SeekTo(std::size_t target_sample) -> cpp::result<void, Error> override;
-
MadMp3Decoder(const MadMp3Decoder&) = delete;
MadMp3Decoder& operator=(const MadMp3Decoder&) = delete;
diff --git a/src/codecs/include/opus.hpp b/src/codecs/include/opus.hpp
index 45b1b07a..de2f7131 100644
--- a/src/codecs/include/opus.hpp
+++ b/src/codecs/include/opus.hpp
@@ -26,14 +26,12 @@ class XiphOpusDecoder : public ICodec {
XiphOpusDecoder();
~XiphOpusDecoder();
- auto OpenStream(std::shared_ptr<IStream> input)
+ auto OpenStream(std::shared_ptr<IStream> input,uint32_t offset)
-> cpp::result<OutputFormat, Error> override;
auto DecodeTo(cpp::span<sample::Sample> destination)
-> cpp::result<OutputInfo, Error> override;
- auto SeekTo(std::size_t target_sample) -> cpp::result<void, Error> override;
-
XiphOpusDecoder(const XiphOpusDecoder&) = delete;
XiphOpusDecoder& operator=(const XiphOpusDecoder&) = delete;
diff --git a/src/codecs/include/source_buffer.hpp b/src/codecs/include/source_buffer.hpp
index d0d7635a..7834834d 100644
--- a/src/codecs/include/source_buffer.hpp
+++ b/src/codecs/include/source_buffer.hpp
@@ -24,6 +24,7 @@ class SourceBuffer {
auto Refill(IStream* src) -> bool;
auto AddBytes(std::function<size_t(cpp::span<std::byte>)> writer) -> void;
auto ConsumeBytes(std::function<size_t(cpp::span<std::byte>)> reader) -> void;
+ auto Empty() -> void;
SourceBuffer(const SourceBuffer&) = delete;
SourceBuffer& operator=(const SourceBuffer&) = delete;
diff --git a/src/codecs/include/vorbis.hpp b/src/codecs/include/vorbis.hpp
index b96a0407..3cf0f9ce 100644
--- a/src/codecs/include/vorbis.hpp
+++ b/src/codecs/include/vorbis.hpp
@@ -26,14 +26,12 @@ class TremorVorbisDecoder : public ICodec {
TremorVorbisDecoder();
~TremorVorbisDecoder();
- auto OpenStream(std::shared_ptr<IStream> input)
+ auto OpenStream(std::shared_ptr<IStream> input,uint32_t offset)
-> cpp::result<OutputFormat, Error> override;
auto DecodeTo(cpp::span<sample::Sample> destination)
-> cpp::result<OutputInfo, Error> override;
- auto SeekTo(std::size_t target_sample) -> cpp::result<void, Error> override;
-
TremorVorbisDecoder(const TremorVorbisDecoder&) = delete;
TremorVorbisDecoder& operator=(const TremorVorbisDecoder&) = delete;
diff --git a/src/codecs/include/wav.hpp b/src/codecs/include/wav.hpp
index 896976dd..40138968 100644
--- a/src/codecs/include/wav.hpp
+++ b/src/codecs/include/wav.hpp
@@ -31,14 +31,12 @@ class WavDecoder : public ICodec {
WavDecoder();
~WavDecoder();
- auto OpenStream(std::shared_ptr<IStream> input)
+ auto OpenStream(std::shared_ptr<IStream> input,uint32_t offset)
-> cpp::result<OutputFormat, Error> override;
auto DecodeTo(cpp::span<sample::Sample> destination)
-> cpp::result<OutputInfo, Error> override;
- auto SeekTo(std::size_t target_sample) -> cpp::result<void, Error> override;
-
WavDecoder(const WavDecoder&) = delete;
WavDecoder& operator=(const WavDecoder&) = delete;