mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
media-session: move bluetooth properties to bluez config
This commit is contained in:
parent
8ac5a89583
commit
c771bc9b5a
3 changed files with 35 additions and 26 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
# bluez-monitor config file
|
# bluez-monitor config file
|
||||||
properties = {
|
properties = {
|
||||||
|
#bluez5.msbc-support = true
|
||||||
|
#bluez5.sbc-xq-support = true
|
||||||
}
|
}
|
||||||
|
|
||||||
rules = [
|
rules = [
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ properties = {
|
||||||
# Properties to configure the session and some
|
# Properties to configure the session and some
|
||||||
# modules
|
# modules
|
||||||
|
|
||||||
#bluez5.msbc-support = true
|
|
||||||
#bluez5.sbc-xq-support = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spa-libs = {
|
spa-libs = {
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,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;
|
||||||
|
|
||||||
struct spa_handle *handle;
|
struct spa_handle *handle;
|
||||||
|
|
||||||
|
|
@ -491,6 +492,7 @@ static void session_destroy(void *data)
|
||||||
spa_hook_remove(&impl->session_listener);
|
spa_hook_remove(&impl->session_listener);
|
||||||
spa_hook_remove(&impl->listener);
|
spa_hook_remove(&impl->listener);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
@ -502,44 +504,47 @@ static const struct sm_media_session_events session_events = {
|
||||||
|
|
||||||
int sm_bluez5_monitor_start(struct sm_media_session *session)
|
int sm_bluez5_monitor_start(struct sm_media_session *session)
|
||||||
{
|
{
|
||||||
struct spa_handle *handle;
|
|
||||||
struct pw_context *context = session->context;
|
struct pw_context *context = session->context;
|
||||||
int res;
|
int res;
|
||||||
void *iface;
|
void *iface;
|
||||||
struct impl *impl;
|
struct impl *impl;
|
||||||
|
const char *str;
|
||||||
handle = pw_context_load_spa_handle(context, SPA_NAME_API_BLUEZ5_ENUM_DBUS, &session->props->dict);
|
|
||||||
if (handle == NULL) {
|
|
||||||
res = -errno;
|
|
||||||
pw_log_error("can't load %s: %m", SPA_NAME_API_BLUEZ5_ENUM_DBUS);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((res = spa_handle_get_interface(handle, SPA_TYPE_INTERFACE_Device, &iface)) < 0) {
|
|
||||||
pw_log_error("can't get Device interface: %s", spa_strerror(res));
|
|
||||||
goto out_unload;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl = calloc(1, sizeof(struct impl));
|
impl = calloc(1, sizeof(struct impl));
|
||||||
if (impl == NULL) {
|
if (impl == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
goto out_unload;
|
goto out;
|
||||||
}
|
}
|
||||||
impl->conf = pw_properties_new(NULL, NULL);
|
impl->session = session;
|
||||||
if (impl->conf == NULL) {
|
|
||||||
|
if ((impl->conf = pw_properties_new(NULL, NULL)) == NULL) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->session = session;
|
|
||||||
impl->handle = handle;
|
|
||||||
impl->monitor = iface;
|
|
||||||
spa_list_init(&impl->device_list);
|
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
|
impl->handle = pw_context_load_spa_handle(context, SPA_NAME_API_BLUEZ5_ENUM_DBUS, &impl->props->dict);
|
||||||
|
if (impl->handle == NULL) {
|
||||||
|
res = -errno;
|
||||||
|
pw_log_error("can't load %s: %m", SPA_NAME_API_BLUEZ5_ENUM_DBUS);
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
if ((res = spa_handle_get_interface(impl->handle, SPA_TYPE_INTERFACE_Device, &iface)) < 0) {
|
||||||
|
pw_log_error("can't get Device interface: %s", spa_strerror(res));
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
impl->monitor = iface;
|
||||||
|
spa_list_init(&impl->device_list);
|
||||||
|
|
||||||
spa_device_add_listener(impl->monitor, &impl->listener,
|
spa_device_add_listener(impl->monitor, &impl->listener,
|
||||||
&bluez5_enum_callbacks, impl);
|
&bluez5_enum_callbacks, impl);
|
||||||
|
|
||||||
|
|
@ -549,9 +554,13 @@ int sm_bluez5_monitor_start(struct sm_media_session *session)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
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);
|
||||||
out_unload:
|
|
||||||
pw_unload_spa_handle(handle);
|
|
||||||
out:
|
out:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue