diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2014-08-05 08:19:25 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2014-08-25 21:20:32 +0200 |
commit | e2ce8e9a5c5a574747db7741626d71652e24b21e (patch) | |
tree | d3cce352a3b5ee2aafa086843380a5667d2711e7 | |
parent | a77d1950e3593a20aa1dd1d36af177867a90d46b (diff) |
gr-fosphor: Prevent multiple thread from initializing fosphor in parallell
Although in theory there is nothing wrong with this and fosphor itself
should support it. However it seems some OpenCL implementation don't
really like having multiple context created in parallell, so we prevent
this manually here.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r-- | lib/base_sink_c_impl.cc | 14 | ||||
-rw-r--r-- | lib/base_sink_c_impl.h | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/base_sink_c_impl.cc b/lib/base_sink_c_impl.cc index 6d0dcb6..035f6e5 100644 --- a/lib/base_sink_c_impl.cc +++ b/lib/base_sink_c_impl.cc @@ -49,6 +49,8 @@ base_sink_c::base_sink_c(const char *name) } +gr::thread::mutex base_sink_c_impl::s_boot_mutex; + const int base_sink_c_impl::k_db_per_div[] = {1, 2, 5, 10, 20}; @@ -84,9 +86,15 @@ void base_sink_c_impl::worker() this->glctx_init(); /* Init fosphor */ - this->d_fosphor = fosphor_init(); - if (!this->d_fosphor) - return; + { + /* (prevent // init of multiple instance to be gentle on the OpenCL + * implementations that don't like this) */ + gr::thread::scoped_lock guard(s_boot_mutex); + + this->d_fosphor = fosphor_init(); + if (!this->d_fosphor) + return; + } this->settings_apply(~SETTING_DIMENSIONS); diff --git a/lib/base_sink_c_impl.h b/lib/base_sink_c_impl.h index b12764f..fbce636 100644 --- a/lib/base_sink_c_impl.h +++ b/lib/base_sink_c_impl.h @@ -60,6 +60,8 @@ namespace gr { void render(); + static gr::thread::mutex s_boot_mutex; + /* settings refresh logic */ enum { SETTING_DIMENSIONS = (1 << 0), |