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
df48fd89
Commit
df48fd89
authored
5 years ago
by
George Kiagiadakis
Browse files
Options
Downloads
Patches
Plain Diff
module/factory: add a get_core() method on both
parent
06db0e41
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/wp/factory.c
+15
-0
15 additions, 0 deletions
lib/wp/factory.c
lib/wp/factory.h
+1
-0
1 addition, 0 deletions
lib/wp/factory.h
lib/wp/module.c
+19
-1
19 additions, 1 deletion
lib/wp/module.c
lib/wp/module.h
+1
-0
1 addition, 0 deletions
lib/wp/module.h
with
36 additions
and
1 deletion
lib/wp/factory.c
+
15
−
0
View file @
df48fd89
...
...
@@ -12,6 +12,7 @@ struct _WpFactory
{
GObject
parent
;
GWeakRef
core
;
gchar
*
name
;
GQuark
name_quark
;
WpFactoryFunc
create_object
;
...
...
@@ -29,6 +30,7 @@ wp_factory_finalize (GObject * obj)
{
WpFactory
*
self
=
WP_FACTORY
(
obj
);
g_weak_ref_clear
(
&
self
->
core
);
g_free
(
self
->
name
);
G_OBJECT_CLASS
(
wp_factory_parent_class
)
->
finalize
(
obj
);
...
...
@@ -50,6 +52,7 @@ wp_factory_new (WpCore * core, const gchar * name, WpFactoryFunc func)
g_return_val_if_fail
(
func
!=
NULL
,
NULL
);
f
=
g_object_new
(
WP_TYPE_FACTORY
,
NULL
);
g_weak_ref_init
(
&
f
->
core
,
core
);
f
->
name
=
g_strdup
(
name
);
f
->
name_quark
=
g_quark_from_string
(
f
->
name
);
f
->
create_object
=
func
;
...
...
@@ -66,6 +69,18 @@ wp_factory_get_name (WpFactory * self)
return
self
->
name
;
}
/**
* wp_factory_get_core:
* @self: the factory
*
* Returns: (transfer full): the core on which this factory is registered
*/
WpCore
*
wp_factory_get_core
(
WpFactory
*
self
)
{
return
g_weak_ref_get
(
&
self
->
core
);
}
gpointer
wp_factory_create_object
(
WpFactory
*
self
,
GType
type
,
GVariant
*
properties
)
{
...
...
This diff is collapsed.
Click to expand it.
lib/wp/factory.h
+
1
−
0
View file @
df48fd89
...
...
@@ -23,6 +23,7 @@ WpFactory * wp_factory_new (WpCore * core, const gchar * name,
WpFactoryFunc
func
);
const
gchar
*
wp_factory_get_name
(
WpFactory
*
self
);
WpCore
*
wp_factory_get_core
(
WpFactory
*
self
);
gpointer
wp_factory_create_object
(
WpFactory
*
self
,
GType
type
,
GVariant
*
properties
);
...
...
This diff is collapsed.
Click to expand it.
lib/wp/module.c
+
19
−
1
View file @
df48fd89
...
...
@@ -17,6 +17,8 @@ typedef void (*WpModuleInitFunc) (WpModule *, WpCore *, GVariant *);
struct
_WpModule
{
GObject
parent
;
GWeakRef
core
;
GVariant
*
properties
;
GDestroyNotify
destroy
;
gpointer
destroy_data
;
...
...
@@ -37,6 +39,7 @@ wp_module_finalize (GObject * object)
if
(
self
->
destroy
)
self
->
destroy
(
self
->
destroy_data
);
g_clear_pointer
(
&
self
->
properties
,
g_variant_unref
);
g_weak_ref_clear
(
&
self
->
core
);
G_OBJECT_CLASS
(
wp_module_parent_class
)
->
finalize
(
object
);
}
...
...
@@ -106,8 +109,10 @@ wp_module_load (WpCore * core, const gchar * abi,
{
g_autoptr
(
WpModule
)
module
=
NULL
;
module
=
g_object_new
(
WP_TYPE_MODULE
,
NULL
);
g_weak_ref_init
(
&
module
->
core
,
core
);
if
(
!
g_strcmp0
(
abi
,
"C"
))
{
module
=
g_object_new
(
WP_TYPE_MODULE
,
NULL
);
if
(
!
wp_module_load_c
(
module
,
core
,
module_name
,
args
,
error
))
return
NULL
;
}
else
{
...
...
@@ -118,6 +123,7 @@ wp_module_load (WpCore * core, const gchar * abi,
wp_core_register_global
(
core
,
g_quark_from_string
(
module_name
),
g_object_ref
(
module
),
g_object_unref
);
return
module
;
}
...
...
@@ -127,6 +133,18 @@ wp_module_get_properties (WpModule * self)
return
self
->
properties
;
}
/**
* wp_module_get_core:
* @self: the module
*
* Returns: (transfer full): the core on which this module is registered
*/
WpCore
*
wp_module_get_core
(
WpModule
*
self
)
{
return
g_weak_ref_get
(
&
self
->
core
);
}
void
wp_module_set_destroy_callback
(
WpModule
*
self
,
GDestroyNotify
callback
,
gpointer
data
)
...
...
This diff is collapsed.
Click to expand it.
lib/wp/module.h
+
1
−
0
View file @
df48fd89
...
...
@@ -20,6 +20,7 @@ WpModule * wp_module_load (WpCore * core, const gchar * abi,
const
gchar
*
module_name
,
GVariant
*
args
,
GError
**
error
);
GVariant
*
wp_module_get_properties
(
WpModule
*
module
);
WpCore
*
wp_module_get_core
(
WpModule
*
module
);
void
wp_module_set_destroy_callback
(
WpModule
*
module
,
GDestroyNotify
callback
,
gpointer
data
);
...
...
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