mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-07 12:18:04 +02:00
properties: add wp_properties_unref_and_take_pw_properties()
a method to take the internal pw_properties without copying
This commit is contained in:
parent
c72d126374
commit
0d1fcd48a1
2 changed files with 29 additions and 0 deletions
|
|
@ -876,6 +876,31 @@ wp_properties_to_pw_properties (WpProperties * self)
|
|||
return pw_properties_new_dict (wp_properties_peek_dict (self));
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_properties_unref_and_take_pw_properties:
|
||||
* @self: (transfer full): a properties object
|
||||
*
|
||||
* Similar to wp_properties_to_pw_properties(), but this method avoids making
|
||||
* a copy of the properties by returning the `struct pw_properties` that is
|
||||
* stored internally and then freeing the #WpProperties wrapper.
|
||||
*
|
||||
* If @self is not uniquely owned (see wp_properties_ensure_unique_owner()),
|
||||
* then this method does make a copy and is the same as
|
||||
* wp_properties_to_pw_properties(), performance-wise.
|
||||
*
|
||||
* Returns: (transfer full): the properties in @self as a `struct pw_properties`
|
||||
*/
|
||||
struct pw_properties *
|
||||
wp_properties_unref_and_take_pw_properties (WpProperties * self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
|
||||
g_autoptr (WpProperties) unique = wp_properties_ensure_unique_owner (self);
|
||||
/* set the flag so that unref-ing @unique will not destroy unique->props */
|
||||
unique->flags = FLAG_NO_OWNERSHIP;
|
||||
return unique->props;
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_properties_matches:
|
||||
* @self: a properties object
|
||||
|
|
|
|||
|
|
@ -152,6 +152,10 @@ const struct spa_dict * wp_properties_peek_dict (WpProperties * self);
|
|||
WP_API
|
||||
struct pw_properties * wp_properties_to_pw_properties (WpProperties * self);
|
||||
|
||||
WP_API
|
||||
struct pw_properties * wp_properties_unref_and_take_pw_properties (
|
||||
WpProperties * self);
|
||||
|
||||
/* comparison */
|
||||
|
||||
WP_API
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue