jsmad/decoder.h

43 lines
757 B
C
Raw Permalink Normal View History

2019-01-14 02:19:37 +00:00
#ifndef DECODER_H
#define DECODER_H
/**
* @todo write docs
*/
#include <deque>
#include <emscripten/val.h>
#include "mad.h"
2019-01-22 21:36:50 +00:00
#define BUFFER_LENGTH 30000000
2019-01-14 02:19:37 +00:00
class Decoder {
public:
Decoder();
~Decoder();
void addFragment(intptr_t bufferPtr, uint32_t length);
emscripten::val decode(uint32_t count = UINT32_MAX);
bool hasMore() const;
uint32_t framesLeft(uint32_t max = UINT32_MAX);
private:
uint32_t sampleRate;
uint8_t channels;
uint32_t cachedLength;
uint16_t samplesPerFrame;
2019-01-22 21:36:50 +00:00
uint8_t* buffer;
2019-01-14 02:19:37 +00:00
bool cached;
2019-01-18 01:50:48 +00:00
mad_synth* synth;
mad_stream* stream;
mad_frame* frame;
2019-01-14 02:19:37 +00:00
emscripten::val context;
private:
void initializeProbe(mad_stream& probe);
2019-01-22 21:36:50 +00:00
2019-01-14 02:19:37 +00:00
};
#endif // DECODER_H