mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
pulse-server: also remap module property keys and values
When loading a module, remap the pulseaudio properties to pipewire ones for consistency. move the media-roles to remap, because it's more about remapping between pa and pw. Fixes #2076
This commit is contained in:
parent
8c10080324
commit
143fadf68e
7 changed files with 36 additions and 25 deletions
|
|
@ -223,7 +223,6 @@ pipewire_module_protocol_pulse_sources = [
|
||||||
'module-protocol-pulse/extensions/ext-stream-restore.c',
|
'module-protocol-pulse/extensions/ext-stream-restore.c',
|
||||||
'module-protocol-pulse/format.c',
|
'module-protocol-pulse/format.c',
|
||||||
'module-protocol-pulse/manager.c',
|
'module-protocol-pulse/manager.c',
|
||||||
'module-protocol-pulse/media-roles.c',
|
|
||||||
'module-protocol-pulse/message.c',
|
'module-protocol-pulse/message.c',
|
||||||
'module-protocol-pulse/message-handler.c',
|
'module-protocol-pulse/message-handler.c',
|
||||||
'module-protocol-pulse/module.c',
|
'module-protocol-pulse/module.c',
|
||||||
|
|
@ -231,6 +230,7 @@ pipewire_module_protocol_pulse_sources = [
|
||||||
'module-protocol-pulse/pending-sample.c',
|
'module-protocol-pulse/pending-sample.c',
|
||||||
'module-protocol-pulse/pulse-server.c',
|
'module-protocol-pulse/pulse-server.c',
|
||||||
'module-protocol-pulse/quirks.c',
|
'module-protocol-pulse/quirks.c',
|
||||||
|
'module-protocol-pulse/remap.c',
|
||||||
'module-protocol-pulse/reply.c',
|
'module-protocol-pulse/reply.c',
|
||||||
'module-protocol-pulse/sample.c',
|
'module-protocol-pulse/sample.c',
|
||||||
'module-protocol-pulse/sample-play.c',
|
'module-protocol-pulse/sample-play.c',
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@
|
||||||
#include "../extension.h"
|
#include "../extension.h"
|
||||||
#include "../format.h"
|
#include "../format.h"
|
||||||
#include "../manager.h"
|
#include "../manager.h"
|
||||||
#include "../media-roles.h"
|
|
||||||
#include "../message.h"
|
#include "../message.h"
|
||||||
#include "../reply.h"
|
#include "../reply.h"
|
||||||
#include "../volume.h"
|
#include "../volume.h"
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@
|
||||||
#include "../extension.h"
|
#include "../extension.h"
|
||||||
#include "../format.h"
|
#include "../format.h"
|
||||||
#include "../manager.h"
|
#include "../manager.h"
|
||||||
#include "../media-roles.h"
|
|
||||||
#include "../message.h"
|
#include "../message.h"
|
||||||
|
#include "../remap.h"
|
||||||
#include "../reply.h"
|
#include "../reply.h"
|
||||||
#include "../volume.h"
|
#include "../volume.h"
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
|
|
|
||||||
|
|
@ -28,15 +28,14 @@
|
||||||
#include <spa/debug/buffer.h>
|
#include <spa/debug/buffer.h>
|
||||||
#include <spa/utils/defs.h>
|
#include <spa/utils/defs.h>
|
||||||
#include <spa/utils/string.h>
|
#include <spa/utils/string.h>
|
||||||
#include <pipewire/keys.h>
|
|
||||||
#include <pipewire/log.h>
|
#include <pipewire/log.h>
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "media-roles.h"
|
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
#include "remap.h"
|
||||||
#include "volume.h"
|
#include "volume.h"
|
||||||
|
|
||||||
#define MAX_SIZE (256*1024)
|
#define MAX_SIZE (256*1024)
|
||||||
|
|
@ -65,20 +64,6 @@ static inline float volume_to_linear(uint32_t vol)
|
||||||
return v * v * v;
|
return v * v * v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct str_map key_table[] = {
|
|
||||||
{ PW_KEY_DEVICE_BUS_PATH, "device.bus_path" },
|
|
||||||
{ PW_KEY_DEVICE_FORM_FACTOR, "device.form_factor" },
|
|
||||||
{ PW_KEY_DEVICE_ICON_NAME, "device.icon_name" },
|
|
||||||
{ PW_KEY_DEVICE_INTENDED_ROLES, "device.intended_roles" },
|
|
||||||
{ PW_KEY_NODE_DESCRIPTION, "device.description" },
|
|
||||||
{ PW_KEY_MEDIA_ICON_NAME, "media.icon_name" },
|
|
||||||
{ PW_KEY_APP_ICON_NAME, "application.icon_name" },
|
|
||||||
{ PW_KEY_APP_PROCESS_MACHINE_ID, "application.process.machine_id" },
|
|
||||||
{ PW_KEY_APP_PROCESS_SESSION_ID, "application.process.session_id" },
|
|
||||||
{ PW_KEY_MEDIA_ROLE, "media.role", media_role_map },
|
|
||||||
{ NULL, NULL },
|
|
||||||
};
|
|
||||||
|
|
||||||
static int read_u8(struct message *m, uint8_t *val)
|
static int read_u8(struct message *m, uint8_t *val)
|
||||||
{
|
{
|
||||||
if (m->offset + 1 > m->length)
|
if (m->offset + 1 > m->length)
|
||||||
|
|
@ -153,7 +138,7 @@ static int read_props(struct message *m, struct pw_properties *props, bool remap
|
||||||
TAG_INVALID)) < 0)
|
TAG_INVALID)) < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
if (remap && (map = str_map_find(key_table, NULL, key)) != NULL) {
|
if (remap && (map = str_map_find(props_key_map, NULL, key)) != NULL) {
|
||||||
key = map->pw_str;
|
key = map->pw_str;
|
||||||
if (map->child != NULL &&
|
if (map->child != NULL &&
|
||||||
(map = str_map_find(map->child, NULL, data)) != NULL)
|
(map = str_map_find(map->child, NULL, data)) != NULL)
|
||||||
|
|
@ -567,7 +552,7 @@ static void write_dict(struct message *m, struct spa_dict *dict, bool remap)
|
||||||
int l;
|
int l;
|
||||||
const struct str_map *map;
|
const struct str_map *map;
|
||||||
|
|
||||||
if (remap && (map = str_map_find(key_table, key, NULL)) != NULL) {
|
if (remap && (map = str_map_find(props_key_map, key, NULL)) != NULL) {
|
||||||
key = map->pa_str;
|
key = map->pa_str;
|
||||||
if (map->child != NULL &&
|
if (map->child != NULL &&
|
||||||
(map = str_map_find(map->child, val, NULL)) != NULL)
|
(map = str_map_find(map->child, val, NULL)) != NULL)
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
#include "remap.h"
|
||||||
|
|
||||||
static void on_module_unload(void *obj, void *data, int res, uint32_t index)
|
static void on_module_unload(void *obj, void *data, int res, uint32_t index)
|
||||||
{
|
{
|
||||||
|
|
@ -139,6 +140,7 @@ void module_args_add_props(struct pw_properties *props, const char *str)
|
||||||
{
|
{
|
||||||
char *s = strdup(str), *p = s, *e, f;
|
char *s = strdup(str), *p = s, *e, f;
|
||||||
const char *k, *v;
|
const char *k, *v;
|
||||||
|
const struct str_map *map;
|
||||||
|
|
||||||
while (*p) {
|
while (*p) {
|
||||||
e = strchr(p, '=');
|
e = strchr(p, '=');
|
||||||
|
|
@ -168,6 +170,13 @@ void module_args_add_props(struct pw_properties *props, const char *str)
|
||||||
if (*e != '\0')
|
if (*e != '\0')
|
||||||
p++;
|
p++;
|
||||||
*e = '\0';
|
*e = '\0';
|
||||||
|
|
||||||
|
if ((map = str_map_find(props_key_map, NULL, k)) != NULL) {
|
||||||
|
k = map->pw_str;
|
||||||
|
if (map->child != NULL &&
|
||||||
|
(map = str_map_find(map->child, NULL, v)) != NULL)
|
||||||
|
v = map->pw_str;
|
||||||
|
}
|
||||||
pw_properties_set(props, k, v);
|
pw_properties_set(props, k, v);
|
||||||
}
|
}
|
||||||
free(s);
|
free(s);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,9 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "media-roles.h"
|
#include <pipewire/keys.h>
|
||||||
|
|
||||||
|
#include "remap.h"
|
||||||
|
|
||||||
const struct str_map media_role_map[] = {
|
const struct str_map media_role_map[] = {
|
||||||
{ "Movie", "video", },
|
{ "Movie", "video", },
|
||||||
|
|
@ -38,3 +40,17 @@ const struct str_map media_role_map[] = {
|
||||||
{ "Test", "test", },
|
{ "Test", "test", },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const struct str_map props_key_map[] = {
|
||||||
|
{ PW_KEY_DEVICE_BUS_PATH, "device.bus_path" },
|
||||||
|
{ PW_KEY_DEVICE_FORM_FACTOR, "device.form_factor" },
|
||||||
|
{ PW_KEY_DEVICE_ICON_NAME, "device.icon_name" },
|
||||||
|
{ PW_KEY_DEVICE_INTENDED_ROLES, "device.intended_roles" },
|
||||||
|
{ PW_KEY_NODE_DESCRIPTION, "device.description" },
|
||||||
|
{ PW_KEY_MEDIA_ICON_NAME, "media.icon_name" },
|
||||||
|
{ PW_KEY_APP_ICON_NAME, "application.icon_name" },
|
||||||
|
{ PW_KEY_APP_PROCESS_MACHINE_ID, "application.process.machine_id" },
|
||||||
|
{ PW_KEY_APP_PROCESS_SESSION_ID, "application.process.session_id" },
|
||||||
|
{ PW_KEY_MEDIA_ROLE, "media.role", media_role_map },
|
||||||
|
{ NULL, NULL },
|
||||||
|
};
|
||||||
|
|
@ -22,8 +22,8 @@
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PULSE_SERVER_MEDIA_ROLES_H
|
#ifndef PULSE_SERVER_REMAP_H
|
||||||
#define PULSE_SERVER_MEDIA_ROLES_H
|
#define PULSE_SERVER_REMAP_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
|
@ -37,6 +37,8 @@ struct str_map {
|
||||||
|
|
||||||
extern const struct str_map media_role_map[];
|
extern const struct str_map media_role_map[];
|
||||||
|
|
||||||
|
extern const struct str_map props_key_map[];
|
||||||
|
|
||||||
static inline const struct str_map *str_map_find(const struct str_map *map, const char *pw, const char *pa)
|
static inline const struct str_map *str_map_find(const struct str_map *map, const char *pw, const char *pa)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
@ -47,4 +49,4 @@ static inline const struct str_map *str_map_find(const struct str_map *map, cons
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PULSE_SERVER_MEDIA_ROLES_H */
|
#endif /* PULSE_SERVER_REMAP_H */
|
||||||
Loading…
Add table
Add a link
Reference in a new issue