mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
policy-node: use the daemon samplerate
Use the samplerate of the daemon to configure the nodes.
This commit is contained in:
parent
852ac043d3
commit
b99074879f
3 changed files with 39 additions and 4 deletions
|
|
@ -55,6 +55,7 @@
|
||||||
|
|
||||||
#define sm_media_session_emit(s,m,v,...) spa_hook_list_call(&(s)->hooks, struct sm_media_session_events, m, v, ##__VA_ARGS__)
|
#define sm_media_session_emit(s,m,v,...) spa_hook_list_call(&(s)->hooks, struct sm_media_session_events, m, v, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
#define sm_media_session_emit_info(s,i) sm_media_session_emit(s, info, 0, i)
|
||||||
#define sm_media_session_emit_create(s,obj) sm_media_session_emit(s, create, 0, obj)
|
#define sm_media_session_emit_create(s,obj) sm_media_session_emit(s, create, 0, obj)
|
||||||
#define sm_media_session_emit_remove(s,obj) sm_media_session_emit(s, remove, 0, obj)
|
#define sm_media_session_emit_remove(s,obj) sm_media_session_emit(s, remove, 0, obj)
|
||||||
#define sm_media_session_emit_rescan(s,seq) sm_media_session_emit(s, rescan, 0, seq)
|
#define sm_media_session_emit_rescan(s,seq) sm_media_session_emit(s, rescan, 0, seq)
|
||||||
|
|
@ -1530,6 +1531,17 @@ static int start_session(struct impl *impl)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void core_info(void *data, const struct pw_core_info *info)
|
||||||
|
{
|
||||||
|
struct impl *impl = data;
|
||||||
|
pw_log_debug(NAME" %p: info", impl);
|
||||||
|
impl->this.info = pw_core_info_update(impl->this.info, info);
|
||||||
|
|
||||||
|
if (impl->this.info->change_mask != 0)
|
||||||
|
sm_media_session_emit_info(impl, impl->this.info);
|
||||||
|
impl->this.info->change_mask = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void core_done(void *data, uint32_t id, int seq)
|
static void core_done(void *data, uint32_t id, int seq)
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
|
|
@ -1574,6 +1586,7 @@ static void core_error(void *data, uint32_t id, int seq, int res, const char *me
|
||||||
|
|
||||||
static const struct pw_core_events core_events = {
|
static const struct pw_core_events core_events = {
|
||||||
PW_VERSION_CORE_EVENTS,
|
PW_VERSION_CORE_EVENTS,
|
||||||
|
.info = core_info,
|
||||||
.done = core_done,
|
.done = core_done,
|
||||||
.error = core_error
|
.error = core_error
|
||||||
};
|
};
|
||||||
|
|
@ -1629,6 +1642,8 @@ static void session_shutdown(struct impl *impl)
|
||||||
pw_core_disconnect(impl->policy_core);
|
pw_core_disconnect(impl->policy_core);
|
||||||
if (impl->monitor_core)
|
if (impl->monitor_core)
|
||||||
pw_core_disconnect(impl->monitor_core);
|
pw_core_disconnect(impl->monitor_core);
|
||||||
|
if (impl->this.info)
|
||||||
|
pw_core_info_free(impl->this.info);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,8 @@ struct sm_media_session_events {
|
||||||
#define SM_VERSION_MEDIA_SESSION_EVENTS 0
|
#define SM_VERSION_MEDIA_SESSION_EVENTS 0
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
|
||||||
|
void (*info) (void *data, const struct pw_core_info *info);
|
||||||
|
|
||||||
void (*create) (void *data, struct sm_object *object);
|
void (*create) (void *data, struct sm_object *object);
|
||||||
void (*remove) (void *data, struct sm_object *object);
|
void (*remove) (void *data, struct sm_object *object);
|
||||||
|
|
||||||
|
|
@ -215,6 +217,8 @@ struct sm_media_session {
|
||||||
struct pw_context *context;
|
struct pw_context *context;
|
||||||
|
|
||||||
struct spa_dbus_connection *dbus_connection;
|
struct spa_dbus_connection *dbus_connection;
|
||||||
|
|
||||||
|
struct pw_core_info *info;
|
||||||
};
|
};
|
||||||
|
|
||||||
int sm_media_session_add_listener(struct sm_media_session *sess, struct spa_hook *listener,
|
int sm_media_session_add_listener(struct sm_media_session *sess, struct spa_hook *listener,
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,6 @@
|
||||||
#define NAME "policy-node"
|
#define NAME "policy-node"
|
||||||
#define SESSION_KEY "policy-node"
|
#define SESSION_KEY "policy-node"
|
||||||
|
|
||||||
#define DEFAULT_CHANNELS 2
|
|
||||||
#define DEFAULT_SAMPLERATE 48000
|
|
||||||
|
|
||||||
#define DEFAULT_IDLE_SECONDS 3
|
#define DEFAULT_IDLE_SECONDS 3
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
|
|
@ -56,6 +53,8 @@ struct impl {
|
||||||
|
|
||||||
struct pw_context *context;
|
struct pw_context *context;
|
||||||
|
|
||||||
|
uint32_t sample_rate;
|
||||||
|
|
||||||
struct spa_list node_list;
|
struct spa_list node_list;
|
||||||
int seq;
|
int seq;
|
||||||
};
|
};
|
||||||
|
|
@ -123,7 +122,7 @@ static int activate_node(struct node *node)
|
||||||
if (node->format.info.raw.channels < info.info.raw.channels)
|
if (node->format.info.raw.channels < info.info.raw.channels)
|
||||||
node->format = info;
|
node->format = info;
|
||||||
}
|
}
|
||||||
node->format.info.raw.rate = 48000;
|
node->format.info.raw.rate = impl->sample_rate;
|
||||||
|
|
||||||
spa_pod_builder_init(&b, buf, sizeof(buf));
|
spa_pod_builder_init(&b, buf, sizeof(buf));
|
||||||
param = spa_format_audio_raw_build(&b, SPA_PARAM_Format, &node->format.info.raw);
|
param = spa_format_audio_raw_build(&b, SPA_PARAM_Format, &node->format.info.raw);
|
||||||
|
|
@ -489,6 +488,20 @@ do_link:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void session_info(void *data, const struct pw_core_info *info)
|
||||||
|
{
|
||||||
|
struct impl *impl = data;
|
||||||
|
|
||||||
|
if (info && (info->change_mask & PW_CORE_CHANGE_MASK_PROPS)) {
|
||||||
|
const char *str;
|
||||||
|
|
||||||
|
if ((str = spa_dict_lookup(info->props, "default.clock.rate")) != NULL)
|
||||||
|
impl->sample_rate = atoi(str);
|
||||||
|
|
||||||
|
pw_log_debug(NAME" %p: props changed sample_rate:%d", impl, impl->sample_rate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void session_rescan(void *data, int seq)
|
static void session_rescan(void *data, int seq)
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
|
|
@ -510,6 +523,7 @@ static void session_destroy(void *data)
|
||||||
|
|
||||||
static const struct sm_media_session_events session_events = {
|
static const struct sm_media_session_events session_events = {
|
||||||
SM_VERSION_MEDIA_SESSION_EVENTS,
|
SM_VERSION_MEDIA_SESSION_EVENTS,
|
||||||
|
.info = session_info,
|
||||||
.create = session_create,
|
.create = session_create,
|
||||||
.remove = session_remove,
|
.remove = session_remove,
|
||||||
.rescan = session_rescan,
|
.rescan = session_rescan,
|
||||||
|
|
@ -527,6 +541,8 @@ int sm_policy_node_start(struct sm_media_session *session)
|
||||||
impl->session = session;
|
impl->session = session;
|
||||||
impl->context = session->context;
|
impl->context = session->context;
|
||||||
|
|
||||||
|
impl->sample_rate = 48000;
|
||||||
|
|
||||||
spa_list_init(&impl->node_list);
|
spa_list_init(&impl->node_list);
|
||||||
|
|
||||||
sm_media_session_add_listener(impl->session, &impl->listener, &session_events, impl);
|
sm_media_session_add_listener(impl->session, &impl->listener, &session_events, impl);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue