Skip to content

Commit

Permalink
a bit refinement on error message
Browse files Browse the repository at this point in the history
  • Loading branch information
nu774 committed Jan 19, 2012
1 parent 2aa4ddd commit 5325852
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 42 deletions.
2 changes: 1 addition & 1 deletion CoreAudioHelper.h
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion flacmodule.cpp
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion flacsrc.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion libsndfilesrc.cpp
Expand Up @@ -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)
Expand Down
49 changes: 30 additions & 19 deletions main.cpp
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions soxdsp.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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()");
}
5 changes: 2 additions & 3 deletions taksrc.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions version.cpp
@@ -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
}
4 changes: 2 additions & 2 deletions win32util.cpp
Expand Up @@ -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);
}

Expand Down
11 changes: 5 additions & 6 deletions wvpacksrc.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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>
Expand Down

0 comments on commit 5325852

Please sign in to comment.