Skip to content

Commit 49cc4c4

Browse files
committed
ProgressStream added totalBytes() and totalSecs()
1 parent 65b83ec commit 49cc4c4

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/AudioTools/AudioStreams.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,12 +1194,17 @@ class ProgressStream : public AudioStream {
11941194
/// Provides the number of processed seconds
11951195
size_t processedSecs() {
11961196
AudioInfo info = audioInfo();
1197-
int byte_rate = info.sample_rate * info.bits_per_sample * info.channels / 8;
1198-
if (byte_rate==0){
1199-
LOGE("Audio Info not defined");
1200-
return 0;
1201-
}
1202-
return total_processed / byte_rate;
1197+
return total_processed / byteRate();
1198+
}
1199+
1200+
/// Provides the total_size provided in the configuration
1201+
size_t totalBytes() {
1202+
return progress_info.total_size;
1203+
}
1204+
1205+
/// Converts the totalBytes() to seconds
1206+
size_t totalSecs() {
1207+
return totalBytes() / byteRate();
12031208
}
12041209

12051210
/// Provides the processed percentage: If no size has been defined we return 0
@@ -1243,6 +1248,14 @@ class ProgressStream : public AudioStream {
12431248
return len;
12441249
}
12451250

1251+
size_t byteRate() {
1252+
int byte_rate = info.sample_rate * info.bits_per_sample * info.channels / 8;
1253+
if (byte_rate==0){
1254+
LOGE("Audio Info not defined");
1255+
return 0;
1256+
}
1257+
return byte_rate;
1258+
}
12461259

12471260
};
12481261

0 commit comments

Comments
 (0)