Skip to content

Commit

Permalink
o Fix channel availability test.
Browse files Browse the repository at this point in the history
o The lowest bit on Byte 20 of the header is actually in use.
  • Loading branch information
hzeller committed Nov 19, 2012
1 parent 30c747e commit 013631a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
16 changes: 11 additions & 5 deletions convolve-file-handler.cc
Expand Up @@ -275,13 +275,19 @@ void ConvolveFileHandler::SetOutputSoundfile(ConversionBuffer *out_buffer,
out_buffer->WriteCharAt((1152 & 0xFF00) >> 8, 10); out_buffer->WriteCharAt((1152 & 0xFF00) >> 8, 10);
out_buffer->WriteCharAt((1152 & 0x00FF) , 11); out_buffer->WriteCharAt((1152 & 0x00FF) , 11);
for (int i = 12; i < 18; ++i) out_buffer->WriteCharAt(0, i); // framesize for (int i = 12; i < 18; ++i) out_buffer->WriteCharAt(0, i); // framesize
// upper nibble: lowest 4 bit of samplerate, lower nibble: channels << 1 // Byte 20:
// 1 bit free. // 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 out_buffer->WriteCharAt((in_info_.samplerate & 0x0f) << 4
| (info.channels - 1) << 1, 20); | (info.channels - 1) << 1
} else { | ((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 // .. 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 MD5 sum starts at position strlen("fLaC") + 4 + 18 = 26
// The 32 bits before that are the samples (and another 4 bit before that, // The 32 bits before that are the samples (and another 4 bit before that,
// ignoring that for now). // ignoring that for now).
Expand Down
3 changes: 2 additions & 1 deletion processor-pool.cc
Expand Up @@ -84,8 +84,9 @@ SoundProcessor *ProcessorPool::GetOrCreate(const std::string &base_dir,
if (result == NULL) { if (result == NULL) {
*errmsg = "Problem parsing " + config_path; *errmsg = "Problem parsing " + config_path;
syslog(LOG_ERR, "filter-config %s is broken.", config_path.c_str()); 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; return result;
} }


Expand Down
4 changes: 2 additions & 2 deletions sound-processor.cc
Expand Up @@ -41,8 +41,8 @@ SoundProcessor *SoundProcessor::Create(const std::string &config_file,
{ // fftw threading bug workaround, see above. { // fftw threading bug workaround, see above.
folve::MutexLock l(&fftw_mutex); folve::MutexLock l(&fftw_mutex);
if ((config(&zita, config_file.c_str()) != 0) if ((config(&zita, config_file.c_str()) != 0)
|| zita.convproc->inpdata(channels - 1) == NULL || zita.convproc->inpdata(zita.ninp - 1) == NULL
|| zita.convproc->outdata(channels - 1) == NULL) { || zita.convproc->outdata(zita.nout - 1) == NULL) {
return NULL; return NULL;
} }
} }
Expand Down
6 changes: 4 additions & 2 deletions zita-config.h
Expand Up @@ -30,15 +30,17 @@
#include "zita-sstring.h" #include "zita-sstring.h"


struct ZitaConfig { struct ZitaConfig {
Convproc *convproc; const char *config_file; // Configuration file we're reading from.
Convproc *convproc; // Resulting filter object.

// Parameters.
int latency; int latency;
int options; int options;
int fsamp; int fsamp;
int fragm; int fragm;
int ninp; int ninp;
int nout; int nout;
int size; int size;
const char *config_file;
}; };


enum { NOERR, ERR_OTHER, ERR_SYNTAX, ERR_PARAM, ERR_ALLOC, ERR_CANTCD, ERR_COMMAND, ERR_NOCONV, ERR_IONUM }; enum { NOERR, ERR_OTHER, ERR_SYNTAX, ERR_PARAM, ERR_ALLOC, ERR_CANTCD, ERR_COMMAND, ERR_NOCONV, ERR_IONUM };
Expand Down

0 comments on commit 013631a

Please sign in to comment.