summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcamera/internal/ipa_proxy.h7
-rw-r--r--src/libcamera/ipa_proxy.cpp2
-rw-r--r--utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl9
-rw-r--r--utils/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl1
-rw-r--r--utils/ipc/generators/libcamera_templates/proxy_functions.tmpl7
5 files changed, 17 insertions, 9 deletions
diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h
index f651a3ae..9fe446c3 100644
--- a/include/libcamera/internal/ipa_proxy.h
+++ b/include/libcamera/internal/ipa_proxy.h
@@ -17,6 +17,12 @@ namespace libcamera {
class IPAModule;
+enum ProxyState {
+ ProxyStopped,
+ ProxyStopping,
+ ProxyRunning,
+};
+
class IPAProxy : public IPAInterface
{
public:
@@ -31,6 +37,7 @@ protected:
std::string resolvePath(const std::string &file) const;
bool valid_;
+ ProxyState state_;
private:
IPAModule *ipam_;
diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp
index 29c0e9e0..ec4c2cc8 100644
--- a/src/libcamera/ipa_proxy.cpp
+++ b/src/libcamera/ipa_proxy.cpp
@@ -37,7 +37,7 @@ LOG_DEFINE_CATEGORY(IPAProxy)
* \param[in] ipam The IPA module
*/
IPAProxy::IPAProxy(IPAModule *ipam)
- : valid_(false), ipam_(ipam)
+ : valid_(false), state_(ProxyStopped), ipam_(ipam)
{
}
diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
index e3b541db..dc674815 100644
--- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
+++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl
@@ -45,8 +45,7 @@ namespace {{ns}} {
{%- endif %}
{{proxy_name}}::{{proxy_name}}(IPAModule *ipam, bool isolate)
- : IPAProxy(ipam), running_(false),
- isolate_(isolate), seq_(0)
+ : IPAProxy(ipam), isolate_(isolate), seq_(0)
{
LOG(IPAProxy, Debug)
<< "initializing {{module_name}} proxy: loading IPA from "
@@ -155,7 +154,7 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data)
return {{ "_ret" if method|method_return_value != "void" }};
{%- elif method.mojom_name == "start" %}
- running_ = true;
+ state_ = ProxyRunning;
thread_.start();
{{ "return " if method|method_return_value != "void" -}}
@@ -173,7 +172,7 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data)
{%- endfor -%}
);
{% elif method|is_async %}
- ASSERT(running_);
+ ASSERT(state_ == ProxyRunning);
proxy_.invokeMethod(&ThreadProxy::{{method.mojom_name}}, ConnectionTypeQueued,
{%- for param in method|method_param_names -%}
{{param}}{{- ", " if not loop.last}}
@@ -226,7 +225,7 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data)
{% for method in interface_event.methods %}
{{proxy_funcs.func_sig(proxy_name, method, "Thread")}}
{
- ASSERT(running_);
+ ASSERT(state_ != ProxyStopped);
{{method.mojom_name}}.emit({{method.parameters|params_comma_sep}});
}
diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl
index efb09a18..017b870c 100644
--- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl
+++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl
@@ -104,7 +104,6 @@ private:
{{interface_name}} *ipa_;
};
- bool running_;
Thread thread_;
ThreadProxy proxy_;
std::unique_ptr<{{interface_name}}> ipa_;
diff --git a/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl b/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl
index 8addc2fa..ea9cc86b 100644
--- a/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl
+++ b/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl
@@ -23,9 +23,12 @@
# \brief Generate function body for IPA stop() function for thread
#}
{%- macro stop_thread_body() -%}
- if (!running_)
+ ASSERT(state_ != ProxyStopping);
+ if (state_ != ProxyRunning)
return;
+ state_ = ProxyStopping;
+
proxy_.invokeMethod(&ThreadProxy::stop, ConnectionTypeBlocking);
thread_.exit();
@@ -33,7 +36,7 @@
Thread::current()->dispatchMessages(Message::Type::InvokeMessage);
- running_ = false;
+ state_ = ProxyStopped;
{%- endmacro -%}