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
2031809d
Commit
2031809d
authored
5 years ago
by
George Kiagiadakis
Browse files
Options
Downloads
Patches
Plain Diff
lib: add new WpProperties object to wrap pw_properties & spa_dict
parent
6786b13f
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/wp/meson.build
+2
-0
2 additions, 0 deletions
lib/wp/meson.build
lib/wp/properties.c
+222
-0
222 additions, 0 deletions
lib/wp/properties.c
lib/wp/properties.h
+55
-0
55 additions, 0 deletions
lib/wp/properties.h
lib/wp/wp.h
+1
-0
1 addition, 0 deletions
lib/wp/wp.h
with
280 additions
and
0 deletions
lib/wp/meson.build
+
2
−
0
View file @
2031809d
...
...
@@ -5,6 +5,7 @@ wp_lib_sources = [
'factory.c'
,
'module.c'
,
'policy.c'
,
'properties.c'
,
'proxy.c'
,
'proxy-node.c'
,
'proxy-port.c'
,
...
...
@@ -20,6 +21,7 @@ wp_lib_headers = [
'factory.h'
,
'module.h'
,
'policy.h'
,
'properties.h'
,
'proxy.h'
,
'proxy-node.h'
,
'proxy-port.h'
,
...
...
This diff is collapsed.
Click to expand it.
lib/wp/properties.c
0 → 100644
+
222
−
0
View file @
2031809d
/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#include
"properties.h"
#include
<errno.h>
#include
<pipewire/properties.h>
enum
{
FLAG_IS_DICT
=
(
1
<<
1
),
FLAG_NO_OWNERSHIP
=
(
1
<<
2
),
};
struct
_WpProperties
{
guint32
flags
;
union
{
struct
pw_properties
*
props
;
const
struct
spa_dict
*
dict
;
};
};
G_DEFINE_BOXED_TYPE
(
WpProperties
,
wp_properties
,
wp_properties_ref
,
wp_properties_unref
)
WpProperties
*
wp_properties_new_empty
(
void
)
{
WpProperties
*
self
=
g_rc_box_new
(
WpProperties
);
self
->
flags
=
0
;
self
->
props
=
pw_properties_new
(
NULL
,
NULL
);
return
self
;
}
WpProperties
*
wp_properties_new
(
const
gchar
*
key
,
...)
{
WpProperties
*
self
;
va_list
varargs
;
va_start
(
varargs
,
key
);
self
=
wp_properties_new_valist
(
key
,
varargs
);
va_end
(
varargs
);
return
self
;
}
WpProperties
*
wp_properties_new_valist
(
const
gchar
*
key
,
va_list
varargs
)
{
WpProperties
*
self
=
wp_properties_new_empty
();
const
gchar
*
value
;
while
(
key
!=
NULL
)
{
value
=
va_arg
(
varargs
,
gchar
*
);
if
(
value
&&
key
[
0
])
wp_properties_set
(
self
,
key
,
value
);
key
=
va_arg
(
varargs
,
gchar
*
);
}
return
self
;
}
WpProperties
*
wp_properties_new_string
(
const
gchar
*
str
)
{
WpProperties
*
self
;
g_return_val_if_fail
(
str
!=
NULL
,
NULL
);
self
=
g_rc_box_new
(
WpProperties
);
self
->
flags
=
0
;
self
->
props
=
pw_properties_new_string
(
str
);
return
self
;
}
WpProperties
*
wp_properties_new_wrap
(
struct
pw_properties
*
props
)
{
WpProperties
*
self
;
g_return_val_if_fail
(
props
!=
NULL
,
NULL
);
self
=
g_rc_box_new
(
WpProperties
);
self
->
flags
=
FLAG_NO_OWNERSHIP
;
self
->
props
=
props
;
return
self
;
}
WpProperties
*
wp_properties_new_take
(
struct
pw_properties
*
props
)
{
WpProperties
*
self
;
g_return_val_if_fail
(
props
!=
NULL
,
NULL
);
self
=
g_rc_box_new
(
WpProperties
);
self
->
flags
=
0
;
self
->
props
=
props
;
return
self
;
}
WpProperties
*
wp_properties_new_copy
(
const
struct
pw_properties
*
props
)
{
WpProperties
*
self
;
g_return_val_if_fail
(
props
!=
NULL
,
NULL
);
self
=
g_rc_box_new
(
WpProperties
);
self
->
flags
=
0
;
self
->
props
=
pw_properties_copy
(
props
);
return
self
;
}
WpProperties
*
wp_properties_new_wrap_dict
(
const
struct
spa_dict
*
dict
)
{
WpProperties
*
self
;
g_return_val_if_fail
(
dict
!=
NULL
,
NULL
);
self
=
g_rc_box_new
(
WpProperties
);
self
->
flags
=
FLAG_NO_OWNERSHIP
|
FLAG_IS_DICT
;
self
->
dict
=
dict
;
return
self
;
}
WpProperties
*
wp_properties_new_copy_dict
(
const
struct
spa_dict
*
dict
)
{
WpProperties
*
self
;
g_return_val_if_fail
(
dict
!=
NULL
,
NULL
);
self
=
g_rc_box_new
(
WpProperties
);
self
->
flags
=
0
;
self
->
props
=
pw_properties_new_dict
(
dict
);
return
self
;
}
static
void
wp_properties_free
(
WpProperties
*
self
)
{
if
(
!
(
self
->
flags
&
FLAG_NO_OWNERSHIP
))
pw_properties_free
(
self
->
props
);
}
WpProperties
*
wp_properties_ref
(
WpProperties
*
self
)
{
return
g_rc_box_acquire
(
self
);
}
void
wp_properties_unref
(
WpProperties
*
self
)
{
g_rc_box_release_full
(
self
,
(
GDestroyNotify
)
wp_properties_free
);
}
const
gchar
*
wp_properties_get
(
WpProperties
*
self
,
const
gchar
*
key
)
{
g_return_val_if_fail
(
self
!=
NULL
,
NULL
);
g_return_val_if_fail
(
key
!=
NULL
,
NULL
);
return
spa_dict_lookup
(
wp_properties_peek_dict
(
self
),
key
);
}
gint
wp_properties_set
(
WpProperties
*
self
,
const
gchar
*
key
,
const
gchar
*
value
)
{
g_return_val_if_fail
(
self
!=
NULL
,
-
EINVAL
);
g_return_val_if_fail
(
!
(
self
->
flags
&
FLAG_IS_DICT
),
-
EINVAL
);
return
pw_properties_set
(
self
->
props
,
key
,
value
);
}
gint
wp_properties_setf
(
WpProperties
*
self
,
const
gchar
*
key
,
const
gchar
*
format
,
...)
{
gint
res
;
va_list
varargs
;
va_start
(
varargs
,
format
);
res
=
wp_properties_setf_valist
(
self
,
key
,
format
,
varargs
);
va_end
(
varargs
);
return
res
;
}
gint
wp_properties_setf_valist
(
WpProperties
*
self
,
const
gchar
*
key
,
const
gchar
*
format
,
va_list
args
)
{
g_return_val_if_fail
(
self
!=
NULL
,
-
EINVAL
);
g_return_val_if_fail
(
!
(
self
->
flags
&
FLAG_IS_DICT
),
-
EINVAL
);
return
pw_properties_setva
(
self
->
props
,
key
,
format
,
args
);
}
const
struct
spa_dict
*
wp_properties_peek_dict
(
WpProperties
*
self
)
{
g_return_val_if_fail
(
self
!=
NULL
,
NULL
);
return
(
self
->
flags
&
FLAG_IS_DICT
)
?
self
->
dict
:
&
self
->
props
->
dict
;
}
struct
pw_properties
*
wp_properties_to_pw_properties
(
WpProperties
*
self
)
{
g_return_val_if_fail
(
self
!=
NULL
,
NULL
);
return
pw_properties_new_dict
(
wp_properties_peek_dict
(
self
));
}
This diff is collapsed.
Click to expand it.
lib/wp/properties.h
0 → 100644
+
55
−
0
View file @
2031809d
/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#ifndef __WIREPLUMBER_PROPERTIES_H__
#define __WIREPLUMBER_PROPERTIES_H__
#include
<glib-object.h>
G_BEGIN_DECLS
struct
pw_properties
;
struct
spa_dict
;
#define WP_TYPE_PROPERTIES (wp_properties_get_type ())
GType
wp_properties_get_type
(
void
);
typedef
struct
_WpProperties
WpProperties
;
WpProperties
*
wp_properties_new_empty
(
void
);
WpProperties
*
wp_properties_new
(
const
gchar
*
key
,
...)
G_GNUC_NULL_TERMINATED
;
WpProperties
*
wp_properties_new_valist
(
const
gchar
*
key
,
va_list
args
);
WpProperties
*
wp_properties_new_string
(
const
gchar
*
str
);
WpProperties
*
wp_properties_new_wrap
(
struct
pw_properties
*
props
);
WpProperties
*
wp_properties_new_take
(
struct
pw_properties
*
props
);
WpProperties
*
wp_properties_new_copy
(
const
struct
pw_properties
*
props
);
WpProperties
*
wp_properties_new_wrap_dict
(
const
struct
spa_dict
*
dict
);
WpProperties
*
wp_properties_new_copy_dict
(
const
struct
spa_dict
*
dict
);
WpProperties
*
wp_properties_ref
(
WpProperties
*
self
);
void
wp_properties_unref
(
WpProperties
*
self
);
const
gchar
*
wp_properties_get
(
WpProperties
*
self
,
const
gchar
*
key
);
gint
wp_properties_set
(
WpProperties
*
self
,
const
gchar
*
key
,
const
gchar
*
value
);
gint
wp_properties_setf
(
WpProperties
*
self
,
const
gchar
*
key
,
const
gchar
*
format
,
...)
G_GNUC_PRINTF
(
3
,
4
);
gint
wp_properties_setf_valist
(
WpProperties
*
self
,
const
gchar
*
key
,
const
gchar
*
format
,
va_list
args
);
const
struct
spa_dict
*
wp_properties_peek_dict
(
WpProperties
*
self
);
struct
pw_properties
*
wp_properties_to_pw_properties
(
WpProperties
*
self
);
G_DEFINE_AUTOPTR_CLEANUP_FUNC
(
WpProperties
,
wp_properties_unref
)
G_END_DECLS
#endif
This diff is collapsed.
Click to expand it.
lib/wp/wp.h
+
1
−
0
View file @
2031809d
...
...
@@ -12,6 +12,7 @@
#include
"factory.h"
#include
"module.h"
#include
"policy.h"
#include
"properties.h"
#include
"proxy.h"
#include
"proxy-link.h"
#include
"proxy-node.h"
...
...
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