@@ -27,10 +27,12 @@ class TimeInfoStream : public AudioStreamX {
27
27
end_time = endSeconds;
28
28
}
29
29
30
+ // / Defines the start time in seconds. The audio before the start time will be skipped
30
31
void setStartTime (long startSeconds){
31
32
start_time = startSeconds;
32
33
}
33
34
35
+ // / Defines (an optional) the end time in seconds. After the end time no audio is played and available() will return 0
34
36
void setEndTime (long endSeconds){
35
37
end_time = endSeconds;
36
38
}
@@ -63,18 +65,30 @@ class TimeInfoStream : public AudioStreamX {
63
65
return isActive ();
64
66
}
65
67
68
+ // / Provides only data for the indicated start and end time
66
69
size_t readBytes (uint8_t *buffer, size_t length) override {
67
70
if (p_stream==nullptr ) return 0 ;
68
71
calculateTime (length);
69
- return isPlaying ()?p_stream->readBytes (buffer, length):length;
72
+ size_t result = p_stream->readBytes (buffer, length);
73
+ return isPlaying ()?result : 0 ;
70
74
}
71
75
76
+ // / Plays only data for the indiated start and end time
72
77
size_t write (const uint8_t *buffer, size_t length) override {
73
78
calculateTime (length);
74
79
return isPlaying ()?p_print->write (buffer, length):length;
75
80
}
76
81
77
- int available () override { return p_stream!=nullptr ? p_stream->available ():0 ; };
82
+ // / Provides the available bytes until the end time has reached
83
+ int available () override {
84
+ if (p_stream==nullptr ) return 0 ;
85
+ return isActive () ? p_stream->available () : 0 ;
86
+ }
87
+
88
+ void setAudioInfo (AudioBaseInfo info) override {
89
+ p_info->setAudioInfo (info);
90
+ }
91
+
78
92
int availableForWrite () override { return p_print->availableForWrite (); }
79
93
80
94
protected:
0 commit comments