mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2026-04-19 06:42:43 +00:00
refactoring
This commit is contained in:
43
core/src/utils/riff.h
Normal file
43
core/src/utils/riff.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include <mutex>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <stack>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace riff {
|
||||
#pragma pack(push, 1)
|
||||
struct ChunkHeader {
|
||||
char id[4];
|
||||
uint32_t size;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct ChunkDesc {
|
||||
ChunkHeader hdr;
|
||||
std::streampos pos;
|
||||
};
|
||||
|
||||
class Writer {
|
||||
public:
|
||||
bool open(std::string path, const char form[4]);
|
||||
bool isOpen();
|
||||
void close();
|
||||
|
||||
void beginList(const char id[4]);
|
||||
void endList();
|
||||
|
||||
void beginChunk(const char id[4]);
|
||||
void endChunk();
|
||||
|
||||
void write(const uint8_t* data, size_t len);
|
||||
|
||||
private:
|
||||
void beginRIFF(const char form[4]);
|
||||
void endRIFF();
|
||||
|
||||
std::recursive_mutex mtx;
|
||||
std::ofstream file;
|
||||
std::stack<ChunkDesc> chunks;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user