mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
cpu: add force cpu flags
Use PIPEWIRE_CPU to force cpu flags.
This commit is contained in:
parent
1ca7704d64
commit
9573b24e52
3 changed files with 23 additions and 0 deletions
|
|
@ -66,6 +66,7 @@ extern "C" {
|
|||
#define SPA_CPU_FLAG_NEON (1 << 5)
|
||||
#define SPA_CPU_FLAG_ARMV8 (1 << 6)
|
||||
|
||||
#define SPA_CPU_FORCE_AUTODETECT ((uint32_t)-1)
|
||||
/**
|
||||
* The CPU features interface
|
||||
*/
|
||||
|
|
@ -82,6 +83,9 @@ struct spa_cpu {
|
|||
/** get CPU flags */
|
||||
uint32_t (*get_flags) (struct spa_cpu *cpu);
|
||||
|
||||
/** force CPU flags, use SPA_CPU_FORCE_AUTODETECT to autodetect CPU flags */
|
||||
int (*force_flags) (struct spa_cpu *cpu, uint32_t flags);
|
||||
|
||||
/** get number of CPU cores */
|
||||
uint32_t (*get_count) (struct spa_cpu *cpu);
|
||||
|
||||
|
|
@ -90,6 +94,7 @@ struct spa_cpu {
|
|||
};
|
||||
|
||||
#define spa_cpu_get_flags(c) (c)->get_flags((c))
|
||||
#define spa_cpu_force_flags(c,f) (c)->force_flags((c), (f))
|
||||
#define spa_cpu_get_count(c) (c)->get_count((c))
|
||||
#define spa_cpu_get_max_align(c) (c)->get_max_align((c))
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ struct impl {
|
|||
struct spa_log *log;
|
||||
|
||||
uint32_t flags;
|
||||
uint32_t force;
|
||||
uint32_t count;
|
||||
uint32_t max_align;
|
||||
};
|
||||
|
|
@ -58,9 +59,19 @@ static uint32_t
|
|||
impl_cpu_get_flags(struct spa_cpu *cpu)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(cpu, struct impl, cpu);
|
||||
if (impl->force != SPA_CPU_FORCE_AUTODETECT)
|
||||
return impl->force;
|
||||
return impl->flags;
|
||||
}
|
||||
|
||||
static int
|
||||
impl_cpu_force_flags(struct spa_cpu *cpu, uint32_t flags)
|
||||
{
|
||||
struct impl *impl = SPA_CONTAINER_OF(cpu, struct impl, cpu);
|
||||
impl->force = flags;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t get_count(struct impl *this)
|
||||
{
|
||||
cpu_set_t cpuset;
|
||||
|
|
@ -88,6 +99,7 @@ static const struct spa_cpu impl_cpu = {
|
|||
SPA_VERSION_CPU,
|
||||
NULL,
|
||||
impl_cpu_get_flags,
|
||||
impl_cpu_force_flags,
|
||||
impl_cpu_get_count,
|
||||
impl_cpu_get_max_align,
|
||||
};
|
||||
|
|
@ -146,6 +158,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this->log = support[i].data;
|
||||
}
|
||||
this->flags = 0;
|
||||
this->force = SPA_CPU_FORCE_AUTODETECT;
|
||||
this->max_align = 16;
|
||||
this->count = get_count(this);
|
||||
init(this);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include <dlfcn.h>
|
||||
|
||||
#include <spa/support/dbus.h>
|
||||
#include <spa/support/cpu.h>
|
||||
|
||||
#include "pipewire.h"
|
||||
#include "private.h"
|
||||
|
|
@ -445,6 +446,10 @@ void pw_init(int *argc, char **argv[])
|
|||
iface = load_interface(plugin, "cpu", SPA_TYPE_INTERFACE_CPU, &info,
|
||||
support->n_support, support->support);
|
||||
if (iface != NULL) {
|
||||
struct spa_cpu *cpu = iface->iface;
|
||||
if ((str = getenv("PIPEWIRE_CPU")))
|
||||
spa_cpu_force_flags(cpu, strtoul(str, NULL, 0));
|
||||
|
||||
support->support[support->n_support++] =
|
||||
SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_CPU, iface->iface);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue