Skip to content

Commit e8a6f56

Browse files
committed
TimeInfoStream readBytes
1 parent 5f6ac2c commit e8a6f56

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Experiments/TimeInfoStream.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,17 @@ class TimeInfoStream : public AudioStreamX {
6969

7070
/// Provides only data for the indicated start and end time
7171
size_t readBytes(uint8_t *buffer, size_t length) override {
72+
// if reading is not supported we stop
7273
if (p_stream==nullptr) return 0;
73-
size_t result = p_stream->readBytes(buffer, length);
74-
calculateTime(result);
74+
// if we are past the end we stop
75+
if (!isActive()) return 0;
76+
// read the data now
77+
size_t result=0;
78+
do {
79+
result = p_stream->readBytes(buffer, length);
80+
calculateTime(result);
81+
// ignore data before start time
82+
} while(result>0 && current_time<start_time);
7583
return isPlaying()?result : 0;
7684
}
7785

0 commit comments

Comments
 (0)