mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 12:31:51 +00:00
add MemoryPCMStream
This commit is contained in:
parent
4b19c29a29
commit
31137f83b6
2 changed files with 105 additions and 0 deletions
42
src/audio/MemoryPCMStream.hpp
Normal file
42
src/audio/MemoryPCMStream.hpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "audio.hpp"
|
||||
#include "util/span.hpp"
|
||||
|
||||
namespace audio {
|
||||
class MemoryPCMStream : public PCMStream {
|
||||
public:
|
||||
MemoryPCMStream(uint sampleRate, uint channels, uint bitsPerSample);
|
||||
|
||||
void feed(util::span<ubyte> bytes);
|
||||
|
||||
bool isOpen() const override;
|
||||
|
||||
void close() override;
|
||||
|
||||
size_t read(char* buffer, size_t bufferSize) override;
|
||||
|
||||
size_t getTotalSamples() const override;
|
||||
|
||||
duration_t getTotalDuration() const override;
|
||||
|
||||
uint getChannels() const override;
|
||||
|
||||
uint getSampleRate() const override;
|
||||
|
||||
uint getBitsPerSample() const override;
|
||||
|
||||
bool isSeekable() const override;
|
||||
|
||||
void seek(size_t position) override;
|
||||
private:
|
||||
uint sampleRate;
|
||||
uint channels;
|
||||
uint bitsPerSample;
|
||||
bool open = true;
|
||||
|
||||
std::vector<ubyte> buffer;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue