3 #include "AudioConfig.h"
4 #include "AudioLogger.h"
5 #include "AudioTools/CoreAudio/AudioBasic/Collections/Vector.h"
6 #include "AudioTools/CoreAudio/AudioTypes.h"
29 notifyAudioChange(from);
35 Print *p_print = &out_stream;
42 Print *p_print = &out_stream;
48 virtual void setOutput(
Print &out_stream)
override { p_print = &out_stream; }
52 virtual bool begin(
AudioInfo info)
override {
56 bool begin()
override {
return true; }
57 void end()
override {}
63 Print *p_print =
nullptr;
75 bool isResultPCM()
override {
return true; }
91 virtual const char *
mime() = 0;
102 virtual void setBlockSize(
int blockSize) = 0;
107 virtual int blockSize() = 0;
125 virtual bool begin() {
return true; }
126 virtual void end() {}
135 virtual operator bool() {
return false; }
136 virtual int readStream(Stream &in) {
return 0; };
139 virtual size_t write(
const uint8_t *data,
size_t len) {
140 memset((
void *)data, 0, len);
144 virtual const char *
mime() {
return nullptr; }
167 Print *p_print = &out_stream;
174 Print *p_print = &out_stream;
188 virtual operator bool() = 0;
194 virtual size_t readBytes(uint8_t *data,
size_t len) = 0;
195 Print *p_print =
nullptr;
196 Stream *p_input =
nullptr;
208 int copySize = DEFAULT_BUFFER_SIZE) {
209 p_decoder = &decoder;
210 if (copySize > 0)
resize(copySize);
213 bool begin()
override {
return p_input !=
nullptr && p_decoder->begin(); }
216 void end()
override { p_decoder->end(); }
227 virtual operator bool() {
return *p_decoder; }
231 int read = readBytes(&buffer[0], buffer.size());
233 if (read > 0) written = p_decoder->write(&buffer[0], read);
238 void resize(
int bufferSize) { buffer.resize(bufferSize); }
244 size_t readBytes(uint8_t *data,
size_t len)
override {
245 if (p_input ==
nullptr)
return 0;
246 return p_input->readBytes(data, len);