[beast: 7/43] BSE: only use Bse::assert_return{_unreached} and Bse::warning everywhere
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 7/43] BSE: only use Bse::assert_return{_unreached} and Bse::warning everywhere
- Date: Mon, 26 Jun 2017 23:27:53 +0000 (UTC)
commit 581400b31673e593c6a46e1a8c632cc22119e52c
Author: Tim Janik <timj gnu org>
Date: Sun Jun 25 02:49:51 2017 +0200
BSE: only use Bse::assert_return{_unreached} and Bse::warning everywhere
Signed-off-by: Tim Janik <timj gnu org>
bse/bsebiquadfilter.cc | 10 +++++-----
bse/bsebus.cc | 18 +++++++++---------
bse/bsecategories.cc | 4 ++--
bse/bseconstant.cc | 2 +-
bse/bsecontainer.cc | 2 +-
bse/bsecontextmerger.cc | 4 ++--
bse/bsecxxbase.cc | 6 +++---
bse/bsedatahandle-fir.cc | 2 +-
bse/bsedatahandle-resample.cc | 10 +++++-----
bse/bsedevice.cc | 2 +-
bse/bseeditablesample.cc | 2 +-
bse/bseengine.cc | 8 ++++----
bse/bseenginemaster.cc | 38 +++++++++++++++++++-------------------
bse/bseengineschedule.cc | 31 ++++++++++++++++---------------
bse/bseengineutils.cc | 8 ++++----
bse/bseenums.cc | 2 +-
bse/bsegconfig.cc | 2 +-
bse/bseinstrumentinput.cc | 10 +++++-----
bse/bseinstrumentoutput.cc | 10 +++++-----
bse/bseitem.cc | 6 +++---
bse/bseladspamodule.cc | 18 ++++++++++--------
bse/bseloader-aiff.cc | 2 +-
bse/bseloader-bsewave.cc | 4 ++--
bse/bseloader-flac.cc | 2 +-
bse/bseloader-guspatch.cc | 2 +-
bse/bseloader-mad.cc | 2 +-
bse/bseloader-oggvorbis.cc | 2 +-
bse/bseloader-wav.cc | 8 ++++----
bse/bsemain.cc | 10 +++++-----
bse/bsemidicontroller.cc | 8 ++++----
bse/bsemididecoder.cc | 2 +-
bse/bsemididevice-null.cc | 2 +-
bse/bsemidiinput.cc | 8 ++++----
bse/bsemidireceiver.cc | 8 ++++----
bse/bsemidivoice.cc | 20 ++++++++++----------
bse/bseobject.cc | 24 ++++++++++++------------
bse/bsepart.cc | 18 +++++++++---------
bse/bsepcminput.cc | 4 ++--
bse/bsepcmoutput.cc | 4 ++--
bse/bseplugin.cc | 2 +-
bse/bseprobe.cc | 30 +++++++++++++++---------------
bse/bseprocedure.cc | 2 +-
bse/bsesequencer.cc | 28 ++++++++++++++--------------
bse/bseserver.cc | 23 +++++++++++++----------
bse/bsesnet.cc | 8 ++++----
bse/bsesnooper.cc | 2 +-
bse/bsesong.cc | 4 ++--
bse/bsesource.cc | 12 ++++++------
bse/bsestandardosc.cc | 12 ++++++------
bse/bsestartup.cc | 8 ++++----
bse/bsestorage.cc | 6 +++---
bse/bsesubiport.cc | 2 +-
bse/bsesuboport.cc | 2 +-
bse/bsesubsynth.cc | 6 +++---
bse/bsetrack.cc | 14 +++++++-------
bse/bsetype.cc | 6 +++---
bse/bseutils.cc | 32 ++++++++++----------------------
bse/bsewaveosc.cc | 12 ++++++------
bse/gsldatacache.cc | 6 +++---
bse/gsldatahandle-mad.cc | 2 +-
bse/gsldatahandle-vorbis.cc | 2 +-
bse/gsldatahandle.cc | 4 ++--
bse/gsldatautils.cc | 6 +++---
bse/gslfilehash.cc | 2 +-
bse/gslfilter.cc | 10 +++-------
bse/gslmagic.cc | 2 +-
bse/gslvorbis-enc.cc | 2 +-
bse/gslwavechunk.cc | 4 ++--
bse/gslwaveosc.cc | 8 ++++----
bse/tests/blocktests.cc | 11 ++++++-----
bse/tests/filtertest.cc | 13 +++++++------
bse/tests/firhandle.cc | 18 +++++++++---------
bse/tests/resamplehandle.cc | 7 ++++---
bse/tests/subnormals.cc | 12 ++++++------
74 files changed, 319 insertions(+), 326 deletions(-)
---
diff --git a/bse/bsebiquadfilter.cc b/bse/bsebiquadfilter.cc
index 6e4744e..28725ca 100644
--- a/bse/bsebiquadfilter.cc
+++ b/bse/bsebiquadfilter.cc
@@ -169,15 +169,15 @@ bse_biquad_filter_class_init (BseBiquadFilterClass *klass)
SFI_PARAM_STANDARD ":scale"));
channel_id = bse_source_class_add_ichannel (source_class, "audio-in", _("Audio In"), _("Unfiltered Audio
Signal"));
- assert (channel_id == BSE_BIQUAD_FILTER_ICHANNEL_AUDIO);
+ assert_return (channel_id == BSE_BIQUAD_FILTER_ICHANNEL_AUDIO);
channel_id = bse_source_class_add_ichannel (source_class, "freq-in", _("Freq In"), _("Center Frequency
Input"));
- assert (channel_id == BSE_BIQUAD_FILTER_ICHANNEL_FREQ);
+ assert_return (channel_id == BSE_BIQUAD_FILTER_ICHANNEL_FREQ);
channel_id = bse_source_class_add_ichannel (source_class, "freq-mod-in", _("Freq Mod In"), _("Frequency
Modulation Input"));
- assert (channel_id == BSE_BIQUAD_FILTER_ICHANNEL_FREQ_MOD);
+ assert_return (channel_id == BSE_BIQUAD_FILTER_ICHANNEL_FREQ_MOD);
channel_id = bse_source_class_add_ichannel (source_class, "gain-mod-in", _("Gain Mod In"), _("Gain
Modulation Input"));
- assert (channel_id == BSE_BIQUAD_FILTER_ICHANNEL_GAIN_MOD);
+ assert_return (channel_id == BSE_BIQUAD_FILTER_ICHANNEL_GAIN_MOD);
channel_id = bse_source_class_add_ochannel (source_class, "audio-out", _("Audio Out"), _("Filtered Audio
Signal"));
- assert (channel_id == BSE_BIQUAD_FILTER_OCHANNEL_AUDIO);
+ assert_return (channel_id == BSE_BIQUAD_FILTER_OCHANNEL_AUDIO);
}
static void
diff --git a/bse/bsebus.cc b/bse/bsebus.cc
index 4a2ec3a..557531d 100644
--- a/bse/bsebus.cc
+++ b/bse/bsebus.cc
@@ -60,16 +60,16 @@ bse_bus_dispose (GObject *object)
/* chain parent class' handler */
G_OBJECT_CLASS (bus_parent_class)->dispose (object);
- assert (self->bus_outputs == NULL);
+ assert_return (self->bus_outputs == NULL);
}
static void
bse_bus_finalize (GObject *object)
{
BseBus *self = BSE_BUS (object);
- assert (self->inputs == NULL);
- assert (self->bus_outputs == NULL);
- assert (self->summation == NULL);
+ assert_return (self->inputs == NULL);
+ assert_return (self->bus_outputs == NULL);
+ assert_return (self->summation == NULL);
/* chain parent class' handler */
G_OBJECT_CLASS (bus_parent_class)->finalize (object);
}
@@ -561,7 +561,7 @@ bse_bus_get_stack (BseBus *self,
BseProject *project = bse_item_get_project (item);
if (!BSE_SUB_SYNTH (self)->snet && project && BSE_IS_SONG (item->parent))
{
- assert (self->n_effects == 0);
+ assert_return (self->n_effects == 0, FALSE);
bse_bus_ensure_summation (self);
BseSNet *snet = (BseSNet*) bse_project_create_intern_csynth (project, "%BusEffectStack");
self->vin = (BseSource*) bse_container_new_child_bname (BSE_CONTAINER (snet), BSE_TYPE_SUB_IPORT,
"%VInput", NULL);
@@ -899,13 +899,13 @@ bse_bus_class_init (BseBusClass *klass)
FALSE, SFI_PARAM_STORAGE ":skip-default"));
channel_id = bse_source_class_add_ichannel (source_class, "left-audio-in", _("Left Audio In"), _("Left
channel input"));
- assert (channel_id == BSE_BUS_ICHANNEL_LEFT);
+ assert_return (channel_id == BSE_BUS_ICHANNEL_LEFT);
channel_id = bse_source_class_add_ichannel (source_class, "right-audio-in", _("Right Audio In"), _("Right
channel input"));
- assert (channel_id == BSE_BUS_ICHANNEL_RIGHT);
+ assert_return (channel_id == BSE_BUS_ICHANNEL_RIGHT);
channel_id = bse_source_class_add_ochannel (source_class, "left-audio-out", _("Left Audio Out"), _("Left
channel output"));
- assert (channel_id == BSE_BUS_OCHANNEL_LEFT);
+ assert_return (channel_id == BSE_BUS_OCHANNEL_LEFT);
channel_id = bse_source_class_add_ochannel (source_class, "right-audio-out", _("Right Audio Out"),
_("Right channel output"));
- assert (channel_id == BSE_BUS_OCHANNEL_RIGHT);
+ assert_return (channel_id == BSE_BUS_OCHANNEL_RIGHT);
}
BSE_BUILTIN_TYPE (BseBus)
diff --git a/bse/bsecategories.cc b/bse/bsecategories.cc
index c901c9b..668139a 100644
--- a/bse/bsecategories.cc
+++ b/bse/bsecategories.cc
@@ -96,12 +96,12 @@ centry_new (const char *caller, const std::string &category, GType type)
const uint mindex = category_strip_toplevels (category, type);
if (!mindex)
{
- critical ("%s: refusing to add non-conforming category '%s'", caller, category);
+ Bse::warning ("%s: refusing to add non-conforming category '%s'", caller, category);
return NULL;
}
if (centry_find (category))
{
- critical ("%s: unable to add category duplicate '%s'", caller, category);
+ Bse::warning ("%s: unable to add category duplicate '%s'", caller, category);
return NULL;
}
diff --git a/bse/bseconstant.cc b/bse/bseconstant.cc
index e4f19c2..cbd209a 100644
--- a/bse/bseconstant.cc
+++ b/bse/bseconstant.cc
@@ -120,7 +120,7 @@ bse_constant_class_init (BseConstantClass *klass)
label = g_strdup_format (_("Const Out%u"), i);
blurb = g_strdup_format (_("Constant Output %u"), i);
ochannel = bse_source_class_add_ochannel (source_class, ident, label, blurb);
- assert (ochannel == i - 1);
+ assert_return (ochannel == i - 1);
g_free (ident);
g_free (label);
g_free (blurb);
diff --git a/bse/bsecontainer.cc b/bse/bsecontainer.cc
index e263697..b669ac9 100644
--- a/bse/bsecontainer.cc
+++ b/bse/bsecontainer.cc
@@ -725,7 +725,7 @@ uncross_link_R (BseContainerCrossLinks *clinks,
unode.next = uncross_stack;
uncross_stack = &unode;
unode.uncross (unode.owner, unode.link); /* may recurse */
- assert (uncross_stack == &unode); /* paranoid */
+ assert_return (uncross_stack == &unode); /* paranoid */
uncross_stack = unode.next;
}
}
diff --git a/bse/bsecontextmerger.cc b/bse/bsecontextmerger.cc
index f394c2c..6c367d2 100644
--- a/bse/bsecontextmerger.cc
+++ b/bse/bsecontextmerger.cc
@@ -62,12 +62,12 @@ bse_context_merger_class_init (BseContextMergerClass *klass)
ident = g_strdup_format ("input-%u", i + 1);
channel_id = bse_source_class_add_jchannel (source_class, ident, NULL, NULL);
- assert (channel_id == i);
+ assert_return (channel_id == i);
g_free (ident);
ident = g_strdup_format ("output-%u", i + 1);
channel_id = bse_source_class_add_ochannel (source_class, ident, NULL, NULL);
- assert (channel_id == i);
+ assert_return (channel_id == i);
g_free (ident);
}
}
diff --git a/bse/bsecxxbase.cc b/bse/bsecxxbase.cc
index dbe46b6..e305d44 100644
--- a/bse/bsecxxbase.cc
+++ b/bse/bsecxxbase.cc
@@ -307,7 +307,7 @@ CxxBaseClass::add_ochannel (const char *ident,
{
int channel_id = bse_source_class_add_ochannel ((BseSourceClass*) this, ident, label, blurb);
if (assert_id >= 0)
- assert (assert_id == channel_id);
+ assert_return (assert_id == channel_id);
}
void
@@ -318,7 +318,7 @@ CxxBaseClass::add_ichannel (const char *ident,
{
int channel_id = bse_source_class_add_ichannel ((BseSourceClass*) this, ident, label, blurb);
if (assert_id >= 0)
- assert (assert_id == channel_id);
+ assert_return (assert_id == channel_id);
}
void
@@ -329,7 +329,7 @@ CxxBaseClass::add_jchannel (const char *ident,
{
int channel_id = bse_source_class_add_jchannel ((BseSourceClass*) this, ident, label, blurb);
if (assert_id >= 0)
- assert (assert_id == channel_id);
+ assert_return (assert_id == channel_id);
}
} // Bse
diff --git a/bse/bsedatahandle-fir.cc b/bse/bsedatahandle-fir.cc
index 3c8dbf7..005d340 100644
--- a/bse/bsedatahandle-fir.cc
+++ b/bse/bsedatahandle-fir.cc
@@ -174,7 +174,7 @@ public:
return l;
}
- assert (ivoffset == m_input_voffset);
+ assert_return (ivoffset == m_input_voffset, 0);
voffset -= ivoffset;
n_values = min (n_values, m_block_size - voffset);
diff --git a/bse/bsedatahandle-resample.cc b/bse/bsedatahandle-resample.cc
index 7993568..8603ed4 100644
--- a/bse/bsedatahandle-resample.cc
+++ b/bse/bsedatahandle-resample.cc
@@ -142,7 +142,7 @@ public:
case BSE_RESAMPLER2_MODE_DOWNSAMPLE: setup->mix_freq /= 2.0;
setup->n_values = (setup->n_values + 1) / 2;
break;
- default: assert_unreached();
+ default: assert_return_unreached (Bse::Error::INTERNAL);
}
m_frame_size = 1024 * setup->n_channels;
@@ -153,11 +153,11 @@ public:
for (guint i = 0; i < setup->n_channels; i++)
{
Resampler2 *resampler = Resampler2::create (mode(), precision);
- assert (resampler);
+ assert_return (resampler, Bse::Error::INTERNAL);
m_resamplers.push_back (resampler);
}
- assert (!m_resamplers.empty()); /* n_channels is always > 0 */
+ assert_return (!m_resamplers.empty(), Bse::Error::INTERNAL); /* n_channels is always > 0 */
m_filter_order = m_resamplers[0]->order();
/* Resampler2::delay() is defined in output samples, but we need to
@@ -209,10 +209,10 @@ public:
if (l < 0)
return l;
}
- assert (m_pcm_frame == frame);
+ assert_return (m_pcm_frame == frame, 0);
voffset -= m_pcm_frame * m_frame_size;
- assert (voffset >= 0);
+ assert_return (voffset >= 0, 0);
n_values = std::min (n_values, m_frame_size - voffset);
for (int64 i = 0; i < n_values; i++)
diff --git a/bse/bsedevice.cc b/bse/bsedevice.cc
index 6398b05..67e3b86 100644
--- a/bse/bsedevice.cc
+++ b/bse/bsedevice.cc
@@ -492,7 +492,7 @@ BSE_BUILTIN_TYPE (BseDevice)
(GInstanceInitFunc) bse_device_init,
};
- assert (BSE_DEVICE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
+ assert_return (BSE_DEVICE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT, 0);
return bse_type_register_abstract (BSE_TYPE_OBJECT,
"BseDevice",
diff --git a/bse/bseeditablesample.cc b/bse/bseeditablesample.cc
index a1ff88e..6d9ebca 100644
--- a/bse/bseeditablesample.cc
+++ b/bse/bseeditablesample.cc
@@ -45,7 +45,7 @@ BSE_BUILTIN_TYPE (BseEditableSample)
(GInstanceInitFunc) bse_editable_sample_init,
};
- assert (BSE_EDITABLE_SAMPLE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
+ assert_return (BSE_EDITABLE_SAMPLE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT, 0);
return bse_type_register_static (BSE_TYPE_ITEM,
"BseEditableSample",
diff --git a/bse/bseengine.cc b/bse/bseengine.cc
index 016bb05..239c0bd 100644
--- a/bse/bseengine.cc
+++ b/bse/bseengine.cc
@@ -1358,10 +1358,10 @@ bse_engine_init()
assert_return (bse_engine_initialized == FALSE);
bse_engine_initialized = TRUE;
/* assert correct implmentation of accessor macros defined in bsedefs.hh */
- assert (&BSE_MODULE_GET_USER_DATA ((BseModule*) 42) == &((BseModule*) 42)->user_data);
- assert (&BSE_MODULE_GET_ISTREAMSP ((BseModule*) 42) == (void*) &((BseModule*) 42)->istreams);
- assert (&BSE_MODULE_GET_JSTREAMSP ((BseModule*) 42) == (void*) &((BseModule*) 42)->jstreams);
- assert (&BSE_MODULE_GET_OSTREAMSP ((BseModule*) 42) == (void*) &((BseModule*) 42)->ostreams);
+ assert_return (&BSE_MODULE_GET_USER_DATA ((BseModule*) 42) == &((BseModule*) 42)->user_data);
+ assert_return (&BSE_MODULE_GET_ISTREAMSP ((BseModule*) 42) == (void*) &((BseModule*) 42)->istreams);
+ assert_return (&BSE_MODULE_GET_JSTREAMSP ((BseModule*) 42) == (void*) &((BseModule*) 42)->jstreams);
+ assert_return (&BSE_MODULE_GET_OSTREAMSP ((BseModule*) 42) == (void*) &((BseModule*) 42)->ostreams);
/* setup threading */
Bse::MasterThread::start (bse_main_wakeup);
/* first configure */
diff --git a/bse/bseenginemaster.cc b/bse/bseenginemaster.cc
index 57ecf0b..66a198b 100644
--- a/bse/bseenginemaster.cc
+++ b/bse/bseenginemaster.cc
@@ -126,8 +126,8 @@ master_idisconnect_node (EngineNode *node,
guint ostream = node->inputs[istream].src_stream;
gboolean was_consumer;
- assert (ostream < ENGINE_NODE_N_OSTREAMS (src_node) &&
- src_node->outputs[ostream].n_outputs > 0); /* these checks better pass */
+ assert_return (ostream < ENGINE_NODE_N_OSTREAMS (src_node) &&
+ src_node->outputs[ostream].n_outputs > 0); /* these checks better pass */
node->inputs[istream].src_node = NULL;
node->inputs[istream].src_stream = ~0;
@@ -154,9 +154,9 @@ master_jdisconnect_node (EngineNode *node,
guint i, ostream = node->jinputs[jstream][con].src_stream;
gboolean was_consumer;
- assert (ostream < ENGINE_NODE_N_OSTREAMS (src_node) &&
- node->module.jstreams[jstream].jcount > 0 &&
- src_node->outputs[ostream].n_outputs > 0); /* these checks better pass */
+ assert_return (ostream < ENGINE_NODE_N_OSTREAMS (src_node) &&
+ node->module.jstreams[jstream].jcount > 0 &&
+ src_node->outputs[ostream].n_outputs > 0); /* these checks better pass */
i = --node->module.jstreams[jstream].jcount;
node->jinputs[jstream][con] = node->jinputs[jstream][i];
@@ -626,7 +626,7 @@ master_process_job (BseJob *job)
master_timer_list = timer;
break;
default:
- assert_unreached ();
+ assert_return_unreached ();
}
JOB_DEBUG ("done");
}
@@ -711,7 +711,7 @@ master_take_probes (EngineNode *node,
if (ptype == PROBE_SCHEDULED)
{
uint i;
- assert (tjob->probe.n_ostreams == ENGINE_NODE_N_OSTREAMS (node));
+ assert_return (tjob->probe.n_ostreams == ENGINE_NODE_N_OSTREAMS (node));
/* swap output buffers with probe buffers */
BseOStream *ostreams = node->module.ostreams;
node->module.ostreams = tjob->probe.ostreams;
@@ -966,7 +966,7 @@ master_process_flow (void)
assert_return (master_need_process == TRUE);
- assert (bse_fpu_okround () == TRUE);
+ assert_return (bse_fpu_okround () == TRUE);
if (master_schedule)
{
@@ -1194,7 +1194,7 @@ namespace Bse {
MasterThread::MasterThread (const std::function<void()> &caller_wakeup) :
caller_wakeup_ (caller_wakeup)
{
- assert (caller_wakeup_ != NULL);
+ assert_return (caller_wakeup_ != NULL);
if (event_fd_.open() != 0)
fatal ("BSE: failed to create master thread wake-up pipe: %s", strerror (errno));
}
@@ -1207,13 +1207,13 @@ MasterThread::master_thread()
Bse::TaskRegistry::add ("DSP #1", Rapicorn::ThisThread::process_pid(), Rapicorn::ThisThread::thread_pid());
/* assert pollfd equality, since we're simply casting structures */
- RAPICORN_STATIC_ASSERT (sizeof (struct pollfd) == sizeof (GPollFD));
- RAPICORN_STATIC_ASSERT (G_STRUCT_OFFSET (GPollFD, fd) == G_STRUCT_OFFSET (struct pollfd, fd));
- RAPICORN_STATIC_ASSERT (sizeof (((GPollFD*) 0)->fd) == sizeof (((struct pollfd*) 0)->fd));
- RAPICORN_STATIC_ASSERT (G_STRUCT_OFFSET (GPollFD, events) == G_STRUCT_OFFSET (struct pollfd, events));
- RAPICORN_STATIC_ASSERT (sizeof (((GPollFD*) 0)->events) == sizeof (((struct pollfd*) 0)->events));
- RAPICORN_STATIC_ASSERT (G_STRUCT_OFFSET (GPollFD, revents) == G_STRUCT_OFFSET (struct pollfd, revents));
- RAPICORN_STATIC_ASSERT (sizeof (((GPollFD*) 0)->revents) == sizeof (((struct pollfd*) 0)->revents));
+ static_assert (sizeof (struct pollfd) == sizeof (GPollFD), "");
+ static_assert (G_STRUCT_OFFSET (GPollFD, fd) == G_STRUCT_OFFSET (struct pollfd, fd), "");
+ static_assert (sizeof (((GPollFD*) 0)->fd) == sizeof (((struct pollfd*) 0)->fd), "");
+ static_assert (G_STRUCT_OFFSET (GPollFD, events) == G_STRUCT_OFFSET (struct pollfd, events), "");
+ static_assert (sizeof (((GPollFD*) 0)->events) == sizeof (((struct pollfd*) 0)->events), "");
+ static_assert (G_STRUCT_OFFSET (GPollFD, revents) == G_STRUCT_OFFSET (struct pollfd, revents), "");
+ static_assert (sizeof (((GPollFD*) 0)->revents) == sizeof (((struct pollfd*) 0)->revents), "");
/* add the thread wakeup pipe to master pollfds,
* so we get woken up in time.
@@ -1255,7 +1255,7 @@ static std::atomic<MasterThread*> master_thread_singleton { NULL };
void
MasterThread::reap_master_thread ()
{
- assert (master_thread_singleton != NULL);
+ assert_return (master_thread_singleton != NULL);
assert_return (master_thread_running == true);
master_thread_running = false;
BseInternal::engine_stop_slaves();
@@ -1269,10 +1269,10 @@ MasterThread::reap_master_thread ()
void
MasterThread::start (const std::function<void()> &caller_wakeup)
{
- assert (master_thread_singleton == NULL);
+ assert_return (master_thread_singleton == NULL);
MasterThread *mthread = new MasterThread (caller_wakeup);
master_thread_singleton = mthread;
- assert (master_thread_running == false);
+ assert_return (master_thread_running == false);
if (std::atexit (reap_master_thread) != 0)
fatal ("BSE: failed to install master thread reaper");
master_thread_running = true;
diff --git a/bse/bseengineschedule.cc b/bse/bseengineschedule.cc
index c953169..2f6860d 100644
--- a/bse/bseengineschedule.cc
+++ b/bse/bseengineschedule.cc
@@ -369,8 +369,8 @@ _engine_schedule_consumer_node (EngineSchedule *schedule,
assert_return (ENGINE_NODE_IS_VIRTUAL (node) == FALSE);
subschedule_query_node (schedule, node, &query);
- assert (query.cycles == NULL); /* paranoid */
- assert (query.cycle_nodes == NULL); /* paranoid */
+ assert_return (query.cycles == NULL); /* paranoid */
+ assert_return (query.cycle_nodes == NULL); /* paranoid */
schedule_node (schedule, node, query.leaf_level);
}
@@ -405,13 +405,14 @@ determine_suspension_state (EngineNode *node,
gboolean *keep_state_p)
{
gboolean seen_cycle = FALSE;
- guint64 stamp;
- assert (node->in_suspend_call == FALSE);
+ guint64 stamp = Bse::TickStamp::max_stamp();
+ assert_return (node->in_suspend_call == FALSE, stamp);
if (node->update_suspend)
{
node->in_suspend_call = TRUE;
SfiRing *ring; /* calculate outer suspend constraints */
- stamp = ENGINE_NODE_IS_CONSUMER (node) ? 0 : Bse::TickStamp::max_stamp();
+ if (ENGINE_NODE_IS_CONSUMER (node))
+ stamp = 0;
gboolean keep_state = FALSE;
for (ring = node->output_nodes; ring; ring = sfi_ring_walk (ring, node->output_nodes))
{
@@ -467,13 +468,13 @@ merge_untagged_node_lists_uniq (SfiRing *ring1,
for (walk = ring2; walk; walk = sfi_ring_walk (walk, ring2))
{
EngineNode *node = (EngineNode*) walk->data;
- assert (node->sched_recurse_tag == FALSE);
+ assert_return (node->sched_recurse_tag == FALSE, NULL);
}
/* tag all nodes in ring1 first */
for (walk = ring1; walk; walk = sfi_ring_walk (walk, ring1))
{
EngineNode *node = (EngineNode*) walk->data;
- assert (node->sched_recurse_tag == FALSE); /* paranoid check */
+ assert_return (node->sched_recurse_tag == FALSE, NULL); /* paranoid check */
node->sched_recurse_tag = TRUE;
}
/* merge list with missing (untagged) nodes */
@@ -521,7 +522,7 @@ master_resolve_cycles (EngineQuery *query,
{
SfiRing *walk;
gboolean all_resolved = TRUE;
- assert (query->cycles != NULL); /* paranoid */
+ assert_return (query->cycles != NULL, FALSE); /* paranoid */
walk = query->cycles;
while (walk)
{
@@ -529,8 +530,8 @@ master_resolve_cycles (EngineQuery *query,
EngineCycle *cycle = (EngineCycle*) walk->data;
if (resolve_cycle (cycle, node, &query->cycle_nodes))
{
- assert (cycle->last == NULL); /* paranoid */
- assert (cycle->nodes == NULL); /* paranoid */
+ assert_return (cycle->last == NULL, FALSE); /* paranoid */
+ assert_return (cycle->nodes == NULL, FALSE); /* paranoid */
sfi_delete_struct (EngineCycle, cycle);
query->cycles = sfi_ring_remove_node (query->cycles, walk);
}
@@ -539,7 +540,7 @@ master_resolve_cycles (EngineQuery *query,
walk = next;
}
if (all_resolved)
- assert (query->cycles == NULL); /* paranoid */
+ assert_return (query->cycles == NULL, FALSE); /* paranoid */
return all_resolved;
}
@@ -562,7 +563,7 @@ query_merge_cycles (EngineQuery *query,
EngineNode *node)
{
SfiRing *walk;
- assert (child_query->cycles != NULL); /* paranoid */
+ assert_return (child_query->cycles != NULL); /* paranoid */
/* add node to all child cycles */
for (walk = child_query->cycles; walk; walk = sfi_ring_walk (walk, child_query->cycles))
{
@@ -654,18 +655,18 @@ subschedule_child (EngineSchedule *schedule,
query->leaf_level = MAX (query->leaf_level, child_query.leaf_level + 1);
if (!child_query.cycles)
{
- assert (child_query.cycle_nodes == NULL); /* paranoid */
+ assert_return (child_query.cycle_nodes == NULL); /* paranoid */
schedule_node (schedule, child, child_query.leaf_level);
}
else if (master_resolve_cycles (&child_query, child))
{
- assert (child == child_query.cycle_nodes->data); /* paranoid */
+ assert_return (child == child_query.cycle_nodes->data); /* paranoid */
schedule_cycle (schedule, child_query.cycle_nodes, child_query.leaf_level);
child_query.cycle_nodes = NULL;
}
else
query_merge_cycles (query, &child_query, node);
- assert (child_query.cycles == NULL && child_query.cycle_nodes == NULL); /* paranoid */
+ assert_return (child_query.cycles == NULL && child_query.cycle_nodes == NULL); /* paranoid */
}
}
diff --git a/bse/bseengineutils.cc b/bse/bseengineutils.cc
index 686ae7f..9bcae5b 100644
--- a/bse/bseengineutils.cc
+++ b/bse/bseengineutils.cc
@@ -68,7 +68,7 @@ void
bse_engine_free_ostreams (guint n_ostreams,
BseOStream *ostreams)
{
- assert (n_ostreams > 0);
+ assert_return (n_ostreams > 0);
/* bse_engine_block_size() may have changed since allocation */
g_free (ostreams);
}
@@ -414,7 +414,7 @@ engine_fetch_process_queue_trash_jobs_U (EngineTimedJob **trash_tjobs_head,
* during processing. to ensure this, we assert that no flow processing
* schedule is currently set.
*/
- assert (pqueue_schedule == NULL);
+ assert_return (pqueue_schedule == NULL);
pqueue_mutex.unlock();
}
else
@@ -513,7 +513,7 @@ _engine_push_processed_node (EngineNode *node)
assert_return (pqueue_n_nodes > 0);
assert_return (ENGINE_NODE_IS_SCHEDULED (node));
pqueue_mutex.lock();
- assert (pqueue_n_nodes > 0); /* paranoid */
+ assert_return (pqueue_n_nodes > 0); /* paranoid */
collect_user_jobs_L (node);
pqueue_n_nodes -= 1;
ENGINE_NODE_UNLOCK (node);
@@ -590,7 +590,7 @@ _engine_mnl_integrate (EngineNode *node)
master_node_list_tail = node;
if (!master_node_list_head)
master_node_list_head = master_node_list_tail;
- assert (node->mnl_next == NULL);
+ assert_return (node->mnl_next == NULL);
}
void
diff --git a/bse/bseenums.cc b/bse/bseenums.cc
index 1266bde..dfb5e7f 100644
--- a/bse/bseenums.cc
+++ b/bse/bseenums.cc
@@ -34,7 +34,7 @@ bse_type_register_enums (void)
else if (enums[i].parent_type == G_TYPE_FLAGS)
*(enums[i].type_p) = g_flags_register_static (enums[i].name, (GFlagsValue*) enums[i].values);
else
- assert_unreached ();
+ assert_return_unreached ();
}
}
diff --git a/bse/bsegconfig.cc b/bse/bsegconfig.cc
index 6aa24bc..640cc80 100644
--- a/bse/bsegconfig.cc
+++ b/bse/bsegconfig.cc
@@ -88,7 +88,7 @@ expand_sub14 (char *gstr)
// UTF-8: "\xef\xbf\xb9\x1a\xef\xbf\xba{{...}}\xef\xbf\xbb";
const char *pattern = "\357\277\271\357\277\272\\{\\{([^{}]*)\\}\\}\357\277\273";
rc = regcomp (&preg, pattern, REG_EXTENDED); // FIXME: should be atomic
- assert (rc == 0 && preg.re_nsub);
+ assert_return (rc == 0 && preg.re_nsub, NULL);
// if non-static: regfree (&preg);
}
regmatch_t pm[2] = { { 0, }, };
diff --git a/bse/bseinstrumentinput.cc b/bse/bseinstrumentinput.cc
index c2589f7..98a2cc0 100644
--- a/bse/bseinstrumentinput.cc
+++ b/bse/bseinstrumentinput.cc
@@ -103,7 +103,7 @@ bse_instrument_input_class_init (BseInstrumentInputClass *klass)
item_class->set_parent = bse_instrument_input_set_parent;
/* assert parent class introduced enough ports */
- assert (BSE_SUB_IPORT_N_PORTS >= 4);
+ assert_return (BSE_SUB_IPORT_N_PORTS >= 4);
/* override parent properties with NOP properties */
for (i = 0; i < BSE_SUB_IPORT_N_PORTS; i++)
{
@@ -115,13 +115,13 @@ bse_instrument_input_class_init (BseInstrumentInputClass *klass)
}
ochannel_id = bse_source_class_add_ochannel (source_class, "frequency", _("Frequency"), _("Note
Frequency"));
- assert (ochannel_id == BSE_INSTRUMENT_INPUT_OCHANNEL_FREQUENCY);
+ assert_return (ochannel_id == BSE_INSTRUMENT_INPUT_OCHANNEL_FREQUENCY);
ochannel_id = bse_source_class_add_ochannel (source_class, "gate", _("Gate"), _("High if the note is
currently being pressed"));
- assert (ochannel_id == BSE_INSTRUMENT_INPUT_OCHANNEL_GATE);
+ assert_return (ochannel_id == BSE_INSTRUMENT_INPUT_OCHANNEL_GATE);
ochannel_id = bse_source_class_add_ochannel (source_class, "velocity", _("Velocity"), _("Velocity of the
note press"));
- assert (ochannel_id == BSE_INSTRUMENT_INPUT_OCHANNEL_VELOCITY);
+ assert_return (ochannel_id == BSE_INSTRUMENT_INPUT_OCHANNEL_VELOCITY);
ochannel_id = bse_source_class_add_ochannel (source_class, "aftertouch", _("Aftertouch"), _("Velocity
while the note is pressed"));
- assert (ochannel_id == BSE_INSTRUMENT_INPUT_OCHANNEL_AFTERTOUCH);
+ assert_return (ochannel_id == BSE_INSTRUMENT_INPUT_OCHANNEL_AFTERTOUCH);
}
BSE_BUILTIN_TYPE (BseInstrumentInput)
diff --git a/bse/bseinstrumentoutput.cc b/bse/bseinstrumentoutput.cc
index 6820784..98e8308 100644
--- a/bse/bseinstrumentoutput.cc
+++ b/bse/bseinstrumentoutput.cc
@@ -103,7 +103,7 @@ bse_instrument_output_class_init (BseInstrumentOutputClass *klass)
item_class->set_parent = bse_instrument_output_set_parent;
/* assert parent class introduced enough ports */
- assert (BSE_SUB_OPORT_N_PORTS >= 4);
+ assert_return (BSE_SUB_OPORT_N_PORTS >= 4);
/* override parent properties with NOP properties */
for (i = 0; i < BSE_SUB_OPORT_N_PORTS; i++)
{
@@ -115,13 +115,13 @@ bse_instrument_output_class_init (BseInstrumentOutputClass *klass)
}
ichannel_id = bse_source_class_add_ichannel (source_class, "left-audio", _("Left Audio"), _("Left Channel
Output"));
- assert (ichannel_id == BSE_INSTRUMENT_OUTPUT_ICHANNEL_LEFT);
+ assert_return (ichannel_id == BSE_INSTRUMENT_OUTPUT_ICHANNEL_LEFT);
ichannel_id = bse_source_class_add_ichannel (source_class, "right-audio", _("Right Audio"), _("Right
Channel Output"));
- assert (ichannel_id == BSE_INSTRUMENT_OUTPUT_ICHANNEL_RIGHT);
+ assert_return (ichannel_id == BSE_INSTRUMENT_OUTPUT_ICHANNEL_RIGHT);
ichannel_id = bse_source_class_add_ichannel (source_class, "unused", _("Unused"), NULL);
- assert (ichannel_id == BSE_INSTRUMENT_OUTPUT_ICHANNEL_UNUSED);
+ assert_return (ichannel_id == BSE_INSTRUMENT_OUTPUT_ICHANNEL_UNUSED);
ichannel_id = bse_source_class_add_ichannel (source_class, "synth-done", _("Synth Done"), _("High
indicates the instrument is done synthesizing"));
- assert (ichannel_id == BSE_INSTRUMENT_OUTPUT_ICHANNEL_DONE);
+ assert_return (ichannel_id == BSE_INSTRUMENT_OUTPUT_ICHANNEL_DONE);
}
BSE_BUILTIN_TYPE (BseInstrumentOutput)
diff --git a/bse/bseitem.cc b/bse/bseitem.cc
index 627adf5..876fa34 100644
--- a/bse/bseitem.cc
+++ b/bse/bseitem.cc
@@ -65,7 +65,7 @@ BSE_BUILTIN_TYPE (BseItem)
(GInstanceInitFunc) bse_item_init,
};
- assert (BSE_ITEM_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
+ assert_return (BSE_ITEM_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT, 0);
return bse_type_register_abstract (BSE_TYPE_OBJECT,
"BseItem",
@@ -1336,13 +1336,13 @@ ItemImpl::push_property_undo (const String &property_name)
assert_return (property_name.empty() == false);
Any saved_value = __aida_get__ (property_name);
if (saved_value.empty())
- critical ("%s: invalid property name: %s", __func__, property_name);
+ Bse::warning ("%s: invalid property name: %s", __func__, property_name);
else
{
auto lambda = [property_name, saved_value] (ItemImpl &self, BseUndoStack *ustack) -> Error {
const bool success = self.__aida_set__ (property_name, saved_value);
if (!success)
- critical ("%s: failed to undo property change for '%s': %s", __func__, property_name,
saved_value.repr());
+ Bse::warning ("%s: failed to undo property change for '%s': %s", __func__, property_name,
saved_value.repr());
return Error::NONE;
};
push_undo (__func__, *this, lambda);
diff --git a/bse/bseladspamodule.cc b/bse/bseladspamodule.cc
index 7b6c08f..d7d3a0a 100644
--- a/bse/bseladspamodule.cc
+++ b/bse/bseladspamodule.cc
@@ -75,7 +75,7 @@ ladspa_derived_class_init (BseLadspaModuleClass *klass,
derived_parent_class = g_type_class_peek_parent (klass);
- assert (class_data != NULL);
+ assert_return (class_data != NULL);
klass->bli = (BseLadspaInfo*) class_data;
gobject_class->finalize = ladspa_derived_finalize;
@@ -97,7 +97,7 @@ bse_ladspa_module_derived_type_info (GType type,
BseLadspaInfo *bli,
GTypeInfo *type_info)
{
- assert (bli != NULL);
+ assert_return (bli != NULL);
type_info->class_size = sizeof (BseLadspaModuleClass);
type_info->class_init = (GClassInitFunc) ladspa_derived_class_init;
type_info->class_finalize = (GClassFinalizeFunc) ladspa_derived_class_finalize;
@@ -113,11 +113,10 @@ bse_ladspa_module_class_init_from_info (BseLadspaModuleClass *ladspa_module_clas
BseObjectClass *object_class = BSE_OBJECT_CLASS (ladspa_module_class);
BseSourceClass *source_class = BSE_SOURCE_CLASS (ladspa_module_class);
BseLadspaInfo *bli = ladspa_module_class->bli;
- uint ochannel, ichannel;
- assert (ladspa_module_class->bli != NULL &&
- gobject_class->set_property == NULL &&
- gobject_class->get_property == NULL);
+ assert_return (ladspa_module_class->bli != NULL &&
+ gobject_class->set_property == NULL &&
+ gobject_class->get_property == NULL);
gobject_class->set_property = ladspa_derived_set_property;
gobject_class->get_property = ladspa_derived_get_property;
@@ -215,6 +214,7 @@ bse_ladspa_module_class_init_from_info (BseLadspaModuleClass *ladspa_module_clas
}
}
+ uint ochannel, ichannel;
for (size_t i = 0; i < bli->n_aports; i++)
{
BseLadspaPort *port = bli->aports + i;
@@ -223,6 +223,8 @@ bse_ladspa_module_class_init_from_info (BseLadspaModuleClass *ladspa_module_clas
else /* port->output */
ochannel = bse_source_class_add_ochannel (source_class, port->ident, port->name, NULL);
}
+ (void) ochannel;
+ (void) ichannel;
}
static float
@@ -242,7 +244,7 @@ ladspa_value_get_float (BseLadspaModule *self,
case SFI_SCAT_REAL:
return sfi_value_get_real (value);
default:
- assert_unreached ();
+ assert_return_unreached (0);
return 0;
}
}
@@ -268,7 +270,7 @@ ladspa_value_set_float (BseLadspaModule *self,
sfi_value_set_real (value, v_float);
break;
default:
- assert_unreached ();
+ assert_return_unreached ();
}
}
diff --git a/bse/bseloader-aiff.cc b/bse/bseloader-aiff.cc
index a607f12..4e069ad 100644
--- a/bse/bseloader-aiff.cc
+++ b/bse/bseloader-aiff.cc
@@ -542,7 +542,7 @@ _gsl_init_loader_aiff (void)
};
static gboolean initialized = FALSE;
- assert (initialized == FALSE);
+ assert_return (initialized == FALSE);
initialized = TRUE;
bse_loader_register (&loader);
diff --git a/bse/bseloader-bsewave.cc b/bse/bseloader-bsewave.cc
index 2896da2..fd815a3 100644
--- a/bse/bseloader-bsewave.cc
+++ b/bse/bseloader-bsewave.cc
@@ -145,7 +145,7 @@ bsewave_load_file_info (void *data,
{
const char *p = strrchr (_file_name, G_DIR_SEPARATOR);
- assert (p != NULL);
+ assert_return (p != NULL, NULL);
cwd = g_strndup (_file_name, p - _file_name + 1);
file_name = g_strdup (_file_name);
}
@@ -863,7 +863,7 @@ _gsl_init_loader_gslwave (void)
};
static gboolean initialized = FALSE;
- assert (initialized == FALSE);
+ assert_return (initialized == FALSE);
initialized = TRUE;
bse_loader_register (&loader);
diff --git a/bse/bseloader-flac.cc b/bse/bseloader-flac.cc
index 77fa1be..47f5b0a 100644
--- a/bse/bseloader-flac.cc
+++ b/bse/bseloader-flac.cc
@@ -182,7 +182,7 @@ bse_init_loader_flac (void)
};
static gboolean initialized = FALSE;
- assert (initialized == FALSE);
+ assert_return (initialized == FALSE);
initialized = TRUE;
bse_loader_register (&loader);
diff --git a/bse/bseloader-guspatch.cc b/bse/bseloader-guspatch.cc
index f50ea4e..a23075e 100644
--- a/bse/bseloader-guspatch.cc
+++ b/bse/bseloader-guspatch.cc
@@ -625,7 +625,7 @@ bse_init_loader_gus_patch (void)
};
static gboolean initialized = FALSE;
- assert (initialized == FALSE);
+ assert_return (initialized == FALSE);
initialized = TRUE;
bse_loader_register (&loader);
diff --git a/bse/bseloader-mad.cc b/bse/bseloader-mad.cc
index fc5b984..9c2c446 100644
--- a/bse/bseloader-mad.cc
+++ b/bse/bseloader-mad.cc
@@ -195,7 +195,7 @@ _gsl_init_loader_mad (void)
};
static gboolean initialized = FALSE;
- assert (initialized == FALSE);
+ assert_return (initialized == FALSE);
initialized = TRUE;
if (BSE_HAVE_LIBMAD)
diff --git a/bse/bseloader-oggvorbis.cc b/bse/bseloader-oggvorbis.cc
index 579f1a8..fac60c8 100644
--- a/bse/bseloader-oggvorbis.cc
+++ b/bse/bseloader-oggvorbis.cc
@@ -158,7 +158,7 @@ _gsl_init_loader_oggvorbis (void)
};
static gboolean initialized = FALSE;
- assert (initialized == FALSE);
+ assert_return (initialized == FALSE);
initialized = TRUE;
bse_loader_register (&loader);
diff --git a/bse/bseloader-wav.cc b/bse/bseloader-wav.cc
index 5626f98..92cbb28 100644
--- a/bse/bseloader-wav.cc
+++ b/bse/bseloader-wav.cc
@@ -41,7 +41,7 @@ wav_read_header (int fd,
/* read header contents */
n_bytes = 4 + 4 + 4;
- assert (n_bytes == sizeof (*header));
+ assert_return (n_bytes == sizeof (*header), Bse::Error::INTERNAL);
if (read (fd, header, n_bytes) != n_bytes)
{
LDEBUG ("failed to read WavHeader: %s", g_strerror (errno));
@@ -94,7 +94,7 @@ wav_read_fmt_header (int fd,
/* read header contents */
n_bytes = 4 + 4 + 2 + 2 + 4 + 4 + 2 + 2;
- assert (n_bytes == sizeof (*header));
+ assert_return (n_bytes == sizeof (*header), Bse::Error::INTERNAL);
if (read (fd, header, n_bytes) != n_bytes)
{
LDEBUG ("failed to read FmtHeader");
@@ -196,7 +196,7 @@ wav_read_data_header (int fd,
/* read header contents */
n_bytes = 4 + 4;
- assert (n_bytes == sizeof (*header));
+ assert_return (n_bytes == sizeof (*header), Bse::Error::INTERNAL);
if (read (fd, header, n_bytes) != n_bytes)
{
LDEBUG ("failed to read DataHeader");
@@ -456,7 +456,7 @@ _gsl_init_loader_wav (void)
};
static gboolean initialized = FALSE;
- assert (initialized == FALSE);
+ assert_return (initialized == FALSE);
initialized = TRUE;
bse_loader_register (&loader);
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index 2a08b0f..5d9f030 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -77,7 +77,7 @@ bse_init_intern()
// paranoid assertions
if (bse_initialization_stage != 0 || ++bse_initialization_stage != 1)
g_error ("%s() may only be called once", "bse_init_inprocess");
- assert (G_BYTE_ORDER == G_LITTLE_ENDIAN || G_BYTE_ORDER == G_BIG_ENDIAN);
+ assert_return (G_BYTE_ORDER == G_LITTLE_ENDIAN || G_BYTE_ORDER == G_BIG_ENDIAN);
// main loop
bse_main_context = g_main_context_new ();
@@ -179,8 +179,8 @@ _bse_initialized ()
static void
initialize_with_argv (int *argc, char **argv, const char *app_name, const Bse::StringVector &args)
{
- assert (_bse_initialized() == false);
- assert (bse_main_context == NULL);
+ assert_return (_bse_initialized() == false);
+ assert_return (bse_main_context == NULL);
// setup GLib's prgname for error messages
if (argc && argv && *argc && !g_get_prgname ())
@@ -254,7 +254,7 @@ _bse_init_async (int *argc, char **argv, const char *app_name, const Bse::String
async_bse_thread = std::thread (bse_main_loop_thread, init_queue); // calls bse_init_intern
// wait for initialization completion of the core thread
int msg = init_queue->pop();
- assert (msg == 'B');
+ assert_return (msg == 'B');
delete init_queue;
}
@@ -309,7 +309,7 @@ bse_main_wakeup ()
void
bse_init_test (int *argc, char **argv, const Bse::StringVector &args)
{
- assert (initialized_for_unit_testing < 0);
+ assert_return (initialized_for_unit_testing < 0);
initialized_for_unit_testing = 1;
bse_init_inprocess (argc, argv, NULL, args);
}
diff --git a/bse/bsemidicontroller.cc b/bse/bsemidicontroller.cc
index cb31735..5279d06 100644
--- a/bse/bsemidicontroller.cc
+++ b/bse/bsemidicontroller.cc
@@ -120,13 +120,13 @@ bse_midi_controller_class_init (BseMidiControllerClass *klass)
SFI_PARAM_STANDARD));
ochannel_id = bse_source_class_add_ochannel (source_class, "ctrl-out1", _("Ctrl Out1"), _("MIDI Signal
1"));
- assert (ochannel_id == BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL1);
+ assert_return (ochannel_id == BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL1);
ochannel_id = bse_source_class_add_ochannel (source_class, "ctrl-out2", _("Ctrl Out2"), _("MIDI Signal
2"));
- assert (ochannel_id == BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL2);
+ assert_return (ochannel_id == BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL2);
ochannel_id = bse_source_class_add_ochannel (source_class, "ctrl-out3", _("Ctrl Out3"), _("MIDI Signal
3"));
- assert (ochannel_id == BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL3);
+ assert_return (ochannel_id == BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL3);
ochannel_id = bse_source_class_add_ochannel (source_class, "ctrl-out4", _("Ctrl Out4"), _("MIDI Signal
4"));
- assert (ochannel_id == BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL4);
+ assert_return (ochannel_id == BSE_MIDI_CONTROLLER_OCHANNEL_CONTROL4);
}
static void
diff --git a/bse/bsemididecoder.cc b/bse/bsemididecoder.cc
index ce97c62..c7c2002 100644
--- a/bse/bsemididecoder.cc
+++ b/bse/bsemididecoder.cc
@@ -90,7 +90,7 @@ midi_decoder_advance_state (BseMidiDecoder *self)
self->delta_time = 0;
self->event_type = BseMidiEventType (0);
/* keep running_mode and zchannel */
- assert (self->left_bytes == 0);
+ assert_return (self->left_bytes == 0);
if (self->n_bytes)
g_warning ("leaking %d bytes of midi data", self->n_bytes);
self->n_bytes = 0;
diff --git a/bse/bsemididevice-null.cc b/bse/bsemididevice-null.cc
index 604d90d..3676bf5 100644
--- a/bse/bsemididevice-null.cc
+++ b/bse/bsemididevice-null.cc
@@ -46,7 +46,7 @@ bse_midi_device_null_close (BseDevice *device)
NULLHandle *null = (NULLHandle*) BSE_MIDI_DEVICE (device)->handle;
BseMidiHandle *handle = &null->handle;
BSE_MIDI_DEVICE (device)->handle = NULL;
- assert (handle->running_thread == FALSE);
+ assert_return (handle->running_thread == FALSE);
/* midi_handle_abort_wait (handle); */
g_free (null);
}
diff --git a/bse/bsemidiinput.cc b/bse/bsemidiinput.cc
index eabf37f..00e44eb 100644
--- a/bse/bsemidiinput.cc
+++ b/bse/bsemidiinput.cc
@@ -91,13 +91,13 @@ bse_midi_input_class_init (BseMidiInputClass *klass)
SFI_PARAM_GUI SFI_PARAM_STORAGE ":scale:skip-default"));
ochannel_id = bse_source_class_add_ochannel (source_class, "frequency", _("Frequency"), _("Note
Frequency"));
- assert (ochannel_id == BSE_MIDI_INPUT_OCHANNEL_FREQUENCY);
+ assert_return (ochannel_id == BSE_MIDI_INPUT_OCHANNEL_FREQUENCY);
ochannel_id = bse_source_class_add_ochannel (source_class, "gate", _("Gate"), _("High if the note is
currently being pressed"));
- assert (ochannel_id == BSE_MIDI_INPUT_OCHANNEL_GATE);
+ assert_return (ochannel_id == BSE_MIDI_INPUT_OCHANNEL_GATE);
ochannel_id = bse_source_class_add_ochannel (source_class, "velocity", _("Velocity"), _("Velocity of the
note press"));
- assert (ochannel_id == BSE_MIDI_INPUT_OCHANNEL_VELOCITY);
+ assert_return (ochannel_id == BSE_MIDI_INPUT_OCHANNEL_VELOCITY);
ochannel_id = bse_source_class_add_ochannel (source_class, "aftertouch", _("Aftertouch"), _("Velocity
while the note is pressed"));
- assert (ochannel_id == BSE_MIDI_INPUT_OCHANNEL_AFTERTOUCH);
+ assert_return (ochannel_id == BSE_MIDI_INPUT_OCHANNEL_AFTERTOUCH);
}
static void
diff --git a/bse/bsemidireceiver.cc b/bse/bsemidireceiver.cc
index 06dc383..d80f3b9 100644
--- a/bse/bsemidireceiver.cc
+++ b/bse/bsemidireceiver.cc
@@ -348,7 +348,7 @@ public:
}
~MidiReceiver()
{
- assert (ref_count == 0);
+ assert_return (ref_count == 0);
for (Channels::iterator it = midi_channels.begin(); it != midi_channels.end(); it++)
delete *it;
while (events)
@@ -711,7 +711,7 @@ voice_input_remove_from_table_L (VoiceInput *vinput) /* UserThread */
vinput->queue_state = VSTATE_IDLE;
return;
}
- assert_unreached ();
+ assert_return_unreached ();
}
}
@@ -804,7 +804,7 @@ change_voice_input_L (VoiceInput *vinput,
assert_return (vinput->iter == vinput->table->end());
vinput->next = (*vinput->table)[freq_value];
vinput->iter = vinput->table->find (freq_value);
- assert (vinput->iter != vinput->table->end());
+ assert_return (vinput->iter != vinput->table->end());
vinput->iter->second = vinput;
}
vinput->queue_state = VSTATE_BUSY;
@@ -849,7 +849,7 @@ voice_input_module_free_U (gpointer data,
const BseModuleClass *klass)
{
VoiceInput *vinput = (VoiceInput*) data;
- assert (vinput->next == NULL);
+ assert_return (vinput->next == NULL);
delete vinput;
}
diff --git a/bse/bsemidivoice.cc b/bse/bsemidivoice.cc
index 373dc4d..010c263 100644
--- a/bse/bsemidivoice.cc
+++ b/bse/bsemidivoice.cc
@@ -92,13 +92,13 @@ bse_midi_voice_input_class_init (BseMidiVoiceInputClass *klass)
source_class->context_dismiss = bse_midi_voice_input_context_dismiss;
channel_id = bse_source_class_add_ochannel (source_class, "freq-out", _("Freq Out"), NULL);
- assert (channel_id == BSE_MIDI_VOICE_INPUT_OCHANNEL_FREQUENCY);
+ assert_return (channel_id == BSE_MIDI_VOICE_INPUT_OCHANNEL_FREQUENCY);
channel_id = bse_source_class_add_ochannel (source_class, "gate-out", _("Gate Out"), NULL);
- assert (channel_id == BSE_MIDI_VOICE_INPUT_OCHANNEL_GATE);
+ assert_return (channel_id == BSE_MIDI_VOICE_INPUT_OCHANNEL_GATE);
channel_id = bse_source_class_add_ochannel (source_class, "velocity-out", _("Velocity Out"), NULL);
- assert (channel_id == BSE_MIDI_VOICE_INPUT_OCHANNEL_VELOCITY);
+ assert_return (channel_id == BSE_MIDI_VOICE_INPUT_OCHANNEL_VELOCITY);
channel_id = bse_source_class_add_ochannel (source_class, "aftertouch-out", _("Aftertouch Out"), NULL);
- assert (channel_id == BSE_MIDI_VOICE_INPUT_OCHANNEL_AFTERTOUCH);
+ assert_return (channel_id == BSE_MIDI_VOICE_INPUT_OCHANNEL_AFTERTOUCH);
}
static void
@@ -116,17 +116,17 @@ bse_midi_voice_switch_class_init (BseMidiVoiceSwitchClass *klass)
source_class->context_dismiss = bse_midi_voice_switch_context_dismiss;
channel_id = bse_source_class_add_ichannel (source_class, "left-in", _("Left In"), NULL);
- assert (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_LEFT);
+ assert_return (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_LEFT);
channel_id = bse_source_class_add_ichannel (source_class, "right-in", _("Right In"), NULL);
- assert (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_RIGHT);
+ assert_return (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_RIGHT);
channel_id = bse_source_class_add_ichannel (source_class, "disconnect-in", _("Disconnect In"), NULL);
- assert (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_DISCONNECT);
+ assert_return (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_DISCONNECT);
channel_id = bse_source_class_add_ochannel (source_class, "left-out", _("Left Out"), NULL);
- assert (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_LEFT);
+ assert_return (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_LEFT);
channel_id = bse_source_class_add_ochannel (source_class, "right-out", _("Right Out"), NULL);
- assert (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_RIGHT);
+ assert_return (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_RIGHT);
channel_id = bse_source_class_add_ochannel (source_class, "disconnect-out", _("Disconnect Out"), NULL);
- assert (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_DISCONNECT);
+ assert_return (channel_id == BSE_MIDI_VOICE_SWITCH_ICHANNEL_DISCONNECT);
}
static void
diff --git a/bse/bseobject.cc b/bse/bseobject.cc
index 85b0f38..7775167 100644
--- a/bse/bseobject.cc
+++ b/bse/bseobject.cc
@@ -14,15 +14,15 @@ namespace Bse {
ObjectImpl::ObjectImpl (BseObject *bobj) :
gobject_ (bobj)
{
- assert (gobject_);
- assert (gobject_->cxxobject_ == NULL);
+ assert_return (gobject_);
+ assert_return (gobject_->cxxobject_ == NULL);
g_object_ref (gobject_);
gobject_->cxxobject_ = this;
}
ObjectImpl::~ObjectImpl ()
{
- assert (gobject_->cxxobject_ == this);
+ assert_return (gobject_->cxxobject_ == this);
gobject_->cxxobject_ = NULL;
g_object_unref (gobject_);
// ObjectImpl keeps BseObject alive until it is destroyed
@@ -164,7 +164,7 @@ static __thread uint in_bse_object_new = 0;
static void
bse_object_init (BseObject *object)
{
- assert (in_bse_object_new);
+ assert_return (in_bse_object_new);
object->cxxobject_ = NULL;
object->cxxobjref_ = NULL;
object->flags = 0;
@@ -458,7 +458,7 @@ bse_object_lock (gpointer _object)
assert_return (BSE_IS_OBJECT (object));
assert_return (gobject->ref_count > 0);
- assert (object->lock_count < 65535); // if this breaks, we need to fix the guint16
+ assert_return (object->lock_count < 65535); // if this breaks, we need to fix the guint16
if (!object->lock_count)
{
@@ -932,8 +932,8 @@ bse_object_new_valist (GType object_type, const gchar *first_property_name, va_l
in_bse_object_new++;
BseObject *object = (BseObject*) g_object_new_valist (object_type, first_property_name, var_args);
in_bse_object_new--;
- assert (object->cxxobject_ == NULL);
- assert (object->cxxobjref_ == NULL);
+ assert_return (object->cxxobject_ == NULL, NULL);
+ assert_return (object->cxxobjref_ == NULL, NULL);
Bse::ObjectImpl *cxxo;
if (g_type_is_a (object_type, BSE_TYPE_SERVER))
cxxo = new Bse::ServerImpl (object);
@@ -982,11 +982,11 @@ bse_object_new_valist (GType object_type, const gchar *first_property_name, va_l
else if (g_type_is_a (object_type, BSE_TYPE_OBJECT))
cxxo = new Bse::ObjectImpl (object);
else
- assert (!"reached");
- assert (object->cxxobject_ == cxxo);
- assert (object->cxxobjref_ == NULL);
+ assert_return_unreached (NULL);
+ assert_return (object->cxxobject_ == cxxo, NULL);
+ assert_return (object->cxxobjref_ == NULL, NULL);
object->cxxobjref_ = new Bse::ObjectImplP (cxxo); // shared_ptr that allows enable_shared_from_this
- assert (cxxo == *object);
- assert (object == *cxxo);
+ assert_return (cxxo == *object, NULL);
+ assert_return (object == *cxxo, NULL);
return object;
}
diff --git a/bse/bsepart.cc b/bse/bsepart.cc
index 3d064f4..e7bfe85 100644
--- a/bse/bsepart.cc
+++ b/bse/bsepart.cc
@@ -172,7 +172,7 @@ bse_part_set_property (GObject *object,
bse_part_note_channel_destroy (&self->channels[--self->n_channels]);
break;
case PROP_LAST_TICK:
- assert_unreached ();
+ assert_return_unreached ();
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, param_id, pspec);
@@ -276,7 +276,7 @@ bse_part_alloc_id (BsePart *self,
{
guint i = self->last_id - 1;
- assert (self->ids[i] >= BSE_PART_INVAL_TICK_FLAG);
+ assert_return (self->ids[i] >= BSE_PART_INVAL_TICK_FLAG, 0);
self->last_id = self->ids[i] - BSE_PART_INVAL_TICK_FLAG;
id = i + 1;
@@ -1663,7 +1663,7 @@ bse_part_controls_lookup_ge (BsePartControls *self,
{
guint ix = 1 + g_bsearch_array_get_index (self->bsa, &controls_bsc, node);
node = (BsePartTickNode*) g_bsearch_array_get_nth (self->bsa, &controls_bsc, ix); /* returns NULL for
i >= n_nodes */
- assert (!node || node->tick >= tick);
+ assert_return (!node || node->tick >= tick, NULL);
}
return node;
}
@@ -1678,7 +1678,7 @@ bse_part_controls_lookup_le (BsePartControls *self,
if (node && node->tick > tick) /* adjust smaller ticks */
{
node = g_bsearch_array_get_index (self->bsa, &controls_bsc, node) > 0 ? node - 1 : NULL;
- assert (!node || node->tick <= tick);
+ assert_return (!node || node->tick <= tick, NULL);
}
return node;
}
@@ -1875,7 +1875,7 @@ bse_part_note_channel_lookup_le (BsePartNoteChannel *self,
if (note && note->tick > tick) /* adjust greater ticks */
{
note = g_bsearch_array_get_index (self->bsa, ¬e_channel_bsc, note) > 0 ? note - 1 : NULL;
- assert (!note || note->tick <= tick);
+ assert_return (!note || note->tick <= tick, NULL);
}
return note;
}
@@ -1898,7 +1898,7 @@ bse_part_note_channel_lookup_ge (BsePartNoteChannel *self,
{
guint ix = 1 + g_bsearch_array_get_index (self->bsa, ¬e_channel_bsc, note);
note = (BsePartEventNote*) g_bsearch_array_get_nth (self->bsa, ¬e_channel_bsc, ix); /* returns NULL
for i >= n_nodes */
- assert (!note || note->tick >= tick);
+ assert_return (!note || note->tick >= tick, NULL);
}
return note;
}
@@ -1932,7 +1932,7 @@ part_note_channel_check_crossing (BsePartNoteChannel *self,
BsePartEventNote key, *note;
key.tick = note_tick;
note = (BsePartEventNote*) g_bsearch_array_lookup (self->bsa, ¬e_channel_bsc, &key);
- assert (note);
+ assert_return (note, FALSE);
return note->tick + note->duration > tick_mark;
}
@@ -1959,7 +1959,7 @@ part_note_channel_crossings_remove (guint *crossings,
crossings[i] = crossings[n_crossings];
break;
}
- assert (i <= n_crossings); /* must have found one */
+ assert_return (i <= n_crossings, NULL); /* must have found one */
n_crossings--;
if (n_crossings)
crossings[0] = n_crossings;
@@ -1982,7 +1982,7 @@ bse_part_note_channel_insert (BsePartNoteChannel *self, BsePartEventNote key)
self->bsa = g_bsearch_array_insert (self->bsa, ¬e_channel_bsc, &key);
BSE_SEQUENCER_UNLOCK ();
note = (BsePartEventNote*) g_bsearch_array_lookup (self->bsa, ¬e_channel_bsc, &key);
- assert (note->crossings == NULL && note->id == key.id);
+ assert_return (note->crossings == NULL && note->id == key.id, NULL);
ix = g_bsearch_array_get_index (self->bsa, ¬e_channel_bsc, note);
/* copy predecessor crossings */
if (ix > 0)
diff --git a/bse/bsepcminput.cc b/bse/bsepcminput.cc
index 3081ed0..84d1d49 100644
--- a/bse/bsepcminput.cc
+++ b/bse/bsepcminput.cc
@@ -110,9 +110,9 @@ bse_pcm_input_class_init (BsePcmInputClass *klass)
1, SFI_PARAM_GUI ":dial"));
ochannel_id = bse_source_class_add_ochannel (source_class, "left-audio-out", _("Left Audio Out"), _("Left
channel output"));
- assert (ochannel_id == BSE_PCM_INPUT_OCHANNEL_LEFT);
+ assert_return (ochannel_id == BSE_PCM_INPUT_OCHANNEL_LEFT);
ochannel_id = bse_source_class_add_ochannel (source_class, "right-audio-out", _("Right Audio Out"),
_("Right channel output"));
- assert (ochannel_id == BSE_PCM_INPUT_OCHANNEL_RIGHT);
+ assert_return (ochannel_id == BSE_PCM_INPUT_OCHANNEL_RIGHT);
}
static void
diff --git a/bse/bsepcmoutput.cc b/bse/bsepcmoutput.cc
index 47fe26d..d5deda3 100644
--- a/bse/bsepcmoutput.cc
+++ b/bse/bsepcmoutput.cc
@@ -110,9 +110,9 @@ bse_pcm_output_class_init (BsePcmOutputClass *klass)
1, SFI_PARAM_GUI ":dial"));
ichannel_id = bse_source_class_add_ichannel (source_class, "left-audio-in", _("Left Audio In"), _("Left
channel input"));
- assert (ichannel_id == BSE_PCM_OUTPUT_ICHANNEL_LEFT);
+ assert_return (ichannel_id == BSE_PCM_OUTPUT_ICHANNEL_LEFT);
ichannel_id = bse_source_class_add_ichannel (source_class, "right-audio-in", _("Right Audio In"), _("Right
channel Input"));
- assert (ichannel_id == BSE_PCM_OUTPUT_ICHANNEL_RIGHT);
+ assert_return (ichannel_id == BSE_PCM_OUTPUT_ICHANNEL_RIGHT);
}
static void
diff --git a/bse/bseplugin.cc b/bse/bseplugin.cc
index 7f9a7bc..08c4785 100644
--- a/bse/bseplugin.cc
+++ b/bse/bseplugin.cc
@@ -193,7 +193,7 @@ static BsePlugin *startup_plugin = NULL;
void
bse_plugin_make_resident()
{
- assert (startup_plugin != NULL);
+ assert_return (startup_plugin != NULL);
startup_plugin->resident_types = TRUE;
}
diff --git a/bse/bseprobe.cc b/bse/bseprobe.cc
index b6379c4..f3c5a68 100644
--- a/bse/bseprobe.cc
+++ b/bse/bseprobe.cc
@@ -82,7 +82,7 @@ class ProbeQueue {
const gfloat *oblock,
bool connected)
{
- assert (n <= block_size - n_computed);
+ assert_return (n <= block_size - n_computed);
/* store samples, possibly for fft */
if (requests.samples || requests.fft)
{
@@ -297,7 +297,7 @@ public:
probes (_probes), block_size (_block_size),
first_stamp (0), n_computed (0), raw_floats (NULL)
{
- assert (block_size > 0);
+ assert_return (block_size > 0);
memset (&requests, 0, sizeof (requests));
reset_probe_state();
}
@@ -365,7 +365,7 @@ private:
std::pair<ProbeQueueSet::iterator,bool> result;
result = channel_sets[channel].insert (new ProbeQueue (*this, block_size));
it = result.first;
- assert (result.second == true);
+ assert_return (result.second == true, NULL);
}
return *it;
}
@@ -382,7 +382,7 @@ public:
{}
~SourceProbes ()
{
- assert (queued_jobs == 0);
+ assert_return (queued_jobs == 0);
reset_omodules();
for (uint j = 0; j < channel_sets.size(); j++)
{
@@ -409,7 +409,7 @@ private:
{}
~ProbeData()
{
- assert (ostreams == NULL);
+ assert_return (ostreams == NULL);
}
RAPICORN_CLASS_NON_COPYABLE (ProbeData);
};
@@ -420,14 +420,14 @@ private:
guint n_ostreams, /* ENGINE_NODE_N_OSTREAMS() */
BseOStream **ostreams_p)
{
- assert (pdata.n_pending > 0);
- assert (n_ostreams == channel_sets.size());
+ assert_return (pdata.n_pending > 0);
+ assert_return (n_ostreams == channel_sets.size());
/* preprocess data from multiple modules */
if (!pdata.ostreams) /* first module */
{
/* upon first block, "steal" ostreams */
- assert (pdata.ostreams == NULL);
- assert (pdata.debug_stamp == 0);
+ assert_return (pdata.ostreams == NULL);
+ assert_return (pdata.debug_stamp == 0);
pdata.ostreams = *ostreams_p;
*ostreams_p = NULL;
pdata.debug_n_values = n_values;
@@ -436,8 +436,8 @@ private:
else /* successive modules */
{
/* add up all successive blocks */
- assert (pdata.debug_stamp == tick_stamp);
- assert (pdata.debug_n_values == n_values);
+ assert_return (pdata.debug_stamp == tick_stamp);
+ assert_return (pdata.debug_n_values == n_values);
BseOStream *ostreams = *ostreams_p;
for (uint j = 0; j < n_ostreams; j++)
if (ostreams[j].connected && channel_sets[j].size() > 0)
@@ -483,9 +483,9 @@ private:
{
ProbeData *pdata = reinterpret_cast<ProbeData*> (data);
SourceProbes *probes = peek_from_source (pdata->source);
- assert (probes != NULL);
- assert (probes->queued_jobs > 0);
- assert (pdata->n_pending > 0);
+ assert_return (probes != NULL);
+ assert_return (probes->queued_jobs > 0);
+ assert_return (pdata->n_pending > 0);
probes->handle_probe (*pdata, n_values, tick_stamp, n_ostreams, ostreams_p);
if (!pdata->n_pending)
{
@@ -737,7 +737,7 @@ bse_source_probes_modules_changed (BseSource *source)
void
bse_source_class_add_probe_signals (BseSourceClass *klass)
{
- assert (bse_source_signal_probes == 0);
+ assert_return (bse_source_signal_probes == 0);
BseObjectClass *object_class = BSE_OBJECT_CLASS (klass);
bse_source_signal_probes = bse_object_class_add_signal (object_class, "probes", G_TYPE_NONE, 1,
BSE_TYPE_PROBE_SEQ);
}
diff --git a/bse/bseprocedure.cc b/bse/bseprocedure.cc
index f712761..223411a 100644
--- a/bse/bseprocedure.cc
+++ b/bse/bseprocedure.cc
@@ -670,7 +670,7 @@ procedure_class_unref (BseProcedureClass *proc)
if (!proc->cache_stamp)
{
// printerr ("cache-procedure: %s\n", BSE_PROCEDURE_NAME (proc));
- assert (proc->cache_next == NULL);
+ assert_return (proc->cache_next == NULL);
proc->cache_stamp = 2; /* 'recent' stamp */
proc->cache_next = proc_cache;
proc_cache = proc;
diff --git a/bse/bsesequencer.cc b/bse/bsesequencer.cc
index c7b008f..d0cc2ab 100644
--- a/bse/bsesequencer.cc
+++ b/bse/bsesequencer.cc
@@ -51,7 +51,7 @@ public:
fill_pfds (guint n_pfds,
GPollFD *pfds)
{
- assert (n_pfds == watch_pfds.size());
+ assert_return (n_pfds == watch_pfds.size());
copy (watch_pfds.begin(), watch_pfds.end(), pfds);
for (guint i = 0; i < watches.size(); i++)
watches[i].notify_pfds = pfds + watches[i].index;
@@ -122,13 +122,13 @@ public:
watches.erase (watches.begin() + i);
return true;
}
- RAPICORN_STATIC_ASSERT (sizeof (GPollFD) == sizeof (struct pollfd));
- RAPICORN_STATIC_ASSERT (offsetof (GPollFD, fd) == offsetof (struct pollfd, fd));
- RAPICORN_STATIC_ASSERT (sizeof (((GPollFD*) 0)->fd) == sizeof (((struct pollfd*) 0)->fd));
- RAPICORN_STATIC_ASSERT (offsetof (GPollFD, events) == offsetof (struct pollfd, events));
- RAPICORN_STATIC_ASSERT (sizeof (((GPollFD*) 0)->events) == sizeof (((struct pollfd*) 0)->events));
- RAPICORN_STATIC_ASSERT (offsetof (GPollFD, revents) == offsetof (struct pollfd, revents));
- RAPICORN_STATIC_ASSERT (sizeof (((GPollFD*) 0)->revents) == sizeof (((struct pollfd*) 0)->revents));
+ static_assert (sizeof (GPollFD) == sizeof (struct pollfd), "");
+ static_assert (offsetof (GPollFD, fd) == offsetof (struct pollfd, fd), "");
+ static_assert (sizeof (((GPollFD*) 0)->fd) == sizeof (((struct pollfd*) 0)->fd), "");
+ static_assert (offsetof (GPollFD, events) == offsetof (struct pollfd, events), "");
+ static_assert (sizeof (((GPollFD*) 0)->events) == sizeof (((struct pollfd*) 0)->events), "");
+ static_assert (offsetof (GPollFD, revents) == offsetof (struct pollfd, revents), "");
+ static_assert (sizeof (((GPollFD*) 0)->revents) == sizeof (((struct pollfd*) 0)->revents), "");
};
void
@@ -217,7 +217,7 @@ Sequencer::pool_poll_Lm (gint timeout_ms)
GPollFD *watch_pfds;
while (poll_pool_->fetch_notify_watch (current_watch_func, current_watch_data, watch_n_pfds,
watch_pfds))
{
- assert (!current_watch_needs_remove1 && !current_watch_needs_remove2);
+ assert_return (!current_watch_needs_remove1 && !current_watch_needs_remove2, false);
BSE_SEQUENCER_UNLOCK();
bool current_watch_stays_alive = current_watch_func (current_watch_data, watch_n_pfds, watch_pfds);
BSE_SEQUENCER_LOCK();
@@ -241,7 +241,7 @@ Sequencer::start_song (BseSong *song, uint64 start_stamp)
assert_return (BSE_IS_SONG (song));
assert_return (BSE_SOURCE_PREPARED (song));
assert_return (song->sequencer_start_request_SL == 0);
- assert (song->sequencer_owns_refcount_SL == false);
+ assert_return (song->sequencer_owns_refcount_SL == false);
start_stamp = MAX (start_stamp, 1);
// synchornize pcm-writer output with song start
@@ -273,7 +273,7 @@ Sequencer::remove_song (BseSong *song)
assert_return (BSE_SOURCE_PREPARED (song));
if (song->sequencer_start_request_SL == 0)
{
- assert (song->sequencer_owns_refcount_SL == false);
+ assert_return (song->sequencer_owns_refcount_SL == false);
return; // uncontained
}
BSE_SEQUENCER_LOCK();
@@ -543,7 +543,7 @@ Sequencer::Sequencer() :
stamp_ (0), songs_ (NULL)
{
stamp_ = Bse::TickStamp::current();
- assert (stamp_ > 0);
+ assert_return (stamp_ > 0);
poll_pool_ = new PollPool;
@@ -563,8 +563,8 @@ Sequencer::reap_thread ()
void
Sequencer::_init_threaded ()
{
- assert (singleton_ == NULL);
- assert (sequencer_thread_running == false);
+ assert_return (singleton_ == NULL);
+ assert_return (sequencer_thread_running == false);
singleton_ = new Sequencer();
if (std::atexit (Sequencer::reap_thread) != 0)
fatal ("BSE: failed to install sequencer thread reaper");
diff --git a/bse/bseserver.cc b/bse/bseserver.cc
index 92b1b91..d7bd552 100644
--- a/bse/bseserver.cc
+++ b/bse/bseserver.cc
@@ -146,7 +146,7 @@ rc_file_try_statement (gpointer context_data,
gpointer user_data)
{
BseServer *server = (BseServer*) context_data;
- assert (scanner->next_token == G_TOKEN_IDENTIFIER);
+ assert_return (scanner->next_token == G_TOKEN_IDENTIFIER, G_TOKEN_ERROR);
if (strcmp ("bse-preferences", scanner->next_value.v_identifier) == 0)
{
GValue *value = sfi_value_rec (NULL);
@@ -169,7 +169,7 @@ rc_file_try_statement (gpointer context_data,
static void
bse_server_init (BseServer *self)
{
- assert (BSE_OBJECT_ID (self) == 1); /* assert being the first object */
+ assert_return (BSE_OBJECT_ID (self) == 1); /* assert being the first object */
BSE_OBJECT_SET_FLAGS (self, BSE_ITEM_FLAG_SINGLETON);
self->engine_source = NULL;
@@ -356,10 +356,10 @@ bse_server_get (void)
{
server = (BseServer*) bse_object_new (BSE_TYPE_SERVER, "uname", "ServerImpl", NULL);
g_object_ref (server);
- assert (server);
- assert (server->cxxobject_);
- assert (dynamic_cast<Bse::ObjectImpl*> (server->cxxobject_));
- assert (dynamic_cast<Bse::ServerImpl*> (server->cxxobject_));
+ assert_return (server, NULL);
+ assert_return (server->cxxobject_, NULL);
+ assert_return (dynamic_cast<Bse::ObjectImpl*> (server->cxxobject_), NULL);
+ assert_return (dynamic_cast<Bse::ServerImpl*> (server->cxxobject_), NULL);
}
return server;
@@ -884,7 +884,7 @@ main_thread_source_setup (BseServer *self)
MainSource *xsource = (MainSource*) source;
static gboolean single_call = 0;
- assert (single_call++ == 0);
+ assert_return (single_call++ == 0);
xsource->server = self;
g_source_set_priority (source, BSE_PRIORITY_NORMAL);
@@ -1364,10 +1364,13 @@ ServerImpl::destroy_project (ProjectIface &project_iface)
{
BseServer *server = as<BseServer*>();
BseProject *project = project_iface.as<BseProject*>();
+ bool project_found_and_destroyed = false;
if (g_list_find (server->projects, project))
- g_object_run_dispose (project);
- else
- critical ("%s: project not found", __func__);
+ {
+ g_object_run_dispose (project);
+ project_found_and_destroyed = true;
+ }
+ assert_return (project_found_and_destroyed);
}
struct AuxDataAndIcon : AuxData {
diff --git a/bse/bsesnet.cc b/bse/bsesnet.cc
index f2f8fe4..538415d 100644
--- a/bse/bsesnet.cc
+++ b/bse/bsesnet.cc
@@ -684,7 +684,7 @@ bse_snet_context_clone_branch (BseSNet *self,
ContextData *cdata;
SfiRing *node;
- assert (self->tmp_context_children == NULL);
+ assert_return (self->tmp_context_children == NULL, 0);
for (node = ring; node; node = sfi_ring_walk (node, ring))
self->tmp_context_children = g_slist_prepend (self->tmp_context_children, node->data);
self->tmp_context_children = g_slist_prepend (self->tmp_context_children, context_merger);
@@ -692,7 +692,7 @@ bse_snet_context_clone_branch (BseSNet *self,
bcid = bse_id_alloc ();
cdata = create_context_data (self, bcid, context, mcontext.midi_receiver, mcontext.midi_channel);
bse_source_create_context_with_data (BSE_SOURCE (self), bcid, cdata, free_context_data, trans);
- assert (self->tmp_context_children == NULL);
+ assert_return (self->tmp_context_children == NULL, 0);
}
else
{
@@ -803,7 +803,7 @@ bse_snet_context_create (BseSource *source,
BseContextMerger *context_merger = (BseContextMerger*) self->tmp_context_children->data;
ContextData *cdata = find_context_data (self, context_handle);
- assert (BSE_IS_CONTEXT_MERGER (context_merger));
+ assert_return (BSE_IS_CONTEXT_MERGER (context_merger));
bse_context_merger_set_merge_context (context_merger, cdata->parent_context);
/* chain parent class' handler */
@@ -889,7 +889,7 @@ BSE_BUILTIN_TYPE (BseSNet)
0 /* n_preallocs */,
(GInstanceInitFunc) bse_snet_init,
};
- assert (BSE_SNET_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
+ assert_return (BSE_SNET_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT, 0);
return bse_type_register_abstract (BSE_TYPE_SUPER, "BseSNet", "BSE Synthesis (Filter) Network", __FILE__,
__LINE__, &type_info);
}
diff --git a/bse/bsesnooper.cc b/bse/bsesnooper.cc
index 7356457..2835792 100644
--- a/bse/bsesnooper.cc
+++ b/bse/bsesnooper.cc
@@ -90,7 +90,7 @@ bse_snooper_class_init (BseSnooperClass *klass)
SFI_PARAM_STANDARD));
ichannel = bse_source_class_add_ichannel (source_class, "signal-in", _("Signal In"), _("Snoop Signal"));
- assert (ichannel == BSE_SNOOPER_ICHANNEL_MONO);
+ assert_return (ichannel == BSE_SNOOPER_ICHANNEL_MONO);
}
static void
diff --git a/bse/bsesong.cc b/bse/bsesong.cc
index b852177..838abde 100644
--- a/bse/bsesong.cc
+++ b/bse/bsesong.cc
@@ -496,7 +496,7 @@ bse_song_reset (BseSource *source)
Bse::Sequencer::instance().remove_song (self);
// chain parent class' handler
BSE_SOURCE_CLASS (parent_class)->reset (source);
- assert (self->sequencer_start_request_SL == 0);
+ assert_return (self->sequencer_start_request_SL == 0);
/* outside of sequencer reach, so no locks needed */
self->sequencer_start_SL = 0;
self->sequencer_done_SL = 0;
@@ -515,7 +515,7 @@ bse_song_create_summation (BseSong *self)
if (!g_type_is_a (type, BSE_TYPE_SOURCE))
g_error ("%s: failed to resolve %s object type, probably missing or broken plugin installation",
__func__, "BseSummation");
BseSource *summation = (BseSource*) bse_container_new_child (BSE_CONTAINER (self), type, "uname",
"Summation", NULL);
- assert (summation != NULL);
+ assert_return (summation != NULL, NULL);
bse_snet_intern_child (BSE_SNET (self), summation);
return summation;
}
diff --git a/bse/bsesource.cc b/bse/bsesource.cc
index 2e0bf99..c71bd92 100644
--- a/bse/bsesource.cc
+++ b/bse/bsesource.cc
@@ -469,11 +469,11 @@ bse_source_set_automation_property (BseSource *source,
guint midi_channel,
Bse::MidiSignal signal_type)
{
- assert (BSE_MIDI_CONTROL_NONE == BseMidiControlType (0) &&
- BSE_MIDI_CONTROL_CONTINUOUS_0 == BseMidiControlType (Bse::MidiSignal::CONTINUOUS_0) &&
- BSE_MIDI_CONTROL_CONTINUOUS_31 == BseMidiControlType (Bse::MidiSignal::CONTINUOUS_31) &&
- BSE_MIDI_CONTROL_0 == BseMidiControlType (Bse::MidiSignal::CONTROL_0) &&
- BSE_MIDI_CONTROL_127 == BseMidiControlType (Bse::MidiSignal::CONTROL_127));
+ static_assert (BSE_MIDI_CONTROL_NONE == BseMidiControlType (0) &&
+ BSE_MIDI_CONTROL_CONTINUOUS_0 == BseMidiControlType (Bse::MidiSignal::CONTINUOUS_0) &&
+ BSE_MIDI_CONTROL_CONTINUOUS_31 == BseMidiControlType (Bse::MidiSignal::CONTINUOUS_31) &&
+ BSE_MIDI_CONTROL_0 == BseMidiControlType (Bse::MidiSignal::CONTROL_0) &&
+ BSE_MIDI_CONTROL_127 == BseMidiControlType (Bse::MidiSignal::CONTROL_127), "");
assert_return (BSE_IS_SOURCE (source), Bse::Error::INTERNAL);
assert_return (prop_name != NULL, Bse::Error::INTERNAL);
if (BSE_SOURCE_PREPARED (source))
@@ -2053,7 +2053,7 @@ BSE_BUILTIN_TYPE (BseSource)
(GInstanceInitFunc) bse_source_init,
};
- assert (BSE_SOURCE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
+ assert_return (BSE_SOURCE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT, 0);
return bse_type_register_abstract (BSE_TYPE_ITEM,
"BseSource",
diff --git a/bse/bsestandardosc.cc b/bse/bsestandardosc.cc
index dfb075f..168a2c5 100644
--- a/bse/bsestandardosc.cc
+++ b/bse/bsestandardosc.cc
@@ -180,17 +180,17 @@ bse_standard_osc_class_init (BseStandardOscClass *klass)
SFI_PARAM_STANDARD ":f:dial"));
ichannel = bse_source_class_add_ichannel (source_class, "freq-in", _("Freq In"), _("Oscillating Frequency
Input"));
- assert (ichannel == BSE_STANDARD_OSC_ICHANNEL_FREQ);
+ assert_return (ichannel == BSE_STANDARD_OSC_ICHANNEL_FREQ);
ichannel = bse_source_class_add_ichannel (source_class, "freq-mod-in", _("Freq Mod In"), _("Frequency
Modulation Input"));
- assert (ichannel == BSE_STANDARD_OSC_ICHANNEL_FREQ_MOD);
+ assert_return (ichannel == BSE_STANDARD_OSC_ICHANNEL_FREQ_MOD);
ichannel = bse_source_class_add_ichannel (source_class, "pwm-in", _("PWM In"), _("Pulse Width Modulation
Input"));
- assert (ichannel == BSE_STANDARD_OSC_ICHANNEL_PWM);
+ assert_return (ichannel == BSE_STANDARD_OSC_ICHANNEL_PWM);
ichannel = bse_source_class_add_ichannel (source_class, "sync-in", _("Sync In"), _("Syncronization
Input"));
- assert (ichannel == BSE_STANDARD_OSC_ICHANNEL_SYNC);
+ assert_return (ichannel == BSE_STANDARD_OSC_ICHANNEL_SYNC);
ochannel = bse_source_class_add_ochannel (source_class, "audio-out", _("Audio Out"), _("Oscillated
Output"));
- assert (ochannel == BSE_STANDARD_OSC_OCHANNEL_OSC);
+ assert_return (ochannel == BSE_STANDARD_OSC_OCHANNEL_OSC);
ochannel = bse_source_class_add_ochannel (source_class, "sync-out", _("Sync Out"), _("Syncronization
Output"));
- assert (ochannel == BSE_STANDARD_OSC_OCHANNEL_SYNC);
+ assert_return (ochannel == BSE_STANDARD_OSC_OCHANNEL_SYNC);
}
static void
diff --git a/bse/bsestartup.cc b/bse/bsestartup.cc
index 378ee65..b1b964b 100644
--- a/bse/bsestartup.cc
+++ b/bse/bsestartup.cc
@@ -118,7 +118,7 @@ public:
static AidaGlibSourceImpl*
create (Rapicorn::Aida::BaseConnection *connection)
{
- AIDA_ASSERT (connection != NULL);
+ assert_return (connection != NULL, NULL);
static GSourceFuncs glib_source_funcs = { glib_prepare, glib_check, glib_dispatch, glib_finalize, NULL,
NULL };
GSource *src = g_source_new (&glib_source_funcs, sizeof (AidaGlibSourceImpl));
return new (src) AidaGlibSourceImpl (connection);
@@ -158,9 +158,9 @@ init_server_connection () // bse.hh
if (!server) // shouldn't happen
sfi_error ("%s: failed to establish BSE connection: %s", __func__, g_strerror (errno));
constexpr SfiProxy BSE_SERVER = 1;
- assert (server.proxy_id() == BSE_SERVER);
- assert (server.from_proxy (BSE_SERVER) == server);
- assert (client_connection == NULL);
+ assert_return (server.proxy_id() == BSE_SERVER, NULL);
+ assert_return (server.from_proxy (BSE_SERVER) == server, NULL);
+ assert_return (client_connection == NULL, NULL);
client_connection = new Rapicorn::Aida::ClientConnectionP (connection);
}
return *client_connection;
diff --git a/bse/bsestorage.cc b/bse/bsestorage.cc
index 75b8e8c..7a8362c 100644
--- a/bse/bsestorage.cc
+++ b/bse/bsestorage.cc
@@ -91,7 +91,7 @@ BSE_BUILTIN_TYPE (BseStorage)
(GInstanceInitFunc) bse_storage_init,
};
- assert (BSE_STORAGE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT);
+ assert_return (BSE_STORAGE_FLAGS_USHIFT < BSE_OBJECT_FLAGS_MAX_SHIFT, 0);
return bse_type_register_static (BSE_TYPE_OBJECT, "BseStorage",
"Storage object for item serialization",
@@ -1289,9 +1289,9 @@ storage_store_property_value (BseStorage *self, const std::string &property_name
target = einfo.value_to_string (any.as_int64());
break;
}
- default: assert (!"reached");
+ default: assert_return_unreached();
}
- assert (!target.empty());
+ assert_return (!target.empty());
bse_storage_break (self);
bse_storage_putc (self, '(');
bse_storage_puts (self, property_name.c_str());
diff --git a/bse/bsesubiport.cc b/bse/bsesubiport.cc
index be53552..99252d7 100644
--- a/bse/bsesubiport.cc
+++ b/bse/bsesubiport.cc
@@ -278,7 +278,7 @@ bse_sub_iport_class_init (BseSubIPortClass *klass)
ident = g_strdup_format ("output-%u", i + 1);
label = g_strdup_format (_("Virtual input %u"), i + 1);
channel_id = bse_source_class_add_ochannel (source_class, ident, label, NULL);
- assert (channel_id == i);
+ assert_return (channel_id == i);
g_free (ident);
g_free (label);
diff --git a/bse/bsesuboport.cc b/bse/bsesuboport.cc
index 38dc15b..bfad064 100644
--- a/bse/bsesuboport.cc
+++ b/bse/bsesuboport.cc
@@ -279,7 +279,7 @@ bse_sub_oport_class_init (BseSubOPortClass *klass)
ident = g_strdup_format ("input-%u", i + 1);
label = g_strdup_format (_("Virtual output %u"), i + 1);
channel_id = bse_source_class_add_ichannel (source_class, ident, label, NULL);
- assert (channel_id == i);
+ assert_return (channel_id == i);
g_free (ident);
g_free (label);
diff --git a/bse/bsesubsynth.cc b/bse/bsesubsynth.cc
index b554a20..f5b9eb1 100644
--- a/bse/bsesubsynth.cc
+++ b/bse/bsesubsynth.cc
@@ -338,7 +338,7 @@ bse_sub_synth_context_create (BseSource *source,
recursion_stack = g_slist_prepend (recursion_stack, self);
foreign_context_handle = bse_snet_create_context (snet, mcontext, trans);
recursion_stack = g_slist_remove (recursion_stack, self);
- assert (foreign_context_handle > 0);
+ assert_return (foreign_context_handle > 0);
}
else
shortcut = self->null_shortcut;
@@ -522,14 +522,14 @@ bse_sub_synth_class_init (BseSubSynthClass *klass)
ident = g_strdup_format ("input-%u", i + 1);
label = g_strdup_format (_("Virtual input %u"), i + 1);
channel_id = bse_source_class_add_ichannel (source_class, ident, label, NULL);
- assert (channel_id == i);
+ assert_return (channel_id == i);
g_free (ident);
g_free (label);
ident = g_strdup_format ("output-%u", i + 1);
label = g_strdup_format (_("Virtual output %u"), i + 1);
channel_id = bse_source_class_add_ochannel (source_class, ident, label, NULL);
- assert (channel_id == i);
+ assert_return (channel_id == i);
g_free (ident);
g_free (label);
}
diff --git a/bse/bsetrack.cc b/bse/bsetrack.cc
index 0b610a0..c6dd1c1 100644
--- a/bse/bsetrack.cc
+++ b/bse/bsetrack.cc
@@ -128,17 +128,17 @@ bse_track_dispose (GObject *object)
/* we may assert removal here, since if these assertions fail,
* our parent (BseSong) doesn't properly implement track support
*/
- assert (self->sub_synth == NULL);
+ assert_return (self->sub_synth == NULL);
/* check uncrossed references */
- assert (self->snet == NULL);
- assert (self->pnet == NULL);
- assert (self->n_entries_SL == 0);
+ assert_return (self->snet == NULL);
+ assert_return (self->pnet == NULL);
+ assert_return (self->n_entries_SL == 0);
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
- assert (self->bus_outputs == NULL);
+ assert_return (self->bus_outputs == NULL);
}
static void
@@ -146,9 +146,9 @@ bse_track_finalize (GObject *object)
{
BseTrack *self = BSE_TRACK (object);
- assert (self->bus_outputs == NULL);
+ assert_return (self->bus_outputs == NULL);
- assert (self->n_entries_SL == 0);
+ assert_return (self->n_entries_SL == 0);
g_free (self->entries_SL);
bse_id_free (self->channel_id);
diff --git a/bse/bsetype.cc b/bse/bsetype.cc
index 6ff6ede..9be4614 100644
--- a/bse/bsetype.cc
+++ b/bse/bsetype.cc
@@ -323,7 +323,7 @@ bse_type_reinit_boxed (BseExportNodeBoxed *bnode)
case BSE_EXPORT_NODE_SEQUENCE:
sfi_boxed_type_set_seq_element (bnode->node.type, bnode->func.get_element());
break;
- default: assert_unreached();
+ default: assert_return_unreached();
}
}
@@ -340,7 +340,7 @@ bse_type_uninit_boxed (BseExportNodeBoxed *bnode)
case BSE_EXPORT_NODE_SEQUENCE:
sfi_boxed_type_set_seq_element (bnode->node.type, NULL);
break;
- default: assert_unreached();
+ default: assert_return_unreached();
}
g_type_set_qdata (bnode->node.type, quark_boxed_export_node, NULL);
}
@@ -424,7 +424,7 @@ bse_type_init (void)
bse_type_register_procedure_info (&info);
g_type_register_fundamental (BSE_TYPE_PROCEDURE, "BseProcedure", &info, &finfo, GTypeFlags (0));
bse_type_add_blurb (BSE_TYPE_PROCEDURE, "BSE Procedure base type", __FILE__, __LINE__);
- assert (BSE_TYPE_PROCEDURE == g_type_from_name ("BseProcedure"));
+ assert_return (BSE_TYPE_PROCEDURE == g_type_from_name ("BseProcedure"));
/* initialize extra types */
{
diff --git a/bse/bseutils.cc b/bse/bseutils.cc
index 7356863..0f60808 100644
--- a/bse/bseutils.cc
+++ b/bse/bseutils.cc
@@ -195,20 +195,12 @@ static Bse::Icon
bse_icon_from_pixdata (const BsePixdata *pixdata)
{
Bse::Icon icon;
- if (pixdata->width < 1 || pixdata->width > 128 ||
- pixdata->height < 1 || pixdata->height > 128)
- {
- critical ("%s: `pixdata' exceeds dimension limits (%ux%u)", RAPICORN_SIMPLE_FUNCTION, pixdata->width,
pixdata->height);
- return icon;
- }
+ assert_return (pixdata->width >= 1 && pixdata->width <= 128, icon); // unsupported dimension
+ assert_return (pixdata->height >= 1 && pixdata->height <= 128, icon); // unsupported dimension
const uint bpp = pixdata->type & BSE_PIXDATA_RGB_MASK;
const uint encoding = pixdata->type & BSE_PIXDATA_ENCODING_MASK;
- if ((bpp != BSE_PIXDATA_RGB && bpp != BSE_PIXDATA_RGBA) ||
- (encoding && encoding != BSE_PIXDATA_1BYTE_RLE))
- {
- critical ("%s: `pixdata' format/encoding unrecognized", RAPICORN_SIMPLE_FUNCTION);
- return icon;
- }
+ assert_return (bpp == BSE_PIXDATA_RGB || bpp == BSE_PIXDATA_RGBA, icon); // unsupported depth
+ assert_return (encoding == 0 || encoding == BSE_PIXDATA_1BYTE_RLE, icon); // unsupported format
if (!pixdata->encoded_pix_data)
return icon;
icon.width = pixdata->width;
@@ -632,12 +624,12 @@ icon_from_pixstream (const uint8 *pixstream)
while (image_buffer < image_limit)
{
uint length = *(rle_buffer++);
- bool check_overrun = false;
+ bool overrun_in_icon_rle = false;
if (length & 128)
{
length = length - 128;
- check_overrun = image_buffer + length * bpp > image_limit;
- if (check_overrun)
+ overrun_in_icon_rle = image_buffer + length * bpp > image_limit;
+ if (overrun_in_icon_rle)
length = (image_limit - image_buffer) / bpp;
if (bpp < 4)
do
@@ -659,8 +651,8 @@ icon_from_pixstream (const uint8 *pixstream)
else
{
length *= bpp;
- check_overrun = image_buffer + length > image_limit;
- if (check_overrun)
+ overrun_in_icon_rle = image_buffer + length > image_limit;
+ if (overrun_in_icon_rle)
length = image_limit - image_buffer;
for (uint i = 0; i < length / bpp; i++)
{
@@ -671,11 +663,7 @@ icon_from_pixstream (const uint8 *pixstream)
image_buffer += length;
rle_buffer += length;
}
- if (check_overrun)
- {
- critical ("%s: pixdata with invalid encoding", RAPICORN_SIMPLE_FUNCTION);
- return none;
- }
+ assert_return (overrun_in_icon_rle == false, none); // invalid encoding
}
}
else
diff --git a/bse/bsewaveosc.cc b/bse/bsewaveosc.cc
index af127ee..faa93a2 100644
--- a/bse/bsewaveosc.cc
+++ b/bse/bsewaveosc.cc
@@ -573,15 +573,15 @@ bse_wave_osc_class_init (BseWaveOscClass *klass)
G_TYPE_INT);
ichannel = bse_source_class_add_ichannel (source_class, "freq-in", _("Freq In"), _("Frequency Input"));
- assert (ichannel == BSE_WAVE_OSC_ICHANNEL_FREQ);
+ assert_return (ichannel == BSE_WAVE_OSC_ICHANNEL_FREQ);
ichannel = bse_source_class_add_ichannel (source_class, "sync-in", _("Sync In"), _("Syncronization
Input"));
- assert (ichannel == BSE_WAVE_OSC_ICHANNEL_SYNC);
+ assert_return (ichannel == BSE_WAVE_OSC_ICHANNEL_SYNC);
ichannel = bse_source_class_add_ichannel (source_class, "mod-in", _("Mod In"), _("Modulation Input"));
- assert (ichannel == BSE_WAVE_OSC_ICHANNEL_MOD);
+ assert_return (ichannel == BSE_WAVE_OSC_ICHANNEL_MOD);
ochannel = bse_source_class_add_ochannel (source_class, "audio-out", _("Audio Out"), _("Wave Output"));
- assert (ochannel == BSE_WAVE_OSC_OCHANNEL_WAVE);
+ assert_return (ochannel == BSE_WAVE_OSC_OCHANNEL_WAVE);
ochannel = bse_source_class_add_ochannel (source_class, "gate-out", _("Gate Out"), _("Gate Output"));
- assert (ochannel == BSE_WAVE_OSC_OCHANNEL_GATE);
+ assert_return (ochannel == BSE_WAVE_OSC_OCHANNEL_GATE);
ochannel = bse_source_class_add_ochannel (source_class, "done-out", _("Done Out"), _("Done Output"));
- assert (ochannel == BSE_WAVE_OSC_OCHANNEL_DONE);
+ assert_return (ochannel == BSE_WAVE_OSC_OCHANNEL_DONE);
}
diff --git a/bse/gsldatacache.cc b/bse/gsldatacache.cc
index f11116b..3e8b77a 100644
--- a/bse/gsldatacache.cc
+++ b/bse/gsldatacache.cc
@@ -53,7 +53,7 @@ void
_gsl_init_data_caches (void)
{
static gboolean initialized = FALSE;
- assert (initialized == FALSE);
+ assert_return (initialized == FALSE);
initialized++;
RAPICORN_STATIC_ASSERT (AGE_EPSILON < LOW_PERSISTENCY_RESIDENT_SET);
}
@@ -66,7 +66,7 @@ gsl_data_cache_new (GslDataHandle *dhandle,
assert_return (dhandle != NULL, NULL);
assert_return (padding > 0, NULL);
assert_return (dhandle->name != NULL, NULL);
- assert (node_size == sfi_alloc_upper_power2 (node_size));
+ assert_return (node_size == sfi_alloc_upper_power2 (node_size), NULL);
assert_return (padding < node_size / 2, NULL);
/* allocate new closed dcache if necessary */
dcache = sfi_new_struct (GslDataCache, 1);
@@ -468,7 +468,7 @@ gsl_data_cache_unref_node (GslDataCache *dcache,
assert_return (node->ref_count > 0);
dcache->mutex.lock();
node_p = data_cache_lookup_nextmost_node_L (dcache, node->offset);
- assert (node_p && *node_p == node); /* paranoid check lookup, yeah! */
+ assert_return (node_p && *node_p == node); /* paranoid check lookup, yeah! */
node->ref_count -= 1;
check_cache = !node->ref_count;
if (!node->ref_count &&
diff --git a/bse/gsldatahandle-mad.cc b/bse/gsldatahandle-mad.cc
index c626c32..5eba61a 100644
--- a/bse/gsldatahandle-mad.cc
+++ b/bse/gsldatahandle-mad.cc
@@ -464,7 +464,7 @@ dh_mad_read (GslDataHandle *dhandle,
/* suckage, need to do lengthy seek in file */
tmp = dh_mad_coarse_seek (dhandle, voffset);
- assert (tmp <= voffset);
+ assert_return (tmp <= voffset, 0);
}
while (pos >= handle->pcm_pos + handle->pcm_length)
diff --git a/bse/gsldatahandle-vorbis.cc b/bse/gsldatahandle-vorbis.cc
index 76a7d6c..06b7cc7 100644
--- a/bse/gsldatahandle-vorbis.cc
+++ b/bse/gsldatahandle-vorbis.cc
@@ -305,7 +305,7 @@ dh_vorbis_read (GslDataHandle *dhandle,
/* suckage, needs to seek in file, this takes ages */
tmp = dh_vorbis_coarse_seek (dhandle, voffset);
- assert (tmp <= voffset);
+ assert_return (tmp <= voffset, 0);
}
while (pos >= vhandle->pcm_pos + vhandle->pcm_length)
diff --git a/bse/gsldatahandle.cc b/bse/gsldatahandle.cc
index 06525ff..1c8ea03 100644
--- a/bse/gsldatahandle.cc
+++ b/bse/gsldatahandle.cc
@@ -722,7 +722,7 @@ reverse_handle_read (GslDataHandle *dhandle,
int64 left, new_offset = dhandle->setup.n_values - (voffset + n_values);
gfloat *t, *p = values;
- assert (new_offset >= 0);
+ assert_return (new_offset >= 0, 0);
left = n_values;
do
@@ -1598,7 +1598,7 @@ wave_handle_read (GslDataHandle *dhandle,
break;
default:
l = -1;
- assert_unreached ();
+ assert_return_unreached (l);
}
return l;
diff --git a/bse/gsldatautils.cc b/bse/gsldatautils.cc
index 7d61b26..1185cab 100644
--- a/bse/gsldatautils.cc
+++ b/bse/gsldatautils.cc
@@ -522,7 +522,7 @@ tailmatch_score_loop (GslDataHandle *shandle,
gfloat v1[GSL_DATA_HANDLE_PEEK_BUFFER], v2[GSL_DATA_HANDLE_PEEK_BUFFER];
gdouble score = 0;
- assert (start < length);
+ assert_return (start < length, 0);
for (l = start; l < length; )
{
@@ -530,7 +530,7 @@ tailmatch_score_loop (GslDataHandle *shandle,
b = gsl_data_handle_read (shandle, l, b, v1);
b = gsl_data_handle_read (dhandle, l, b, v2);
- assert (b >= 1); // FIXME
+ assert_return (b >= 1, 0); // FIXME
l += b;
while (b--)
@@ -785,7 +785,7 @@ gsl_data_clip_sample (GslDataHandle *dhandle,
return result->error;
}
SfiNum tail = gsl_data_find_sample (dhandle, +cconfig->threshold, -cconfig->threshold, -1, -1);
- assert (tail >= 0);
+ assert_return (tail >= 0, Bse::Error::INTERNAL);
/* verify silence detection */
if (last_value - tail < cconfig->tail_samples)
diff --git a/bse/gslfilehash.cc b/bse/gslfilehash.cc
index f24c327..9dc2658 100644
--- a/bse/gslfilehash.cc
+++ b/bse/gslfilehash.cc
@@ -39,7 +39,7 @@ hfile_equals (gconstpointer key1,
void
_gsl_init_fd_pool (void)
{
- assert (hfile_ht == NULL);
+ assert_return (hfile_ht == NULL);
hfile_ht = g_hash_table_new (hfile_hash, hfile_equals);
}
static gboolean
diff --git a/bse/gslfilter.cc b/bse/gslfilter.cc
index 7f74716..bcb668f 100644
--- a/bse/gslfilter.cc
+++ b/bse/gslfilter.cc
@@ -787,12 +787,8 @@ gsl_filter_tscheb1_test (uint iorder,
}
iorder /= 2;
- /* assert roots found */
- if (!(r - roots == iorder))
- {
- printout ("ERROR: n_roots=%u != iorder=%u\n", r - roots, iorder);
- abort ();
- }
+ /* assume we have found roots */
+ assert_return (r - roots == iorder);
/* s => z */
for (i = 0; i < iorder; i++)
@@ -1167,7 +1163,7 @@ gsl_biquad_filter_config (GslBiquadFilter *f,
f->yc1 = -f->yc1;
break;
default:
- assert_unreached ();
+ assert_return_unreached ();
}
c->dirty = FALSE;
}
diff --git a/bse/gslmagic.cc b/bse/gslmagic.cc
index 12bd56b..0b5b6bc 100644
--- a/bse/gslmagic.cc
+++ b/bse/gslmagic.cc
@@ -611,7 +611,7 @@ magic_read_data (BFile *bfile, GslRealMagic *magic, MagicData *data)
data->v_int32 = (signed) uint8;
}
else
- assert_unreached ();
+ assert_return_unreached (FALSE);
}
return TRUE;
diff --git a/bse/gslvorbis-enc.cc b/bse/gslvorbis-enc.cc
index 68c06fc..249e5b8 100644
--- a/bse/gslvorbis-enc.cc
+++ b/bse/gslvorbis-enc.cc
@@ -302,7 +302,7 @@ vorbis_encoder_write_pcm_1k (GslVorbisEncoder *self,
/* the vorbis encoding engine has a bug that produces junk at
* certain block sizes beyond 1024
*/
- assert (n_values <= 1024);
+ assert_return (n_values <= 1024);
/* people passing in non-channel-aligned data get what they deserve */
n_values /= self->n_channels;
diff --git a/bse/gslwavechunk.cc b/bse/gslwavechunk.cc
index 8ddc68e..6e988fc 100644
--- a/bse/gslwavechunk.cc
+++ b/bse/gslwavechunk.cc
@@ -460,7 +460,7 @@ gsl_wave_chunk_use_block (GslWaveChunk *wchunk,
reverse = FALSE;
block->length = (iter.ubound - iter.rel_pos) / wchunk->n_channels;
block->length *= wchunk->n_channels;
- assert (block->length <= STATIC_ZERO_SIZE - 2 * wchunk->n_pad_values);
+ assert_return (block->length <= STATIC_ZERO_SIZE - 2 * wchunk->n_pad_values);
block->start = static_zero_block + iter.rel_pos;
}
else
@@ -510,7 +510,7 @@ gsl_wave_chunk_use_block (GslWaveChunk *wchunk,
block->dirstride = +wchunk->n_channels;
block->end = block->start + block->length;
}
- assert (block->length > 0);
+ assert_return (block->length > 0);
/* we might want to partly reset this at some point to implement
* truely infinite loops
*/
diff --git a/bse/gslwaveosc.cc b/bse/gslwaveosc.cc
index 9ebd1c9..1d9a40d 100644
--- a/bse/gslwaveosc.cc
+++ b/bse/gslwaveosc.cc
@@ -189,7 +189,7 @@ gsl_wave_osc_process (GslWaveOscData *wosc,
wosc_process_sfme (wosc, n_values, freq_in, mod_in, sync_in, mono_out);
break;
default:
- assert_unreached ();
+ assert_return_unreached (FALSE);
}
if (wosc->y[0] != 0.0 &&
!(fabs (wosc->y[0]) > BSE_SIGNAL_EPSILON && fabs (wosc->y[0]) < BSE_SIGNAL_KAPPA))
@@ -205,8 +205,8 @@ gsl_wave_osc_process (GslWaveOscData *wosc,
wosc->y[i] = 0.0;
}
}
- assert (!BSE_DOUBLE_IS_NANINF (wosc->y[0]));
- assert (!BSE_DOUBLE_IS_SUBNORMAL (wosc->y[0]));
+ assert_return (!BSE_DOUBLE_IS_NANINF (wosc->y[0]), FALSE);
+ assert_return (!BSE_DOUBLE_IS_SUBNORMAL (wosc->y[0]), FALSE);
wosc->done = (wosc->block.is_silent && /* FIXME, let filter state run out? */
((wosc->block.play_dir < 0 && wosc->block.offset < 0) ||
@@ -370,7 +370,7 @@ gsl_wave_osc_init (GslWaveOscData *wosc)
{
assert_return (wosc != NULL);
- assert (GSL_WAVE_OSC_FILTER_ORDER <= BSE_CONFIG (wave_chunk_padding));
+ assert_return (GSL_WAVE_OSC_FILTER_ORDER <= BSE_CONFIG (wave_chunk_padding));
memset (wosc, 0, sizeof (GslWaveOscData));
wosc->mix_freq = bse_engine_sample_freq ();
diff --git a/bse/tests/blocktests.cc b/bse/tests/blocktests.cc
index 92d88de..c00c82a 100644
--- a/bse/tests/blocktests.cc
+++ b/bse/tests/blocktests.cc
@@ -332,8 +332,8 @@ bench_range (void)
};
Rapicorn::Test::Timer timer (MAX_SECONDS);
const double bench_time = timer.benchmark (loop);
- assert (min_value == correct_min_value);
- assert (max_value == correct_max_value);
+ assert_return (min_value == correct_min_value);
+ assert_return (max_value == correct_max_value);
TPASS ("Block::range # timing: fastest=%fs throughput=%.1fMB/s\n", bench_time, bytes_per_loop /
bench_time / 1048576.);
}
@@ -373,8 +373,8 @@ bench_range_and_square_sum (void)
};
Rapicorn::Test::Timer timer (MAX_SECONDS);
const double bench_time = timer.benchmark (loop);
- assert (min_value == correct_min_value);
- assert (max_value == correct_max_value);
+ assert_return (min_value == correct_min_value);
+ assert_return (max_value == correct_max_value);
TPASS ("Block::range+sumĀ² # timing: fastest=%fs throughput=%.1fMB/s\n", bench_time, bytes_per_loop /
bench_time / 1048576.);
}
@@ -406,7 +406,7 @@ int
main (int argc,
char *argv[])
{
- // usually we'd call bse_init_test() here, but we have tests to rnu before plugins are loaded
+ // usually we'd call bse_init_test() here, but we have tests to run before plugins are loaded
Rapicorn::init_core_test (RAPICORN_PRETTY_FILE, &argc, argv);
Rapicorn::StringVector sv = Rapicorn::string_split (Rapicorn::cpu_info(), " ");
Rapicorn::String machine = sv.size() >= 2 ? sv[1] : "Unknown";
@@ -416,6 +416,7 @@ main (int argc,
TASSERT (Bse::Block::default_singleton() == Bse::Block::current_singleton());
TDONE();
run_tests(); /* run tests on FPU */
+ Bse::assertion_failed_hook (NULL); // hack to allow test reinitialization
/* load plugins */
bse_init_test (&argc, argv, Bse::cstrings_to_vector ("load-core-plugins=1", NULL));
/* check for possible specialization */
diff --git a/bse/tests/filtertest.cc b/bse/tests/filtertest.cc
index e4323a3..eef3177 100644
--- a/bse/tests/filtertest.cc
+++ b/bse/tests/filtertest.cc
@@ -278,7 +278,7 @@ butterwoth_tests ()
BseIIRFilterDesign fdes;
BseIIRFilterRequest req = { BseIIRFilterKind (0), };
req.kind = BSE_IIR_FILTER_BUTTERWORTH;
- Test::set_assertion_hook ([&] () { print_filter_on_abort (req, fdes); });
+ Bse::assertion_failed_hook ([&] () { print_filter_on_abort (req, fdes); });
TOK();
{
req.type = BSE_IIR_FILTER_LOW_PASS;
@@ -341,7 +341,7 @@ butterwoth_tests ()
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -3.0103, 1000, 4000, -77, 1500, 3500);
}
- Test::set_assertion_hook (NULL);
+ Bse::assertion_failed_hook (NULL);
TOK();
TDONE();
}
@@ -354,7 +354,7 @@ chebychev1_tests ()
BseIIRFilterDesign fdes;
BseIIRFilterRequest req = { BseIIRFilterKind (0), };
req.kind = BSE_IIR_FILTER_CHEBYSHEV1;
- Test::set_assertion_hook ([&] () { print_filter_on_abort (req, fdes); });
+ Bse::assertion_failed_hook ([&] () { print_filter_on_abort (req, fdes); });
const double gaineps = 1e-7;
TOK();
{
@@ -417,7 +417,7 @@ chebychev1_tests ()
if (0)
exit_with_iir_filter_gnuplot (&req, &fdes, "tmpfilter", -1.001, 8000, 12000, -78, 8500, 11500);
}
- Test::set_assertion_hook (NULL);
+ Bse::assertion_failed_hook (NULL);
TOK();
TDONE();
}
@@ -696,7 +696,7 @@ generic_filter_tests (const char *test_name,
{
const BseIIRFilterRequest *req = filters[i].filter_request;
BseIIRFilterDesign fdes;
- Test::set_assertion_hook ([&] () { print_filter_on_abort (*req, fdes); });
+ Bse::assertion_failed_hook ([&] () { print_filter_on_abort (*req, fdes); });
bool success = bse_iir_filter_design (req, &fdes);
TASSERT (success == true);
if (filters[i].zeros)
@@ -770,8 +770,8 @@ generic_filter_tests (const char *test_name,
}
if (i % tick_count == 0)
TOK();
+ Bse::assertion_failed_hook (NULL);
}
- Test::set_assertion_hook (NULL);
TDONE();
}
@@ -780,6 +780,7 @@ main (int argc,
char **argv)
{
bse_init_test (&argc, argv);
+ Bse::assertion_failed_hook (NULL);
butterwoth_tests ();
chebychev1_tests ();
test_problem_candidates ();
diff --git a/bse/tests/firhandle.cc b/bse/tests/firhandle.cc
index 289432d..d4a04c8 100644
--- a/bse/tests/firhandle.cc
+++ b/bse/tests/firhandle.cc
@@ -27,11 +27,11 @@ read_through (GslDataHandle *handle)
// we don't use 1024 here, because we know that it is the FIR handle internal buffer size
gfloat values[700];
int64 values_read = gsl_data_handle_read (handle, offset, 700, values);
- assert (values_read > 0);
+ assert_return (values_read > 0);
offset += values_read;
}
- assert (offset == n_values);
+ assert_return (offset == n_values);
}
static double
@@ -56,10 +56,10 @@ band_min (const vector<double>& scanned_freq,
double start_freq,
double end_freq)
{
- assert (scanned_freq.size() == scanned_values.size());
+ double min_value = 1e19;
+ assert_return (scanned_freq.size() == scanned_values.size(), min_value);
bool init = false;
- double min_value = 1e19;
for (size_t i = 0; i < scanned_values.size(); i++)
{
if (scanned_freq[i] >= start_freq && scanned_freq[i] <= end_freq)
@@ -73,7 +73,7 @@ band_min (const vector<double>& scanned_freq,
}
}
}
- assert (init);
+ assert_return (init, min_value);
return min_value;
}
@@ -83,10 +83,10 @@ band_max (const vector<double>& scanned_freq,
double start_freq,
double end_freq)
{
- assert (scanned_freq.size() == scanned_values.size());
+ double max_value = -1e19;
+ assert_return (scanned_freq.size() == scanned_values.size(), max_value);
bool init = false;
- double max_value = -1e19;
for (size_t i = 0; i < scanned_values.size(); i++)
{
if (scanned_freq[i] >= start_freq && scanned_freq[i] <= end_freq)
@@ -100,7 +100,7 @@ band_max (const vector<double>& scanned_freq,
}
}
}
- assert (init);
+ assert_return (init, max_value);
return max_value;
}
@@ -117,7 +117,7 @@ handle_name (FirHandleType type)
{
case FIR_HIGHPASS: return "Highpass";
case FIR_LOWPASS: return "Lowpass";
- default: assert_unreached();
+ default: assert_return_unreached (NULL);
}
}
diff --git a/bse/tests/resamplehandle.cc b/bse/tests/resamplehandle.cc
index 64ea808..3413418 100644
--- a/bse/tests/resamplehandle.cc
+++ b/bse/tests/resamplehandle.cc
@@ -27,11 +27,11 @@ read_through (GslDataHandle *handle)
{
gfloat values[1024];
int64 values_read = gsl_data_handle_read (handle, offset, 1024, values);
- assert (values_read > 0);
+ assert_return (values_read > 0);
offset += values_read;
}
- assert (offset == n_values);
+ assert_return (offset == n_values);
}
static void
@@ -324,7 +324,7 @@ test_delay_compensation (const char *run_type)
if (j % 2)
{
/* implement half a output sample delay (for downsampling only) */
- assert (params[p].mode == BSE_RESAMPLER2_MODE_DOWNSAMPLE);
+ assert_return (params[p].mode == BSE_RESAMPLER2_MODE_DOWNSAMPLE);
i++;
j += 2;
}
@@ -467,6 +467,7 @@ main (int argc,
test_state_length ("FPU");
run_tests ("FPU");
/* load plugins */
+ Bse::assertion_failed_hook (NULL); // hack to allow test reinitialization
bse_init_test (&argc, argv, Bse::cstrings_to_vector ("load-core-plugins=1", NULL));
/* check for possible specialization */
if (Bse::Block::default_singleton() == Bse::Block::current_singleton())
diff --git a/bse/tests/subnormals.cc b/bse/tests/subnormals.cc
index 9eaa1fa..77e5841 100644
--- a/bse/tests/subnormals.cc
+++ b/bse/tests/subnormals.cc
@@ -36,11 +36,11 @@ test_correct_subnormal_elimination (const char* algo_name)
for (int i = 1; i < n; i++)
{
float value = BSE_FLOAT_MAX_SUBNORMAL * i / n;
- assert (BSE_FLOAT_IS_SUBNORMAL (value));
+ assert_return (BSE_FLOAT_IS_SUBNORMAL (value));
float normalized_positive_value = Func (value);
- assert (!BSE_FLOAT_IS_SUBNORMAL (normalized_positive_value));
+ assert_return (!BSE_FLOAT_IS_SUBNORMAL (normalized_positive_value));
float normalized_negative_value = Func (-value);
- assert (!BSE_FLOAT_IS_SUBNORMAL (normalized_negative_value));
+ assert_return (!BSE_FLOAT_IS_SUBNORMAL (normalized_negative_value));
if (i % 100000 == 0)
TOK();
}
@@ -55,11 +55,11 @@ test_correct_subnormal_elimination (const char* algo_name)
for (int i = 1; i < n; i++)
{
double value = BSE_DOUBLE_MAX_SUBNORMAL * i / n;
- assert (BSE_DOUBLE_IS_SUBNORMAL (value));
+ assert_return (BSE_DOUBLE_IS_SUBNORMAL (value));
double normalized_positive_value = Func (value);
- assert (!BSE_DOUBLE_IS_SUBNORMAL (normalized_positive_value));
+ assert_return (!BSE_DOUBLE_IS_SUBNORMAL (normalized_positive_value));
double normalized_negative_value = Func (-value);
- assert (!BSE_DOUBLE_IS_SUBNORMAL (normalized_negative_value));
+ assert_return (!BSE_DOUBLE_IS_SUBNORMAL (normalized_negative_value));
if (i % 100000 == 0)
TOK();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]