Skip to content

Commit

Permalink
o skipping debug message.
Browse files Browse the repository at this point in the history
  • Loading branch information
hzeller committed Sep 12, 2012
1 parent f8cb9e5 commit e2619a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
15 changes: 13 additions & 2 deletions conversion-buffer.cc
Expand Up @@ -53,7 +53,8 @@ static sf_count_t DummySeek(sf_count_t offset, int whence, void *userdata) {
// header. It actually attempts to write that end up at the end of the
// file. We don't care, it is not accessed for reading anymore.
// TODO(hzeller): Suppress writing after close() and really warn
if (reinterpret_cast<ConversionBuffer*>(userdata)->sndfile_writes_enabled()) {
if (offset > 0 &&
reinterpret_cast<ConversionBuffer*>(userdata)->sndfile_writes_enabled()) {
fprintf(stderr, "DummySeek called %ld\n", offset);
}
return 0;
Expand Down Expand Up @@ -99,9 +100,19 @@ ssize_t ConversionBuffer::Read(char *buf, size_t size, off_t offset) {
const off_t required_min_written = offset + 1;
// As soon as someone tries to read beyond of what we already have, we call
// our WriteToSoundfile() callback that fills more of it.
const size_t initial_written = total_written_;
int callback_count = 0;
while (total_written_ < required_min_written) {
++callback_count;
if (!source_->AddMoreSoundData())
break;
}
return pread(tmpfile_, buf, size, offset);
const ssize_t result = pread(tmpfile_, buf, size, offset);
if (callback_count > 10) {
fprintf(stderr, "Looks like file-skipping: "
"From %ld -> %ld to read %ld bytes (got %ld)"
"(and we filtered all that audio data in-between .. in vain)\n"
initial_written, total_written_, size, result);
}
return result;
}
13 changes: 9 additions & 4 deletions convolver.cc
Expand Up @@ -78,6 +78,12 @@ class SndFileFilter :
int bits = 16;
if ((in_info.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_24) bits = 24;
if ((in_info.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_32) bits = 32;

long int seconds = in_info.frames / in_info.samplerate;
fprintf(stderr, "%ld samples @ %.1fkHz, %d Bit; duration %ld:%02ld\n",
in_info.frames, in_info.samplerate / 1000.0,
bits, seconds / 60, seconds % 60);

char config_path[1024];
snprintf(config_path, sizeof(config_path), "%s/filter-%d-%d-%d.conf",
global_zita_config_dir, in_info.samplerate,
Expand All @@ -89,7 +95,7 @@ class SndFileFilter :
return NULL;
} else {
fprintf(stderr, "- found.\n");
}
}
return new SndFileFilter(path, filedes, snd, in_info, config_path);
}

Expand Down Expand Up @@ -144,9 +150,9 @@ class SndFileFilter :
struct SF_INFO out_info = in_info;
out_info.seekable = 0;
if ((in_info.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_OGG) {
// If the input was ogg, we're re-coding this to flac/24.
// If the input was ogg, we're re-coding this to flac/16.
out_info.format = SF_FORMAT_FLAC;
out_info.format |= SF_FORMAT_PCM_24;
out_info.format |= SF_FORMAT_PCM_16;
}
else if ((in_info.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV
&& (in_info.format & SF_FORMAT_SUBMASK) != SF_FORMAT_PCM_16) {
Expand Down Expand Up @@ -206,7 +212,6 @@ class SndFileFilter :
raw_sample_buffer_ = new float[zita_.fragm * channels_];
}
int r = sf_readf_float(snd_in_, raw_sample_buffer_, zita_.fragm);
if (r == 0) { fprintf(stderr, "eeeempty\n"); return false; }
if (r == (int) zita_.fragm) {
fprintf(stderr, ".");
} else {
Expand Down

0 comments on commit e2619a6

Please sign in to comment.