mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
type: improve type check
This commit is contained in:
parent
0855ca0050
commit
53dd63eb3a
2 changed files with 6 additions and 6 deletions
|
|
@ -45,7 +45,7 @@ typedef uint32_t SpaType;
|
||||||
static inline bool
|
static inline bool
|
||||||
spa_type_is_a (const char *type, const char *parent)
|
spa_type_is_a (const char *type, const char *parent)
|
||||||
{
|
{
|
||||||
return type != NULL && parent != NULL && strstr (type, parent) == type;
|
return type != NULL && parent != NULL && strncmp (type, parent, strlen (parent)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -270,11 +270,11 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
do_static_struct (map);
|
do_static_struct (map);
|
||||||
|
|
||||||
printf ("%d\n", spa_type_is_a (SPA_TYPE__MediaType, SPA_TYPE_ENUM_BASE));
|
printf ("media type is enum %d\n", spa_type_is_a (SPA_TYPE__MediaType, SPA_TYPE_ENUM_BASE));
|
||||||
printf ("%d\n", spa_type_is_a (SPA_TYPE__MediaSubtype, SPA_TYPE_ENUM_BASE));
|
printf ("media sybtype is enum %d\n", spa_type_is_a (SPA_TYPE__MediaSubtype, SPA_TYPE_ENUM_BASE));
|
||||||
printf ("%d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_ENUM_BASE));
|
printf ("format is enum %d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_ENUM_BASE));
|
||||||
printf ("%d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_POD_BASE));
|
printf ("format is pod %d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_POD_BASE));
|
||||||
printf ("%d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_POD_OBJECT_BASE));
|
printf ("format is object %d\n", spa_type_is_a (SPA_TYPE__Format, SPA_TYPE_POD_OBJECT_BASE));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue