Permalink
Browse files

o Fix channel availability test.

o The lowest bit on Byte 20 of the header is actually in use.
  • Loading branch information...
1 parent 30c747e commit 013631a49c052f64c933e81a5d25ef7c8d834965 @hzeller committed Nov 19, 2012
Showing with 19 additions and 10 deletions.
  1. +11 −5 convolve-file-handler.cc
  2. +2 −1 processor-pool.cc
  3. +2 −2 sound-processor.cc
  4. +4 −2 zita-config.h
View
16 convolve-file-handler.cc
@@ -275,13 +275,19 @@ void ConvolveFileHandler::SetOutputSoundfile(ConversionBuffer *out_buffer,
out_buffer->WriteCharAt((1152 & 0xFF00) >> 8, 10);
out_buffer->WriteCharAt((1152 & 0x00FF) , 11);
for (int i = 12; i < 18; ++i) out_buffer->WriteCharAt(0, i); // framesize
- // upper nibble: lowest 4 bit of samplerate, lower nibble: channels << 1
- // 1 bit free.
+ // Byte 20:
+ // XXXX YYY Z
+ // X: lowest 4 bit samplerate; Y: channels - 1; Z: upper bit bit/sample
+ int bits = 16;
+ if ((info.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_24) bits = 24;
+ if ((info.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_32) bits = 32;
out_buffer->WriteCharAt((in_info_.samplerate & 0x0f) << 4
- | (info.channels - 1) << 1, 20);
- } else {
+ | (info.channels - 1) << 1
+ | ((bits - 1 ) & 0x10) >> 4,
+ 20);
+ } else if ((info.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_FLAC) {
// .. and if SNDFILE writes the header, it misses out in writing the
- // number of samples to be expected. So let's fill that in.
+ // number of samples to be expected. So let's fill that in for flac files.
// The MD5 sum starts at position strlen("fLaC") + 4 + 18 = 26
// The 32 bits before that are the samples (and another 4 bit before that,
// ignoring that for now).
View
3 processor-pool.cc
@@ -84,8 +84,9 @@ SoundProcessor *ProcessorPool::GetOrCreate(const std::string &base_dir,
if (result == NULL) {
*errmsg = "Problem parsing " + config_path;
syslog(LOG_ERR, "filter-config %s is broken.", config_path.c_str());
+ } else {
+ DLogf("Processor %p: Newly created [%s]", result, config_path.c_str());
}
- DLogf("Processor %p: Newly created [%s]", result, config_path.c_str());
return result;
}
View
4 sound-processor.cc
@@ -41,8 +41,8 @@ SoundProcessor *SoundProcessor::Create(const std::string &config_file,
{ // fftw threading bug workaround, see above.
folve::MutexLock l(&fftw_mutex);
if ((config(&zita, config_file.c_str()) != 0)
- || zita.convproc->inpdata(channels - 1) == NULL
- || zita.convproc->outdata(channels - 1) == NULL) {
+ || zita.convproc->inpdata(zita.ninp - 1) == NULL
+ || zita.convproc->outdata(zita.nout - 1) == NULL) {
return NULL;
}
}
View
6 zita-config.h
@@ -30,15 +30,17 @@
#include "zita-sstring.h"
struct ZitaConfig {
- Convproc *convproc;
+ const char *config_file; // Configuration file we're reading from.
+ Convproc *convproc; // Resulting filter object.
+
+ // Parameters.
int latency;
int options;
int fsamp;
int fragm;
int ninp;
int nout;
int size;
- const char *config_file;
};
enum { NOERR, ERR_OTHER, ERR_SYNTAX, ERR_PARAM, ERR_ALLOC, ERR_CANTCD, ERR_COMMAND, ERR_NOCONV, ERR_IONUM };

0 comments on commit 013631a

Please sign in to comment.