[beast: 17/43] BSE: avoid g_error in library code
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 17/43] BSE: avoid g_error in library code
- Date: Mon, 26 Jun 2017 23:28:44 +0000 (UTC)
commit 9093e85d5a6e6ae262c9ceff8eeb984df0aec94a
Author: Tim Janik <timj gnu org>
Date: Sun Jun 25 17:22:08 2017 +0200
BSE: avoid g_error in library code
Signed-off-by: Tim Janik <timj gnu org>
bse/bseengine.cc | 22 +++++++++++-----------
bse/bseenginemaster.cc | 7 +++++--
bse/bseengineschedule.cc | 5 +----
bse/bseladspa.cc | 2 +-
bse/bsemain.cc | 10 ++++++++--
bse/bseplugin.cc | 20 +++++++++++---------
bse/bsesequencer.cc | 2 +-
bse/bseserver.cc | 8 ++++----
bse/bsesong.cc | 5 ++++-
9 files changed, 46 insertions(+), 35 deletions(-)
---
diff --git a/bse/bseengine.cc b/bse/bseengine.cc
index 239c0bd..1d8eeee 100644
--- a/bse/bseengine.cc
+++ b/bse/bseengine.cc
@@ -1438,17 +1438,17 @@ bse_engine_tick_stamp_from_systime (guint64 systime)
}
#if 0
if (tick_stamp > 158760000)
- g_error ("tick_stamp conversion problem:\n"
- " tick_stamp = %llu\n"
- " usec_systime = %llu\n"
- " current-systime = %llu\n"
- " current-tickstamp = %llu\n"
- " last-update-systime = %llu\n"
- " last-update-tickstamp = %llu\n"
- " sample-freq = %u\n",
- tick_stamp, systime, sfi_time_system (), Bse::TickStamp::get_current (),
- ustamp.system_time, ustamp.tick_stamp,
- bse_engine_sample_freq ());
+ Bse::warning ("tick_stamp conversion problem:\n"
+ " tick_stamp = %llu\n"
+ " usec_systime = %llu\n"
+ " current-systime = %llu\n"
+ " current-tickstamp = %llu\n"
+ " last-update-systime = %llu\n"
+ " last-update-tickstamp = %llu\n"
+ " sample-freq = %u\n",
+ tick_stamp, systime, sfi_time_system (), Bse::TickStamp::get_current (),
+ ustamp.system_time, ustamp.tick_stamp,
+ bse_engine_sample_freq ());
#endif
return tick_stamp;
}
diff --git a/bse/bseenginemaster.cc b/bse/bseenginemaster.cc
index 66a198b..5be4b64 100644
--- a/bse/bseenginemaster.cc
+++ b/bse/bseenginemaster.cc
@@ -567,8 +567,11 @@ master_process_job (BseJob *job)
case ENGINE_JOB_ADD_POLL:
JOB_DEBUG ("add poll %p(%p,%u)", job->poll.poll_func, job->poll.data, job->poll.n_fds);
if (job->poll.n_fds + master_n_pollfds > BSE_ENGINE_MAX_POLLFDS)
- g_error ("adding poll job exceeds maximum number of poll-fds (%u > %u)",
- job->poll.n_fds + master_n_pollfds, BSE_ENGINE_MAX_POLLFDS);
+ {
+ Bse::warning ("adding poll job exceeds maximum number of poll-fds (%u > %u)",
+ job->poll.n_fds + master_n_pollfds, BSE_ENGINE_MAX_POLLFDS);
+ return;
+ }
poll = sfi_new_struct0 (Poll, 1);
poll->poll_func = job->poll.poll_func;
poll->data = job->poll.data;
diff --git a/bse/bseengineschedule.cc b/bse/bseengineschedule.cc
index 2f6860d..dba8424 100644
--- a/bse/bseengineschedule.cc
+++ b/bse/bseengineschedule.cc
@@ -506,10 +506,7 @@ resolve_cycle (EngineCycle *cycle,
{
if (node != cycle->last)
return FALSE;
- if (!cycle->seen_deferred_node)
- {
- g_error ("cycle without delay module: (%p)", cycle);
- }
+ assert_return (cycle->seen_deferred_node, FALSE); // cycle without delay module
*cycle_nodes_p = merge_untagged_node_lists_uniq (*cycle_nodes_p, cycle->nodes);
cycle->nodes = NULL;
cycle->last = NULL;
diff --git a/bse/bseladspa.cc b/bse/bseladspa.cc
index c79a7d6..caa18ec 100644
--- a/bse/bseladspa.cc
+++ b/bse/bseladspa.cc
@@ -95,7 +95,7 @@ ladspa_plugin_use (GTypePlugin *gplugin)
if (!error)
error = ladspa_plugin_reinit_type_ids (self, ldf);
if (error)
- g_error ("Fatal: failed to reinitialize plugin \"%s\": %s", self->fname, error);
+ Bse::warning ("Fatal: failed to reinitialize plugin \"%s\": %s", self->fname, error);
}
else
self->use_count++;
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index 5d9f030..167fd59 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -76,7 +76,10 @@ 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");
+ {
+ Bse::warning ("%s() may only be called once", "bse_init_inprocess");
+ return;
+ }
assert_return (G_BYTE_ORDER == G_LITTLE_ENDIAN || G_BYTE_ORDER == G_BIG_ENDIAN);
// main loop
@@ -284,7 +287,10 @@ _bse_glue_context_create (const char *client, const std::function<void()> &calle
AsyncData adata = { client, caller_wakeup };
// function runs in user threads and queues handler in BSE thread to create context
if (bse_initialization_stage < 2)
- g_error ("%s: called without prior %s()", __func__, "Bse::init_async");
+ {
+ Bse::warning ("%s: called without prior %s()", __func__, "Bse::init_async");
+ return NULL;
+ }
// queue handler to create context
GSource *source = g_idle_source_new ();
g_source_set_priority (source, G_PRIORITY_HIGH);
diff --git a/bse/bseplugin.cc b/bse/bseplugin.cc
index 08c4785..5bb11ca 100644
--- a/bse/bseplugin.cc
+++ b/bse/bseplugin.cc
@@ -201,8 +201,7 @@ BsePlugin*
bse_exports__add_node (const BseExportIdentity *identity,
BseExportNode *enode)
{
- if (!startup_plugin)
- g_error ("%s: plugin startup called without plugin", __func__);
+ assert_return (startup_plugin != NULL, NULL);
if (!enode || enode->next)
return NULL;
if (identity->major != BST_MAJOR_VERSION ||
@@ -260,13 +259,16 @@ bse_plugin_use (GTypePlugin *gplugin)
plugin->gmodule = g_module_open (plugin->fname, GModuleFlags (0)); /* reopen for use non-lazy */
startup_plugin = NULL;
if (!plugin->gmodule)
- g_error ("failed to reinitialize plugin \"%s\": %s", plugin->fname, g_module_error ());
+ {
+ Bse::warning ("failed to reinitialize plugin \"%s\": %s", plugin->fname, g_module_error ());
+ return;
+ }
const char *cerror = plugin_check_identity (plugin, (GModule*) plugin->gmodule);
- if (cerror)
- g_error ("failed to reinitialize plugin \"%s\": %s", plugin->fname, cerror);
- if (!plugin->chain)
- g_error ("failed to reinitialize plugin \"%s\": %s", plugin->fname, "empty plugin");
-
+ if (cerror || !plugin->chain)
+ {
+ Bse::warning ("failed to reinitialize plugin \"%s\": %s", plugin->fname, cerror ? cerror : "empty
plugin");
+ return;
+ }
bse_plugin_reinit_types (plugin);
}
else
@@ -393,7 +395,7 @@ bse_plugin_complete_info (GTypePlugin *gplugin,
break;
}
if (!node || node->type != type)
- g_error ("%s: unable to complete type from plugin: %s", plugin->fname, g_type_name (type));
+ Bse::warning ("%s: unable to complete type from plugin: %s", plugin->fname, g_type_name (type));
}
static void
diff --git a/bse/bsesequencer.cc b/bse/bsesequencer.cc
index d0cc2ab..d8613f0 100644
--- a/bse/bsesequencer.cc
+++ b/bse/bsesequencer.cc
@@ -548,7 +548,7 @@ Sequencer::Sequencer() :
poll_pool_ = new PollPool;
if (event_fd_.open() != 0)
- g_error ("failed to create sequencer wake-up pipe: %s", strerror (errno));
+ Bse::warning ("failed to create sequencer wake-up pipe: %s", strerror (errno));
}
void
diff --git a/bse/bseserver.cc b/bse/bseserver.cc
index d7bd552..28eabf4 100644
--- a/bse/bseserver.cc
+++ b/bse/bseserver.cc
@@ -36,7 +36,7 @@ enum
/* --- prototypes --- */
static void bse_server_class_init (BseServerClass *klass);
static void bse_server_init (BseServer *server);
-static void bse_server_finalize (GObject *object);
+static void bse_server_singleton_finalize (GObject *object);
static void bse_server_set_property (GObject *object,
guint param_id,
const GValue *value,
@@ -104,7 +104,7 @@ bse_server_class_init (BseServerClass *klass)
gobject_class->set_property = bse_server_set_property;
gobject_class->get_property = bse_server_get_property;
- gobject_class->finalize = bse_server_finalize;
+ gobject_class->finalize = bse_server_singleton_finalize;
item_class->set_parent = bse_server_set_parent;
@@ -211,9 +211,9 @@ bse_server_init (BseServer *self)
}
static void
-bse_server_finalize (GObject *object)
+bse_server_singleton_finalize (GObject *object)
{
- g_error ("Fatal attempt to destroy singleton BseServer");
+ assert_return_unreached();
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
diff --git a/bse/bsesong.cc b/bse/bsesong.cc
index 838abde..8998e30 100644
--- a/bse/bsesong.cc
+++ b/bse/bsesong.cc
@@ -513,7 +513,10 @@ bse_song_create_summation (BseSong *self)
{
GType type = g_type_from_name ("BseSummation");
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");
+ {
+ Bse::warning ("%s: failed to resolve %s object type, probably missing or broken plugin installation",
__func__, "BseSummation");
+ return NULL;
+ }
BseSource *summation = (BseSource*) bse_container_new_child (BSE_CONTAINER (self), type, "uname",
"Summation", NULL);
assert_return (summation != NULL, NULL);
bse_snet_intern_child (BSE_SNET (self), summation);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]