Permalink
Browse files

o Remove TODO: pass out detailed error msg when failing to

  create filter.
  • Loading branch information...
1 parent 950f192 commit cf8ddb8da3faf2c604c16fa9ff1f4a07b3c4e39f @hzeller committed Oct 6, 2012
Showing with 14 additions and 10 deletions.
  1. +2 −7 folve-filesystem.cc
  2. +8 −2 processor-pool.cc
  3. +4 −1 processor-pool.h
View
9 folve-filesystem.cc
@@ -120,14 +120,9 @@ class SndFileHandler :
partial_file_info->duration_seconds = in_info.frames / in_info.samplerate;
SoundProcessor *processor = fs->processor_pool()
- ->GetOrCreate(zita_config_dir, in_info.samplerate, in_info.channels, bits);
+ ->GetOrCreate(zita_config_dir, in_info.samplerate, in_info.channels, bits,
+ &partial_file_info->message);
if (processor == NULL) {
- // TODO: depending on why this happened, provide one of these messages.
- /*
- partial_file_info_.message = "Problem parsing " + config_path_;
- partial_file_info->message = "Missing ( " + path_choices[0]
- + "<br/> ... " + path_choices[max_choice] + " )";
- */
sf_close(snd);
return NULL;
}
View
10 processor-pool.cc
@@ -46,7 +46,7 @@ for (size_t i = 0; i < path.size(); ++i) {
SoundProcessor *ProcessorPool::GetOrCreate(const std::string &base_dir,
int sampling_rate, int channels,
- int bits) {
+ int bits, std::string *errmsg) {
std::vector<std::string> path_choices;
// From specific to non-specific.
path_choices.push_back(StringPrintf("%s/filter-%d-%d-%d.conf",
@@ -58,9 +58,14 @@ SoundProcessor *ProcessorPool::GetOrCreate(const std::string &base_dir,
path_choices.push_back(StringPrintf("%s/filter-%d.conf",
base_dir.c_str(),
sampling_rate));
+
std::string config_path;
- if (!FindFirstAccessiblePath(path_choices, &config_path))
+ if (!FindFirstAccessiblePath(path_choices, &config_path)) {
+ *errmsg = StringPrintf("No filter in %s for %.1fkHz/%d ch/%d bits",
+ base_dir.c_str(), sampling_rate / 1000.0,
+ channels, bits);
return NULL;
+ }
SoundProcessor *result;
while ((result = CheckOutOfPool(config_path)) != NULL) {
if (result->ConfigStillUpToDate())
@@ -76,6 +81,7 @@ SoundProcessor *ProcessorPool::GetOrCreate(const std::string &base_dir,
result = SoundProcessor::Create(config_path, sampling_rate, channels);
if (result == NULL) {
+ *errmsg = "Problem parsing " + config_path;
syslog(LOG_ERR, "filter-config %s is broken.", config_path.c_str());
}
DLogf("Processor %p: Newly created [%s]", result, config_path.c_str());
View
5 processor-pool.h
@@ -34,8 +34,11 @@ class ProcessorPool {
ProcessorPool(int max_per_config);
// Get a new SoundProcesor from this pool with the given configuration.
+ // If this isn't possible, NULL is returned an an error message stored in
+ // "errmsg".
SoundProcessor *GetOrCreate(const std::string &base_dir,
- int sampling_rate, int channels, int bits);
+ int sampling_rate, int channels, int bits,
+ std::string *errmsg);
// Return a processor pack to the pool.
void Return(SoundProcessor *processor);

0 comments on commit cf8ddb8

Please sign in to comment.