Browse files

o Fix problem with re-initializing the convproc. Turns out that the c…

…onfig()

  called dirname() that modifies the string.
o Make strings printed less noisy.
o Print out some information about the file we see.
  • Loading branch information...
1 parent 0115879 commit 7e756eb97b9a422446d48cbbaf068aee7cb6a917 @hzeller committed Sep 10, 2012
Showing with 31 additions and 18 deletions.
  1. +3 −3 Makefile
  2. +22 −14 convolver.cc
  3. +6 −1 zita-config.cc
View
6 Makefile
@@ -1,7 +1,7 @@
CC=gcc
CXX=g++
-CFLAGS=-D_FILE_OFFSET_BITS=64 -Wall -g
-CXXFLAGS=-Wall -g
+CFLAGS=-D_FILE_OFFSET_BITS=64 -Wall -g -O3
+CXXFLAGS=-Wall -g -O3
LDFLAGS=-lfuse -lsndfile -ffast-math -lfftw3f -lpthread
fuse-convolve: fuse-convolve.o convolver.o conversion-buffer.o zita-audiofile.o zita-config.o zita-fconfig.o zita-sstring.o zita-convolver.o
@@ -11,4 +11,4 @@ copy-music: copy-music.cc
$(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS)
clean:
- rm fuse-convolve *.o
+ rm -f fuse-convolve *.o
View
36 convolver.cc
@@ -24,10 +24,6 @@
#include "conversion-buffer.h"
#include "zita-config.h"
-// Something is fishy with the convproc. It only works if we have
-// one instance we re-use. Otherwise it crashes
-#define REQUIRES_GLOBAL_CONVPROC 1
-
const char *sGlobal_zita_config;
namespace {
@@ -80,6 +76,22 @@ class SndFileFilter :
return;
}
+ // TODO(hzeller): with the following information, we can choose the
+ // configuration file to use. We might move this out into a factory: in
+ // case we don't have that configuration file, we might fall back to
+ // PassThroughFilter.
+ int bits = 16;
+ if ((in_info.format & SF_FORMAT_PCM_24) != 0) bits = 24;
+ if ((in_info.format & SF_FORMAT_PCM_32) != 0) bits = 32;
+ fprintf(stderr, "File %s, %d-bit, %d channels, %dHz\n", path,
+ bits, in_info.channels, in_info.samplerate);
+
+ // Initialize zita config, but don't allocate converter quite yet.
+ memset(&zita_, 0, sizeof(zita_));
+ zita_.fsamp = in_info.samplerate;
+ zita_.ninp = in_info.channels;
+ zita_.nout = in_info.channels;
+
channels_ = in_info.channels;
input_frames_left_ = in_info.frames;
@@ -95,13 +107,11 @@ class SndFileFilter :
}
virtual ~SndFileFilter() {
-#ifndef REQUIRES_GLOBAL_CONVPROC
if (zita_.convproc) {
zita_.convproc->stop_process();
zita_.convproc->cleanup();
delete zita_.convproc;
}
-#endif
delete output_buffer_;
delete [] raw_sample_buffer_;
}
@@ -154,7 +164,12 @@ class SndFileFilter :
raw_sample_buffer_ = new float[zita_.fragm * channels_];
}
int r = sf_readf_float(snd_in_, raw_sample_buffer_, zita_.fragm);
- fprintf(stderr, "** conversion callback; %d new samples **\n", r);
+ if (r == 0) { fprintf(stderr, "eeeempty\n"); return false; }
+ if (r == (int) zita_.fragm) {
+ fprintf(stderr, ".");
+ } else {
+ fprintf(stderr, "[%d]\n", r);
+ }
if (r < (int) zita_.fragm) {
// zero out the rest of the buffer
const int missing = zita_.fragm - r;
@@ -195,15 +210,8 @@ class SndFileFilter :
// Used in conversion.
float *raw_sample_buffer_;
int input_frames_left_;
-#ifdef REQUIRES_GLOBAL_CONVPROC
- static ZitaConfig zita_;
-#else
ZitaConfig zita_;
-#endif
};
-#ifdef REQUIRES_GLOBAL_CONVPROC
- ZitaConfig SndFileFilter::zita_;
-#endif
} // namespace
// We do a very simple decision which filter to apply by looking at the suffix.
View
7 zita-config.cc
@@ -273,13 +273,18 @@ int config (ZitaConfig *cfg, const char *config)
char cdir [1024];
char *p, *q;
+ fprintf(stderr, "config('%s')\n", config);
+
if (! (F = fopen (config, "r")))
{
fprintf (stderr, "Can't open '%s' for reading\n", config);
return -1;
}
+
+ char *config_name_copy = strdup(config);
+ strcpy (cdir, dirname(config_name_copy));
+ free(config_name_copy);
- strcpy (cdir, dirname ((char *) config));
stat = 0;
lnum = 0;

0 comments on commit 7e756eb

Please sign in to comment.