From 3f5c75c52d26c59831ea4267d923ae281b2db3f8 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 6 Jun 2019 15:11:37 +0200 Subject: [PATCH] cpu: add CPU_FORCE option to cpu interface --- spa/include/spa/support/cpu.h | 3 +++ spa/plugins/support/cpu.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/spa/include/spa/support/cpu.h b/spa/include/spa/support/cpu.h index e36189c3c..21328661a 100644 --- a/spa/include/spa/support/cpu.h +++ b/spa/include/spa/support/cpu.h @@ -114,6 +114,9 @@ struct spa_cpu_methods { #define spa_cpu_get_count(c) spa_cpu_method(c, get_count, 0) #define spa_cpu_get_max_align(c) spa_cpu_method(c, get_max_align, 0) +/** keys can be given when initializing the cpu handle */ +#define SPA_KEY_CPU_FORCE "cpu.force" /**< force cpu flags */ + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/plugins/support/cpu.c b/spa/plugins/support/cpu.c index a32179105..c6ca7ba70 100644 --- a/spa/plugins/support/cpu.c +++ b/spa/plugins/support/cpu.c @@ -142,6 +142,7 @@ impl_init(const struct spa_handle_factory *factory, uint32_t n_support) { struct impl *this; + const char *str; uint32_t i; spa_return_val_if_fail(factory != NULL, -EINVAL); @@ -158,8 +159,11 @@ impl_init(const struct spa_handle_factory *factory, &impl_cpu, this); for (i = 0; i < n_support; i++) { - if (support[i].type == SPA_TYPE_INTERFACE_Log) + switch (support[i].type) { + case SPA_TYPE_INTERFACE_Log: this->log = support[i].data; + break; + } } this->flags = 0; this->force = SPA_CPU_FORCE_AUTODETECT; @@ -167,6 +171,11 @@ impl_init(const struct spa_handle_factory *factory, this->count = get_count(this); init(this); + if (info) { + if ((str = spa_dict_lookup(info, SPA_KEY_CPU_FORCE)) != NULL) + this->flags = atoi(str); + } + spa_log_debug(this->log, NAME " %p: count:%d align:%d flags:%08x", this, this->count, this->max_align, this->flags);