mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
audioconvert: use position rate as default rate
This commit is contained in:
parent
c14881fbe2
commit
f026e95585
4 changed files with 38 additions and 5 deletions
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
#define NAME "channelmix"
|
#define NAME "channelmix"
|
||||||
|
|
||||||
#define DEFAULT_RATE 44100
|
#define DEFAULT_RATE 48000
|
||||||
#define DEFAULT_CHANNELS 2
|
#define DEFAULT_CHANNELS 2
|
||||||
|
|
||||||
#define MAX_SAMPLES 8192
|
#define MAX_SAMPLES 8192
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,8 @@ struct impl {
|
||||||
struct spa_log *log;
|
struct spa_log *log;
|
||||||
struct spa_cpu *cpu;
|
struct spa_cpu *cpu;
|
||||||
|
|
||||||
|
struct spa_io_position *io_position;
|
||||||
|
|
||||||
uint64_t info_all;
|
uint64_t info_all;
|
||||||
struct spa_node_info info;
|
struct spa_node_info info;
|
||||||
struct spa_param_info params[8];
|
struct spa_param_info params[8];
|
||||||
|
|
@ -236,7 +238,20 @@ static int impl_node_enum_params(void *object, int seq,
|
||||||
|
|
||||||
static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
|
static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
|
||||||
{
|
{
|
||||||
return -ENOTSUP;
|
struct impl *this = object;
|
||||||
|
|
||||||
|
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||||
|
|
||||||
|
spa_log_debug(this->log, NAME " %p: io %d %p/%zd", this, id, data, size);
|
||||||
|
|
||||||
|
switch (id) {
|
||||||
|
case SPA_IO_Position:
|
||||||
|
this->io_position = data;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
#define NAME "resample"
|
#define NAME "resample"
|
||||||
|
|
||||||
#define DEFAULT_RATE 44100
|
#define DEFAULT_RATE 48000
|
||||||
#define DEFAULT_CHANNELS 2
|
#define DEFAULT_CHANNELS 2
|
||||||
|
|
||||||
#define MAX_SAMPLES 8192
|
#define MAX_SAMPLES 8192
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ struct impl {
|
||||||
struct spa_log *log;
|
struct spa_log *log;
|
||||||
struct spa_cpu *cpu;
|
struct spa_cpu *cpu;
|
||||||
|
|
||||||
|
struct spa_io_position *io_position;
|
||||||
|
|
||||||
uint64_t info_all;
|
uint64_t info_all;
|
||||||
struct spa_node_info info;
|
struct spa_node_info info;
|
||||||
struct spa_param_info params[8];
|
struct spa_param_info params[8];
|
||||||
|
|
@ -227,7 +229,20 @@ static int impl_node_enum_params(void *object, int seq,
|
||||||
|
|
||||||
static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
|
static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
|
||||||
{
|
{
|
||||||
return -ENOTSUP;
|
struct impl *this = object;
|
||||||
|
|
||||||
|
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||||
|
|
||||||
|
spa_log_debug(this->log, NAME " %p: io %d %p/%zd", this, id, data, size);
|
||||||
|
|
||||||
|
switch (id) {
|
||||||
|
case SPA_IO_Position:
|
||||||
|
this->io_position = data;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
||||||
|
|
@ -385,6 +400,9 @@ static int port_enum_formats(void *object,
|
||||||
SPA_PARAM_EnumFormat, &port->format.info.raw);
|
SPA_PARAM_EnumFormat, &port->format.info.raw);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
uint32_t rate = this->io_position ?
|
||||||
|
this->io_position->clock.rate.denom : DEFAULT_RATE;
|
||||||
|
|
||||||
*param = spa_pod_builder_add_object(builder,
|
*param = spa_pod_builder_add_object(builder,
|
||||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
||||||
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
||||||
|
|
@ -409,7 +427,7 @@ static int port_enum_formats(void *object,
|
||||||
SPA_AUDIO_FORMAT_U8P,
|
SPA_AUDIO_FORMAT_U8P,
|
||||||
SPA_AUDIO_FORMAT_U8),
|
SPA_AUDIO_FORMAT_U8),
|
||||||
SPA_FORMAT_AUDIO_rate, SPA_POD_CHOICE_RANGE_Int(
|
SPA_FORMAT_AUDIO_rate, SPA_POD_CHOICE_RANGE_Int(
|
||||||
DEFAULT_RATE, 1, INT32_MAX),
|
rate, 1, INT32_MAX),
|
||||||
SPA_FORMAT_AUDIO_channels, SPA_POD_CHOICE_RANGE_Int(
|
SPA_FORMAT_AUDIO_channels, SPA_POD_CHOICE_RANGE_Int(
|
||||||
DEFAULT_CHANNELS, 1, MAX_PORTS));
|
DEFAULT_CHANNELS, 1, MAX_PORTS));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue