Permalink
Browse files

a bit refinement on error message

  • Loading branch information...
1 parent 2aa4ddd commit 53258529017c297898ea0b8b5a55a24934123853 @nu774 committed Jan 17, 2012
Showing with 51 additions and 42 deletions.
  1. +1 −1 CoreAudioHelper.h
  2. +1 −1 flacmodule.cpp
  3. +1 −1 flacsrc.cpp
  4. +1 −1 libsndfilesrc.cpp
  5. +30 −19 main.cpp
  6. +6 −6 soxdsp.cpp
  7. +2 −3 taksrc.cpp
  8. +2 −2 version.cpp
  9. +2 −2 win32util.cpp
  10. +5 −6 wvpacksrc.cpp
View
@@ -15,7 +15,7 @@
long err = expr; \
if (err) { \
std::stringstream ss; \
- ss << "ERROR " << err << ": " << #expr; \
+ ss << err << ": " << #expr; \
throw std::runtime_error(ss.str()); \
} \
} while (0)
View
@@ -1,6 +1,6 @@
#include "flacmodule.h"
-#define CHECK(expr) do { if (!(expr)) throw std::runtime_error("ERROR"); } \
+#define CHECK(expr) do { if (!(expr)) throw std::runtime_error("!!!"); } \
while (0)
FLACModule::FLACModule(const std::wstring &path)
View
@@ -7,7 +7,7 @@
namespace flac {
template <typename T> void try__(T expr, const char *msg)
{
- if (!expr) throw std::runtime_error(format("ERROR: %s", msg));
+ if (!expr) throw std::runtime_error(msg);
}
inline void want(bool expr)
View
@@ -33,7 +33,7 @@ uint32_t convert_chanmap(uint32_t value)
}
}
-#define CHECK(expr) do { if (!(expr)) throw std::runtime_error("ERROR"); } \
+#define CHECK(expr) do { if (!(expr)) throw std::runtime_error("!?"); } \
while (0)
LibSndfileModule::LibSndfileModule(const std::wstring &path)
View
@@ -595,16 +595,21 @@ x::shared_ptr<ISource> mapped_source(const x::shared_ptr<ISource> &src,
channels = srcx->getChannels();
}
// remix
- if ((opts.remix_preset || opts.remix_file) && opts.libsoxrate.loaded()) {
- std::vector<std::vector<complex_t> > matrix;
- matrix_from_preset(opts, &matrix);
- if (opts.verbose > 1 || opts.logfilename) {
- LOG("Matrix mixer: %dch -> %dch\n",
- matrix[0].size(), matrix.size());
+ if (opts.remix_preset || opts.remix_file) {
+ if (!opts.libsoxrate.loaded())
+ LOG("WARNING: mixer requires libsoxrate. Mixing disabled\n");
+ else {
+ std::vector<std::vector<complex_t> > matrix;
+ matrix_from_preset(opts, &matrix);
+ if (opts.verbose > 1 || opts.logfilename) {
+ LOG("Matrix mixer: %dch -> %dch\n",
+ matrix[0].size(), matrix.size());
+ }
+ srcx.reset(new MatrixMixer(srcx, opts.libsoxrate,
+ matrix, threading));
+ channels = 0;
+ nchannels = srcx->getSampleFormat().m_nchannels;
}
- srcx.reset(new MatrixMixer(srcx, opts.libsoxrate, matrix, threading));
- channels = 0;
- nchannels = srcx->getSampleFormat().m_nchannels;
}
// map with --chanmap option
if (opts.chanmap.size()) {
@@ -673,6 +678,8 @@ x::shared_ptr<ISource> delayed_source(const x::shared_ptr<ISource> &src,
IPartialSource *p = dynamic_cast<IPartialSource*>(src.get());
if (p) {
int nsamples = lrint(-0.001 * opts.delay * rate);
+ if (src->length() >= 0 && nsamples > src->length())
+ nsamples = src->length();
p->setRange(nsamples, -1);
if (opts.verbose > 1 || opts.logfilename)
LOG("Delay of %dms: trunc %d samples\n", opts.delay,
@@ -768,15 +775,19 @@ preprocess_input(const x::shared_ptr<ISource> &src,
srcx.reset(new SoxDSPProcessor(engine, srcx));
}
}
- if (opts.lowpass > 0 && opts.libsoxrate.loaded()) {
- if (opts.verbose > 1 || opts.logfilename)
- LOG("Applying LPF: %dHz\n", opts.lowpass);
- x::shared_ptr<ISoxDSPEngine>
- engine(new SoxLowpassFilter(opts.libsoxrate,
- srcx->getSampleFormat(),
- opts.lowpass,
- threading));
- srcx.reset(new SoxDSPProcessor(engine, srcx));
+ if (opts.lowpass > 0) {
+ if (!opts.libsoxrate.loaded())
+ LOG("WARNING: --lowpass requires libsoxrate. LPF disabled\n");
+ else {
+ if (opts.verbose > 1 || opts.logfilename)
+ LOG("Applying LPF: %dHz\n", opts.lowpass);
+ x::shared_ptr<ISoxDSPEngine>
+ engine(new SoxLowpassFilter(opts.libsoxrate,
+ srcx->getSampleFormat(),
+ opts.lowpass,
+ threading));
+ srcx.reset(new SoxDSPProcessor(engine, srcx));
+ }
}
if (opts.normalize)
srcx = do_normalize(srcx, opts);
@@ -1413,7 +1424,7 @@ int wmain1(int argc, wchar_t **argv)
} catch (const std::exception &e) {
if (opts.print_available_formats)
Log::instance()->enable_stderr();
- LOG("%s\n", e.what());
+ LOG("ERROR: %s\n", e.what());
result = 2;
}
delete Log::instance();
View
@@ -3,7 +3,7 @@
#include <vector>
#include "soxdsp.h"
-#define CHECK(expr) do { if (!(expr)) throw std::runtime_error("ERROR"); } \
+#define CHECK(expr) do { if (!(expr)) throw std::runtime_error("!?"); } \
while (0)
SoxModule::SoxModule(const std::wstring &path)
@@ -92,11 +92,11 @@ SoxResampler::SoxResampler(const SoxModule &module, const SampleFormat &format,
lsx_rate_t *converter = m_module.rate_create(
format.m_nchannels, format.m_rate, rate);
if (!converter)
- throw std::runtime_error("ERROR: SoxResampler");
+ throw std::runtime_error("lsx_rate_create()");
m_processor = x::shared_ptr<lsx_rate_t>(converter, m_module.rate_close);
m_module.rate_config(converter, SOX_RATE_USE_THREADS, static_cast<int>(mt));
if (m_module.rate_start(converter) < 0)
- throw std::runtime_error("ERROR: SoxResampler");
+ throw std::runtime_error("lsx_rate_config()");
}
SoxLowpassFilter::SoxLowpassFilter(const SoxModule &module,
@@ -111,14 +111,14 @@ SoxLowpassFilter::SoxLowpassFilter(const SoxModule &module,
int num_taps = 0;
double *coefs = m_module.design_lpf(Fp, Fc, Fn, 0, 120.0, &num_taps, 0);
if (!coefs)
- throw std::runtime_error("SoxLowpassFilter: failed to design lpf");
+ throw std::runtime_error("lsx_design_lpf()");
x::shared_ptr<double> __delete_lator__(coefs, m_module.free);
lsx_fir_t *converter =
m_module.fir_create(format.m_nchannels, coefs, num_taps,
num_taps >> 1, mt);
if (!converter)
- throw std::runtime_error("ERROR: SoxLowpassFilter");
+ throw std::runtime_error("lsx_fir_create()");
m_processor = x::shared_ptr<lsx_fir_t>(converter, m_module.fir_close);
if (m_module.fir_start(converter) < 0)
- throw std::runtime_error("ERROR: SoxLowpassFilter");
+ throw std::runtime_error("lsx_fir_start()");
}
View
@@ -5,7 +5,7 @@
#include "itunetags.h"
#include "cuesheet.h"
-#define CHECK(expr) do { if (!(expr)) throw std::runtime_error("ERROR"); } \
+#define CHECK(expr) do { if (!(expr)) throw std::runtime_error("!?"); } \
while (0)
TakModule::TakModule(const std::wstring &path)
@@ -36,8 +36,7 @@ TakModule::TakModule(const std::wstring &path)
namespace tak {
template <typename T> void try__(T expr, const char *s)
{
- if (expr != tak_res_Ok)
- throw std::runtime_error(format("ERROR: %s", s));
+ if (expr != tak_res_Ok) throw std::runtime_error(s);
}
}
View
@@ -1,8 +1,8 @@
const char *get_qaac_version()
{
#ifdef REFALAC
- return "0.33";
+ return "0.34";
#else
- return "1.22";
+ return "1.23";
#endif
}
View
@@ -21,9 +21,9 @@ void throw_win32_error(const std::string &msg, DWORD code)
LocalFree(pszMsg);
}
else if (code < 0xfe00)
- ss = format("ERROR %d: %s", code, msg.c_str());
+ ss = format("%d: %s", code, msg.c_str());
else
- ss = format("ERROR %08x: %s", code, msg.c_str());
+ ss = format("%08x: %s", code, msg.c_str());
throw std::runtime_error(ss);
}
View
@@ -6,7 +6,7 @@
#include "cuesheet.h"
#include "chanmap.h"
-#define CHECK(expr) do { if (!(expr)) throw std::runtime_error("ERROR"); } \
+#define CHECK(expr) do { if (!(expr)) throw std::runtime_error("!?"); } \
while (0)
WavpackModule::WavpackModule(const std::wstring &path)
@@ -101,7 +101,7 @@ WavpackSource::WavpackSource(const WavpackModule &module, InputStream &stream,
m_module.OpenFileInputEx(&reader, &m_stream, m_cstream.get(),
error, flags, 0);
if (!wpc)
- throw std::runtime_error(format("WavpackOpenFileInputEx: %s", error));
+ throw std::runtime_error(format("WavpackOpenFileInputEx(): %s", error));
m_wpc = x::shared_ptr<WavpackContext>(wpc, m_module.CloseFile);
int mode = m_module.GetMode(wpc);
@@ -126,10 +126,9 @@ WavpackSource::WavpackSource(const WavpackModule &module, InputStream &stream,
void WavpackSource::skipSamples(int64_t count)
{
- if (!m_module.SeekSample(m_wpc.get(),
- static_cast<int32_t>(PartialSource::getSamplesRead() + count)))
- throw std::runtime_error("WavpackSeekSample");
-
+ uint64_t cur = PartialSource::getSamplesRead();
+ if (!m_module.SeekSample(m_wpc.get(), static_cast<int32_t>(cur + count)))
+ throw std::runtime_error("WavpackSeekSample()");
}
template <class MemorySink>

0 comments on commit 5325852

Please sign in to comment.