Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wireplumber
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pkg
wireplumber
Commits
ec30336f
Commit
ec30336f
authored
4 years ago
by
Julian Bouzas
Browse files
Options
Downloads
Patches
Plain Diff
session-item: add id property
Makes it easier when handling session items in Lua
parent
c0143b5f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/wp/session-item.c
+37
-0
37 additions, 0 deletions
lib/wp/session-item.c
lib/wp/session-item.h
+5
-0
5 additions, 0 deletions
lib/wp/session-item.h
with
42 additions
and
0 deletions
lib/wp/session-item.c
+
37
−
0
View file @
ec30336f
...
...
@@ -26,12 +26,14 @@ enum {
typedef
struct
_WpSessionItemPrivate
WpSessionItemPrivate
;
struct
_WpSessionItemPrivate
{
guint
id
;
GWeakRef
parent
;
WpProperties
*
properties
;
};
enum
{
PROP_0
,
PROP_ID
,
PROP_PROPERTIES
,
};
...
...
@@ -41,11 +43,20 @@ enum {
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE
(
WpSessionItem
,
wp_session_item
,
WP_TYPE_OBJECT
)
static
guint
get_next_id
()
{
static
guint
next_id
=
0
;
g_atomic_int_inc
(
&
next_id
);
return
next_id
;
}
static
void
wp_session_item_init
(
WpSessionItem
*
self
)
{
WpSessionItemPrivate
*
priv
=
wp_session_item_get_instance_private
(
self
);
priv
->
id
=
get_next_id
();
g_weak_ref_init
(
&
priv
->
parent
,
NULL
);
priv
->
properties
=
NULL
;
}
...
...
@@ -86,8 +97,12 @@ wp_session_item_get_property (GObject * object, guint property_id,
GValue
*
value
,
GParamSpec
*
pspec
)
{
WpSessionItem
*
self
=
WP_SESSION_ITEM
(
object
);
WpSessionItemPrivate
*
priv
=
wp_session_item_get_instance_private
(
self
);
switch
(
property_id
)
{
case
PROP_ID
:
g_value_set_uint
(
value
,
priv
->
id
);
break
;
case
PROP_PROPERTIES
:
g_value_set_boxed
(
value
,
wp_session_item_get_properties
(
self
));
break
;
...
...
@@ -204,6 +219,11 @@ wp_session_item_class_init (WpSessionItemClass * klass)
klass
->
reset
=
wp_session_item_default_reset
;
g_object_class_install_property
(
object_class
,
PROP_ID
,
g_param_spec_uint
(
"id"
,
"id"
,
"The session item unique id"
,
0
,
G_MAXUINT
,
0
,
G_PARAM_READABLE
|
G_PARAM_STATIC_STRINGS
));
g_object_class_install_property
(
object_class
,
PROP_PROPERTIES
,
g_param_spec_boxed
(
"properties"
,
"properties"
,
"The session item properties"
,
WP_TYPE_PROPERTIES
,
...
...
@@ -248,6 +268,23 @@ wp_session_item_set_parent (WpSessionItem *self, WpSessionItem *parent)
g_weak_ref_set
(
&
priv
->
parent
,
parent
);
}
/**
* wp_session_item_get_id:
* @self: the session item
*
* Gets the unique Id of the session item
*/
guint
wp_session_item_get_id
(
WpSessionItem
*
self
)
{
WpSessionItemPrivate
*
priv
=
NULL
;
g_return_val_if_fail
(
WP_IS_SESSION_ITEM
(
self
),
SPA_ID_INVALID
);
priv
=
wp_session_item_get_instance_private
(
self
);
return
priv
->
id
;
}
/**
* wp_session_item_reset: (virtual reset)
* @self: the session item
...
...
This diff is collapsed.
Click to expand it.
lib/wp/session-item.h
+
5
−
0
View file @
ec30336f
...
...
@@ -69,6 +69,11 @@ WpSessionItem * wp_session_item_get_parent (WpSessionItem * self);
WP_PRIVATE_API
void
wp_session_item_set_parent
(
WpSessionItem
*
self
,
WpSessionItem
*
parent
);
/* Id */
WP_API
guint
wp_session_item_get_id
(
WpSessionItem
*
self
);
/* configuration */
WP_API
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment