Skip to content

Conversation

@GeopJr
Copy link
Owner

@GeopJr GeopJr commented May 23, 2025

fix: #1431


#if CLAPPER_0_10
private bool enhancer_check (string scheme, string? t_host = null) {
if (!Clapper.WITH_ENHANCERS_LOADER) return false;
Copy link
Contributor

@Rafostar Rafostar May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for information, this is fine cause it might save you from calling .substring (4) below in a (I guess rare) situation where Clapper is compiled without this option, so you can leave it as-is. But other than that (including compiled with but none installed) it is perfectly safe for applications to call Clapper.get_global_enhancer_proxies() - in this case returned GListModel will simply have zero elements and for loop would not execute.

@GeopJr
Copy link
Owner Author

GeopJr commented May 23, 2025

extra_data_lists_value

Ohhh, I didn't read the description, I just assumed it would only check the whole value and not treat them as a list, so I dismissed it instantly 😔... Much better than splitting and all!


It doesn't look like it matters and it's too early to do optimizations since the API is not done, but I do wonder if it's worth keeping some sort of 'cache'.

E.g.

"https", "youtube.com": passed
"peertube", null: failed

Keep that in memory and next time those combinations of scheme and host are checked, instantly return whether it's supported from memory instead of checking all plugins again

@Rafostar
Copy link
Contributor

It doesn't look like it matters and it's too early to do optimizations since the API is not done, but I do wonder if it's worth keeping some sort of 'cache'.

I thought about this too, but unsure how much of a boost you would get here to be worth it. These strings are read during init, then stored in enhancer proxy object, so there is no string dup/free going on. Just saving the amount of time it takes to iterate (currently) up to 3 elements array.

GeopJr and others added 2 commits May 24, 2025 04:32
Co-authored-by: Rafał Dzięgiel <rafostar.github@gmail.com>
Co-authored-by: Rafał Dzięgiel <rafostar.github@gmail.com>
@GeopJr
Copy link
Owner Author

GeopJr commented Jul 12, 2025

In regards of MPRIS moving to enhancers, is there anything I should do here?

@Rafostar
Copy link
Contributor

Rafostar commented Jul 12, 2025

In regards of MPRIS moving to enhancers, is there anything I should do here?

Built-in ClapperFeature objects are on their deprecation way in favour of being re-implemented as enhancer plugins. This work is currently still ongoing, so APIs for that are still subject to change. I am trying to keep compatibility, so even if your app does not update from using old (now deprecated) implementation it should still work.

@Rafostar
Copy link
Contributor

Currently something like this:

#if CLAPPER_HAVE_MPRIS
  ClapperFeature *feature = CLAPPER_FEATURE (clapper_mpris_new (
      mpris_name, APP_NAME, APP_ID));
  clapper_mpris_set_queue_controllable (CLAPPER_MPRIS (feature), TRUE);
  clapper_player_add_feature (player, feature);
  gst_object_unref (feature);
#endif

Becomes this:

ClapperEnhancerProxyList *proxies = clapper_player_get_enhancer_proxies (player);
ClapperEnhancerProxy *proxy;

/* Check if MPRIS enhancer is available */
if ((proxy = clapper_enhancer_proxy_list_get_proxy_by_module (proxies, "clapper-mpris"))) {
  /* Allow instances of this proxy target to be created as needed (enable this enhancer) */
  clapper_enhancer_proxy_set_target_creation_allowed (proxy, TRUE);
  
  /* Configure application scope properties */
  clapper_enhancer_proxy_set_locally (proxy,
      "own-name", mpris_name,
      "identity", APP_NAME,
      "desktop-entry", APP_ID,
      "queue-controllable", TRUE, NULL);

  gst_object_unref (proxy);
}

Optionally, an else can be added to new code with first example code for app to remain compatible with both implementations.

I also imagine that once this goes live, you might want to build clapper without mpris meson option in your Flathub manifest, since you are gonna get mpris from enhancers extension.

I have yet to test whether bindings (including VALA) for that work correctly.

@GeopJr
Copy link
Owner Author

GeopJr commented Jul 12, 2025

Sounds good to me and it makes sense to move it to enhancers! I'll add this to this PR eventually, after all this is a draft for 0.10 / I expect API changes :)

@Rafostar
Copy link
Contributor

Rafostar commented Jan 5, 2026

I expect API changes :)

Just dropping here links to migration guide(s) in case you ever decide to continue with this PR. No rush. Even with latest Clapper version, Tuba still compiles cleanly (only deprecations warnings). Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clapper_enhancer_check is deprecated

2 participants