Skip to content

Commit

Permalink
o Remove TODO: pass out detailed error msg when failing to
Browse files Browse the repository at this point in the history
  create filter.
  • Loading branch information
hzeller committed Oct 6, 2012
1 parent 950f192 commit cf8ddb8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
9 changes: 2 additions & 7 deletions folve-filesystem.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -120,14 +120,9 @@ class SndFileHandler :
partial_file_info->duration_seconds = in_info.frames / in_info.samplerate; partial_file_info->duration_seconds = in_info.frames / in_info.samplerate;


SoundProcessor *processor = fs->processor_pool() 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) { 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); sf_close(snd);
return NULL; return NULL;
} }
Expand Down
10 changes: 8 additions & 2 deletions processor-pool.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ for (size_t i = 0; i < path.size(); ++i) {


SoundProcessor *ProcessorPool::GetOrCreate(const std::string &base_dir, SoundProcessor *ProcessorPool::GetOrCreate(const std::string &base_dir,
int sampling_rate, int channels, int sampling_rate, int channels,
int bits) { int bits, std::string *errmsg) {
std::vector<std::string> path_choices; std::vector<std::string> path_choices;
// From specific to non-specific. // From specific to non-specific.
path_choices.push_back(StringPrintf("%s/filter-%d-%d-%d.conf", path_choices.push_back(StringPrintf("%s/filter-%d-%d-%d.conf",
Expand All @@ -58,9 +58,14 @@ SoundProcessor *ProcessorPool::GetOrCreate(const std::string &base_dir,
path_choices.push_back(StringPrintf("%s/filter-%d.conf", path_choices.push_back(StringPrintf("%s/filter-%d.conf",
base_dir.c_str(), base_dir.c_str(),
sampling_rate)); sampling_rate));

std::string config_path; 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; return NULL;
}
SoundProcessor *result; SoundProcessor *result;
while ((result = CheckOutOfPool(config_path)) != NULL) { while ((result = CheckOutOfPool(config_path)) != NULL) {
if (result->ConfigStillUpToDate()) if (result->ConfigStillUpToDate())
Expand All @@ -76,6 +81,7 @@ SoundProcessor *ProcessorPool::GetOrCreate(const std::string &base_dir,


result = SoundProcessor::Create(config_path, sampling_rate, channels); result = SoundProcessor::Create(config_path, sampling_rate, channels);
if (result == NULL) { if (result == NULL) {
*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());
} }
DLogf("Processor %p: Newly created [%s]", result, config_path.c_str()); DLogf("Processor %p: Newly created [%s]", result, config_path.c_str());
Expand Down
5 changes: 4 additions & 1 deletion processor-pool.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ class ProcessorPool {
ProcessorPool(int max_per_config); ProcessorPool(int max_per_config);


// Get a new SoundProcesor from this pool with the given configuration. // 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, 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. // Return a processor pack to the pool.
void Return(SoundProcessor *processor); void Return(SoundProcessor *processor);
Expand Down

0 comments on commit cf8ddb8

Please sign in to comment.