Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

o Write zita config problems to syslog.

o allow relative filenames in zita config.
o Additional check if input/output buffers exist.
  • Loading branch information...
commit 23b24f0b72bbb6768b3bf1e6f1ae825cbc76f311 1 parent 249865a
@hzeller authored
Showing with 48 additions and 35 deletions.
  1. +6 −3 folve-filesystem.cc
  2. +35 −27 zita-config.cc
  3. +7 −5 zita-fconfig.cc
View
9 folve-filesystem.cc
@@ -308,9 +308,12 @@ class SndFileHandler :
if (!zita_.convproc) {
// First time we're called.
zita_.convproc = new Convproc();
- if (config(&zita_, config_path_.c_str()) != 0) {
- syslog(LOG_ERR, "filter-config %s is broken. Please fix."
- "Won't play this stream **\n", config_path_.c_str());
+ if ((config(&zita_, config_path_.c_str()) != 0)
+ || zita_.convproc->inpdata(channels_ - 1) == NULL
+ || zita_.convproc->outdata(channels_ - 1) == NULL) {
+ syslog(LOG_ERR, "filter-config %s is broken. Please fix. "
+ "Won't play this stream %s (simulating empty file)",
+ config_path_.c_str(), base_stats_.filename.c_str());
base_stats_.message = "Problem parsing " + config_path_;
input_frames_left_ = 0;
Close();
View
62 zita-config.cc
@@ -26,10 +26,11 @@
#include <ctype.h>
#include <math.h>
#include <libgen.h>
+#include <syslog.h>
+
#include "zita-audiofile.h"
#include "zita-config.h"
-
// zita-config
#define BSIZE 0x4000
@@ -75,7 +76,7 @@ static int readfile (ZitaConfig *cfg,
k -= delay;
delay = 0;
offset += k;
- fprintf (stderr, "%s:%d: First %d frames removed by latency compensation.\n", cfg->config_file, lnum, k);
+ syslog(LOG_ERR, "%s:%d: First %d frames removed by latency compensation.\n", cfg->config_file, lnum, k);
}
}
err = check_inout (cfg, ip1, op1);
@@ -91,30 +92,30 @@ static int readfile (ZitaConfig *cfg,
if (audio.open_read (path))
{
- fprintf (stderr, "%s:%d: Unable to open '%s'.\n", cfg->config_file,
- lnum, path);
+ syslog(LOG_ERR, "%s:%d: Unable to open '%s' >%s<.\n", cfg->config_file,
+ lnum, path, cdir);
return ERR_OTHER;
}
if (audio.rate () != (int) cfg->fsamp)
{
- fprintf (stderr, "%s:%d: Sample rate (%d) of '%s' does not match.\n",
- cfg->config_file, lnum, audio.rate (), path);
+ syslog(LOG_ERR, "%s:%d: Sample rate (%d) of '%s' does not match.\n",
+ cfg->config_file, lnum, audio.rate (), path);
}
nchan = audio.chan ();
nfram = audio.size ();
if ((ichan < 1) || (ichan > nchan))
{
- fprintf (stderr, "%s:%d: Channel not available.\n",
- cfg->config_file, lnum);
+ syslog(LOG_ERR, "%s:%d: Channel not available.\n",
+ cfg->config_file, lnum);
audio.close ();
return ERR_OTHER;
}
if (offset && audio.seek (offset))
{
- fprintf (stderr, "%s:%d: Can't seek to offset.\n",
- cfg->config_file, lnum);
+ syslog(LOG_ERR, "%s:%d: Can't seek to offset.\n",
+ cfg->config_file, lnum);
audio.close ();
return ERR_OTHER;
}
@@ -122,7 +123,7 @@ static int readfile (ZitaConfig *cfg,
if (length > cfg->size - delay)
{
length = cfg->size - delay;
- fprintf (stderr, "%s:%d: Data truncated.\n", cfg->config_file, lnum);
+ syslog(LOG_ERR, "%s:%d: Data truncated.\n", cfg->config_file, lnum);
}
try
@@ -141,8 +142,8 @@ static int readfile (ZitaConfig *cfg,
nfram = audio.read (buff, nfram);
if (nfram < 0)
{
- fprintf (stderr, "%s:%d: Error reading file.\n",
- cfg->config_file, lnum);
+ syslog(LOG_ERR, "%s:%d: Error reading file.\n",
+ cfg->config_file, lnum);
audio.close ();
delete[] buff;
return ERR_OTHER;
@@ -183,8 +184,8 @@ static int impdirac (ZitaConfig *cfg, const char *line, int lnum)
k = cfg->latency;
if (delay < k)
{
- fprintf (stderr, "%s:%d: Dirac pulse removed: delay < latency.\n",
- cfg->config_file, lnum);
+ syslog(LOG_ERR, "%s:%d: Dirac pulse removed: delay < latency.\n",
+ cfg->config_file, lnum);
return 0;
}
delay -= k;
@@ -222,7 +223,7 @@ static int imphilbert (ZitaConfig *cfg, const char *line, int lnum)
k = cfg->latency;
if (delay < k + length / 2)
{
- fprintf (stderr, "%s:%d: Hilbert impulse removed: delay < latency + lenght / 2.\n", cfg->config_file, lnum);
+ syslog(LOG_ERR, "%s:%d: Hilbert impulse removed: delay < latency + lenght / 2.\n", cfg->config_file, lnum);
return 0;
}
delay -= k + length / 2;
@@ -280,7 +281,7 @@ int config (ZitaConfig *cfg, const char *config_file)
if (! (F = fopen (config_file, "r")))
{
- fprintf (stderr, "Can't open '%s' for reading\n", config_file);
+ syslog(LOG_ERR, "Can't open '%s' for reading\n", config_file);
return -1;
}
@@ -313,7 +314,14 @@ int config (ZitaConfig *cfg, const char *config_file)
if (! strcmp (p, "/cd"))
{
- if (sstring (q, cdir, 1024) == 0) stat = ERR_PARAM;
+ char tmp[1024];
+ if (sstring (q, tmp, 1024) == 0) stat = ERR_PARAM;
+ if (tmp[0] == '/') {
+ strcpy(cdir, tmp);
+ } else {
+ strcat(cdir, "/");
+ strcat(cdir, tmp);
+ }
}
else if (! strcmp (p, "/convolver/new")) stat = convnew (cfg, q, lnum);
else if (! strcmp (p, "/impulse/read")) stat = readfile (cfg, q, lnum, cdir);
@@ -329,32 +337,32 @@ int config (ZitaConfig *cfg, const char *config_file)
if (stat == ERR_OTHER) stat = 0;
if (stat)
{
- fprintf (stderr, "%s:%d: ", config_file, lnum);
+ syslog(LOG_ERR, "%s:%d: ", config_file, lnum);
switch (stat)
{
case ERR_SYNTAX:
- fprintf (stderr, "Syntax error.\n");
+ syslog(LOG_ERR, "Syntax error.\n");
break;
case ERR_PARAM:
- fprintf (stderr, "Bad or missing parameters.\n");
+ syslog(LOG_ERR, "Bad or missing parameters.\n");
break;
case ERR_ALLOC:
- fprintf (stderr, "Out of memory.\n");
+ syslog(LOG_ERR, "Out of memory.\n");
break;
case ERR_CANTCD:
- fprintf (stderr, "Can't change directory to '%s'.\n", cdir);
+ syslog(LOG_ERR, "Can't change directory to '%s'.\n", cdir);
break;
case ERR_COMMAND:
- fprintf (stderr, "Unknown command.\n");
+ syslog(LOG_ERR, "Unknown command.\n");
break;
case ERR_NOCONV:
- fprintf (stderr, "No convolver yet defined.\n");
+ syslog(LOG_ERR, "No convolver yet defined.\n");
break;
case ERR_IONUM:
- fprintf (stderr, "Bad input or output number.\n");
+ syslog(LOG_ERR, "Bad input or output number.\n");
break;
default:
- fprintf (stderr, "Unknown error.\n");
+ syslog(LOG_ERR, "Unknown error.\n");
}
}
View
12 zita-fconfig.cc
@@ -22,6 +22,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <syslog.h>
+
#include "zita-config.h"
@@ -38,25 +40,25 @@ int convnew (ZitaConfig *cfg, const char *line, int lnum)
if ((cfg->ninp == 0) || (cfg->ninp > Convproc::MAXINP))
{
- fprintf (stderr, "%s:%d: Number of inputs (%d) is out of range.\n",
+ syslog(LOG_ERR, "%s:%d: Number of inputs (%d) is out of range.\n",
cfg->config_file, lnum, cfg->ninp);
return ERR_OTHER;
}
if ((cfg->nout == 0) || (cfg->nout > Convproc::MAXOUT))
{
- fprintf (stderr, "%s:%d: Number of outputs (%d) is out of range.\n",
+ syslog(LOG_ERR, "%s:%d: Number of outputs (%d) is out of range.\n",
cfg->config_file, lnum, cfg->nout);
return ERR_OTHER;
}
if (cfg->size > MAXSIZE)
{
- fprintf (stderr, "%s:%d: Convolver size (%d) is out of range.\n",
+ syslog(LOG_ERR, "%s:%d: Convolver size (%d) is out of range.\n",
cfg->config_file, lnum, cfg->size);
return ERR_OTHER;
}
if ((dens < 0.0f) || (dens > 1.0f))
{
- fprintf (stderr, "%s:%d: Density parameter is out of range.\n",
+ syslog(LOG_ERR, "%s:%d: Density parameter is out of range.\n",
cfg->config_file, lnum);
return ERR_OTHER;
}
@@ -70,7 +72,7 @@ int convnew (ZitaConfig *cfg, const char *line, int lnum)
if (cfg->convproc->configure (cfg->ninp, cfg->nout, cfg->size,
cfg->fragm, cfg->fragm, cfg->fragm))
{
- fprintf (stderr, "Can't initialise convolution engine\n");
+ syslog(LOG_ERR, "Can't initialise convolution engine\n");
return ERR_OTHER;
}
Please sign in to comment.
Something went wrong with that request. Please try again.