Skip to content

Commit 57754e1

Browse files
committed
Standardized begin and end
1 parent 02f51b2 commit 57754e1

File tree

3 files changed

+15
-122
lines changed

3 files changed

+15
-122
lines changed

src/AudioTools/AudioSPDIF.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,10 @@ class SPDIFStream : public AudioStreamX {
171171
return i2sOn;
172172
}
173173

174-
bool end() {
174+
void end() {
175175
LOGD(LOG_METHOD);
176176
i2s.end();
177177
i2sOn = false;
178-
return true;
179178
}
180179

181180
/// Change the audio parameters

src/AudioTools/AudioStreams.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ static const char *UNDERFLOW_MSG = "data underflow";
2323
*/
2424
class AudioStream : public Stream, public AudioBaseInfoDependent {
2525
public:
26+
virtual bool begin();
27+
virtual void end();
28+
2629
// overwrite to do something useful
2730
virtual void setAudioInfo(AudioBaseInfo info) {
2831
LOGD(LOG_METHOD);
@@ -52,6 +55,8 @@ class AudioStream : public Stream, public AudioBaseInfoDependent {
5255
*/
5356
class AudioStreamX : public AudioStream {
5457
public:
58+
virtual bool begin(){return true;}
59+
virtual void end(){}
5560
virtual size_t readBytes(uint8_t *buffer, size_t length) override { return not_supported(0); }
5661
virtual size_t write(const uint8_t *buffer, size_t size) override{ return not_supported(0); }
5762
virtual size_t write(uint8_t) override { return not_supported(0); }
@@ -126,10 +131,11 @@ class MemoryStream : public AudioStream {
126131
}
127132

128133
// resets the read pointer
129-
void begin() {
134+
bool begin() override {
130135
LOGD(LOG_METHOD);
131136
write_pos = buffer_size;
132137
read_pos = 0;
138+
return true;
133139
}
134140

135141
virtual size_t write(uint8_t byte) override {
@@ -184,6 +190,10 @@ class MemoryStream : public AudioStream {
184190

185191
virtual void flush() override {}
186192

193+
virtual void end() {
194+
read_pos = 0;
195+
}
196+
187197
virtual void clear(bool reset = false) {
188198
write_pos = 0;
189199
read_pos = 0;
@@ -383,9 +393,7 @@ class NullStream : public BufferedStream {
383393
is_measure = measureWrite;
384394
}
385395

386-
void begin(AudioBaseInfo info, int opt = 0) {}
387-
388-
void begin() {}
396+
bool begin(AudioBaseInfo info, int opt = 0) {return true;}
389397

390398
AudioBaseInfo defaultConfig(int opt = 0) {
391399
AudioBaseInfo info;
@@ -720,14 +728,15 @@ class TimerCallbackAudioStream : public BufferedStream,
720728
}
721729

722730
/// Restart the processing
723-
void begin() {
731+
bool begin() {
724732
LOGD(LOG_METHOD);
725733
if (this->frameCallback != nullptr) {
726734
if (cfg.use_timer) {
727735
timer->begin(timerCallback, time, TimeUnit::US);
728736
}
729737
active = true;
730738
}
739+
return active;
731740
}
732741

733742
/// Stops the processing

src/Experiments/SDCard.h

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)