media-session: add option to restore bluetooth profile

Add default-profile.restore-bluetooth option to restore the BT
profile.

See #1567
This commit is contained in:
Wim Taymans 2021-09-02 11:39:17 +02:00
parent f277487887
commit 9052b1be33
2 changed files with 8 additions and 1 deletions

View file

@ -11,6 +11,7 @@ context.properties = {
#support.dbus = true
#log.level = 2
#alsa.seq.name = Midi-Bridge
#default-profile.restore-bluetooth = false
}
context.spa-libs = {

View file

@ -95,6 +95,8 @@ struct impl {
struct spa_hook meta_listener;
struct pw_properties *properties;
unsigned int restore_bluetooth:1;
};
struct device {
@ -399,7 +401,7 @@ static void object_update(void *data)
if (dev->obj->info && dev->obj->info->props &&
(str = spa_dict_lookup(dev->obj->info->props, PW_KEY_DEVICE_BUS)) != NULL &&
spa_streq(str, "bluetooth"))
spa_streq(str, "bluetooth") && !impl->restore_bluetooth)
return;
if (dev->obj->obj.changed & SM_DEVICE_CHANGE_MASK_PARAMS)
@ -479,6 +481,7 @@ int sm_default_profile_start(struct sm_media_session *session)
{
struct impl *impl;
int res;
const char *str;
impl = calloc(1, sizeof(struct impl));
if (impl == NULL)
@ -493,6 +496,9 @@ int sm_default_profile_start(struct sm_media_session *session)
return -ENOMEM;
}
if ((str = pw_properties_get(session->props, "default-profile.restore-bluetooth")) != NULL)
impl->restore_bluetooth = pw_properties_parse_bool(str);
if ((res = sm_media_session_load_state(impl->session,
SESSION_KEY, impl->properties)) < 0)
pw_log_info("can't load "SESSION_KEY" state: %s", spa_strerror(res));