diff --git a/spa/plugins/audioconvert/channelmix-ops.c b/spa/plugins/audioconvert/channelmix-ops.c index 6241aef17..0d18c323f 100644 --- a/spa/plugins/audioconvert/channelmix-ops.c +++ b/spa/plugins/audioconvert/channelmix-ops.c @@ -25,6 +25,7 @@ #include #include +#include #include #define VOLUME_MIN 0.0f @@ -423,8 +424,7 @@ static const struct channelmix_info { uint64_t dst_mask; channelmix_func_t func; -#define FEATURE_SSE (1<<0) -#define FEATURE_DEFAULT FEATURE_SSE +#define FEATURE_SSE SPA_CPU_FLAG_SSE uint32_t features; } channelmix_table[] = { diff --git a/spa/plugins/audioconvert/channelmix.c b/spa/plugins/audioconvert/channelmix.c index 1c2e2ec30..7fd12fee4 100644 --- a/spa/plugins/audioconvert/channelmix.c +++ b/spa/plugins/audioconvert/channelmix.c @@ -94,6 +94,7 @@ struct impl { struct spa_node node; struct spa_log *log; + struct spa_cpu *cpu; struct props props; @@ -105,6 +106,7 @@ struct impl { bool started; + uint32_t cpu_flags; channelmix_func_t convert; uint32_t n_matrix; float matrix[4096]; @@ -430,10 +432,12 @@ static int setup_convert(struct impl *this, return -EINVAL; /* find convert function */ - if ((chanmix_info = find_channelmix_info(src_chan, src_mask, dst_chan, dst_mask, FEATURE_DEFAULT)) == NULL) + if ((chanmix_info = find_channelmix_info(src_chan, src_mask, + dst_chan, dst_mask, this->cpu_flags)) == NULL) return -ENOTSUP; - spa_log_info(this->log, NAME " %p: got channelmix features %08x", this, chanmix_info->features); + spa_log_info(this->log, NAME " %p: got channelmix features %08x:%08x", + this, this->cpu_flags, chanmix_info->features); this->convert = chanmix_info->func; @@ -1255,10 +1259,19 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; 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; + case SPA_TYPE_INTERFACE_CPU: + this->cpu = support[i].data; + break; + } } + if (this->cpu) + this->cpu_flags = spa_cpu_get_flags(this->cpu); + this->node = impl_node; port = GET_OUT_PORT(this, 0); diff --git a/spa/plugins/audioconvert/fmt-ops.c b/spa/plugins/audioconvert/fmt-ops.c index d1be443c4..f9b732d35 100644 --- a/spa/plugins/audioconvert/fmt-ops.c +++ b/spa/plugins/audioconvert/fmt-ops.c @@ -25,6 +25,7 @@ #include #include +#include #include #define U8_MIN 0 @@ -677,9 +678,7 @@ typedef void (*convert_func_t) (void *data, int n_dst, void *dst[n_dst], static const struct conv_info { uint32_t src_fmt; uint32_t dst_fmt; -#define FEATURE_SSE (1<<0) -#define FEATURE_SSE2 (1<<1) -#define FEATURE_DEFAULT FEATURE_SSE +#define FEATURE_SSE SPA_CPU_FLAG_SSE uint32_t features; convert_func_t func; diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index cd3193869..80e6320b7 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -98,6 +99,7 @@ struct impl { struct spa_node node; struct spa_log *log; + struct spa_cpu *cpu; struct props props; @@ -110,6 +112,7 @@ struct impl { bool started; + uint32_t cpu_flags; convert_func_t convert; float empty[4096]; @@ -173,12 +176,12 @@ static int setup_convert(struct impl *this) } /* find fast path */ - conv = find_conv_info(src_fmt, dst_fmt, FEATURE_DEFAULT); + conv = find_conv_info(src_fmt, dst_fmt, this->cpu_flags); if (conv == NULL) return -ENOTSUP; - spa_log_info(this->log, NAME " %p: got converter features %08x", this, - conv->features); + spa_log_info(this->log, NAME " %p: got converter features %08x:%08x", this, + this->cpu_flags, conv->features); this->convert = conv->func; return 0; @@ -973,11 +976,20 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; 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; + case SPA_TYPE_INTERFACE_CPU: + this->cpu = support[i].data; + break; + } } this->node = impl_node; + if (this->cpu) + this->cpu_flags = spa_cpu_get_flags(this->cpu); + init_port(this, SPA_DIRECTION_OUTPUT, 0, SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS); init_port(this, SPA_DIRECTION_INPUT, 0, SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS); diff --git a/spa/plugins/audioconvert/merger.c b/spa/plugins/audioconvert/merger.c index 48db7ac77..f72697c0d 100644 --- a/spa/plugins/audioconvert/merger.c +++ b/spa/plugins/audioconvert/merger.c @@ -82,6 +82,7 @@ struct impl { struct spa_node node; struct spa_log *log; + struct spa_cpu *cpu; const struct spa_node_callbacks *callbacks; void *user_data; @@ -92,6 +93,7 @@ struct impl { int monitor_count; bool started; + uint32_t cpu_flags; convert_func_t convert; bool monitor; @@ -576,10 +578,10 @@ static int setup_convert(struct impl *this) outport->format.info.raw.channels, outport->format.info.raw.rate); - conv = find_conv_info(src_fmt, dst_fmt, FEATURE_DEFAULT); + conv = find_conv_info(src_fmt, dst_fmt, this->cpu_flags); if (conv != NULL) { - spa_log_info(this->log, NAME " %p: got converter features %08x", this, - conv->features); + spa_log_info(this->log, NAME " %p: got converter features %08x:%08x", this, + this->cpu_flags, conv->features); this->convert = conv->func; return 0; @@ -1063,10 +1065,19 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; 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; + case SPA_TYPE_INTERFACE_CPU: + this->cpu = support[i].data; + break; + } } + if (this->cpu) + this->cpu_flags = spa_cpu_get_flags(this->cpu); + if (info != NULL && (str = spa_dict_lookup(info, "merger.monitor")) != NULL) this->monitor = atoi(str); diff --git a/spa/plugins/audioconvert/splitter.c b/spa/plugins/audioconvert/splitter.c index 54c539856..19ec845ef 100644 --- a/spa/plugins/audioconvert/splitter.c +++ b/spa/plugins/audioconvert/splitter.c @@ -83,6 +83,7 @@ struct impl { struct spa_node node; struct spa_log *log; + struct spa_cpu *cpu; const struct spa_node_callbacks *callbacks; void *user_data; @@ -92,6 +93,7 @@ struct impl { int port_count; bool started; + uint32_t cpu_flags; convert_func_t convert; bool have_profile; @@ -569,10 +571,10 @@ static int setup_convert(struct impl *this) inport->format.info.raw.rate, this->port_count); - conv = find_conv_info(src_fmt, dst_fmt, FEATURE_DEFAULT); + conv = find_conv_info(src_fmt, dst_fmt, this->cpu_flags); if (conv != NULL) { - spa_log_info(this->log, NAME " %p: got converter features %08x", this, - conv->features); + spa_log_info(this->log, NAME " %p: got converter features %08x:%08x", this, + this->cpu_flags, conv->features); this->convert = conv->func; return 0; @@ -1006,9 +1008,17 @@ impl_init(const struct spa_handle_factory *factory, this = (struct impl *) handle; 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; + case SPA_TYPE_INTERFACE_CPU: + this->cpu = support[i].data; + break; + } } + if (this->cpu) + this->cpu_flags = spa_cpu_get_flags(this->cpu); this->node = impl_node;