mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
media-session: add option to enable acp device
This commit is contained in:
parent
1612f5e4d2
commit
0bbc25e3e2
2 changed files with 36 additions and 13 deletions
|
|
@ -115,6 +115,8 @@ struct impl {
|
|||
|
||||
struct spa_source *jack_timeout;
|
||||
struct pw_proxy *jack_device;
|
||||
|
||||
unsigned int use_acp:1;
|
||||
};
|
||||
|
||||
#undef NAME
|
||||
|
|
@ -455,9 +457,13 @@ static int update_device_props(struct device *device)
|
|||
|
||||
static void set_profile(struct device *device, int index)
|
||||
{
|
||||
struct impl *impl = device->impl;
|
||||
char buf[1024];
|
||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buf, sizeof(buf));
|
||||
|
||||
if (impl->use_acp)
|
||||
return;
|
||||
|
||||
pw_log_debug("%p: set profile %d id:%d", device, index, device->device_id);
|
||||
|
||||
if (device->device_id != 0) {
|
||||
|
|
@ -670,7 +676,7 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id,
|
|||
struct spa_handle *handle;
|
||||
int res;
|
||||
void *iface;
|
||||
const char *card;
|
||||
const char *card, *factory_name;
|
||||
|
||||
pw_log_debug("new device %u", id);
|
||||
|
||||
|
|
@ -679,9 +685,13 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (impl->use_acp)
|
||||
factory_name = SPA_NAME_API_ALSA_ACP_DEVICE;
|
||||
else
|
||||
factory_name = info->factory_name;
|
||||
|
||||
handle = pw_context_load_spa_handle(context,
|
||||
info->factory_name,
|
||||
info->props);
|
||||
factory_name, info->props);
|
||||
if (handle == NULL) {
|
||||
res = -errno;
|
||||
pw_log_error("can't make factory instance: %m");
|
||||
|
|
@ -834,6 +844,7 @@ int sm_alsa_monitor_start(struct sm_media_session *session)
|
|||
struct pw_context *context = session->context;
|
||||
struct impl *impl;
|
||||
void *iface;
|
||||
const char *str;
|
||||
int res;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
|
|
@ -842,6 +853,9 @@ int sm_alsa_monitor_start(struct sm_media_session *session)
|
|||
|
||||
impl->session = session;
|
||||
|
||||
if ((str = pw_properties_get(session->props, "alsa.use-acp")) != NULL)
|
||||
impl->use_acp = pw_properties_parse_bool(str);
|
||||
|
||||
if (session->dbus_connection)
|
||||
impl->conn = spa_dbus_connection_get(session->dbus_connection);
|
||||
if (impl->conn == NULL)
|
||||
|
|
|
|||
|
|
@ -1735,16 +1735,18 @@ static const struct {
|
|||
const char *name;
|
||||
const char *desc;
|
||||
int (*start)(struct sm_media_session *sess);
|
||||
const char *props;
|
||||
|
||||
} modules[] = {
|
||||
{ "alsa-seq", "alsa seq midi support", sm_alsa_midi_start },
|
||||
{ "alsa-pcm", "alsa pcm udev detection", sm_alsa_monitor_start },
|
||||
{ "v4l2", "video for linux udev detection", sm_v4l2_monitor_start },
|
||||
{ "libcamera", "libcamera udev detection", sm_libcamera_monitor_start },
|
||||
{ "bluez5", "bluetooth support", sm_bluez5_monitor_start },
|
||||
{ "metadata", "export metadata API", sm_metadata_start },
|
||||
{ "suspend-node", "suspend inactive nodes", sm_suspend_node_start },
|
||||
{ "policy-node", "configure and link nodes", sm_policy_node_start },
|
||||
{ "alsa-seq", "alsa seq midi support", sm_alsa_midi_start, NULL },
|
||||
{ "alsa-pcm", "alsa pcm udev detection", sm_alsa_monitor_start, NULL },
|
||||
{ "alsa-acp", "alsa card profile udev detection", sm_alsa_monitor_start, "alsa.use-acp=true" },
|
||||
{ "v4l2", "video for linux udev detection", sm_v4l2_monitor_start, NULL },
|
||||
{ "libcamera", "libcamera udev detection", sm_libcamera_monitor_start, NULL },
|
||||
{ "bluez5", "bluetooth support", sm_bluez5_monitor_start, NULL },
|
||||
{ "metadata", "export metadata API", sm_metadata_start, NULL },
|
||||
{ "suspend-node", "suspend inactive nodes", sm_suspend_node_start, NULL },
|
||||
{ "policy-node", "configure and link nodes", sm_policy_node_start, NULL },
|
||||
};
|
||||
|
||||
static int opt_contains(const char *opt, const char *val)
|
||||
|
|
@ -1833,9 +1835,8 @@ int main(int argc, char *argv[])
|
|||
if (impl.this.props == NULL)
|
||||
return -1;
|
||||
|
||||
spa_dict_for_each(item, &impl.this.props->dict) {
|
||||
spa_dict_for_each(item, &impl.this.props->dict)
|
||||
pw_log_info(" '%s' = '%s'", item->key, item->value);
|
||||
}
|
||||
|
||||
impl.loop = pw_main_loop_new(NULL);
|
||||
if (impl.loop == NULL)
|
||||
|
|
@ -1882,6 +1883,14 @@ int main(int argc, char *argv[])
|
|||
const char *name = modules[i].name;
|
||||
if (opt_contains(opt_enabled, name) &&
|
||||
!opt_contains(opt_disabled, name)) {
|
||||
if (modules[i].props) {
|
||||
struct pw_properties *props;
|
||||
props = pw_properties_new_string(modules[i].props);
|
||||
if (props) {
|
||||
pw_properties_update(impl.this.props, &props->dict);
|
||||
pw_properties_free(props);
|
||||
}
|
||||
}
|
||||
pw_log_info("enable: %s", name);
|
||||
modules[i].start(&impl.this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue