added code for mp3 and jpeg parsing
added interface for data sources
This commit is contained in:
42
data/formats/DataSourceFile.h
Normal file
42
data/formats/DataSourceFile.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../ext/sd/File.h"
|
||||
|
||||
/** data source using our filesystem */
|
||||
class DataSourceFile {
|
||||
|
||||
File* f;
|
||||
|
||||
public:
|
||||
|
||||
/** empty ctor */
|
||||
DataSourceFile() : f(nullptr) {
|
||||
|
||||
}
|
||||
|
||||
/** ctor with the filesystem file to wrap */
|
||||
DataSourceFile(File& f) : f(&f) {
|
||||
|
||||
}
|
||||
|
||||
/** get the current position */
|
||||
uint32_t curPos() const {
|
||||
return f->curPos();
|
||||
}
|
||||
|
||||
/** seek to the given position */
|
||||
void seekTo(uint32_t newPos) {
|
||||
f->seekTo(newPos);
|
||||
}
|
||||
|
||||
/** read x bytes from the input into dst */
|
||||
uint32_t read(uint32_t size, uint8_t* dst) {
|
||||
return f->read(size, dst);
|
||||
}
|
||||
|
||||
/** read an entity */
|
||||
template <typename T> void readType(T& dst) {
|
||||
read(sizeof(T), (uint8_t*)&dst);
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user