Skip to content

Commit 65b83ec

Browse files
committed
ProgressStream take audio info from AudioStream if possible
1 parent 1ff5231 commit 65b83ec

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/AudioTools/AudioStreams.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,11 @@ class ProgressStream : public AudioStream {
11291129
setStream(stream);
11301130
}
11311131

1132+
ProgressStream(AudioStream &stream){
1133+
setStream(stream);
1134+
p_info_from = &stream;
1135+
}
1136+
11321137
ProgressStreamInfo& defaultConfig() {
11331138
return progress_info;
11341139
}
@@ -1151,16 +1156,23 @@ class ProgressStream : public AudioStream {
11511156
p_print =&print;
11521157
}
11531158

1159+
bool begin() override {
1160+
if (p_info_from!=nullptr){
1161+
setAudioInfo(p_info_from->audioInfo());
1162+
}
1163+
return AudioStream::begin();
1164+
}
1165+
11541166
/// Updates the total size and restarts the percent calculation: Same as calling setSize()
11551167
bool begin(size_t len){
11561168
setSize(len);
1157-
return AudioStream::begin();
1169+
return begin();
11581170
}
11591171

11601172
bool begin(ProgressStreamInfo info){
11611173
progress_info = info;
11621174
setAudioInfo(info);
1163-
return AudioStream::begin();
1175+
return begin();
11641176
}
11651177

11661178
/// Updates the total size and restarts the percent calculation
@@ -1223,6 +1235,7 @@ class ProgressStream : public AudioStream {
12231235
ProgressStreamInfo progress_info;
12241236
Stream *p_stream=nullptr;
12251237
Print *p_print=nullptr;
1238+
AudioInfoDependent *p_info_from=nullptr;
12261239
size_t total_processed = 0;
12271240

12281241
size_t measure(size_t len) {

0 commit comments

Comments
 (0)