+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
main
| 1 | /* Simple Plugin API */ |
| 2 | /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */ |
| 3 | /* SPDX-License-Identifier: MIT */ |
| 4 | |
| 5 | #ifndef SPA_UTILS_RESULT_H |
| 6 | #define SPA_UTILS_RESULT_H |
| 7 | |
| 8 | #include <errno.h> |
| 9 | |
| 10 | #include <spa/utils/defs.h> |
| 11 | |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
| 16 | /** |
| 17 | * \defgroup spa_result Result handling |
| 18 | * Asynchronous result utilities |
| 19 | */ |
| 20 | |
| 21 | /** |
| 22 | * \addtogroup spa_result |
| 23 | * \{ |
| 24 | */ |
| 25 | |
| 26 | #ifndef SPA_API_RESULT |
| 27 | #ifdef SPA_API_IMPL |
| 28 | #define SPA_API_RESULT SPA_API_IMPL |
| 29 | #else |
| 30 | #define SPA_API_RESULT static inline |
| 31 | #endif |
| 32 | #endif |
| 33 | |
| 34 | |
| 35 | #define SPA_ASYNC_BIT (1 << 30) |
| 36 | #define SPA_ASYNC_SEQ_MASK (SPA_ASYNC_BIT - 1) |
| 37 | #define SPA_ASYNC_MASK (~SPA_ASYNC_SEQ_MASK) |
| 38 | |
| 39 | #define SPA_RESULT_IS_OK(res) ((res) >= 0) |
| 40 | #define SPA_RESULT_IS_ERROR(res) ((res) < 0) |
| 41 | #define SPA_RESULT_IS_ASYNC(res) (((res) & SPA_ASYNC_MASK) == SPA_ASYNC_BIT) |
| 42 | |
| 43 | #define SPA_RESULT_ASYNC_SEQ(res) ((res) & SPA_ASYNC_SEQ_MASK) |
| 44 | #define SPA_RESULT_RETURN_ASYNC(seq) (SPA_ASYNC_BIT | SPA_RESULT_ASYNC_SEQ(seq)) |
| 45 | |
| 46 | SPA_API_RESULT const char *spa_strerror(int err) |
| 47 | { |
| 48 | int _err = -(err); |
| 49 | if (SPA_RESULT_IS_ASYNC(err)) |
| 50 | _err = EINPROGRESS; |
| 51 | return strerror(_err); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * \} |
| 56 | */ |
| 57 | |
| 58 | #ifdef __cplusplus |
| 59 | } /* extern "C" */ |
| 60 | #endif |
| 61 | |
| 62 | #endif /* SPA_UTILS_RESULT_H */ |