mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
pulse-server: Factor out module code to compile independently
This starts breaking up the giant monolith that is the pulse-server.c code into more manageable chunks by trying to split the module code into individual compilation units.
This commit is contained in:
parent
abf193452c
commit
74140abada
19 changed files with 763 additions and 558 deletions
|
|
@ -96,8 +96,13 @@ endif
|
|||
|
||||
pipewire_module_protocol_pulse = shared_library('pipewire-module-protocol-pulse',
|
||||
[ 'module-protocol-pulse.c',
|
||||
'module-protocol-pulse/manager.c',
|
||||
'module-protocol-pulse/pulse-server.c',
|
||||
'module-protocol-pulse/manager.c' ],
|
||||
'module-protocol-pulse/modules/module-loopback.c',
|
||||
'module-protocol-pulse/modules/module-native-protocol-tcp.c',
|
||||
'module-protocol-pulse/modules/module-null-sink.c',
|
||||
'module-protocol-pulse/modules/module-simple-protocol-tcp.c',
|
||||
],
|
||||
c_args : pipewire_module_c_args,
|
||||
include_directories : [configinc, spa_inc],
|
||||
install : true,
|
||||
|
|
|
|||
|
|
@ -22,87 +22,6 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
static bool object_is_client(struct pw_manager_object *o)
|
||||
{
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Client) == 0;
|
||||
}
|
||||
|
||||
static bool object_is_module(struct pw_manager_object *o)
|
||||
{
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Module) == 0;
|
||||
}
|
||||
|
||||
static bool object_is_card(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Device) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
strcmp(str, "Audio/Device") == 0;
|
||||
}
|
||||
|
||||
static bool object_is_sink(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
(strcmp(str, "Audio/Sink") == 0 || strcmp(str, "Audio/Duplex") == 0);
|
||||
}
|
||||
|
||||
static bool object_is_source(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
(strcmp(str, "Audio/Source") == 0 ||
|
||||
strcmp(str, "Audio/Duplex") == 0 ||
|
||||
strcmp(str, "Audio/Source/Virtual") == 0);
|
||||
}
|
||||
|
||||
static bool object_is_monitor(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
(strcmp(str, "Audio/Sink") == 0);
|
||||
}
|
||||
|
||||
static bool object_is_source_or_monitor(struct pw_manager_object *o)
|
||||
{
|
||||
return object_is_source(o) || object_is_monitor(o);
|
||||
}
|
||||
|
||||
static bool object_is_sink_input(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
strcmp(str, "Stream/Output/Audio") == 0;
|
||||
}
|
||||
|
||||
static bool object_is_source_output(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
strcmp(str, "Stream/Input/Audio") == 0;
|
||||
}
|
||||
|
||||
static bool object_is_recordable(struct pw_manager_object *o)
|
||||
{
|
||||
return object_is_source(o) || object_is_sink(o) || object_is_sink_input(o);
|
||||
}
|
||||
|
||||
static bool object_is_link(struct pw_manager_object *o)
|
||||
{
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Link) == 0;
|
||||
}
|
||||
|
||||
struct selector {
|
||||
bool (*type) (struct pw_manager_object *o);
|
||||
uint32_t id;
|
||||
|
|
@ -160,7 +79,7 @@ static struct pw_manager_object *find_linked(struct pw_manager *m, uint32_t obj_
|
|||
uint32_t in_node, out_node;
|
||||
|
||||
spa_list_for_each(o, &m->object_list, link) {
|
||||
if (o->props == NULL || !object_is_link(o))
|
||||
if (o->props == NULL || !pw_manager_object_is_link(o))
|
||||
continue;
|
||||
|
||||
if ((str = pw_properties_get(o->props, PW_KEY_LINK_OUTPUT_NODE)) == NULL)
|
||||
|
|
@ -171,12 +90,12 @@ static struct pw_manager_object *find_linked(struct pw_manager *m, uint32_t obj_
|
|||
in_node = pw_properties_parse_int(str);
|
||||
|
||||
if (direction == PW_DIRECTION_OUTPUT && obj_id == out_node) {
|
||||
struct selector sel = { .id = in_node, .type = object_is_sink, };
|
||||
struct selector sel = { .id = in_node, .type = pw_manager_object_is_sink, };
|
||||
if ((p = select_object(m, &sel)) != NULL)
|
||||
return p;
|
||||
}
|
||||
if (direction == PW_DIRECTION_INPUT && obj_id == in_node) {
|
||||
struct selector sel = { .id = out_node, .type = object_is_recordable, };
|
||||
struct selector sel = { .id = out_node, .type = pw_manager_object_is_recordable, };
|
||||
if ((p = select_object(m, &sel)) != NULL)
|
||||
return p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -410,7 +410,7 @@ static const char *port_types[] = {
|
|||
"analog",
|
||||
};
|
||||
|
||||
static uint32_t port_type_value(const char *port_type)
|
||||
static inline uint32_t port_type_value(const char *port_type)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < SPA_N_ELEMENTS(port_types); i++) {
|
||||
|
|
|
|||
|
|
@ -22,47 +22,7 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RATE_MAX (48000u*8u)
|
||||
#define CHANNELS_MAX (64u)
|
||||
|
||||
enum sample_format {
|
||||
SAMPLE_U8,
|
||||
SAMPLE_ALAW,
|
||||
SAMPLE_ULAW,
|
||||
SAMPLE_S16LE,
|
||||
SAMPLE_S16BE,
|
||||
SAMPLE_FLOAT32LE,
|
||||
SAMPLE_FLOAT32BE,
|
||||
SAMPLE_S32LE,
|
||||
SAMPLE_S32BE,
|
||||
SAMPLE_S24LE,
|
||||
SAMPLE_S24BE,
|
||||
SAMPLE_S24_32LE,
|
||||
SAMPLE_S24_32BE,
|
||||
SAMPLE_MAX,
|
||||
SAMPLE_INVALID = -1
|
||||
};
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define SAMPLE_S16NE SAMPLE_S16BE
|
||||
#define SAMPLE_FLOAT32NE SAMPLE_FLOAT32BE
|
||||
#define SAMPLE_S32NE SAMPLE_S32BE
|
||||
#define SAMPLE_S24NE SAMPLE_S24BE
|
||||
#define SAMPLE_S24_32NE SAMPLE_S24_32BE
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define SAMPLE_S16NE SAMPLE_S16LE
|
||||
#define SAMPLE_FLOAT32NE SAMPLE_FLOAT32LE
|
||||
#define SAMPLE_S32NE SAMPLE_S32LE
|
||||
#define SAMPLE_S24NE SAMPLE_S24LE
|
||||
#define SAMPLE_S24_32NE SAMPLE_S24_32LE
|
||||
#endif
|
||||
|
||||
struct format {
|
||||
uint32_t pa;
|
||||
uint32_t id;
|
||||
const char *name;
|
||||
uint32_t size;
|
||||
};
|
||||
#include "format.h"
|
||||
|
||||
static const struct format audio_formats[] = {
|
||||
[SAMPLE_U8] = { SAMPLE_U8, SPA_AUDIO_FORMAT_U8, "u8", 1 },
|
||||
|
|
@ -101,14 +61,14 @@ static const struct format audio_formats[] = {
|
|||
{ SAMPLE_FLOAT32NE, SPA_AUDIO_FORMAT_F32P, "float32ne", 4 },
|
||||
};
|
||||
|
||||
static inline uint32_t format_pa2id(enum sample_format format)
|
||||
uint32_t format_pa2id(enum sample_format format)
|
||||
{
|
||||
if (format < 0 || format >= SAMPLE_MAX)
|
||||
return SPA_AUDIO_FORMAT_UNKNOWN;
|
||||
return audio_formats[format].id;
|
||||
}
|
||||
|
||||
static inline const char *format_id2name(uint32_t format)
|
||||
const char *format_id2name(uint32_t format)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; spa_type_audio_format[i].name; i++) {
|
||||
|
|
@ -117,7 +77,7 @@ static inline const char *format_id2name(uint32_t format)
|
|||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
static inline uint32_t format_name2id(const char *name)
|
||||
uint32_t format_name2id(const char *name)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; spa_type_audio_format[i].name; i++) {
|
||||
|
|
@ -127,7 +87,7 @@ static inline uint32_t format_name2id(const char *name)
|
|||
return SPA_AUDIO_CHANNEL_UNKNOWN;
|
||||
}
|
||||
|
||||
static inline uint32_t format_paname2id(const char *name, size_t size)
|
||||
uint32_t format_paname2id(const char *name, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < SPA_N_ELEMENTS(audio_formats); i++) {
|
||||
|
|
@ -138,7 +98,7 @@ static inline uint32_t format_paname2id(const char *name, size_t size)
|
|||
return SPA_AUDIO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
static inline enum sample_format format_id2pa(uint32_t id)
|
||||
enum sample_format format_id2pa(uint32_t id)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < SPA_N_ELEMENTS(audio_formats); i++) {
|
||||
|
|
@ -148,7 +108,7 @@ static inline enum sample_format format_id2pa(uint32_t id)
|
|||
return SAMPLE_INVALID;
|
||||
}
|
||||
|
||||
static inline const char *format_id2paname(uint32_t id)
|
||||
const char *format_id2paname(uint32_t id)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < SPA_N_ELEMENTS(audio_formats); i++) {
|
||||
|
|
@ -159,18 +119,7 @@ static inline const char *format_id2paname(uint32_t id)
|
|||
return "invalid";
|
||||
}
|
||||
|
||||
struct sample_spec {
|
||||
uint32_t format;
|
||||
uint32_t rate;
|
||||
uint8_t channels;
|
||||
};
|
||||
#define SAMPLE_SPEC_INIT (struct sample_spec) { \
|
||||
.format = SPA_AUDIO_FORMAT_UNKNOWN, \
|
||||
.rate = 0, \
|
||||
.channels = 0, \
|
||||
}
|
||||
|
||||
static inline uint32_t sample_spec_frame_size(const struct sample_spec *ss)
|
||||
uint32_t sample_spec_frame_size(const struct sample_spec *ss)
|
||||
{
|
||||
switch (ss->format) {
|
||||
case SPA_AUDIO_FORMAT_U8:
|
||||
|
|
@ -198,81 +147,13 @@ static inline uint32_t sample_spec_frame_size(const struct sample_spec *ss)
|
|||
}
|
||||
}
|
||||
|
||||
static inline bool sample_spec_valid(const struct sample_spec *ss)
|
||||
bool sample_spec_valid(const struct sample_spec *ss)
|
||||
{
|
||||
return (sample_spec_frame_size(ss) > 0 &&
|
||||
ss->rate > 0 && ss->rate <= RATE_MAX &&
|
||||
ss->channels > 0 && ss->channels <= CHANNELS_MAX);
|
||||
}
|
||||
|
||||
enum channel_position {
|
||||
CHANNEL_POSITION_INVALID = -1,
|
||||
CHANNEL_POSITION_MONO = 0,
|
||||
CHANNEL_POSITION_FRONT_LEFT,
|
||||
CHANNEL_POSITION_FRONT_RIGHT,
|
||||
CHANNEL_POSITION_FRONT_CENTER,
|
||||
|
||||
CHANNEL_POSITION_REAR_CENTER,
|
||||
CHANNEL_POSITION_REAR_LEFT,
|
||||
CHANNEL_POSITION_REAR_RIGHT,
|
||||
|
||||
CHANNEL_POSITION_LFE,
|
||||
CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
|
||||
CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
|
||||
|
||||
CHANNEL_POSITION_SIDE_LEFT,
|
||||
CHANNEL_POSITION_SIDE_RIGHT,
|
||||
CHANNEL_POSITION_AUX0,
|
||||
CHANNEL_POSITION_AUX1,
|
||||
CHANNEL_POSITION_AUX2,
|
||||
CHANNEL_POSITION_AUX3,
|
||||
CHANNEL_POSITION_AUX4,
|
||||
CHANNEL_POSITION_AUX5,
|
||||
CHANNEL_POSITION_AUX6,
|
||||
CHANNEL_POSITION_AUX7,
|
||||
CHANNEL_POSITION_AUX8,
|
||||
CHANNEL_POSITION_AUX9,
|
||||
CHANNEL_POSITION_AUX10,
|
||||
CHANNEL_POSITION_AUX11,
|
||||
CHANNEL_POSITION_AUX12,
|
||||
CHANNEL_POSITION_AUX13,
|
||||
CHANNEL_POSITION_AUX14,
|
||||
CHANNEL_POSITION_AUX15,
|
||||
CHANNEL_POSITION_AUX16,
|
||||
CHANNEL_POSITION_AUX17,
|
||||
CHANNEL_POSITION_AUX18,
|
||||
CHANNEL_POSITION_AUX19,
|
||||
CHANNEL_POSITION_AUX20,
|
||||
CHANNEL_POSITION_AUX21,
|
||||
CHANNEL_POSITION_AUX22,
|
||||
CHANNEL_POSITION_AUX23,
|
||||
CHANNEL_POSITION_AUX24,
|
||||
CHANNEL_POSITION_AUX25,
|
||||
CHANNEL_POSITION_AUX26,
|
||||
CHANNEL_POSITION_AUX27,
|
||||
CHANNEL_POSITION_AUX28,
|
||||
CHANNEL_POSITION_AUX29,
|
||||
CHANNEL_POSITION_AUX30,
|
||||
CHANNEL_POSITION_AUX31,
|
||||
|
||||
CHANNEL_POSITION_TOP_CENTER,
|
||||
|
||||
CHANNEL_POSITION_TOP_FRONT_LEFT,
|
||||
CHANNEL_POSITION_TOP_FRONT_RIGHT,
|
||||
CHANNEL_POSITION_TOP_FRONT_CENTER,
|
||||
|
||||
CHANNEL_POSITION_TOP_REAR_LEFT,
|
||||
CHANNEL_POSITION_TOP_REAR_RIGHT,
|
||||
CHANNEL_POSITION_TOP_REAR_CENTER,
|
||||
|
||||
CHANNEL_POSITION_MAX
|
||||
};
|
||||
|
||||
struct channel {
|
||||
uint32_t channel;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
static const struct channel audio_channels[] = {
|
||||
[CHANNEL_POSITION_MONO] = { SPA_AUDIO_CHANNEL_MONO, "mono", },
|
||||
|
||||
|
|
@ -335,23 +216,14 @@ static const struct channel audio_channels[] = {
|
|||
[CHANNEL_POSITION_TOP_REAR_CENTER] = { SPA_AUDIO_CHANNEL_TRC, "top-rear-center", },
|
||||
};
|
||||
|
||||
struct channel_map {
|
||||
uint8_t channels;
|
||||
uint32_t map[CHANNELS_MAX];
|
||||
};
|
||||
|
||||
#define CHANNEL_MAP_INIT (struct channel_map) { \
|
||||
.channels = 0, \
|
||||
}
|
||||
|
||||
static inline uint32_t channel_pa2id(enum channel_position channel)
|
||||
uint32_t channel_pa2id(enum channel_position channel)
|
||||
{
|
||||
if (channel < 0 || (size_t)channel >= SPA_N_ELEMENTS(audio_channels))
|
||||
return SPA_AUDIO_CHANNEL_UNKNOWN;
|
||||
return audio_channels[channel].channel;
|
||||
}
|
||||
|
||||
static inline const char *channel_id2name(uint32_t channel)
|
||||
const char *channel_id2name(uint32_t channel)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; spa_type_audio_channel[i].name; i++) {
|
||||
|
|
@ -361,7 +233,7 @@ static inline const char *channel_id2name(uint32_t channel)
|
|||
return "UNK";
|
||||
}
|
||||
|
||||
static inline uint32_t channel_name2id(const char *name)
|
||||
uint32_t channel_name2id(const char *name)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; spa_type_audio_channel[i].name; i++) {
|
||||
|
|
@ -371,7 +243,7 @@ static inline uint32_t channel_name2id(const char *name)
|
|||
return SPA_AUDIO_CHANNEL_UNKNOWN;
|
||||
}
|
||||
|
||||
static inline enum channel_position channel_id2pa(uint32_t id, uint32_t *aux)
|
||||
enum channel_position channel_id2pa(uint32_t id, uint32_t *aux)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < SPA_N_ELEMENTS(audio_channels); i++) {
|
||||
|
|
@ -381,7 +253,7 @@ static inline enum channel_position channel_id2pa(uint32_t id, uint32_t *aux)
|
|||
return CHANNEL_POSITION_AUX0 + ((*aux)++ & 31);
|
||||
}
|
||||
|
||||
static inline const char *channel_id2paname(uint32_t id, uint32_t *aux)
|
||||
const char *channel_id2paname(uint32_t id, uint32_t *aux)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < SPA_N_ELEMENTS(audio_channels); i++) {
|
||||
|
|
@ -392,7 +264,7 @@ static inline const char *channel_id2paname(uint32_t id, uint32_t *aux)
|
|||
return audio_channels[CHANNEL_POSITION_AUX0 + ((*aux)++ & 31)].name;
|
||||
}
|
||||
|
||||
static inline uint32_t channel_paname2id(const char *name, size_t size)
|
||||
uint32_t channel_paname2id(const char *name, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < SPA_N_ELEMENTS(audio_channels); i++) {
|
||||
|
|
@ -403,14 +275,14 @@ static inline uint32_t channel_paname2id(const char *name, size_t size)
|
|||
}
|
||||
|
||||
|
||||
static inline void channel_map_to_positions(const struct channel_map *map, uint32_t *pos)
|
||||
void channel_map_to_positions(const struct channel_map *map, uint32_t *pos)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < map->channels; i++)
|
||||
pos[i] = map->map[i];
|
||||
}
|
||||
|
||||
static inline void channel_map_parse(const char *str, struct channel_map *map)
|
||||
void channel_map_parse(const char *str, struct channel_map *map)
|
||||
{
|
||||
const char *p = str;
|
||||
size_t len;
|
||||
|
|
@ -487,7 +359,7 @@ static inline void channel_map_parse(const char *str, struct channel_map *map)
|
|||
}
|
||||
}
|
||||
|
||||
static inline bool channel_map_valid(const struct channel_map *map)
|
||||
bool channel_map_valid(const struct channel_map *map)
|
||||
{
|
||||
uint8_t i;
|
||||
if (map->channels == 0 || map->channels > CHANNELS_MAX)
|
||||
|
|
@ -499,20 +371,6 @@ static inline bool channel_map_valid(const struct channel_map *map)
|
|||
}
|
||||
|
||||
|
||||
enum encoding {
|
||||
ENCODING_ANY,
|
||||
ENCODING_PCM,
|
||||
ENCODING_AC3_IEC61937,
|
||||
ENCODING_EAC3_IEC61937,
|
||||
ENCODING_MPEG_IEC61937,
|
||||
ENCODING_DTS_IEC61937,
|
||||
ENCODING_MPEG2_AAC_IEC61937,
|
||||
ENCODING_TRUEHD_IEC61937,
|
||||
ENCODING_DTSHD_IEC61937,
|
||||
ENCODING_MAX,
|
||||
ENCODING_INVALID = -1,
|
||||
};
|
||||
|
||||
static const char *encoding_names[] = {
|
||||
[ENCODING_ANY] = "ANY",
|
||||
[ENCODING_PCM] = "PCM",
|
||||
|
|
@ -525,7 +383,7 @@ static const char *encoding_names[] = {
|
|||
[ENCODING_DTSHD_IEC61937] = "DTSHD-IEC61937",
|
||||
};
|
||||
|
||||
static inline const char *format_encoding2name(enum encoding enc)
|
||||
const char *format_encoding2name(enum encoding enc)
|
||||
{
|
||||
if (enc >= 0 && enc < (int)SPA_N_ELEMENTS(encoding_names) &&
|
||||
encoding_names[enc] != NULL)
|
||||
|
|
|
|||
191
src/modules/module-protocol-pulse/format.h
Normal file
191
src/modules/module-protocol-pulse/format.h
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
/* PipeWire
|
||||
*
|
||||
* Copyright © 2020 Wim Taymans
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PULSE_SERVER_FORMAT_H
|
||||
#define PULSE_SERVER_FORMAT_H
|
||||
|
||||
#define RATE_MAX (48000u*8u)
|
||||
#define CHANNELS_MAX (64u)
|
||||
|
||||
enum sample_format {
|
||||
SAMPLE_U8,
|
||||
SAMPLE_ALAW,
|
||||
SAMPLE_ULAW,
|
||||
SAMPLE_S16LE,
|
||||
SAMPLE_S16BE,
|
||||
SAMPLE_FLOAT32LE,
|
||||
SAMPLE_FLOAT32BE,
|
||||
SAMPLE_S32LE,
|
||||
SAMPLE_S32BE,
|
||||
SAMPLE_S24LE,
|
||||
SAMPLE_S24BE,
|
||||
SAMPLE_S24_32LE,
|
||||
SAMPLE_S24_32BE,
|
||||
SAMPLE_MAX,
|
||||
SAMPLE_INVALID = -1
|
||||
};
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define SAMPLE_S16NE SAMPLE_S16BE
|
||||
#define SAMPLE_FLOAT32NE SAMPLE_FLOAT32BE
|
||||
#define SAMPLE_S32NE SAMPLE_S32BE
|
||||
#define SAMPLE_S24NE SAMPLE_S24BE
|
||||
#define SAMPLE_S24_32NE SAMPLE_S24_32BE
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define SAMPLE_S16NE SAMPLE_S16LE
|
||||
#define SAMPLE_FLOAT32NE SAMPLE_FLOAT32LE
|
||||
#define SAMPLE_S32NE SAMPLE_S32LE
|
||||
#define SAMPLE_S24NE SAMPLE_S24LE
|
||||
#define SAMPLE_S24_32NE SAMPLE_S24_32LE
|
||||
#endif
|
||||
|
||||
struct format {
|
||||
uint32_t pa;
|
||||
uint32_t id;
|
||||
const char *name;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct sample_spec {
|
||||
uint32_t format;
|
||||
uint32_t rate;
|
||||
uint8_t channels;
|
||||
};
|
||||
#define SAMPLE_SPEC_INIT (struct sample_spec) { \
|
||||
.format = SPA_AUDIO_FORMAT_UNKNOWN, \
|
||||
.rate = 0, \
|
||||
.channels = 0, \
|
||||
}
|
||||
|
||||
enum channel_position {
|
||||
CHANNEL_POSITION_INVALID = -1,
|
||||
CHANNEL_POSITION_MONO = 0,
|
||||
CHANNEL_POSITION_FRONT_LEFT,
|
||||
CHANNEL_POSITION_FRONT_RIGHT,
|
||||
CHANNEL_POSITION_FRONT_CENTER,
|
||||
|
||||
CHANNEL_POSITION_REAR_CENTER,
|
||||
CHANNEL_POSITION_REAR_LEFT,
|
||||
CHANNEL_POSITION_REAR_RIGHT,
|
||||
|
||||
CHANNEL_POSITION_LFE,
|
||||
CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
|
||||
CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
|
||||
|
||||
CHANNEL_POSITION_SIDE_LEFT,
|
||||
CHANNEL_POSITION_SIDE_RIGHT,
|
||||
CHANNEL_POSITION_AUX0,
|
||||
CHANNEL_POSITION_AUX1,
|
||||
CHANNEL_POSITION_AUX2,
|
||||
CHANNEL_POSITION_AUX3,
|
||||
CHANNEL_POSITION_AUX4,
|
||||
CHANNEL_POSITION_AUX5,
|
||||
CHANNEL_POSITION_AUX6,
|
||||
CHANNEL_POSITION_AUX7,
|
||||
CHANNEL_POSITION_AUX8,
|
||||
CHANNEL_POSITION_AUX9,
|
||||
CHANNEL_POSITION_AUX10,
|
||||
CHANNEL_POSITION_AUX11,
|
||||
CHANNEL_POSITION_AUX12,
|
||||
CHANNEL_POSITION_AUX13,
|
||||
CHANNEL_POSITION_AUX14,
|
||||
CHANNEL_POSITION_AUX15,
|
||||
CHANNEL_POSITION_AUX16,
|
||||
CHANNEL_POSITION_AUX17,
|
||||
CHANNEL_POSITION_AUX18,
|
||||
CHANNEL_POSITION_AUX19,
|
||||
CHANNEL_POSITION_AUX20,
|
||||
CHANNEL_POSITION_AUX21,
|
||||
CHANNEL_POSITION_AUX22,
|
||||
CHANNEL_POSITION_AUX23,
|
||||
CHANNEL_POSITION_AUX24,
|
||||
CHANNEL_POSITION_AUX25,
|
||||
CHANNEL_POSITION_AUX26,
|
||||
CHANNEL_POSITION_AUX27,
|
||||
CHANNEL_POSITION_AUX28,
|
||||
CHANNEL_POSITION_AUX29,
|
||||
CHANNEL_POSITION_AUX30,
|
||||
CHANNEL_POSITION_AUX31,
|
||||
|
||||
CHANNEL_POSITION_TOP_CENTER,
|
||||
|
||||
CHANNEL_POSITION_TOP_FRONT_LEFT,
|
||||
CHANNEL_POSITION_TOP_FRONT_RIGHT,
|
||||
CHANNEL_POSITION_TOP_FRONT_CENTER,
|
||||
|
||||
CHANNEL_POSITION_TOP_REAR_LEFT,
|
||||
CHANNEL_POSITION_TOP_REAR_RIGHT,
|
||||
CHANNEL_POSITION_TOP_REAR_CENTER,
|
||||
|
||||
CHANNEL_POSITION_MAX
|
||||
};
|
||||
|
||||
struct channel {
|
||||
uint32_t channel;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
struct channel_map {
|
||||
uint8_t channels;
|
||||
uint32_t map[CHANNELS_MAX];
|
||||
};
|
||||
|
||||
#define CHANNEL_MAP_INIT (struct channel_map) { \
|
||||
.channels = 0, \
|
||||
}
|
||||
|
||||
enum encoding {
|
||||
ENCODING_ANY,
|
||||
ENCODING_PCM,
|
||||
ENCODING_AC3_IEC61937,
|
||||
ENCODING_EAC3_IEC61937,
|
||||
ENCODING_MPEG_IEC61937,
|
||||
ENCODING_DTS_IEC61937,
|
||||
ENCODING_MPEG2_AAC_IEC61937,
|
||||
ENCODING_TRUEHD_IEC61937,
|
||||
ENCODING_DTSHD_IEC61937,
|
||||
ENCODING_MAX,
|
||||
ENCODING_INVALID = -1,
|
||||
};
|
||||
|
||||
uint32_t format_pa2id(enum sample_format format);
|
||||
const char *format_id2name(uint32_t format);
|
||||
uint32_t format_name2id(const char *name);
|
||||
uint32_t format_paname2id(const char *name, size_t size);
|
||||
enum sample_format format_id2pa(uint32_t id);
|
||||
const char *format_id2paname(uint32_t id);
|
||||
uint32_t sample_spec_frame_size(const struct sample_spec *ss);
|
||||
bool sample_spec_valid(const struct sample_spec *ss);
|
||||
uint32_t channel_pa2id(enum channel_position channel);
|
||||
const char *channel_id2name(uint32_t channel);
|
||||
uint32_t channel_name2id(const char *name);
|
||||
enum channel_position channel_id2pa(uint32_t id, uint32_t *aux);
|
||||
const char *channel_id2paname(uint32_t id, uint32_t *aux);
|
||||
uint32_t channel_paname2id(const char *name, size_t size);
|
||||
void channel_map_to_positions(const struct channel_map *map, uint32_t *pos);
|
||||
void channel_map_parse(const char *str, struct channel_map *map);
|
||||
bool channel_map_valid(const struct channel_map *map);
|
||||
const char *format_encoding2name(enum encoding enc);
|
||||
|
||||
#endif
|
||||
237
src/modules/module-protocol-pulse/internal.h
Normal file
237
src/modules/module-protocol-pulse/internal.h
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
/* PipeWire
|
||||
*
|
||||
* Copyright © 2020 Wim Taymans
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PULSE_SERVER_INTERNAL_H
|
||||
#define PULSE_SERVER_INTERNAL_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/ringbuffer.h>
|
||||
#include <pipewire/pipewire.h>
|
||||
#include <pipewire/private.h>
|
||||
|
||||
#include "format.h"
|
||||
|
||||
#define NAME "pulse-server"
|
||||
|
||||
struct defs {
|
||||
struct spa_fraction min_req;
|
||||
struct spa_fraction default_req;
|
||||
struct spa_fraction min_frag;
|
||||
struct spa_fraction default_frag;
|
||||
struct spa_fraction default_tlength;
|
||||
struct spa_fraction min_quantum;
|
||||
struct sample_spec sample_spec;
|
||||
struct channel_map channel_map;
|
||||
};
|
||||
|
||||
struct descriptor {
|
||||
uint32_t length;
|
||||
uint32_t channel;
|
||||
uint32_t offset_hi;
|
||||
uint32_t offset_lo;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
struct stats {
|
||||
uint32_t n_allocated;
|
||||
uint32_t allocated;
|
||||
uint32_t n_accumulated;
|
||||
uint32_t accumulated;
|
||||
uint32_t sample_cache;
|
||||
};
|
||||
|
||||
struct impl;
|
||||
struct server;
|
||||
struct client;
|
||||
|
||||
struct client {
|
||||
struct spa_list link;
|
||||
struct impl *impl;
|
||||
struct server *server;
|
||||
|
||||
int ref;
|
||||
const char *name;
|
||||
|
||||
struct spa_source *source;
|
||||
struct spa_source *cleanup;
|
||||
|
||||
uint32_t version;
|
||||
|
||||
struct pw_properties *props;
|
||||
|
||||
struct pw_core *core;
|
||||
struct pw_manager *manager;
|
||||
struct spa_hook manager_listener;
|
||||
|
||||
uint32_t subscribed;
|
||||
|
||||
struct pw_manager_object *metadata_default;
|
||||
char *default_sink;
|
||||
char *default_source;
|
||||
struct pw_manager_object *metadata_routes;
|
||||
struct pw_properties *routes;
|
||||
|
||||
uint32_t connect_tag;
|
||||
|
||||
uint32_t in_index;
|
||||
uint32_t out_index;
|
||||
struct descriptor desc;
|
||||
struct message *message;
|
||||
|
||||
struct pw_map streams;
|
||||
struct spa_list out_messages;
|
||||
|
||||
struct spa_list operations;
|
||||
struct spa_list loading_modules;
|
||||
|
||||
struct spa_list pending_samples;
|
||||
|
||||
unsigned int disconnect:1;
|
||||
unsigned int disconnecting:1;
|
||||
unsigned int need_flush:1;
|
||||
|
||||
struct pw_manager_object *prev_default_sink;
|
||||
struct pw_manager_object *prev_default_source;
|
||||
};
|
||||
|
||||
struct buffer_attr {
|
||||
uint32_t maxlength;
|
||||
uint32_t tlength;
|
||||
uint32_t prebuf;
|
||||
uint32_t minreq;
|
||||
uint32_t fragsize;
|
||||
};
|
||||
|
||||
struct volume {
|
||||
uint8_t channels;
|
||||
float values[CHANNELS_MAX];
|
||||
};
|
||||
|
||||
#define VOLUME_INIT (struct volume) { \
|
||||
.channels = 0, \
|
||||
}
|
||||
|
||||
struct stream {
|
||||
uint32_t create_tag;
|
||||
uint32_t channel; /* index in map */
|
||||
uint32_t id; /* id of global */
|
||||
|
||||
struct impl *impl;
|
||||
struct client *client;
|
||||
#define STREAM_TYPE_RECORD 0
|
||||
#define STREAM_TYPE_PLAYBACK 1
|
||||
#define STREAM_TYPE_UPLOAD 2
|
||||
uint32_t type;
|
||||
enum pw_direction direction;
|
||||
|
||||
struct pw_properties *props;
|
||||
|
||||
struct pw_stream *stream;
|
||||
struct spa_hook stream_listener;
|
||||
|
||||
struct spa_io_rate_match *rate_match;
|
||||
struct spa_ringbuffer ring;
|
||||
void *buffer;
|
||||
|
||||
int64_t read_index;
|
||||
int64_t write_index;
|
||||
uint64_t underrun_for;
|
||||
uint64_t playing_for;
|
||||
uint64_t ticks_base;
|
||||
uint64_t timestamp;
|
||||
int64_t delay;
|
||||
|
||||
uint32_t missing;
|
||||
uint32_t requested;
|
||||
|
||||
struct sample_spec ss;
|
||||
struct channel_map map;
|
||||
struct buffer_attr attr;
|
||||
uint32_t frame_size;
|
||||
uint32_t rate;
|
||||
|
||||
struct volume volume;
|
||||
bool muted;
|
||||
|
||||
uint32_t drain_tag;
|
||||
unsigned int corked:1;
|
||||
unsigned int draining:1;
|
||||
unsigned int volume_set:1;
|
||||
unsigned int muted_set:1;
|
||||
unsigned int early_requests:1;
|
||||
unsigned int adjust_latency:1;
|
||||
unsigned int is_underrun:1;
|
||||
unsigned int in_prebuf:1;
|
||||
unsigned int done:1;
|
||||
unsigned int killed:1;
|
||||
};
|
||||
|
||||
struct server {
|
||||
struct spa_list link;
|
||||
struct impl *impl;
|
||||
|
||||
#define SERVER_TYPE_INVALID 0
|
||||
#define SERVER_TYPE_UNIX 1
|
||||
#define SERVER_TYPE_INET 2
|
||||
uint32_t type;
|
||||
struct sockaddr_un addr;
|
||||
|
||||
struct spa_source *source;
|
||||
struct spa_list clients;
|
||||
unsigned int activated:1;
|
||||
};
|
||||
|
||||
struct impl {
|
||||
struct pw_loop *loop;
|
||||
struct pw_context *context;
|
||||
struct spa_hook context_listener;
|
||||
|
||||
struct pw_properties *props;
|
||||
void *dbus_name;
|
||||
|
||||
struct ratelimit rate_limit;
|
||||
|
||||
struct spa_source *source;
|
||||
struct spa_list servers;
|
||||
|
||||
struct spa_source *cleanup;
|
||||
struct spa_list cleanup_clients;
|
||||
|
||||
struct pw_map samples;
|
||||
struct pw_map modules;
|
||||
|
||||
struct spa_list free_messages;
|
||||
struct defs defs;
|
||||
struct stats stat;
|
||||
};
|
||||
|
||||
struct server *create_server(struct impl *impl, const char *address);
|
||||
void server_free(struct server *server);
|
||||
|
||||
#endif
|
||||
|
|
@ -807,3 +807,84 @@ int pw_manager_sync(struct pw_manager *manager)
|
|||
struct manager *m = SPA_CONTAINER_OF(manager, struct manager, this);
|
||||
return core_sync(m);
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_client(struct pw_manager_object *o)
|
||||
{
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Client) == 0;
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_module(struct pw_manager_object *o)
|
||||
{
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Module) == 0;
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_card(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Device) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
strcmp(str, "Audio/Device") == 0;
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_sink(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
(strcmp(str, "Audio/Sink") == 0 || strcmp(str, "Audio/Duplex") == 0);
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_source(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
(strcmp(str, "Audio/Source") == 0 ||
|
||||
strcmp(str, "Audio/Duplex") == 0 ||
|
||||
strcmp(str, "Audio/Source/Virtual") == 0);
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_monitor(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
(strcmp(str, "Audio/Sink") == 0);
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_source_or_monitor(struct pw_manager_object *o)
|
||||
{
|
||||
return pw_manager_object_is_source(o) || pw_manager_object_is_monitor(o);
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_sink_input(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
strcmp(str, "Stream/Output/Audio") == 0;
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_source_output(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
|
||||
o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_MEDIA_CLASS)) != NULL &&
|
||||
strcmp(str, "Stream/Input/Audio") == 0;
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_recordable(struct pw_manager_object *o)
|
||||
{
|
||||
return pw_manager_object_is_source(o) || pw_manager_object_is_sink(o) || pw_manager_object_is_sink_input(o);
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_link(struct pw_manager_object *o)
|
||||
{
|
||||
return strcmp(o->type, PW_TYPE_INTERFACE_Link) == 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,18 @@ int pw_manager_for_each_object(struct pw_manager *manager,
|
|||
|
||||
void *pw_manager_object_add_data(struct pw_manager_object *o, const char *id, size_t size);
|
||||
|
||||
bool pw_manager_object_is_client(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_module(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_card(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_sink(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_source(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_monitor(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_source_or_monitor(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_sink_input(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_source_output(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_recordable(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_link(struct pw_manager_object *o);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ static void register_object_message_handlers(struct pw_manager_object *o)
|
|||
return;
|
||||
}
|
||||
|
||||
if (object_is_card(o) && o->props != NULL &&
|
||||
if (pw_manager_object_is_card(o) && o->props != NULL &&
|
||||
(str = pw_properties_get(o->props, PW_KEY_DEVICE_API)) != NULL &&
|
||||
strcmp(str, "bluez5") == 0) {
|
||||
str = pw_properties_get(o->props, PW_KEY_DEVICE_NAME);
|
||||
|
|
|
|||
|
|
@ -88,14 +88,6 @@ static inline const struct str_map *str_map_find(const struct str_map *map, cons
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct descriptor {
|
||||
uint32_t length;
|
||||
uint32_t channel;
|
||||
uint32_t offset_hi;
|
||||
uint32_t offset_lo;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
enum {
|
||||
TAG_INVALID = 0,
|
||||
TAG_STRING = 't',
|
||||
|
|
|
|||
|
|
@ -23,42 +23,7 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
struct module;
|
||||
|
||||
struct module_info {
|
||||
const char *name;
|
||||
struct module *(*create) (struct impl *impl, const char *args);
|
||||
};
|
||||
|
||||
struct module_events {
|
||||
#define VERSION_MODULE_EVENTS 0
|
||||
uint32_t version;
|
||||
|
||||
void (*loaded) (void *data, int res);
|
||||
};
|
||||
|
||||
#define module_emit_loaded(m,r) spa_hook_list_call(&m->hooks, struct module_events, loaded, 0, r)
|
||||
|
||||
struct module_methods {
|
||||
#define VERSION_MODULE_METHODS 0
|
||||
uint32_t version;
|
||||
|
||||
int (*load) (struct client *client, struct module *module);
|
||||
int (*unload) (struct client *client, struct module *module);
|
||||
};
|
||||
|
||||
struct module {
|
||||
uint32_t idx;
|
||||
const char *name;
|
||||
const char *args;
|
||||
struct pw_properties *props;
|
||||
struct spa_list link; /**< link in client modules */
|
||||
struct impl *impl;
|
||||
const struct module_methods *methods;
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_source *unload;
|
||||
void *user_data;
|
||||
};
|
||||
#include "module.h"
|
||||
|
||||
static int module_unload(struct client *client, struct module *module);
|
||||
|
||||
|
|
@ -69,7 +34,7 @@ static void on_module_unload(void *data, uint64_t count)
|
|||
module_unload(NULL, module);
|
||||
}
|
||||
|
||||
static struct module *module_new(struct impl *impl, const struct module_methods *methods, size_t user_data)
|
||||
struct module *module_new(struct impl *impl, const struct module_methods *methods, size_t user_data)
|
||||
{
|
||||
struct module *module;
|
||||
|
||||
|
|
@ -143,7 +108,7 @@ static int module_unload(struct client *client, struct module *module)
|
|||
}
|
||||
|
||||
/** utils */
|
||||
static void add_props(struct pw_properties *props, const char *str)
|
||||
void module_args_add_props(struct pw_properties *props, const char *str)
|
||||
{
|
||||
char *s = strdup(str), *p = s, *e, f;
|
||||
const char *k, *v;
|
||||
|
|
@ -177,7 +142,7 @@ static void add_props(struct pw_properties *props, const char *str)
|
|||
free(s);
|
||||
}
|
||||
|
||||
static int args_to_audioinfo(struct impl *impl, struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
int module_args_to_audioinfo(struct impl *impl, struct pw_properties *props, struct spa_audio_info_raw *info)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
|
|
@ -225,10 +190,7 @@ static int args_to_audioinfo(struct impl *impl, struct pw_properties *props, str
|
|||
return 0;
|
||||
}
|
||||
|
||||
#include "module-loopback.c"
|
||||
#include "module-null-sink.c"
|
||||
#include "module-native-protocol-tcp.c"
|
||||
#include "module-simple-protocol-tcp.c"
|
||||
#include "modules/registry.h"
|
||||
|
||||
static const struct module_info module_list[] = {
|
||||
{ "module-loopback", create_module_loopback, },
|
||||
|
|
|
|||
75
src/modules/module-protocol-pulse/module.h
Normal file
75
src/modules/module-protocol-pulse/module.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/* PipeWire
|
||||
*
|
||||
* Copyright © 2020 Georges Basile Stavracas Neto
|
||||
* Copyright © 2021 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PIPEWIRE_PULSE_MODULE_H
|
||||
#define PIPEWIRE_PULSE_MODULE_H
|
||||
|
||||
#include <spa/param/audio/raw.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
struct module;
|
||||
|
||||
struct module_info {
|
||||
const char *name;
|
||||
struct module *(*create) (struct impl *impl, const char *args);
|
||||
};
|
||||
|
||||
struct module_events {
|
||||
#define VERSION_MODULE_EVENTS 0
|
||||
uint32_t version;
|
||||
|
||||
void (*loaded) (void *data, int res);
|
||||
};
|
||||
|
||||
#define module_emit_loaded(m,r) spa_hook_list_call(&m->hooks, struct module_events, loaded, 0, r)
|
||||
|
||||
struct module_methods {
|
||||
#define VERSION_MODULE_METHODS 0
|
||||
uint32_t version;
|
||||
|
||||
int (*load) (struct client *client, struct module *module);
|
||||
int (*unload) (struct client *client, struct module *module);
|
||||
};
|
||||
|
||||
struct module {
|
||||
uint32_t idx;
|
||||
const char *name;
|
||||
const char *args;
|
||||
struct pw_properties *props;
|
||||
struct spa_list link; /**< link in client modules */
|
||||
struct impl *impl;
|
||||
const struct module_methods *methods;
|
||||
struct spa_hook_list hooks;
|
||||
struct spa_source *unload;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
struct module *module_new(struct impl *impl, const struct module_methods *methods, size_t user_data);
|
||||
|
||||
void module_args_add_props(struct pw_properties *props, const char *str);
|
||||
int module_args_to_audioinfo(struct impl *impl, struct pw_properties *props, struct spa_audio_info_raw *info);
|
||||
|
||||
#endif
|
||||
|
|
@ -23,6 +23,15 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <spa/param/audio/format-utils.h>
|
||||
#include <spa/utils/hook.h>
|
||||
#include <pipewire/pipewire.h>
|
||||
#include <pipewire/private.h>
|
||||
|
||||
#include "../defs.h"
|
||||
#include "../module.h"
|
||||
#include "registry.h"
|
||||
|
||||
#define ERROR_RETURN(str) \
|
||||
{ \
|
||||
pw_log_error(str); \
|
||||
|
|
@ -220,7 +229,7 @@ static const struct spa_dict_item module_loopback_info[] = {
|
|||
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
static struct module *create_module_loopback(struct impl *impl, const char *argument)
|
||||
struct module *create_module_loopback(struct impl *impl, const char *argument)
|
||||
{
|
||||
struct module *module;
|
||||
struct module_loopback_data *d;
|
||||
|
|
@ -237,7 +246,7 @@ static struct module *create_module_loopback(struct impl *impl, const char *argu
|
|||
goto out;
|
||||
}
|
||||
if (argument)
|
||||
add_props(props, argument);
|
||||
module_args_add_props(props, argument);
|
||||
|
||||
/* The following modargs are not implemented:
|
||||
* adjust_time, max_latency_msec, fast_adjust_threshold_msec: these are just not relevant
|
||||
|
|
@ -258,7 +267,7 @@ static struct module *create_module_loopback(struct impl *impl, const char *argu
|
|||
pw_properties_set(props, "sink", NULL);
|
||||
}
|
||||
|
||||
if (args_to_audioinfo(impl, props, &info) < 0) {
|
||||
if (module_args_to_audioinfo(impl, props, &info) < 0) {
|
||||
res = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -291,12 +300,12 @@ static struct module *create_module_loopback(struct impl *impl, const char *argu
|
|||
}
|
||||
|
||||
if ((str = pw_properties_get(props, "sink_input_properties")) != NULL) {
|
||||
add_props(playback_props, str);
|
||||
module_args_add_props(playback_props, str);
|
||||
pw_properties_set(props, "sink_input_properties", NULL);
|
||||
}
|
||||
|
||||
if ((str = pw_properties_get(props, "source_output_properties")) != NULL) {
|
||||
add_props(capture_props, str);
|
||||
module_args_add_props(capture_props, str);
|
||||
pw_properties_set(props, "source_output_properties", NULL);
|
||||
}
|
||||
|
||||
|
|
@ -22,6 +22,11 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pipewire/pipewire.h>
|
||||
|
||||
#include "../module.h"
|
||||
#include "registry.h"
|
||||
|
||||
#define ERROR_RETURN(str) \
|
||||
{ \
|
||||
pw_log_error(str); \
|
||||
|
|
@ -77,7 +82,7 @@ static const struct spa_dict_item module_native_protocol_tcp_info[] = {
|
|||
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
static struct module *create_module_native_protocol_tcp(struct impl *impl, const char *argument)
|
||||
struct module *create_module_native_protocol_tcp(struct impl *impl, const char *argument)
|
||||
{
|
||||
struct module *module;
|
||||
struct module_native_protocol_tcp_data *d;
|
||||
|
|
@ -91,7 +96,7 @@ static struct module *create_module_native_protocol_tcp(struct impl *impl, const
|
|||
goto out;
|
||||
}
|
||||
if (argument)
|
||||
add_props(props, argument);
|
||||
module_args_add_props(props, argument);
|
||||
|
||||
if ((port = pw_properties_get(props, "port")) == NULL)
|
||||
port = "4713";
|
||||
|
|
@ -22,6 +22,12 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pipewire/pipewire.h>
|
||||
|
||||
#include "../manager.h"
|
||||
#include "../module.h"
|
||||
#include "registry.h"
|
||||
|
||||
struct module_null_sink_data {
|
||||
struct pw_proxy *proxy;
|
||||
struct spa_hook listener;
|
||||
|
|
@ -116,7 +122,7 @@ static const struct spa_dict_item module_null_sink_info[] = {
|
|||
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
static struct module *create_module_null_sink(struct impl *impl, const char *argument)
|
||||
struct module *create_module_null_sink(struct impl *impl, const char *argument)
|
||||
{
|
||||
struct module *module;
|
||||
struct module_null_sink_data *d;
|
||||
|
|
@ -132,7 +138,7 @@ static struct module *create_module_null_sink(struct impl *impl, const char *arg
|
|||
goto out;
|
||||
}
|
||||
if (argument)
|
||||
add_props(props, argument);
|
||||
module_args_add_props(props, argument);
|
||||
|
||||
if ((str = pw_properties_get(props, "sink_name")) != NULL) {
|
||||
pw_properties_set(props, PW_KEY_NODE_NAME, str);
|
||||
|
|
@ -141,7 +147,7 @@ static struct module *create_module_null_sink(struct impl *impl, const char *arg
|
|||
pw_properties_set(props, PW_KEY_NODE_NAME, "null");
|
||||
}
|
||||
if ((str = pw_properties_get(props, "sink_properties")) != NULL) {
|
||||
add_props(props, str);
|
||||
module_args_add_props(props, str);
|
||||
pw_properties_set(props, "sink_properties", NULL);
|
||||
}
|
||||
if ((str = pw_properties_get(props, "channels")) != NULL) {
|
||||
|
|
@ -23,6 +23,11 @@
|
|||
*/
|
||||
|
||||
#include <pipewire/impl.h>
|
||||
#include <pipewire/pipewire.h>
|
||||
|
||||
#include "../defs.h"
|
||||
#include "../module.h"
|
||||
#include "registry.h"
|
||||
|
||||
struct module_simple_protocol_tcp_data {
|
||||
struct module *module;
|
||||
|
|
@ -104,7 +109,7 @@ static const struct spa_dict_item module_simple_protocol_tcp_info[] = {
|
|||
{ PW_KEY_MODULE_VERSION, PACKAGE_VERSION },
|
||||
};
|
||||
|
||||
static struct module *create_module_simple_protocol_tcp(struct impl *impl, const char *argument)
|
||||
struct module *create_module_simple_protocol_tcp(struct impl *impl, const char *argument)
|
||||
{
|
||||
struct module *module;
|
||||
struct module_simple_protocol_tcp_data *d;
|
||||
|
|
@ -118,7 +123,7 @@ static struct module *create_module_simple_protocol_tcp(struct impl *impl, const
|
|||
goto out;
|
||||
}
|
||||
if (argument)
|
||||
add_props(props, argument);
|
||||
module_args_add_props(props, argument);
|
||||
|
||||
module_props = pw_properties_new(NULL, NULL);
|
||||
if (module_props == NULL) {
|
||||
36
src/modules/module-protocol-pulse/modules/registry.h
Normal file
36
src/modules/module-protocol-pulse/modules/registry.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* PipeWire
|
||||
*
|
||||
* Copyright © 2021 Wim Taymans <wim.taymans@gmail.com>
|
||||
* Copyright © 2021 Arun Raghavan <arun@asymptotic.io>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef PIPEWIRE_PULSE_MODULE_REGISTRY_H
|
||||
#define PIPEWIRE_PULSE_MODULE_REGISTRY_H
|
||||
|
||||
#include "../internal.h"
|
||||
|
||||
struct module *create_module_loopback(struct impl *impl, const char *argument);
|
||||
struct module *create_module_native_protocol_tcp(struct impl *impl, const char *argument);
|
||||
struct module *create_module_null_sink(struct impl *impl, const char *argument);
|
||||
struct module *create_module_simple_protocol_tcp(struct impl *impl, const char *argument);
|
||||
|
||||
#endif
|
||||
|
|
@ -77,14 +77,7 @@
|
|||
|
||||
#include "pulse-server.h"
|
||||
#include "defs.h"
|
||||
|
||||
struct stats {
|
||||
uint32_t n_allocated;
|
||||
uint32_t allocated;
|
||||
uint32_t n_accumulated;
|
||||
uint32_t accumulated;
|
||||
uint32_t sample_cache;
|
||||
};
|
||||
#include "internal.h"
|
||||
|
||||
#define DEFAULT_MIN_REQ "256/48000"
|
||||
#define DEFAULT_DEFAULT_REQ "960/48000"
|
||||
|
|
@ -107,25 +100,8 @@ struct stats {
|
|||
#include "manager.h"
|
||||
#include "dbus-name.c"
|
||||
|
||||
struct defs {
|
||||
struct spa_fraction min_req;
|
||||
struct spa_fraction default_req;
|
||||
struct spa_fraction min_frag;
|
||||
struct spa_fraction default_frag;
|
||||
struct spa_fraction default_tlength;
|
||||
struct spa_fraction min_quantum;
|
||||
struct sample_spec sample_spec;
|
||||
struct channel_map channel_map;
|
||||
};
|
||||
|
||||
#define NAME "pulse-server"
|
||||
|
||||
static bool debug_messages = false;
|
||||
|
||||
struct impl;
|
||||
struct server;
|
||||
struct client;
|
||||
|
||||
#include "sample.c"
|
||||
|
||||
struct operation {
|
||||
|
|
@ -134,169 +110,14 @@ struct operation {
|
|||
uint32_t tag;
|
||||
};
|
||||
|
||||
struct client {
|
||||
struct spa_list link;
|
||||
struct impl *impl;
|
||||
struct server *server;
|
||||
|
||||
int ref;
|
||||
const char *name;
|
||||
|
||||
struct spa_source *source;
|
||||
struct spa_source *cleanup;
|
||||
|
||||
uint32_t version;
|
||||
|
||||
struct pw_properties *props;
|
||||
|
||||
struct pw_core *core;
|
||||
struct pw_manager *manager;
|
||||
struct spa_hook manager_listener;
|
||||
|
||||
uint32_t subscribed;
|
||||
|
||||
struct pw_manager_object *metadata_default;
|
||||
char *default_sink;
|
||||
char *default_source;
|
||||
struct pw_manager_object *metadata_routes;
|
||||
struct pw_properties *routes;
|
||||
|
||||
uint32_t connect_tag;
|
||||
|
||||
uint32_t in_index;
|
||||
uint32_t out_index;
|
||||
struct descriptor desc;
|
||||
struct message *message;
|
||||
|
||||
struct pw_map streams;
|
||||
struct spa_list out_messages;
|
||||
|
||||
struct spa_list operations;
|
||||
struct spa_list loading_modules;
|
||||
|
||||
struct spa_list pending_samples;
|
||||
|
||||
unsigned int disconnect:1;
|
||||
unsigned int disconnecting:1;
|
||||
unsigned int need_flush:1;
|
||||
|
||||
struct pw_manager_object *prev_default_sink;
|
||||
struct pw_manager_object *prev_default_source;
|
||||
};
|
||||
|
||||
struct latency_offset_data {
|
||||
int64_t prev_latency_offset;
|
||||
unsigned int initialized:1;
|
||||
};
|
||||
|
||||
struct buffer_attr {
|
||||
uint32_t maxlength;
|
||||
uint32_t tlength;
|
||||
uint32_t prebuf;
|
||||
uint32_t minreq;
|
||||
uint32_t fragsize;
|
||||
};
|
||||
|
||||
struct stream {
|
||||
uint32_t create_tag;
|
||||
uint32_t channel; /* index in map */
|
||||
uint32_t id; /* id of global */
|
||||
|
||||
struct impl *impl;
|
||||
struct client *client;
|
||||
#define STREAM_TYPE_RECORD 0
|
||||
#define STREAM_TYPE_PLAYBACK 1
|
||||
#define STREAM_TYPE_UPLOAD 2
|
||||
uint32_t type;
|
||||
enum pw_direction direction;
|
||||
|
||||
struct pw_properties *props;
|
||||
|
||||
struct pw_stream *stream;
|
||||
struct spa_hook stream_listener;
|
||||
|
||||
struct spa_io_rate_match *rate_match;
|
||||
struct spa_ringbuffer ring;
|
||||
void *buffer;
|
||||
|
||||
int64_t read_index;
|
||||
int64_t write_index;
|
||||
uint64_t underrun_for;
|
||||
uint64_t playing_for;
|
||||
uint64_t ticks_base;
|
||||
uint64_t timestamp;
|
||||
int64_t delay;
|
||||
|
||||
uint32_t missing;
|
||||
uint32_t requested;
|
||||
|
||||
struct sample_spec ss;
|
||||
struct channel_map map;
|
||||
struct buffer_attr attr;
|
||||
uint32_t frame_size;
|
||||
uint32_t rate;
|
||||
|
||||
struct volume volume;
|
||||
bool muted;
|
||||
|
||||
uint32_t drain_tag;
|
||||
unsigned int corked:1;
|
||||
unsigned int draining:1;
|
||||
unsigned int volume_set:1;
|
||||
unsigned int muted_set:1;
|
||||
unsigned int early_requests:1;
|
||||
unsigned int adjust_latency:1;
|
||||
unsigned int is_underrun:1;
|
||||
unsigned int in_prebuf:1;
|
||||
unsigned int done:1;
|
||||
unsigned int killed:1;
|
||||
};
|
||||
|
||||
struct server {
|
||||
struct spa_list link;
|
||||
struct impl *impl;
|
||||
|
||||
#define SERVER_TYPE_INVALID 0
|
||||
#define SERVER_TYPE_UNIX 1
|
||||
#define SERVER_TYPE_INET 2
|
||||
uint32_t type;
|
||||
struct sockaddr_un addr;
|
||||
|
||||
struct spa_source *source;
|
||||
struct spa_list clients;
|
||||
unsigned int activated:1;
|
||||
};
|
||||
|
||||
struct impl {
|
||||
struct pw_loop *loop;
|
||||
struct pw_context *context;
|
||||
struct spa_hook context_listener;
|
||||
|
||||
struct pw_properties *props;
|
||||
void *dbus_name;
|
||||
|
||||
struct ratelimit rate_limit;
|
||||
|
||||
struct spa_source *source;
|
||||
struct spa_list servers;
|
||||
|
||||
struct spa_source *cleanup;
|
||||
struct spa_list cleanup_clients;
|
||||
|
||||
struct pw_map samples;
|
||||
struct pw_map modules;
|
||||
|
||||
struct spa_list free_messages;
|
||||
struct defs defs;
|
||||
struct stats stat;
|
||||
};
|
||||
|
||||
/* Functions that modules can use */
|
||||
static void broadcast_subscribe_event(struct impl *impl, uint32_t mask, uint32_t event, uint32_t id);
|
||||
|
||||
static struct server *create_server(struct impl *impl, const char *address);
|
||||
static void server_free(struct server *server);
|
||||
|
||||
#include "collect.c"
|
||||
#include "module.c"
|
||||
#include "message-handler.c"
|
||||
|
|
@ -775,35 +596,35 @@ static int send_object_event(struct client *client, struct pw_manager_object *o,
|
|||
{
|
||||
uint32_t event = 0, mask = 0, res_id = o->id;
|
||||
|
||||
if (object_is_sink(o)) {
|
||||
if (pw_manager_object_is_sink(o)) {
|
||||
send_subscribe_event(client,
|
||||
SUBSCRIPTION_MASK_SINK,
|
||||
SUBSCRIPTION_EVENT_SINK | facility,
|
||||
res_id);
|
||||
}
|
||||
if (object_is_source_or_monitor(o)) {
|
||||
if (!object_is_source(o))
|
||||
if (pw_manager_object_is_source_or_monitor(o)) {
|
||||
if (!pw_manager_object_is_source(o))
|
||||
res_id |= MONITOR_FLAG;
|
||||
mask = SUBSCRIPTION_MASK_SOURCE;
|
||||
event = SUBSCRIPTION_EVENT_SOURCE;
|
||||
}
|
||||
else if (object_is_sink_input(o)) {
|
||||
else if (pw_manager_object_is_sink_input(o)) {
|
||||
mask = SUBSCRIPTION_MASK_SINK_INPUT;
|
||||
event = SUBSCRIPTION_EVENT_SINK_INPUT;
|
||||
}
|
||||
else if (object_is_source_output(o)) {
|
||||
else if (pw_manager_object_is_source_output(o)) {
|
||||
mask = SUBSCRIPTION_MASK_SOURCE_OUTPUT;
|
||||
event = SUBSCRIPTION_EVENT_SOURCE_OUTPUT;
|
||||
}
|
||||
else if (object_is_module(o)) {
|
||||
else if (pw_manager_object_is_module(o)) {
|
||||
mask = SUBSCRIPTION_MASK_MODULE;
|
||||
event = SUBSCRIPTION_EVENT_MODULE;
|
||||
}
|
||||
else if (object_is_client(o)) {
|
||||
else if (pw_manager_object_is_client(o)) {
|
||||
mask = SUBSCRIPTION_MASK_CLIENT;
|
||||
event = SUBSCRIPTION_EVENT_CLIENT;
|
||||
}
|
||||
else if (object_is_card(o)) {
|
||||
else if (pw_manager_object_is_card(o)) {
|
||||
mask = SUBSCRIPTION_MASK_CARD;
|
||||
event = SUBSCRIPTION_EVENT_CARD;
|
||||
} else
|
||||
|
|
@ -845,7 +666,7 @@ static void send_latency_offset_subscribe_event(struct client *client, struct pw
|
|||
int64_t latency_offset = 0LL;
|
||||
bool changed = false;
|
||||
|
||||
if (!object_is_sink(o) && !object_is_source_or_monitor(o))
|
||||
if (!pw_manager_object_is_sink(o) && !pw_manager_object_is_source_or_monitor(o))
|
||||
return;
|
||||
|
||||
/*
|
||||
|
|
@ -933,7 +754,7 @@ static void manager_added(void *data, struct pw_manager_object *o)
|
|||
send_object_event(client, o, SUBSCRIPTION_EVENT_NEW);
|
||||
|
||||
/* Adding sinks etc. may also change defaults */
|
||||
send_default_change_subscribe_event(client, object_is_sink(o), object_is_source_or_monitor(o));
|
||||
send_default_change_subscribe_event(client, pw_manager_object_is_sink(o), pw_manager_object_is_source_or_monitor(o));
|
||||
}
|
||||
|
||||
static void manager_updated(void *data, struct pw_manager_object *o)
|
||||
|
|
@ -943,7 +764,7 @@ static void manager_updated(void *data, struct pw_manager_object *o)
|
|||
send_object_event(client, o, SUBSCRIPTION_EVENT_CHANGE);
|
||||
|
||||
send_latency_offset_subscribe_event(client, o);
|
||||
send_default_change_subscribe_event(client, object_is_sink(o), object_is_source_or_monitor(o));
|
||||
send_default_change_subscribe_event(client, pw_manager_object_is_sink(o), pw_manager_object_is_source_or_monitor(o));
|
||||
}
|
||||
|
||||
static void manager_removed(void *data, struct pw_manager_object *o)
|
||||
|
|
@ -953,7 +774,7 @@ static void manager_removed(void *data, struct pw_manager_object *o)
|
|||
|
||||
send_object_event(client, o, SUBSCRIPTION_EVENT_REMOVE);
|
||||
|
||||
send_default_change_subscribe_event(client, object_is_sink(o), object_is_source_or_monitor(o));
|
||||
send_default_change_subscribe_event(client, pw_manager_object_is_sink(o), pw_manager_object_is_source_or_monitor(o));
|
||||
|
||||
if (strcmp(o->type, PW_TYPE_INTERFACE_Metadata) == 0) {
|
||||
if (o->props != NULL &&
|
||||
|
|
@ -1344,7 +1165,7 @@ static int reply_create_playback_stream(struct stream *stream)
|
|||
TAG_INVALID);
|
||||
|
||||
peer = find_linked(manager, stream->id, stream->direction);
|
||||
if (peer && object_is_sink(peer)) {
|
||||
if (peer && pw_manager_object_is_sink(peer)) {
|
||||
peer_id = peer->id;
|
||||
peer_name = pw_properties_get(peer->props, PW_KEY_NODE_NAME);
|
||||
} else {
|
||||
|
|
@ -1477,11 +1298,11 @@ static int reply_create_record_stream(struct stream *stream)
|
|||
TAG_INVALID);
|
||||
|
||||
peer = find_linked(manager, stream->id, stream->direction);
|
||||
if (peer && object_is_sink_input(peer))
|
||||
if (peer && pw_manager_object_is_sink_input(peer))
|
||||
peer = find_linked(manager, peer->id, PW_DIRECTION_OUTPUT);
|
||||
if (peer && object_is_source_or_monitor(peer)) {
|
||||
if (peer && pw_manager_object_is_source_or_monitor(peer)) {
|
||||
name = pw_properties_get(peer->props, PW_KEY_NODE_NAME);
|
||||
if (!object_is_source(peer)) {
|
||||
if (!pw_manager_object_is_source(peer)) {
|
||||
size_t len = (name ? strlen(name) : 5) + 10;
|
||||
peer_id = peer->id | MONITOR_FLAG;
|
||||
peer_name = tmp = alloca(len);
|
||||
|
|
@ -2719,12 +2540,12 @@ static const char *get_default(struct client *client, bool sink)
|
|||
|
||||
spa_zero(sel);
|
||||
if (sink) {
|
||||
sel.type = object_is_sink;
|
||||
sel.type = pw_manager_object_is_sink;
|
||||
sel.key = PW_KEY_NODE_NAME;
|
||||
sel.value = client->default_sink;
|
||||
def = DEFAULT_SINK;
|
||||
} else {
|
||||
sel.type = object_is_source_or_monitor;
|
||||
sel.type = pw_manager_object_is_source_or_monitor;
|
||||
sel.key = PW_KEY_NODE_NAME;
|
||||
sel.value = client->default_source;
|
||||
def = DEFAULT_SOURCE;
|
||||
|
|
@ -2736,7 +2557,7 @@ static const char *get_default(struct client *client, bool sink)
|
|||
return def;
|
||||
str = pw_properties_get(o->props, PW_KEY_NODE_NAME);
|
||||
|
||||
if (!sink && object_is_monitor(o)) {
|
||||
if (!sink && pw_manager_object_is_monitor(o)) {
|
||||
def = DEFAULT_MONITOR;
|
||||
if (str != NULL &&
|
||||
(mon = pw_properties_get(o->props, PW_KEY_NODE_NAME".monitor")) == NULL) {
|
||||
|
|
@ -2782,10 +2603,10 @@ static struct pw_manager_object *find_device(struct client *client,
|
|||
sel.value = name;
|
||||
|
||||
if (sink) {
|
||||
sel.type = object_is_sink;
|
||||
sel.type = pw_manager_object_is_sink;
|
||||
def = DEFAULT_SINK;
|
||||
} else {
|
||||
sel.type = object_is_source;
|
||||
sel.type = pw_manager_object_is_source;
|
||||
def = DEFAULT_SOURCE;
|
||||
}
|
||||
if (id == SPA_ID_INVALID &&
|
||||
|
|
@ -3190,9 +3011,9 @@ static int do_set_stream_volume(struct client *client, uint32_t command, uint32_
|
|||
spa_zero(sel);
|
||||
sel.id = id;
|
||||
if (command == COMMAND_SET_SINK_INPUT_VOLUME)
|
||||
sel.type = object_is_sink_input;
|
||||
sel.type = pw_manager_object_is_sink_input;
|
||||
else
|
||||
sel.type = object_is_source_output;
|
||||
sel.type = pw_manager_object_is_source_output;
|
||||
|
||||
o = select_object(manager, &sel);
|
||||
if (o == NULL)
|
||||
|
|
@ -3241,9 +3062,9 @@ static int do_set_stream_mute(struct client *client, uint32_t command, uint32_t
|
|||
spa_zero(sel);
|
||||
sel.id = id;
|
||||
if (command == COMMAND_SET_SINK_INPUT_MUTE)
|
||||
sel.type = object_is_sink_input;
|
||||
sel.type = pw_manager_object_is_sink_input;
|
||||
else
|
||||
sel.type = object_is_source_output;
|
||||
sel.type = pw_manager_object_is_source_output;
|
||||
|
||||
o = select_object(manager, &sel);
|
||||
if (o == NULL)
|
||||
|
|
@ -3299,7 +3120,7 @@ static int do_set_volume(struct client *client, uint32_t command, uint32_t tag,
|
|||
if ((str = spa_dict_lookup(info->props, "card.profile.device")) != NULL)
|
||||
dev_info.device = (uint32_t)atoi(str);
|
||||
if (card_id != SPA_ID_INVALID) {
|
||||
struct selector sel = { .id = card_id, .type = object_is_card, };
|
||||
struct selector sel = { .id = card_id, .type = pw_manager_object_is_card, };
|
||||
card = select_object(manager, &sel);
|
||||
}
|
||||
collect_device_info(o, card, &dev_info);
|
||||
|
|
@ -3364,7 +3185,7 @@ static int do_set_mute(struct client *client, uint32_t command, uint32_t tag, st
|
|||
if ((str = spa_dict_lookup(info->props, "card.profile.device")) != NULL)
|
||||
dev_info.device = (uint32_t)atoi(str);
|
||||
if (card_id != SPA_ID_INVALID) {
|
||||
struct selector sel = { .id = card_id, .type = object_is_card, };
|
||||
struct selector sel = { .id = card_id, .type = pw_manager_object_is_card, };
|
||||
card = select_object(manager, &sel);
|
||||
}
|
||||
collect_device_info(o, card, &dev_info);
|
||||
|
|
@ -3425,7 +3246,7 @@ static int do_set_port(struct client *client, uint32_t command, uint32_t tag, st
|
|||
if ((str = spa_dict_lookup(info->props, "card.profile.device")) != NULL)
|
||||
device_id = (uint32_t)atoi(str);
|
||||
if (card_id != SPA_ID_INVALID) {
|
||||
struct selector sel = { .id = card_id, .type = object_is_card, };
|
||||
struct selector sel = { .id = card_id, .type = pw_manager_object_is_card, };
|
||||
card = select_object(manager, &sel);
|
||||
}
|
||||
if (card == NULL || device_id == SPA_ID_INVALID)
|
||||
|
|
@ -3458,7 +3279,7 @@ static int do_set_port_latency_offset(struct client *client, uint32_t command, u
|
|||
|
||||
spa_zero(sel);
|
||||
sel.key = PW_KEY_DEVICE_NAME;
|
||||
sel.type = object_is_card;
|
||||
sel.type = pw_manager_object_is_card;
|
||||
|
||||
if ((res = message_get(m,
|
||||
TAG_U32, &sel.id,
|
||||
|
|
@ -3749,7 +3570,7 @@ static int do_lookup(struct client *client, uint32_t command, uint32_t tag, stru
|
|||
if ((o = find_device(client, SPA_ID_INVALID, name, is_sink)) == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
is_monitor = !is_sink && object_is_monitor(o);
|
||||
is_monitor = !is_sink && pw_manager_object_is_monitor(o);
|
||||
|
||||
reply = reply_new(client, tag);
|
||||
message_put(reply,
|
||||
|
|
@ -3790,7 +3611,7 @@ static int fill_client_info(struct client *client, struct message *m,
|
|||
const char *str;
|
||||
uint32_t module_id = SPA_ID_INVALID;
|
||||
|
||||
if (!object_is_client(o) || info == NULL || info->props == NULL)
|
||||
if (!pw_manager_object_is_client(o) || info == NULL || info->props == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||
|
|
@ -3815,7 +3636,7 @@ static int fill_module_info(struct client *client, struct message *m,
|
|||
{
|
||||
struct pw_module_info *info = o->info;
|
||||
|
||||
if (!object_is_module(o) || info == NULL || info->props == NULL)
|
||||
if (!pw_manager_object_is_module(o) || info == NULL || info->props == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
message_put(m,
|
||||
|
|
@ -3884,7 +3705,7 @@ static int64_t get_port_latency_offset(struct client *client, struct pw_manager_
|
|||
|
||||
if (o->creating || o->removing)
|
||||
continue;
|
||||
if (!object_is_sink(o) && !object_is_source_or_monitor(o))
|
||||
if (!pw_manager_object_is_sink(o) && !pw_manager_object_is_source_or_monitor(o))
|
||||
continue;
|
||||
if ((info = o->info) == NULL || info->props == NULL)
|
||||
continue;
|
||||
|
|
@ -3913,7 +3734,7 @@ static int fill_card_info(struct client *client, struct message *m,
|
|||
struct card_info card_info = CARD_INFO_INIT;
|
||||
struct profile_info *profile_info;
|
||||
|
||||
if (!object_is_card(o) || info == NULL || info->props == NULL)
|
||||
if (!pw_manager_object_is_card(o) || info == NULL || info->props == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||
|
|
@ -4053,7 +3874,7 @@ static int fill_sink_info(struct client *client, struct message *m,
|
|||
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_OUTPUT);
|
||||
size_t size;
|
||||
|
||||
if (!object_is_sink(o) || info == NULL || info->props == NULL)
|
||||
if (!pw_manager_object_is_sink(o) || info == NULL || info->props == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
name = spa_dict_lookup(info->props, PW_KEY_NODE_NAME);
|
||||
|
|
@ -4064,7 +3885,7 @@ static int fill_sink_info(struct client *client, struct message *m,
|
|||
|
||||
size = strlen(name) + 10;
|
||||
monitor_name = alloca(size);
|
||||
if (object_is_source(o))
|
||||
if (pw_manager_object_is_source(o))
|
||||
snprintf(monitor_name, size, "%s", name);
|
||||
else
|
||||
snprintf(monitor_name, size, "%s.monitor", name);
|
||||
|
|
@ -4076,7 +3897,7 @@ static int fill_sink_info(struct client *client, struct message *m,
|
|||
if ((str = spa_dict_lookup(info->props, "card.profile.device")) != NULL)
|
||||
dev_info.device = (uint32_t)atoi(str);
|
||||
if (card_id != SPA_ID_INVALID) {
|
||||
struct selector sel = { .id = card_id, .type = object_is_card, };
|
||||
struct selector sel = { .id = card_id, .type = pw_manager_object_is_card, };
|
||||
card = select_object(manager, &sel);
|
||||
}
|
||||
if (card)
|
||||
|
|
@ -4194,8 +4015,8 @@ static int fill_source_info(struct client *client, struct message *m,
|
|||
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_INPUT);
|
||||
size_t size;
|
||||
|
||||
is_monitor = object_is_monitor(o);
|
||||
if ((!object_is_source(o) && !is_monitor) || info == NULL || info->props == NULL)
|
||||
is_monitor = pw_manager_object_is_monitor(o);
|
||||
if ((!pw_manager_object_is_source(o) && !is_monitor) || info == NULL || info->props == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
name = spa_dict_lookup(info->props, PW_KEY_NODE_NAME);
|
||||
|
|
@ -4220,7 +4041,7 @@ static int fill_source_info(struct client *client, struct message *m,
|
|||
dev_info.device = (uint32_t)atoi(str);
|
||||
|
||||
if (card_id != SPA_ID_INVALID) {
|
||||
struct selector sel = { .id = card_id, .type = object_is_card, };
|
||||
struct selector sel = { .id = card_id, .type = pw_manager_object_is_card, };
|
||||
card = select_object(manager, &sel);
|
||||
}
|
||||
if (card)
|
||||
|
|
@ -4340,7 +4161,7 @@ static int fill_sink_input_info(struct client *client, struct message *m,
|
|||
uint32_t module_id = SPA_ID_INVALID, client_id = SPA_ID_INVALID;
|
||||
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_OUTPUT);
|
||||
|
||||
if (!object_is_sink_input(o) || info == NULL || info->props == NULL)
|
||||
if (!pw_manager_object_is_sink_input(o) || info == NULL || info->props == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||
|
|
@ -4410,7 +4231,7 @@ static int fill_source_output_info(struct client *client, struct message *m,
|
|||
uint32_t peer_id;
|
||||
struct device_info dev_info = DEVICE_INFO_INIT(PW_DIRECTION_INPUT);
|
||||
|
||||
if (!object_is_source_output(o) || info == NULL || info->props == NULL)
|
||||
if (!pw_manager_object_is_source_output(o) || info == NULL || info->props == NULL)
|
||||
return -ENOENT;
|
||||
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
|
||||
|
|
@ -4426,9 +4247,9 @@ static int fill_source_output_info(struct client *client, struct message *m,
|
|||
return -ENOENT;
|
||||
|
||||
peer = find_linked(manager, o->id, PW_DIRECTION_INPUT);
|
||||
if (peer && object_is_source_or_monitor(peer)) {
|
||||
if (peer && pw_manager_object_is_source_or_monitor(peer)) {
|
||||
peer_id = peer->id;
|
||||
if (!object_is_source(peer))
|
||||
if (!pw_manager_object_is_source(peer))
|
||||
peer_id |= MONITOR_FLAG;
|
||||
} else {
|
||||
peer_id = SPA_ID_INVALID;
|
||||
|
|
@ -4501,36 +4322,36 @@ static int do_get_info(struct client *client, uint32_t command, uint32_t tag, st
|
|||
|
||||
switch (command) {
|
||||
case COMMAND_GET_CLIENT_INFO:
|
||||
sel.type = object_is_client;
|
||||
sel.type = pw_manager_object_is_client;
|
||||
fill_func = fill_client_info;
|
||||
break;
|
||||
case COMMAND_GET_MODULE_INFO:
|
||||
sel.type = object_is_module;
|
||||
sel.type = pw_manager_object_is_module;
|
||||
fill_func = fill_module_info;
|
||||
break;
|
||||
case COMMAND_GET_CARD_INFO:
|
||||
sel.type = object_is_card;
|
||||
sel.type = pw_manager_object_is_card;
|
||||
sel.key = PW_KEY_DEVICE_NAME;
|
||||
fill_func = fill_card_info;
|
||||
break;
|
||||
case COMMAND_GET_SINK_INFO:
|
||||
sel.type = object_is_sink;
|
||||
sel.type = pw_manager_object_is_sink;
|
||||
sel.key = PW_KEY_NODE_NAME;
|
||||
fill_func = fill_sink_info;
|
||||
def = DEFAULT_SINK;
|
||||
break;
|
||||
case COMMAND_GET_SOURCE_INFO:
|
||||
sel.type = object_is_source_or_monitor;
|
||||
sel.type = pw_manager_object_is_source_or_monitor;
|
||||
sel.key = PW_KEY_NODE_NAME;
|
||||
fill_func = fill_source_info;
|
||||
def = DEFAULT_SOURCE;
|
||||
break;
|
||||
case COMMAND_GET_SINK_INPUT_INFO:
|
||||
sel.type = object_is_sink_input;
|
||||
sel.type = pw_manager_object_is_sink_input;
|
||||
fill_func = fill_sink_input_info;
|
||||
break;
|
||||
case COMMAND_GET_SOURCE_OUTPUT_INFO:
|
||||
sel.type = object_is_source_output;
|
||||
sel.type = pw_manager_object_is_source_output;
|
||||
fill_func = fill_source_output_info;
|
||||
break;
|
||||
}
|
||||
|
|
@ -4911,7 +4732,7 @@ static int do_set_profile(struct client *client, uint32_t command, uint32_t tag,
|
|||
|
||||
spa_zero(sel);
|
||||
sel.key = PW_KEY_DEVICE_NAME;
|
||||
sel.type = object_is_card;
|
||||
sel.type = pw_manager_object_is_card;
|
||||
|
||||
if ((res = message_get(m,
|
||||
TAG_U32, &sel.id,
|
||||
|
|
@ -5052,7 +4873,7 @@ static int do_move_stream(struct client *client, uint32_t command, uint32_t tag,
|
|||
|
||||
spa_zero(sel);
|
||||
sel.id = id;
|
||||
sel.type = sink ? object_is_sink_input: object_is_source_output;
|
||||
sel.type = sink ? pw_manager_object_is_sink_input: pw_manager_object_is_source_output;
|
||||
|
||||
o = select_object(manager, &sel);
|
||||
if (o == NULL)
|
||||
|
|
@ -5109,13 +4930,13 @@ static int do_kill(struct client *client, uint32_t command, uint32_t tag, struct
|
|||
sel.id = id;
|
||||
switch (command) {
|
||||
case COMMAND_KILL_CLIENT:
|
||||
sel.type = object_is_client;
|
||||
sel.type = pw_manager_object_is_client;
|
||||
break;
|
||||
case COMMAND_KILL_SINK_INPUT:
|
||||
sel.type = object_is_sink_input;
|
||||
sel.type = pw_manager_object_is_sink_input;
|
||||
break;
|
||||
case COMMAND_KILL_SOURCE_OUTPUT:
|
||||
sel.type = object_is_source_output;
|
||||
sel.type = pw_manager_object_is_source_output;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
|
@ -6018,7 +5839,7 @@ get_runtime_dir(char *buf, size_t buflen, const char *dir)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void server_free(struct server *server)
|
||||
void server_free(struct server *server)
|
||||
{
|
||||
struct impl *impl = server->impl;
|
||||
struct client *c;
|
||||
|
|
@ -6238,7 +6059,7 @@ error:
|
|||
return res;
|
||||
}
|
||||
|
||||
static struct server *create_server(struct impl *impl, const char *address)
|
||||
struct server *create_server(struct impl *impl, const char *address)
|
||||
{
|
||||
int fd, res;
|
||||
struct server *server;
|
||||
|
|
|
|||
|
|
@ -22,15 +22,6 @@
|
|||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
struct volume {
|
||||
uint8_t channels;
|
||||
float values[CHANNELS_MAX];
|
||||
};
|
||||
|
||||
#define VOLUME_INIT (struct volume) { \
|
||||
.channels = 0, \
|
||||
}
|
||||
|
||||
static inline bool volume_valid(const struct volume *vol)
|
||||
{
|
||||
if (vol->channels == 0 || vol->channels > CHANNELS_MAX)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue