mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
Pass some more properties around
Only start listener when core is a daemon.
This commit is contained in:
parent
4f9d631910
commit
83b4eaca53
7 changed files with 42 additions and 17 deletions
|
|
@ -152,6 +152,9 @@ struct spa_fraction {
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define SPA_STRINGIFY_1(x...) #x
|
||||
#define SPA_STRINGIFY(x...) SPA_STRINGIFY_1(x)
|
||||
|
||||
#define spa_return_if_fail(expr) \
|
||||
do { \
|
||||
if (SPA_UNLIKELY(!(expr))) \
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ int main(int argc, char *argv[])
|
|||
struct pw_main_loop *loop;
|
||||
struct pw_daemon_config *config;
|
||||
char *err = NULL;
|
||||
struct pw_properties *props;
|
||||
|
||||
pw_init(&argc, &argv);
|
||||
|
||||
|
|
@ -42,7 +43,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
loop = pw_main_loop_new();
|
||||
|
||||
core = pw_core_new(loop->loop, NULL);
|
||||
props = pw_properties_new("pipewire.core.name", "pipewire-0",
|
||||
"pipewire.daemon", "1", NULL);
|
||||
|
||||
core = pw_core_new(loop->loop, props);
|
||||
|
||||
pw_daemon_config_run_commands(config, core);
|
||||
|
||||
|
|
|
|||
|
|
@ -395,7 +395,6 @@ get_name(struct pw_properties *properties)
|
|||
name = getenv("PIPEWIRE_CORE");
|
||||
if (name == NULL)
|
||||
name = "pipewire-0";
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
@ -411,10 +410,7 @@ static int impl_connect(struct pw_protocol_connection *conn)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (name == NULL)
|
||||
name = getenv("PIPEWIRE_CORE");
|
||||
if (name == NULL)
|
||||
name = "pipewire-0";
|
||||
name = get_name(NULL);
|
||||
|
||||
if ((fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) < 0)
|
||||
return -1;
|
||||
|
|
@ -614,7 +610,7 @@ impl_add_listener(struct pw_protocol *protocol,
|
|||
l->fd = -1;
|
||||
l->fd_lock = -1;
|
||||
|
||||
name = get_name(properties);
|
||||
name = get_name(core->properties);
|
||||
|
||||
if (!init_socket_name(l, name))
|
||||
goto error;
|
||||
|
|
@ -643,6 +639,7 @@ impl_add_listener(struct pw_protocol *protocol,
|
|||
static struct impl *pw_protocol_native_new(struct pw_core *core, struct pw_properties *properties)
|
||||
{
|
||||
struct impl *impl;
|
||||
const char *val;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
|
||||
|
|
@ -656,8 +653,10 @@ static struct impl *pw_protocol_native_new(struct pw_core *core, struct pw_prope
|
|||
|
||||
spa_list_init(&impl->client_list);
|
||||
|
||||
if ((val = pw_properties_get(core->properties, "pipewire.daemon"))) {
|
||||
if (atoi(val) == 1)
|
||||
impl_add_listener(impl->protocol, core, properties);
|
||||
|
||||
}
|
||||
return impl;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <spa/lib/debug.h>
|
||||
|
|
@ -273,6 +274,7 @@ core_bind_func(struct pw_global *global, struct pw_client *client, uint32_t vers
|
|||
|
||||
this->info.change_mask = PW_CORE_CHANGE_MASK_ALL;
|
||||
pw_core_notify_info(resource, &this->info);
|
||||
this->info.change_mask = 0;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
|
||||
|
|
@ -293,6 +295,7 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
|
|||
{
|
||||
struct impl *impl;
|
||||
struct pw_core *this;
|
||||
const char *name;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
if (impl == NULL)
|
||||
|
|
@ -305,7 +308,6 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
|
|||
|
||||
this->data_loop = impl->data_loop->loop;
|
||||
this->main_loop = main_loop;
|
||||
this->properties = properties;
|
||||
|
||||
pw_type_init(&this->type);
|
||||
pw_map_init(&this->objects, 128, 32);
|
||||
|
|
@ -344,12 +346,21 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
|
|||
this->info.change_mask = 0;
|
||||
this->info.user_name = pw_get_user_name();
|
||||
this->info.host_name = pw_get_host_name();
|
||||
this->info.version = "0";
|
||||
this->info.name = "pipewire-0";
|
||||
this->info.version = SPA_STRINGIFY(PW_VERSION_CORE);
|
||||
srandom(time(NULL));
|
||||
this->info.cookie = random();
|
||||
this->info.props = this->properties ? &this->properties->dict : NULL;
|
||||
|
||||
if (properties == NULL)
|
||||
properties = pw_properties_new(NULL, NULL);
|
||||
if ((name = pw_properties_get(properties, "pipewire.core.name")) == NULL) {
|
||||
pw_properties_setf(properties,
|
||||
"pipewire.core.name", "pipewire-%s-%d",
|
||||
pw_get_user_name(), getpid());
|
||||
}
|
||||
this->info.name = pw_properties_get(properties, "pipewire.core.name");
|
||||
this->properties = properties;
|
||||
|
||||
return this;
|
||||
|
||||
no_data_loop:
|
||||
|
|
@ -522,6 +533,7 @@ void pw_core_update_properties(struct pw_core *core, const struct spa_dict *dict
|
|||
spa_list_for_each(resource, &core->resource_list, link) {
|
||||
pw_core_notify_info(resource, &core->info);
|
||||
}
|
||||
core->info.change_mask = 0;
|
||||
}
|
||||
|
||||
/** Find a port to link with
|
||||
|
|
|
|||
|
|
@ -298,8 +298,10 @@ char *pw_get_client_name(void)
|
|||
*
|
||||
* \memberof pw_pipewire
|
||||
*/
|
||||
void pw_fill_remote_properties(struct pw_properties *properties)
|
||||
void pw_fill_remote_properties(struct pw_core *core, struct pw_properties *properties)
|
||||
{
|
||||
const char *val;
|
||||
|
||||
if (!pw_properties_get(properties, "application.name"))
|
||||
pw_properties_set(properties, "application.name", pw_get_application_name());
|
||||
|
||||
|
|
@ -322,6 +324,11 @@ void pw_fill_remote_properties(struct pw_properties *properties)
|
|||
pw_properties_set(properties, "application.process.session_id",
|
||||
getenv("XDG_SESSION_ID"));
|
||||
}
|
||||
pw_properties_set(properties, "pipewire.core.version", core->info.version);
|
||||
pw_properties_set(properties, "pipewire.core.name", core->info.name);
|
||||
|
||||
if ((val = pw_properties_get(core->properties, "pipewire.daemon")))
|
||||
pw_properties_set(properties, "pipewire.daemon", val);
|
||||
}
|
||||
|
||||
/** Fill stream properties
|
||||
|
|
@ -331,7 +338,7 @@ void pw_fill_remote_properties(struct pw_properties *properties)
|
|||
*
|
||||
* \memberof pw_pipewire
|
||||
*/
|
||||
void pw_fill_stream_properties(struct pw_properties *properties)
|
||||
void pw_fill_stream_properties(struct pw_core *core, struct pw_properties *properties)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,10 +109,10 @@ char *
|
|||
pw_get_client_name(void);
|
||||
|
||||
void
|
||||
pw_fill_remote_properties(struct pw_properties *properties);
|
||||
pw_fill_remote_properties(struct pw_core *core, struct pw_properties *properties);
|
||||
|
||||
void
|
||||
pw_fill_stream_properties(struct pw_properties *properties);
|
||||
pw_fill_stream_properties(struct pw_core *core, struct pw_properties *properties);
|
||||
|
||||
enum pw_direction
|
||||
pw_direction_reverse(enum pw_direction direction);
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ struct pw_remote *pw_remote_new(struct pw_core *core,
|
|||
if (properties == NULL)
|
||||
goto no_mem;
|
||||
|
||||
pw_fill_remote_properties(properties);
|
||||
pw_fill_remote_properties(core, properties);
|
||||
this->properties = properties;
|
||||
|
||||
this->state = PW_REMOTE_STATE_UNCONNECTED;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue