mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
alsa: add Tag set and enum support
So that we can see the tags on the sinks and sources.
This commit is contained in:
parent
7554bdea97
commit
a9659d9dce
4 changed files with 68 additions and 4 deletions
|
|
@ -577,7 +577,16 @@ impl_node_port_enum_params(void *object, int seq,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SPA_PARAM_Tag:
|
||||||
|
switch (result.index) {
|
||||||
|
case 0: case 1:
|
||||||
|
if ((param = this->tag[result.index]) == NULL)
|
||||||
|
goto next;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
@ -703,9 +712,25 @@ impl_node_port_set_param(void *object,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPA_PARAM_Tag:
|
case SPA_PARAM_Tag:
|
||||||
if (param != NULL)
|
{
|
||||||
spa_debug_log_pod(this->log, SPA_LOG_LEVEL_DEBUG, 0, NULL, param);
|
enum spa_direction other = SPA_DIRECTION_REVERSE(direction);
|
||||||
|
if (param != NULL) {
|
||||||
|
struct spa_tag_info info;
|
||||||
|
void *state = NULL;
|
||||||
|
if (spa_tag_parse(param, &info, &state) < 0 ||
|
||||||
|
info.direction != other)
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
if (spa_tag_compare(param, this->tag[other]) != 0) {
|
||||||
|
free(this->tag[other]);
|
||||||
|
this->tag[other] = param ? spa_pod_copy(param) : NULL;
|
||||||
|
|
||||||
|
this->port_info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
|
||||||
|
this->port_params[PORT_Tag].user++;
|
||||||
|
emit_port_info(this, false);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
res = -ENOENT;
|
res = -ENOENT;
|
||||||
break;
|
break;
|
||||||
|
|
@ -957,6 +982,7 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
this->port_params[PORT_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
this->port_params[PORT_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||||
this->port_params[PORT_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
this->port_params[PORT_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||||
this->port_params[PORT_Latency] = SPA_PARAM_INFO(SPA_PARAM_Latency, SPA_PARAM_INFO_READWRITE);
|
this->port_params[PORT_Latency] = SPA_PARAM_INFO(SPA_PARAM_Latency, SPA_PARAM_INFO_READWRITE);
|
||||||
|
this->port_params[PORT_Tag] = SPA_PARAM_INFO(SPA_PARAM_Tag, SPA_PARAM_INFO_READWRITE);
|
||||||
this->port_info.params = this->port_params;
|
this->port_info.params = this->port_params;
|
||||||
this->port_info.n_params = N_PORT_PARAMS;
|
this->port_info.n_params = N_PORT_PARAMS;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -524,6 +524,16 @@ impl_node_port_enum_params(void *object, int seq,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SPA_PARAM_Tag:
|
||||||
|
switch (result.index) {
|
||||||
|
case 0: case 1:
|
||||||
|
if ((param = this->tag[result.index]) == NULL)
|
||||||
|
goto next;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
@ -636,6 +646,26 @@ impl_node_port_set_param(void *object,
|
||||||
emit_port_info(this, false);
|
emit_port_info(this, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SPA_PARAM_Tag:
|
||||||
|
{
|
||||||
|
enum spa_direction other = SPA_DIRECTION_REVERSE(direction);
|
||||||
|
if (param != NULL) {
|
||||||
|
struct spa_tag_info info;
|
||||||
|
void *state = NULL;
|
||||||
|
if (spa_tag_parse(param, &info, &state) < 0 ||
|
||||||
|
info.direction != other)
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
if (spa_tag_compare(param, this->tag[other]) != 0) {
|
||||||
|
free(this->tag[other]);
|
||||||
|
this->tag[other] = param ? spa_pod_copy(param) : NULL;
|
||||||
|
|
||||||
|
this->port_info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
|
||||||
|
this->port_params[PORT_Tag].user++;
|
||||||
|
emit_port_info(this, false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
res = -ENOENT;
|
res = -ENOENT;
|
||||||
break;
|
break;
|
||||||
|
|
@ -901,6 +931,7 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
this->port_params[PORT_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
this->port_params[PORT_Format] = SPA_PARAM_INFO(SPA_PARAM_Format, SPA_PARAM_INFO_WRITE);
|
||||||
this->port_params[PORT_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
this->port_params[PORT_Buffers] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
|
||||||
this->port_params[PORT_Latency] = SPA_PARAM_INFO(SPA_PARAM_Latency, SPA_PARAM_INFO_READWRITE);
|
this->port_params[PORT_Latency] = SPA_PARAM_INFO(SPA_PARAM_Latency, SPA_PARAM_INFO_READWRITE);
|
||||||
|
this->port_params[PORT_Tag] = SPA_PARAM_INFO(SPA_PARAM_Tag, SPA_PARAM_INFO_READWRITE);
|
||||||
this->port_info.params = this->port_params;
|
this->port_info.params = this->port_params;
|
||||||
this->port_info.n_params = N_PORT_PARAMS;
|
this->port_info.n_params = N_PORT_PARAMS;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -575,6 +575,9 @@ int spa_alsa_clear(struct state *state)
|
||||||
spa_log_warn(state->log, "output close failed: %s", snd_strerror(err));
|
spa_log_warn(state->log, "output close failed: %s", snd_strerror(err));
|
||||||
fclose(state->log_file);
|
fclose(state->log_file);
|
||||||
|
|
||||||
|
free(state->tag[0]);
|
||||||
|
free(state->tag[1]);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ extern "C" {
|
||||||
#include <spa/param/param.h>
|
#include <spa/param/param.h>
|
||||||
#include <spa/param/latency-utils.h>
|
#include <spa/param/latency-utils.h>
|
||||||
#include <spa/param/audio/format-utils.h>
|
#include <spa/param/audio/format-utils.h>
|
||||||
|
#include <spa/param/tag-utils.h>
|
||||||
|
|
||||||
#include "alsa.h"
|
#include "alsa.h"
|
||||||
|
|
||||||
|
|
@ -165,7 +166,8 @@ struct state {
|
||||||
#define PORT_Format 3
|
#define PORT_Format 3
|
||||||
#define PORT_Buffers 4
|
#define PORT_Buffers 4
|
||||||
#define PORT_Latency 5
|
#define PORT_Latency 5
|
||||||
#define N_PORT_PARAMS 6
|
#define PORT_Tag 6
|
||||||
|
#define N_PORT_PARAMS 7
|
||||||
struct spa_param_info port_params[N_PORT_PARAMS];
|
struct spa_param_info port_params[N_PORT_PARAMS];
|
||||||
enum spa_direction port_direction;
|
enum spa_direction port_direction;
|
||||||
struct spa_io_buffers *io;
|
struct spa_io_buffers *io;
|
||||||
|
|
@ -234,6 +236,8 @@ struct state {
|
||||||
struct spa_latency_info latency[2];
|
struct spa_latency_info latency[2];
|
||||||
struct spa_process_latency_info process_latency;
|
struct spa_process_latency_info process_latency;
|
||||||
|
|
||||||
|
struct spa_pod *tag[2];
|
||||||
|
|
||||||
/* Rate match via an ALSA ctl */
|
/* Rate match via an ALSA ctl */
|
||||||
snd_ctl_t *ctl;
|
snd_ctl_t *ctl;
|
||||||
snd_ctl_elem_value_t *pitch_elem;
|
snd_ctl_elem_value_t *pitch_elem;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue