Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

o Write a warning when file size exceeds prediction.

  • Loading branch information...
commit 189625c8e21894ad0ad7213f2995db783b467eb1 1 parent 8f4d8eb
@hzeller authored
View
17 convolve-file-handler.cc
@@ -169,7 +169,11 @@ void ConvolveFileHandler::GetHandlerStatus(HandlerStats *stats) {
int ConvolveFileHandler::Stat(struct stat *st) {
const off_t current_file_size = output_buffer_->FileSize();
- if (current_file_size > start_estimating_size_) {
+ if (output_buffer_->IsFileComplete()) {
+ // Once we're complete, we know exactly the final size.
+ file_stat_.st_size = current_file_size;
+ }
+ else if (current_file_size > start_estimating_size_) {
const int frames_done = in_info_.frames - frames_left();
if (frames_done > 0) {
const float estimated_end = 1.0 * in_info_.frames / frames_done;
@@ -207,6 +211,7 @@ ConvolveFileHandler::ConvolveFileHandler(FolveFilesystem *fs,
// the size of the file to check when to stop.
fstat(filedes_, &file_stat_);
start_estimating_size_ = 0.4 * file_stat_.st_size;
+ original_file_size_ = file_stat_.st_size;
file_stat_.st_size *= fs->file_oversize_factor();
// The flac header we get is more rich than what we can create via
@@ -485,6 +490,16 @@ void ConvolveFileHandler::Close() {
if (snd_out_) sf_close(snd_out_);
snd_out_ = NULL;
close(filedes_);
+
+ const double factor = 1.0 * output_buffer_->FileSize() / original_file_size_;
+ if (factor > fs_->file_oversize_factor()) {
+ syslog(LOG_WARNING, "File larger than prediction: "
+ "%ldx%.2f=%ld < %ld (x%4.2f) '%s'; "
+ "naive streamer implementations might trip.",
+ original_file_size_, fs_->file_oversize_factor(),
+ (off_t) (original_file_size_ * fs_->file_oversize_factor()),
+ output_buffer_->FileSize(), factor, base_stats_.filename.c_str());
+ }
}
bool ConvolveFileHandler::LooksLikeInputIsFlac(const SF_INFO &sndinfo,
View
1  convolve-file-handler.h
@@ -89,6 +89,7 @@ class ConvolveFileHandler : public FileHandler,
HandlerStats base_stats_; // UI information about current file.
struct stat file_stat_; // we dynamically report a changing size.
+ off_t original_file_size_;
off_t start_estimating_size_; // essentially const.
bool error_;
View
2  folve-filesystem.h
@@ -106,7 +106,7 @@ class FolveFilesystem {
// with a factor - overestimating seems to be less of a problem than
// understimating.
// This is the factor (maybe configurable later).
- float file_oversize_factor() { return 1.1; }
+ double file_oversize_factor() { return 1.15; }
// Some stats.
int total_file_openings() { return total_file_openings_; }
Please sign in to comment.
Something went wrong with that request. Please try again.