mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
media-session: add alsa.jack-device property to alsa-monitor
This commit is contained in:
parent
c3d4eea6ca
commit
2c4c78c51e
3 changed files with 31 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
# alsa-monitor config file
|
# alsa-monitor config file
|
||||||
properties = {
|
properties = {
|
||||||
|
#alsa.jack-device = true
|
||||||
}
|
}
|
||||||
|
|
||||||
rules = [
|
rules = [
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ properties = {
|
||||||
# Properties to configure the session and some
|
# Properties to configure the session and some
|
||||||
# modules
|
# modules
|
||||||
#mem.mlock-all = false
|
#mem.mlock-all = false
|
||||||
|
#context.profile.modules = default,rtkit
|
||||||
}
|
}
|
||||||
|
|
||||||
spa-libs = {
|
spa-libs = {
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,7 @@ struct impl {
|
||||||
struct spa_hook session_listener;
|
struct spa_hook session_listener;
|
||||||
|
|
||||||
struct pw_properties *conf;
|
struct pw_properties *conf;
|
||||||
|
struct pw_properties *props;
|
||||||
|
|
||||||
DBusConnection *conn;
|
DBusConnection *conn;
|
||||||
|
|
||||||
|
|
@ -963,8 +964,10 @@ static int alsa_start_jack_device(struct impl *impl)
|
||||||
&props->dict,
|
&props->dict,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (impl->jack_device == NULL)
|
if (impl->jack_device == NULL) {
|
||||||
|
pw_log_error("can't create JACK Device: %m");
|
||||||
res = -errno;
|
res = -errno;
|
||||||
|
}
|
||||||
|
|
||||||
pw_properties_free(props);
|
pw_properties_free(props);
|
||||||
|
|
||||||
|
|
@ -977,8 +980,10 @@ static void session_destroy(void *data)
|
||||||
remove_jack_timeout(impl);
|
remove_jack_timeout(impl);
|
||||||
spa_hook_remove(&impl->session_listener);
|
spa_hook_remove(&impl->session_listener);
|
||||||
spa_hook_remove(&impl->listener);
|
spa_hook_remove(&impl->listener);
|
||||||
pw_proxy_destroy(impl->jack_device);
|
if (impl->jack_device)
|
||||||
|
pw_proxy_destroy(impl->jack_device);
|
||||||
pw_unload_spa_handle(impl->handle);
|
pw_unload_spa_handle(impl->handle);
|
||||||
|
pw_properties_free(impl->props);
|
||||||
pw_properties_free(impl->conf);
|
pw_properties_free(impl->conf);
|
||||||
free(impl);
|
free(impl);
|
||||||
}
|
}
|
||||||
|
|
@ -994,6 +999,7 @@ int sm_alsa_monitor_start(struct sm_media_session *session)
|
||||||
struct impl *impl;
|
struct impl *impl;
|
||||||
void *iface;
|
void *iface;
|
||||||
int res;
|
int res;
|
||||||
|
const char *str;
|
||||||
|
|
||||||
impl = calloc(1, sizeof(struct impl));
|
impl = calloc(1, sizeof(struct impl));
|
||||||
if (impl == NULL)
|
if (impl == NULL)
|
||||||
|
|
@ -1002,14 +1008,21 @@ int sm_alsa_monitor_start(struct sm_media_session *session)
|
||||||
impl->session = session;
|
impl->session = session;
|
||||||
impl->conf = pw_properties_new(NULL, NULL);
|
impl->conf = pw_properties_new(NULL, NULL);
|
||||||
if (impl->conf == NULL) {
|
if (impl->conf == NULL) {
|
||||||
free(impl);
|
res = -errno;
|
||||||
return -errno;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res = sm_media_session_load_conf(impl->session,
|
if ((res = sm_media_session_load_conf(impl->session,
|
||||||
SESSION_CONF, impl->conf)) < 0)
|
SESSION_CONF, impl->conf)) < 0)
|
||||||
pw_log_info("can't load "SESSION_CONF" config: %s", spa_strerror(res));
|
pw_log_info("can't load "SESSION_CONF" config: %s", spa_strerror(res));
|
||||||
|
|
||||||
|
if ((impl->props = pw_properties_new(NULL, NULL)) == NULL) {
|
||||||
|
res = -errno;
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
if ((str = pw_properties_get(impl->conf, "properties")) != NULL)
|
||||||
|
pw_properties_update_string(impl->props, str, strlen(str));
|
||||||
|
|
||||||
if (session->dbus_connection)
|
if (session->dbus_connection)
|
||||||
impl->conn = spa_dbus_connection_get(session->dbus_connection);
|
impl->conn = spa_dbus_connection_get(session->dbus_connection);
|
||||||
if (impl->conn == NULL)
|
if (impl->conn == NULL)
|
||||||
|
|
@ -1017,7 +1030,6 @@ int sm_alsa_monitor_start(struct sm_media_session *session)
|
||||||
else
|
else
|
||||||
pw_log_debug("got dbus connection %p", impl->conn);
|
pw_log_debug("got dbus connection %p", impl->conn);
|
||||||
|
|
||||||
|
|
||||||
impl->handle = pw_context_load_spa_handle(context, SPA_NAME_API_ALSA_ENUM_UDEV, NULL);
|
impl->handle = pw_context_load_spa_handle(context, SPA_NAME_API_ALSA_ENUM_UDEV, NULL);
|
||||||
if (impl->handle == NULL) {
|
if (impl->handle == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
|
|
@ -1026,22 +1038,29 @@ int sm_alsa_monitor_start(struct sm_media_session *session)
|
||||||
|
|
||||||
if ((res = spa_handle_get_interface(impl->handle, SPA_TYPE_INTERFACE_Device, &iface)) < 0) {
|
if ((res = spa_handle_get_interface(impl->handle, SPA_TYPE_INTERFACE_Device, &iface)) < 0) {
|
||||||
pw_log_error("can't get udev Device interface: %d", res);
|
pw_log_error("can't get udev Device interface: %d", res);
|
||||||
goto out_unload;
|
goto out_free;
|
||||||
}
|
}
|
||||||
impl->monitor = iface;
|
impl->monitor = iface;
|
||||||
spa_list_init(&impl->device_list);
|
spa_list_init(&impl->device_list);
|
||||||
spa_device_add_listener(impl->monitor, &impl->listener, &alsa_udev_events, impl);
|
spa_device_add_listener(impl->monitor, &impl->listener, &alsa_udev_events, impl);
|
||||||
|
|
||||||
if ((res = alsa_start_jack_device(impl)) < 0)
|
if ((str = pw_properties_get(impl->props, "alsa.jack-device")) == NULL ||
|
||||||
goto out_unload;
|
pw_properties_parse_bool(str)) {
|
||||||
|
if ((res = alsa_start_jack_device(impl)) < 0)
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
|
||||||
sm_media_session_add_listener(session, &impl->session_listener, &session_events, impl);
|
sm_media_session_add_listener(session, &impl->session_listener, &session_events, impl);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_unload:
|
|
||||||
pw_unload_spa_handle(impl->handle);
|
|
||||||
out_free:
|
out_free:
|
||||||
|
if (impl->handle)
|
||||||
|
pw_unload_spa_handle(impl->handle);
|
||||||
|
if (impl->conf)
|
||||||
|
pw_properties_free(impl->conf);
|
||||||
|
if (impl->props)
|
||||||
|
pw_properties_free(impl->props);
|
||||||
free(impl);
|
free(impl);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue