diff --git a/lib/wp/component-loader.c b/lib/wp/component-loader.c index 539f6f2b..ddd0955a 100644 --- a/lib/wp/component-loader.c +++ b/lib/wp/component-loader.c @@ -54,8 +54,8 @@ load_module (WpCore * core, const gchar * module_name, GModule *gmodule; gpointer module_init; - wp_debug_object(core, "loading module(%s)", module_name); module_path = g_module_build_path (wp_get_module_dir (), module_name); + wp_debug_object(core, "loading module(%s) at %s", module_name, module_path); gmodule = g_module_open (module_path, G_MODULE_BIND_LOCAL); if (!gmodule) { g_set_error (error, WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_OPERATION_FAILED, diff --git a/src/config/bluetooth.lua.d/00-functions.lua b/src/config/bluetooth.lua.d/00-functions.lua deleted file mode 120000 index 8334af3b..00000000 --- a/src/config/bluetooth.lua.d/00-functions.lua +++ /dev/null @@ -1 +0,0 @@ -../common/00-functions.lua \ No newline at end of file diff --git a/src/config/bluetooth.lua.d/30-bluez-monitor.lua b/src/config/bluetooth.lua.d/30-bluez-monitor.lua deleted file mode 100644 index a1a7e073..00000000 --- a/src/config/bluetooth.lua.d/30-bluez-monitor.lua +++ /dev/null @@ -1,14 +0,0 @@ -bluez_monitor = {} -bluez_monitor.properties = {} -bluez_monitor.rules = {} - -function bluez_monitor.enable() - -- load_monitor("bluez", { - -- properties = bluez_monitor.properties, - -- rules = bluez_monitor.rules, - -- }) - - if bluez_monitor.properties["with-logind"] then - load_optional_module("logind") - end -end diff --git a/src/config/bluetooth.lua.d/50-bluez-config.lua b/src/config/bluetooth.lua.d/50-bluez-config.lua deleted file mode 100644 index f4334064..00000000 --- a/src/config/bluetooth.lua.d/50-bluez-config.lua +++ /dev/null @@ -1,141 +0,0 @@ -bluez_monitor.enabled = true - -bluez_monitor.properties = { - -- Enabled roles (default: [ a2dp_sink a2dp_source bap_sink bap_source hfp_hf hfp_ag ]) - -- - -- Currently some headsets (Sony WH-1000XM3) are not working with - -- both hsp_ag and hfp_ag enabled, so by default we enable only HFP. - -- - -- Supported roles: hsp_hs (HSP Headset), - -- hsp_ag (HSP Audio Gateway), - -- hfp_hf (HFP Hands-Free), - -- hfp_ag (HFP Audio Gateway) - -- a2dp_sink (A2DP Audio Sink) - -- a2dp_source (A2DP Audio Source) - -- bap_sink (LE Audio Basic Audio Profile Sink) - -- bap_source (LE Audio Basic Audio Profile Source) - --["bluez5.roles"] = "[ a2dp_sink a2dp_source bap_sink bap_source hsp_hs hsp_ag hfp_hf hfp_ag ]", - - -- Enabled A2DP codecs (default: all). - --["bluez5.codecs"] = "[ sbc sbc_xq aac ldac aptx aptx_hd aptx_ll aptx_ll_duplex faststream faststream_duplex ]", - - -- HFP/HSP backend (default: native). - -- Available values: any, none, hsphfpd, ofono, native - --["bluez5.hfphsp-backend"] = "native", - - -- HFP/HSP native backend modem (default: none). - -- Available values: none, any or the modem device string as found in - -- 'Device' property of org.freedesktop.ModemManager1.Modem interface - --["bluez5.hfphsp-backend-native-modem"] = "none", - - -- HFP/HSP hardware offload SCO support (default: false). - --["bluez5.hw-offload-sco"] = false, - - -- Properties for the A2DP codec configuration - --["bluez5.default.rate"] = 48000, - --["bluez5.default.channels"] = 2, - - -- Register dummy AVRCP player, required for AVRCP volume function. - -- Disable if you are running mpris-proxy or equivalent. - --["bluez5.dummy-avrcp-player"] = true, - - -- Opus Pro Audio mode settings - --["bluez5.a2dp.opus.pro.channels"] = 3, -- no. channels - --["bluez5.a2dp.opus.pro.coupled-streams"] = 1, -- no. joint stereo pairs, see RFC 7845 Sec. 5.1.1 - --["bluez5.a2dp.opus.pro.locations"] = "FL,FR,LFE", -- audio locations - --["bluez5.a2dp.opus.pro.max-bitrate"] = 600000, - --["bluez5.a2dp.opus.pro.frame-dms"] = 50, -- frame duration in 1/10 ms: 25, 50, 100, 200, 400 - --["bluez5.a2dp.opus.pro.bidi.channels"] = 1, -- same settings for the return direction - --["bluez5.a2dp.opus.pro.bidi.coupled-streams"] = 0, - --["bluez5.a2dp.opus.pro.bidi.locations"] = "FC", - --["bluez5.a2dp.opus.pro.bidi.max-bitrate"] = 160000, - --["bluez5.a2dp.opus.pro.bidi.frame-dms"] = 400, - - -- Enable the logind module, which arbitrates which user will be allowed - -- to have bluetooth audio enabled at any given time (particularly useful - -- if you are using GDM as a display manager, as the gdm user also launches - -- pipewire and wireplumber). - -- This requires access to the D-Bus user session; disable if you are running - -- a system-wide instance of wireplumber. - ["with-logind"] = true, - - -- The settings below can be used to override feature enabled status. By default - -- all of them are enabled. They may also be disabled via the hardware quirk - -- database, see bluez-hardware.conf - --["bluez5.enable-sbc-xq"] = true, - --["bluez5.enable-msbc"] = true, - --["bluez5.enable-hw-volume"] = true, -} - -bluez_monitor.rules = { - -- An array of matches/actions to evaluate. - { - -- Rules for matching a device or node. It is an array of - -- properties that all need to match the regexp. If any of the - -- matches work, the actions are executed for the object. - matches = { - { - -- This matches all cards. - { "device.name", "matches", "bluez_card.*" }, - }, - }, - -- Apply properties on the matched object. - apply_properties = { - -- Auto-connect device profiles on start up or when only partial - -- profiles have connected. Disabled by default if the property - -- is not specified. - --["bluez5.auto-connect"] = "[ hfp_hf hsp_hs a2dp_sink hfp_ag hsp_ag a2dp_source ]", - ["bluez5.auto-connect"] = "[ hfp_hf hsp_hs a2dp_sink ]", - - -- Hardware volume control (default: [ hfp_ag hsp_ag a2dp_source ]) - --["bluez5.hw-volume"] = "[ hfp_hf hsp_hs a2dp_sink hfp_ag hsp_ag a2dp_source ]", - - -- LDAC encoding quality - -- Available values: auto (Adaptive Bitrate, default) - -- hq (High Quality, 990/909kbps) - -- sq (Standard Quality, 660/606kbps) - -- mq (Mobile use Quality, 330/303kbps) - --["bluez5.a2dp.ldac.quality"] = "auto", - - -- AAC variable bitrate mode - -- Available values: 0 (cbr, default), 1-5 (quality level) - --["bluez5.a2dp.aac.bitratemode"] = 0, - - -- Profile connected first - -- Available values: a2dp-sink (default), headset-head-unit - --["device.profile"] = "a2dp-sink", - - -- Opus Pro Audio encoding mode: audio, voip, lowdelay - --["bluez5.a2dp.opus.pro.application"] = "audio", - --["bluez5.a2dp.opus.pro.bidi.application"] = "audio", - }, - }, - { - matches = { - { - -- Matches all sources. - { "node.name", "matches", "bluez_input.*" }, - }, - { - -- Matches all sinks. - { "node.name", "matches", "bluez_output.*" }, - }, - }, - apply_properties = { - --["node.nick"] = "My Node", - --["priority.driver"] = 100, - --["priority.session"] = 100, - --["node.pause-on-idle"] = false, - --["resample.quality"] = 4, - --["channelmix.normalize"] = false, - --["channelmix.mix-lfe"] = false, - --["session.suspend-timeout-seconds"] = 5, -- 0 disables suspend - --["monitor.channel-volumes"] = false, - - -- Media source role, "input" or "playback" - -- Defaults to "playback", playing stream to speakers - -- Set to "input" to use as an input for apps - --["bluez5.media-source-role"] = "input", - }, - }, -} diff --git a/src/config/bluetooth.lua.d/90-enable-all.lua b/src/config/bluetooth.lua.d/90-enable-all.lua deleted file mode 100644 index 68721d64..00000000 --- a/src/config/bluetooth.lua.d/90-enable-all.lua +++ /dev/null @@ -1,2 +0,0 @@ --- bluez_monitor.enable() --- bluez_midi_monitor.enable() diff --git a/src/config/wireplumber.conf b/src/config/wireplumber.conf index a3c862b7..550cf777 100644 --- a/src/config/wireplumber.conf +++ b/src/config/wireplumber.conf @@ -98,7 +98,6 @@ wireplumber.components = [ # The lua configuration file(s) # Other components are loaded from there { name = policy.lua, type = config/lua } - { name = bluetooth.lua, type = config/lua } ] wireplumber.settings = { diff --git a/src/config/wireplumber.conf.d/bluetooth-settings.conf b/src/config/wireplumber.conf.d/bluetooth-settings.conf index 96860693..c317a76e 100644 --- a/src/config/wireplumber.conf.d/bluetooth-settings.conf +++ b/src/config/wireplumber.conf.d/bluetooth-settings.conf @@ -1,6 +1,10 @@ wireplumber.components = [ { name = monitors/bluez.lua, type = script/lua } { name = monitors/bluez-midi.lua, type = script/lua } + + # If ifexists is given, the module is ignored when it is not found. + # If nofail is given, module initialization failures are ignored. + { name = libwireplumber-module-logind , type = module, deps = with-logind, flags = [ ifexists ] } ] wireplumber.settings = { @@ -12,18 +16,20 @@ wireplumber.settings = { # bluez5.enable-msbc = true # bluez5.enable-hw-volume = true - # See bluez-hardware.conf for the hardware database. - - # Enabled headset roles (default: [ hsp_hs hfp_ag ]), this - # property only applies to native backend. Currently some headsets - # (Sony WH-1000XM3) are not working with both hsp_ag and hfp_ag - # enabled, disable either hsp_ag or hfp_ag to work around it. - - # Supported headset roles: hsp_hs (HSP Headset), - # hsp_ag (HSP Audio Gateway), - # hfp_hf (HFP Hands-Free), - # hfp_ag (HFP Audio Gateway) - # bluez5.headset-roles = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]" + # Enabled roles (default: [ a2dp_sink a2dp_source bap_sink bap_source hfp_hf hfp_ag ]) + # + # Currently some headsets (Sony WH-1000XM3) are not working with + # both hsp_ag and hfp_ag enabled, so by default we enable only HFP. + # + # Supported roles: hsp_hs (HSP Headset), + # hsp_ag (HSP Audio Gateway), + # hfp_hf (HFP Hands-Free), + # hfp_ag (HFP Audio Gateway) + # a2dp_sink (A2DP Audio Sink) + # a2dp_source (A2DP Audio Source) + # bap_sink (LE Audio Basic Audio Profile Sink) + # bap_source (LE Audio Basic Audio Profile Source) + # bluez5.roles = "[ a2dp_sink a2dp_source bap_sink bap_source hsp_hs hsp_ag hfp_hf hfp_ag ]" # Enabled A2DP codecs (default: all). # bluez5.codecs = "[ sbc sbc_xq aac ldac aptx aptx_hd aptx_ll aptx_ll_duplex faststream faststream_duplex ]" @@ -34,7 +40,7 @@ wireplumber.settings = { # HFP/HSP native backend modem (default: none). # Available values: none, any or the modem device string as found in - # 'Device' property of org.freedesktop.ModemManager1.Modem interface + # 'Device' property of org.freedesktop.ModemManager1.Modem interface # bluez5.hfphsp-backend-native-modem = "none" # HFP/HSP hardware offload SCO support (default: false). diff --git a/src/main.c b/src/main.c index 4d45c2a1..6bc86d0b 100644 --- a/src/main.c +++ b/src/main.c @@ -165,6 +165,9 @@ do_load_components(void *data, const char *location, const char *section, g_autofree gchar *name = NULL; g_autofree gchar *type = NULL; g_autofree gchar *deps = NULL; + WpSpaJson *flags = NULL; + gboolean if_exists = FALSE; + gboolean no_fail = FALSE; if (!wp_spa_json_is_object (o) || !wp_spa_json_object_get (o, @@ -187,9 +190,37 @@ do_load_components(void *data, const char *location, const char *section, } } - wp_debug ("load component(%s) type(%s) deps(%s)", name, type, - (deps ? deps : "nill")); + if (wp_spa_json_object_get (o, "flags", "J", &flags, NULL) && flags) { + g_autofree gchar *s1 = NULL; + g_autofree gchar *s2 = NULL; + + wp_spa_json_parse_array (flags, "s", &s1, "s", &s2, NULL); + + if (!g_strcmp0 (s1, "ifexists") || !g_strcmp0 (s2, "ifexists")) + if_exists = TRUE; + if (!g_strcmp0 (s1, "nofail") || !g_strcmp0 (s2, "nofail")) + no_fail = TRUE; + } + + wp_debug ("load component(%s) type(%s) deps(%s) ifexists(%d) nofail(%d)", + name, type, deps, if_exists, no_fail); + if (!wp_core_load_component (core, name, type, NULL, &error)) { + wp_info ("%s", error->message); + if ((error->code == G_FILE_ERROR_NOENT) || + (error->code == G_FILE_ERROR_ACCES)) { + + if (if_exists) { + wp_info ("\"ifexists\" flag set, ignore the failure"); + g_clear_error (&error); + continue; + } + + } else if (no_fail) { + wp_info ("\"nofail\" flag set, ignore the failure"); + g_clear_error (&error); + continue; + } wp_transition_return_error (transition, error); return -EINVAL; }