summaryrefslogtreecommitdiff
path: root/src/audiofile.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2019-07-25 17:49:16 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2019-09-28 20:37:47 +0200
commit9d1ea1e7cfa256c7f5cac027382d92f658734ccb (patch)
tree39ec7cdaa8ed571137430ccbbc0a391bb27427a3 /src/audiofile.cc
parentcd9af98abdce1fe3759e786d6b010a7fe3395e2c (diff)
Add generic logger interface for propagating messages while loading drumkits to the commandline
and/or plugin UI.
Diffstat (limited to 'src/audiofile.cc')
-rw-r--r--src/audiofile.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/audiofile.cc b/src/audiofile.cc
index c2c5cf9..2d61eb5 100644
--- a/src/audiofile.cc
+++ b/src/audiofile.cc
@@ -73,7 +73,7 @@ void AudioFile::unload()
#define BUFFER_SIZE 4096
-void AudioFile::load(std::size_t sample_limit)
+void AudioFile::load(LogFunction logger, std::size_t sample_limit)
{
// Make sure we don't unload the object while loading it...
std::lock_guard<std::mutex> guard(mutex);
@@ -89,12 +89,22 @@ void AudioFile::load(std::size_t sample_limit)
{
ERR(audiofile,"SNDFILE Error (%s): %s\n",
filename.c_str(), sf_strerror(fh));
+ if(logger)
+ {
+ logger(LogLevel::Warning, "Could not load '" + filename +
+ "': " + sf_strerror(fh));
+ }
return;
}
if(sf_info.channels < 1)
{
// This should never happen but lets check just in case.
+ if(logger)
+ {
+ logger(LogLevel::Warning, "Could not load '" + filename +
+ "': no audio channels available.");
+ }
return;
}
@@ -116,6 +126,11 @@ void AudioFile::load(std::size_t sample_limit)
// check filechannel exists
if(filechannel >= (std::size_t)sf_info.channels)
{
+ if(logger)
+ {
+ logger(LogLevel::Warning, "Audio file '" + filename +
+ "' does no have " + std::to_string(filechannel + 1) + " channels.");
+ }
filechannel = sf_info.channels - 1;
}