@@ -23,6 +23,9 @@ static const char *UNDERFLOW_MSG = "data underflow";
23
23
*/
24
24
class AudioStream : public Stream , public AudioBaseInfoDependent {
25
25
public:
26
+ virtual bool begin ();
27
+ virtual void end ();
28
+
26
29
// overwrite to do something useful
27
30
virtual void setAudioInfo (AudioBaseInfo info) {
28
31
LOGD (LOG_METHOD);
@@ -52,6 +55,8 @@ class AudioStream : public Stream, public AudioBaseInfoDependent {
52
55
*/
53
56
class AudioStreamX : public AudioStream {
54
57
public:
58
+ virtual bool begin (){return true ;}
59
+ virtual void end (){}
55
60
virtual size_t readBytes (uint8_t *buffer, size_t length) override { return not_supported (0 ); }
56
61
virtual size_t write (const uint8_t *buffer, size_t size) override { return not_supported (0 ); }
57
62
virtual size_t write (uint8_t ) override { return not_supported (0 ); }
@@ -126,10 +131,11 @@ class MemoryStream : public AudioStream {
126
131
}
127
132
128
133
// resets the read pointer
129
- void begin () {
134
+ bool begin () override {
130
135
LOGD (LOG_METHOD);
131
136
write_pos = buffer_size;
132
137
read_pos = 0 ;
138
+ return true ;
133
139
}
134
140
135
141
virtual size_t write (uint8_t byte) override {
@@ -184,6 +190,10 @@ class MemoryStream : public AudioStream {
184
190
185
191
virtual void flush () override {}
186
192
193
+ virtual void end () {
194
+ read_pos = 0 ;
195
+ }
196
+
187
197
virtual void clear (bool reset = false ) {
188
198
write_pos = 0 ;
189
199
read_pos = 0 ;
@@ -383,9 +393,7 @@ class NullStream : public BufferedStream {
383
393
is_measure = measureWrite;
384
394
}
385
395
386
- void begin (AudioBaseInfo info, int opt = 0 ) {}
387
-
388
- void begin () {}
396
+ bool begin (AudioBaseInfo info, int opt = 0 ) {return true ;}
389
397
390
398
AudioBaseInfo defaultConfig (int opt = 0 ) {
391
399
AudioBaseInfo info;
@@ -720,14 +728,15 @@ class TimerCallbackAudioStream : public BufferedStream,
720
728
}
721
729
722
730
// / Restart the processing
723
- void begin () {
731
+ bool begin () {
724
732
LOGD (LOG_METHOD);
725
733
if (this ->frameCallback != nullptr ) {
726
734
if (cfg.use_timer ) {
727
735
timer->begin (timerCallback, time, TimeUnit::US);
728
736
}
729
737
active = true ;
730
738
}
739
+ return active;
731
740
}
732
741
733
742
// / Stops the processing
0 commit comments