mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-15 07:00:05 -05:00
spa: add some more functions
This commit is contained in:
parent
d966a36fdd
commit
9fc33a6142
2 changed files with 28 additions and 8 deletions
|
|
@ -62,8 +62,18 @@ SPA_API_JSON void spa_json_enter(struct spa_json * iter, struct spa_json * sub)
|
|||
|
||||
#define SPA_JSON_SAVE(iter) ((struct spa_json) { (iter)->cur, (iter)->end, NULL, (iter)->state, 0 })
|
||||
|
||||
SPA_API_JSON void spa_json_save(struct spa_json * iter, struct spa_json * save)
|
||||
{
|
||||
*save = SPA_JSON_SAVE(iter);
|
||||
}
|
||||
|
||||
#define SPA_JSON_START(iter,p) ((struct spa_json) { (p), (iter)->end, NULL, 0, 0 })
|
||||
|
||||
SPA_API_JSON void spa_json_start(struct spa_json * iter, struct spa_json * sub, const char *pos)
|
||||
{
|
||||
*sub = SPA_JSON_START(iter,pos);
|
||||
}
|
||||
|
||||
/** Get the next token. \a value points to the token and the return value
|
||||
* is the length. Returns -1 on parse error, 0 on end of input. */
|
||||
SPA_API_JSON int spa_json_next(struct spa_json * iter, const char **value)
|
||||
|
|
|
|||
|
|
@ -19,8 +19,18 @@ extern "C" {
|
|||
* \{
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/list.h>
|
||||
|
||||
#ifndef SPA_API_RESULT
|
||||
#ifdef SPA_API_IMPL
|
||||
#define SPA_API_RESULT SPA_API_IMPL
|
||||
#else
|
||||
#define SPA_API_RESULT static inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define SPA_ASYNC_BIT (1 << 30)
|
||||
#define SPA_ASYNC_SEQ_MASK (SPA_ASYNC_BIT - 1)
|
||||
|
|
@ -33,13 +43,13 @@ extern "C" {
|
|||
#define SPA_RESULT_ASYNC_SEQ(res) ((res) & SPA_ASYNC_SEQ_MASK)
|
||||
#define SPA_RESULT_RETURN_ASYNC(seq) (SPA_ASYNC_BIT | SPA_RESULT_ASYNC_SEQ(seq))
|
||||
|
||||
#define spa_strerror(err) \
|
||||
({ \
|
||||
int _err = -(err); \
|
||||
if (SPA_RESULT_IS_ASYNC(err)) \
|
||||
_err = EINPROGRESS; \
|
||||
strerror(_err); \
|
||||
})
|
||||
SPA_API_RESULT const char *spa_strerror(int err)
|
||||
{
|
||||
int _err = -(err);
|
||||
if (SPA_RESULT_IS_ASYNC(err))
|
||||
_err = EINPROGRESS;
|
||||
return strerror(_err);
|
||||
}
|
||||
|
||||
/**
|
||||
* \}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue