diff --git a/pipewire/client/context.c b/pipewire/client/context.c index 7486a2978..287f61463 100644 --- a/pipewire/client/context.c +++ b/pipewire/client/context.c @@ -38,11 +38,11 @@ struct context { int fd; struct pw_connection *connection; - SpaSource *source; + struct spa_source *source; bool disconnecting; struct pw_listener need_flush; - SpaSource *flush_event; + struct spa_source *flush_event; }; /** @@ -140,7 +140,7 @@ core_event_done (void *object, static void core_event_error (void *object, uint32_t id, - SpaResult res, + int res, const char *error, ...) { struct pw_proxy *proxy = object; @@ -174,7 +174,7 @@ core_event_update_types (void *object, int i; for (i = 0; i < n_types; i++, first_id++) { - SpaType this_id = spa_type_map_get_id (this->type.map, types[i]); + uint32_t this_id = spa_type_map_get_id (this->type.map, types[i]); if (!pw_map_insert_at (&this->types, first_id, PW_MAP_ID_TO_PTR (this_id))) pw_log_error ("can't add type for client"); } @@ -383,8 +383,8 @@ static const struct pw_registry_events registry_events = { typedef bool (*demarshal_func_t) (void *object, void *data, size_t size); static void -do_flush_event (SpaLoopUtils *utils, - SpaSource *source, +do_flush_event (struct spa_loop_utils *utils, + struct spa_source *source, void *data) { struct context *impl = data; @@ -403,10 +403,10 @@ on_need_flush (struct pw_listener *listener, } static void -on_context_data (SpaLoopUtils *utils, - SpaSource *source, +on_context_data (struct spa_loop_utils *utils, + struct spa_source *source, int fd, - SpaIO mask, + enum spa_io mask, void *data) { struct context *impl = data; @@ -742,7 +742,7 @@ pw_context_get_core_info (struct pw_context *context, cb (context, SPA_RESULT_ENUM_END, NULL, user_data); } -typedef void (*list_func_t) (struct pw_context *, SpaResult, void *, void *); +typedef void (*list_func_t) (struct pw_context *, int, void *, void *); static void do_list (struct pw_context *context, diff --git a/pipewire/client/context.h b/pipewire/client/context.h index b345afd32..78ef2eb00 100644 --- a/pipewire/client/context.h +++ b/pipewire/client/context.h @@ -75,9 +75,9 @@ struct pw_context { uint32_t n_types; struct pw_map types; - SpaList global_list; - SpaList stream_list; - SpaList proxy_list; + struct spa_list global_list; + struct spa_list stream_list; + struct spa_list proxy_list; void *protocol_private; diff --git a/pipewire/client/interfaces.h b/pipewire/client/interfaces.h index 75b9c0b37..0a44f7fac 100644 --- a/pipewire/client/interfaces.h +++ b/pipewire/client/interfaces.h @@ -42,7 +42,7 @@ extern "C" { struct pw_core_methods { void (*client_update) (void *object, - const SpaDict *props); + const struct spa_dict *props); void (*sync) (void *object, uint32_t seq); void (*get_registry) (void *object, @@ -50,11 +50,11 @@ struct pw_core_methods { void (*create_node) (void *object, const char *factory_name, const char *name, - const SpaDict *props, + const struct spa_dict *props, uint32_t new_id); void (*create_client_node) (void *object, const char *name, - const SpaDict *props, + const struct spa_dict *props, uint32_t new_id); void (*update_types) (void *object, uint32_t first_id, @@ -83,7 +83,7 @@ struct pw_core_events { uint32_t seq); void (*error) (void *object, uint32_t id, - SpaResult res, + int res, const char *error, ...); void (*remove_id) (void *object, uint32_t id); @@ -147,10 +147,10 @@ struct pw_node_events { #define pw_node_notify_info(r,...) ((struct pw_node_events*)r->iface->events)->info(r,__VA_ARGS__) struct pw_client_node_buffer { - uint32_t mem_id; - uint32_t offset; - uint32_t size; - SpaBuffer *buffer; + uint32_t mem_id; + uint32_t offset; + uint32_t size; + struct spa_buffer *buffer; }; #define PW_CLIENT_NODE_METHOD_UPDATE 0 @@ -167,10 +167,10 @@ struct pw_client_node_methods { uint32_t change_mask, uint32_t max_input_ports, uint32_t max_output_ports, - const SpaProps *props); + const struct spa_props *props); void (*port_update) (void *object, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, #define PW_MESSAGE_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0) #define PW_MESSAGE_PORT_UPDATE_FORMAT (1 << 1) @@ -178,13 +178,13 @@ struct pw_client_node_methods { #define PW_MESSAGE_PORT_UPDATE_INFO (1 << 3) uint32_t change_mask, uint32_t n_possible_formats, - const SpaFormat **possible_formats, - const SpaFormat *format, + const struct spa_format **possible_formats, + const struct spa_format *format, uint32_t n_params, - const SpaParam **params, - const SpaPortInfo *info); + const struct spa_param **params, + const struct spa_port_info *info); void (*event) (void *object, - SpaEvent *event); + struct spa_event *event); void (*destroy) (void *object); }; @@ -211,28 +211,28 @@ struct pw_client_node_events { int readfd, int writefd); void (*event) (void *object, - const SpaEvent *event); + const struct spa_event *event); void (*add_port) (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id); void (*remove_port) (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id); void (*set_format) (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format); + const struct spa_format *format); void (*set_property) (void *object, uint32_t seq, uint32_t id, uint32_t size, const void *value); void (*add_mem) (void *object, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t mem_id, uint32_t type, @@ -242,16 +242,16 @@ struct pw_client_node_events { uint32_t size); void (*use_buffers) (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t n_buffers, struct pw_client_node_buffer *buffers); void (*node_command) (void *object, uint32_t seq, - const SpaCommand *command); + const struct spa_command *command); void (*port_command) (void *object, uint32_t port_id, - const SpaCommand *command); + const struct spa_command *command); void (*transport) (void *object, int memfd, uint32_t offset, diff --git a/pipewire/client/introspect.c b/pipewire/client/introspect.c index 7ff267449..f9b7ffea6 100644 --- a/pipewire/client/introspect.c +++ b/pipewire/client/introspect.c @@ -103,9 +103,9 @@ pw_link_state_as_string (enum pw_link_state state) } static void -pw_spa_dict_destroy (SpaDict *dict) +pw_spa_dict_destroy (struct spa_dict *dict) { - SpaDictItem *item; + struct spa_dict_item *item; spa_dict_for_each (item, dict) { free ((void *)item->key); @@ -115,19 +115,19 @@ pw_spa_dict_destroy (SpaDict *dict) free (dict); } -static SpaDict * -pw_spa_dict_copy (SpaDict *dict) +static struct spa_dict * +pw_spa_dict_copy (struct spa_dict *dict) { - SpaDict *copy; + struct spa_dict *copy; uint32_t i; if (dict == NULL) return NULL; - copy = calloc (1, sizeof (SpaDict)); + copy = calloc (1, sizeof (struct spa_dict)); if (copy == NULL) goto no_mem; - copy->items = calloc (dict->n_items, sizeof (SpaDictItem)); + copy->items = calloc (dict->n_items, sizeof (struct spa_dict_item)); if (copy->items == NULL) goto no_items; copy->n_items = dict->n_items; @@ -246,7 +246,7 @@ pw_node_info_update (struct pw_node_info *info, free (info->input_formats[i]); info->n_input_formats = update->n_input_formats; if (info->n_input_formats) - info->input_formats = realloc (info->input_formats, info->n_input_formats * sizeof (SpaFormat *)); + info->input_formats = realloc (info->input_formats, info->n_input_formats * sizeof (struct spa_format *)); else { free (info->input_formats); info->input_formats = NULL; @@ -262,7 +262,7 @@ pw_node_info_update (struct pw_node_info *info, free (info->output_formats[i]); info->n_output_formats = update->n_output_formats; if (info->n_output_formats) - info->output_formats = realloc (info->output_formats, info->n_output_formats * sizeof (SpaFormat *)); + info->output_formats = realloc (info->output_formats, info->n_output_formats * sizeof (struct spa_format *)); else { free (info->output_formats); info->output_formats = NULL; diff --git a/pipewire/client/introspect.h b/pipewire/client/introspect.h index 5e7fd796f..91989645f 100644 --- a/pipewire/client/introspect.h +++ b/pipewire/client/introspect.h @@ -122,7 +122,7 @@ struct pw_core_info { const char *version; const char *name; uint32_t cookie; - SpaDict *props; + struct spa_dict *props; }; struct pw_core_info * pw_core_info_update (struct pw_core_info *info, @@ -138,7 +138,7 @@ void pw_core_info_free (struct pw_core_info *info); * Callback with information about the PipeWire core in @info. */ typedef void (*pw_core_info_cb_t) (struct pw_context *c, - SpaResult res, + int res, const struct pw_core_info *info, void *user_data); @@ -161,7 +161,7 @@ struct pw_module_info { const char *name; const char *filename; const char *args; - SpaDict *props; + struct spa_dict *props; }; struct pw_module_info * pw_module_info_update (struct pw_module_info *info, @@ -178,7 +178,7 @@ void pw_module_info_free (struct pw_module_info *inf * Callback with information about the PipeWire module in @info. */ typedef void (*pw_module_info_cb_t) (struct pw_context *c, - SpaResult res, + int res, const struct pw_module_info *info, void *user_data); @@ -202,7 +202,7 @@ void pw_context_get_module_info_by_id (struct pw_context *context, struct pw_client_info { uint32_t id; uint64_t change_mask; - SpaDict *props; + struct spa_dict *props; }; struct pw_client_info * pw_client_info_update (struct pw_client_info *info, @@ -219,7 +219,7 @@ void pw_client_info_free (struct pw_client_info *inf * Callback with information about the PipeWire client in @info. */ typedef void (*pw_client_info_cb_t) (struct pw_context *c, - SpaResult res, + int res, const struct pw_client_info *info, void *user_data); @@ -250,14 +250,14 @@ struct pw_node_info { uint32_t max_inputs; uint32_t n_inputs; uint32_t n_input_formats; - SpaFormat **input_formats; + struct spa_format **input_formats; uint32_t max_outputs; uint32_t n_outputs; uint32_t n_output_formats; - SpaFormat **output_formats; + struct spa_format **output_formats; enum pw_node_state state; const char *error; - SpaDict *props; + struct spa_dict *props; }; struct pw_node_info * pw_node_info_update (struct pw_node_info *info, @@ -273,7 +273,7 @@ void pw_node_info_free (struct pw_node_info *info); * Callback with information about the PipeWire node in @info. */ typedef void (*pw_node_info_cb_t) (struct pw_context *c, - SpaResult res, + int res, const struct pw_node_info *info, void *user_data); @@ -321,7 +321,7 @@ void pw_link_info_free (struct pw_link_info *info); * Callback with information about the PipeWire link in @info. */ typedef void (*pw_link_info_cb_t) (struct pw_context *c, - SpaResult res, + int res, const struct pw_link_info *info, void *user_data); diff --git a/pipewire/client/log.c b/pipewire/client/log.c index 91980a076..e0cbd7291 100644 --- a/pipewire/client/log.c +++ b/pipewire/client/log.c @@ -27,27 +27,27 @@ #define DEFAULT_LOG_LEVEL SPA_LOG_LEVEL_ERROR -SpaLogLevel pw_log_level = DEFAULT_LOG_LEVEL; +enum spa_log_level pw_log_level = DEFAULT_LOG_LEVEL; #define TRACE_BUFFER (16*1024) -typedef struct { - SpaLog log; - SpaRingbuffer trace_rb; +struct debug_log { + struct spa_log log; + struct spa_ringbuffer trace_rb; uint8_t trace_data[TRACE_BUFFER]; - SpaSource *source; -} DebugLog; + struct spa_source *source; +}; static void -do_logv (SpaLog *log, - SpaLogLevel level, - const char *file, - int line, - const char *func, - const char *fmt, - va_list args) +do_logv (struct spa_log *log, + enum spa_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, + va_list args) { - DebugLog *l = SPA_CONTAINER_OF (log, DebugLog, log); + struct debug_log *l = SPA_CONTAINER_OF (log, struct debug_log, log); char text[1024], location[1024]; static const char *levels[] = { "-", "E", "W", "I", "D", "T", "*T*"}; int size; @@ -77,12 +77,12 @@ do_logv (SpaLog *log, } static void -do_log (SpaLog *log, - SpaLogLevel level, - const char *file, - int line, - const char *func, - const char *fmt, ...) +do_log (struct spa_log *log, + enum spa_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, ...) { va_list args; va_start (args, fmt); @@ -90,8 +90,8 @@ do_log (SpaLog *log, va_end (args); } -static DebugLog log = { - { sizeof (SpaLog), +static struct debug_log log = { + { sizeof (struct spa_log), NULL, DEFAULT_LOG_LEVEL, do_log, @@ -100,21 +100,21 @@ static DebugLog log = { { 0, 0, TRACE_BUFFER, TRACE_BUFFER - 1 }, }; -SpaLog * +struct spa_log * pw_log_get (void) { return &log.log; } void -pw_log_set_level (SpaLogLevel level) +pw_log_set_level (enum spa_log_level level) { pw_log_level = level; log.log.level = level; } static void -on_trace_event (SpaSource *source) +on_trace_event (struct spa_source *source) { int32_t avail; uint32_t index; @@ -143,7 +143,7 @@ on_trace_event (SpaSource *source) } void -pw_log_set_trace_event (SpaSource *source) +pw_log_set_trace_event (struct spa_source *source) { log.source = source; log.source->func = on_trace_event; @@ -151,11 +151,11 @@ pw_log_set_trace_event (SpaSource *source) } void -pw_log_log (SpaLogLevel level, - const char *file, - int line, - const char *func, - const char *fmt, ...) +pw_log_log (enum spa_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, ...) { if (SPA_UNLIKELY (pw_log_level_enabled (level))) { va_list args; @@ -166,12 +166,12 @@ pw_log_log (SpaLogLevel level, } void -pw_log_logv (SpaLogLevel level, - const char *file, - int line, - const char *func, - const char *fmt, - va_list args) +pw_log_logv (enum spa_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, + va_list args) { if (SPA_UNLIKELY (pw_log_level_enabled (level))) { do_logv (&log.log, level, file, line, func, fmt, args); diff --git a/pipewire/client/log.h b/pipewire/client/log.h index 686e16283..c7d90c144 100644 --- a/pipewire/client/log.h +++ b/pipewire/client/log.h @@ -27,25 +27,25 @@ extern "C" { #endif -extern SpaLogLevel pw_log_level; +extern enum spa_log_level pw_log_level; -SpaLog * pw_log_get (void); +struct spa_log* pw_log_get (void); -void pw_log_set_level (SpaLogLevel level); -void pw_log_set_trace_event (SpaSource *source); +void pw_log_set_level (enum spa_log_level level); +void pw_log_set_trace_event (struct spa_source *source); -void pw_log_log (SpaLogLevel level, - const char *file, - int line, - const char *func, - const char *fmt, ...) SPA_PRINTF_FUNC(5, 6); -void pw_log_logv (SpaLogLevel level, - const char *file, - int line, - const char *func, - const char *fmt, - va_list args) SPA_PRINTF_FUNC(5, 0); +void pw_log_log (enum spa_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, ...) SPA_PRINTF_FUNC(5, 6); +void pw_log_logv (enum spa_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, + va_list args) SPA_PRINTF_FUNC(5, 0); #define pw_log_level_enabled(lev) (pw_log_level >= (lev)) diff --git a/pipewire/client/loop.c b/pipewire/client/loop.c index fc26cb154..25199577a 100644 --- a/pipewire/client/loop.c +++ b/pipewire/client/loop.c @@ -38,56 +38,56 @@ #define DATAS_SIZE (4096 * 8) struct invoke_item { - size_t item_size; - SpaInvokeFunc func; - uint32_t seq; - size_t size; - void *data; - void *user_data; + size_t item_size; + spa_invoke_func_t func; + uint32_t seq; + size_t size; + void *data; + void *user_data; }; -struct loop { +struct impl { struct pw_loop this; - SpaList source_list; + struct spa_list source_list; - SpaLoopHook pre_func; - SpaLoopHook post_func; + spa_loop_hook_t pre_func; + spa_loop_hook_t post_func; void *hook_data; int epoll_fd; pthread_t thread; - SpaLoop loop; - SpaLoopControl control; - SpaLoopUtils utils; + struct spa_loop loop; + struct spa_loop_control control; + struct spa_loop_utils utils; - SpaSource *event; + struct spa_source *event; - SpaRingbuffer buffer; + struct spa_ringbuffer buffer; uint8_t buffer_data[DATAS_SIZE]; }; -typedef struct { - SpaSource source; +struct source_impl { + struct spa_source source; - struct loop *impl; - SpaList link; + struct impl *impl; + struct spa_list link; bool close; union { - SpaSourceIOFunc io; - SpaSourceIdleFunc idle; - SpaSourceEventFunc event; - SpaSourceTimerFunc timer; - SpaSourceSignalFunc signal; + spa_source_io_func_t io; + spa_source_idle_func_t idle; + spa_source_event_func_t event; + spa_source_timer_func_t timer; + spa_source_signal_func_t signal; } func; int signal_number; bool enabled; -} SpaSourceImpl; +}; static inline uint32_t -spa_io_to_epoll (SpaIO mask) +spa_io_to_epoll (enum spa_io mask) { uint32_t events = 0; @@ -103,10 +103,10 @@ spa_io_to_epoll (SpaIO mask) return events; } -static inline SpaIO +static inline enum spa_io spa_epoll_to_io (uint32_t events) { - SpaIO mask = 0; + enum spa_io mask = 0; if (events & EPOLLIN) mask |= SPA_IO_IN; @@ -120,11 +120,11 @@ spa_epoll_to_io (uint32_t events) return mask; } -static SpaResult -loop_add_source (SpaLoop *loop, - SpaSource *source) +static int +loop_add_source (struct spa_loop *loop, + struct spa_source *source) { - struct loop *impl = SPA_CONTAINER_OF (loop, struct loop, loop); + struct impl *impl = SPA_CONTAINER_OF (loop, struct impl, loop); source->loop = loop; @@ -141,11 +141,11 @@ loop_add_source (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -loop_update_source (SpaSource *source) +static int +loop_update_source (struct spa_source *source) { - SpaLoop *loop = source->loop; - struct loop *impl = SPA_CONTAINER_OF (loop, struct loop, loop); + struct spa_loop *loop = source->loop; + struct impl *impl = SPA_CONTAINER_OF (loop, struct impl, loop); if (source->fd != -1) { struct epoll_event ep; @@ -161,10 +161,10 @@ loop_update_source (SpaSource *source) } static void -loop_remove_source (SpaSource *source) +loop_remove_source (struct spa_source *source) { - SpaLoop *loop = source->loop; - struct loop *impl = SPA_CONTAINER_OF (loop, struct loop, loop); + struct spa_loop *loop = source->loop; + struct impl *impl = SPA_CONTAINER_OF (loop, struct impl, loop); if (source->fd != -1) epoll_ctl (impl->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL); @@ -172,18 +172,18 @@ loop_remove_source (SpaSource *source) source->loop = NULL; } -static SpaResult -loop_invoke (SpaLoop *loop, - SpaInvokeFunc func, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +loop_invoke (struct spa_loop *loop, + spa_invoke_func_t func, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - struct loop *impl = SPA_CONTAINER_OF (loop, struct loop, loop); + struct impl *impl = SPA_CONTAINER_OF (loop, struct impl, loop); bool in_thread = pthread_equal (impl->thread, pthread_self()); struct invoke_item *item; - SpaResult res; + int res; if (in_thread) { res = func (loop, false, seq, size, data, user_data); @@ -237,11 +237,11 @@ loop_invoke (SpaLoop *loop, } static void -event_func (SpaLoopUtils *utils, - SpaSource *source, +event_func (struct spa_loop_utils *utils, + struct spa_source *source, void *data) { - struct loop *impl = data; + struct impl *impl = data; uint32_t index; while (spa_ringbuffer_get_read_index (&impl->buffer, &index) > 0) { @@ -252,20 +252,20 @@ event_func (SpaLoopUtils *utils, } static int -loop_get_fd (SpaLoopControl *ctrl) +loop_get_fd (struct spa_loop_control *ctrl) { - struct loop *impl = SPA_CONTAINER_OF (ctrl, struct loop, control); + struct impl *impl = SPA_CONTAINER_OF (ctrl, struct impl, control); return impl->epoll_fd; } static void -loop_set_hooks (SpaLoopControl *ctrl, - SpaLoopHook pre_func, - SpaLoopHook post_func, +loop_set_hooks (struct spa_loop_control *ctrl, + spa_loop_hook_t pre_func, + spa_loop_hook_t post_func, void *data) { - struct loop *impl = SPA_CONTAINER_OF (ctrl, struct loop, control); + struct impl *impl = SPA_CONTAINER_OF (ctrl, struct impl, control); impl->pre_func = pre_func; impl->post_func = post_func; @@ -273,24 +273,24 @@ loop_set_hooks (SpaLoopControl *ctrl, } static void -loop_enter (SpaLoopControl *ctrl) +loop_enter (struct spa_loop_control *ctrl) { - struct loop *impl = SPA_CONTAINER_OF (ctrl, struct loop, control); + struct impl *impl = SPA_CONTAINER_OF (ctrl, struct impl, control); impl->thread = pthread_self(); } static void -loop_leave (SpaLoopControl *ctrl) +loop_leave (struct spa_loop_control *ctrl) { - struct loop *impl = SPA_CONTAINER_OF (ctrl, struct loop, control); + struct impl *impl = SPA_CONTAINER_OF (ctrl, struct impl, control); impl->thread = 0; } -static SpaResult -loop_iterate (SpaLoopControl *ctrl, +static int +loop_iterate (struct spa_loop_control *ctrl, int timeout) { - struct loop *impl = SPA_CONTAINER_OF (ctrl, struct loop, control); + struct impl *impl = SPA_CONTAINER_OF (ctrl, struct impl, control); struct pw_loop *loop = &impl->this; struct epoll_event ep[32]; int i, nfds, save_errno; @@ -315,11 +315,11 @@ loop_iterate (SpaLoopControl *ctrl, * some callback might also want to look at other sources it manages and * can then reset the rmask to suppress the callback */ for (i = 0; i < nfds; i++) { - SpaSource *source = ep[i].data.ptr; + struct spa_source *source = ep[i].data.ptr; source->rmask = spa_epoll_to_io (ep[i].events); } for (i = 0; i < nfds; i++) { - SpaSource *source = ep[i].data.ptr; + struct spa_source *source = ep[i].data.ptr; if (source->rmask) { source->func (source); } @@ -328,24 +328,24 @@ loop_iterate (SpaLoopControl *ctrl, } static void -source_io_func (SpaSource *source) +source_io_func (struct spa_source *source) { - SpaSourceImpl *impl = SPA_CONTAINER_OF (source, SpaSourceImpl, source); + struct source_impl *impl = SPA_CONTAINER_OF (source, struct source_impl, source); impl->func.io (&impl->impl->utils, source, source->fd, source->rmask, source->data); } -static SpaSource * -loop_add_io (SpaLoopUtils *utils, +static struct spa_source * +loop_add_io (struct spa_loop_utils *utils, int fd, - SpaIO mask, + enum spa_io mask, bool close, - SpaSourceIOFunc func, + spa_source_io_func_t func, void *data) { - struct loop *impl = SPA_CONTAINER_OF (utils, struct loop, utils); - SpaSourceImpl *source; + struct impl *impl = SPA_CONTAINER_OF (utils, struct impl, utils); + struct source_impl *source; - source = calloc (1, sizeof (SpaSourceImpl)); + source = calloc (1, sizeof (struct source_impl)); if (source == NULL) return NULL; @@ -365,9 +365,9 @@ loop_add_io (SpaLoopUtils *utils, return &source->source; } -static SpaResult -loop_update_io (SpaSource *source, - SpaIO mask) +static int +loop_update_io (struct spa_source *source, + enum spa_io mask) { source->mask = mask; return spa_loop_update_source (source->loop, source); @@ -375,22 +375,22 @@ loop_update_io (SpaSource *source, static void -source_idle_func (SpaSource *source) +source_idle_func (struct spa_source *source) { - SpaSourceImpl *impl = SPA_CONTAINER_OF (source, SpaSourceImpl, source); + struct source_impl *impl = SPA_CONTAINER_OF (source, struct source_impl, source); impl->func.idle (&impl->impl->utils, source, source->data); } -static SpaSource * -loop_add_idle (SpaLoopUtils *utils, +static struct spa_source * +loop_add_idle (struct spa_loop_utils *utils, bool enabled, - SpaSourceIdleFunc func, + spa_source_idle_func_t func, void *data) { - struct loop *impl = SPA_CONTAINER_OF (utils, struct loop, utils); - SpaSourceImpl *source; + struct impl *impl = SPA_CONTAINER_OF (utils, struct impl, utils); + struct source_impl *source; - source = calloc (1, sizeof (SpaSourceImpl)); + source = calloc (1, sizeof (struct source_impl)); if (source == NULL) return NULL; @@ -414,10 +414,10 @@ loop_add_idle (SpaLoopUtils *utils, } static void -loop_enable_idle (SpaSource *source, +loop_enable_idle (struct spa_source *source, bool enabled) { - SpaSourceImpl *impl = SPA_CONTAINER_OF (source, SpaSourceImpl, source); + struct source_impl *impl = SPA_CONTAINER_OF (source, struct source_impl, source); uint64_t count; if (enabled && !impl->enabled) { @@ -432,9 +432,9 @@ loop_enable_idle (SpaSource *source, } static void -source_event_func (SpaSource *source) +source_event_func (struct spa_source *source) { - SpaSourceImpl *impl = SPA_CONTAINER_OF (source, SpaSourceImpl, source); + struct source_impl *impl = SPA_CONTAINER_OF (source, struct source_impl, source); uint64_t count; if (read (source->fd, &count, sizeof (uint64_t)) != sizeof (uint64_t)) @@ -443,15 +443,15 @@ source_event_func (SpaSource *source) impl->func.event (&impl->impl->utils, source, source->data); } -static SpaSource * -loop_add_event (SpaLoopUtils *utils, - SpaSourceEventFunc func, +static struct spa_source * +loop_add_event (struct spa_loop_utils *utils, + spa_source_event_func_t func, void *data) { - struct loop *impl = SPA_CONTAINER_OF (utils, struct loop, utils); - SpaSourceImpl *source; + struct impl *impl = SPA_CONTAINER_OF (utils, struct impl, utils); + struct source_impl *source; - source = calloc (1, sizeof (SpaSourceImpl)); + source = calloc (1, sizeof (struct source_impl)); if (source == NULL) return NULL; @@ -472,7 +472,7 @@ loop_add_event (SpaLoopUtils *utils, } static void -loop_signal_event (SpaSource *source) +loop_signal_event (struct spa_source *source) { uint64_t count = 1; @@ -481,9 +481,9 @@ loop_signal_event (SpaSource *source) } static void -source_timer_func (SpaSource *source) +source_timer_func (struct spa_source *source) { - SpaSourceImpl *impl = SPA_CONTAINER_OF (source, SpaSourceImpl, source); + struct source_impl *impl = SPA_CONTAINER_OF (source, struct source_impl, source); uint64_t expires; if (read (source->fd, &expires, sizeof (uint64_t)) != sizeof (uint64_t)) @@ -492,15 +492,15 @@ source_timer_func (SpaSource *source) impl->func.timer (&impl->impl->utils, source, source->data); } -static SpaSource * -loop_add_timer (SpaLoopUtils *utils, - SpaSourceTimerFunc func, +static struct spa_source * +loop_add_timer (struct spa_loop_utils *utils, + spa_source_timer_func_t func, void *data) { - struct loop *impl = SPA_CONTAINER_OF (utils, struct loop, utils); - SpaSourceImpl *source; + struct impl *impl = SPA_CONTAINER_OF (utils, struct impl, utils); + struct source_impl *source; - source = calloc (1, sizeof (SpaSourceImpl)); + source = calloc (1, sizeof (struct source_impl)); if (source == NULL) return NULL; @@ -520,8 +520,8 @@ loop_add_timer (SpaLoopUtils *utils, return &source->source; } -static SpaResult -loop_update_timer (SpaSource *source, +static int +loop_update_timer (struct spa_source *source, struct timespec *value, struct timespec *interval, bool absolute) @@ -549,9 +549,9 @@ loop_update_timer (SpaSource *source, } static void -source_signal_func (SpaSource *source) +source_signal_func (struct spa_source *source) { - SpaSourceImpl *impl = SPA_CONTAINER_OF (source, SpaSourceImpl, source); + struct source_impl *impl = SPA_CONTAINER_OF (source, struct source_impl, source); struct signalfd_siginfo signal_info; if (read (source->fd, &signal_info, sizeof (signal_info)) != sizeof (signal_info)) @@ -560,17 +560,17 @@ source_signal_func (SpaSource *source) impl->func.signal (&impl->impl->utils, source, impl->signal_number, source->data); } -static SpaSource * -loop_add_signal (SpaLoopUtils *utils, +static struct spa_source * +loop_add_signal (struct spa_loop_utils *utils, int signal_number, - SpaSourceSignalFunc func, + spa_source_signal_func_t func, void *data) { - struct loop *impl = SPA_CONTAINER_OF (utils, struct loop, utils); - SpaSourceImpl *source; + struct impl *impl = SPA_CONTAINER_OF (utils, struct impl, utils); + struct source_impl *source; sigset_t mask; - source = calloc (1, sizeof (SpaSourceImpl)); + source = calloc (1, sizeof (struct source_impl)); if (source == NULL) return NULL; @@ -595,9 +595,9 @@ loop_add_signal (SpaLoopUtils *utils, } static void -loop_destroy_source (SpaSource *source) +loop_destroy_source (struct spa_source *source) { - SpaSourceImpl *impl = SPA_CONTAINER_OF (source, SpaSourceImpl, source); + struct source_impl *impl = SPA_CONTAINER_OF (source, struct source_impl, source); spa_list_remove (&impl->link); @@ -611,10 +611,10 @@ loop_destroy_source (SpaSource *source) struct pw_loop * pw_loop_new (void) { - struct loop *impl; + struct impl *impl; struct pw_loop *this; - impl = calloc (1, sizeof (struct loop)); + impl = calloc (1, sizeof (struct impl)); if (impl == NULL) return NULL; @@ -629,14 +629,14 @@ pw_loop_new (void) pw_signal_init (&this->before_iterate); pw_signal_init (&this->destroy_signal); - impl->loop.size = sizeof (SpaLoop); + impl->loop.size = sizeof (struct spa_loop); impl->loop.add_source = loop_add_source; impl->loop.update_source = loop_update_source; impl->loop.remove_source = loop_remove_source; impl->loop.invoke = loop_invoke; this->loop = &impl->loop; - impl->control.size = sizeof (SpaLoopControl); + impl->control.size = sizeof (struct spa_loop_control); impl->control.get_fd = loop_get_fd; impl->control.set_hooks = loop_set_hooks; impl->control.enter = loop_enter; @@ -644,7 +644,7 @@ pw_loop_new (void) impl->control.iterate = loop_iterate; this->control = &impl->control; - impl->utils.size = sizeof (SpaLoopUtils); + impl->utils.size = sizeof (struct spa_loop_utils); impl->utils.add_io = loop_add_io; impl->utils.update_io = loop_update_io; impl->utils.add_idle = loop_add_idle; @@ -673,8 +673,8 @@ no_epoll: void pw_loop_destroy (struct pw_loop *loop) { - struct loop *impl = SPA_CONTAINER_OF (loop, struct loop, this); - SpaSourceImpl *source, *tmp; + struct impl *impl = SPA_CONTAINER_OF (loop, struct impl, this); + struct source_impl *source, *tmp; pw_signal_emit (&loop->destroy_signal, loop); diff --git a/pipewire/client/loop.h b/pipewire/client/loop.h index 95af48bb5..5a173fece 100644 --- a/pipewire/client/loop.h +++ b/pipewire/client/loop.h @@ -34,9 +34,9 @@ extern "C" { * PipeWire loop interface. */ struct pw_loop { - SpaLoop *loop; - SpaLoopControl *control; - SpaLoopUtils *utils; + struct spa_loop *loop; + struct spa_loop_control *control; + struct spa_loop_utils *utils; PW_SIGNAL (before_iterate, (struct pw_listener *listener, struct pw_loop *loop)); diff --git a/pipewire/client/mapper.c b/pipewire/client/mapper.c index 87aaa83e9..bc9826df1 100644 --- a/pipewire/client/mapper.c +++ b/pipewire/client/mapper.c @@ -27,16 +27,16 @@ #include -typedef struct { - SpaTypeMap map; +struct impl { + struct spa_type_map map; struct pw_map types; struct pw_array strings; -} TypeMap; +}; static uint32_t -type_map_get_id (SpaTypeMap *map, const char *type) +type_map_get_id (struct spa_type_map *map, const char *type) { - TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map); + struct impl *this = SPA_CONTAINER_OF (map, struct impl, map); uint32_t i = 0, len; void *p; off_t o; @@ -57,9 +57,9 @@ type_map_get_id (SpaTypeMap *map, const char *type) } static const char * -type_map_get_type (const SpaTypeMap *map, uint32_t id) +type_map_get_type (const struct spa_type_map *map, uint32_t id) { - TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map); + struct impl *this = SPA_CONTAINER_OF (map, struct impl, map); if (id == SPA_ID_INVALID) return NULL; @@ -72,14 +72,14 @@ type_map_get_type (const SpaTypeMap *map, uint32_t id) } static size_t -type_map_get_size (const SpaTypeMap *map) +type_map_get_size (const struct spa_type_map *map) { - TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map); + struct impl *this = SPA_CONTAINER_OF (map, struct impl, map); return pw_map_get_size (&this->types); } -static TypeMap default_type_map = { - { sizeof (SpaTypeMap), +static struct impl default_type_map = { + { sizeof (struct spa_type_map), NULL, type_map_get_id, type_map_get_type, @@ -89,7 +89,7 @@ static TypeMap default_type_map = { PW_ARRAY_INIT (4096) }; -SpaTypeMap * +struct spa_type_map * pw_type_map_get_default (void) { spa_type_map_set_default (&default_type_map.map); diff --git a/pipewire/client/mem.c b/pipewire/client/mem.c index c96df8d99..565cfb851 100644 --- a/pipewire/client/mem.c +++ b/pipewire/client/mem.c @@ -75,7 +75,7 @@ static inline int memfd_create(const char *name, unsigned int flags) { #undef USE_MEMFD -SpaResult +int pw_memblock_map (struct pw_memblock *mem) { if (mem->ptr != NULL) @@ -118,7 +118,7 @@ pw_memblock_map (struct pw_memblock *mem) return SPA_RESULT_OK; } -SpaResult +int pw_memblock_alloc (enum pw_memblock_flags flags, size_t size, struct pw_memblock *mem) diff --git a/pipewire/client/mem.h b/pipewire/client/mem.h index 28174f043..4e2bb87cc 100644 --- a/pipewire/client/mem.h +++ b/pipewire/client/mem.h @@ -45,10 +45,10 @@ struct pw_memblock { size_t size; }; -SpaResult pw_memblock_alloc (enum pw_memblock_flags flags, +int pw_memblock_alloc (enum pw_memblock_flags flags, size_t size, struct pw_memblock *mem); -SpaResult pw_memblock_map (struct pw_memblock *mem); +int pw_memblock_map (struct pw_memblock *mem); void pw_memblock_free (struct pw_memblock *mem); #ifdef __cplusplus diff --git a/pipewire/client/pipewire.h b/pipewire/client/pipewire.h index 89b695a21..36bc75242 100644 --- a/pipewire/client/pipewire.h +++ b/pipewire/client/pipewire.h @@ -51,7 +51,7 @@ void pw_fill_stream_properties (struct pw_properties *properties); enum pw_direction pw_direction_reverse (enum pw_direction direction); -SpaTypeMap * pw_type_map_get_default (void); +struct spa_type_map * pw_type_map_get_default (void); #ifdef __cplusplus } diff --git a/pipewire/client/properties.c b/pipewire/client/properties.c index f2cdef45a..975903550 100644 --- a/pipewire/client/properties.c +++ b/pipewire/client/properties.c @@ -29,19 +29,19 @@ struct properties { static void add_func (struct pw_properties *this, char *key, char *value) { - SpaDictItem *item; + struct spa_dict_item *item; struct properties *impl = SPA_CONTAINER_OF (this, struct properties, this); - item = pw_array_add (&impl->items, sizeof (SpaDictItem)); + item = pw_array_add (&impl->items, sizeof (struct spa_dict_item)); item->key = key; item->value = value; this->dict.items = impl->items.data; - this->dict.n_items = pw_array_get_len (&impl->items, SpaDictItem); + this->dict.n_items = pw_array_get_len (&impl->items, struct spa_dict_item); } static void -clear_item (SpaDictItem *item) +clear_item (struct spa_dict_item *item) { free ((char*)item->key); free ((char*)item->value); @@ -51,10 +51,10 @@ static int find_index (struct pw_properties *this, const char *key) { struct properties *impl = SPA_CONTAINER_OF (this, struct properties, this); - int i, len = pw_array_get_len (&impl->items, SpaDictItem); + int i, len = pw_array_get_len (&impl->items, struct spa_dict_item); for (i = 0; i < len; i++) { - SpaDictItem *item = pw_array_get_unchecked (&impl->items, i, SpaDictItem); + struct spa_dict_item *item = pw_array_get_unchecked (&impl->items, i, struct spa_dict_item); if (strcmp (item->key, key) == 0) return i; } @@ -103,7 +103,7 @@ pw_properties_new (const char *key, ...) * Returns: a new #struct pw_properties */ struct pw_properties * -pw_properties_new_dict (const SpaDict *dict) +pw_properties_new_dict (const struct spa_dict *dict) { uint32_t i; struct properties *impl; @@ -133,7 +133,7 @@ pw_properties_copy (struct pw_properties *properties) { struct properties *impl = SPA_CONTAINER_OF (properties, struct properties, this); struct pw_properties *copy; - SpaDictItem *item; + struct spa_dict_item *item; copy = pw_properties_new (NULL, NULL); if (copy == NULL) @@ -185,7 +185,7 @@ void pw_properties_free (struct pw_properties *properties) { struct properties *impl = SPA_CONTAINER_OF (properties, struct properties, this); - SpaDictItem *item; + struct spa_dict_item *item; pw_array_for_each (item, &impl->items) clear_item (item); @@ -205,16 +205,16 @@ do_replace (struct pw_properties *properties, if (index == -1) { add_func (properties, key, value); } else { - SpaDictItem *item = pw_array_get_unchecked (&impl->items, index, SpaDictItem); + struct spa_dict_item *item = pw_array_get_unchecked (&impl->items, index, struct spa_dict_item); clear_item (item); if (value == NULL) { - SpaDictItem *other = pw_array_get_unchecked (&impl->items, - pw_array_get_len (&impl->items, SpaDictItem) - 1, - SpaDictItem); + struct spa_dict_item *other = pw_array_get_unchecked (&impl->items, + pw_array_get_len (&impl->items, struct spa_dict_item) - 1, + struct spa_dict_item); item->key = other->key; item->value = other->value; - impl->items.size -= sizeof (SpaDictItem); + impl->items.size -= sizeof (struct spa_dict_item); } else { item->key = key; item->value = value; @@ -285,7 +285,7 @@ pw_properties_get (struct pw_properties *properties, if (index == -1) return NULL; - return pw_array_get_unchecked (&impl->items, index, SpaDictItem)->value; + return pw_array_get_unchecked (&impl->items, index, struct spa_dict_item)->value; } /** @@ -314,10 +314,10 @@ pw_properties_iterate (struct pw_properties *properties, else index = SPA_PTR_TO_INT (*state); - if (!pw_array_check_index (&impl->items, index, SpaDictItem)) + if (!pw_array_check_index (&impl->items, index, struct spa_dict_item)) return NULL; *state = SPA_INT_TO_PTR (index + 1); - return pw_array_get_unchecked (&impl->items, index, SpaDictItem)->key; + return pw_array_get_unchecked (&impl->items, index, struct spa_dict_item)->key; } diff --git a/pipewire/client/properties.h b/pipewire/client/properties.h index 4f58acadc..a539f9eaa 100644 --- a/pipewire/client/properties.h +++ b/pipewire/client/properties.h @@ -27,11 +27,11 @@ extern "C" { #include struct pw_properties { - SpaDict dict; + struct spa_dict dict; }; struct pw_properties * pw_properties_new (const char *key, ...); -struct pw_properties * pw_properties_new_dict (const SpaDict *dict); +struct pw_properties * pw_properties_new_dict (const struct spa_dict *dict); struct pw_properties * pw_properties_copy (struct pw_properties *properties); struct pw_properties * pw_properties_merge (struct pw_properties *oldprops, struct pw_properties *newprops); diff --git a/pipewire/client/protocol-native.c b/pipewire/client/protocol-native.c index cb05ca62c..955459423 100644 --- a/pipewire/client/protocol-native.c +++ b/pipewire/client/protocol-native.c @@ -27,14 +27,14 @@ #include "pipewire/client/connection.h" struct builder { - SpaPODBuilder b; + struct spa_pod_builder b; struct pw_connection *connection; }; typedef bool (*demarshal_func_t) (void *object, void *data, size_t size); static uint32_t -write_pod (SpaPODBuilder *b, uint32_t ref, const void *data, uint32_t size) +write_pod (struct spa_pod_builder *b, uint32_t ref, const void *data, uint32_t size) { if (ref == -1) ref = b->offset; @@ -71,12 +71,12 @@ core_update_map (struct pw_context *context) static void core_marshal_client_update (void *object, - const SpaDict *props) + const struct spa_dict *props) { struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; int i, n_items; if (connection == NULL) @@ -108,7 +108,7 @@ core_marshal_sync (void *object, struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; if (connection == NULL) return; @@ -128,7 +128,7 @@ core_marshal_get_registry (void *object, struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; if (connection == NULL) return; @@ -145,13 +145,13 @@ static void core_marshal_create_node (void *object, const char *factory_name, const char *name, - const SpaDict *props, + const struct spa_dict *props, uint32_t new_id) { struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; uint32_t i, n_items; if (connection == NULL) @@ -183,13 +183,13 @@ core_marshal_create_node (void *object, static void core_marshal_create_client_node (void *object, const char *name, - const SpaDict *props, + const struct spa_dict *props, uint32_t new_id) { struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; uint32_t i, n_items; if (connection == NULL) @@ -226,7 +226,7 @@ core_marshal_update_types (void *object, struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; uint32_t i; if (connection == NULL) @@ -253,9 +253,9 @@ core_demarshal_info (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaDict props; + struct spa_dict props; struct pw_core_info info; - SpaPODIter it; + struct spa_pod_iter it; int i; if (!spa_pod_iter_struct (&it, data, size) || @@ -272,7 +272,7 @@ core_demarshal_info (void *object, return false; info.props = &props; - props.items = alloca (props.n_items * sizeof (SpaDictItem)); + props.items = alloca (props.n_items * sizeof (struct spa_dict_item)); for (i = 0; i < props.n_items; i++) { if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &props.items[i].key, @@ -290,7 +290,7 @@ core_demarshal_done (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t seq; if (!spa_pod_iter_struct (&it, data, size) || @@ -309,7 +309,7 @@ core_demarshal_error (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t id, res; const char *error; @@ -331,7 +331,7 @@ core_demarshal_remove_id (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t id; if (!spa_pod_iter_struct (&it, data, size) || @@ -350,7 +350,7 @@ core_demarshal_update_types (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t first_id, n_types; const char **types; int i; @@ -377,8 +377,8 @@ module_demarshal_info (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; - SpaDict props; + struct spa_pod_iter it; + struct spa_dict props; struct pw_module_info info; int i; @@ -394,7 +394,7 @@ module_demarshal_info (void *object, return false; info.props = &props; - props.items = alloca (props.n_items * sizeof (SpaDictItem)); + props.items = alloca (props.n_items * sizeof (struct spa_dict_item)); for (i = 0; i < props.n_items; i++) { if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &props.items[i].key, @@ -412,8 +412,8 @@ node_demarshal_info (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; - SpaDict props; + struct spa_pod_iter it; + struct spa_dict props; struct pw_node_info info; int i; @@ -429,7 +429,7 @@ node_demarshal_info (void *object, 0)) return false; - info.input_formats = alloca (info.n_input_formats * sizeof (SpaFormat*)); + info.input_formats = alloca (info.n_input_formats * sizeof (struct spa_format*)); for (i = 0; i < info.n_input_formats; i++) if (!spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &info.input_formats[i], 0)) return false; @@ -441,7 +441,7 @@ node_demarshal_info (void *object, 0)) return false; - info.output_formats = alloca (info.n_output_formats * sizeof (SpaFormat*)); + info.output_formats = alloca (info.n_output_formats * sizeof (struct spa_format*)); for (i = 0; i < info.n_output_formats; i++) if (!spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &info.output_formats[i], 0)) return false; @@ -454,7 +454,7 @@ node_demarshal_info (void *object, return false; info.props = &props; - props.items = alloca (props.n_items * sizeof (SpaDictItem)); + props.items = alloca (props.n_items * sizeof (struct spa_dict_item)); for (i = 0; i < props.n_items; i++) { if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &props.items[i].key, @@ -471,12 +471,12 @@ client_node_marshal_update (void *object, uint32_t change_mask, uint32_t max_input_ports, uint32_t max_output_ports, - const SpaProps *props) + const struct spa_props *props) { struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; if (connection == NULL) return; @@ -494,20 +494,20 @@ client_node_marshal_update (void *object, static void client_node_marshal_port_update (void *object, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t change_mask, uint32_t n_possible_formats, - const SpaFormat **possible_formats, - const SpaFormat *format, + const struct spa_format **possible_formats, + const struct spa_format *format, uint32_t n_params, - const SpaParam **params, - const SpaPortInfo *info) + const struct spa_param **params, + const struct spa_port_info *info) { struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f[2]; + struct spa_pod_frame f[2]; int i; if (connection == NULL) @@ -532,7 +532,7 @@ client_node_marshal_port_update (void *object, 0); for (i = 0; i < n_params; i++) { - const SpaParam *p = params[i]; + const struct spa_param *p = params[i]; spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, p, 0); } @@ -553,12 +553,12 @@ client_node_marshal_port_update (void *object, static void client_node_marshal_event (void *object, - SpaEvent *event) + struct spa_event *event) { struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; if (connection == NULL) return; @@ -577,7 +577,7 @@ client_node_marshal_destroy (void *object) struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; if (connection == NULL) return; @@ -595,7 +595,7 @@ client_node_demarshal_done (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; struct pw_connection *connection = proxy->context->protocol_private; int32_t ridx, widx; int readfd, writefd; @@ -622,8 +622,8 @@ client_node_demarshal_event (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; - const SpaEvent *event; + struct spa_pod_iter it; + const struct spa_event *event; if (!spa_pod_iter_struct (&it, data, size) || !pw_pod_remap_data (SPA_POD_TYPE_STRUCT, data, size, &proxy->context->types) || @@ -642,7 +642,7 @@ client_node_demarshal_add_port (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; int32_t seq, direction, port_id; if (!spa_pod_iter_struct (&it, data, size) || @@ -663,7 +663,7 @@ client_node_demarshal_remove_port (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; int32_t seq, direction, port_id; if (!spa_pod_iter_struct (&it, data, size) || @@ -684,9 +684,9 @@ client_node_demarshal_set_format (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t seq, direction, port_id, flags; - const SpaFormat *format = NULL; + const struct spa_format *format = NULL; if (!spa_pod_iter_struct (&it, data, size) || !pw_pod_remap_data (SPA_POD_TYPE_STRUCT, data, size, &proxy->context->types) || @@ -710,7 +710,7 @@ client_node_demarshal_set_property (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t seq, id; const void *value; uint32_t s; @@ -733,7 +733,7 @@ client_node_demarshal_add_mem (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; struct pw_connection *connection = proxy->context->protocol_private; uint32_t direction, port_id, mem_id, type, memfd_idx, flags, offset, sz; int memfd; @@ -772,7 +772,7 @@ client_node_demarshal_use_buffers (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t seq, direction, port_id, n_buffers, data_id; struct pw_client_node_buffer *buffers; int i, j; @@ -789,7 +789,7 @@ client_node_demarshal_use_buffers (void *object, buffers = alloca (sizeof (struct pw_client_node_buffer) * n_buffers); for (i = 0; i < n_buffers; i++) { - SpaBuffer *buf = buffers[i].buffer = alloca (sizeof (SpaBuffer)); + struct spa_buffer *buf = buffers[i].buffer = alloca (sizeof (struct spa_buffer)); if (!spa_pod_iter_get (&it, SPA_POD_TYPE_INT, &buffers[i].mem_id, @@ -799,9 +799,9 @@ client_node_demarshal_use_buffers (void *object, SPA_POD_TYPE_INT, &buf->n_metas, 0)) return false; - buf->metas = alloca (sizeof (SpaMeta) * buf->n_metas); + buf->metas = alloca (sizeof (struct spa_meta) * buf->n_metas); for (j = 0; j < buf->n_metas; j++) { - SpaMeta *m = &buf->metas[j]; + struct spa_meta *m = &buf->metas[j]; if (!spa_pod_iter_get (&it, SPA_POD_TYPE_ID, &m->type, @@ -811,9 +811,9 @@ client_node_demarshal_use_buffers (void *object, if (!spa_pod_iter_get (&it, SPA_POD_TYPE_INT, &buf->n_datas, 0)) return false; - buf->datas = alloca (sizeof (SpaData) * buf->n_datas); + buf->datas = alloca (sizeof (struct spa_data) * buf->n_datas); for (j = 0; j < buf->n_datas; j++) { - SpaData *d = &buf->datas[j]; + struct spa_data *d = &buf->datas[j]; if (!spa_pod_iter_get (&it, SPA_POD_TYPE_ID, &d->type, @@ -842,8 +842,8 @@ client_node_demarshal_node_command (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; - const SpaCommand *command; + struct spa_pod_iter it; + const struct spa_command *command; uint32_t seq; if (!spa_pod_iter_struct (&it, data, size) || @@ -864,8 +864,8 @@ client_node_demarshal_port_command (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; - const SpaCommand *command; + struct spa_pod_iter it; + const struct spa_command *command; uint32_t port_id; if (!spa_pod_iter_struct (&it, data, size) || @@ -886,7 +886,7 @@ client_node_demarshal_transport (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; struct pw_connection *connection = proxy->context->protocol_private; uint32_t memfd_idx, offset, sz; int memfd; @@ -910,8 +910,8 @@ client_demarshal_info (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; - SpaDict props; + struct spa_pod_iter it; + struct spa_dict props; struct pw_client_info info; uint32_t i; @@ -924,7 +924,7 @@ client_demarshal_info (void *object, return false; info.props = &props; - props.items = alloca (props.n_items * sizeof (SpaDictItem)); + props.items = alloca (props.n_items * sizeof (struct spa_dict_item)); for (i = 0; i < props.n_items; i++) { if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &props.items[i].key, @@ -942,7 +942,7 @@ link_demarshal_info (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; struct pw_link_info info; if (!spa_pod_iter_struct (&it, data, size) || @@ -966,7 +966,7 @@ registry_demarshal_global (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t id; const char *type; @@ -987,7 +987,7 @@ registry_demarshal_global_remove (void *object, size_t size) { struct pw_proxy *proxy = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t id; if (!spa_pod_iter_struct (&it, data, size) || @@ -1008,7 +1008,7 @@ registry_marshal_bind (void *object, struct pw_proxy *proxy = object; struct pw_connection *connection = proxy->context->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; if (connection == NULL) return; diff --git a/pipewire/client/proxy.h b/pipewire/client/proxy.h index f89f5f56e..407d07f50 100644 --- a/pipewire/client/proxy.h +++ b/pipewire/client/proxy.h @@ -30,7 +30,7 @@ extern "C" { struct pw_proxy { struct pw_context *context; - SpaList link; + struct spa_list link; uint32_t id; uint32_t type; diff --git a/pipewire/client/sig.h b/pipewire/client/sig.h index 7f08a0544..e801597b0 100644 --- a/pipewire/client/sig.h +++ b/pipewire/client/sig.h @@ -27,13 +27,13 @@ extern "C" { #endif struct pw_listener { - SpaList link; + struct spa_list link; void (*notify) (void *); }; #define PW_SIGNAL(name,func) \ union { \ - SpaList listeners; \ + struct spa_list listeners; \ void (*notify) func; \ } name; diff --git a/pipewire/client/stream.c b/pipewire/client/stream.c index 64106e1e5..ef238a0c6 100644 --- a/pipewire/client/stream.c +++ b/pipewire/client/stream.c @@ -51,25 +51,25 @@ struct mem_id { }; struct buffer_id { - SpaList link; + struct spa_list link; uint32_t id; bool used; void *buf_ptr; - SpaBuffer *buf; + struct spa_buffer *buf; }; struct stream { struct pw_stream this; uint32_t n_possible_formats; - SpaFormat **possible_formats; + struct spa_format **possible_formats; uint32_t n_params; - SpaParam **params; + struct spa_param **params; - SpaFormat *format; - SpaPortInfo port_info; - SpaDirection direction; + struct spa_format *format; + struct spa_port_info port_info; + enum spa_direction direction; uint32_t port_id; uint32_t pending_seq; @@ -77,7 +77,7 @@ struct stream { int rtreadfd; int rtwritefd; - SpaSource *rtsocket_source; + struct spa_source *rtsocket_source; struct pw_proxy *node_proxy; bool disconnecting; @@ -85,13 +85,13 @@ struct stream { struct pw_transport *trans; - SpaSource *timeout_source; + struct spa_source *timeout_source; struct pw_array mem_ids; struct pw_array buffer_ids; bool in_order; - SpaList free; + struct spa_list free; bool in_need_buffer; int64_t last_ticks; @@ -272,7 +272,7 @@ unhandle_socket (struct pw_stream *stream) static void set_possible_formats (struct pw_stream *stream, int n_possible_formats, - SpaFormat **possible_formats) + struct spa_format **possible_formats) { struct stream *impl = SPA_CONTAINER_OF (stream, struct stream, this); int i; @@ -285,7 +285,7 @@ set_possible_formats (struct pw_stream *stream, } impl->n_possible_formats = n_possible_formats; if (n_possible_formats > 0) { - impl->possible_formats = malloc (n_possible_formats * sizeof (SpaFormat *)); + impl->possible_formats = malloc (n_possible_formats * sizeof (struct spa_format *)); for (i = 0; i < n_possible_formats; i++) impl->possible_formats[i] = spa_format_copy (possible_formats[i]); } @@ -294,7 +294,7 @@ set_possible_formats (struct pw_stream *stream, static void set_params (struct pw_stream *stream, int n_params, - SpaParam **params) + struct spa_param **params) { struct stream *impl = SPA_CONTAINER_OF (stream, struct stream, this); int i; @@ -307,7 +307,7 @@ set_params (struct pw_stream *stream, } impl->n_params = n_params; if (n_params > 0) { - impl->params = malloc (n_params * sizeof (SpaParam *)); + impl->params = malloc (n_params * sizeof (struct spa_param *)); for (i = 0; i < n_params; i++) impl->params[i] = spa_param_copy (params[i]); } @@ -384,10 +384,10 @@ add_port_update (struct pw_stream *stream, uint32_t change_mask) impl->port_id, change_mask, impl->n_possible_formats, - (const SpaFormat **) impl->possible_formats, + (const struct spa_format **) impl->possible_formats, impl->format, impl->n_params, - (const SpaParam **)impl->params, + (const struct spa_param **)impl->params, &impl->port_info); } @@ -396,14 +396,10 @@ send_need_input (struct pw_stream *stream) { #if 0 struct stream *impl = SPA_CONTAINER_OF (stream, struct stream, this); - SpaEventNodeNeedInput ni; uint64_t cmd = 1; - pw_log_debug ("stream %p: need input", stream); - - ni.event.type = SPA_EVENT_NODE_NEED_INPUT; - ni.event.size = sizeof (ni); - pw_transport_add_event (impl->trans, &ni.event); + pw_transport_add_event (impl->trans, + &SPA_EVENT_INIT (stream->context->type.event_transport.NeedInput)); write (impl->rtwritefd, &cmd, 8); #endif } @@ -424,7 +420,7 @@ add_request_clock_update (struct pw_stream *stream) { struct stream *impl = SPA_CONTAINER_OF (stream, struct stream, this); - pw_client_node_do_event (impl->node_proxy, (SpaEvent*) + pw_client_node_do_event (impl->node_proxy, (struct spa_event*) &SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_INIT (stream->context->type.event_node.RequestClockUpdate, SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_TIME, 0, 0)); } @@ -432,11 +428,11 @@ add_request_clock_update (struct pw_stream *stream) static void add_async_complete (struct pw_stream *stream, uint32_t seq, - SpaResult res) + int res) { struct stream *impl = SPA_CONTAINER_OF (stream, struct stream, this); - pw_client_node_do_event (impl->node_proxy, (SpaEvent*) + pw_client_node_do_event (impl->node_proxy, (struct spa_event*) &SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (stream->context->type.event_node.AsyncComplete, seq, res)); @@ -457,8 +453,8 @@ do_node_init (struct pw_stream *stream) } static void -on_timeout (SpaLoopUtils *utils, - SpaSource *source, +on_timeout (struct spa_loop_utils *utils, + struct spa_source *source, void *data) { struct pw_stream *stream = data; @@ -512,7 +508,7 @@ reuse_buffer (struct pw_stream *stream, uint32_t id) static void handle_rtnode_event (struct pw_stream *stream, - SpaEvent *event) + struct spa_event *event) { struct stream *impl = SPA_CONTAINER_OF (stream, struct stream, this); struct pw_context *context = impl->this.context; @@ -521,7 +517,7 @@ handle_rtnode_event (struct pw_stream *stream, int i; for (i = 0; i < impl->trans->area->n_inputs; i++) { - SpaPortIO *input = &impl->trans->inputs[i]; + struct spa_port_io *input = &impl->trans->inputs[i]; pw_log_trace ("stream %p: have output %d %d", stream, input->status, input->buffer_id); if (input->buffer_id == SPA_ID_INVALID) @@ -536,7 +532,7 @@ handle_rtnode_event (struct pw_stream *stream, int i; for (i = 0; i < impl->trans->area->n_outputs; i++) { - SpaPortIO *output = &impl->trans->outputs[i]; + struct spa_port_io *output = &impl->trans->outputs[i]; if (output->buffer_id == SPA_ID_INVALID) continue; @@ -565,10 +561,10 @@ handle_rtnode_event (struct pw_stream *stream, } static void -on_rtsocket_condition (SpaLoopUtils *utils, - SpaSource *source, +on_rtsocket_condition (struct spa_loop_utils *utils, + struct spa_source *source, int fd, - SpaIO mask, + enum spa_io mask, void *data) { struct pw_stream *stream = data; @@ -581,13 +577,13 @@ on_rtsocket_condition (SpaLoopUtils *utils, } if (mask & SPA_IO_IN) { - SpaEvent event; + struct spa_event event; uint64_t cmd; read (impl->rtreadfd, &cmd, 8); while (pw_transport_next_event (impl->trans, &event) == SPA_RESULT_OK) { - SpaEvent *ev = alloca (SPA_POD_SIZE (&event)); + struct spa_event *ev = alloca (SPA_POD_SIZE (&event)); pw_transport_parse_event (impl->trans, ev); handle_rtnode_event (stream, ev); } @@ -624,7 +620,7 @@ handle_socket (struct pw_stream *stream, int rtreadfd, int rtwritefd) static void handle_node_event (struct pw_stream *stream, - const SpaEvent *event) + const struct spa_event *event) { pw_log_warn ("unhandled node event %d", SPA_EVENT_TYPE (event)); } @@ -632,7 +628,7 @@ handle_node_event (struct pw_stream *stream, static bool handle_node_command (struct pw_stream *stream, uint32_t seq, - const SpaCommand *command) + const struct spa_command *command) { struct stream *impl = SPA_CONTAINER_OF (stream, struct stream, this); struct pw_context *context = stream->context; @@ -671,7 +667,7 @@ handle_node_command (struct pw_stream *stream, } } else if (SPA_COMMAND_TYPE (command) == context->type.command_node.ClockUpdate) { - SpaCommandNodeClockUpdate *cu = (SpaCommandNodeClockUpdate *) command; + struct spa_command_node_clock_update *cu = (struct spa_command_node_clock_update *) command; if (cu->body.flags.value & SPA_COMMAND_NODE_CLOCK_UPDATE_FLAG_LIVE) { pw_properties_set (stream->properties, "pipewire.latency.is-live", "1"); @@ -706,7 +702,7 @@ client_node_done (void *object, static void client_node_event (void *object, - const SpaEvent *event) + const struct spa_event *event) { struct pw_proxy *proxy = object; struct pw_stream *stream = proxy->user_data; @@ -716,7 +712,7 @@ client_node_event (void *object, static void client_node_add_port (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id) { pw_log_warn ("add port not supported"); @@ -725,7 +721,7 @@ client_node_add_port (void *object, static void client_node_remove_port (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id) { pw_log_warn ("remove port not supported"); @@ -734,10 +730,10 @@ client_node_remove_port (void *object, static void client_node_set_format (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { struct pw_proxy *proxy = object; struct pw_stream *stream = proxy->user_data; @@ -768,7 +764,7 @@ client_node_set_property (void *object, static void client_node_add_mem (void *object, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t mem_id, uint32_t type, @@ -803,7 +799,7 @@ client_node_add_mem (void *object, static void client_node_use_buffers (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t n_buffers, struct pw_client_node_buffer *buffers) @@ -813,7 +809,7 @@ client_node_use_buffers (void *object, struct stream *impl = SPA_CONTAINER_OF (stream, struct stream, this); struct buffer_id *bid; uint32_t i, j, len; - SpaBuffer *b; + struct spa_buffer *b; /* clear previous buffers */ clear_buffers (stream); @@ -852,17 +848,17 @@ client_node_use_buffers (void *object, { size_t size; - size = sizeof (SpaBuffer); + size = sizeof (struct spa_buffer); for (j = 0; j < buffers[i].buffer->n_metas; j++) - size += sizeof (SpaMeta); + size += sizeof (struct spa_meta); for (j = 0; j < buffers[i].buffer->n_datas; j++) - size += sizeof (SpaData); + size += sizeof (struct spa_data); b = bid->buf = malloc (size); - memcpy (b, buffers[i].buffer, sizeof (SpaBuffer)); + memcpy (b, buffers[i].buffer, sizeof (struct spa_buffer)); - b->metas = SPA_MEMBER (b, sizeof (SpaBuffer), SpaMeta); - b->datas = SPA_MEMBER (b->metas, sizeof(SpaMeta) * b->n_metas, SpaData); + b->metas = SPA_MEMBER (b, sizeof (struct spa_buffer), struct spa_meta); + b->datas = SPA_MEMBER (b->metas, sizeof(struct spa_meta) * b->n_metas, struct spa_data); } bid->id = b->id; @@ -874,17 +870,17 @@ client_node_use_buffers (void *object, offset = 0; for (j = 0; j < b->n_metas; j++) { - SpaMeta *m = &b->metas[j]; - memcpy (m, &buffers[i].buffer->metas[j], sizeof (SpaMeta)); + struct spa_meta *m = &b->metas[j]; + memcpy (m, &buffers[i].buffer->metas[j], sizeof (struct spa_meta)); m->data = SPA_MEMBER (bid->buf_ptr, offset, void); offset += m->size; } for (j = 0; j < b->n_datas; j++) { - SpaData *d = &b->datas[j]; + struct spa_data *d = &b->datas[j]; - memcpy (d, &buffers[i].buffer->datas[j], sizeof (SpaData)); - d->chunk = SPA_MEMBER (bid->buf_ptr, offset + sizeof (SpaChunk) * j, SpaChunk); + memcpy (d, &buffers[i].buffer->datas[j], sizeof (struct spa_data)); + d->chunk = SPA_MEMBER (bid->buf_ptr, offset + sizeof (struct spa_chunk) * j, struct spa_chunk); if (d->type == stream->context->type.data.Id) { struct mem_id *bmid = find_mem (stream, SPA_PTR_TO_UINT32 (d->data)); @@ -918,7 +914,7 @@ client_node_use_buffers (void *object, static void client_node_node_command (void *object, uint32_t seq, - const SpaCommand *command) + const struct spa_command *command) { struct pw_proxy *proxy = object; struct pw_stream *stream = proxy->user_data; @@ -928,7 +924,7 @@ client_node_node_command (void *object, static void client_node_port_command (void *object, uint32_t port_id, - const SpaCommand *command) + const struct spa_command *command) { pw_log_warn ("port command not supported"); } @@ -1009,7 +1005,7 @@ pw_stream_connect (struct pw_stream *stream, const char *port_path, enum pw_stream_flags flags, uint32_t n_possible_formats, - SpaFormat **possible_formats) + struct spa_format **possible_formats) { struct stream *impl = SPA_CONTAINER_OF (stream, struct stream, this); @@ -1053,8 +1049,8 @@ pw_stream_connect (struct pw_stream *stream, /** * pw_stream_finish_format: * @stream: a #struct pw_stream - * @res: a #SpaResult - * @params: an array of pointers to #SpaParam + * @res: a #int + * @params: an array of pointers to #struct spa_param * @n_params: number of elements in @params * * Complete the negotiation process with result code @res. @@ -1068,8 +1064,8 @@ pw_stream_connect (struct pw_stream *stream, */ bool pw_stream_finish_format (struct pw_stream *stream, - SpaResult res, - SpaParam **params, + int res, + struct spa_param **params, uint32_t n_params) { struct stream *impl = SPA_CONTAINER_OF (stream, struct stream, this); @@ -1180,7 +1176,7 @@ pw_stream_recycle_buffer (struct pw_stream *stream, bid->used = false; spa_list_insert (impl->free.prev, &bid->link); - pw_transport_add_event (impl->trans, (SpaEvent *)&rb); + pw_transport_add_event (impl->trans, (struct spa_event *)&rb); write (impl->rtwritefd, &cmd, 8); return true; @@ -1194,9 +1190,9 @@ pw_stream_recycle_buffer (struct pw_stream *stream, * Get the buffer with @id from @stream. This function should be called from * the new-buffer signal callback. * - * Returns: a #SpaBuffer or %NULL when there is no buffer. + * Returns: a #struct spa_buffer or %NULL when there is no buffer. */ -SpaBuffer * +struct spa_buffer * pw_stream_peek_buffer (struct pw_stream *stream, uint32_t id) { diff --git a/pipewire/client/stream.h b/pipewire/client/stream.h index fbbd2920c..579a650dd 100644 --- a/pipewire/client/stream.h +++ b/pipewire/client/stream.h @@ -65,7 +65,7 @@ struct pw_time{ */ struct pw_stream { struct pw_context *context; - SpaList link; + struct spa_list link; char *name; struct pw_properties *properties; @@ -80,7 +80,7 @@ struct pw_stream { PW_SIGNAL (format_changed, (struct pw_listener *listener, struct pw_stream *stream, - SpaFormat *format)); + struct spa_format *format)); PW_SIGNAL (add_buffer, (struct pw_listener *listener, struct pw_stream *stream, @@ -106,12 +106,12 @@ bool pw_stream_connect (struct pw_stream *stream, const char *port_path, enum pw_stream_flags flags, uint32_t n_possible_formats, - SpaFormat **possible_formats); + struct spa_format **possible_formats); bool pw_stream_disconnect (struct pw_stream *stream); bool pw_stream_finish_format (struct pw_stream *stream, - SpaResult res, - SpaParam **params, + int res, + struct spa_param **params, uint32_t n_params); bool pw_stream_get_time (struct pw_stream *stream, @@ -120,7 +120,7 @@ bool pw_stream_get_time (struct pw_stream *stream, uint32_t pw_stream_get_empty_buffer (struct pw_stream *stream); bool pw_stream_recycle_buffer (struct pw_stream *stream, uint32_t id); -SpaBuffer * pw_stream_peek_buffer (struct pw_stream *stream, +struct spa_buffer *pw_stream_peek_buffer (struct pw_stream *stream, uint32_t id); bool pw_stream_send_buffer (struct pw_stream *stream, uint32_t id); diff --git a/pipewire/client/thread-mainloop.c b/pipewire/client/thread-mainloop.c index 9de3f766f..8bc45feb0 100644 --- a/pipewire/client/thread-mainloop.c +++ b/pipewire/client/thread-mainloop.c @@ -34,14 +34,14 @@ struct thread_main_loop { bool running; pthread_t thread; - SpaSource *event; + struct spa_source *event; int n_waiting; int n_waiting_for_accept; }; static void -pre_hook (SpaLoopControl *ctrl, +pre_hook (struct spa_loop_control *ctrl, void *data) { struct thread_main_loop *impl = data; @@ -49,7 +49,7 @@ pre_hook (SpaLoopControl *ctrl, } static void -post_hook (SpaLoopControl *ctrl, +post_hook (struct spa_loop_control *ctrl, void *data) { struct thread_main_loop *impl = data; @@ -57,8 +57,8 @@ post_hook (SpaLoopControl *ctrl, } static void -do_stop (SpaLoopUtils *utils, - SpaSource *source, +do_stop (struct spa_loop_utils *utils, + struct spa_source *source, void *data) { struct thread_main_loop *impl = data; @@ -136,7 +136,7 @@ do_loop (void *user_data) { struct thread_main_loop *impl = user_data; struct pw_thread_main_loop *this = &impl->this; - SpaResult res; + int res; pthread_mutex_lock (&impl->lock); pw_log_debug ("thread-mainloop %p: enter thread", this); @@ -161,7 +161,7 @@ do_loop (void *user_data) * * Returns: %SPA_RESULT_OK on success. */ -SpaResult +int pw_thread_main_loop_start (struct pw_thread_main_loop *loop) { struct thread_main_loop *impl = SPA_CONTAINER_OF (loop, struct thread_main_loop, this); diff --git a/pipewire/client/thread-mainloop.h b/pipewire/client/thread-mainloop.h index ccdd5df32..62a386cf8 100644 --- a/pipewire/client/thread-mainloop.h +++ b/pipewire/client/thread-mainloop.h @@ -43,7 +43,7 @@ struct pw_thread_main_loop * pw_thread_main_loop_new (struct pw_loo const char *name); void pw_thread_main_loop_destroy (struct pw_thread_main_loop *loop); -SpaResult pw_thread_main_loop_start (struct pw_thread_main_loop *loop); +int pw_thread_main_loop_start (struct pw_thread_main_loop *loop); void pw_thread_main_loop_stop (struct pw_thread_main_loop *loop); void pw_thread_main_loop_lock (struct pw_thread_main_loop *loop); diff --git a/pipewire/client/transport.c b/pipewire/client/transport.c index 0287b7829..8117e577e 100644 --- a/pipewire/client/transport.c +++ b/pipewire/client/transport.c @@ -38,7 +38,7 @@ struct transport { struct pw_memblock mem; size_t offset; - SpaEvent current; + struct spa_event current; uint32_t current_index; }; @@ -47,11 +47,11 @@ transport_area_get_size (struct pw_transport_area *area) { size_t size; size = sizeof (struct pw_transport_area); - size += area->max_inputs * sizeof (SpaPortIO); - size += area->max_outputs * sizeof (SpaPortIO); - size += sizeof (SpaRingbuffer); + size += area->max_inputs * sizeof (struct spa_port_io); + size += area->max_outputs * sizeof (struct spa_port_io); + size += sizeof (struct spa_ringbuffer); size += INPUT_BUFFER_SIZE; - size += sizeof (SpaRingbuffer); + size += sizeof (struct spa_ringbuffer); size += OUTPUT_BUFFER_SIZE; return size; } @@ -62,22 +62,22 @@ transport_setup_area (void *p, struct pw_transport *trans) struct pw_transport_area *a; trans->area = a = p; - p = SPA_MEMBER (p, sizeof (struct pw_transport_area), SpaPortIO); + p = SPA_MEMBER (p, sizeof (struct pw_transport_area), struct spa_port_io); trans->inputs = p; - p = SPA_MEMBER (p, a->max_inputs * sizeof (SpaPortIO), void); + p = SPA_MEMBER (p, a->max_inputs * sizeof (struct spa_port_io), void); trans->outputs = p; - p = SPA_MEMBER (p, a->max_outputs * sizeof (SpaPortIO), void); + p = SPA_MEMBER (p, a->max_outputs * sizeof (struct spa_port_io), void); trans->input_buffer = p; - p = SPA_MEMBER (p, sizeof (SpaRingbuffer), void); + p = SPA_MEMBER (p, sizeof (struct spa_ringbuffer), void); trans->input_data = p; p = SPA_MEMBER (p, INPUT_BUFFER_SIZE, void); trans->output_buffer = p; - p = SPA_MEMBER (p, sizeof (SpaRingbuffer), void); + p = SPA_MEMBER (p, sizeof (struct spa_ringbuffer), void); trans->output_data = p; p = SPA_MEMBER (p, OUTPUT_BUFFER_SIZE, void); @@ -193,7 +193,7 @@ pw_transport_destroy (struct pw_transport *trans) free (impl); } -SpaResult +int pw_transport_get_info (struct pw_transport *trans, struct pw_transport_info *info) { @@ -206,9 +206,9 @@ pw_transport_get_info (struct pw_transport *trans, return SPA_RESULT_OK; } -SpaResult +int pw_transport_add_event (struct pw_transport *trans, - SpaEvent *event) + struct spa_event *event) { struct transport *impl = (struct transport *) trans; int32_t filled, avail; @@ -233,9 +233,9 @@ pw_transport_add_event (struct pw_transport *trans, return SPA_RESULT_OK; } -SpaResult +int pw_transport_next_event (struct pw_transport *trans, - SpaEvent *event) + struct spa_event *event) { struct transport *impl = (struct transport *) trans; int32_t avail; @@ -244,21 +244,21 @@ pw_transport_next_event (struct pw_transport *trans, return SPA_RESULT_INVALID_ARGUMENTS; avail = spa_ringbuffer_get_read_index (trans->input_buffer, &impl->current_index); - if (avail < sizeof (SpaEvent)) + if (avail < sizeof (struct spa_event)) return SPA_RESULT_ENUM_END; spa_ringbuffer_read_data (trans->input_buffer, trans->input_data, impl->current_index & trans->input_buffer->mask, &impl->current, - sizeof (SpaEvent)); + sizeof (struct spa_event)); *event = impl->current; return SPA_RESULT_OK; } -SpaResult +int pw_transport_parse_event (struct pw_transport *trans, void *event) { diff --git a/pipewire/client/transport.h b/pipewire/client/transport.h index ef1d966c1..7c2e24b69 100644 --- a/pipewire/client/transport.h +++ b/pipewire/client/transport.h @@ -55,12 +55,12 @@ struct pw_transport { struct pw_transport *trans)); struct pw_transport_area *area; - SpaPortIO *inputs; - SpaPortIO *outputs; + struct spa_port_io *inputs; + struct spa_port_io *outputs; void *input_data; - SpaRingbuffer *input_buffer; + struct spa_ringbuffer *input_buffer; void *output_data; - SpaRingbuffer *output_buffer; + struct spa_ringbuffer *output_buffer; }; struct pw_transport * pw_transport_new (uint32_t max_inputs, @@ -69,15 +69,15 @@ struct pw_transport * pw_transport_new_from_info (struct pw_transport_info *inf void pw_transport_destroy (struct pw_transport *trans); -SpaResult pw_transport_get_info (struct pw_transport *trans, +int pw_transport_get_info (struct pw_transport *trans, struct pw_transport_info *info); -SpaResult pw_transport_add_event (struct pw_transport *trans, - SpaEvent *event); +int pw_transport_add_event (struct pw_transport *trans, + struct spa_event *event); -SpaResult pw_transport_next_event (struct pw_transport *trans, - SpaEvent *event); -SpaResult pw_transport_parse_event (struct pw_transport *trans, +int pw_transport_next_event (struct pw_transport *trans, + struct spa_event *event); +int pw_transport_parse_event (struct pw_transport *trans, void *event); #define PIPEWIRE_TYPE_EVENT__Transport SPA_TYPE_EVENT_BASE "Transport" @@ -94,7 +94,7 @@ struct pw_type_event_transport { }; static inline void -pw_type_event_transport_map (SpaTypeMap *map, struct pw_type_event_transport *type) +pw_type_event_transport_map (struct spa_type_map *map, struct pw_type_event_transport *type) { if (type->HaveOutput == 0) { type->HaveOutput = spa_type_map_get_id (map, PIPEWIRE_TYPE_EVENT_TRANSPORT__HaveOutput); @@ -104,13 +104,13 @@ pw_type_event_transport_map (SpaTypeMap *map, struct pw_type_event_transport *ty } struct pw_event_transport_reuse_buffer_body { - SpaPODObjectBody body; - SpaPODInt port_id; - SpaPODInt buffer_id; + struct spa_pod_object_body body; + struct spa_pod_int port_id; + struct spa_pod_int buffer_id; }; struct pw_event_transport_reuse_buffer { - SpaPOD pod; + struct spa_pod pod; struct pw_event_transport_reuse_buffer_body body; }; diff --git a/pipewire/client/type.c b/pipewire/client/type.c index 1845f7412..005a8e97b 100644 --- a/pipewire/client/type.c +++ b/pipewire/client/type.c @@ -76,7 +76,7 @@ pw_pod_remap_data (uint32_t type, void * body, uint32_t size, struct pw_map *typ case SPA_POD_TYPE_PROP: { - SpaPODPropBody *b = body; + struct spa_pod_prop_body *b = body; if ((t = pw_map_lookup (types, b->key)) == NULL) return false; @@ -95,8 +95,8 @@ pw_pod_remap_data (uint32_t type, void * body, uint32_t size, struct pw_map *typ } case SPA_POD_TYPE_OBJECT: { - SpaPODObjectBody *b = body; - SpaPOD *p; + struct spa_pod_object_body *b = body; + struct spa_pod *p; if ((t = pw_map_lookup (types, b->type)) == NULL) return false; @@ -109,7 +109,7 @@ pw_pod_remap_data (uint32_t type, void * body, uint32_t size, struct pw_map *typ } case SPA_POD_TYPE_STRUCT: { - SpaPOD *b = body, *p; + struct spa_pod *b = body, *p; SPA_POD_FOREACH (b, size, p) if (!pw_pod_remap_data (p->type, SPA_POD_BODY (p), p->size, types)) diff --git a/pipewire/client/type.h b/pipewire/client/type.h index b0c3805a6..7bc5564be 100644 --- a/pipewire/client/type.h +++ b/pipewire/client/type.h @@ -46,31 +46,31 @@ struct pw_interface { * PipeWire Type support struct. */ struct pw_type { - SpaTypeMap *map; + struct spa_type_map *map; - SpaType core; - SpaType registry; - SpaType node; - SpaType node_factory; - SpaType link; - SpaType client; - SpaType client_node; - SpaType module; + uint32_t core; + uint32_t registry; + uint32_t node; + uint32_t node_factory; + uint32_t link; + uint32_t client; + uint32_t client_node; + uint32_t module; - SpaType spa_node; - SpaType spa_clock; - SpaType spa_monitor; - SpaType spa_format; - SpaType spa_props; + uint32_t spa_node; + uint32_t spa_clock; + uint32_t spa_monitor; + uint32_t spa_format; + uint32_t spa_props; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; - SpaTypeMonitor monitor; - SpaTypeParamAllocBuffers param_alloc_buffers; - SpaTypeParamAllocMetaEnable param_alloc_meta_enable; - SpaTypeParamAllocVideoPadding param_alloc_video_padding; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; + struct spa_type_monitor monitor; + struct spa_type_param_alloc_buffers param_alloc_buffers; + struct spa_type_param_alloc_meta_enable param_alloc_meta_enable; + struct spa_type_param_alloc_video_padding param_alloc_video_padding; struct pw_type_event_transport event_transport; }; @@ -79,7 +79,7 @@ void pw_type_init (struct pw_type *type); bool pw_pod_remap_data (uint32_t type, void *body, uint32_t size, struct pw_map *types); static inline bool -pw_pod_remap (SpaPOD *pod, struct pw_map *types) +pw_pod_remap (struct spa_pod *pod, struct pw_map *types) { return pw_pod_remap_data (pod->type, SPA_POD_BODY (pod), pod->size, types); } diff --git a/pipewire/client/utils.h b/pipewire/client/utils.h index cf6138f50..5da388945 100644 --- a/pipewire/client/utils.h +++ b/pipewire/client/utils.h @@ -40,15 +40,15 @@ void pw_free_strv (char **str); char * pw_strip (char *str, const char *whitespace); -static inline SpaPOD * -pw_spa_pod_copy (const SpaPOD *pod) +static inline struct spa_pod * +pw_spa_pod_copy (const struct spa_pod *pod) { return pod ? memcpy (malloc (SPA_POD_SIZE (pod)), pod, SPA_POD_SIZE (pod)) : NULL; } -#define spa_format_copy(f) ((SpaFormat*)pw_spa_pod_copy(&(f)->pod)) -#define spa_props_copy(p) ((SpaProps*)pw_spa_pod_copy(&(p)->pod)) -#define spa_param_copy(p) ((SpaParam*)pw_spa_pod_copy(&(p)->pod)) +#define spa_format_copy(f) ((struct spa_format*)pw_spa_pod_copy(&(f)->pod)) +#define spa_props_copy(p) ((struct spa_prop*)pw_spa_pod_copy(&(p)->object.pod)) +#define spa_param_copy(p) ((struct spa_param*)pw_spa_pod_copy(&(p)->object.pod)) #ifdef __cplusplus } /* extern "C" */ diff --git a/pipewire/daemon/daemon-config.h b/pipewire/daemon/daemon-config.h index 23921605a..b22a3e5cb 100644 --- a/pipewire/daemon/daemon-config.h +++ b/pipewire/daemon/daemon-config.h @@ -28,7 +28,7 @@ extern "C" { #include struct pw_daemon_config { - SpaList commands; + struct spa_list commands; }; struct pw_daemon_config * pw_daemon_config_new (void); diff --git a/pipewire/daemon/main.c b/pipewire/daemon/main.c index fc4234ca3..25e2c44e6 100644 --- a/pipewire/daemon/main.c +++ b/pipewire/daemon/main.c @@ -44,7 +44,7 @@ main (int argc, char *argv[]) loop = pw_main_loop_new (); #if 1 { - SpaSource *source; + struct spa_source *source; source = pw_loop_add_event (loop->loop, NULL, NULL); pw_log_set_trace_event (source); } diff --git a/pipewire/examples/video-play.c b/pipewire/examples/video-play.c index abb4e2d49..61fa0cf08 100644 --- a/pipewire/examples/video-play.c +++ b/pipewire/examples/video-play.c @@ -32,19 +32,19 @@ #include #include -typedef struct { +struct type { uint32_t format; uint32_t props; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatVideo format_video; - SpaTypeVideoFormat video_format; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_video format_video; + struct spa_type_video_format video_format; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->format = spa_type_map_get_id (map, SPA_TYPE__Format); type->props = spa_type_map_get_id (map, SPA_TYPE__Props); @@ -61,7 +61,7 @@ init_type (Type *type, SpaTypeMap *map) #define BPP 3 struct data { - Type type; + struct type type; const char *path; @@ -71,7 +71,7 @@ struct data { bool running; struct pw_loop *loop; - SpaSource *timer; + struct spa_source *timer; struct pw_context *context; struct pw_listener on_state_changed; @@ -81,7 +81,7 @@ struct data { struct pw_listener on_stream_format_changed; struct pw_listener on_stream_new_buffer; - SpaVideoInfoRaw format; + struct spa_video_info_raw format; int32_t stride; uint8_t params_buffer[1024]; @@ -107,7 +107,7 @@ on_stream_new_buffer (struct pw_listener *listener, uint32_t id) { struct data *data = SPA_CONTAINER_OF (listener, struct data, on_stream_new_buffer); - SpaBuffer *buf; + struct spa_buffer *buf; uint8_t *map; void *sdata, *ddata; int sstride, dstride, ostride; @@ -166,46 +166,46 @@ static struct { Uint32 format; uint32_t id; } video_formats[] = { - { SDL_PIXELFORMAT_UNKNOWN, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_INDEX1LSB, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_UNKNOWN, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_INDEX1LSB, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_INDEX1MSB, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_INDEX4LSB, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_INDEX4MSB, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_INDEX8, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_RGB332, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_RGB444, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_RGB555, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_BGR555, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_ARGB4444, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_RGBA4444, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_ABGR4444, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_BGRA4444, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_ARGB1555, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_RGBA5551, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_ABGR1555, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_BGRA5551, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_RGB565, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_BGR565, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_RGB24, offsetof (SpaTypeVideoFormat, RGB), }, - { SDL_PIXELFORMAT_RGB888, offsetof (SpaTypeVideoFormat, RGB), }, - { SDL_PIXELFORMAT_RGBX8888, offsetof (SpaTypeVideoFormat, RGBx), }, - { SDL_PIXELFORMAT_BGR24, offsetof (SpaTypeVideoFormat, BGR), }, - { SDL_PIXELFORMAT_BGR888, offsetof (SpaTypeVideoFormat, BGR), }, - { SDL_PIXELFORMAT_BGRX8888, offsetof (SpaTypeVideoFormat, BGRx), }, - { SDL_PIXELFORMAT_ARGB2101010, offsetof (SpaTypeVideoFormat, UNKNOWN), }, - { SDL_PIXELFORMAT_RGBA8888, offsetof (SpaTypeVideoFormat, RGBA), }, - { SDL_PIXELFORMAT_ARGB8888, offsetof (SpaTypeVideoFormat, ARGB), }, - { SDL_PIXELFORMAT_BGRA8888, offsetof (SpaTypeVideoFormat, BGRA), }, - { SDL_PIXELFORMAT_ABGR8888, offsetof (SpaTypeVideoFormat, ABGR), }, - { SDL_PIXELFORMAT_YV12, offsetof (SpaTypeVideoFormat, YV12), }, - { SDL_PIXELFORMAT_IYUV, offsetof (SpaTypeVideoFormat, I420), }, - { SDL_PIXELFORMAT_YUY2, offsetof (SpaTypeVideoFormat, YUY2), }, - { SDL_PIXELFORMAT_UYVY, offsetof (SpaTypeVideoFormat, UYVY), }, - { SDL_PIXELFORMAT_YVYU, offsetof (SpaTypeVideoFormat, YVYU), }, - { SDL_PIXELFORMAT_NV12, offsetof (SpaTypeVideoFormat, NV12), }, - { SDL_PIXELFORMAT_NV21, offsetof (SpaTypeVideoFormat, NV21), } + { SDL_PIXELFORMAT_UNKNOWN, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_INDEX1LSB, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_UNKNOWN, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_INDEX1LSB, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_INDEX1MSB, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_INDEX4LSB, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_INDEX4MSB, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_INDEX8, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_RGB332, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_RGB444, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_RGB555, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_BGR555, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_ARGB4444, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_RGBA4444, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_ABGR4444, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_BGRA4444, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_ARGB1555, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_RGBA5551, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_ABGR1555, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_BGRA5551, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_RGB565, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_BGR565, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_RGB24, offsetof (struct spa_type_video_format, RGB), }, + { SDL_PIXELFORMAT_RGB888, offsetof (struct spa_type_video_format, RGB), }, + { SDL_PIXELFORMAT_RGBX8888, offsetof (struct spa_type_video_format, RGBx), }, + { SDL_PIXELFORMAT_BGR24, offsetof (struct spa_type_video_format, BGR), }, + { SDL_PIXELFORMAT_BGR888, offsetof (struct spa_type_video_format, BGR), }, + { SDL_PIXELFORMAT_BGRX8888, offsetof (struct spa_type_video_format, BGRx), }, + { SDL_PIXELFORMAT_ARGB2101010, offsetof (struct spa_type_video_format, UNKNOWN), }, + { SDL_PIXELFORMAT_RGBA8888, offsetof (struct spa_type_video_format, RGBA), }, + { SDL_PIXELFORMAT_ARGB8888, offsetof (struct spa_type_video_format, ARGB), }, + { SDL_PIXELFORMAT_BGRA8888, offsetof (struct spa_type_video_format, BGRA), }, + { SDL_PIXELFORMAT_ABGR8888, offsetof (struct spa_type_video_format, ABGR), }, + { SDL_PIXELFORMAT_YV12, offsetof (struct spa_type_video_format, YV12), }, + { SDL_PIXELFORMAT_IYUV, offsetof (struct spa_type_video_format, I420), }, + { SDL_PIXELFORMAT_YUY2, offsetof (struct spa_type_video_format, YUY2), }, + { SDL_PIXELFORMAT_UYVY, offsetof (struct spa_type_video_format, UYVY), }, + { SDL_PIXELFORMAT_YVYU, offsetof (struct spa_type_video_format, YVYU), }, + { SDL_PIXELFORMAT_NV12, offsetof (struct spa_type_video_format, NV12), }, + { SDL_PIXELFORMAT_NV21, offsetof (struct spa_type_video_format, NV21), } }; static uint32_t @@ -241,13 +241,13 @@ id_to_sdl_format (struct data *data, uint32_t id) static void on_stream_format_changed (struct pw_listener *listener, struct pw_stream *stream, - SpaFormat *format) + struct spa_format *format) { struct data *data = SPA_CONTAINER_OF (listener, struct data, on_stream_format_changed); struct pw_context *ctx = stream->context; - SpaPODBuilder b = { NULL }; - SpaPODFrame f[2]; - SpaParam *params[2]; + struct spa_pod_builder b = { NULL }; + struct spa_pod_frame f[2]; + struct spa_param *params[2]; if (format) { Uint32 sdl_format; @@ -278,12 +278,12 @@ on_stream_format_changed (struct pw_listener *listener, PROP (&f[1], ctx->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, data->stride), PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32), PROP (&f[1], ctx->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16)); - params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], ctx->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header), - PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); - params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); + params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); pw_stream_finish_format (stream, SPA_RESULT_OK, params, 2); } @@ -305,10 +305,10 @@ on_state_changed (struct pw_listener *listener, case PW_CONTEXT_STATE_CONNECTED: { - SpaFormat *formats[1]; + struct spa_format *formats[1]; uint8_t buffer[1024]; - SpaPODBuilder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); - SpaPODFrame f[2]; + struct spa_pod_builder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); + struct spa_pod_frame f[2]; SDL_RendererInfo info; int i, c; @@ -350,7 +350,7 @@ on_state_changed (struct pw_listener *listener, 0); spa_pod_builder_pop (&b, &f[0]); - formats[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + formats[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); printf ("supported formats:\n"); spa_debug_format (formats[0], data->context->type.map); diff --git a/pipewire/examples/video-src.c b/pipewire/examples/video-src.c index fee60eb09..7c0131360 100644 --- a/pipewire/examples/video-src.c +++ b/pipewire/examples/video-src.c @@ -35,16 +35,16 @@ struct type { uint32_t format; uint32_t props; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatVideo format_video; - SpaTypeVideoFormat video_format; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_video format_video; + struct spa_type_video_format video_format; }; static inline void -init_type (struct type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->format = spa_type_map_get_id (map, SPA_TYPE__Format); type->props = spa_type_map_get_id (map, SPA_TYPE__Props); @@ -63,7 +63,7 @@ struct data { bool running; struct pw_loop *loop; - SpaSource *timer; + struct spa_source *timer; struct pw_context *context; struct pw_listener on_state_changed; @@ -72,7 +72,7 @@ struct data { struct pw_listener on_stream_state_changed; struct pw_listener on_stream_format_changed; - SpaVideoInfoRaw format; + struct spa_video_info_raw format; int32_t stride; uint8_t params_buffer[1024]; @@ -81,16 +81,16 @@ struct data { }; static void -on_timeout (SpaLoopUtils *utils, - SpaSource *source, +on_timeout (struct spa_loop_utils *utils, + struct spa_source *source, void *userdata) { struct data *data = userdata; uint32_t id; - SpaBuffer *buf; + struct spa_buffer *buf; int i, j; uint8_t *p, *map; - SpaMetaHeader *h; + struct spa_meta_header *h; id = pw_stream_get_empty_buffer (data->stream); if (id == SPA_ID_INVALID) @@ -183,13 +183,13 @@ on_stream_state_changed (struct pw_listener *listener, static void on_stream_format_changed (struct pw_listener *listener, struct pw_stream *stream, - SpaFormat *format) + struct spa_format *format) { struct data *data = SPA_CONTAINER_OF (listener, struct data, on_stream_format_changed); struct pw_context *ctx = stream->context; - SpaPODBuilder b = { NULL }; - SpaPODFrame f[2]; - SpaParam *params[2]; + struct spa_pod_builder b = { NULL }; + struct spa_pod_frame f[2]; + struct spa_param *params[2]; if (format) { spa_format_video_raw_parse (format, &data->format, &data->type.format_video); @@ -203,12 +203,12 @@ on_stream_format_changed (struct pw_listener *listener, PROP (&f[1], ctx->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, data->stride), PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32), PROP (&f[1], ctx->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16)); - params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], ctx->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header), - PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); - params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); + params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); pw_stream_finish_format (stream, SPA_RESULT_OK, params, 2); } @@ -231,10 +231,10 @@ on_state_changed (struct pw_listener *listener, case PW_CONTEXT_STATE_CONNECTED: { - SpaFormat *formats[1]; + struct spa_format *formats[1]; uint8_t buffer[1024]; - SpaPODBuilder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); - SpaPODFrame f[2]; + struct spa_pod_builder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); + struct spa_pod_frame f[2]; printf ("context state: \"%s\"\n", pw_context_state_as_string (context->state)); @@ -247,7 +247,7 @@ on_state_changed (struct pw_listener *listener, 1, 1, 4096, 4096), PROP (&f[1], data->type.format_video.framerate, SPA_POD_TYPE_FRACTION, 25, 1)); - formats[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + formats[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); pw_signal_add (&data->stream->state_changed, &data->on_stream_state_changed, diff --git a/pipewire/gst/gstburstcache.c b/pipewire/gst/gstburstcache.c deleted file mode 100644 index ac6444a22..000000000 --- a/pipewire/gst/gstburstcache.c +++ /dev/null @@ -1,1428 +0,0 @@ -/* GStreamer - * Copyright (C) <2004> Thomas Vander Stichele - * Copyright (C) <2012> Wim Taymans - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/** - * SECTION:gstburstcache - * @short_description: caches and implements burst-on-connect of buffers - * - * GstBurstCache keeps a cache of buffers up to a configurable limit and replays - * this cache for newly added readers. This can be used to implement - * burst-on-connect for various network scenarios such as TCP or UDP. - * - * A new cache is created with gst_burst_cache_new(), which requires a size of - * the structure to hold the reader information. - * - * New buffers are put in the cache with gst_burst_cache_queue_buffer(). Old - * buffers will be removed from the cache. With gst_burst_cache_set_min_amount() - * one can control the amount of data in time/bytes/buffers to keep in the - * cache. - * - * New readers can be constructed with gst_burst_cache_reader_new(). This will - * allocate a new reader structure with the configured size when the cache was - * constructed. A callback needs to be provided that will be called when new - * data is available for the reader. - * - * The caller can configure the reader with gst_burst_cache_reader_set_burst(). - * The start_method property will define which buffer in the cahced buffers will - * be sent first to the reader. Readers can be sent the most recent buffer - * (which might not be decodable by the reader if it is not a keyframe), the - * next keyframe received in the cache (which can take some time depending on - * the keyframe rate), or the last received keyframe (which will cause a simple - * burst-on-connect). GstBurstCache will always keep at least one keyframe in - * its internal cache. - * - * There are additional values for the start_method to allow finer control over - * burst-on-connect behaviour. By selecting the 'burst' method a minimum burst - * size can be chosen, 'burst-keyframe' additionally requires that the burst - * begin with a keyframe, and 'burst-with-keyframe' attempts to burst beginning - * with a keyframe, but will prefer a minimum burst size even if it requires - * not starting with a keyframe. - * - * When a reader is created and configured, it can be added to the cache with - * gst_burst_cache_add_reader(). This will trigger the callback when new data is - * available for the reader. The reader should call gst_burst_cache_get_buffer() - * to retrieve the available buffer until the function returns - * GST_BURST_CACHE_RESULT_WAIT, in which case it should wait for the callback again. - * This makes it possible to implement a push or pull model for retrieving data - * from the cache. - * - * If the reader does not call gst_burst_cache_get_buffer() fast enough, it will - * start to lag. With gst_burst_cache_set_limits() you can configure how much a - * reader is allowed to lag. You can configure a soft limit and a hard limit in - * and format. - * - * A reader with a lag of at least soft-max enters the recovery procedure which - * is controlled with the recover property. A recover policy of NONE will do - * nothing, RESYNC_LATEST will send the most recently received buffer as the - * next buffer for the reader, RESYNC_SOFT_LIMIT positions the reader to the - * soft limit in the buffer queue and RESYNC_KEYFRAME positions the reader at - * the most recent keyframe in the buffer queue. - * - * When the reader is lagging more that the soft-limit, its recovery - * procedure will be started, which usually will make it drop buffers to catch - * up. When the hard limit is reached, the reader is removed from the cache. - * - * A reader can be removed from the cache with gst_burst_cache_remove_reader(). - * - * When a reader is in error, gst_burst_cache_error_reader() must be called, - * which will cause the reader to be removed from the cache. - * - * When a reader is freed, its GHook destroy function will be called with the - * GHook data. You can install a custom function and data to be notified. - * - * Last reviewed on 2012-11-09 (1.0.3) - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstburstcache.h" - -#define DEFAULT_LIMIT_FORMAT GST_FORMAT_BUFFERS -#define DEFAULT_LIMIT_MAX -1 -#define DEFAULT_LIMIT_SOFT_MAX -1 -#define DEFAULT_TIME_MIN -1 -#define DEFAULT_BYTES_MIN -1 -#define DEFAULT_BUFFERS_MIN -1 -#define DEFAULT_RECOVER GST_BURST_CACHE_RECOVER_NONE - -enum -{ - PROP_0, - PROP_LAST -}; - -GQuark gst_burst_cache_error_quark (void) -{ - static GQuark quark; - if (!quark) - quark = g_quark_from_static_string ("gst-burst-cache-error-quark"); - return quark; -} - -GST_DEBUG_CATEGORY_STATIC (burstcache_debug); -#define GST_CAT_DEFAULT (burstcache_debug) - -#define gst_burst_cache_parent_class parent_class -G_DEFINE_TYPE (GstBurstCache, gst_burst_cache, G_TYPE_OBJECT); - -#define CACHE_LOCK_INIT(cache) (g_rec_mutex_init(&(cache)->lock)) -#define CACHE_LOCK_CLEAR(cache) (g_rec_mutex_clear(&(cache)->lock)) -#define CACHE_LOCK(cache) (g_rec_mutex_lock(&(cache)->lock)) -#define CACHE_UNLOCK(cache) (g_rec_mutex_unlock(&(cache)->lock)) - -#define VALUE_INVALID ((guint64)-1) - -static void gst_burst_cache_finalize (GObject * object); - -G_DEFINE_POINTER_TYPE (GstBurstCacheReader, gst_burst_cache_reader); - -static gint find_keyframe (GstBurstCache * cache, gint idx, gint direction); -#define find_next_keyframe(s,i) find_keyframe(s,i,1) -#define find_prev_keyframe(s,i) find_keyframe(s,i,-1) -static gboolean is_keyframe (GstBurstCache * cache, GstBuffer * buffer); - -static gint get_buffers_max (GstBurstCache * cache, GstFormat format, - gint64 max); -static gint gst_burst_cache_recover_reader (GstBurstCache * cache, - GstBurstCacheReader * reader); -static gboolean find_limits (GstBurstCache * cache, gint * min_idx, - gint bytes_min, gint buffers_min, gint64 time_min, gint * max_idx, - gint bytes_max, gint buffers_max, gint64 time_max); - -static void -gst_burst_cache_class_init (GstBurstCacheClass * klass) -{ - GObjectClass *gobject_class; - - gobject_class = (GObjectClass *) klass; - - gobject_class->finalize = gst_burst_cache_finalize; - - GST_DEBUG_CATEGORY_INIT (burstcache_debug, "burstcache", 0, "GstBurstCache"); -} - -static void -gst_burst_cache_init (GstBurstCache * this) -{ - CACHE_LOCK_INIT (this); - this->bufqueue = g_ptr_array_new (); - this->limit_format = DEFAULT_LIMIT_FORMAT; - this->limit_max = DEFAULT_LIMIT_MAX; - this->limit_soft_max = DEFAULT_LIMIT_SOFT_MAX; - this->time_min = DEFAULT_TIME_MIN; - this->bytes_min = DEFAULT_BYTES_MIN; - this->buffers_min = DEFAULT_BUFFERS_MIN; - this->recover = DEFAULT_RECOVER; -} - - -static void -gst_burst_cache_finalize (GObject * object) -{ - GstBurstCache *this; - - this = GST_BURST_CACHE (object); - - g_hook_list_clear (&this->readers); - - g_ptr_array_foreach (this->bufqueue, (GFunc) gst_buffer_unref, NULL); - g_ptr_array_free (this->bufqueue, TRUE); - CACHE_LOCK_CLEAR (this); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/** - * gst_burst_cache_new: - * @reader_size: the size of the hook - * - * Make a new burst cache. @hook_size specifies the size of the data structure - * that is kep for each client and must be at least - * sizeof(GstBurstCacheReader). - * - * Returns: a new #GstBurstCache - */ -GstBurstCache * -gst_burst_cache_new (guint reader_size) -{ - GstBurstCache *cache; - - g_return_val_if_fail (reader_size >= sizeof (GstBurstCacheReader), NULL); - - cache = g_object_new (GST_TYPE_BURST_CACHE, NULL); - g_hook_list_init (&cache->readers, reader_size); - - return cache; -} - -/** - * gst_burst_cache_set_min_amount: - * @cache: a #GstBurstCache - * @bytes_min: minimum amount to cache in bytes - * @time_min: minimum amount to cache in time - * @buffers_min: minimum amount to cache in buffers - * - * Set the minimum amount of data that @cache should keep around. Values can be - * specified in bytes, time and buffers. A value of -1 sets unlimited caching. - */ -void -gst_burst_cache_set_min_amount (GstBurstCache * cache, gint bytes_min, - gint64 time_min, gint buffers_min) -{ - g_return_if_fail (GST_IS_BURST_CACHE (cache)); - - cache->bytes_min = bytes_min; - cache->time_min = time_min; - cache->buffers_min = buffers_min; -} - -/** - * gst_burst_cache_get_min_amount: - * @cache: a #GstBurstCache - * @bytes_min: (out) (allow-none): result in bytes - * @time_min: (out) (allow-none): result in time - * @buffers_min: (out) (allow-none): result in buffers - * - * Get the minimum amount of data that @cache keeps around. - */ -void -gst_burst_cache_get_min_amount (GstBurstCache * cache, gint * bytes_min, - gint64 * time_min, gint * buffers_min) -{ - g_return_if_fail (GST_IS_BURST_CACHE (cache)); - - if (bytes_min) - *bytes_min = cache->bytes_min; - if (time_min) - *time_min = cache->time_min; - if (buffers_min) - *buffers_min = cache->buffers_min; -} - -/** - * gst_burst_cache_set_limits: - * @cache: a #GstBurstCache - * @format: format of @max and @soft_max - * @max: maximum lag for a reader - * @soft_max: maximum lag for a reader before recovery is performed - * @recover: a #GstBurstCacheRecover - * - * Set the limits for readers. When a reader lags more than @soft_max behind the - * most recent buffer, the receovery procedure @recovery is started for the - * client. If the client lags up to @max, it will be removed from @cache. - */ -void -gst_burst_cache_set_limits (GstBurstCache * cache, GstFormat format, - gint64 max, gint64 soft_max, GstBurstCacheRecover recover) -{ - g_return_if_fail (GST_IS_BURST_CACHE (cache)); - - cache->limit_format = format; - cache->limit_max = max; - cache->limit_soft_max = soft_max; - cache->recover = recover; -} - -/** - * gst_burst_cache_get_limits: - * @cache: a #GstBurstCache - * @format: (out) (allow-none): result format of @max and @soft_max - * @max: (out) (allow-none): result maximum lag for a reader - * @soft_max: (out) (allow-none): result maximum lag for a reader before - * recovery is performed - * @recover: (out) (allow-none): result #GstBurstCacheRecover - * - * Get the reader limits. See gst_burst_cache_set_limits(). - */ -void -gst_burst_cache_get_limits (GstBurstCache * cache, GstFormat * format, - gint64 * max, gint64 * soft_max, GstBurstCacheRecover * recover) -{ - g_return_if_fail (GST_IS_BURST_CACHE (cache)); - - if (format) - *format = cache->limit_format; - if (max) - *max = cache->limit_max; - if (soft_max) - *soft_max = cache->limit_soft_max; - if (recover) - *recover = cache->recover; -} - -/** - * gst_burst_cache_reader_destroy: - * @reader: a #GstBurstCacheReader - * - * Cleanup the memory of @reader. - */ -void -gst_burst_cache_reader_destroy (GstBurstCacheReader * reader) -{ - if (reader->reason) - g_error_free (reader->reason); - if (reader->notify) - reader->notify (reader->user_data); -} - -/** - * gst_burst_cache_reader_new: - * @cache: a #GstBurstCache - * @callback: a #GstBurstCacheReaderCallback - * @user_data: user data - * @notify: a #GDestroyNotify for @user_data - * - * Make a new #GstBurstCacheReader. When data becomes available for the reader, - * @callback will be called with @user_data. - * - * Returns: a new #GstBurstCacheReader. - */ -GstBurstCacheReader * -gst_burst_cache_reader_new (GstBurstCache * cache, - GstBurstCacheReaderCallback callback, gpointer user_data, - GDestroyNotify notify) -{ - GstBurstCacheReader *reader; - - reader = (GstBurstCacheReader *) g_hook_alloc (&cache->readers); - - reader->hook.data = reader; - reader->hook.destroy = (GDestroyNotify) gst_burst_cache_reader_destroy; - - reader->bufpos = -1; - reader->draincount = -1; - reader->new_reader = TRUE; - reader->discont = FALSE; - - reader->callback = callback; - reader->user_data = user_data; - reader->notify = notify; - - reader->reason = NULL; - - reader->start_method = GST_BURST_CACHE_START_LATEST; - - reader->bytes_sent = 0; - reader->dropped_buffers = 0; - reader->avg_queue_size = 0; - reader->first_buffer_ts = GST_CLOCK_TIME_NONE; - reader->last_buffer_ts = GST_CLOCK_TIME_NONE; - - /* update start time */ - reader->add_time = g_get_real_time (); - reader->remove_time = 0; - /* set last activity time to add time */ - reader->last_activity_time = reader->add_time; - - return reader; -} - -/** - * gst_burst_cache_reader_set_burst: - * @reader: a #GstBurstCacheReader - * @start_method: a #GstBurstCacheStart - * @min_format: format of @min_value - * @min_value: minimum burst amount - * @max_format: format of @max_value - * @max_value: maximum burst amount - * - * Set the burst parameters for @reader. @start_method defines where to position - * the reader in the cache. At least @min_value of data and at most @max_value - * of data will be sent to the new client. - * - * Returns: %TRUE on success. - */ -gboolean -gst_burst_cache_reader_set_burst (GstBurstCacheReader * reader, - GstBurstCacheStart start_method, GstFormat min_format, guint64 min_value, - GstFormat max_format, guint64 max_value) -{ - /* do limits check if we can */ - if (min_format == max_format) { - if (max_value != VALUE_INVALID && min_value != VALUE_INVALID && max_value < min_value) - return FALSE; - } - - reader->start_method = start_method; - reader->min_format = min_format; - reader->min_value = min_value; - reader->max_format = max_format; - reader->max_value = max_value; - - return TRUE; -} - -static gboolean -is_keyframe (GstBurstCache * cache, GstBuffer * buffer) -{ - if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT)) { - return FALSE; - } else if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_HEADER)) { - return TRUE; - } - return FALSE; -} - -/* find the keyframe in the list of buffers starting the - * search from @idx. @direction as -1 will search backwards, - * 1 will search forwards. - * Returns: the index or -1 if there is no keyframe after idx. - */ -static gint -find_keyframe (GstBurstCache * cache, gint idx, gint direction) -{ - gint i, len, result; - - /* take length of queued buffers */ - len = cache->bufqueue->len; - - /* assume we don't find a keyframe */ - result = -1; - - /* then loop over all buffers to find the first keyframe */ - for (i = idx; i >= 0 && i < len; i += direction) { - GstBuffer *buf; - - buf = g_ptr_array_index (cache->bufqueue, i); - if (is_keyframe (cache, buf)) { - GST_LOG_OBJECT (cache, "found keyframe at %d from %d, direction %d", - i, idx, direction); - result = i; - break; - } - } - return result; -} - -/* Get the number of buffers from the buffer queue needed to satisfy - * the maximum max in the configured units. - * If units are not BUFFERS, and there are insufficient buffers in the - * queue to satify the limit, return len(queue) + 1 */ -static gint -get_buffers_max (GstBurstCache * cache, GstFormat format, gint64 max) -{ - switch (format) { - case GST_FORMAT_BUFFERS: - return max; - case GST_FORMAT_TIME: - { - GstBuffer *buf; - int i; - int len; - gint64 diff; - GstClockTime first = GST_CLOCK_TIME_NONE; - - len = cache->bufqueue->len; - - for (i = 0; i < len; i++) { - buf = g_ptr_array_index (cache->bufqueue, i); - if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { - if (first == GST_CLOCK_TIME_NONE) - first = GST_BUFFER_TIMESTAMP (buf); - - diff = first - GST_BUFFER_TIMESTAMP (buf); - - if (diff > max) - return i + 1; - } - } - return len + 1; - } - case GST_FORMAT_BYTES: - { - GstBuffer *buf; - int i; - int len; - gint acc = 0; - - len = cache->bufqueue->len; - - for (i = 0; i < len; i++) { - buf = g_ptr_array_index (cache->bufqueue, i); - acc += gst_buffer_get_size (buf); - - if (acc > max) - return i + 1; - } - return len + 1; - } - default: - return max; - } -} - -/* find the positions in the buffer queue where *_min and *_max - * is satisfied - */ -/* count the amount of data in the buffers and return the index - * that satifies the given limits. - * - * Returns: index @idx in the buffer queue so that the given limits are - * satisfied. TRUE if all the limits could be satisfied, FALSE if not - * enough data was in the queue. - * - * FIXME, this code might not work if any of the units is in buffers... - */ -static gboolean -find_limits (GstBurstCache * cache, - gint * min_idx, gint bytes_min, gint buffers_min, gint64 time_min, - gint * max_idx, gint bytes_max, gint buffers_max, gint64 time_max) -{ - GstClockTime first, time; - gint i, len, bytes; - gboolean result, max_hit; - - /* take length of queue */ - len = cache->bufqueue->len; - - /* this must hold */ - g_assert (len > 0); - - GST_LOG_OBJECT (cache, - "bytes_min %d, buffers_min %d, time_min %" GST_TIME_FORMAT - ", bytes_max %d, buffers_max %d, time_max %" GST_TIME_FORMAT, bytes_min, - buffers_min, GST_TIME_ARGS (time_min), bytes_max, buffers_max, - GST_TIME_ARGS (time_max)); - - /* do the trivial buffer limit test */ - if (buffers_min != -1 && len < buffers_min) { - *min_idx = len - 1; - *max_idx = len - 1; - return FALSE; - } - - result = FALSE; - /* else count bytes and time */ - first = -1; - bytes = 0; - /* unset limits */ - *min_idx = -1; - *max_idx = -1; - max_hit = FALSE; - - i = 0; - /* loop through the buffers, when a limit is ok, mark it - * as -1, we have at least one buffer in the queue. */ - do { - GstBuffer *buf; - - /* if we checked all min limits, update result */ - if (bytes_min == -1 && time_min == -1 && *min_idx == -1) { - /* don't go below 0 */ - *min_idx = MAX (i - 1, 0); - } - /* if we reached one max limit break out */ - if (max_hit) { - /* i > 0 when we get here, we subtract one to get the position - * of the previous buffer. */ - *max_idx = i - 1; - /* we have valid complete result if we found a min_idx too */ - result = *min_idx != -1; - break; - } - buf = g_ptr_array_index (cache->bufqueue, i); - - bytes += gst_buffer_get_size (buf); - - /* take timestamp and save for the base first timestamp */ - if ((time = GST_BUFFER_TIMESTAMP (buf)) != GST_CLOCK_TIME_NONE) { - GST_LOG_OBJECT (cache, "Ts %" GST_TIME_FORMAT " on buffer", - GST_TIME_ARGS (time)); - if (first == GST_CLOCK_TIME_NONE) - first = time; - - /* increase max usage if we did not fill enough. Note that - * buffers are sorted from new to old, so the first timestamp is - * bigger than the next one. */ - if (time_min != -1 && first - time >= (guint64) time_min) - time_min = -1; - if (time_max != -1 && first - time >= (guint64) time_max) - max_hit = TRUE; - } else { - GST_LOG_OBJECT (cache, "No timestamp on buffer"); - } - /* time is OK or unknown, check and increase if not enough bytes */ - if (bytes_min != -1) { - if (bytes >= bytes_min) - bytes_min = -1; - } - if (bytes_max != -1) { - if (bytes >= bytes_max) { - max_hit = TRUE; - } - } - i++; - } - while (i < len); - - /* if we did not hit the max or min limit, set to buffer size */ - if (*max_idx == -1) - *max_idx = len - 1; - /* make sure min does not exceed max */ - if (*min_idx == -1) - *min_idx = *max_idx; - - return result; -} - -/* parse the unit/value pair and assign it to the result value of the - * right type, leave the other values untouched - * - * Returns: FALSE if the unit is unknown or undefined. TRUE otherwise. - */ -static gboolean -assign_value (GstFormat format, guint64 value, gint * bytes, gint * buffers, - GstClockTime * time) -{ - gboolean res = TRUE; - - /* set only the limit of the given format to the given value */ - switch (format) { - case GST_FORMAT_BUFFERS: - *buffers = (gint) value; - break; - case GST_FORMAT_TIME: - *time = value; - break; - case GST_FORMAT_BYTES: - *bytes = (gint) value; - break; - case GST_FORMAT_UNDEFINED: - default: - res = FALSE; - break; - } - return res; -} - -/* count the index in the buffer queue to satisfy the given unit - * and value pair starting from buffer at index 0. - * - * Returns: TRUE if there was enough data in the queue to satisfy the - * burst values. @idx contains the index in the buffer that contains enough - * data to satisfy the limits or the last buffer in the queue when the - * function returns FALSE. - */ -static gboolean -count_burst_unit (GstBurstCache * cache, gint * min_idx, - GstFormat min_format, guint64 min_value, gint * max_idx, - GstFormat max_format, guint64 max_value) -{ - gint bytes_min = -1, buffers_min = -1; - gint bytes_max = -1, buffers_max = -1; - GstClockTime time_min = GST_CLOCK_TIME_NONE, time_max = GST_CLOCK_TIME_NONE; - - assign_value (min_format, min_value, &bytes_min, &buffers_min, &time_min); - assign_value (max_format, max_value, &bytes_max, &buffers_max, &time_max); - - return find_limits (cache, min_idx, bytes_min, buffers_min, time_min, - max_idx, bytes_max, buffers_max, time_max); -} - -/* decide where in the current buffer queue this new reader should start - * receiving buffers from. - * This function is called whenever a reader is added and has not yet - * received a buffer. - */ -static void -handle_new_reader (GstBurstCache * cache, GstBurstCacheReader * reader) -{ - gint position; - - GST_DEBUG_OBJECT (cache, - "%s new reader, deciding where to start in queue", reader->debug); - GST_DEBUG_OBJECT (cache, "queue is currently %d buffers long", - cache->bufqueue->len); - - switch (reader->start_method) { - case GST_BURST_CACHE_START_LATEST: - /* no syncing, we are happy with whatever the reader is going to get */ - position = reader->bufpos; - GST_DEBUG_OBJECT (cache, - "%s BURST_CACHE_START_LATEST, position %d", reader->debug, position); - break; - case GST_BURST_CACHE_START_NEXT_KEYFRAME: - { - /* if one of the new buffers (between reader->bufpos and 0) in the queue - * is a key frame, we can proceed, otherwise we need to keep waiting */ - GST_LOG_OBJECT (cache, - "%s new reader, bufpos %d, waiting for keyframe", - reader->debug, reader->bufpos); - - position = find_prev_keyframe (cache, reader->bufpos); - if (position != -1) { - GST_DEBUG_OBJECT (cache, - "%s BURST_CACHE_START_NEXT_KEYFRAME: position %d", reader->debug, - position); - break; - } - - /* reader is not on a keyframe, need to skip these buffers and - * wait some more */ - GST_LOG_OBJECT (cache, - "%s new reader, skipping buffer(s), no keyframe found", - reader->debug); - reader->bufpos = -1; - break; - } - case GST_BURST_CACHE_START_LATEST_KEYFRAME: - { - GST_DEBUG_OBJECT (cache, "%s BURST_CACHE_START_LATEST_KEYFRAME", - reader->debug); - - /* for new readers we initially scan the complete buffer queue for - * a keyframe when a buffer is added. If we don't find a keyframe, - * we need to wait for the next keyframe and so we change the reader's - * start method to GST_BURST_CACHE_START_NEXT_KEYFRAME. - */ - position = find_next_keyframe (cache, 0); - if (position != -1) { - GST_DEBUG_OBJECT (cache, - "%s BURST_CACHE_START_LATEST_KEYFRAME: position %d", reader->debug, - position); - break; - } - - GST_DEBUG_OBJECT (cache, - "%s BURST_CACHE_START_LATEST_KEYFRAME: no keyframe found, " - "switching to BURST_CACHE_START_NEXT_KEYFRAME", reader->debug); - /* throw reader to the waiting state */ - reader->bufpos = -1; - /* and make reader sync to next keyframe */ - reader->start_method = GST_BURST_CACHE_START_NEXT_KEYFRAME; - break; - } - case GST_BURST_CACHE_START_BURST: - { - gboolean ok; - gint max; - - /* move to the position where we satisfy the reader's burst - * parameters. If we could not satisfy the parameters because there - * is not enough data, we just send what we have (which is in position). - * We use the max value to limit the search - */ - ok = count_burst_unit (cache, &position, reader->min_format, - reader->min_value, &max, reader->max_format, reader->max_value); - GST_DEBUG_OBJECT (cache, - "%s BURST_CACHE_START_BURST: burst_unit returned %d, position %d", - reader->debug, ok, position); - - GST_LOG_OBJECT (cache, "min %d, max %d", position, max); - - /* we hit the max and it is below the min, use that then */ - if (max != -1 && max <= position) { - position = MAX (max - 1, 0); - GST_DEBUG_OBJECT (cache, - "%s BURST_CACHE_START_BURST: position above max, taken down to %d", - reader->debug, position); - } - break; - } - case GST_BURST_CACHE_START_BURST_KEYFRAME: - { - gint min_idx, max_idx; - gint next_keyframe, prev_keyframe; - - /* BURST_KEYFRAME: - * - * _always_ start sending a keyframe to the reader. We first search - * a keyframe between min/max limits. If there is none, we send it the - * last keyframe before min. If there is none, the behaviour is like - * NEXT_KEYFRAME. - */ - /* gather burst limits */ - count_burst_unit (cache, &min_idx, reader->min_format, - reader->min_value, &max_idx, reader->max_format, reader->max_value); - - GST_LOG_OBJECT (cache, "min %d, max %d", min_idx, max_idx); - - /* first find a keyframe after min_idx */ - next_keyframe = find_next_keyframe (cache, min_idx); - if (next_keyframe != -1 && next_keyframe < max_idx) { - /* we have a valid keyframe and it's below the max */ - GST_LOG_OBJECT (cache, "found keyframe in min/max limits"); - position = next_keyframe; - break; - } - - /* no valid keyframe, try to find one below min */ - prev_keyframe = find_prev_keyframe (cache, min_idx); - if (prev_keyframe != -1) { - GST_WARNING_OBJECT (cache, - "using keyframe below min in BURST_KEYFRAME start mode"); - position = prev_keyframe; - break; - } - - /* no prev keyframe or not enough data */ - GST_WARNING_OBJECT (cache, - "no prev keyframe found in BURST_KEYFRAME start mode, waiting for next"); - - /* throw reader to the waiting state */ - reader->bufpos = -1; - /* and make reader sync to next keyframe */ - reader->start_method = GST_BURST_CACHE_START_NEXT_KEYFRAME; - position = -1; - break; - } - case GST_BURST_CACHE_START_BURST_WITH_KEYFRAME: - { - gint min_idx, max_idx; - gint next_keyframe; - - /* BURST_WITH_KEYFRAME: - * - * try to start sending a keyframe to the reader. We first search - * a keyframe between min/max limits. If there is none, we send it the - * amount of data up 'till min. - */ - /* gather enough data to burst */ - count_burst_unit (cache, &min_idx, reader->min_format, - reader->min_value, &max_idx, reader->max_format, reader->max_value); - - GST_LOG_OBJECT (cache, "min %d, max %d", min_idx, max_idx); - - /* first find a keyframe after min_idx */ - next_keyframe = find_next_keyframe (cache, min_idx); - if (next_keyframe != -1 && next_keyframe < max_idx) { - /* we have a valid keyframe and it's below the max */ - GST_LOG_OBJECT (cache, "found keyframe in min/max limits"); - position = next_keyframe; - break; - } - - /* no keyframe, send data from min_idx */ - GST_WARNING_OBJECT (cache, "using min in BURST_WITH_KEYFRAME start mode"); - - /* make sure we don't go over the max limit */ - if (max_idx != -1 && max_idx <= min_idx) { - position = MAX (max_idx - 1, 0); - } else { - position = min_idx; - } - - break; - } - default: - g_warning ("unknown start method %d", reader->start_method); - position = reader->bufpos; - break; - } - - if (position >= 0) { - /* we got a valid spot in the queue */ - reader->new_reader = FALSE; - reader->bufpos = position; - /* signal that the reader is ready */ - reader->callback (cache, reader, reader->user_data); - } -} - -/** - * gst_burst_cache_add_reader: - * @cache: a #GstBurstCache - * @reader: a #GstBurstCacheReader - * - * Add @reader to @cache. - * - * Returns: %TRUE when @reader could be added - */ -gboolean -gst_burst_cache_add_reader (GstBurstCache * cache, GstBurstCacheReader * reader) -{ - g_return_val_if_fail (GST_IS_BURST_CACHE (cache), FALSE); - g_return_val_if_fail (reader != NULL, FALSE); - g_return_val_if_fail (reader->new_reader, FALSE); - - /* do limits check if we can */ - if (reader->min_format == reader->max_format) { - if (reader->max_value != VALUE_INVALID && reader->min_value != VALUE_INVALID && - reader->max_value < reader->min_value) - goto wrong_limits; - } - - CACHE_LOCK (cache); - handle_new_reader (cache, reader); - /* we can add the handle now */ - g_hook_prepend (&cache->readers, (GHook *) reader); - cache->readers_cookie++; - CACHE_UNLOCK (cache); - - return TRUE; - - /* errors */ -wrong_limits: - { - GST_WARNING_OBJECT (cache, - "%s wrong values min =%" G_GUINT64_FORMAT ", max=%" - G_GUINT64_FORMAT ", unit %d specified when adding reader", - reader->debug, reader->min_value, reader->max_value, - reader->min_format); - return FALSE; - } -} - -/* should be called with the readerslock held. */ -static void -gst_burst_cache_remove_reader_link (GstBurstCache * cache, - GstBurstCacheReader * reader, gboolean remove, GError * reason) -{ - if (!G_HOOK_IS_VALID (reader)) - goto was_removing; - - GST_DEBUG_OBJECT (cache, "%s removing reader %p: (%s)", - reader->debug, reader, reason ? reason->message : "Unknown reason"); - - /* set reader to invalid position while being removed */ - reader->bufpos = -1; - reader->reason = reason; - reader->remove_time = g_get_real_time (); - - cache->readers_cookie++; - if (remove) - g_hook_destroy_link (&cache->readers, (GHook *) reader); - - return; - - /* ERRORS */ -was_removing: - { - GST_WARNING_OBJECT (cache, "%s reader is already being removed", - reader->debug); - if (reason) - g_error_free (reason); - return; - } -} - -/** - * gst_burst_cache_remove_reader: - * @cache: a #GstBurstCache - * @reader: a #GstBurstCacheReader - * @drain: drain flag - * - * Remove @reader from @cache. When @drain is %TRUE all remaining data - * in the cache will be sent to the reader before it is removed. - * - * Returns: %TRUE on success - */ -gboolean -gst_burst_cache_remove_reader (GstBurstCache * cache, - GstBurstCacheReader * reader, gboolean drain) -{ - g_return_val_if_fail (GST_IS_BURST_CACHE (cache), FALSE); - g_return_val_if_fail (reader != NULL, FALSE); - - GST_DEBUG_OBJECT (cache, "%s removing reader", reader->debug); - - CACHE_LOCK (cache); - if (!G_HOOK_IS_VALID (reader)) - goto not_valid; - - if (drain) { - if (reader->draincount == -1) { - /* take the position of the reader as the number of buffers left to drain. - * If the reader was at position -1, we drain 0 buffers, 0 == drain 1 - * buffer, etc... This will mark reader as draining. We can not remove the - * reader right away because it might have some buffers to drain in its - * queue. */ - reader->draincount = reader->bufpos + 1; - } else { - GST_INFO_OBJECT (cache, "%s Reader already draining", reader->debug); - } - } else { - gst_burst_cache_remove_reader_link (cache, reader, TRUE, - g_error_new (GST_BURST_CACHE_ERROR, GST_BURST_CACHE_ERROR_NONE, "User requested remove")); - } - CACHE_UNLOCK (cache); - - return TRUE; - - /* ERRORS */ -not_valid: - { - GST_WARNING_OBJECT (cache, "reader %s not found!", reader->debug); - CACHE_UNLOCK (cache); - return FALSE; - } -} - -/** - * gst_burst_cache_error_reader: - * @cache: a #GstBurstCache - * @reader: a #GstBurstCacheReader - * @error: (transfer full): a #GError - * - * Remove @reader from @cache and set the reason to @error. Ownership is taken - * of @error. - * - * Returns: %TRUE on success - */ -gboolean -gst_burst_cache_error_reader (GstBurstCache * cache, - GstBurstCacheReader * reader, GError * error) -{ - g_return_val_if_fail (GST_IS_BURST_CACHE (cache), FALSE); - g_return_val_if_fail (reader != NULL, FALSE); - - GST_DEBUG_OBJECT (cache, "%s error reader", reader->debug); - - CACHE_LOCK (cache); - if (!G_HOOK_IS_VALID (reader)) - goto not_valid; - - if (error == NULL) - error = g_error_new (GST_BURST_CACHE_ERROR, GST_BURST_CACHE_ERROR_ERROR, "Unknown error"); - - GST_WARNING_OBJECT (cache, "%s reader %p error, removing: %s", - reader->debug, reader, error->message); - - gst_burst_cache_remove_reader_link (cache, reader, TRUE, error); - CACHE_UNLOCK (cache); - - return TRUE; - - /* ERRORS */ -not_valid: - { - GST_WARNING_OBJECT (cache, "reader %s not found!", reader->debug); - CACHE_UNLOCK (cache); - return FALSE; - } -} - -static gboolean -remove_hook (GstBurstCacheReader * reader, GstBurstCache * cache) -{ - gst_burst_cache_remove_reader_link (cache, reader, FALSE, - g_error_new (GST_BURST_CACHE_ERROR, GST_BURST_CACHE_ERROR_NONE, "User requested clear")); - - /* FALSE to remove */ - return FALSE; -} - -/** - * gst_burst_cache_remove_readers: - * @cache: a #GstBurstCache - * - * Remove all readers from @cache. - */ -void -gst_burst_cache_remove_readers (GstBurstCache * cache) -{ - g_return_if_fail (GST_IS_BURST_CACHE (cache)); - - GST_DEBUG_OBJECT (cache, "removing all readers"); - - CACHE_LOCK (cache); - g_hook_list_marshal_check (&cache->readers, TRUE, (GHookCheckMarshaller) - remove_hook, cache); - CACHE_UNLOCK (cache); -} - -/* calculate the new position for a reader after recovery. This function - * does not update the reader position but merely returns the required - * position. - */ -static gint -gst_burst_cache_recover_reader (GstBurstCache * cache, - GstBurstCacheReader * reader) -{ - gint newbufpos; - - GST_WARNING_OBJECT (cache, - "%s reader %p is lagging at %d, recover using policy %d", - reader->debug, reader, reader->bufpos, cache->recover); - - switch (cache->recover) { - case GST_BURST_CACHE_RECOVER_NONE: - /* do nothing, reader will catch up or get kicked out when it reaches - * the hard max */ - newbufpos = reader->bufpos; - break; - case GST_BURST_CACHE_RECOVER_RESYNC_LATEST: - /* move to beginning of queue */ - newbufpos = -1; - break; - case GST_BURST_CACHE_RECOVER_RESYNC_SOFT_LIMIT: - /* move to beginning of soft max */ - newbufpos = - get_buffers_max (cache, cache->limit_format, cache->limit_soft_max); - break; - case GST_BURST_CACHE_RECOVER_RESYNC_KEYFRAME: - /* find keyframe in buffers, we search backwards to find the - * closest keyframe relative to what this reader already received. */ - newbufpos = MIN ((gint) (cache->bufqueue->len - 1), - get_buffers_max (cache, cache->limit_format, - cache->limit_soft_max) - 1); - - while (newbufpos >= 0) { - GstBuffer *buf; - - buf = g_ptr_array_index (cache->bufqueue, newbufpos); - if (is_keyframe (cache, buf)) { - /* found a buffer that is not a delta unit */ - break; - } - newbufpos--; - } - break; - default: - /* unknown recovery procedure */ - newbufpos = - get_buffers_max (cache, cache->limit_format, cache->limit_soft_max); - break; - } - return newbufpos; -} - -typedef struct -{ - GstBurstCache *cache; - GstBurstCacheClass *klass; - GstClockTime now; - gint max_buffer_usage; - gint max_buffers; - gint soft_max_buffers; -} QueueHookData; - -static gboolean -queue_hook (GstBurstCacheReader * reader, QueueHookData * data) -{ - GstBurstCache *cache = data->cache; - - /* move reader forwards */ - reader->bufpos++; - - GST_LOG_OBJECT (cache, "%s reader %p at position %d", - reader->debug, reader, reader->bufpos); - - /* check soft max if needed, recover reader */ - if (data->soft_max_buffers > 0 && reader->bufpos >= data->soft_max_buffers) { - gint newpos; - - newpos = gst_burst_cache_recover_reader (cache, reader); - if (newpos != reader->bufpos) { - reader->dropped_buffers += reader->bufpos - newpos; - reader->bufpos = newpos; - reader->discont = TRUE; - GST_INFO_OBJECT (cache, "%s reader %p position reset to %d", - reader->debug, reader, reader->bufpos); - } else { - GST_INFO_OBJECT (cache, - "%s reader %p not recovering position", reader->debug, reader); - } - } - - /* check hard max */ - if (data->max_buffers > 0 && reader->bufpos >= data->max_buffers) - goto hit_limit; - - /* check timeout */ - if (reader->timeout > 0 && data->now - reader->last_activity_time > - reader->timeout) - goto timeout; - - if (reader->new_reader) { - handle_new_reader (cache, reader); - } else if (reader->bufpos == 0) { - /* reader changed from -1 to 0, we can send data to this reader now. */ - reader->callback (cache, reader, reader->user_data); - } - - /* keep track of maximum buffer usage */ - if (reader->bufpos > data->max_buffer_usage) { - data->max_buffer_usage = reader->bufpos; - } - - return TRUE; - - /* ERRORS */ -hit_limit: - { - GST_WARNING_OBJECT (cache, "%s reader %p is too slow, removing", - reader->debug, reader); - gst_burst_cache_remove_reader_link (cache, reader, FALSE, - g_error_new (GST_BURST_CACHE_ERROR, GST_BURST_CACHE_ERROR_SLOW, "Reader is too slow")); - /* remove reader */ - return FALSE; - } -timeout: - { - GST_WARNING_OBJECT (cache, "%s reader %p timeout, removing", - reader->debug, reader); - gst_burst_cache_remove_reader_link (cache, reader, FALSE, - g_error_new (GST_BURST_CACHE_ERROR, GST_BURST_CACHE_ERROR_SLOW, "Reader timed out")); - /* remove reader */ - return FALSE; - } -} - -/** - * gst_burst_cache_queue_buffer: - * @cache: a #GstBurstCache - * @buffer: a #GstBuffer - * - * Queue @buffer in @cache. Older and unused buffers will be removed from - * @cache. - */ -void -gst_burst_cache_queue_buffer (GstBurstCache * cache, GstBuffer * buffer) -{ - gint queuelen; - gint i; - QueueHookData data; - - g_return_if_fail (GST_IS_BURST_CACHE (cache)); - g_return_if_fail (buffer != NULL); - - data.now = g_get_real_time (); - - data.klass = GST_BURST_CACHE_GET_CLASS (cache); - - CACHE_LOCK (cache); - /* add buffer to queue */ - g_ptr_array_insert (cache->bufqueue, 0, buffer); - queuelen = cache->bufqueue->len; - - data.cache = cache; - - if (cache->limit_max > 0) - data.max_buffers = - get_buffers_max (cache, cache->limit_format, cache->limit_max); - else - data.max_buffers = -1; - - if (cache->limit_soft_max > 0) - data.soft_max_buffers = - get_buffers_max (cache, cache->limit_format, cache->limit_soft_max); - else - data.soft_max_buffers = -1; - - GST_LOG_OBJECT (cache, "Using max %d, softmax %d", data.max_buffers, - data.soft_max_buffers); - - /* After adding the buffer, we update all reader positions in the queue. If - * a reader moves over the soft max, we start the recovery procedure for this - * slow reader. If it goes over the hard max, it is put into the slow list - * and removed. */ - data.max_buffer_usage = 0; - - g_hook_list_marshal_check (&cache->readers, TRUE, (GHookCheckMarshaller) - queue_hook, &data); - - /* make sure we respect bytes-min, buffers-min and time-min when they are set */ - { - gint usage, max; - - GST_LOG_OBJECT (cache, - "extending queue %d to respect time_min %" GST_TIME_FORMAT - ", bytes_min %d, buffers_min %d", data.max_buffer_usage, - GST_TIME_ARGS (cache->time_min), cache->bytes_min, cache->buffers_min); - - /* get index where the limits are ok, we don't really care if all limits - * are ok, we just queue as much as we need. We also don't compare against - * the max limits. */ - find_limits (cache, &usage, cache->bytes_min, cache->buffers_min, - cache->time_min, &max, -1, -1, -1); - - data.max_buffer_usage = MAX (data.max_buffer_usage, usage + 1); - GST_LOG_OBJECT (cache, "extended queue to %d", data.max_buffer_usage); - } - - /* now look for start points and make sure there is at least one - * keyframe point in the queue. */ - { - /* no point in searching beyond the queue length */ - gint limit = queuelen; - - /* no point in searching beyond the soft-max if any. */ - if (data.soft_max_buffers > 0) { - limit = MIN (limit, data.soft_max_buffers); - } - GST_LOG_OBJECT (cache, - "extending queue to include start point, now at %d, limit is %d", - data.max_buffer_usage, limit); - - for (i = 0; i < limit; i++) { - GstBuffer *buf; - - buf = g_ptr_array_index (cache->bufqueue, i); - if (is_keyframe (cache, buf)) { - /* found a sync frame, now extend the buffer usage to - * include at least this frame. */ - data.max_buffer_usage = MAX (data.max_buffer_usage, i); - break; - } - } - GST_LOG_OBJECT (cache, "max buffer usage is now %d", data.max_buffer_usage); - } - - GST_LOG_OBJECT (cache, "len %d, usage %d", queuelen, data.max_buffer_usage); - - /* nobody is referencing units after max_buffer_usage so we can - * remove them from the queue. We remove them in reverse order as - * this is the most optimal for GArray. */ - for (i = queuelen - 1; i > data.max_buffer_usage; i--) { - GstBuffer *old; - - /* queue exceeded max size */ - queuelen--; - old = g_ptr_array_remove_index (cache->bufqueue, i); - - /* unref tail buffer */ - gst_buffer_unref (old); - } - /* save for stats */ - cache->buffers_queued = data.max_buffer_usage; - CACHE_UNLOCK (cache); -} - -/** - * gst_burst_cache_remove_buffers: - * @cache: a #GstBurstCache - * - * Remove all buffers from @cache. - */ -void -gst_burst_cache_remove_buffers (GstBurstCache * cache) -{ - g_return_if_fail (GST_IS_BURST_CACHE (cache)); - - CACHE_LOCK (cache); - g_ptr_array_foreach (cache->bufqueue, (GFunc) gst_buffer_unref, NULL); - g_ptr_array_set_size (cache->bufqueue, 0); - CACHE_UNLOCK (cache); -} - -/** - * gst_burst_cache_get_buffer: - * @cache: a #GstBurstCache - * @reader: a #GstBurstCacheReader - * @buffer: a #GstBuffer - * - * Get the next buffer for @reader in @cache. - * - * Returns: #GST_BURST_CACHE_RESULT_OK when a buffer is available. - * #GST_BURST_CACHE_RESULT_WAIT is returned when no buffers are available, the - * caller should wait for the callback signal before attempting to get a - * buffer again. #GST_BURST_CACHE_RESULT_EOS is returned when the client has - * received all buffers and is ready to be removed. - */ -GstBurstCacheResult -gst_burst_cache_get_buffer (GstBurstCache * cache, GstBurstCacheReader * reader, - GstBuffer ** buffer) -{ - GstBuffer *buf; - GstClockTime timestamp; - - g_return_val_if_fail (GST_IS_BURST_CACHE (cache), - GST_BURST_CACHE_RESULT_ERROR); - g_return_val_if_fail (reader != NULL, GST_BURST_CACHE_RESULT_ERROR); - g_return_val_if_fail (buffer != NULL, GST_BURST_CACHE_RESULT_ERROR); - - CACHE_LOCK (cache); - if (reader->bufpos == -1) - goto no_data_yet; - - /* we drained all remaining buffers, no need to get a new one */ - if (reader->draincount == 0) - goto drained; - - /* grab buffer */ - buf = g_ptr_array_index (cache->bufqueue, reader->bufpos); - reader->bufpos--; - - /* update stats */ - timestamp = GST_BUFFER_TIMESTAMP (buf); - if (reader->first_buffer_ts == GST_CLOCK_TIME_NONE) - reader->first_buffer_ts = timestamp; - if (timestamp != GST_CLOCK_TIME_NONE) - reader->last_buffer_ts = timestamp; - - /* decrease draincount */ - if (reader->draincount != -1) - reader->draincount--; - - GST_LOG_OBJECT (cache, "%s reader %p at position %d", - reader->debug, reader, reader->bufpos); - - *buffer = gst_buffer_ref (buf); - CACHE_UNLOCK (cache); - - return GST_BURST_CACHE_RESULT_OK; - - /* ERRORS */ -no_data_yet: - { - GST_DEBUG_OBJECT (cache, "%s no data available", reader->debug); - CACHE_UNLOCK (cache); - return GST_BURST_CACHE_RESULT_WAIT; - } -drained: - { - GST_DEBUG_OBJECT (cache, "%s drained", reader->debug); - CACHE_UNLOCK (cache); - return GST_BURST_CACHE_RESULT_EOS; - } -} diff --git a/pipewire/gst/gstburstcache.h b/pipewire/gst/gstburstcache.h deleted file mode 100644 index c03ac11c6..000000000 --- a/pipewire/gst/gstburstcache.h +++ /dev/null @@ -1,305 +0,0 @@ -/* GStreamer - * Copyright (C) <2012> Wim Taymans - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_BURST_CACHE_H__ -#define __GST_BURST_CACHE_H__ - -#include - -G_BEGIN_DECLS - -#define GST_TYPE_BURST_CACHE \ - (gst_burst_cache_get_type()) -#define GST_BURST_CACHE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BURST_CACHE,GstBurstCache)) -#define GST_BURST_CACHE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BURST_CACHE,GstBurstCacheClass)) -#define GST_IS_BURST_CACHE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BURST_CACHE)) -#define GST_IS_BURST_CACHE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BURST_CACHE)) -#define GST_BURST_CACHE_GET_CLASS(klass) \ - (G_TYPE_INSTANCE_GET_CLASS ((klass), GST_TYPE_BURST_CACHE, GstBurstCacheClass)) - -typedef struct _GstBurstCache GstBurstCache; -typedef struct _GstBurstCacheClass GstBurstCacheClass; -typedef struct _GstBurstCacheReader GstBurstCacheReader; - -/** - * GstBurstCacheRecover: - * @GST_BURST_CACHE_RECOVER_NONE : no recovering is done - * @GST_BURST_CACHE_RECOVER_RESYNC_LATEST : reader is moved to last buffer - * @GST_BURST_CACHE_RECOVER_RESYNC_SOFT_LIMIT: reader is moved to the soft limit - * @GST_BURST_CACHE_RECOVER_RESYNC_KEYFRAME : reader is moved to latest keyframe - * - * Possible values for the recovery procedure to use when a reader consumes - * data too slowly and has a backlog of more that soft-limit buffers. - */ -typedef enum -{ - GST_BURST_CACHE_RECOVER_NONE, - GST_BURST_CACHE_RECOVER_RESYNC_LATEST, - GST_BURST_CACHE_RECOVER_RESYNC_SOFT_LIMIT, - GST_BURST_CACHE_RECOVER_RESYNC_KEYFRAME -} GstBurstCacheRecover; - -/** - * GstBurstCacheStart: - * @GST_BURST_CACHE_START_LATEST : reader receives most recent buffer - * @GST_BURST_CACHE_START_NEXT_KEYFRAME : reader receives next keyframe - * @GST_BURST_CACHE_START_LATEST_KEYFRAME : reader receives latest keyframe (burst) - * @GST_BURST_CACHE_START_BURST : reader receives specific amount of data - * @GST_BURST_CACHE_START_BURST_KEYFRAME : reader receives specific amount of data - * starting from latest keyframe - * @GST_BURST_CACHE_START_BURST_WITH_KEYFRAME : reader receives specific amount of data from - * a keyframe, or if there is not enough data after - * the keyframe, starting before the keyframe - * - * This enum defines the selection of the first buffer that is sent - * to a new reader. - */ -typedef enum -{ - GST_BURST_CACHE_START_LATEST, - GST_BURST_CACHE_START_NEXT_KEYFRAME, - GST_BURST_CACHE_START_LATEST_KEYFRAME, - GST_BURST_CACHE_START_BURST, - GST_BURST_CACHE_START_BURST_KEYFRAME, - GST_BURST_CACHE_START_BURST_WITH_KEYFRAME -} GstBurstCacheStart; - -/** - * GstBurstCacheError: - * @GST_BURST_CACHE_ERROR_NONE : No error - * @GST_BURST_CACHE_ERROR_SLOW : reader is too slow - * @GST_BURST_CACHE_ERROR_ERROR : reader is in error - * @GST_BURST_CACHE_ERROR_DUPLICATE: same reader added twice - * - * Error codes used in the reason GError. - */ -typedef enum -{ - GST_BURST_CACHE_ERROR_NONE = 0, - GST_BURST_CACHE_ERROR_SLOW = 1, - GST_BURST_CACHE_ERROR_ERROR = 2, - GST_BURST_CACHE_ERROR_DUPLICATE = 3, -} GstBurstCacheError; - -GQuark gst_burst_cache_error_quark (void); -#define GST_BURST_CACHE_ERROR gst_burst_cache_error_quark() - -/** - * GstBurstCacheResult: - * @GST_BURST_CACHE_RESULT_ERROR : An error occured - * @GST_BURST_CACHE_RESULT_OK : No error - * @GST_BURST_CACHE_RESULT_WAIT : Wait for more buffers - * @GST_BURST_CACHE_RESULT_EOS : No more buffers - * - * Error codes used in the reason GError. - */ -typedef enum -{ - GST_BURST_CACHE_RESULT_ERROR = 0, - GST_BURST_CACHE_RESULT_OK = 1, - GST_BURST_CACHE_RESULT_WAIT = 2, - GST_BURST_CACHE_RESULT_EOS = 3, -} GstBurstCacheResult; - -/** - * GstBurstCacheReaderCallback: - * @cache: a #GstBurstCache - * @reader: a #GstBurstCacheReader - * @user_data: user data given when creating @reader - * - * Called when @reader in @cache has data. You can get the new data with - * gst_burst_cache_get_buffer() from this callback or any other thread. - */ -typedef void (*GstBurstCacheReaderCallback) (GstBurstCache *cache, - GstBurstCacheReader *reader, - gpointer user_data); - -/** - * GstBurstCacheReader: - * @object: parent miniobject - * @bufpos: position of this reader in the global queue - * @draincount: the remaining number of buffers to drain or -1 if the - * reader is not draining. - * @new_reader: this is a new reader - * @discont: is the next buffer was discont - * @reason: the reason why the reader is being removed - * - * structure for a reader - */ -struct _GstBurstCacheReader { - GHook hook; - - gint bufpos; - gint draincount; - - GstBurstCacheReaderCallback callback; - gpointer user_data; - GDestroyNotify notify; - - gboolean new_reader; - gboolean discont; - - GError *reason; - - /* method to sync reader when connecting */ - GstBurstCacheStart start_method; - GstFormat min_format; - guint64 min_value; - GstFormat max_format; - guint64 max_value; - - /* stats */ - guint64 bytes_sent; - guint64 dropped_buffers; - guint64 avg_queue_size; - guint64 first_buffer_ts; - guint64 last_buffer_ts; - - guint64 add_time; - guint64 remove_time; - guint64 last_activity_time; - guint64 timeout; - - gchar debug[30]; /* a debug string used in debug calls to - identify the reader */ -}; - -/** - * GstBurstCache: - * @parent: parent GObject - * @lock: lock to protect @readers - * @bufqueue: global queue of buffers - * @readers: list of readers we are serving - * @readers_cookie: Cookie to detect changes to @readers - * @limit_format: the format of @limit_max and @@limit_soft_max - * @limit_max: max units to queue for a reader - * @limit_soft_max: max units a reader can lag before recovery starts - * @recover: how to recover a lagging reader - * @bytes_min: min number of bytes to queue - * @time_min: min time to queue - * @buffers_min: min number of buffers to queue - * @bytes_to_serve: how much bytes we must serve - * @bytes_served: how much bytes have we served - * @bytes_queued: number of queued bytes - * @time_queued: amount of queued time - * @buffers_queued: number of queued buffers - */ -struct _GstBurstCache { - GObject parent; - - /*< private >*/ - GRecMutex lock; - GPtrArray *bufqueue; - /* the readers */ - GHookList readers; - guint readers_cookie; - - /* these values are used to check if a reader is reading fast - * enough and to control recovery */ - GstFormat limit_format; - gint64 limit_max; - gint64 limit_soft_max; - GstBurstCacheRecover recover; - - /* these values are used to control the amount of data - * kept in the queues. It allows readers to perform a burst - * on connect. */ - gint bytes_min; - gint64 time_min; - gint buffers_min; - - /* stats */ - gint bytes_queued; - gint64 time_queued; - gint buffers_queued; -}; - -/** - * GstBurstCacheClass: - * @parent_class: parent GObjectClass - * @reader_ready: called when a reader has a new buffer available - * - * The GstBurstCache class structure. - */ -struct _GstBurstCacheClass { - GObjectClass parent_class; -}; - -GType gst_burst_cache_get_type (void); -GType gst_burst_cache_reader_get_type (void); - -GstBurstCache * gst_burst_cache_new (guint reader_size); - -void gst_burst_cache_set_min_amount (GstBurstCache *cache, - gint bytes_min, - gint64 time_min, - gint buffers_min); -void gst_burst_cache_get_min_amount (GstBurstCache *cache, - gint *bytes_min, - gint64 *time_min, - gint *buffers_min); - -void gst_burst_cache_set_limits (GstBurstCache *cache, - GstFormat format, - gint64 max, - gint64 soft_max, - GstBurstCacheRecover recover); -void gst_burst_cache_get_limits (GstBurstCache *cache, - GstFormat *format, - gint64 *max, - gint64 *soft_max, - GstBurstCacheRecover *recover); - -void gst_burst_cache_queue_buffer (GstBurstCache *cache, - GstBuffer *buffer); -void gst_burst_cache_remove_buffers (GstBurstCache *cache); - -GstBurstCacheReader * gst_burst_cache_reader_new (GstBurstCache *cache, - GstBurstCacheReaderCallback callback, - gpointer user_data, - GDestroyNotify notify); -gboolean gst_burst_cache_reader_set_burst (GstBurstCacheReader *reader, - GstBurstCacheStart start_method, - GstFormat min_format, guint64 min_value, - GstFormat max_format, guint64 max_value); -void gst_burst_cache_reader_destroy (GstBurstCacheReader *reader); - -gboolean gst_burst_cache_add_reader (GstBurstCache *cache, - GstBurstCacheReader *reader); -gboolean gst_burst_cache_remove_reader (GstBurstCache *cache, - GstBurstCacheReader *reader, - gboolean drain); -gboolean gst_burst_cache_error_reader (GstBurstCache *cache, - GstBurstCacheReader *reader, - GError *error); - -void gst_burst_cache_remove_readers (GstBurstCache * cache); - - -GstBurstCacheResult gst_burst_cache_get_buffer (GstBurstCache *cache, - GstBurstCacheReader *reader, - GstBuffer **buffer); - -G_END_DECLS - -#endif /* __GST_BURST_CACHE_H__ */ diff --git a/pipewire/gst/gstpipewiredeviceprovider.c b/pipewire/gst/gstpipewiredeviceprovider.c index bdcdbdf83..9ca3f97f8 100644 --- a/pipewire/gst/gstpipewiredeviceprovider.c +++ b/pipewire/gst/gstpipewiredeviceprovider.c @@ -198,7 +198,7 @@ new_node (const struct pw_node_info *info) GstCaps *caps = NULL; GstStructure *props; const gchar *klass = NULL; - SpaDictItem *item; + struct spa_dict_item *item; GstPipeWireDeviceType type; int i; @@ -243,7 +243,7 @@ new_node (const struct pw_node_info *info) static void get_node_info_cb (struct pw_context *context, - SpaResult res, + int res, const struct pw_node_info *info, gpointer user_data) { @@ -316,7 +316,7 @@ typedef struct { static void list_node_info_cb (struct pw_context *c, - SpaResult res, + int res, const struct pw_node_info *info, void *user_data) { @@ -330,7 +330,7 @@ list_node_info_cb (struct pw_context *c, static void get_core_info_cb (struct pw_context *c, - SpaResult res, + int res, const struct pw_core_info *info, void *user_data) { diff --git a/pipewire/gst/gstpipewireformat.c b/pipewire/gst/gstpipewireformat.c index f553d1f51..3dc3f5bf0 100644 --- a/pipewire/gst/gstpipewireformat.c +++ b/pipewire/gst/gstpipewireformat.c @@ -31,29 +31,29 @@ #include "gstpipewireformat.h" -typedef struct { +struct media_type { const char *name; uint32_t *media_type; uint32_t *media_subtype; -} MediaType; +}; static struct { - SpaTypeMap *map; + struct spa_type_map *map; uint32_t format; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeMediaSubtypeVideo media_subtype_video; - SpaTypeMediaSubtypeAudio media_subtype_audio; - SpaTypeFormatVideo format_video; - SpaTypeFormatAudio format_audio; - SpaTypeVideoFormat video_format; - SpaTypeAudioFormat audio_format; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_media_subtype_video media_subtype_video; + struct spa_type_media_subtype_audio media_subtype_audio; + struct spa_type_format_video format_video; + struct spa_type_format_audio format_audio; + struct spa_type_video_format video_format; + struct spa_type_audio_format audio_format; } type = { NULL, }; static void ensure_types (void) { - SpaTypeMap *map = type.map = spa_type_map_get_default (); + struct spa_type_map *map = type.map = spa_type_map_get_default (); type.format = spa_type_map_get_id (map, SPA_TYPE__Format); spa_type_media_type_map (map, &type.media_type); @@ -66,7 +66,7 @@ ensure_types (void) spa_type_audio_format_map (map, &type.audio_format); } -static const MediaType media_type_map[] = { +static const struct media_type media_type_map[] = { { "video/x-raw", &type.media_type.video, &type.media_subtype.raw }, { "audio/x-raw", &type.media_type.audio, &type.media_subtype.raw }, { "image/jpeg", &type.media_type.video, &type.media_subtype_video.mjpg }, @@ -199,13 +199,13 @@ static const uint32_t *audio_format_map[] = { }; typedef struct { - SpaPODBuilder b; - const MediaType *type; + struct spa_pod_builder b; + const struct media_type *type; const GstCapsFeatures *cf; const GstStructure *cs; } ConvertData; -static const MediaType * +static const struct media_type * find_media_types (const char *name) { int i; @@ -266,7 +266,7 @@ get_nth_int (const GValue *val, int idx, int *res) } static gboolean -get_nth_fraction (const GValue *val, int idx, SpaFraction *f) +get_nth_fraction (const GValue *val, int idx, struct spa_fraction *f) { const GValue *v = NULL; GType type = G_VALUE_TYPE (val); @@ -294,7 +294,7 @@ get_nth_fraction (const GValue *val, int idx, SpaFraction *f) } static gboolean -get_nth_rectangle (const GValue *width, const GValue *height, int idx, SpaRectangle *r) +get_nth_rectangle (const GValue *width, const GValue *height, int idx, struct spa_rectangle *r) { const GValue *w = NULL, *h = NULL; GType wt = G_VALUE_TYPE (width); @@ -373,7 +373,7 @@ get_range_type2 (const GValue *v1, const GValue *v2) static gboolean handle_video_fields (ConvertData *d) { - SpaPODFrame f; + struct spa_pod_frame f; const GValue *value, *value2; int i; @@ -392,13 +392,13 @@ handle_video_fields (ConvertData *d) spa_pod_builder_id (&d->b, *video_format_map[idx]); } if (i > 1) - SPA_POD_BUILDER_DEREF (&d->b, f.ref, SpaPODProp)->body.flags |= SPA_POD_PROP_FLAG_UNSET; + SPA_POD_BUILDER_DEREF (&d->b, f.ref, struct spa_pod_prop)->body.flags |= SPA_POD_PROP_FLAG_UNSET; spa_pod_builder_pop (&d->b, &f); } value = gst_structure_get_value (d->cs, "width"); value2 = gst_structure_get_value (d->cs, "height"); if (value || value2) { - SpaRectangle v; + struct spa_rectangle v; for (i = 0; get_nth_rectangle (value, value2, i, &v); i++) { if (i == 0) spa_pod_builder_push_prop (&d->b, &f, @@ -408,13 +408,13 @@ handle_video_fields (ConvertData *d) spa_pod_builder_rectangle (&d->b, v.width, v.height); } if (i > 1) - SPA_POD_BUILDER_DEREF (&d->b, f.ref, SpaPODProp)->body.flags |= SPA_POD_PROP_FLAG_UNSET; + SPA_POD_BUILDER_DEREF (&d->b, f.ref, struct spa_pod_prop)->body.flags |= SPA_POD_PROP_FLAG_UNSET; spa_pod_builder_pop (&d->b, &f); } value = gst_structure_get_value (d->cs, "framerate"); if (value) { - SpaFraction v; + struct spa_fraction v; for (i = 0; get_nth_fraction (value, i, &v); i++) { if (i == 0) spa_pod_builder_push_prop (&d->b, &f, @@ -424,13 +424,13 @@ handle_video_fields (ConvertData *d) spa_pod_builder_fraction (&d->b, v.num, v.denom); } if (i > 1) - SPA_POD_BUILDER_DEREF (&d->b, f.ref, SpaPODProp)->body.flags |= SPA_POD_PROP_FLAG_UNSET; + SPA_POD_BUILDER_DEREF (&d->b, f.ref, struct spa_pod_prop)->body.flags |= SPA_POD_PROP_FLAG_UNSET; spa_pod_builder_pop (&d->b, &f); } value = gst_structure_get_value (d->cs, "max-framerate"); if (value) { - SpaFraction v; + struct spa_fraction v; for (i = 0; get_nth_fraction (value, i, &v); i++) { if (i == 0) spa_pod_builder_push_prop (&d->b, &f, @@ -440,7 +440,7 @@ handle_video_fields (ConvertData *d) spa_pod_builder_fraction (&d->b, v.num, v.denom); } if (i > 1) - SPA_POD_BUILDER_DEREF (&d->b, f.ref, SpaPODProp)->body.flags |= SPA_POD_PROP_FLAG_UNSET; + SPA_POD_BUILDER_DEREF (&d->b, f.ref, struct spa_pod_prop)->body.flags |= SPA_POD_PROP_FLAG_UNSET; spa_pod_builder_pop (&d->b, &f); } return TRUE; @@ -449,7 +449,7 @@ handle_video_fields (ConvertData *d) static gboolean handle_audio_fields (ConvertData *d) { - SpaPODFrame f; + struct spa_pod_frame f; const GValue *value; int i = 0; @@ -468,7 +468,7 @@ handle_audio_fields (ConvertData *d) spa_pod_builder_id (&d->b, *audio_format_map[idx]); } if (i > 1) - SPA_POD_BUILDER_DEREF (&d->b, f.ref, SpaPODProp)->body.flags |= SPA_POD_PROP_FLAG_UNSET; + SPA_POD_BUILDER_DEREF (&d->b, f.ref, struct spa_pod_prop)->body.flags |= SPA_POD_PROP_FLAG_UNSET; spa_pod_builder_pop (&d->b, &f); } @@ -476,7 +476,7 @@ handle_audio_fields (ConvertData *d) if (value) { const char *v; for (i = 0; (v = get_nth_string (value, i)); i++) { - SpaAudioLayout layout; + enum spa_audio_layout layout; if (!strcmp (v, "interleaved")) layout = SPA_AUDIO_LAYOUT_INTERLEAVED; @@ -493,7 +493,7 @@ handle_audio_fields (ConvertData *d) spa_pod_builder_int (&d->b, layout); } if (i > 1) - SPA_POD_BUILDER_DEREF (&d->b, f.ref, SpaPODProp)->body.flags |= SPA_POD_PROP_FLAG_UNSET; + SPA_POD_BUILDER_DEREF (&d->b, f.ref, struct spa_pod_prop)->body.flags |= SPA_POD_PROP_FLAG_UNSET; spa_pod_builder_pop (&d->b, &f); } value = gst_structure_get_value (d->cs, "rate"); @@ -508,7 +508,7 @@ handle_audio_fields (ConvertData *d) spa_pod_builder_int (&d->b, v); } if (i > 1) - SPA_POD_BUILDER_DEREF (&d->b, f.ref, SpaPODProp)->body.flags |= SPA_POD_PROP_FLAG_UNSET; + SPA_POD_BUILDER_DEREF (&d->b, f.ref, struct spa_pod_prop)->body.flags |= SPA_POD_PROP_FLAG_UNSET; spa_pod_builder_pop (&d->b, &f); } value = gst_structure_get_value (d->cs, "channels"); @@ -523,14 +523,14 @@ handle_audio_fields (ConvertData *d) spa_pod_builder_int (&d->b, v); } if (i > 1) - SPA_POD_BUILDER_DEREF (&d->b, f.ref, SpaPODProp)->body.flags |= SPA_POD_PROP_FLAG_UNSET; + SPA_POD_BUILDER_DEREF (&d->b, f.ref, struct spa_pod_prop)->body.flags |= SPA_POD_PROP_FLAG_UNSET; spa_pod_builder_pop (&d->b, &f); } return TRUE; } static uint32_t -write_pod (SpaPODBuilder *b, uint32_t ref, const void *data, uint32_t size) +write_pod (struct spa_pod_builder *b, uint32_t ref, const void *data, uint32_t size) { if (ref == -1) ref = b->offset; @@ -543,11 +543,11 @@ write_pod (SpaPODBuilder *b, uint32_t ref, const void *data, uint32_t size) return ref; } -static SpaFormat * +static struct spa_format * convert_1 (GstCapsFeatures *cf, GstStructure *cs) { ConvertData d; - SpaPODFrame f; + struct spa_pod_frame f; spa_zero (d); d.cf = cf; @@ -569,15 +569,15 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs) spa_pod_builder_pop (&d.b, &f); - return SPA_MEMBER (d.b.data, 0, SpaFormat); + return SPA_MEMBER (d.b.data, 0, struct spa_format); } -SpaFormat * +struct spa_format * gst_caps_to_format (GstCaps *caps, guint index) { GstCapsFeatures *f; GstStructure *s; - SpaFormat *res; + struct spa_format *res; g_return_val_if_fail (GST_IS_CAPS (caps), NULL); g_return_val_if_fail (gst_caps_is_fixed (caps), NULL); @@ -597,7 +597,7 @@ foreach_func (GstCapsFeatures *features, GstStructure *structure, GPtrArray *array) { - SpaFormat *fmt; + struct spa_format *fmt; if ((fmt = convert_1 (features, structure))) g_ptr_array_insert (array, -1, fmt); @@ -620,10 +620,10 @@ gst_caps_to_format_all (GstCaps *caps) } static void -handle_id_prop (SpaPODProp *prop, const char *key, GstCaps *res) +handle_id_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res) { const char * str; - uint32_t *id = SPA_POD_CONTENTS (SpaPODProp, prop); + uint32_t *id = SPA_POD_CONTENTS (struct spa_pod_prop, prop); uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop); uint32_t flags; @@ -660,9 +660,9 @@ handle_id_prop (SpaPODProp *prop, const char *key, GstCaps *res) } static void -handle_int_prop (SpaPODProp *prop, const char *key, GstCaps *res) +handle_int_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res) { - uint32_t *val = SPA_POD_CONTENTS (SpaPODProp, prop); + uint32_t *val = SPA_POD_CONTENTS (struct spa_pod_prop, prop); uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop); uint32_t flags; @@ -702,9 +702,9 @@ handle_int_prop (SpaPODProp *prop, const char *key, GstCaps *res) } static void -handle_rect_prop (SpaPODProp *prop, const char *width, const char *height, GstCaps *res) +handle_rect_prop (struct spa_pod_prop *prop, const char *width, const char *height, GstCaps *res) { - SpaRectangle *rect = SPA_POD_CONTENTS (SpaPODProp, prop); + struct spa_rectangle *rect = SPA_POD_CONTENTS (struct spa_pod_prop, prop); uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop); uint32_t flags; @@ -753,9 +753,9 @@ handle_rect_prop (SpaPODProp *prop, const char *width, const char *height, GstCa } static void -handle_fraction_prop (SpaPODProp *prop, const char *key, GstCaps *res) +handle_fraction_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res) { - SpaFraction *fract = SPA_POD_CONTENTS (SpaPODProp, prop); + struct spa_fraction *fract = SPA_POD_CONTENTS (struct spa_pod_prop, prop); uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop); uint32_t flags; @@ -795,11 +795,11 @@ handle_fraction_prop (SpaPODProp *prop, const char *key, GstCaps *res) } } GstCaps * -gst_caps_from_format (const SpaFormat *format) +gst_caps_from_format (const struct spa_format *format) { GstCaps *res = NULL; uint32_t media_type, media_subtype; - SpaPODProp *prop; + struct spa_pod_prop *prop; ensure_types(); diff --git a/pipewire/gst/gstpipewireformat.h b/pipewire/gst/gstpipewireformat.h index 74b4833d2..9d647a138 100644 --- a/pipewire/gst/gstpipewireformat.h +++ b/pipewire/gst/gstpipewireformat.h @@ -26,10 +26,10 @@ G_BEGIN_DECLS -SpaFormat * gst_caps_to_format (GstCaps *caps, guint index); +struct spa_format * gst_caps_to_format (GstCaps *caps, guint index); GPtrArray * gst_caps_to_format_all (GstCaps *caps); -GstCaps * gst_caps_from_format (const SpaFormat *format); +GstCaps * gst_caps_from_format (const struct spa_format *format); G_END_DECLS diff --git a/pipewire/gst/gstpipewiresink.c b/pipewire/gst/gstpipewiresink.c index 8e68fbff8..d7b84f496 100644 --- a/pipewire/gst/gstpipewiresink.c +++ b/pipewire/gst/gstpipewiresink.c @@ -241,10 +241,10 @@ pool_activated (GstPipeWirePool *pool, GstPipeWireSink *sink) guint size; guint min_buffers; guint max_buffers; - SpaParam *port_params[3]; - SpaPODBuilder b = { NULL }; + struct spa_param *port_params[3]; + struct spa_pod_builder b = { NULL }; uint8_t buffer[1024]; - SpaPODFrame f[2]; + struct spa_pod_frame f[2]; config = gst_buffer_pool_get_config (GST_BUFFER_POOL (pool)); gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers, &max_buffers); @@ -264,23 +264,23 @@ pool_activated (GstPipeWirePool *pool, GstPipeWireSink *sink) PROP (&f[1], ctx->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16), 0); spa_pod_builder_pop (&b, &f[0]); - port_params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + port_params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], ctx->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header), - PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); - port_params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); + port_params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], ctx->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Ringbuffer), - PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaRingbuffer)), + PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_ringbuffer)), PROP (&f[1], ctx->type.param_alloc_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, size * SPA_MAX (4, SPA_MAX (min_buffers, max_buffers))), PROP (&f[1], ctx->type.param_alloc_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0), PROP (&f[1], ctx->type.param_alloc_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1), PROP (&f[1], ctx->type.param_alloc_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16)); - port_params[2] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + port_params[2] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); pw_stream_finish_format (sink->stream, SPA_RESULT_OK, port_params, 2); } @@ -414,8 +414,8 @@ gst_pipewire_sink_get_property (GObject * object, guint prop_id, typedef struct { GstPipeWireSink *sink; guint id; - SpaBuffer *buf; - SpaMetaHeader *header; + struct spa_buffer *buf; + struct spa_meta_header *header; guint flags; goffset offset; } ProcessMemData; @@ -435,7 +435,7 @@ on_add_buffer (struct pw_listener *listener, uint32_t id) { GstPipeWireSink *pwsink = SPA_CONTAINER_OF (listener, GstPipeWireSink, stream_add_buffer); - SpaBuffer *b; + struct spa_buffer *b; GstBuffer *buf; uint32_t i; ProcessMemData data; @@ -455,7 +455,7 @@ on_add_buffer (struct pw_listener *listener, data.header = spa_buffer_find_meta (b, stream->context->type.meta.Header); for (i = 0; i < b->n_datas; i++) { - SpaData *d = &b->datas[i]; + struct spa_data *d = &b->datas[i]; GstMemory *gmem = NULL; if (d->type == stream->context->type.data.MemFd || @@ -548,7 +548,7 @@ do_send_buffer (GstPipeWireSink *pwsink) data->header->dts_offset = GST_BUFFER_DTS (buffer); } for (i = 0; i < data->buf->n_datas; i++) { - SpaData *d = &data->buf->datas[i]; + struct spa_data *d = &data->buf->datas[i]; GstMemory *mem = gst_buffer_peek_memory (buffer, i); d->chunk->offset = mem->offset - data->offset; d->chunk->size = mem->size; @@ -604,7 +604,7 @@ on_state_changed (struct pw_listener *listener, static void on_format_changed (struct pw_listener *listener, struct pw_stream *stream, - SpaFormat *format) + struct spa_format *format) { GstPipeWireSink *pwsink = SPA_CONTAINER_OF (listener, GstPipeWireSink, stream_format_changed); @@ -642,7 +642,7 @@ gst_pipewire_sink_setcaps (GstBaseSink * bsink, GstCaps * caps) pwsink->path, flags, possible->len, - (SpaFormat **) possible->pdata); + (struct spa_format **) possible->pdata); while (TRUE) { state = pwsink->stream->state; diff --git a/pipewire/gst/gstpipewiresrc.c b/pipewire/gst/gstpipewiresrc.c index 2883a4ca2..57910d050 100644 --- a/pipewire/gst/gstpipewiresrc.c +++ b/pipewire/gst/gstpipewiresrc.c @@ -364,8 +364,8 @@ gst_pipewire_src_src_fixate (GstBaseSrc * bsrc, GstCaps * caps) typedef struct { GstPipeWireSrc *src; guint id; - SpaBuffer *buf; - SpaMetaHeader *header; + struct spa_buffer *buf; + struct spa_meta_header *header; guint flags; goffset offset; } ProcessMemData; @@ -405,7 +405,7 @@ on_add_buffer (struct pw_listener *listener, guint id) { GstPipeWireSrc *pwsrc = SPA_CONTAINER_OF (listener, GstPipeWireSrc, stream_add_buffer); - SpaBuffer *b; + struct spa_buffer *b; GstBuffer *buf; uint32_t i; ProcessMemData data; @@ -427,7 +427,7 @@ on_add_buffer (struct pw_listener *listener, data.header = spa_buffer_find_meta (b, ctx->type.meta.Header); for (i = 0; i < b->n_datas; i++) { - SpaData *d = &b->datas[i]; + struct spa_data *d = &b->datas[i]; GstMemory *gmem = NULL; if (d->type == ctx->type.data.MemFd || d->type == ctx->type.data.DmaBuf) { @@ -490,7 +490,7 @@ on_new_buffer (struct pw_listener *listener, GstPipeWireSrc *pwsrc = SPA_CONTAINER_OF (listener, GstPipeWireSrc, stream_new_buffer); GstBuffer *buf; ProcessMemData *data; - SpaMetaHeader *h; + struct spa_meta_header *h; guint i; buf = g_hash_table_lookup (pwsrc->buf_ids, GINT_TO_POINTER (id)); @@ -514,7 +514,7 @@ on_new_buffer (struct pw_listener *listener, GST_BUFFER_OFFSET (buf) = h->seq; } for (i = 0; i < data->buf->n_datas; i++) { - SpaData *d = &data->buf->datas[i]; + struct spa_data *d = &data->buf->datas[i]; GstMemory *mem = gst_buffer_peek_memory (buf, i); mem->offset = d->chunk->offset + data->offset; mem->size = d->chunk->size; @@ -714,7 +714,7 @@ gst_pipewire_src_negotiate (GstBaseSrc * basesrc) pwsrc->path, PW_STREAM_FLAG_AUTOCONNECT, possible->len, - (SpaFormat **)possible->pdata); + (struct spa_format **)possible->pdata); while (TRUE) { enum pw_stream_state state = pwsrc->stream->state; @@ -781,7 +781,7 @@ connect_error: static void on_format_changed (struct pw_listener *listener, struct pw_stream *stream, - SpaFormat *format) + struct spa_format *format) { GstPipeWireSrc *pwsrc = SPA_CONTAINER_OF (listener, GstPipeWireSrc, stream_format_changed); GstCaps *caps; @@ -800,10 +800,10 @@ on_format_changed (struct pw_listener *listener, gst_caps_unref (caps); if (res) { - SpaParam *params[2]; - SpaPODBuilder b = { NULL }; + struct spa_param *params[2]; + struct spa_pod_builder b = { NULL }; uint8_t buffer[512]; - SpaPODFrame f[2]; + struct spa_pod_frame f[2]; spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_buffers.Buffers, @@ -811,12 +811,12 @@ on_format_changed (struct pw_listener *listener, PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 0, 0, INT32_MAX), PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 16, 0, INT32_MAX), PROP (&f[1], ctx->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16)); - params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], ctx->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header), - PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); - params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); + params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); GST_DEBUG_OBJECT (pwsrc, "doing finish format"); pw_stream_finish_format (pwsrc->stream, SPA_RESULT_OK, params, 2); diff --git a/pipewire/modules/module-autolink.c b/pipewire/modules/module-autolink.c index 2a28abfaf..50d3183b3 100644 --- a/pipewire/modules/module-autolink.c +++ b/pipewire/modules/module-autolink.c @@ -35,16 +35,16 @@ struct impl { struct pw_listener global_added; struct pw_listener global_removed; - SpaList client_list; + struct spa_list client_list; }; struct client_info { struct impl *impl; struct pw_client *client; - SpaList link; + struct spa_list link; struct pw_listener resource_added; struct pw_listener resource_removed; - SpaList node_list; + struct spa_list node_list; }; struct node_info { @@ -52,7 +52,7 @@ struct node_info { struct client_info *info; struct pw_node *node; struct pw_resource *resource; - SpaList link; + struct spa_list link; struct pw_listener state_changed; struct pw_listener port_added; struct pw_listener port_removed; diff --git a/pipewire/modules/module-flatpak.c b/pipewire/modules/module-flatpak.c index a605356e9..8305b47c6 100644 --- a/pipewire/modules/module-flatpak.c +++ b/pipewire/modules/module-flatpak.c @@ -42,25 +42,25 @@ struct impl { struct pw_listener global_added; struct pw_listener global_removed; - SpaList client_list; + struct spa_list client_list; struct pw_access access; - SpaSource *dispatch_event; + struct spa_source *dispatch_event; }; struct client_info { - struct impl *impl; - SpaList link; + struct impl *impl; + struct spa_list link; struct pw_client *client; - bool is_sandboxed; - SpaList async_pending; + bool is_sandboxed; + struct spa_list async_pending; }; struct async_pending { - SpaList link; - bool handled; - struct client_info *info; - char *handle; + struct spa_list link; + bool handled; + struct client_info *info; + char *handle; struct pw_access_data *access_data; }; @@ -232,7 +232,7 @@ check_global_owner (struct pw_core *core, return false; } -static SpaResult +static int do_view_global (struct pw_access *access, struct pw_client *client, struct pw_global *global) @@ -253,7 +253,7 @@ do_view_global (struct pw_access *access, return SPA_RESULT_OK; } -static SpaResult +static int do_create_node (struct pw_access *access, struct pw_access_data *data, const char *factory_name, @@ -310,7 +310,7 @@ portal_response (DBusConnection *connection, DBusMessage *msg, void *user_data) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static SpaResult +static int do_create_client_node (struct pw_access *access, struct pw_access_data *data, const char *name, @@ -453,7 +453,7 @@ on_global_removed (struct pw_listener *listener, } static void -dispatch_cb (SpaLoopUtils *utils, SpaSource *source, void *userdata) +dispatch_cb (struct spa_loop_utils *utils, struct spa_source *source, void *userdata) { struct impl *impl = userdata; @@ -471,10 +471,10 @@ dispatch_status (DBusConnection *conn, DBusDispatchStatus status, void *userdata status == DBUS_DISPATCH_COMPLETE ? false : true); } -static inline SpaIO +static inline enum spa_io dbus_to_io (DBusWatch *watch) { - SpaIO mask; + enum spa_io mask; unsigned int flags; /* no watch flags for disabled watches */ @@ -493,7 +493,7 @@ dbus_to_io (DBusWatch *watch) } static inline unsigned int -io_to_dbus (SpaIO mask) +io_to_dbus (enum spa_io mask) { unsigned int flags = 0; @@ -509,10 +509,10 @@ io_to_dbus (SpaIO mask) } static void -handle_io_event (SpaLoopUtils *utils, - SpaSource *source, +handle_io_event (struct spa_loop_utils *utils, + struct spa_source *source, int fd, - SpaIO mask, + enum spa_io mask, void *userdata) { DBusWatch *watch = userdata; @@ -528,7 +528,7 @@ static dbus_bool_t add_watch (DBusWatch *watch, void *userdata) { struct impl *impl = userdata; - SpaSource *source; + struct spa_source *source; pw_log_debug ("add watch %p %d", watch, dbus_watch_get_unix_fd (watch)); @@ -549,7 +549,7 @@ static void remove_watch (DBusWatch *watch, void *userdata) { struct impl *impl = userdata; - SpaSource *source; + struct spa_source *source; if ((source = dbus_watch_get_data (watch))) pw_loop_destroy_source (impl->core->main_loop->loop, source); @@ -559,7 +559,7 @@ static void toggle_watch (DBusWatch *watch, void *userdata) { struct impl *impl = userdata; - SpaSource *source; + struct spa_source *source; source = dbus_watch_get_data (watch); @@ -569,7 +569,7 @@ toggle_watch (DBusWatch *watch, void *userdata) } static void -handle_timer_event (SpaLoopUtils *utils, SpaSource *source, void *userdata) +handle_timer_event (struct spa_loop_utils *utils, struct spa_source *source, void *userdata) { DBusTimeout *timeout = userdata; uint64_t t; @@ -589,7 +589,7 @@ static dbus_bool_t add_timeout (DBusTimeout *timeout, void *userdata) { struct impl *impl = userdata; - SpaSource *source; + struct spa_source *source; struct timespec ts; uint64_t t; @@ -617,7 +617,7 @@ static void remove_timeout (DBusTimeout *timeout, void *userdata) { struct impl *impl = userdata; - SpaSource *source; + struct spa_source *source; if ((source = dbus_timeout_get_data (timeout))) pw_loop_destroy_source (impl->core->main_loop->loop, source); @@ -627,7 +627,7 @@ static void toggle_timeout (DBusTimeout *timeout, void *userdata) { struct impl *impl = userdata; - SpaSource *source; + struct spa_source *source; struct timespec ts, *tsp; source = dbus_timeout_get_data (timeout); diff --git a/pipewire/modules/module-mixer.c b/pipewire/modules/module-mixer.c index 4920ddd42..aaf876274 100644 --- a/pipewire/modules/module-mixer.c +++ b/pipewire/modules/module-mixer.c @@ -34,22 +34,22 @@ struct impl { struct pw_properties *properties; void *hnd; - const SpaHandleFactory *factory; + const struct spa_handle_factory *factory; }; -static const SpaHandleFactory * +static const struct spa_handle_factory * find_factory (struct impl *impl) { - SpaEnumHandleFactoryFunc enum_func; + spa_handle_factory_enum_func_t enum_func; uint32_t index; - const SpaHandleFactory *factory = NULL; - SpaResult res; + const struct spa_handle_factory *factory = NULL; + int res; if ((impl->hnd = dlopen (AUDIOMIXER_LIB, RTLD_NOW)) == NULL) { pw_log_error ("can't load %s: %s", AUDIOMIXER_LIB, dlerror()); return NULL; } - if ((enum_func = dlsym (impl->hnd, "spa_enum_handle_factory")) == NULL) { + if ((enum_func = dlsym (impl->hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { pw_log_error ("can't find enum function"); goto no_symbol; } @@ -75,11 +75,11 @@ no_symbol: static struct pw_node * make_node (struct impl *impl) { - SpaHandle *handle; - SpaResult res; + struct spa_handle *handle; + int res; void *iface; - SpaNode *spa_node; - SpaClock *spa_clock; + struct spa_node *spa_node; + struct spa_clock *spa_clock; struct pw_node *node; handle = calloc (1, impl->factory->size); diff --git a/pipewire/modules/module-protocol-dbus.c b/pipewire/modules/module-protocol-dbus.c index ae0cdde8a..648dad9f9 100644 --- a/pipewire/modules/module-protocol-dbus.c +++ b/pipewire/modules/module-protocol-dbus.c @@ -52,15 +52,15 @@ struct impl { struct pw_core *core; - SpaList link; + struct spa_list link; struct pw_properties *properties; GDBusConnection *connection; GDBusObjectManagerServer *server_manager; - SpaList client_list; - SpaList object_list; + struct spa_list client_list; + struct spa_list object_list; struct pw_listener global_added; struct pw_listener global_removed; @@ -68,7 +68,7 @@ struct impl { struct object { struct impl *impl; - SpaList link; + struct spa_list link; struct pw_global *global; void *iface; PipeWireObjectSkeleton *skel; @@ -78,15 +78,15 @@ struct object { struct server { struct object parent; - SpaList link; + struct spa_list link; guint id; }; struct client { - struct object parent; - SpaList link; - gchar *sender; - guint id; + struct object parent; + struct spa_list link; + gchar *sender; + guint id; }; struct node { @@ -389,7 +389,7 @@ handle_create_client_node (PipeWireDaemon1 *interface, struct impl *impl = user_data; struct pw_client_node *node; struct pw_client *client; - SpaResult res; + int res; const char *sender, *object_path, *target_node; struct pw_properties *props; GError *error = NULL; diff --git a/pipewire/modules/module-protocol-native.c b/pipewire/modules/module-protocol-native.c index 947ffc30a..9dadbfebc 100644 --- a/pipewire/modules/module-protocol-native.c +++ b/pipewire/modules/module-protocol-native.c @@ -59,30 +59,31 @@ struct socket { int fd_lock; struct sockaddr_un addr; char lock_addr[UNIX_PATH_MAX + LOCK_SUFFIXLEN]; - struct pw_loop *loop; - SpaSource *source; - char *core_name; - SpaList link; + + struct pw_loop *loop; + struct spa_source *source; + char *core_name; + struct spa_list link; }; struct impl { struct pw_core *core; - SpaList link; + struct spa_list link; struct pw_properties *properties; - SpaList socket_list; - SpaList client_list; + struct spa_list socket_list; + struct spa_list client_list; struct pw_listener before_iterate; }; struct native_client { - struct impl *impl; - SpaList link; + struct impl *impl; + struct spa_list link; struct pw_client *client; int fd; - SpaSource *source; + struct spa_source *source; struct pw_connection *connection; struct pw_listener resource_added; }; @@ -120,11 +121,11 @@ on_before_iterate (struct pw_listener *listener, } static void -connection_data (SpaLoopUtils *utils, - SpaSource *source, - int fd, - SpaIO mask, - void *data) +connection_data (struct spa_loop_utils *utils, + struct spa_source *source, + int fd, + enum spa_io mask, + void *data) { struct native_client *client = data; struct pw_connection *conn = client->connection; @@ -331,10 +332,10 @@ err: } static void -socket_data (SpaLoopUtils *utils, - SpaSource *source, +socket_data (struct spa_loop_utils *utils, + struct spa_source *source, int fd, - SpaIO mask, + enum spa_io mask, void *data) { struct impl *impl = data; diff --git a/pipewire/modules/module-suspend-on-idle.c b/pipewire/modules/module-suspend-on-idle.c index 28182e70e..b6fc59093 100644 --- a/pipewire/modules/module-suspend-on-idle.c +++ b/pipewire/modules/module-suspend-on-idle.c @@ -33,22 +33,22 @@ struct impl { struct pw_listener global_added; struct pw_listener global_removed; - SpaList node_list; + struct spa_list node_list; }; -typedef struct { +struct node_info { struct impl *impl; struct pw_node *node; - SpaList link; + struct spa_list link; struct pw_listener node_state_request; struct pw_listener node_state_changed; - SpaSource *idle_timeout; -} NodeInfo; + struct spa_source *idle_timeout; +}; -static NodeInfo * +static struct node_info * find_node_info (struct impl *impl, struct pw_node *node) { - NodeInfo *info; + struct node_info *info; spa_list_for_each (info, &impl->node_list, link) { if (info->node == node) @@ -58,7 +58,7 @@ find_node_info (struct impl *impl, struct pw_node *node) } static void -remove_idle_timeout (NodeInfo *info) +remove_idle_timeout (struct node_info *info) { if (info->idle_timeout) { pw_loop_destroy_source (info->impl->core->main_loop->loop, info->idle_timeout); @@ -67,7 +67,7 @@ remove_idle_timeout (NodeInfo *info) } static void -node_info_free (NodeInfo *info) +node_info_free (struct node_info *info) { spa_list_remove (&info->link); remove_idle_timeout (info); @@ -77,11 +77,11 @@ node_info_free (NodeInfo *info) } static void -idle_timeout (SpaLoopUtils *utils, - SpaSource *source, +idle_timeout (struct spa_loop_utils *utils, + struct spa_source *source, void *data) { - NodeInfo *info = data; + struct node_info *info = data; pw_log_debug ("module %p: node %p idle timeout", info->impl, info->node); remove_idle_timeout (info); @@ -93,7 +93,7 @@ on_node_state_request (struct pw_listener *listener, struct pw_node *node, enum pw_node_state state) { - NodeInfo *info = SPA_CONTAINER_OF (listener, NodeInfo, node_state_request); + struct node_info *info = SPA_CONTAINER_OF (listener, struct node_info, node_state_request); remove_idle_timeout (info); } @@ -103,7 +103,7 @@ on_node_state_changed (struct pw_listener *listener, enum pw_node_state old, enum pw_node_state state) { - NodeInfo *info = SPA_CONTAINER_OF (listener, NodeInfo, node_state_changed); + struct node_info *info = SPA_CONTAINER_OF (listener, struct node_info, node_state_changed); struct impl *impl = info->impl; if (state != PW_NODE_STATE_IDLE) { @@ -134,9 +134,9 @@ on_global_added (struct pw_listener *listener, if (global->type == impl->core->type.node) { struct pw_node *node = global->object; - NodeInfo *info; + struct node_info *info; - info = calloc (1, sizeof (NodeInfo)); + info = calloc (1, sizeof (struct node_info)); info->impl = impl; info->node = node; spa_list_insert (impl->node_list.prev, &info->link); @@ -156,7 +156,7 @@ on_global_removed (struct pw_listener *listener, if (global->type == impl->core->type.node) { struct pw_node *node = global->object; - NodeInfo *info; + struct node_info *info; if ((info = find_node_info (impl, node))) node_info_free (info); diff --git a/pipewire/modules/spa/module.c b/pipewire/modules/spa/module.c index d4558b2ab..7e608b2b9 100644 --- a/pipewire/modules/spa/module.c +++ b/pipewire/modules/spa/module.c @@ -30,11 +30,11 @@ #include "spa-monitor.h" #include "spa-node.h" -static SpaResult -setup_video_node (struct pw_core *core, SpaNode *spa_node, struct pw_properties *pw_props) { - SpaResult res; - SpaProps *props; - SpaPODProp *prop; +static int +setup_video_node (struct pw_core *core, struct spa_node *spa_node, struct pw_properties *pw_props) { + int res; + struct spa_props *props; + struct spa_pod_prop *prop; const char *pattern, *pattern_type; /* Retrieve pattern property */ @@ -53,9 +53,9 @@ setup_video_node (struct pw_core *core, SpaNode *spa_node, struct pw_properties return SPA_RESULT_ERROR; } - if ((prop = spa_pod_object_find_prop (props, spa_type_map_get_id (core->type.map, SPA_TYPE_PROPS__patternType)))) { + if ((prop = spa_pod_object_find_prop (&props->object, spa_type_map_get_id (core->type.map, SPA_TYPE_PROPS__patternType)))) { if (prop->body.value.type == SPA_POD_TYPE_ID) - SPA_POD_VALUE (SpaPODId, &prop->body.value) = spa_type_map_get_id (core->type.map, pattern_type); + SPA_POD_VALUE (struct spa_pod_id, &prop->body.value) = spa_type_map_get_id (core->type.map, pattern_type); } if ((res = spa_node_set_props (spa_node, props)) != SPA_RESULT_OK) { diff --git a/pipewire/modules/spa/spa-monitor.c b/pipewire/modules/spa/spa-monitor.c index 66a458710..2c1b828fa 100644 --- a/pipewire/modules/spa/spa-monitor.c +++ b/pipewire/modules/spa/spa-monitor.c @@ -36,9 +36,9 @@ struct monitor_item { - char *id; - SpaList link; - struct pw_node *node; + char *id; + struct spa_list link; + struct pw_node *node; }; struct impl { @@ -48,24 +48,24 @@ struct impl { void *hnd; - SpaList item_list; + struct spa_list item_list; }; static void -add_item (struct pw_spa_monitor *this, SpaMonitorItem *item) +add_item (struct pw_spa_monitor *this, struct spa_monitor_item *item) { struct impl *impl = SPA_CONTAINER_OF (this, struct impl, this); - SpaResult res; - SpaHandle *handle; + int res; + struct spa_handle *handle; struct monitor_item *mitem; void *node_iface; void *clock_iface; struct pw_properties *props = NULL; const char *name, *id, *klass; - SpaHandleFactory *factory; - SpaPOD *info = NULL; + struct spa_handle_factory *factory; + struct spa_pod *info = NULL; - spa_pod_object_query (item, + spa_pod_object_query (&item->object, impl->core->type.monitor.name, SPA_POD_TYPE_STRING, &name, impl->core->type.monitor.id, SPA_POD_TYPE_STRING, &id, impl->core->type.monitor.klass, SPA_POD_TYPE_STRING, &klass, @@ -78,7 +78,7 @@ add_item (struct pw_spa_monitor *this, SpaMonitorItem *item) props = pw_properties_new (NULL, NULL); if (info) { - SpaPODIter it; + struct spa_pod_iter it; spa_pod_iter_pod (&it, info); while (true) { @@ -146,13 +146,13 @@ destroy_item (struct monitor_item *mitem) } static void -remove_item (struct pw_spa_monitor *this, SpaMonitorItem *item) +remove_item (struct pw_spa_monitor *this, struct spa_monitor_item *item) { struct impl *impl = SPA_CONTAINER_OF (this, struct impl, this); struct monitor_item *mitem; const char *name, *id; - spa_pod_object_query (item, + spa_pod_object_query (&item->object, impl->core->type.monitor.name, SPA_POD_TYPE_STRING, &name, impl->core->type.monitor.id, SPA_POD_TYPE_STRING, &id, 0); @@ -164,26 +164,26 @@ remove_item (struct pw_spa_monitor *this, SpaMonitorItem *item) } static void -on_monitor_event (SpaMonitor *monitor, - SpaEventMonitor *event, - void *user_data) +on_monitor_event (struct spa_monitor *monitor, + struct spa_event *event, + void *user_data) { struct pw_spa_monitor *this = user_data; struct impl *impl = SPA_CONTAINER_OF (this, struct impl, this); if (SPA_EVENT_TYPE (event) == impl->core->type.monitor.Added) { - SpaMonitorItem *item = SPA_POD_CONTENTS (SpaEvent, event); + struct spa_monitor_item *item = SPA_POD_CONTENTS (struct spa_event, event); add_item (this, item); } else if (SPA_EVENT_TYPE (event) == impl->core->type.monitor.Removed) { - SpaMonitorItem *item = SPA_POD_CONTENTS (SpaEvent, event); + struct spa_monitor_item *item = SPA_POD_CONTENTS (struct spa_event, event); remove_item (this, item); } else if (SPA_EVENT_TYPE (event) == impl->core->type.monitor.Changed) { - SpaMonitorItem *item = SPA_POD_CONTENTS (SpaEvent, event); + struct spa_monitor_item *item = SPA_POD_CONTENTS (struct spa_event, event); const char *name; - spa_pod_object_query (item, + spa_pod_object_query (&item->object, impl->core->type.monitor.name, SPA_POD_TYPE_STRING, &name, 0); @@ -196,8 +196,8 @@ update_monitor (struct pw_core *core, const char *name) { const char *monitors; - SpaDictItem item; - SpaDict dict = SPA_DICT_INIT(1, &item); + struct spa_dict_item item; + struct spa_dict dict = SPA_DICT_INIT(1, &item); if (core->properties) monitors = pw_properties_get (core->properties, "monitors"); @@ -216,6 +216,10 @@ update_monitor (struct pw_core *core, free ((void*)item.value); } +static const struct spa_monitor_callbacks callbacks = { + on_monitor_event, +}; + struct pw_spa_monitor * pw_spa_monitor_load (struct pw_core *core, const char *lib, @@ -224,19 +228,19 @@ pw_spa_monitor_load (struct pw_core *core, { struct impl *impl; struct pw_spa_monitor *this; - SpaHandle *handle; - SpaResult res; + struct spa_handle *handle; + int res; void *iface; void *hnd; uint32_t index; - SpaEnumHandleFactoryFunc enum_func; - const SpaHandleFactory *factory; + spa_handle_factory_enum_func_t enum_func; + const struct spa_handle_factory *factory; if ((hnd = dlopen (lib, RTLD_NOW)) == NULL) { pw_log_error ("can't load %s: %s", lib, dlerror()); return NULL; } - if ((enum_func = dlsym (hnd, "spa_enum_handle_factory")) == NULL) { + if ((enum_func = dlsym (hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { pw_log_error ("can't find enum function"); goto no_symbol; } @@ -284,8 +288,8 @@ pw_spa_monitor_load (struct pw_core *core, spa_list_init (&impl->item_list); for (index = 0;; index++) { - SpaMonitorItem *item; - SpaResult res; + struct spa_monitor_item *item; + int res; if ((res = spa_monitor_enum_items (this->monitor, &item, index)) < 0) { if (res != SPA_RESULT_ENUM_END) @@ -294,7 +298,7 @@ pw_spa_monitor_load (struct pw_core *core, } add_item (this, item); } - spa_monitor_set_event_callback (this->monitor, on_monitor_event, this); + spa_monitor_set_callbacks (this->monitor, &callbacks, sizeof (callbacks), this); return this; diff --git a/pipewire/modules/spa/spa-monitor.h b/pipewire/modules/spa/spa-monitor.h index ebba3067d..354190685 100644 --- a/pipewire/modules/spa/spa-monitor.h +++ b/pipewire/modules/spa/spa-monitor.h @@ -28,12 +28,12 @@ extern "C" { #endif struct pw_spa_monitor { - SpaMonitor *monitor; + struct spa_monitor *monitor; char *lib; char *factory_name; char *system_name; - SpaHandle *handle; + struct spa_handle *handle; PW_SIGNAL (destroy_signal, (struct pw_listener *listener, struct pw_spa_monitor *monitor)); }; diff --git a/pipewire/modules/spa/spa-node.c b/pipewire/modules/spa/spa-node.c index 597e07105..f1729dad3 100644 --- a/pipewire/modules/spa/spa-node.c +++ b/pipewire/modules/spa/spa-node.c @@ -42,21 +42,21 @@ pw_spa_node_load (struct pw_core *core, { struct pw_spa_node *this; struct impl *impl; - SpaNode *spa_node; - SpaClock *spa_clock; - SpaResult res; - SpaHandle *handle; + struct spa_node *spa_node; + struct spa_clock *spa_clock; + int res; + struct spa_handle *handle; void *hnd; uint32_t index; - SpaEnumHandleFactoryFunc enum_func; - const SpaHandleFactory *factory; + spa_handle_factory_enum_func_t enum_func; + const struct spa_handle_factory *factory; void *iface; if ((hnd = dlopen (lib, RTLD_NOW)) == NULL) { pw_log_error ("can't load %s: %s", lib, dlerror()); return NULL; } - if ((enum_func = dlsym (hnd, "spa_enum_handle_factory")) == NULL) { + if ((enum_func = dlsym (hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { pw_log_error ("can't find enum function"); goto no_symbol; } diff --git a/pipewire/modules/spa/spa-node.h b/pipewire/modules/spa/spa-node.h index ae7386221..490be5ed9 100644 --- a/pipewire/modules/spa/spa-node.h +++ b/pipewire/modules/spa/spa-node.h @@ -32,13 +32,13 @@ struct pw_spa_node { char *lib; char *factory_name; - SpaHandle *handle; + struct spa_handle *handle; PW_SIGNAL (destroy_signal, (struct pw_listener *listener, struct pw_spa_node *node)); }; -typedef SpaResult (*setup_node_t) (struct pw_core *core, - SpaNode *spa_node, +typedef int (*setup_node_t) (struct pw_core *core, + struct spa_node *spa_node, struct pw_properties *pw_props); struct pw_spa_node * pw_spa_node_load (struct pw_core *core, diff --git a/pipewire/server/access.h b/pipewire/server/access.h index 24dee42cb..6560277f9 100644 --- a/pipewire/server/access.h +++ b/pipewire/server/access.h @@ -32,7 +32,7 @@ extern "C" { #include struct pw_access_data { - SpaResult res; + int res; struct pw_resource *resource; void * (*async_copy) (struct pw_access_data *data, size_t size); @@ -48,15 +48,15 @@ struct pw_access_data { * PipeWire Access support struct. */ struct pw_access { - SpaResult (*view_global) (struct pw_access *access, + int (*view_global) (struct pw_access *access, struct pw_client *client, struct pw_global *global); - SpaResult (*create_node) (struct pw_access *access, + int (*create_node) (struct pw_access *access, struct pw_access_data *data, const char *factory_name, const char *name, struct pw_properties *properties); - SpaResult (*create_client_node) (struct pw_access *access, + int (*create_client_node) (struct pw_access *access, struct pw_access_data *data, const char *name, struct pw_properties *properties); diff --git a/pipewire/server/client-node.c b/pipewire/server/client-node.c index bde38bbea..9c109c1df 100644 --- a/pipewire/server/client-node.c +++ b/pipewire/server/client-node.c @@ -56,24 +56,24 @@ #define CHECK_PORT_BUFFER(this,b,p) (b < p->n_buffers) struct proxy_buffer { - SpaBuffer *outbuf; - SpaBuffer buffer; - SpaMeta metas[4]; - SpaData datas[4]; - off_t offset; - size_t size; - bool outstanding; + struct spa_buffer *outbuf; + struct spa_buffer buffer; + struct spa_meta metas[4]; + struct spa_data datas[4]; + off_t offset; + size_t size; + bool outstanding; }; struct proxy_port { bool valid; - SpaPortInfo info; - SpaFormat *format; + struct spa_port_info info; + struct spa_format *format; uint32_t n_formats; - SpaFormat **formats; + struct spa_format **formats; uint32_t n_params; - SpaParam **params; - SpaPortIO *io; + struct spa_param **params; + struct spa_port_io *io; uint32_t n_buffers; struct proxy_buffer buffers[MAX_BUFFERS]; @@ -84,21 +84,21 @@ struct proxy_port { struct proxy { - SpaNode node; + struct spa_node node; struct impl *impl; - SpaTypeMap *map; - SpaLog *log; - SpaLoop *main_loop; - SpaLoop *data_loop; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop *main_loop; + struct spa_loop *data_loop; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; struct pw_resource *resource; - SpaSource data_source; + struct spa_source data_source; int writefd; uint32_t max_inputs; @@ -130,7 +130,7 @@ struct impl { int other_fds[2]; }; -static SpaResult +static int clear_buffers (struct proxy *this, struct proxy_port *port) { if (port->n_buffers) { @@ -143,16 +143,16 @@ clear_buffers (struct proxy *this, struct proxy_port *port) return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_get_props (SpaNode *node, - SpaProps **props) +static int +spa_proxy_node_get_props (struct spa_node *node, + struct spa_props **props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_proxy_node_set_props (SpaNode *node, - const SpaProps *props) +static int +spa_proxy_node_set_props (struct spa_node *node, + const struct spa_props *props) { return SPA_RESULT_NOT_IMPLEMENTED; } @@ -184,12 +184,12 @@ send_have_output (struct proxy *this) do_flush (this); } -static SpaResult -spa_proxy_node_send_command (SpaNode *node, - SpaCommand *command) +static int +spa_proxy_node_send_command (struct spa_node *node, + struct spa_command *command) { struct proxy *this; - SpaResult res = SPA_RESULT_OK; + int res = SPA_RESULT_OK; struct pw_core *core; if (node == NULL || command == NULL) @@ -220,9 +220,9 @@ spa_proxy_node_send_command (SpaNode *node, return res; } -static SpaResult -spa_proxy_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +spa_proxy_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { @@ -238,8 +238,8 @@ spa_proxy_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_get_n_ports (SpaNode *node, +static int +spa_proxy_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -264,8 +264,8 @@ spa_proxy_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_get_port_ids (SpaNode *node, +static int +spa_proxy_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -296,15 +296,15 @@ spa_proxy_node_get_port_ids (SpaNode *node, static void do_update_port (struct proxy *this, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t change_mask, uint32_t n_possible_formats, - const SpaFormat **possible_formats, - const SpaFormat *format, + const struct spa_format **possible_formats, + const struct spa_format *format, uint32_t n_params, - const SpaParam **params, - const SpaPortInfo *info) + const struct spa_param **params, + const struct spa_port_info *info) { struct proxy_port *port; uint32_t i; @@ -319,7 +319,7 @@ do_update_port (struct proxy *this, for (i = 0; i < port->n_formats; i++) free (port->formats[i]); port->n_formats = n_possible_formats; - port->formats = realloc (port->formats, port->n_formats * sizeof (SpaFormat *)); + port->formats = realloc (port->formats, port->n_formats * sizeof (struct spa_format *)); for (i = 0; i < port->n_formats; i++) port->formats[i] = spa_format_copy (possible_formats[i]); } @@ -333,7 +333,7 @@ do_update_port (struct proxy *this, for (i = 0; i < port->n_params; i++) free (port->params[i]); port->n_params = n_params; - port->params = realloc (port->params, port->n_params * sizeof (SpaParam *)); + port->params = realloc (port->params, port->n_params * sizeof (struct spa_param *)); for (i = 0; i < port->n_params; i++) port->params[i] = spa_param_copy (params[i]); } @@ -356,7 +356,7 @@ do_update_port (struct proxy *this, static void clear_port (struct proxy *this, struct proxy_port *port, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id) { do_update_port (this, @@ -377,7 +377,7 @@ clear_port (struct proxy *this, static void do_uninit_port (struct proxy *this, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id) { struct proxy_port *port; @@ -394,9 +394,9 @@ do_uninit_port (struct proxy *this, port->valid = false; } -static SpaResult -spa_proxy_node_add_port (SpaNode *node, - SpaDirection direction, +static int +spa_proxy_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { struct proxy *this; @@ -416,9 +416,9 @@ spa_proxy_node_add_port (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +spa_proxy_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { struct proxy *this; @@ -436,19 +436,19 @@ spa_proxy_node_remove_port (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +spa_proxy_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { struct proxy *this; struct proxy_port *port; - SpaFormat *fmt; - SpaPODBuilder b = { NULL, }; - SpaResult res; + struct spa_format *fmt; + struct spa_pod_builder b = { NULL, }; + int res; uint32_t count, match = 0; if (node == NULL || format == NULL) @@ -474,17 +474,17 @@ next: if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK || match++ != index) goto next; - *format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, 0, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +spa_proxy_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { struct proxy *this; @@ -509,11 +509,11 @@ spa_proxy_node_port_set_format (SpaNode *node, return SPA_RESULT_RETURN_ASYNC (this->seq++); } -static SpaResult -spa_proxy_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +spa_proxy_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { struct proxy *this; struct proxy_port *port; @@ -536,11 +536,11 @@ spa_proxy_node_port_get_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +spa_proxy_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { struct proxy *this; struct proxy_port *port; @@ -560,12 +560,12 @@ spa_proxy_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +spa_proxy_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { struct proxy *this; struct proxy_port *port; @@ -587,20 +587,20 @@ spa_proxy_node_port_enum_params (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +spa_proxy_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_proxy_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +spa_proxy_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { struct proxy *this; struct proxy_port *port; @@ -619,12 +619,12 @@ spa_proxy_node_port_set_io (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +spa_proxy_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { struct proxy *this; struct impl *impl; @@ -632,7 +632,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node, uint32_t i, j; size_t n_mem; struct pw_client_node_buffer *mb; - SpaMetaShared *msh; + struct spa_meta_shared *msh; this = SPA_CONTAINER_OF (node, struct proxy, node); impl = this->impl; @@ -670,7 +670,7 @@ spa_proxy_node_port_use_buffers (SpaNode *node, } b->outbuf = buffers[i]; - memcpy (&b->buffer, buffers[i], sizeof (SpaBuffer)); + memcpy (&b->buffer, buffers[i], sizeof (struct spa_buffer)); b->buffer.datas = b->datas; b->buffer.metas = b->metas; @@ -690,13 +690,13 @@ spa_proxy_node_port_use_buffers (SpaNode *node, msh->size); for (j = 0; j < buffers[i]->n_metas; j++) { - memcpy (&b->buffer.metas[j], &buffers[i]->metas[j], sizeof (SpaMeta)); + memcpy (&b->buffer.metas[j], &buffers[i]->metas[j], sizeof (struct spa_meta)); } for (j = 0; j < buffers[i]->n_datas; j++) { - SpaData *d = &buffers[i]->datas[j]; + struct spa_data *d = &buffers[i]->datas[j]; - memcpy (&b->buffer.datas[j], d, sizeof (SpaData)); + memcpy (&b->buffer.datas[j], d, sizeof (struct spa_data)); if (d->type == impl->core->type.data.DmaBuf || d->type == impl->core->type.data.MemFd) { @@ -735,14 +735,14 @@ spa_proxy_node_port_use_buffers (SpaNode *node, return SPA_RESULT_RETURN_ASYNC (this->seq++); } -static SpaResult -spa_proxy_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +spa_proxy_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { struct proxy *this; struct proxy_port *port; @@ -763,8 +763,8 @@ spa_proxy_node_port_alloc_buffers (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_proxy_node_port_reuse_buffer (SpaNode *node, +static int +spa_proxy_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { @@ -784,17 +784,17 @@ spa_proxy_node_port_reuse_buffer (SpaNode *node, { struct pw_event_transport_reuse_buffer rb = PW_EVENT_TRANSPORT_REUSE_BUFFER_INIT (impl->core->type.event_transport.ReuseBuffer, port_id, buffer_id); - pw_transport_add_event (impl->transport, (SpaEvent *)&rb); + pw_transport_add_event (impl->transport, (struct spa_event *)&rb); } return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +spa_proxy_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { struct proxy *this; @@ -807,8 +807,8 @@ spa_proxy_node_port_send_command (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_proxy_node_process_input (SpaNode *node) +static int +spa_proxy_node_process_input (struct spa_node *node) { struct impl *impl; struct proxy *this; @@ -821,7 +821,7 @@ spa_proxy_node_process_input (SpaNode *node) impl = this->impl; for (i = 0; i < MAX_INPUTS; i++) { - SpaPortIO *io = this->in_ports[i].io; + struct spa_port_io *io = this->in_ports[i].io; if (!io) continue; @@ -836,8 +836,8 @@ spa_proxy_node_process_input (SpaNode *node) return SPA_RESULT_OK; } -static SpaResult -spa_proxy_node_process_output (SpaNode *node) +static int +spa_proxy_node_process_output (struct spa_node *node) { struct proxy *this; struct impl *impl; @@ -848,7 +848,7 @@ spa_proxy_node_process_output (SpaNode *node) impl = this->impl; for (i = 0; i < MAX_OUTPUTS; i++) { - SpaPortIO *io = this->out_ports[i].io, tmp; + struct spa_port_io *io = this->out_ports[i].io, tmp; if (!io) continue; @@ -859,7 +859,7 @@ spa_proxy_node_process_output (SpaNode *node) spa_log_trace (this->log, "reuse buffer %d", io->buffer_id); - pw_transport_add_event (impl->transport, (SpaEvent *)&rb); + pw_transport_add_event (impl->transport, (struct spa_event *)&rb); io->buffer_id = SPA_ID_INVALID; flush = true; } @@ -882,16 +882,16 @@ spa_proxy_node_process_output (SpaNode *node) return SPA_RESULT_HAVE_BUFFER; } -static SpaResult +static int handle_node_event (struct proxy *this, - SpaEvent *event) + struct spa_event *event) { struct impl *impl = SPA_CONTAINER_OF (this, struct impl, proxy); int i; if (SPA_EVENT_TYPE (event) == impl->core->type.event_transport.HaveOutput) { for (i = 0; i < MAX_OUTPUTS; i++) { - SpaPortIO *io = this->out_ports[i].io; + struct spa_port_io *io = this->out_ports[i].io; if (!io) continue; @@ -916,7 +916,7 @@ client_node_update (void *object, uint32_t change_mask, uint32_t max_input_ports, uint32_t max_output_ports, - const SpaProps *props) + const struct spa_props *props) { struct pw_resource *resource = object; struct pw_client_node *node = resource->object; @@ -934,15 +934,15 @@ client_node_update (void *object, static void client_node_port_update (void *object, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t change_mask, uint32_t n_possible_formats, - const SpaFormat **possible_formats, - const SpaFormat *format, + const struct spa_format **possible_formats, + const struct spa_format *format, uint32_t n_params, - const SpaParam **params, - const SpaPortInfo *info) + const struct spa_param **params, + const struct spa_port_info *info) { struct pw_resource *resource = object; struct pw_client_node *node = resource->object; @@ -974,7 +974,7 @@ client_node_port_update (void *object, static void client_node_event (void *object, - SpaEvent *event) + struct spa_event *event) { struct pw_resource *resource = object; struct pw_client_node *node = resource->object; @@ -1000,7 +1000,7 @@ static struct pw_client_node_methods client_node_methods = { }; static void -proxy_on_data_fd_events (SpaSource *source) +proxy_on_data_fd_events (struct spa_source *source) { struct proxy *this = source->data; struct impl *impl = this->impl; @@ -1011,21 +1011,21 @@ proxy_on_data_fd_events (SpaSource *source) } if (source->rmask & SPA_IO_IN) { - SpaEvent event; + struct spa_event event; uint64_t cmd; read (this->data_source.fd, &cmd, 8); while (pw_transport_next_event (impl->transport, &event) == SPA_RESULT_OK) { - SpaEvent *ev = alloca (SPA_POD_SIZE (&event)); + struct spa_event *ev = alloca (SPA_POD_SIZE (&event)); pw_transport_parse_event (impl->transport, ev); handle_node_event (this, ev); } } } -static const SpaNode proxy_node = { - sizeof (SpaNode), +static const struct spa_node proxy_node = { + sizeof (struct spa_node), NULL, spa_proxy_node_get_props, spa_proxy_node_set_props, @@ -1050,11 +1050,11 @@ static const SpaNode proxy_node = { spa_proxy_node_process_output, }; -static SpaResult -proxy_init (struct proxy *this, - SpaDict *info, - const SpaSupport *support, - uint32_t n_support) +static int +proxy_init (struct proxy *this, + struct spa_dict *info, + const struct spa_support *support, + uint32_t n_support) { uint32_t i; @@ -1126,7 +1126,7 @@ on_global_added (struct pw_listener *listener, global->owner = impl->this.client; } -static SpaResult +static int proxy_clear (struct proxy *this) { uint32_t i; @@ -1287,7 +1287,7 @@ pw_client_node_destroy (struct pw_client_node * this) * * Returns: %SPA_RESULT_OK on success */ -SpaResult +int pw_client_node_get_fds (struct pw_client_node *this, int *readfd, int *writefd) diff --git a/pipewire/server/client-node.h b/pipewire/server/client-node.h index 874026941..0a3ae8d79 100644 --- a/pipewire/server/client-node.h +++ b/pipewire/server/client-node.h @@ -50,7 +50,7 @@ struct pw_client_node * pw_client_node_new (struct pw_client *cl struct pw_properties *properties); void pw_client_node_destroy (struct pw_client_node *node); -SpaResult pw_client_node_get_fds (struct pw_client_node *node, +int pw_client_node_get_fds (struct pw_client_node *node, int *readfd, int *writefd); diff --git a/pipewire/server/client.c b/pipewire/server/client.c index 7ea104a70..6a705a309 100644 --- a/pipewire/server/client.c +++ b/pipewire/server/client.c @@ -37,7 +37,7 @@ client_unbind_func (void *data) spa_list_remove (&resource->link); } -static SpaResult +static int client_bind_func (struct pw_global *global, struct pw_client *client, uint32_t version, @@ -166,8 +166,8 @@ pw_client_destroy (struct pw_client * client) } void -pw_client_update_properties (struct pw_client *client, - const SpaDict *dict) +pw_client_update_properties (struct pw_client *client, + const struct spa_dict *dict) { struct pw_resource *resource; diff --git a/pipewire/server/client.h b/pipewire/server/client.h index b5a10cea0..2fed3c972 100644 --- a/pipewire/server/client.h +++ b/pipewire/server/client.h @@ -40,7 +40,7 @@ extern "C" { */ struct pw_client { struct pw_core *core; - SpaList link; + struct spa_list link; struct pw_global *global; struct pw_properties *properties; @@ -59,7 +59,7 @@ struct pw_client { uint32_t n_types; struct pw_map types; - SpaList resource_list; + struct spa_list resource_list; PW_SIGNAL (resource_added, (struct pw_listener *listener, struct pw_client *client, struct pw_resource *resource)); @@ -77,7 +77,7 @@ struct pw_client * pw_client_new (struct pw_core *core, void pw_client_destroy (struct pw_client *client); void pw_client_update_properties (struct pw_client *client, - const SpaDict *dict); + const struct spa_dict *dict); #ifdef __cplusplus } diff --git a/pipewire/server/command.h b/pipewire/server/command.h index 9c8189c8e..844ab53ce 100644 --- a/pipewire/server/command.h +++ b/pipewire/server/command.h @@ -28,7 +28,7 @@ extern "C" { #include struct pw_command { - SpaList link; + struct spa_list link; const char *name; }; diff --git a/pipewire/server/core.c b/pipewire/server/core.c index d71e7e40b..f64daafc7 100644 --- a/pipewire/server/core.c +++ b/pipewire/server/core.c @@ -34,7 +34,7 @@ struct global_impl { struct impl { struct pw_core this; - SpaSupport support[4]; + struct spa_support support[4]; }; #define ACCESS_VIEW_GLOBAL(client,global) (client->core->access == NULL || \ @@ -88,8 +88,8 @@ destroy_registry_resource (void *object) } static void -core_client_update (void *object, - const SpaDict *props) +core_client_update (void *object, + const struct spa_dict *props) { struct pw_resource *resource = object; @@ -148,7 +148,7 @@ static void core_create_node (void *object, const char *factory_name, const char *name, - const SpaDict *props, + const struct spa_dict *props, uint32_t new_id) { struct pw_resource *resource = object; @@ -201,7 +201,7 @@ async_create_client_node_complete (struct pw_access_data *data) struct pw_resource *resource = d->data.resource; struct pw_client *client = resource->client; struct pw_client_node *node; - SpaResult res; + int res; int readfd, writefd; if (data->res != SPA_RESULT_OK) @@ -248,7 +248,7 @@ done: static void core_create_client_node (void *object, const char *name, - const SpaDict *props, + const struct spa_dict *props, uint32_t new_id) { struct pw_resource *resource = object; @@ -256,7 +256,7 @@ core_create_client_node (void *object, int i; struct pw_properties *properties; struct access_create_client_node access_data; - SpaResult res; + int res; properties = pw_properties_new (NULL, NULL); if (properties == NULL) @@ -333,7 +333,7 @@ core_unbind_func (void *data) spa_list_remove (&resource->link); } -static SpaResult +static int core_bind_func (struct pw_global *global, struct pw_client *client, uint32_t version, @@ -501,13 +501,13 @@ pw_core_add_global (struct pw_core *core, return true; } -SpaResult +int pw_global_bind (struct pw_global *global, struct pw_client *client, uint32_t version, uint32_t id) { - SpaResult res; + int res; struct global_impl *impl = SPA_CONTAINER_OF (global, struct global_impl, this); if (impl->bind) { @@ -546,7 +546,7 @@ pw_global_destroy (struct pw_global *global) void pw_core_update_properties (struct pw_core *core, - const SpaDict *dict) + const struct spa_dict *dict) { struct pw_resource *resource; @@ -576,7 +576,7 @@ pw_core_find_port (struct pw_core *core, uint32_t id, struct pw_properties *props, uint32_t n_format_filters, - SpaFormat **format_filters, + struct spa_format **format_filters, char **error) { struct pw_port *best = NULL; @@ -634,18 +634,18 @@ pw_core_find_port (struct pw_core *core, return best; } -SpaFormat * +struct spa_format * pw_core_find_format (struct pw_core *core, struct pw_port *output, struct pw_port *input, struct pw_properties *props, uint32_t n_format_filters, - SpaFormat **format_filterss, + struct spa_format **format_filterss, char **error) { uint32_t out_state, in_state; - SpaResult res; - SpaFormat *filter = NULL, *format; + int res; + struct spa_format *filter = NULL, *format; uint32_t iidx = 0, oidx = 0; out_state = output->state; @@ -663,7 +663,7 @@ pw_core_find_format (struct pw_core *core, if ((res = spa_node_port_get_format (output->node->node, SPA_DIRECTION_OUTPUT, output->port_id, - (const SpaFormat **)&format)) < 0) { + (const struct spa_format **)&format)) < 0) { asprintf (error, "error get output format: %d", res); goto error; } @@ -672,7 +672,7 @@ pw_core_find_format (struct pw_core *core, if ((res = spa_node_port_get_format (input->node->node, SPA_DIRECTION_INPUT, input->port_id, - (const SpaFormat **)&format)) < 0) { + (const struct spa_format **)&format)) < 0) { asprintf (error, "error get input format: %d", res); goto error; } diff --git a/pipewire/server/core.h b/pipewire/server/core.h index 182014023..60762f005 100644 --- a/pipewire/server/core.h +++ b/pipewire/server/core.h @@ -36,7 +36,7 @@ struct pw_global; #include #include -typedef SpaResult (*pw_bind_func_t) (struct pw_global *global, +typedef int (*pw_bind_func_t) (struct pw_global *global, struct pw_client *client, uint32_t version, uint32_t id); @@ -45,7 +45,7 @@ struct pw_global { struct pw_core *core; struct pw_client *owner; - SpaList link; + struct spa_list link; uint32_t id; uint32_t type; uint32_t version; @@ -72,18 +72,18 @@ struct pw_core { struct pw_map objects; - SpaList resource_list; - SpaList registry_resource_list; - SpaList global_list; - SpaList client_list; - SpaList node_list; - SpaList node_factory_list; - SpaList link_list; + struct spa_list resource_list; + struct spa_list registry_resource_list; + struct spa_list global_list; + struct spa_list client_list; + struct spa_list node_list; + struct spa_list node_factory_list; + struct spa_list link_list; struct pw_main_loop *main_loop; struct pw_data_loop *data_loop; - SpaSupport *support; + struct spa_support *support; uint32_t n_support; PW_SIGNAL (destroy_signal, (struct pw_listener *listener, @@ -101,8 +101,8 @@ struct pw_core * pw_core_new (struct pw_main_loop *main_loop, struct pw_properties *props); void pw_core_destroy (struct pw_core *core); -void pw_core_update_properties (struct pw_core *core, - const SpaDict *dict); +void pw_core_update_properties (struct pw_core *core, + const struct spa_dict *dict); bool pw_core_add_global (struct pw_core *core, struct pw_client *owner, @@ -112,18 +112,18 @@ bool pw_core_add_global (struct pw_core *core, pw_bind_func_t bind, struct pw_global **global); -SpaResult pw_global_bind (struct pw_global *global, +int pw_global_bind (struct pw_global *global, struct pw_client *client, uint32_t version, uint32_t id); void pw_global_destroy (struct pw_global *global); -SpaFormat * pw_core_find_format (struct pw_core *core, +struct spa_format * pw_core_find_format (struct pw_core *core, struct pw_port *output, struct pw_port *input, struct pw_properties *props, uint32_t n_format_filters, - SpaFormat **format_filters, + struct spa_format **format_filters, char **error); struct pw_port * pw_core_find_port (struct pw_core *core, @@ -131,7 +131,7 @@ struct pw_port * pw_core_find_port (struct pw_core *core, uint32_t id, struct pw_properties *props, uint32_t n_format_filters, - SpaFormat **format_filters, + struct spa_format **format_filters, char **error); struct pw_node_factory * pw_core_find_node_factory (struct pw_core *core, diff --git a/pipewire/server/data-loop.c b/pipewire/server/data-loop.c index d073f7ce4..1ed00034e 100644 --- a/pipewire/server/data-loop.c +++ b/pipewire/server/data-loop.c @@ -36,7 +36,7 @@ struct impl { struct pw_data_loop this; - SpaSource *event; + struct spa_source *event; bool running; pthread_t thread; @@ -91,7 +91,7 @@ do_loop (void *user_data) { struct impl *impl = user_data; struct pw_data_loop *this = &impl->this; - SpaResult res; + int res; make_realtime (this); @@ -110,9 +110,9 @@ do_loop (void *user_data) static void -do_stop (SpaLoopUtils *utils, - SpaSource *source, - void *data) +do_stop (struct spa_loop_utils *utils, + struct spa_source *source, + void *data) { struct impl *impl = data; impl->running = false; @@ -169,7 +169,7 @@ pw_data_loop_destroy (struct pw_data_loop *loop) free (impl); } -SpaResult +int pw_data_loop_start (struct pw_data_loop *loop) { struct impl *impl = SPA_CONTAINER_OF (loop, struct impl, this); @@ -187,7 +187,7 @@ pw_data_loop_start (struct pw_data_loop *loop) return SPA_RESULT_OK; } -SpaResult +int pw_data_loop_stop (struct pw_data_loop *loop) { struct impl *impl = SPA_CONTAINER_OF (loop, struct impl, this); diff --git a/pipewire/server/data-loop.h b/pipewire/server/data-loop.h index 7bb6e98b2..6e9b94eb3 100644 --- a/pipewire/server/data-loop.h +++ b/pipewire/server/data-loop.h @@ -41,8 +41,8 @@ struct pw_data_loop { struct pw_data_loop * pw_data_loop_new (void); void pw_data_loop_destroy (struct pw_data_loop *loop); -SpaResult pw_data_loop_start (struct pw_data_loop *loop); -SpaResult pw_data_loop_stop (struct pw_data_loop *loop); +int pw_data_loop_start (struct pw_data_loop *loop); +int pw_data_loop_stop (struct pw_data_loop *loop); bool pw_data_loop_in_thread (struct pw_data_loop *loop); diff --git a/pipewire/server/link.c b/pipewire/server/link.c index b1137836d..1167bb660 100644 --- a/pipewire/server/link.c +++ b/pipewire/server/link.c @@ -40,7 +40,7 @@ struct impl { struct pw_work_queue *work; - SpaFormat **format_filter; + struct spa_format **format_filter; struct pw_properties *properties; struct pw_listener input_port_destroy; @@ -50,7 +50,7 @@ struct impl { void *buffer_owner; struct pw_memblock buffer_mem; - SpaBuffer **buffers; + struct spa_buffer **buffers; uint32_t n_buffers; }; @@ -79,7 +79,7 @@ pw_link_update_state (struct pw_link *link, static void complete_ready (void *obj, void *data, - SpaResult res, + int res, uint32_t id) { struct pw_port *port = data; @@ -94,7 +94,7 @@ complete_ready (void *obj, static void complete_paused (void *obj, void *data, - SpaResult res, + int res, uint32_t id) { struct pw_port *port = data; @@ -109,7 +109,7 @@ complete_paused (void *obj, static void complete_streaming (void *obj, void *data, - SpaResult res, + int res, uint32_t id) { struct pw_port *port = data; @@ -121,12 +121,12 @@ complete_streaming (void *obj, pw_log_warn ("port %p: failed to go to STREAMING", port); } -static SpaResult +static int do_negotiate (struct pw_link *this, uint32_t in_state, uint32_t out_state) { struct impl *impl = SPA_CONTAINER_OF (this, struct impl, this); - SpaResult res = SPA_RESULT_ERROR, res2; - SpaFormat *format; + int res = SPA_RESULT_ERROR, res2; + struct spa_format *format; char *error = NULL; if (in_state != PW_PORT_STATE_CONFIGURE && out_state != PW_PORT_STATE_CONFIGURE) @@ -191,25 +191,25 @@ error: } } -static SpaParam * -find_param (SpaParam **params, int n_params, uint32_t type) +static struct spa_param * +find_param (struct spa_param **params, int n_params, uint32_t type) { uint32_t i; for (i = 0; i < n_params; i++) { - if (spa_pod_is_object_type (¶ms[i]->pod, type)) + if (spa_pod_is_object_type (¶ms[i]->object.pod, type)) return params[i]; } return NULL; } -static SpaParam * -find_meta_enable (struct pw_core *core, SpaParam **params, int n_params, uint32_t type) +static struct spa_param * +find_meta_enable (struct pw_core *core, struct spa_param **params, int n_params, uint32_t type) { uint32_t i; for (i = 0; i < n_params; i++) { - if (spa_pod_is_object_type (¶ms[i]->pod, core->type.param_alloc_meta_enable.MetaEnable)) { + if (spa_pod_is_object_type (¶ms[i]->object.pod, core->type.param_alloc_meta_enable.MetaEnable)) { uint32_t qtype; if (spa_param_query (params[i], @@ -223,41 +223,41 @@ find_meta_enable (struct pw_core *core, SpaParam **params, int n_params, uint32_ return NULL; } -static SpaBuffer ** +static struct spa_buffer ** alloc_buffers (struct pw_link *this, uint32_t n_buffers, uint32_t n_params, - SpaParam **params, + struct spa_param **params, uint32_t n_datas, size_t *data_sizes, ssize_t *data_strides, struct pw_memblock *mem) { - SpaBuffer **buffers, *bp; + struct spa_buffer **buffers, *bp; uint32_t i; size_t skel_size, data_size, meta_size; - SpaChunk *cdp; + struct spa_chunk *cdp; void *ddp; uint32_t n_metas; - SpaMeta *metas; + struct spa_meta *metas; n_metas = data_size = meta_size = 0; /* each buffer */ - skel_size = sizeof (SpaBuffer); + skel_size = sizeof (struct spa_buffer); - metas = alloca (sizeof (SpaMeta) * n_params + 1); + metas = alloca (sizeof (struct spa_meta) * n_params + 1); /* add shared metadata */ metas[n_metas].type = this->core->type.meta.Shared; - metas[n_metas].size = sizeof (SpaMetaShared); + metas[n_metas].size = sizeof (struct spa_meta_shared); meta_size += metas[n_metas].size; n_metas++; - skel_size += sizeof (SpaMeta); + skel_size += sizeof (struct spa_meta); /* collect metadata */ for (i = 0; i < n_params; i++) { - if (spa_pod_is_object_type (¶ms[i]->pod, this->core->type.param_alloc_meta_enable.MetaEnable)) { + if (spa_pod_is_object_type (¶ms[i]->object.pod, this->core->type.param_alloc_meta_enable.MetaEnable)) { uint32_t type, size; if (spa_param_query (params[i], @@ -272,21 +272,21 @@ alloc_buffers (struct pw_link *this, metas[n_metas].size = size; meta_size += metas[n_metas].size; n_metas++; - skel_size += sizeof (SpaMeta); + skel_size += sizeof (struct spa_meta); } } data_size += meta_size; /* data */ for (i = 0; i < n_datas; i++) { - data_size += sizeof (SpaChunk); + data_size += sizeof (struct spa_chunk); data_size += data_sizes[i]; - skel_size += sizeof (SpaData); + skel_size += sizeof (struct spa_data); } - buffers = calloc (n_buffers, skel_size + sizeof (SpaBuffer *)); + buffers = calloc (n_buffers, skel_size + sizeof (struct spa_buffer *)); /* pointer to buffer structures */ - bp = SPA_MEMBER (buffers, n_buffers * sizeof (SpaBuffer *), SpaBuffer); + bp = SPA_MEMBER (buffers, n_buffers * sizeof (struct spa_buffer *), struct spa_buffer); pw_memblock_alloc (PW_MEMBLOCK_FLAG_WITH_FD | PW_MEMBLOCK_FLAG_MAP_READWRITE | @@ -296,25 +296,25 @@ alloc_buffers (struct pw_link *this, for (i = 0; i < n_buffers; i++) { int j; - SpaBuffer *b; + struct spa_buffer *b; void *p; - buffers[i] = b = SPA_MEMBER (bp, skel_size * i, SpaBuffer); + buffers[i] = b = SPA_MEMBER (bp, skel_size * i, struct spa_buffer); p = SPA_MEMBER (mem->ptr, data_size * i, void); b->id = i; b->n_metas = n_metas; - b->metas = SPA_MEMBER (b, sizeof (SpaBuffer), SpaMeta); + b->metas = SPA_MEMBER (b, sizeof (struct spa_buffer), struct spa_meta); for (j = 0; j < n_metas; j++) { - SpaMeta *m = &b->metas[j]; + struct spa_meta *m = &b->metas[j]; m->type = metas[j].type; m->data = p; m->size = metas[j].size; if (m->type == this->core->type.meta.Shared) { - SpaMetaShared *msh = p; + struct spa_meta_shared *msh = p; msh->flags = 0; msh->fd = mem->fd; @@ -322,20 +322,20 @@ alloc_buffers (struct pw_link *this, msh->size = data_size; } else if (m->type == this->core->type.meta.Ringbuffer) { - SpaMetaRingbuffer *rb = p; + struct spa_meta_ringbuffer *rb = p; spa_ringbuffer_init (&rb->ringbuffer, data_sizes[0]); } p += m->size; } /* pointer to data structure */ b->n_datas = n_datas; - b->datas = SPA_MEMBER (b->metas, n_metas * sizeof (SpaMeta), SpaData); + b->datas = SPA_MEMBER (b->metas, n_metas * sizeof (struct spa_meta), struct spa_data); cdp = p; - ddp = SPA_MEMBER (cdp, sizeof (SpaChunk) * n_datas, void); + ddp = SPA_MEMBER (cdp, sizeof (struct spa_chunk) * n_datas, void); for (j = 0; j < n_datas; j++) { - SpaData *d = &b->datas[j]; + struct spa_data *d = &b->datas[j]; d->chunk = &cdp[j]; if (data_sizes[j] > 0) { @@ -360,14 +360,14 @@ alloc_buffers (struct pw_link *this, static int spa_node_param_filter (struct pw_link *this, - SpaNode *in_node, + struct spa_node *in_node, uint32_t in_port, - SpaNode *out_node, + struct spa_node *out_node, uint32_t out_port, - SpaPODBuilder *result) + struct spa_pod_builder *result) { - SpaResult res; - SpaParam *oparam, *iparam; + int res; + struct spa_param *oparam, *iparam; int iidx, oidx, num = 0; for (iidx = 0; ; iidx++) { @@ -378,7 +378,7 @@ spa_node_param_filter (struct pw_link *this, spa_debug_param (iparam, this->core->type.map); for (oidx = 0; ; oidx++) { - SpaPODFrame f; + struct spa_pod_frame f; uint32_t offset; if (spa_node_port_enum_params (out_node, SPA_DIRECTION_OUTPUT, out_port, oidx, &oparam) < 0) @@ -387,16 +387,16 @@ spa_node_param_filter (struct pw_link *this, if (pw_log_level_enabled (SPA_LOG_LEVEL_DEBUG)) spa_debug_param (oparam, this->core->type.map); - if (iparam->body.body.type != oparam->body.body.type) + if (iparam->object.body.type != oparam->object.body.type) continue; offset = result->offset; - spa_pod_builder_push_object (result, &f, 0, iparam->body.body.type); + spa_pod_builder_push_object (result, &f, 0, iparam->object.body.type); if ((res = spa_props_filter (result, - SPA_POD_CONTENTS (SpaParam, iparam), - SPA_POD_CONTENTS_SIZE (SpaParam, iparam), - SPA_POD_CONTENTS (SpaParam, oparam), - SPA_POD_CONTENTS_SIZE (SpaParam, oparam))) < 0) { + SPA_POD_CONTENTS (struct spa_param, iparam), + SPA_POD_CONTENTS_SIZE (struct spa_param, iparam), + SPA_POD_CONTENTS (struct spa_param, oparam), + SPA_POD_CONTENTS_SIZE (struct spa_param, oparam))) < 0) { result->offset = offset; result->stack = NULL; continue; @@ -408,12 +408,12 @@ spa_node_param_filter (struct pw_link *this, return num; } -static SpaResult +static int do_allocation (struct pw_link *this, uint32_t in_state, uint32_t out_state) { struct impl *impl = SPA_CONTAINER_OF (this, struct impl, this); - SpaResult res; - const SpaPortInfo *iinfo, *oinfo; + int res; + const struct spa_port_info *iinfo, *oinfo; uint32_t in_flags, out_flags; char *error = NULL; @@ -487,9 +487,9 @@ do_allocation (struct pw_link *this, uint32_t in_state, uint32_t out_state) } if (impl->buffers == NULL) { - SpaParam **params, *param; + struct spa_param **params, *param; uint8_t buffer[4096]; - SpaPODBuilder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); + struct spa_pod_builder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); int i, offset, n_params; uint32_t max_buffers; size_t minsize = 1024, stride = 0; @@ -501,9 +501,9 @@ do_allocation (struct pw_link *this, uint32_t in_state, uint32_t out_state) this->output->port_id, &b); - params = alloca (n_params * sizeof (SpaParam *)); + params = alloca (n_params * sizeof (struct spa_param *)); for (i = 0, offset = 0; i < n_params; i++) { - params[i] = SPA_MEMBER (buffer, offset, SpaParam); + params[i] = SPA_MEMBER (buffer, offset, struct spa_param); spa_param_fixate (params[i]); spa_debug_param (params[i], this->core->type.map); offset += SPA_ROUND_UP_N (SPA_POD_SIZE (params[i]), 8); @@ -666,10 +666,10 @@ error: } } -static SpaResult +static int do_start (struct pw_link *this, uint32_t in_state, uint32_t out_state) { - SpaResult res = SPA_RESULT_OK; + int res = SPA_RESULT_OK; struct impl *impl = SPA_CONTAINER_OF (this, struct impl, this); if (in_state < PW_PORT_STATE_PAUSED || out_state < PW_PORT_STATE_PAUSED) @@ -691,10 +691,10 @@ do_start (struct pw_link *this, uint32_t in_state, uint32_t out_state) return res; } -static SpaResult +static int check_states (struct pw_link *this, void *user_data, - SpaResult res) + int res) { struct impl *impl = SPA_CONTAINER_OF (this, struct impl, this); uint32_t in_state, out_state; @@ -745,7 +745,7 @@ static void on_input_async_complete_notify (struct pw_listener *listener, struct pw_node *node, uint32_t seq, - SpaResult res) + int res) { struct impl *impl = SPA_CONTAINER_OF (listener, struct impl, input_async_complete); @@ -757,7 +757,7 @@ static void on_output_async_complete_notify (struct pw_listener *listener, struct pw_node *node, uint32_t seq, - SpaResult res) + int res) { struct impl *impl = SPA_CONTAINER_OF (listener, struct impl, output_async_complete); @@ -868,7 +868,7 @@ link_unbind_func (void *data) pw_link_free (this); } -static SpaResult +static int link_bind_func (struct pw_global *global, struct pw_client *client, uint32_t version, @@ -917,7 +917,7 @@ struct pw_link * pw_link_new (struct pw_core *core, struct pw_port *output, struct pw_port *input, - SpaFormat **format_filter, + struct spa_format **format_filter, struct pw_properties *properties) { struct impl *impl; @@ -998,13 +998,13 @@ clear_port_buffers (struct pw_link *link, struct pw_port *port) } } -static SpaResult -do_link_remove_done (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_link_remove_done (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { struct pw_link *this = user_data; struct impl *impl = SPA_CONTAINER_OF (this, struct impl, this); @@ -1041,15 +1041,15 @@ do_link_remove_done (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -do_link_remove (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_link_remove (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - SpaResult res; + int res; struct pw_link *this = user_data; if (this->rt.input) { diff --git a/pipewire/server/link.h b/pipewire/server/link.h index f2b730250..be0ea3123 100644 --- a/pipewire/server/link.h +++ b/pipewire/server/link.h @@ -39,7 +39,7 @@ extern "C" { */ struct pw_link { struct pw_core *core; - SpaList link; + struct spa_list link; struct pw_global *global; struct pw_properties *properties; @@ -56,22 +56,22 @@ struct pw_link { PW_SIGNAL (free_signal, (struct pw_listener *, struct pw_link *)); - SpaList resource_list; + struct spa_list resource_list; - struct pw_port *output; - SpaList output_link; - struct pw_port *input; - SpaList input_link; + struct pw_port *output; + struct spa_list output_link; + struct pw_port *input; + struct spa_list input_link; PW_SIGNAL (port_unlinked, (struct pw_listener *listener, struct pw_link *link, struct pw_port *port)); struct { - uint32_t in_ready; - struct pw_port *input; - struct pw_port *output; - SpaList input_link; - SpaList output_link; + uint32_t in_ready; + struct pw_port *input; + struct pw_port *output; + struct spa_list input_link; + struct spa_list output_link; } rt; }; @@ -79,7 +79,7 @@ struct pw_link { struct pw_link * pw_link_new (struct pw_core *core, struct pw_port *output, struct pw_port *input, - SpaFormat **format_filter, + struct spa_format **format_filter, struct pw_properties *properties); void pw_link_destroy (struct pw_link *link); diff --git a/pipewire/server/module.c b/pipewire/server/module.c index 9d9f182cd..fda17d9fa 100644 --- a/pipewire/server/module.c +++ b/pipewire/server/module.c @@ -89,7 +89,7 @@ find_module (const char * path, const char *name) return filename; } -static SpaResult +static int module_bind_func (struct pw_global *global, struct pw_client *client, uint32_t version, diff --git a/pipewire/server/module.h b/pipewire/server/module.h index a27ab5c29..d02dc62b1 100644 --- a/pipewire/server/module.h +++ b/pipewire/server/module.h @@ -29,7 +29,7 @@ extern "C" { struct pw_module { struct pw_core *core; - SpaList link; + struct spa_list link; struct pw_global *global; struct pw_module_info info; diff --git a/pipewire/server/node-factory.h b/pipewire/server/node-factory.h index b959fc74f..fb175efda 100644 --- a/pipewire/server/node-factory.h +++ b/pipewire/server/node-factory.h @@ -37,7 +37,7 @@ extern "C" { */ struct pw_node_factory { struct pw_core *core; - SpaList link; + struct spa_list link; struct pw_global *global; const char *name; diff --git a/pipewire/server/node.c b/pipewire/server/node.c index 9052e814b..1c1dfbc80 100644 --- a/pipewire/server/node.c +++ b/pipewire/server/node.c @@ -46,8 +46,8 @@ update_port_ids (struct pw_node *node) uint32_t *input_port_ids, *output_port_ids; uint32_t n_input_ports, n_output_ports, max_input_ports, max_output_ports; uint32_t i; - SpaList *ports; - SpaResult res; + struct spa_list *ports; + int res; if (node->node == NULL) return; @@ -158,10 +158,10 @@ update_port_ids (struct pw_node *node) pw_signal_emit (&node->initialized, node); } -static SpaResult +static int pause_node (struct pw_node *this) { - SpaResult res; + int res; if (this->state <= PW_NODE_STATE_IDLE) return SPA_RESULT_OK; @@ -175,10 +175,10 @@ pause_node (struct pw_node *this) return res; } -static SpaResult +static int start_node (struct pw_node *this) { - SpaResult res; + int res; pw_log_debug ("node %p: start node", this); @@ -189,10 +189,10 @@ start_node (struct pw_node *this) return res; } -static SpaResult +static int suspend_node (struct pw_node *this) { - SpaResult res = SPA_RESULT_OK; + int res = SPA_RESULT_OK; struct pw_port *p; pw_log_debug ("node %p: suspend node", this); @@ -224,8 +224,8 @@ suspend_node (struct pw_node *this) static void send_clock_update (struct pw_node *this) { - SpaResult res; - SpaCommandNodeClockUpdate cu = + int res; + struct spa_command_node_clock_update cu = SPA_COMMAND_NODE_CLOCK_UPDATE_INIT( this->core->type.command_node.ClockUpdate, SPA_COMMAND_NODE_CLOCK_UPDATE_TIME | @@ -249,22 +249,22 @@ send_clock_update (struct pw_node *this) &cu.body.monotonic_time.value); } - if ((res = spa_node_send_command (this->node, (SpaCommand *)&cu)) < 0) + if ((res = spa_node_send_command (this->node, (struct spa_command *)&cu)) < 0) pw_log_debug ("got error %d", res); } -static SpaResult +static int do_pull (struct pw_node *this) { - SpaResult res = SPA_RESULT_OK; + int res = SPA_RESULT_OK; struct pw_port *inport; bool have_output = false; spa_list_for_each (inport, &this->input_ports, link) { struct pw_link *link; struct pw_port *outport; - SpaPortIO *pi; - SpaPortIO *po; + struct spa_port_io *pi; + struct spa_port_io *po; pi = &inport->io; pw_log_trace ("node %p: need input port %d, %d %d", this, @@ -311,13 +311,13 @@ do_pull (struct pw_node *this) } static void -on_node_event (SpaNode *node, SpaEvent *event, void *user_data) +on_node_event (struct spa_node *node, struct spa_event *event, void *user_data) { struct pw_node *this = user_data; struct impl *impl = SPA_CONTAINER_OF (this, struct impl, this); if (SPA_EVENT_TYPE (event) == this->core->type.event_node.AsyncComplete) { - SpaEventNodeAsyncComplete *ac = (SpaEventNodeAsyncComplete *) event; + struct spa_event_node_async_complete *ac = (struct spa_event_node_async_complete *) event; pw_log_debug ("node %p: async complete event %d %d", this, ac->body.seq.value, ac->body.res.value); pw_work_queue_complete (impl->work, this, ac->body.seq.value, ac->body.res.value); @@ -329,7 +329,7 @@ on_node_event (SpaNode *node, SpaEvent *event, void *user_data) } static void -on_node_need_input (SpaNode *node, void *user_data) +on_node_need_input (struct spa_node *node, void *user_data) { struct pw_node *this = user_data; @@ -337,15 +337,15 @@ on_node_need_input (SpaNode *node, void *user_data) } static void -on_node_have_output (SpaNode *node, void *user_data) +on_node_have_output (struct spa_node *node, void *user_data) { struct pw_node *this = user_data; - SpaResult res; + int res; struct pw_port *outport; spa_list_for_each (outport, &this->output_ports, link) { struct pw_link *link; - SpaPortIO *po; + struct spa_port_io *po; po = &outport->io; if (po->buffer_id == SPA_ID_INVALID) @@ -374,7 +374,7 @@ on_node_have_output (SpaNode *node, void *user_data) } static void -on_node_reuse_buffer (SpaNode *node, uint32_t port_id, uint32_t buffer_id, void *user_data) +on_node_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data) { struct pw_node *this = user_data; struct pw_port *inport; @@ -402,7 +402,7 @@ node_unbind_func (void *data) spa_list_remove (&resource->link); } -static SpaResult +static int node_bind_func (struct pw_global *global, struct pw_client *client, uint32_t version, @@ -432,7 +432,7 @@ node_bind_func (struct pw_global *global, info.n_inputs = this->n_input_ports; info.input_formats = NULL; for (info.n_input_formats = 0; ; info.n_input_formats++) { - SpaFormat *fmt; + struct spa_format *fmt; if (spa_node_port_enum_formats (this->node, SPA_DIRECTION_INPUT, @@ -442,14 +442,14 @@ node_bind_func (struct pw_global *global, info.n_input_formats) < 0) break; - info.input_formats = realloc (info.input_formats, sizeof (SpaFormat*) * (info.n_input_formats + 1)); + info.input_formats = realloc (info.input_formats, sizeof (struct spa_format*) * (info.n_input_formats + 1)); info.input_formats[info.n_input_formats] = spa_format_copy (fmt); } info.max_outputs = this->max_output_ports; info.n_outputs = this->n_output_ports; info.output_formats = NULL; for (info.n_output_formats = 0; ; info.n_output_formats++) { - SpaFormat *fmt; + struct spa_format *fmt; if (spa_node_port_enum_formats (this->node, SPA_DIRECTION_OUTPUT, @@ -459,7 +459,7 @@ node_bind_func (struct pw_global *global, info.n_output_formats) < 0) break; - info.output_formats = realloc (info.output_formats, sizeof (SpaFormat*) * (info.n_output_formats + 1)); + info.output_formats = realloc (info.output_formats, sizeof (struct spa_format*) * (info.n_output_formats + 1)); info.output_formats[info.n_output_formats] = spa_format_copy (fmt); } info.state = this->state; @@ -520,7 +520,7 @@ pw_node_set_data_loop (struct pw_node *node, pw_signal_emit (&node->loop_changed, node); } -static const SpaNodeCallbacks node_callbacks = { +static const struct spa_node_callbacks node_callbacks = { &on_node_event, &on_node_need_input, &on_node_have_output, @@ -532,8 +532,8 @@ pw_node_new (struct pw_core *core, struct pw_client *owner, const char *name, bool async, - SpaNode *node, - SpaClock *clock, + struct spa_node *node, + struct spa_clock *clock, struct pw_properties *properties) { struct impl *impl; @@ -611,13 +611,13 @@ no_mem: return NULL; } -static SpaResult -do_node_remove_done (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_node_remove_done (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { struct pw_node *this = user_data; struct impl *impl = SPA_CONTAINER_OF (this, struct impl, this); @@ -649,17 +649,17 @@ do_node_remove_done (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -do_node_remove (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_node_remove (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { struct pw_node *this = user_data; struct pw_port *port, *tmp; - SpaResult res; + int res; pause_node (this); @@ -736,9 +736,9 @@ pw_node_get_free_port (struct pw_node *node, enum pw_direction direction) { uint32_t *n_ports, max_ports; - SpaList *ports; + struct spa_list *ports; struct pw_port *port = NULL, *p, **portmap; - SpaResult res; + int res; int i; if (direction == PW_DIRECTION_INPUT) { @@ -793,7 +793,7 @@ pw_node_get_free_port (struct pw_node *node, static void on_state_complete (struct pw_node *node, void *data, - SpaResult res) + int res) { enum pw_node_state state = SPA_PTR_TO_INT (data); char *error = NULL; @@ -829,13 +829,13 @@ node_activate (struct pw_node *this) * * Set the state of @node to @state. * - * Returns: a #SpaResult + * Returns: a #int */ -SpaResult +int pw_node_set_state (struct pw_node *node, enum pw_node_state state) { - SpaResult res = SPA_RESULT_OK; + int res = SPA_RESULT_OK; struct impl *impl = SPA_CONTAINER_OF (node, struct impl, this); pw_signal_emit (&node->state_request, node, state); diff --git a/pipewire/server/node.h b/pipewire/server/node.h index 663891e97..61e737cce 100644 --- a/pipewire/server/node.h +++ b/pipewire/server/node.h @@ -46,7 +46,7 @@ extern "C" { */ struct pw_node { struct pw_core *core; - SpaList link; + struct spa_list link; struct pw_global *global; struct pw_client *owner; @@ -62,25 +62,25 @@ struct pw_node { enum pw_node_state old, enum pw_node_state state)); - SpaHandle *handle; - SpaNode *node; + struct spa_handle *handle; + struct spa_node *node; bool live; - SpaClock *clock; + struct spa_clock *clock; - SpaList resource_list; + struct spa_list resource_list; PW_SIGNAL (initialized, (struct pw_listener *listener, struct pw_node *object)); uint32_t max_input_ports; uint32_t n_input_ports; - SpaList input_ports; + struct spa_list input_ports; struct pw_port **input_port_map; uint32_t n_used_input_links; uint32_t max_output_ports; uint32_t n_output_ports; - SpaList output_ports; + struct spa_list output_ports; struct pw_port **output_port_map; uint32_t n_used_output_links; @@ -99,7 +99,7 @@ struct pw_node { PW_SIGNAL (async_complete, (struct pw_listener *listener, struct pw_node *node, uint32_t seq, - SpaResult res)); + int res)); struct pw_data_loop *data_loop; PW_SIGNAL (loop_changed, (struct pw_listener *listener, @@ -110,8 +110,8 @@ struct pw_node * pw_node_new (struct pw_core *core, struct pw_client *owner, const char *name, bool async, - SpaNode *node, - SpaClock *clock, + struct spa_node *node, + struct spa_clock *clock, struct pw_properties *properties); void pw_node_destroy (struct pw_node *node); @@ -122,7 +122,7 @@ void pw_node_set_data_loop (struct pw_node *node, struct pw_port * pw_node_get_free_port (struct pw_node *node, enum pw_direction direction); -SpaResult pw_node_set_state (struct pw_node *node, +int pw_node_set_state (struct pw_node *node, enum pw_node_state state); void pw_node_update_state (struct pw_node *node, enum pw_node_state state, diff --git a/pipewire/server/port.c b/pipewire/server/port.c index 03e8e2c80..82113132c 100644 --- a/pipewire/server/port.c +++ b/pipewire/server/port.c @@ -71,8 +71,8 @@ pw_port_destroy (struct pw_port *port) free (port); } -static SpaResult -do_add_link (SpaLoop *loop, +static int +do_add_link (struct spa_loop *loop, bool async, uint32_t seq, size_t size, @@ -130,7 +130,7 @@ pw_port_get_link (struct pw_port *output_port, struct pw_link * pw_port_link (struct pw_port *output_port, struct pw_port *input_port, - SpaFormat **format_filter, + struct spa_format **format_filter, struct pw_properties *properties, char **error) { @@ -199,10 +199,10 @@ no_mem: return NULL; } -SpaResult +int pw_port_pause_rt (struct pw_port *port) { - SpaResult res; + int res; if (port->state <= PW_PORT_STATE_PAUSED) return SPA_RESULT_OK; @@ -216,13 +216,13 @@ pw_port_pause_rt (struct pw_port *port) return res; } -static SpaResult -do_remove_link_done (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_remove_link_done (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { struct pw_port *port = user_data; struct pw_node *node = port->node; @@ -263,18 +263,18 @@ do_remove_link_done (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -do_remove_link (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_remove_link (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { struct pw_port *port = user_data; struct pw_node *this = port->node; struct pw_link *link = ((struct pw_link**)data)[0]; - SpaResult res; + int res; if (port->direction == PW_DIRECTION_INPUT) { pw_port_pause_rt (link->rt.input); @@ -295,10 +295,10 @@ do_remove_link (SpaLoop *loop, return res; } -SpaResult +int pw_port_unlink (struct pw_port *port, struct pw_link *link) { - SpaResult res; + int res; struct impl *impl = SPA_CONTAINER_OF (port, struct impl, this); pw_log_debug ("port %p: start unlink %p", port, link); @@ -312,16 +312,16 @@ pw_port_unlink (struct pw_port *port, struct pw_link *link) return res; } -static SpaResult -do_clear_buffers_done (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_clear_buffers_done (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { struct pw_port *port = user_data; - SpaResult res; + int res; if (port->state <= PW_PORT_STATE_READY) return SPA_RESULT_OK; @@ -339,17 +339,17 @@ do_clear_buffers_done (SpaLoop *loop, return res; } -static SpaResult -do_clear_buffers (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_clear_buffers (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { struct pw_port *port = user_data; struct pw_node *node = port->node; - SpaResult res; + int res; pw_port_pause_rt (port); @@ -361,10 +361,10 @@ do_clear_buffers (SpaLoop *loop, return res; } -SpaResult +int pw_port_clear_buffers (struct pw_port *port) { - SpaResult res; + int res; struct impl *impl = SPA_CONTAINER_OF (port, struct impl, this); pw_log_debug ("port %p: clear buffers", port); diff --git a/pipewire/server/port.h b/pipewire/server/port.h index 17b5365a5..a701b6d62 100644 --- a/pipewire/server/port.h +++ b/pipewire/server/port.h @@ -45,7 +45,7 @@ enum pw_port_state { }; struct pw_port { - SpaList link; + struct spa_list link; PW_SIGNAL (destroy_signal, (struct pw_listener *listener, struct pw_port *)); @@ -53,17 +53,17 @@ struct pw_port { enum pw_direction direction; uint32_t port_id; enum pw_port_state state; - SpaPortIO io; + struct spa_port_io io; bool allocated; struct pw_memblock buffer_mem; - SpaBuffer **buffers; + struct spa_buffer **buffers; uint32_t n_buffers; - SpaList links; + struct spa_list links; struct { - SpaList links; + struct spa_list links; } rt; }; @@ -75,14 +75,14 @@ void pw_port_destroy (struct pw_port *port struct pw_link * pw_port_link (struct pw_port *output_port, struct pw_port *input_port, - SpaFormat **format_filter, + struct spa_format **format_filter, struct pw_properties *properties, char **error); -SpaResult pw_port_unlink (struct pw_port *port, +int pw_port_unlink (struct pw_port *port, struct pw_link *link); -SpaResult pw_port_pause_rt (struct pw_port *port); -SpaResult pw_port_clear_buffers (struct pw_port *port); +int pw_port_pause_rt (struct pw_port *port); +int pw_port_clear_buffers (struct pw_port *port); #ifdef __cplusplus diff --git a/pipewire/server/protocol-native.c b/pipewire/server/protocol-native.c index 14a04669c..1d5de6b55 100644 --- a/pipewire/server/protocol-native.c +++ b/pipewire/server/protocol-native.c @@ -27,12 +27,12 @@ typedef bool (*demarshal_func_t) (void *object, void *data, size_t size); struct builder { - SpaPODBuilder b; + struct spa_pod_builder b; struct pw_connection *connection; }; static uint32_t -write_pod (SpaPODBuilder *b, uint32_t ref, const void *data, uint32_t size) +write_pod (struct spa_pod_builder *b, uint32_t ref, const void *data, uint32_t size) { if (ref == -1) ref = b->offset; @@ -75,7 +75,7 @@ core_marshal_info (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; uint32_t i, n_items; core_update_map (resource->client); @@ -111,7 +111,7 @@ core_marshal_done (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -124,14 +124,14 @@ core_marshal_done (void *object, static void core_marshal_error (void *object, uint32_t id, - SpaResult res, + int res, const char *error, ...) { struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; char buffer[128]; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; va_list ap; core_update_map (resource->client); @@ -155,7 +155,7 @@ core_marshal_remove_id (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -174,7 +174,7 @@ core_marshal_update_types (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; uint32_t i; spa_pod_builder_add (&b.b, @@ -198,8 +198,8 @@ core_demarshal_client_update (void *object, size_t size) { struct pw_resource *resource = object; - SpaDict props; - SpaPODIter it; + struct spa_dict props; + struct spa_pod_iter it; uint32_t i; if (!spa_pod_iter_struct (&it, data, size) || @@ -208,7 +208,7 @@ core_demarshal_client_update (void *object, 0)) return false; - props.items = alloca (props.n_items * sizeof (SpaDictItem)); + props.items = alloca (props.n_items * sizeof (struct spa_dict_item)); for (i = 0; i < props.n_items; i++) { if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &props.items[i].key, @@ -226,7 +226,7 @@ core_demarshal_sync (void *object, size_t size) { struct pw_resource *resource = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t seq; if (!spa_pod_iter_struct (&it, data, size) || @@ -245,7 +245,7 @@ core_demarshal_get_registry (void *object, size_t size) { struct pw_resource *resource = object; - SpaPODIter it; + struct spa_pod_iter it; int32_t new_id; if (!spa_pod_iter_struct (&it, data, size) || @@ -264,10 +264,10 @@ core_demarshal_create_node (void *object, size_t size) { struct pw_resource *resource = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t new_id, i; const char *factory_name, *name; - SpaDict props; + struct spa_dict props; if (!spa_pod_iter_struct (&it, data, size) || !spa_pod_iter_get (&it, @@ -277,7 +277,7 @@ core_demarshal_create_node (void *object, 0)) return false; - props.items = alloca (props.n_items * sizeof (SpaDictItem)); + props.items = alloca (props.n_items * sizeof (struct spa_dict_item)); for (i = 0; i < props.n_items; i++) { if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &props.items[i].key, @@ -302,10 +302,10 @@ core_demarshal_create_client_node (void *object, size_t size) { struct pw_resource *resource = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t new_id, i; const char *name; - SpaDict props; + struct spa_dict props; if (!spa_pod_iter_struct (&it, data, size) || !spa_pod_iter_get (&it, @@ -314,7 +314,7 @@ core_demarshal_create_client_node (void *object, 0)) return false; - props.items = alloca (props.n_items * sizeof (SpaDictItem)); + props.items = alloca (props.n_items * sizeof (struct spa_dict_item)); for (i = 0; i < props.n_items; i++) { if (!spa_pod_iter_get (&it, SPA_POD_TYPE_STRING, &props.items[i].key, @@ -338,7 +338,7 @@ core_demarshal_update_types (void *object, size_t size) { struct pw_resource *resource = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t first_id, n_types; const char **types; int i; @@ -367,7 +367,7 @@ registry_marshal_global (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -385,7 +385,7 @@ registry_marshal_global_remove (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -401,7 +401,7 @@ registry_demarshal_bind (void *object, size_t size) { struct pw_resource *resource = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t id, new_id; if (!spa_pod_iter_struct (&it, data, size) || @@ -422,7 +422,7 @@ module_marshal_info (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; uint32_t i, n_items; core_update_map (resource->client); @@ -456,7 +456,7 @@ node_marshal_info (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; uint32_t i, n_items; core_update_map (resource->client); @@ -505,7 +505,7 @@ client_marshal_info (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; uint32_t i, n_items; core_update_map (resource->client); @@ -536,7 +536,7 @@ client_node_marshal_done (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -549,12 +549,12 @@ client_node_marshal_done (void *object, static void client_node_marshal_event (void *object, - const SpaEvent *event) + const struct spa_event *event) { struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -567,13 +567,13 @@ client_node_marshal_event (void *object, static void client_node_marshal_add_port (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id) { struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -588,13 +588,13 @@ client_node_marshal_add_port (void *object, static void client_node_marshal_remove_port (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id) { struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -609,15 +609,15 @@ client_node_marshal_remove_port (void *object, static void client_node_marshal_set_format (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -641,7 +641,7 @@ client_node_marshal_set_property (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -655,7 +655,7 @@ client_node_marshal_set_property (void *object, static void client_node_marshal_add_mem (void *object, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t mem_id, uint32_t type, @@ -667,7 +667,7 @@ client_node_marshal_add_mem (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -687,7 +687,7 @@ client_node_marshal_add_mem (void *object, static void client_node_marshal_use_buffers (void *object, uint32_t seq, - SpaDirection direction, + enum spa_direction direction, uint32_t port_id, uint32_t n_buffers, struct pw_client_node_buffer *buffers) @@ -695,7 +695,7 @@ client_node_marshal_use_buffers (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; uint32_t i, j; core_update_map (resource->client); @@ -708,7 +708,7 @@ client_node_marshal_use_buffers (void *object, SPA_POD_TYPE_INT, n_buffers, 0); for (i = 0; i < n_buffers; i++) { - SpaBuffer *buf = buffers[i].buffer; + struct spa_buffer *buf = buffers[i].buffer; spa_pod_builder_add (&b.b, SPA_POD_TYPE_INT, buffers[i].mem_id, @@ -718,14 +718,14 @@ client_node_marshal_use_buffers (void *object, SPA_POD_TYPE_INT, buf->n_metas, 0); for (j = 0; j < buf->n_metas; j++) { - SpaMeta *m = &buf->metas[j]; + struct spa_meta *m = &buf->metas[j]; spa_pod_builder_add (&b.b, SPA_POD_TYPE_ID, m->type, SPA_POD_TYPE_INT, m->size, 0); } spa_pod_builder_add (&b.b, SPA_POD_TYPE_INT, buf->n_datas, 0); for (j = 0; j < buf->n_datas; j++) { - SpaData *d = &buf->datas[j]; + struct spa_data *d = &buf->datas[j]; spa_pod_builder_add (&b.b, SPA_POD_TYPE_ID, d->type, SPA_POD_TYPE_INT, SPA_PTR_TO_UINT32 (d->data), @@ -742,12 +742,12 @@ client_node_marshal_use_buffers (void *object, static void client_node_marshal_node_command (void *object, uint32_t seq, - const SpaCommand *command) + const struct spa_command *command) { struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -761,12 +761,12 @@ client_node_marshal_node_command (void *object, static void client_node_marshal_port_command (void *object, uint32_t port_id, - const SpaCommand *command) + const struct spa_command *command) { struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -786,7 +786,7 @@ client_node_marshal_transport (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); @@ -804,9 +804,9 @@ client_node_demarshal_update (void *object, size_t size) { struct pw_resource *resource = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t change_mask, max_input_ports, max_output_ports; - const SpaProps *props; + const struct spa_props *props; if (!spa_pod_iter_struct (&it, data, size) || !pw_pod_remap_data (SPA_POD_TYPE_STRUCT, data, size, &resource->client->types) || @@ -828,12 +828,12 @@ client_node_demarshal_port_update (void *object, size_t size) { struct pw_resource *resource = object; - SpaPODIter it; + struct spa_pod_iter it; uint32_t i, direction, port_id, change_mask, n_possible_formats, n_params; - const SpaParam **params = NULL; - const SpaFormat **possible_formats = NULL, *format = NULL; - SpaPortInfo info, *infop = NULL; - SpaPOD *ipod; + const struct spa_param **params = NULL; + const struct spa_format **possible_formats = NULL, *format = NULL; + struct spa_port_info info, *infop = NULL; + struct spa_pod *ipod; if (!spa_pod_iter_struct (&it, data, size) || !pw_pod_remap_data (SPA_POD_TYPE_STRUCT, data, size, &resource->client->types) || @@ -845,7 +845,7 @@ client_node_demarshal_port_update (void *object, 0)) return false; - possible_formats = alloca (n_possible_formats * sizeof (SpaFormat*)); + possible_formats = alloca (n_possible_formats * sizeof (struct spa_format*)); for (i = 0; i < n_possible_formats; i++) if (!spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &possible_formats[i], 0)) return false; @@ -856,7 +856,7 @@ client_node_demarshal_port_update (void *object, 0)) return false; - params = alloca (n_params * sizeof (SpaParam*)); + params = alloca (n_params * sizeof (struct spa_param*)); for (i = 0; i < n_params; i++) if (!spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, ¶ms[i], 0)) return false; @@ -867,7 +867,7 @@ client_node_demarshal_port_update (void *object, return false; if (ipod) { - SpaPODIter it2; + struct spa_pod_iter it2; infop = &info; if (!spa_pod_iter_pod (&it2, ipod) || @@ -897,8 +897,8 @@ client_node_demarshal_event (void *object, size_t size) { struct pw_resource *resource = object; - SpaPODIter it; - SpaEvent *event; + struct spa_pod_iter it; + struct spa_event *event; if (!spa_pod_iter_struct (&it, data, size) || !pw_pod_remap_data (SPA_POD_TYPE_STRUCT, data, size, &resource->client->types) || @@ -915,7 +915,7 @@ client_node_demarshal_destroy (void *object, size_t size) { struct pw_resource *resource = object; - SpaPODIter it; + struct spa_pod_iter it; if (!spa_pod_iter_struct (&it, data, size)) return false; @@ -931,7 +931,7 @@ link_marshal_info (void *object, struct pw_resource *resource = object; struct pw_connection *connection = resource->client->protocol_private; struct builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; - SpaPODFrame f; + struct spa_pod_frame f; core_update_map (resource->client); diff --git a/pipewire/server/resource.h b/pipewire/server/resource.h index 05e0a592f..7b27b89d0 100644 --- a/pipewire/server/resource.h +++ b/pipewire/server/resource.h @@ -36,7 +36,7 @@ typedef void (*pw_destroy_t) (void *object); struct pw_resource { struct pw_core *core; - SpaList link; + struct spa_list link; struct pw_client *client; diff --git a/pipewire/server/work-queue.c b/pipewire/server/work-queue.c index 8fac03227..de78715ea 100644 --- a/pipewire/server/work-queue.c +++ b/pipewire/server/work-queue.c @@ -27,28 +27,28 @@ struct work_item { uint32_t id; void *obj; uint32_t seq; - SpaResult res; + int res; pw_work_func_t func; void *data; - SpaList link; + struct spa_list link; }; struct impl { struct pw_work_queue this; - SpaSource *wakeup; + struct spa_source *wakeup; uint32_t counter; - SpaList work_list; - SpaList free_list; - int n_queued; + struct spa_list work_list; + struct spa_list free_list; + int n_queued; }; static void -process_work_queue (SpaLoopUtils *utils, - SpaSource *source, - void *data) +process_work_queue (struct spa_loop_utils *utils, + struct spa_source *source, + void *data) { struct impl *impl = data; struct pw_work_queue *this = &impl->this; @@ -135,7 +135,7 @@ pw_work_queue_destroy (struct pw_work_queue * queue) uint32_t pw_work_queue_add (struct pw_work_queue *queue, void *obj, - SpaResult res, + int res, pw_work_func_t func, void *data) { @@ -205,7 +205,7 @@ bool pw_work_queue_complete (struct pw_work_queue *queue, void *obj, uint32_t seq, - SpaResult res) + int res) { struct work_item *item; struct impl *impl = SPA_CONTAINER_OF (queue, struct impl, this); diff --git a/pipewire/server/work-queue.h b/pipewire/server/work-queue.h index d8e84c490..a635a1084 100644 --- a/pipewire/server/work-queue.h +++ b/pipewire/server/work-queue.h @@ -28,7 +28,7 @@ extern "C" { typedef void (*pw_work_func_t) (void *obj, void *data, - SpaResult res, + int res, uint32_t id); /** @@ -48,7 +48,7 @@ void pw_work_queue_destroy (struct pw_work_queue *que uint32_t pw_work_queue_add (struct pw_work_queue *queue, void *obj, - SpaResult res, + int res, pw_work_func_t func, void *data); void pw_work_queue_cancel (struct pw_work_queue *queue, @@ -57,7 +57,7 @@ void pw_work_queue_cancel (struct pw_work_queue *que bool pw_work_queue_complete (struct pw_work_queue *queue, void *obj, uint32_t seq, - SpaResult res); + int res); #ifdef __cplusplus } diff --git a/pipewire/tools/pipewire-monitor.c b/pipewire/tools/pipewire-monitor.c index 98cf4b9a3..c4f8cea0b 100644 --- a/pipewire/tools/pipewire-monitor.c +++ b/pipewire/tools/pipewire-monitor.c @@ -33,9 +33,9 @@ struct data { }; static void -print_properties (SpaDict *props, char mark) +print_properties (struct spa_dict *props, char mark) { - SpaDictItem *item; + struct spa_dict_item *item; if (props == NULL) return; @@ -55,7 +55,7 @@ struct dumpdata { static void dump_core_info (struct pw_context *c, - SpaResult res, + int res, const struct pw_core_info *info, void *user_data) { @@ -78,7 +78,7 @@ dump_core_info (struct pw_context *c, static void dump_client_info (struct pw_context *c, - SpaResult res, + int res, const struct pw_client_info *info, void *user_data) { @@ -96,7 +96,7 @@ dump_client_info (struct pw_context *c, static void dump_node_info (struct pw_context *c, - SpaResult res, + int res, const struct pw_node_info *info, void *user_data) { @@ -135,7 +135,7 @@ dump_node_info (struct pw_context *c, static void dump_module_info (struct pw_context *c, - SpaResult res, + int res, const struct pw_module_info *info, void *user_data) { @@ -159,7 +159,7 @@ dump_module_info (struct pw_context *c, static void dump_link_info (struct pw_context *c, - SpaResult res, + int res, const struct pw_link_info *info, void *user_data) { diff --git a/spa/include/spa/audio/format-utils.h b/spa/include/spa/audio/format-utils.h index 712a83be0..20b798f46 100644 --- a/spa/include/spa/audio/format-utils.h +++ b/spa/include/spa/audio/format-utils.h @@ -28,17 +28,17 @@ extern "C" { #include #include -typedef struct { +struct spa_type_format_audio { uint32_t format; uint32_t flags; uint32_t layout; uint32_t rate; uint32_t channels; uint32_t channel_mask; -} SpaTypeFormatAudio; +}; static inline void -spa_type_format_audio_map (SpaTypeMap *map, SpaTypeFormatAudio *type) +spa_type_format_audio_map (struct spa_type_map *map, struct spa_type_format_audio *type) { if (type->format == 0) { type->format = spa_type_map_get_id (map, SPA_TYPE_FORMAT_AUDIO__format); @@ -51,9 +51,9 @@ spa_type_format_audio_map (SpaTypeMap *map, SpaTypeFormatAudio *type) } static inline bool -spa_format_audio_raw_parse (const SpaFormat *format, - SpaAudioInfoRaw *info, - SpaTypeFormatAudio *type) +spa_format_audio_raw_parse (const struct spa_format *format, + struct spa_audio_info_raw *info, + struct spa_type_format_audio *type) { spa_format_query (format, type->format, SPA_POD_TYPE_ID, &info->format, diff --git a/spa/include/spa/audio/format.h b/spa/include/spa/audio/format.h index 312f18dc9..5bef5c424 100644 --- a/spa/include/spa/audio/format.h +++ b/spa/include/spa/audio/format.h @@ -27,8 +27,6 @@ extern "C" { #include #include -typedef struct _SpaAudioInfo SpaAudioInfo; - #define SPA_TYPE_FORMAT__Audio SPA_TYPE_FORMAT_BASE "Audio" #define SPA_TYPE_FORMAT_AUDIO_BASE SPA_TYPE_FORMAT__Audio ":" @@ -39,11 +37,11 @@ typedef struct _SpaAudioInfo SpaAudioInfo; #define SPA_TYPE_FORMAT_AUDIO__channels SPA_TYPE_FORMAT_AUDIO_BASE "channels" #define SPA_TYPE_FORMAT_AUDIO__channelMask SPA_TYPE_FORMAT_AUDIO_BASE "channel-mask" -struct _SpaAudioInfo { +struct spa_audio_info { uint32_t media_type; uint32_t media_subtype; union { - SpaAudioInfoRaw raw; + struct spa_audio_info_raw raw; } info; }; diff --git a/spa/include/spa/audio/raw-utils.h b/spa/include/spa/audio/raw-utils.h index c1794b63d..097e7e50e 100644 --- a/spa/include/spa/audio/raw-utils.h +++ b/spa/include/spa/audio/raw-utils.h @@ -35,7 +35,7 @@ extern "C" { #define _SPA_TYPE_AUDIO_FORMAT_OE(fmt) SPA_TYPE_AUDIO_FORMAT_BASE fmt "BE" #endif -typedef struct { +struct spa_type_audio_format { uint32_t UNKNOWN; uint32_t ENCODED; uint32_t S8; @@ -68,10 +68,10 @@ typedef struct { uint32_t U18_OE; uint32_t F32_OE; uint32_t F64_OE; -} SpaTypeAudioFormat; +}; static inline void -spa_type_audio_format_map (SpaTypeMap *map, SpaTypeAudioFormat *type) +spa_type_audio_format_map (struct spa_type_map *map, struct spa_type_audio_format *type) { if (type->ENCODED == 0) { type->UNKNOWN = 0; diff --git a/spa/include/spa/audio/raw.h b/spa/include/spa/audio/raw.h index 8baa81586..477bd8652 100644 --- a/spa/include/spa/audio/raw.h +++ b/spa/include/spa/audio/raw.h @@ -24,8 +24,6 @@ extern "C" { #endif -typedef struct _SpaAudioInfoRaw SpaAudioInfoRaw; - #include #define SPA_TYPE__AudioFormat SPA_TYPE_ENUM_BASE "AudioFormat" @@ -65,32 +63,32 @@ typedef struct _SpaAudioInfoRaw SpaAudioInfoRaw; #define SPA_TYPE_AUDIO_FORMAT__F64BE SPA_TYPE_AUDIO_FORMAT_BASE "F64BE" /** - * SpaAudioFlags: + * spa_audio_flags: * @SPA_AUDIO_FLAG_NONE: no valid flag * @SPA_AUDIO_FLAG_UNPOSITIONED: the position array explicitly * contains unpositioned channels. * * Extra audio flags */ -typedef enum { +enum spa_audio_flags { SPA_AUDIO_FLAG_NONE = 0, SPA_AUDIO_FLAG_UNPOSITIONED = (1 << 0) -} SpaAudioFlags; +}; /** - * SpaAudioLayout: + * spa_audio_layout: * @SPA_AUDIO_LAYOUT_INTERLEAVED: interleaved audio * @SPA_AUDIO_LAYOUT_NON_INTERLEAVED: non-interleaved audio * * Layout of the audio samples for the different channels. */ -typedef enum { +enum spa_audio_layout { SPA_AUDIO_LAYOUT_INTERLEAVED = 0, SPA_AUDIO_LAYOUT_NON_INTERLEAVED -} SpaAudioLayout; +}; /** - * SpaAudioInfoRaw: + * spa_audio_info_raw: * @format: the format * @flags: extra flags * @layout: the sample layout @@ -98,13 +96,13 @@ typedef enum { * @channels: the number of channels * @channel_mask: the channel mask */ -struct _SpaAudioInfoRaw { - uint32_t format; - SpaAudioFlags flags; - SpaAudioLayout layout; - uint32_t rate; - uint32_t channels; - uint32_t channel_mask; +struct spa_audio_info_raw { + uint32_t format; + enum spa_audio_flags flags; + enum spa_audio_layout layout; + uint32_t rate; + uint32_t channels; + uint32_t channel_mask; }; #ifdef __cplusplus diff --git a/spa/include/spa/buffer.h b/spa/include/spa/buffer.h index 49fce48a1..81c063b9a 100644 --- a/spa/include/spa/buffer.h +++ b/spa/include/spa/buffer.h @@ -24,8 +24,6 @@ extern "C" { #endif -typedef struct _SpaBuffer SpaBuffer; - #include #include #include @@ -41,15 +39,15 @@ typedef struct _SpaBuffer SpaBuffer; #define SPA_TYPE_DATA__DmaBuf SPA_TYPE_DATA_BASE "DmaBuf" #define SPA_TYPE_DATA__Id SPA_TYPE_DATA_BASE "Id" -typedef struct { +struct spa_type_data { uint32_t MemPtr; uint32_t MemFd; uint32_t DmaBuf; uint32_t Id; -} SpaTypeData; +}; static inline void -spa_type_data_map (SpaTypeMap *map, SpaTypeData *type) +spa_type_data_map (struct spa_type_map *map, struct spa_type_data *type) { if (type->MemPtr == 0) { type->MemPtr = spa_type_map_get_id (map, SPA_TYPE_DATA__MemPtr); @@ -60,19 +58,19 @@ spa_type_data_map (SpaTypeMap *map, SpaTypeData *type) } /** - * SpaChunk: + * spa_chunk: * @offset: offset of valid data * @size: size of valid data * @stride: stride of data if applicable */ -typedef struct { +struct spa_chunk { uint32_t offset; uint32_t size; int32_t stride; -} SpaChunk; +}; /** - * SpaData: + * spa_data: * @type: memory type * @flags: memory flags * @fd: file descriptor @@ -81,34 +79,34 @@ typedef struct { * @data: pointer to memory * @chunk: pointer to chunk with valid offset */ -typedef struct { - uint32_t type; - uint32_t flags; - int fd; - uint32_t mapoffset; - uint32_t maxsize; - void *data; - SpaChunk *chunk; -} SpaData; +struct spa_data { + uint32_t type; + uint32_t flags; + int fd; + uint32_t mapoffset; + uint32_t maxsize; + void *data; + struct spa_chunk *chunk; +}; /** - * SpaBuffer: + * spa_buffer: * @id: buffer id * @n_metas: number of metadata * @metas: offset of array of @n_metas metadata * @n_datas: number of data pointers * @datas: offset of array of @n_datas data pointers */ -struct _SpaBuffer { - uint32_t id; - uint32_t n_metas; - SpaMeta *metas; - uint32_t n_datas; - SpaData *datas; +struct spa_buffer { + uint32_t id; + uint32_t n_metas; + struct spa_meta *metas; + uint32_t n_datas; + struct spa_data *datas; }; static inline void * -spa_buffer_find_meta (SpaBuffer *b, uint32_t type) +spa_buffer_find_meta (struct spa_buffer *b, uint32_t type) { uint32_t i; diff --git a/spa/include/spa/clock.h b/spa/include/spa/clock.h index e39d7da11..2c24162c5 100644 --- a/spa/include/spa/clock.h +++ b/spa/include/spa/clock.h @@ -24,76 +24,74 @@ extern "C" { #endif -typedef struct _SpaClock SpaClock; - #define SPA_TYPE__Clock SPA_TYPE_INTERFACE_BASE "Clock" #define SPA_TYPE_CLOCK_BASE SPA_TYPE__Clock ":" /** - * SpaClockState: + * spa_clock_state: * @SPA_CLOCK_STATE_STOPPED: the clock is stopped * @SPA_CLOCK_STATE_PAUSED: the clock is paused * @SPA_CLOCK_STATE_RUNNING: the clock is running */ -typedef enum { +enum spa_clock_state { SPA_CLOCK_STATE_STOPPED, SPA_CLOCK_STATE_PAUSED, SPA_CLOCK_STATE_RUNNING, -} SpaClockState; +}; #include #include #include /** - * SpaClock: + * spa_clock: * * A time provider. */ -struct _SpaClock { +struct spa_clock { /* the total size of this clock. This can be used to expand this * structure in the future */ size_t size; /** - * SpaClock::info + * spa_clock::info * * Extra information about the clock */ - const SpaDict *info; + const struct spa_dict *info; /** - * SpaClock::state: + * spa_clock::state: * * The current state of the clock */ - SpaClockState state; + enum spa_clock_state state; /** - * SpaClock::get_props: - * @clock: a #SpaClock - * @props: a location for a #SpaProps pointer + * spa_clock::get_props: + * @clock: a #spa_clock + * @props: a location for a #struct spa_props pointer * * Get the configurable properties of @clock. * * The returned @props is a snapshot of the current configuration and * can be modified. The modifications will take effect after a call - * to SpaClock::set_props. + * to spa_clock::set_props. * * Returns: #SPA_RESULT_OK on success * #SPA_RESULT_INVALID_ARGUMENTS when clock or props are %NULL * #SPA_RESULT_NOT_IMPLEMENTED when there are no properties * implemented on @clock */ - SpaResult (*get_props) (SpaClock *clock, - SpaProps **props); + int (*get_props) (struct spa_clock *clock, + struct spa_props **props); /** - * SpaClock::set_props: - * @clock: a #SpaClock - * @props: a #SpaProps + * spa_clock::set_props: + * @clock: a #spa_clock + * @props: a #struct spa_props * * Set the configurable properties in @clock. * - * Usually, @props will be obtained from SpaClock::get_props and then - * modified but it is also possible to set another #SpaProps object - * as long as its keys and types match those of SpaProps::get_props. + * Usually, @props will be obtained from spa_clock::get_props and then + * modified but it is also possible to set another #struct spa_props object + * as long as its keys and types match those of struct spa_props::get_props. * * Properties with keys that are not known are ignored. * @@ -106,13 +104,13 @@ struct _SpaClock { * #SPA_RESULT_WRONG_PROPERTY_TYPE when a property has the wrong * type. */ - SpaResult (*set_props) (SpaClock *clock, - const SpaProps *props); + int (*set_props) (struct spa_clock *clock, + const struct spa_props *props); - SpaResult (*get_time) (SpaClock *clock, - int32_t *rate, - int64_t *ticks, - int64_t *monotonic_time); + int (*get_time) (struct spa_clock *clock, + int32_t *rate, + int64_t *ticks, + int64_t *monotonic_time); }; #define spa_clock_get_props(n,...) (n)->get_props((n),__VA_ARGS__) diff --git a/spa/include/spa/command-node.h b/spa/include/spa/command-node.h index d60212e09..202dcb3ab 100644 --- a/spa/include/spa/command-node.h +++ b/spa/include/spa/command-node.h @@ -37,17 +37,17 @@ extern "C" { #define SPA_TYPE_COMMAND_NODE__Marker SPA_TYPE_COMMAND_NODE_BASE "Marker" #define SPA_TYPE_COMMAND_NODE__ClockUpdate SPA_TYPE_COMMAND_NODE_BASE "ClockUpdate" -typedef struct { +struct spa_type_command_node { uint32_t Pause; uint32_t Start; uint32_t Flush; uint32_t Drain; uint32_t Marker; uint32_t ClockUpdate; -} SpaTypeCommandNode; +}; static inline void -spa_type_command_node_map (SpaTypeMap *map, SpaTypeCommandNode *type) +spa_type_command_node_map (struct spa_type_map *map, struct spa_type_command_node *type) { if (type->Pause == 0) { type->Pause = spa_type_map_get_id (map, SPA_TYPE_COMMAND_NODE__Pause); @@ -60,7 +60,7 @@ spa_type_command_node_map (SpaTypeMap *map, SpaTypeCommandNode *type) } /** - * SpaCommandNodeClockUpdate: + * spa_command_node_clock_update: * @change_mask: marks which fields are updated * @rate: the number of @ticks per second * @ticks: the new ticks, when @change_mask = 1<<0 @@ -71,40 +71,40 @@ spa_type_command_node_map (SpaTypeMap *map, SpaTypeCommandNode *type) * @scale: update to the speed stored as Q16.16, @change_mask = 1<<1 * @state: the new clock state, when @change_mask = 1<<2 */ -typedef struct { - SpaPODObjectBody body; +struct spa_command_node_clock_update_body { + struct spa_pod_object_body body; #define SPA_COMMAND_NODE_CLOCK_UPDATE_TIME (1 << 0) #define SPA_COMMAND_NODE_CLOCK_UPDATE_SCALE (1 << 1) #define SPA_COMMAND_NODE_CLOCK_UPDATE_STATE (1 << 2) #define SPA_COMMAND_NODE_CLOCK_UPDATE_LATENCY (1 << 3) - SpaPODInt change_mask SPA_ALIGNED (8); - SpaPODInt rate SPA_ALIGNED (8); - SpaPODLong ticks SPA_ALIGNED (8); - SpaPODLong monotonic_time SPA_ALIGNED (8); - SpaPODLong offset SPA_ALIGNED (8); - SpaPODInt scale SPA_ALIGNED (8); - SpaPODInt state SPA_ALIGNED (8); + struct spa_pod_int change_mask SPA_ALIGNED (8); + struct spa_pod_int rate SPA_ALIGNED (8); + struct spa_pod_long ticks SPA_ALIGNED (8); + struct spa_pod_long monotonic_time SPA_ALIGNED (8); + struct spa_pod_long offset SPA_ALIGNED (8); + struct spa_pod_int scale SPA_ALIGNED (8); + struct spa_pod_int state SPA_ALIGNED (8); #define SPA_COMMAND_NODE_CLOCK_UPDATE_FLAG_LIVE (1 << 0) - SpaPODInt flags SPA_ALIGNED (8); - SpaPODLong latency SPA_ALIGNED (8); -} SpaCommandNodeClockUpdateBody; + struct spa_pod_int flags SPA_ALIGNED (8); + struct spa_pod_long latency SPA_ALIGNED (8); +}; -typedef struct { - SpaPOD pod; - SpaCommandNodeClockUpdateBody body; -} SpaCommandNodeClockUpdate; +struct spa_command_node_clock_update { + struct spa_pod pod; + struct spa_command_node_clock_update_body body; +}; #define SPA_COMMAND_NODE_CLOCK_UPDATE_INIT(type,change_mask,rate,ticks,monotonic_time,offset,scale,state,flags,latency) \ - SPA_COMMAND_INIT_COMPLEX (SpaCommandNodeClockUpdate, \ - sizeof (SpaCommandNodeClockUpdateBody), type, \ - SPA_POD_INT_INIT (change_mask), \ - SPA_POD_INT_INIT (rate), \ - SPA_POD_LONG_INIT (ticks), \ - SPA_POD_LONG_INIT (monotonic_time), \ - SPA_POD_LONG_INIT (offset), \ - SPA_POD_INT_INIT (scale), \ - SPA_POD_INT_INIT (state), \ - SPA_POD_INT_INIT (flags), \ + SPA_COMMAND_INIT_COMPLEX (struct spa_command_node_clock_update, \ + sizeof (struct spa_command_node_clock_update_body), type, \ + SPA_POD_INT_INIT (change_mask), \ + SPA_POD_INT_INIT (rate), \ + SPA_POD_LONG_INIT (ticks), \ + SPA_POD_LONG_INIT (monotonic_time), \ + SPA_POD_LONG_INIT (offset), \ + SPA_POD_INT_INIT (scale), \ + SPA_POD_INT_INIT (state), \ + SPA_POD_INT_INIT (flags), \ SPA_POD_LONG_INIT (latency)) #ifdef __cplusplus diff --git a/spa/include/spa/command.h b/spa/include/spa/command.h index aca3caaaa..6595e9cbe 100644 --- a/spa/include/spa/command.h +++ b/spa/include/spa/command.h @@ -24,27 +24,25 @@ extern "C" { #endif -typedef struct _SpaCommand SpaCommand; - #include #include #define SPA_TYPE__Command SPA_TYPE_POD_OBJECT_BASE "Command" #define SPA_TYPE_COMMAND_BASE SPA_TYPE__Command ":" -typedef struct { - SpaPODObjectBody body; -} SpaCommandBody; +struct spa_command_body { + struct spa_pod_object_body body; +}; -struct _SpaCommand { - SpaPOD pod; - SpaCommandBody body; +struct spa_command { + struct spa_pod pod; + struct spa_command_body body; }; #define SPA_COMMAND_TYPE(cmd) ((cmd)->body.body.type) -#define SPA_COMMAND_INIT(type) (SpaCommand) \ - { { sizeof (SpaCommandBody), SPA_POD_TYPE_OBJECT }, \ +#define SPA_COMMAND_INIT(type) (struct spa_command) \ + { { sizeof (struct spa_command_body), SPA_POD_TYPE_OBJECT }, \ { { 0, type } } } \ #define SPA_COMMAND_INIT_COMPLEX(t,size,type,...) (t) \ diff --git a/spa/include/spa/defs.h b/spa/include/spa/defs.h index f050a8224..01b6a41ca 100644 --- a/spa/include/spa/defs.h +++ b/spa/include/spa/defs.h @@ -30,7 +30,7 @@ extern "C" { #include #include -typedef enum { +enum { SPA_RESULT_ASYNC = (1 << 30), SPA_RESULT_WAIT_SYNC = 2, SPA_RESULT_MODIFIED = 1, @@ -71,7 +71,7 @@ typedef enum { SPA_RESULT_SKIPPED = -34, SPA_RESULT_OUT_OF_BUFFERS = -35, SPA_RESULT_INCOMPATIBLE_PROPS = -36, -} SpaResult; +}; #define SPA_ASYNC_MASK (3 << 30) #define SPA_ASYNC_SEQ_MASK (SPA_RESULT_ASYNC - 1) @@ -83,22 +83,20 @@ typedef enum { #define SPA_RESULT_ASYNC_SEQ(res) ((res) & SPA_ASYNC_SEQ_MASK) #define SPA_RESULT_RETURN_ASYNC(seq) (SPA_RESULT_ASYNC | ((seq) & SPA_ASYNC_SEQ_MASK)) -typedef enum { +enum spa_direction { SPA_DIRECTION_INPUT = 0, SPA_DIRECTION_OUTPUT = 1, -} SpaDirection; +}; -typedef struct { +struct spa_rectangle { uint32_t width; uint32_t height; -} SpaRectangle; +}; -typedef struct { +struct spa_fraction { uint32_t num; uint32_t denom; -} SpaFraction; - -typedef void (*SpaNotify) (void *data); +}; #define SPA_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0])) #define SPA_MIN(a,b) ((a)<(b) ? (a) : (b)) diff --git a/spa/include/spa/dict.h b/spa/include/spa/dict.h index 97e5c242c..dad5d4a71 100644 --- a/spa/include/spa/dict.h +++ b/spa/include/spa/dict.h @@ -24,8 +24,6 @@ extern "C" { #endif -typedef struct _SpaDict SpaDict; - #define SPA_TYPE__Dict SPA_TYPE_POINTER_BASE "Dict" #define SPA_TYPE_DICT_BASE SPA_TYPE__Dict ":" @@ -33,14 +31,14 @@ typedef struct _SpaDict SpaDict; #include -typedef struct { +struct spa_dict_item { const char *key; const char *value; -} SpaDictItem; +}; -struct _SpaDict { - uint32_t n_items; - SpaDictItem *items; +struct spa_dict { + uint32_t n_items; + struct spa_dict_item *items; }; #define SPA_DICT_INIT(n_items,items) { n_items, items } @@ -50,10 +48,10 @@ struct _SpaDict { (item) < &(dict)->items[(dict)->n_items]; \ (item)++) -static inline SpaDictItem * -spa_dict_lookup_item (const SpaDict *dict, const char *key) +static inline struct spa_dict_item * +spa_dict_lookup_item (const struct spa_dict *dict, const char *key) { - SpaDictItem *item; + struct spa_dict_item *item; spa_dict_for_each (item, dict) { if (!strcmp (item->key, key)) return item; @@ -62,9 +60,9 @@ spa_dict_lookup_item (const SpaDict *dict, const char *key) } static inline const char * -spa_dict_lookup (const SpaDict *dict, const char *key) +spa_dict_lookup (const struct spa_dict *dict, const char *key) { - SpaDictItem *item = spa_dict_lookup_item (dict, key); + struct spa_dict_item *item = spa_dict_lookup_item (dict, key); return item ? item->value : NULL; } diff --git a/spa/include/spa/event-node.h b/spa/include/spa/event-node.h index 67b145187..e076cb228 100644 --- a/spa/include/spa/event-node.h +++ b/spa/include/spa/event-node.h @@ -38,16 +38,16 @@ extern "C" { #define SPA_TYPE_EVENT_NODE__RequestRefresh SPA_TYPE_EVENT_NODE_BASE "RequestRefresh" #define SPA_TYPE_EVENT_NODE__RequestClockUpdate SPA_TYPE_EVENT_NODE_BASE "RequestClockUpdate" -typedef struct { +struct spa_type_event_node { uint32_t AsyncComplete; uint32_t Error; uint32_t Buffering; uint32_t RequestRefresh; uint32_t RequestClockUpdate; -} SpaTypeEventNode; +}; static inline void -spa_type_event_node_map (SpaTypeMap *map, SpaTypeEventNode *type) +spa_type_event_node_map (struct spa_type_map *map, struct spa_type_event_node *type) { if (type->AsyncComplete == 0) { type->AsyncComplete = spa_type_map_get_id (map, SPA_TYPE_EVENT_NODE__AsyncComplete); @@ -58,43 +58,43 @@ spa_type_event_node_map (SpaTypeMap *map, SpaTypeEventNode *type) } } -typedef struct { - SpaPODObjectBody body; - SpaPODInt seq SPA_ALIGNED (8); - SpaPODInt res SPA_ALIGNED (8); -} SpaEventNodeAsyncCompleteBody; +struct spa_event_node_async_complete_body { + struct spa_pod_object_body body; + struct spa_pod_int seq SPA_ALIGNED (8); + struct spa_pod_int res SPA_ALIGNED (8); +}; -typedef struct { - SpaPOD pod; - SpaEventNodeAsyncCompleteBody body; -} SpaEventNodeAsyncComplete; +struct spa_event_node_async_complete { + struct spa_pod pod; + struct spa_event_node_async_complete_body body; +}; -#define SPA_EVENT_NODE_ASYNC_COMPLETE_INIT(type,seq,res) \ - SPA_EVENT_INIT_COMPLEX (SpaEventNodeAsyncComplete, \ - sizeof (SpaEventNodeAsyncCompleteBody), type, \ - SPA_POD_INT_INIT (seq), \ +#define SPA_EVENT_NODE_ASYNC_COMPLETE_INIT(type,seq,res) \ + SPA_EVENT_INIT_COMPLEX (struct spa_event_node_async_complete, \ + sizeof (struct spa_event_node_async_complete_body), type, \ + SPA_POD_INT_INIT (seq), \ SPA_POD_INT_INIT (res)) -typedef struct { - SpaPODObjectBody body; +struct spa_event_node_request_clock_update_body { + struct spa_pod_object_body body; #define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_TIME (1 << 0) #define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_SCALE (1 << 1) #define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_STATE (1 << 2) - SpaPODInt update_mask SPA_ALIGNED (8); - SpaPODLong timestamp SPA_ALIGNED (8); - SpaPODLong offset SPA_ALIGNED (8); -} SpaEventNodeRequestClockUpdateBody; + struct spa_pod_int update_mask SPA_ALIGNED (8); + struct spa_pod_long timestamp SPA_ALIGNED (8); + struct spa_pod_long offset SPA_ALIGNED (8); +}; -typedef struct { - SpaPOD pod; - SpaEventNodeRequestClockUpdateBody body; -} SpaEventNodeRequestClockUpdate; +struct spa_event_node_request_clock_update { + struct spa_pod pod; + struct spa_event_node_request_clock_update_body body; +}; -#define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_INIT(type,update_mask,timestamp,offset) \ - SPA_EVENT_INIT_COMPLEX (SpaEventNodeRequestClockUpdate, \ - sizeof (SpaEventNodeRequestClockUpdateBody), type, \ - SPA_POD_INT_INIT (update_mask), \ - SPA_POD_LONG_INIT (timestamp), \ +#define SPA_EVENT_NODE_REQUEST_CLOCK_UPDATE_INIT(type,update_mask,timestamp,offset) \ + SPA_EVENT_INIT_COMPLEX (struct spa_event_node_request_clock_update, \ + sizeof (struct spa_event_node_request_clock_update_body), type, \ + SPA_POD_INT_INIT (update_mask), \ + SPA_POD_LONG_INIT (timestamp), \ SPA_POD_LONG_INIT (offset)) #ifdef __cplusplus diff --git a/spa/include/spa/event.h b/spa/include/spa/event.h index f3e1d9d65..536b76a08 100644 --- a/spa/include/spa/event.h +++ b/spa/include/spa/event.h @@ -24,32 +24,30 @@ extern "C" { #endif -typedef struct _SpaEvent SpaEvent; - #include #include #define SPA_TYPE__Event SPA_TYPE_POD_OBJECT_BASE "Event" #define SPA_TYPE_EVENT_BASE SPA_TYPE__Event ":" -typedef struct { - SpaPODObjectBody body; -} SpaEventBody; +struct spa_event_body { + struct spa_pod_object_body body; +}; -struct _SpaEvent { - SpaPOD pod; - SpaEventBody body; +struct spa_event { + struct spa_pod pod; + struct spa_event_body body; }; #define SPA_EVENT_TYPE(ev) ((ev)->body.body.type) -#define SPA_EVENT_INIT(type) (SpaEvent) \ - { { sizeof (SpaEventBody), SPA_POD_TYPE_OBJECT }, \ - { { 0, type } } } \ +#define SPA_EVENT_INIT(type) (struct spa_event) \ + { { sizeof (struct spa_event_body), SPA_POD_TYPE_OBJECT }, \ + { { 0, type } } } \ -#define SPA_EVENT_INIT_COMPLEX(t,size,type,...) (t) \ - { { size, SPA_POD_TYPE_OBJECT }, \ - { { 0, type }, __VA_ARGS__ } } \ +#define SPA_EVENT_INIT_COMPLEX(t,size,type,...) (t) \ + { { size, SPA_POD_TYPE_OBJECT }, \ + { { 0, type }, __VA_ARGS__ } } \ #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/include/spa/format-builder.h b/spa/include/spa/format-builder.h index 38ddbd9b7..3536b1001 100644 --- a/spa/include/spa/format-builder.h +++ b/spa/include/spa/format-builder.h @@ -30,13 +30,13 @@ extern "C" { #include static inline uint32_t -spa_pod_builder_push_format (SpaPODBuilder *builder, - SpaPODFrame *frame, - uint32_t format_type, - uint32_t media_type, - uint32_t media_subtype) +spa_pod_builder_push_format (struct spa_pod_builder *builder, + struct spa_pod_frame *frame, + uint32_t format_type, + uint32_t media_type, + uint32_t media_subtype) { - const SpaFormat p = { { sizeof (SpaFormatBody), SPA_POD_TYPE_OBJECT }, + const struct spa_format p = { { sizeof (struct spa_format_body), SPA_POD_TYPE_OBJECT }, { { 0, format_type }, { { sizeof (uint32_t), SPA_POD_TYPE_ID }, media_type }, { { sizeof (uint32_t), SPA_POD_TYPE_ID }, media_subtype } } }; @@ -50,10 +50,10 @@ spa_pod_builder_push_format (SpaPODBuilder *builder, SPA_POD_TYPE_ID,media_subtype, \ __VA_ARGS__) -SpaResult -spa_format_filter (const SpaFormat *format, - const SpaFormat *filter, - SpaPODBuilder *result); +int +spa_format_filter (const struct spa_format *format, + const struct spa_format *filter, + struct spa_pod_builder *result); #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/include/spa/format-utils.h b/spa/include/spa/format-utils.h index 67ec61309..cc45bdc95 100644 --- a/spa/include/spa/format-utils.h +++ b/spa/include/spa/format-utils.h @@ -30,16 +30,16 @@ extern "C" { #include #include -typedef struct { +struct spa_type_media_type { uint32_t audio; uint32_t video; uint32_t image; uint32_t binary; uint32_t stream; -} SpaTypeMediaType; +}; static inline void -spa_type_media_type_map (SpaTypeMap *map, SpaTypeMediaType *type) +spa_type_media_type_map (struct spa_type_map *map, struct spa_type_media_type *type) { if (type->audio == 0) { type->audio = spa_type_map_get_id (map, SPA_TYPE_MEDIA_TYPE__audio); @@ -50,19 +50,19 @@ spa_type_media_type_map (SpaTypeMap *map, SpaTypeMediaType *type) } } -typedef struct { +struct spa_type_media_subtype { uint32_t raw; -} SpaTypeMediaSubtype; +}; static inline void -spa_type_media_subtype_map (SpaTypeMap *map, SpaTypeMediaSubtype *type) +spa_type_media_subtype_map (struct spa_type_map *map, struct spa_type_media_subtype *type) { if (type->raw == 0) { type->raw = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__raw); } } -typedef struct { +struct spa_type_media_subtype_video { uint32_t h264; uint32_t mjpg; uint32_t dv; @@ -77,30 +77,30 @@ typedef struct { uint32_t vp9; uint32_t jpeg; uint32_t bayer; -} SpaTypeMediaSubtypeVideo; +}; static inline void -spa_type_media_subtype_video_map (SpaTypeMap *map, SpaTypeMediaSubtypeVideo *type) +spa_type_media_subtype_video_map (struct spa_type_map *map, struct spa_type_media_subtype_video *type) { if (type->h264 == 0) { - type->h264 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__h264); - type->mjpg = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mjpg); - type->dv = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__dv); + type->h264 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__h264); + type->mjpg = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mjpg); + type->dv = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__dv); type->mpegts = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpegts); - type->h263 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__h263); - type->mpeg1 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg1); - type->mpeg2 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg2); - type->mpeg4 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg4); - type->xvid = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__xvid); - type->vc1 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vc1); - type->vp8 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vp8); - type->vp9 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vp9); - type->jpeg = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__jpeg); - type->bayer = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__bayer); + type->h263 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__h263); + type->mpeg1 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg1); + type->mpeg2 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg2); + type->mpeg4 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mpeg4); + type->xvid = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__xvid); + type->vc1 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vc1); + type->vp8 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vp8); + type->vp9 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vp9); + type->jpeg = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__jpeg); + type->bayer = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__bayer); } } -typedef struct { +struct spa_type_media_subtype_audio { uint32_t mp3; uint32_t aac; uint32_t vorbis; @@ -113,24 +113,24 @@ typedef struct { uint32_t g729; uint32_t amr; uint32_t gsm; -} SpaTypeMediaSubtypeAudio; +}; static inline void -spa_type_media_subtype_audio_map (SpaTypeMap *map, SpaTypeMediaSubtypeAudio *type) +spa_type_media_subtype_audio_map (struct spa_type_map *map, struct spa_type_media_subtype_audio *type) { if (type->mp3 == 0) { - type->mp3 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mp3); - type->aac = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__aac); + type->mp3 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__mp3); + type->aac = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__aac); type->vorbis = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__vorbis); - type->wma = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__wma); - type->ra = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__ra); - type->sbc = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__sbc); - type->adpcm = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__adpcm); - type->g723 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g723); - type->g726 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g726); - type->g729 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g729); - type->amr = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__amr); - type->gsm = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__gsm); + type->wma = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__wma); + type->ra = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__ra); + type->sbc = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__sbc); + type->adpcm = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__adpcm); + type->g723 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g723); + type->g726 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g726); + type->g729 = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__g729); + type->amr = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__amr); + type->gsm = spa_type_map_get_id (map, SPA_TYPE_MEDIA_SUBTYPE__gsm); } } @@ -141,39 +141,39 @@ spa_type_media_subtype_audio_map (SpaTypeMap *map, SpaTypeMediaSubtypeAudio *typ SPA_POD_ID_INIT (media_subtype) } } #define SPA_FORMAT_BODY_FOREACH(body, size, iter) \ - for ((iter) = SPA_MEMBER ((body), sizeof (SpaFormatBody), SpaPODProp); \ - (iter) < SPA_MEMBER ((body), (size), SpaPODProp); \ - (iter) = SPA_MEMBER ((iter), SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), SpaPODProp)) + for ((iter) = SPA_MEMBER ((body), sizeof (struct spa_format_body), struct spa_pod_prop); \ + (iter) < SPA_MEMBER ((body), (size), struct spa_pod_prop); \ + (iter) = SPA_MEMBER ((iter), SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), struct spa_pod_prop)) #define SPA_FORMAT_FOREACH(format, iter) \ SPA_FORMAT_BODY_FOREACH(&format->body, SPA_POD_BODY_SIZE(format), iter) -#define SPA_FORMAT_MEDIA_TYPE(f) SPA_POD_VALUE (SpaPODId, &f->body.media_type) -#define SPA_FORMAT_MEDIA_SUBTYPE(f) SPA_POD_VALUE (SpaPODId, &f->body.media_subtype) +#define SPA_FORMAT_MEDIA_TYPE(f) SPA_POD_VALUE (struct spa_pod_id, &f->body.media_type) +#define SPA_FORMAT_MEDIA_SUBTYPE(f) SPA_POD_VALUE (struct spa_pod_id, &f->body.media_subtype) -static inline SpaPODProp * -spa_format_find_prop (const SpaFormat *format, uint32_t key) +static inline struct spa_pod_prop * +spa_format_find_prop (const struct spa_format *format, uint32_t key) { - return spa_pod_contents_find_prop (&format->pod, sizeof (SpaFormat), key); + return spa_pod_contents_find_prop (&format->pod, sizeof (struct spa_format), key); } static inline uint32_t -spa_format_query (const SpaFormat *format, uint32_t key, ...) +spa_format_query (const struct spa_format *format, uint32_t key, ...) { uint32_t count; va_list args; va_start (args, key); - count = spa_pod_contents_queryv (&format->pod, sizeof (SpaFormat), key, args); + count = spa_pod_contents_queryv (&format->pod, sizeof (struct spa_format), key, args); va_end (args); return count; } -static inline SpaResult -spa_format_fixate (SpaFormat *format) +static inline int +spa_format_fixate (struct spa_format *format) { - SpaPODProp *prop; + struct spa_pod_prop *prop; SPA_FORMAT_FOREACH (format, prop) prop->body.flags &= ~SPA_POD_PROP_FLAG_UNSET; diff --git a/spa/include/spa/format.h b/spa/include/spa/format.h index 396ce4ad1..bebfec501 100644 --- a/spa/include/spa/format.h +++ b/spa/include/spa/format.h @@ -24,11 +24,10 @@ extern "C" { #endif +struct spa_format; #define SPA_TYPE__Format SPA_TYPE_POD_OBJECT_BASE "Format" #define SPA_TYPE_FORMAT_BASE SPA_TYPE__Format ":" -typedef struct _SpaFormat SpaFormat; - #include #include @@ -77,22 +76,22 @@ typedef struct _SpaFormat SpaFormat; #define SPA_TYPE_MEDIA_SUBTYPE__amr SPA_TYPE_MEDIA_SUBTYPE_BASE "amr" #define SPA_TYPE_MEDIA_SUBTYPE__gsm SPA_TYPE_MEDIA_SUBTYPE_BASE "gsm" -typedef struct { - SpaPODObjectBody obj_body; - SpaPODId media_type SPA_ALIGNED (8); - SpaPODId media_subtype SPA_ALIGNED (8); - /* contents follow, series of SpaPODProp */ -} SpaFormatBody; +struct spa_format_body { + struct spa_pod_object_body obj_body; + struct spa_pod_id media_type SPA_ALIGNED (8); + struct spa_pod_id media_subtype SPA_ALIGNED (8); + /* contents follow, series of spa_pod_prop */ +}; /** - * SpaFormat: + * spa_format: * @media_type: media type * @media_subtype: subtype * @pod: POD object with properties */ -struct _SpaFormat { - SpaPOD pod; - SpaFormatBody body; +struct spa_format { + struct spa_pod pod; + struct spa_format_body body; }; #ifdef __cplusplus diff --git a/spa/include/spa/graph.h b/spa/include/spa/graph.h index 50ca46dfe..1aa453b60 100644 --- a/spa/include/spa/graph.h +++ b/spa/include/spa/graph.h @@ -27,56 +27,56 @@ extern "C" { #include #include -typedef struct SpaGraph SpaGraph; -typedef struct SpaGraphNode SpaGraphNode; -typedef struct SpaGraphPort SpaGraphPort; +struct spa_graph; +struct spa_graph_node; +struct spa_graph_port; -struct SpaGraph { - SpaList nodes; - SpaList ready; +struct spa_graph { + struct spa_list nodes; + struct spa_list ready; }; -typedef SpaResult (*SpaGraphNodeFunc) (SpaGraphNode *node); +typedef int (*spa_graph_node_func_t) (struct spa_graph_node *node); -struct SpaGraphNode { - SpaList link; - SpaList ready_link; - SpaList ports[2]; +struct spa_graph_node { + struct spa_list link; + struct spa_list ready_link; + struct spa_list ports[2]; #define SPA_GRAPH_NODE_FLAG_ASYNC (1 << 0) uint32_t flags; - SpaResult state; + int state; #define SPA_GRAPH_ACTION_CHECK 0 #define SPA_GRAPH_ACTION_IN 1 #define SPA_GRAPH_ACTION_OUT 2 uint32_t action; - SpaGraphNodeFunc schedule; + spa_graph_node_func_t schedule; void *user_data; uint32_t max_in; uint32_t required_in; uint32_t ready_in; }; -struct SpaGraphPort { - SpaList link; - SpaGraphNode *node; - SpaDirection direction; - uint32_t port_id; - uint32_t flags; - SpaPortIO *io; - SpaGraphPort *peer; +struct spa_graph_port { + struct spa_list link; + struct spa_graph_node *node; + enum spa_direction direction; + uint32_t port_id; + uint32_t flags; + struct spa_port_io *io; + struct spa_graph_port *peer; }; static inline void -spa_graph_init (SpaGraph *graph) +spa_graph_init (struct spa_graph *graph) { spa_list_init (&graph->nodes); spa_list_init (&graph->ready); } -static inline SpaResult -spa_graph_node_schedule_default (SpaGraphNode *node) +static inline int +spa_graph_node_schedule_default (struct spa_graph_node *node) { - SpaNode *n = node->user_data; + struct spa_node *n = node->user_data; if (node->action == SPA_GRAPH_ACTION_IN) return spa_node_process_input (n); @@ -87,7 +87,7 @@ spa_graph_node_schedule_default (SpaGraphNode *node) } static inline void -spa_graph_node_add (SpaGraph *graph, SpaGraphNode *node, SpaGraphNodeFunc schedule, void *user_data) +spa_graph_node_add (struct spa_graph *graph, struct spa_graph_node *node, spa_graph_node_func_t schedule, void *user_data) { spa_list_init (&node->ports[SPA_DIRECTION_INPUT]); spa_list_init (&node->ports[SPA_DIRECTION_OUTPUT]); @@ -101,10 +101,10 @@ spa_graph_node_add (SpaGraph *graph, SpaGraphNode *node, SpaGraphNodeFunc schedu } static inline void -spa_graph_port_check (SpaGraph *graph, - SpaGraphPort *port) +spa_graph_port_check (struct spa_graph *graph, + struct spa_graph_port *port) { - SpaGraphNode *node = port->node; + struct spa_graph_node *node = port->node; if (port->io->status == SPA_RESULT_HAVE_BUFFER) node->ready_in++; @@ -120,13 +120,13 @@ spa_graph_port_check (SpaGraph *graph, } static inline void -spa_graph_port_add (SpaGraph *graph, - SpaGraphNode *node, - SpaGraphPort *port, - SpaDirection direction, - uint32_t port_id, - uint32_t flags, - SpaPortIO *io) +spa_graph_port_add (struct spa_graph *graph, + struct spa_graph_node *node, + struct spa_graph_port *port, + enum spa_direction direction, + uint32_t port_id, + uint32_t flags, + struct spa_port_io *io) { port->node = node; port->direction = direction; @@ -142,41 +142,41 @@ spa_graph_port_add (SpaGraph *graph, } static inline void -spa_graph_node_remove (SpaGraph *graph, SpaGraphNode *node) +spa_graph_node_remove (struct spa_graph *graph, struct spa_graph_node *node) { spa_list_remove (&node->link); } static inline void -spa_graph_port_remove (SpaGraph *graph, SpaGraphPort *port) +spa_graph_port_remove (struct spa_graph *graph, struct spa_graph_port *port) { spa_list_remove (&port->link); } static inline void -spa_graph_port_link (SpaGraph *graph, SpaGraphPort *out, SpaGraphPort *in) +spa_graph_port_link (struct spa_graph *graph, struct spa_graph_port *out, struct spa_graph_port *in) { out->peer = in; in->peer = out; } static inline void -spa_graph_port_unlink (SpaGraph *graph, SpaGraphPort *out, SpaGraphPort *in) +spa_graph_port_unlink (struct spa_graph *graph, struct spa_graph_port *out, struct spa_graph_port *in) { out->peer = NULL; in->peer = NULL; } static inline void -spa_graph_node_schedule (SpaGraph *graph, SpaGraphNode *node) +spa_graph_node_schedule (struct spa_graph *graph, struct spa_graph_node *node) { - SpaGraphPort *p; + struct spa_graph_port *p; if (node->ready_link.next == NULL) spa_list_insert (graph->ready.prev, &node->ready_link); while (!spa_list_is_empty (&graph->ready)) { - SpaGraphNode *n = spa_list_first (&graph->ready, SpaGraphNode, ready_link); + struct spa_graph_node *n = spa_list_first (&graph->ready, struct spa_graph_node, ready_link); spa_list_remove (&n->ready_link); n->ready_link.next = NULL; @@ -195,7 +195,7 @@ spa_graph_node_schedule (SpaGraph *graph, SpaGraphNode *node) if (n->state == SPA_RESULT_NEED_BUFFER) { n->ready_in = 0; spa_list_for_each (p, &n->ports[SPA_DIRECTION_INPUT], link) { - SpaGraphNode *pn = p->peer->node; + struct spa_graph_node *pn = p->peer->node; if (p->io->status == SPA_RESULT_NEED_BUFFER) { if (pn != node || pn->flags & SPA_GRAPH_NODE_FLAG_ASYNC) { pn->action = SPA_GRAPH_ACTION_OUT; diff --git a/spa/include/spa/list.h b/spa/include/spa/list.h index b2fdc5526..94a154997 100644 --- a/spa/include/spa/list.h +++ b/spa/include/spa/list.h @@ -24,25 +24,23 @@ extern "C" { #endif -typedef struct _SpaList SpaList; - #include -struct _SpaList { - SpaList *next; - SpaList *prev; +struct spa_list { + struct spa_list *next; + struct spa_list *prev; }; static inline void -spa_list_init (SpaList *list) +spa_list_init (struct spa_list *list) { list->next = list; list->prev = list; } static inline void -spa_list_insert (SpaList *list, - SpaList *elem) +spa_list_insert (struct spa_list *list, + struct spa_list *elem) { elem->prev = list; elem->next = list->next; @@ -51,7 +49,7 @@ spa_list_insert (SpaList *list, } static inline void -spa_list_remove (SpaList *elem) +spa_list_remove (struct spa_list *elem) { elem->prev->next = elem->next; elem->next->prev = elem->prev; diff --git a/spa/include/spa/log.h b/spa/include/spa/log.h index f6ccd1f72..50058e2d4 100644 --- a/spa/include/spa/log.h +++ b/spa/include/spa/log.h @@ -24,8 +24,6 @@ extern "C" { #endif -typedef struct _SpaLog SpaLog; - #define SPA_TYPE__Log SPA_TYPE_INTERFACE_BASE "Log" #define SPA_TYPE_LOG_BASE SPA_TYPE__Log ":" @@ -34,43 +32,42 @@ typedef struct _SpaLog SpaLog; #include #include -typedef enum -{ +enum spa_log_level { SPA_LOG_LEVEL_NONE = 0, SPA_LOG_LEVEL_ERROR, SPA_LOG_LEVEL_WARN, SPA_LOG_LEVEL_INFO, SPA_LOG_LEVEL_DEBUG, SPA_LOG_LEVEL_TRACE, -} SpaLogLevel; +}; /** - * SpaLog: + * struct spa_log: * * The Log interface */ -struct _SpaLog { +struct spa_log { /* the total size of this log. This can be used to expand this * structure in the future */ size_t size; /** - * SpaLog::info + * struct spa_log::info * * Extra information about the log */ - const SpaDict *info; + const struct spa_dict *info; /** - * SpaLog::level + * struct spa_log::level * * Logging level, everything above this level is not logged */ - SpaLogLevel level; + enum spa_log_level level; /** - * SpaLog::log - * @log: a #SpaLog - * @level: a #SpaLogLevel + * struct spa_log::log + * @log: a #struct spa_log + * @level: a #enum spa_log_level * @file: the file name * @line: the line number * @func: the function name @@ -79,17 +76,17 @@ struct _SpaLog { * * Log a message with the given log level. */ - void (*log) (SpaLog *log, - SpaLogLevel level, - const char *file, - int line, - const char *func, - const char *fmt, ...) SPA_PRINTF_FUNC(6, 7); + void (*log) (struct spa_log *log, + enum spa_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, ...) SPA_PRINTF_FUNC(6, 7); /** - * SpaLog::logv - * @log: a #SpaLog - * @level: a #SpaLogLevel + * struct spa_log::logv + * @log: a #struct spa_log + * @level: a #enum spa_log_level * @file: the file name * @line: the line number * @func: the function name @@ -98,13 +95,13 @@ struct _SpaLog { * * Log a message with the given log level. */ - void (*logv) (SpaLog *log, - SpaLogLevel level, - const char *file, - int line, - const char *func, - const char *fmt, - va_list args) SPA_PRINTF_FUNC(6, 0); + void (*logv) (struct spa_log *log, + enum spa_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, + va_list args) SPA_PRINTF_FUNC(6, 0); }; #define spa_log_level_enabled(l,lev) ((l) && (l)->level >= (lev)) @@ -124,7 +121,7 @@ struct _SpaLog { #else #define SPA_LOG_FUNC(name,lev) \ -static inline void spa_log_##name (SpaLog *l, const char *format, ...) \ +static inline void spa_log_##name (struct spa_log *l, const char *format, ...) \ { \ if (SPA_UNLIKELY (spa_log_level_enabled (l, lev))) { \ va_list varargs; \ diff --git a/spa/include/spa/loop.h b/spa/include/spa/loop.h index f4297fbee..cd5c4821a 100644 --- a/spa/include/spa/loop.h +++ b/spa/include/spa/loop.h @@ -24,15 +24,13 @@ extern "C" { #endif -typedef struct _SpaLoop SpaLoop; -typedef struct _SpaSource SpaSource; -typedef struct _SpaLoopControl SpaLoopControl; -typedef struct _SpaLoopUtils SpaLoopUtils; - +struct spa_loop; #define SPA_TYPE__Loop SPA_TYPE_INTERFACE_BASE "Loop" #define SPA_TYPE_LOOP_BASE SPA_TYPE__Loop ":" +struct spa_loop_control; #define SPA_TYPE__LoopControl SPA_TYPE_INTERFACE_BASE "LoopControl" +struct spa_loop_utils; #define SPA_TYPE__LoopUtils SPA_TYPE_INTERFACE_BASE "LoopUtils" #define SPA_TYPE_LOOP__MainLoop SPA_TYPE_LOOP_BASE "MainLoop" @@ -40,52 +38,54 @@ typedef struct _SpaLoopUtils SpaLoopUtils; #include -typedef void (*SpaSourceFunc) (SpaSource *source); - -typedef enum { +enum spa_io { SPA_IO_IN = (1 << 0), SPA_IO_OUT = (1 << 1), SPA_IO_HUP = (1 << 2), SPA_IO_ERR = (1 << 3), -} SpaIO; - -struct _SpaSource { - SpaLoop *loop; - SpaSourceFunc func; - void *data; - int fd; - SpaIO mask; - SpaIO rmask; }; -typedef SpaResult (*SpaInvokeFunc) (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data); +struct spa_source; + +typedef void (*spa_source_func_t) (struct spa_source *source); + +struct spa_source { + struct spa_loop *loop; + spa_source_func_t func; + void *data; + int fd; + enum spa_io mask; + enum spa_io rmask; +}; + +typedef int (*spa_invoke_func_t) (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data); /** - * SpaLoop: + * spa_loop: * * Register sources and work items to an event loop */ -struct _SpaLoop { +struct spa_loop { /* the total size of this structure. This can be used to expand this * structure in the future */ size_t size; - SpaResult (*add_source) (SpaLoop *loop, - SpaSource *source); - SpaResult (*update_source) (SpaSource *source); + int (*add_source) (struct spa_loop *loop, + struct spa_source *source); + int (*update_source) (struct spa_source *source); - void (*remove_source) (SpaSource *source); + void (*remove_source) (struct spa_source *source); - SpaResult (*invoke) (SpaLoop *loop, - SpaInvokeFunc func, - uint32_t seq, - size_t size, - void *data, - void *user_data); + int (*invoke) (struct spa_loop *loop, + spa_invoke_func_t func, + uint32_t seq, + size_t size, + void *data, + void *user_data); }; #define spa_loop_add_source(l,...) (l)->add_source((l),__VA_ARGS__) @@ -93,30 +93,30 @@ struct _SpaLoop { #define spa_loop_remove_source(l,...) (l)->remove_source(__VA_ARGS__) #define spa_loop_invoke(l,...) (l)->invoke((l),__VA_ARGS__) -typedef void (*SpaLoopHook) (SpaLoopControl *ctrl, - void *data); +typedef void (*spa_loop_hook_t) (struct spa_loop_control *ctrl, + void *data); /** - * SpaLoopControl: + * spa_loop_control: * * Control an event loop */ -struct _SpaLoopControl { +struct spa_loop_control { /* the total size of this structure. This can be used to expand this * structure in the future */ size_t size; - int (*get_fd) (SpaLoopControl *ctrl); + int (*get_fd) (struct spa_loop_control *ctrl); - void (*set_hooks) (SpaLoopControl *ctrl, - SpaLoopHook pre_hook, - SpaLoopHook post_hook, - void *data); + void (*set_hooks) (struct spa_loop_control *ctrl, + spa_loop_hook_t pre_hook, + spa_loop_hook_t post_hook, + void *data); - void (*enter) (SpaLoopControl *ctrl); - void (*leave) (SpaLoopControl *ctrl); + void (*enter) (struct spa_loop_control *ctrl); + void (*leave) (struct spa_loop_control *ctrl); - SpaResult (*iterate) (SpaLoopControl *ctrl, - int timeout); + int (*iterate) (struct spa_loop_control *ctrl, + int timeout); }; #define spa_loop_control_get_fd(l) (l)->get_fd(l) @@ -126,69 +126,69 @@ struct _SpaLoopControl { #define spa_loop_control_leave(l) (l)->leave(l) -typedef void (*SpaSourceIOFunc) (SpaLoopUtils *utils, - SpaSource *source, - int fd, - SpaIO mask, - void *data); -typedef void (*SpaSourceIdleFunc) (SpaLoopUtils *utils, - SpaSource *source, - void *data); -typedef void (*SpaSourceEventFunc) (SpaLoopUtils *utils, - SpaSource *source, - void *data); -typedef void (*SpaSourceTimerFunc) (SpaLoopUtils *utils, - SpaSource *source, - void *data); -typedef void (*SpaSourceSignalFunc) (SpaLoopUtils *utils, - SpaSource *source, - int signal_number, - void *data); +typedef void (*spa_source_io_func_t) (struct spa_loop_utils *utils, + struct spa_source *source, + int fd, + enum spa_io mask, + void *data); +typedef void (*spa_source_idle_func_t) (struct spa_loop_utils *utils, + struct spa_source *source, + void *data); +typedef void (*spa_source_event_func_t) (struct spa_loop_utils *utils, + struct spa_source *source, + void *data); +typedef void (*spa_source_timer_func_t) (struct spa_loop_utils *utils, + struct spa_source *source, + void *data); +typedef void (*spa_source_signal_func_t) (struct spa_loop_utils *utils, + struct spa_source *source, + int signal_number, + void *data); /** - * SpaLoopUtils: + * struct spa_loop_utils: * * Create sources for an event loop */ -struct _SpaLoopUtils { +struct spa_loop_utils { /* the total size of this structure. This can be used to expand this * structure in the future */ size_t size; - SpaSource * (*add_io) (SpaLoopUtils *utils, - int fd, - SpaIO mask, - bool close, - SpaSourceIOFunc func, - void *data); - SpaResult (*update_io) (SpaSource *source, - SpaIO mask); + struct spa_source * (*add_io) (struct spa_loop_utils *utils, + int fd, + enum spa_io mask, + bool close, + spa_source_io_func_t func, + void *data); + int (*update_io) (struct spa_source *source, + enum spa_io mask); - SpaSource * (*add_idle) (SpaLoopUtils *utils, - bool enabled, - SpaSourceIdleFunc func, - void *data); - void (*enable_idle) (SpaSource *source, - bool enabled); + struct spa_source * (*add_idle) (struct spa_loop_utils *utils, + bool enabled, + spa_source_idle_func_t func, + void *data); + void (*enable_idle) (struct spa_source *source, + bool enabled); - SpaSource * (*add_event) (SpaLoopUtils *utils, - SpaSourceEventFunc func, - void *data); - void (*signal_event) (SpaSource *source); + struct spa_source * (*add_event) (struct spa_loop_utils *utils, + spa_source_event_func_t func, + void *data); + void (*signal_event) (struct spa_source *source); - SpaSource * (*add_timer) (SpaLoopUtils *utils, - SpaSourceTimerFunc func, - void *data); - SpaResult (*update_timer) (SpaSource *source, - struct timespec *value, - struct timespec *interval, - bool absolute); - SpaSource * (*add_signal) (SpaLoopUtils *utils, - int signal_number, - SpaSourceSignalFunc func, - void *data); + struct spa_source * (*add_timer) (struct spa_loop_utils *utils, + spa_source_timer_func_t func, + void *data); + int (*update_timer) (struct spa_source *source, + struct timespec *value, + struct timespec *interval, + bool absolute); + struct spa_source * (*add_signal) (struct spa_loop_utils *utils, + int signal_number, + spa_source_signal_func_t func, + void *data); - void (*destroy_source) (SpaSource *source); + void (*destroy_source) (struct spa_source *source); }; #define spa_loop_utils_add_io(l,...) (l)->add_io(l,__VA_ARGS__) diff --git a/spa/include/spa/meta.h b/spa/include/spa/meta.h index cab601d95..f0b70eab2 100644 --- a/spa/include/spa/meta.h +++ b/spa/include/spa/meta.h @@ -37,16 +37,16 @@ extern "C" { #define SPA_TYPE_META__Ringbuffer SPA_TYPE_META_BASE "Ringbuffer" #define SPA_TYPE_META__Shared SPA_TYPE_META_BASE "Shared" -typedef struct { +struct spa_type_meta { uint32_t Header; uint32_t Pointer; uint32_t VideoCrop; uint32_t Ringbuffer; uint32_t Shared; -} SpaTypeMeta; +}; static inline void -spa_type_meta_map (SpaTypeMap *map, SpaTypeMeta *type) +spa_type_meta_map (struct spa_type_map *map, struct spa_type_meta *type) { if (type->Header == 0) { type->Header = spa_type_map_get_id (map, SPA_TYPE_META__Header); @@ -58,14 +58,14 @@ spa_type_meta_map (SpaTypeMap *map, SpaTypeMeta *type) } /** - * SpaMetaHeader: + * spa_meta_header: * @flags: extra flags * @seq: sequence number. This monotonically increments and with the rate, * it can be used to derive a media time. * @pts: The MONOTONIC time for @seq. * @dts_offset: offset relative to @pts to start decoding this buffer. */ -typedef struct { +struct spa_meta_header { #define SPA_META_HEADER_FLAG_DISCONT (1 << 0) /* data is not continous with previous buffer */ #define SPA_META_HEADER_FLAG_CORRUPTED (1 << 1) /* data might be corrupted */ #define SPA_META_HEADER_FLAG_MARKER (1 << 2) /* media specific marker */ @@ -76,58 +76,58 @@ typedef struct { uint32_t seq; int64_t pts; int64_t dts_offset; -} SpaMetaHeader; +}; -typedef struct { +struct spa_meta_pointer { uint32_t type; void *ptr; -} SpaMetaPointer; +}; /** - * SpaMetaVideoCrop: + * spa_meta_video_crop: * @x: * @y: * @width: * @height */ -typedef struct { +struct spa_meta_video_crop { int32_t x, y; int32_t width, height; -} SpaMetaVideoCrop; +}; /** - * SpaMetaRingbuffer: + * spa_meta_ringbuffer: * @ringbuffer: */ -typedef struct { - SpaRingbuffer ringbuffer; -} SpaMetaRingbuffer; +struct spa_meta_ringbuffer { + struct spa_ringbuffer ringbuffer; +}; /** - * SpaMetaShared: + * spa_meta_shared: * @flags: flags * @fd: the fd of the memory * @offset: start offset of memory * @size: size of the memory */ -typedef struct { +struct spa_meta_shared { int32_t flags; int fd; int32_t offset; uint32_t size; -} SpaMetaShared; +}; /** - * SpaMeta: + * spa_meta: * @type: metadata type * @data: pointer to metadata * @size: size of metadata */ -typedef struct { +struct spa_meta { uint32_t type; void *data; uint32_t size; -} SpaMeta; +}; #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/include/spa/monitor.h b/spa/include/spa/monitor.h index 41df2f110..57b8cf5a4 100644 --- a/spa/include/spa/monitor.h +++ b/spa/include/spa/monitor.h @@ -24,8 +24,7 @@ extern "C" { #endif -typedef struct _SpaMonitor SpaMonitor; - +struct spa_monitor; #define SPA_TYPE__Monitor SPA_TYPE_INTERFACE_BASE "Monitor" #define SPA_TYPE_MONITOR_BASE SPA_TYPE__Monitor ":" @@ -33,7 +32,6 @@ typedef struct _SpaMonitor SpaMonitor; #include #include -typedef SpaEvent SpaEventMonitor; #define SPA_TYPE_EVENT__Monitor SPA_TYPE_EVENT_BASE "Monitor" #define SPA_TYPE_EVENT_MONITOR_BASE SPA_TYPE_EVENT__Monitor ":" @@ -41,7 +39,9 @@ typedef SpaEvent SpaEventMonitor; #define SPA_TYPE_EVENT_MONITOR__Removed SPA_TYPE_EVENT_MONITOR_BASE "Removed" #define SPA_TYPE_EVENT_MONITOR__Changed SPA_TYPE_EVENT_MONITOR_BASE "Changed" -typedef SpaPODObject SpaMonitorItem; +struct spa_monitor_item { + struct spa_pod_object object; +}; #define SPA_TYPE__MonitorItem SPA_TYPE_POD_OBJECT_BASE "MonitorItem" #define SPA_TYPE_MONITOR_ITEM_BASE SPA_TYPE__MonitorItem ":" @@ -53,7 +53,7 @@ typedef SpaPODObject SpaMonitorItem; #define SPA_TYPE_MONITOR_ITEM__info SPA_TYPE_MONITOR_ITEM_BASE "info" #define SPA_TYPE_MONITOR_ITEM__factory SPA_TYPE_MONITOR_ITEM_BASE "factory" -typedef struct { +struct spa_type_monitor { uint32_t Monitor; uint32_t Added; @@ -68,10 +68,10 @@ typedef struct { uint32_t klass; uint32_t info; uint32_t factory; -} SpaTypeMonitor; +}; static inline void -spa_type_monitor_map (SpaTypeMap *map, SpaTypeMonitor *type) +spa_type_monitor_map (struct spa_type_map *map, struct spa_type_monitor *type) { if (type->Added == 0) { type->Monitor = spa_type_map_get_id (map, SPA_TYPE__Monitor); @@ -89,75 +89,72 @@ spa_type_monitor_map (SpaTypeMap *map, SpaTypeMonitor *type) } } -typedef enum { +enum spa_monitor_item_flags { SPA_MONITOR_ITEM_FLAG_NONE = 0, -} SpaMonitorItemFlags; +}; /** - * SpaMonitorItemState: + * spa_monitor_item_state: * @SPA_MONITOR_ITEM_STATE_AVAILABLE: The item is available * @SPA_MONITOR_ITEM_STATE_DISABLED: the item is disabled * @SPA_MONITOR_ITEM_STATE_UNAVAILABLE: the item is unavailable */ -typedef enum { +enum spa_monitor_item_state { SPA_MONITOR_ITEM_STATE_AVAILABLE, SPA_MONITOR_ITEM_STATE_DISABLED, SPA_MONITOR_ITEM_STATE_UNAVAILABLE, -} SpaMonitorItemState; +}; /** - * SpaMonitorCallback: - * @node: a #SpaMonitor emiting the event - * @event: the event that was emited - * @user_data: user data provided when registering the callback - * - * This will be called when a monitor event is notified - * on @monitor. + * spa_monitor_callbacks: */ -typedef void (*SpaEventMonitorCallback) (SpaMonitor *monitor, - SpaEventMonitor *event, - void *user_data); +struct spa_monitor_callbacks { + void (*event) (struct spa_monitor *monitor, + struct spa_event *event, + void *user_data); +}; /** - * SpaMonitor: + * spa_monitor: * * The device monitor interface. */ -struct _SpaMonitor { +struct spa_monitor { /** - * SpaMonitor::info + * spa_monitor::info * * Extra information about the monitor */ - const SpaDict * info; + const struct spa_dict* info; /* the total size of this monitor. This can be used to expand this * structure in the future */ size_t size; /** - * SpaMonitor::set_event_callback: - * @monitor: a #SpaMonitor - * @callback: a #SpaEventMonitorCallback + * spa_monitor::set_callbacks: + * @monitor: a #spa_monitor + * @callback: a #callbacks * @user_data: extra user data * - * Set an event callback to receive asynchronous notifications from + * Set callbacks to receive asynchronous notifications from * the monitor. * * Returns: #SPA_RESULT_OK on success */ - SpaResult (*set_event_callback) (SpaMonitor *monitor, - SpaEventMonitorCallback callback, - void *user_data); + int (*set_callbacks) (struct spa_monitor *monitor, + const struct spa_monitor_callbacks *callbacks, + size_t callbacks_size, + void *user_data); - SpaResult (*enum_items) (SpaMonitor *monitor, - SpaMonitorItem **item, - uint32_t index); + int (*enum_items) (struct spa_monitor *monitor, + struct spa_monitor_item **item, + uint32_t index); }; -#define spa_monitor_set_event_callback(m,...) (m)->set_event_callback((m),__VA_ARGS__) -#define spa_monitor_enum_items(m,...) (m)->enum_items((m),__VA_ARGS__) +#define spa_monitor_set_callbacks(m,...) (m)->set_callbacks((m),__VA_ARGS__) +#define spa_monitor_enum_items(m,...) (m)->enum_items((m),__VA_ARGS__) #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/include/spa/node.h b/spa/include/spa/node.h index 60d199f24..2903f6ff3 100644 --- a/spa/include/spa/node.h +++ b/spa/include/spa/node.h @@ -24,11 +24,11 @@ extern "C" { #endif -typedef struct _SpaNode SpaNode; - #define SPA_TYPE__Node SPA_TYPE_INTERFACE_BASE "Node" #define SPA_TYPE_NODE_BASE SPA_TYPE__Node ":" +struct spa_node; + #include #include #include @@ -38,14 +38,14 @@ typedef struct _SpaNode SpaNode; #include #include -typedef struct { - uint64_t offset; - uint32_t min_size; - uint32_t max_size; -} SpaRange; +struct spa_range { + uint64_t offset; + uint32_t min_size; + uint32_t max_size; +}; /** - * SpaPortIO: + * struct spa_port_io: * @status: the status * @buffer_id: a buffer id * @range: requested range @@ -53,20 +53,20 @@ typedef struct { * IO information for a port on a node. This is allocated * by the host and configured on all ports for which IO is requested. */ -typedef struct { - uint32_t status; - uint32_t buffer_id; - SpaRange range; -} SpaPortIO; +struct spa_port_io { + uint32_t status; + uint32_t buffer_id; + struct spa_range range; +}; -#define SPA_PORT_IO_INIT (SpaPortIO) { SPA_RESULT_NEED_BUFFER, SPA_ID_INVALID, } +#define SPA_PORT_IO_INIT (struct spa_port_io) { SPA_RESULT_NEED_BUFFER, SPA_ID_INVALID, } /** - * SpaPortInfo + * struct spa_port_info * @flags: extra port flags * @rate: rate of sequence number increment per second of media data */ -typedef struct { +struct spa_port_info { #define SPA_PORT_INFO_FLAG_REMOVABLE (1<<0) /* port can be removed */ #define SPA_PORT_INFO_FLAG_OPTIONAL (1<<1) /* processing on port is optional */ #define SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS (1<<2) /* the port can allocate buffer data */ @@ -76,27 +76,27 @@ typedef struct { #define SPA_PORT_INFO_FLAG_NO_REF (1<<5) /* the port does not keep a ref on the buffer */ #define SPA_PORT_INFO_FLAG_LIVE (1<<6) /* output buffers from this port are timestamped against * a live clock. */ - uint32_t flags; - uint32_t rate; -} SpaPortInfo; + uint32_t flags; + uint32_t rate; +}; -typedef struct { +struct spa_node_callbacks { /** - * SpaNodeCallbacks::event: - * @node: a #SpaNode + * struct spa_node_callbacks::event: + * @node: a #struct spa_node * @event: the event that was emited * @user_data: user data provided when registering the callbacks * * This will be called when an out-of-bound event is notified * on @node. the callback can be called from any thread. */ - void (*event) (SpaNode *node, - SpaEvent *event, - void *user_data); + void (*event) (struct spa_node *node, + struct spa_event *event, + void *user_data); /** - * SpaNodeCallbacks::need_input: - * @node: a #SpaNode + * struct spa_node_callbacks::need_input: + * @node: a #struct spa_node * @user_data: user data provided when registering the callbacks * * The node needs more input. This callback is called from the @@ -105,11 +105,11 @@ typedef struct { * When this function is NULL, synchronous operation is requested * on the input ports. */ - void (*need_input) (SpaNode *node, - void *user_data); + void (*need_input) (struct spa_node *node, + void *user_data); /** - * SpaNodeCallbacks::have_output: - * @node: a #SpaNode + * struct spa_node_callbacks::have_output: + * @node: a #struct spa_node * @user_data: user data provided when registering the callbacks * * The node has output input. This callback is called from the @@ -118,11 +118,11 @@ typedef struct { * When this function is NULL, synchronous operation is requested * on the output ports. */ - void (*have_output) (SpaNode *node, - void *user_data); + void (*have_output) (struct spa_node *node, + void *user_data); /** - * SpaNodeCallbacks::reuse_buffer: - * @node: a #SpaNode + * struct spa_node_callbacks::reuse_buffer: + * @node: a #struct spa_node * @port_id: an input port_id * @buffer_id: the buffer id to be reused * @user_data: user data provided when registering the callbacks @@ -133,40 +133,40 @@ typedef struct { * When this function is NULL, the buffers to reuse will be set in * the io area or the input ports. */ - void (*reuse_buffer) (SpaNode *node, - uint32_t port_id, - uint32_t buffer_id, - void *user_data); -} SpaNodeCallbacks; + void (*reuse_buffer) (struct spa_node *node, + uint32_t port_id, + uint32_t buffer_id, + void *user_data); +}; /** - * SpaNode: + * struct spa_node: * - * A SpaNode is a component that can comsume and produce buffers. + * A struct spa_node is a component that can comsume and produce buffers. * * * */ -struct _SpaNode { +struct spa_node { /* the total size of this node. This can be used to expand this * structure in the future */ size_t size; /** - * SpaNode::info + * spa_node::info * * Extra information about the node */ - const SpaDict * info; + const struct spa_dict *info; /** - * SpaNode::get_props: - * @node: a #SpaNode - * @props: a location for a #SpaProps pointer + * spa_node::get_props: + * @node: a #spa_node + * @props: a location for a #struct spa_props pointer * * Get the configurable properties of @node. * * The returned @props is a snapshot of the current configuration and * can be modified. The modifications will take effect after a call - * to SpaNode::set_props. + * to spa_node::set_props. * * This function must be called from the main thread. * @@ -175,18 +175,18 @@ struct _SpaNode { * #SPA_RESULT_NOT_IMPLEMENTED when there are no properties * implemented on @node */ - SpaResult (*get_props) (SpaNode *node, - SpaProps **props); + int (*get_props) (struct spa_node *node, + struct spa_props **props); /** - * SpaNode::set_props: - * @node: a #SpaNode - * @props: a #SpaProps + * struct spa_node::set_props: + * @node: a #struct spa_node + * @props: a #struct spa_props * * Set the configurable properties in @node. * - * Usually, @props will be obtained from SpaNode::get_props and then - * modified but it is also possible to set another #SpaProps object - * as long as its keys and types match those of SpaProps::get_props. + * Usually, @props will be obtained from struct spa_node::get_props and then + * modified but it is also possible to set another #struct spa_props object + * as long as its keys and types match those of struct spa_props::get_props. * * Properties with keys that are not known are ignored. * @@ -201,12 +201,12 @@ struct _SpaNode { * #SPA_RESULT_WRONG_PROPERTY_TYPE when a property has the wrong * type. */ - SpaResult (*set_props) (SpaNode *node, - const SpaProps *props); + int (*set_props) (struct spa_node *node, + const struct spa_props *props); /** - * SpaNode::send_command: - * @node: a #SpaNode - * @command: a #SpaCommand + * struct spa_node::send_command: + * @node: a #struct spa_node + * @command: a #spa_command * * Send a command to @node. * @@ -220,11 +220,11 @@ struct _SpaNode { * #SPA_RESULT_INVALID_COMMAND @command is an invalid command * #SPA_RESULT_ASYNC @command is executed asynchronously */ - SpaResult (*send_command) (SpaNode *node, - SpaCommand *command); + int (*send_command) (struct spa_node *node, + struct spa_command *command); /** - * SpaNode::set_event_callback: - * @node: a #SpaNode + * struct spa_node::set_event_callback: + * @node: a #struct spa_node * @callbacks: callbacks to set * @callbacks_size: size of the callbacks structure * @user_data: user data passed to the callback functions @@ -237,13 +237,13 @@ struct _SpaNode { * Returns: #SPA_RESULT_OK on success * #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL */ - SpaResult (*set_callbacks) (SpaNode *node, - const SpaNodeCallbacks *callbacks, - size_t callbacks_size, - void *user_data); + int (*set_callbacks) (struct spa_node *node, + const struct spa_node_callbacks *callbacks, + size_t callbacks_size, + void *user_data); /** - * SpaNode::get_n_ports: - * @node: a #SpaNode + * struct spa_node::get_n_ports: + * @node: a #struct spa_node * @n_input_ports: location to hold the number of input ports or %NULL * @max_input_ports: location to hold the maximum number of input ports or %NULL * @n_output_ports: location to hold the number of output ports or %NULL @@ -257,14 +257,14 @@ struct _SpaNode { * Returns: #SPA_RESULT_OK on success * #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL */ - SpaResult (*get_n_ports) (SpaNode *node, - uint32_t *n_input_ports, - uint32_t *max_input_ports, - uint32_t *n_output_ports, - uint32_t *max_output_ports); + int (*get_n_ports) (struct spa_node *node, + uint32_t *n_input_ports, + uint32_t *max_input_ports, + uint32_t *n_output_ports, + uint32_t *max_output_ports); /** - * SpaNode::get_port_ids: - * @node: a #SpaNode + * struct spa_node::get_port_ids: + * @node: a #struct spa_node * @n_input_ports: size of the @input_ids array * @input_ids: array to store the input stream ids * @n_output_ports: size of the @output_ids array @@ -277,16 +277,16 @@ struct _SpaNode { * Returns: #SPA_RESULT_OK on success * #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL */ - SpaResult (*get_port_ids) (SpaNode *node, - uint32_t n_input_ports, - uint32_t *input_ids, - uint32_t n_output_ports, - uint32_t *output_ids); + int (*get_port_ids) (struct spa_node *node, + uint32_t n_input_ports, + uint32_t *input_ids, + uint32_t n_output_ports, + uint32_t *output_ids); /** - * SpaNode::add_port: - * @node: a #SpaNode - * @direction: a #SpaDirection + * struct spa_node::add_port: + * @node: a #struct spa_node + * @direction: a #enum spa_direction * @port_id: an unused port id * * Make a new port with @port_id. The called should use get_port_ids() to @@ -299,17 +299,17 @@ struct _SpaNode { * Returns: #SPA_RESULT_OK on success * #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL */ - SpaResult (*add_port) (SpaNode *node, - SpaDirection direction, - uint32_t port_id); - SpaResult (*remove_port) (SpaNode *node, - SpaDirection direction, - uint32_t port_id); + int (*add_port) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id); + int (*remove_port) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id); /** - * SpaNode::port_enum_formats: - * @node: a #SpaNode - * @direction: a #SpaDirection + * struct spa_node::port_enum_formats: + * @node: a #struct spa_node + * @direction: a #enum spa_direction * @port_id: the port to query * @format: pointer to a format * @filter: a format filter @@ -324,7 +324,7 @@ struct _SpaNode { * returns #SPA_RESULT_ENUM_END. * * The result format can be queried and modified and ultimately be used - * to call SpaNode::port_set_format. + * to call struct spa_node::port_set_format. * * This function must be called from the main thread. * @@ -333,19 +333,19 @@ struct _SpaNode { * #SPA_RESULT_INVALID_PORT when port_id is not valid * #SPA_RESULT_ENUM_END when no format exists */ - SpaResult (*port_enum_formats) (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, - uint32_t index); + int (*port_enum_formats) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_format **format, + const struct spa_format *filter, + uint32_t index); /** - * SpaNode::port_set_format: - * @node: a #SpaNode - * @direction: a #SpaDirection + * struct spa_node::port_set_format: + * @node: a #struct spa_node + * @direction: a #enum spa_direction * @port_id: the port to configure * @flags: flags - * @format: a #SpaFormat with the format + * @format: a #struct spa_format with the format * * Set a format on @port_id of @node. * @@ -361,7 +361,7 @@ struct _SpaNode { * Returns: #SPA_RESULT_OK on success * #SPA_RESULT_OK_RECHECK on success, the value of @format might have been * changed depending on @flags and the final value can be found by - * doing SpaNode::get_format. + * doing struct spa_node::get_format. * #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL * #SPA_RESULT_INVALID_PORT when port_id is not valid * #SPA_RESULT_INVALID_MEDIA_TYPE when the media type is not valid @@ -376,19 +376,19 @@ struct _SpaNode { #define SPA_PORT_FORMAT_FLAG_FIXATE (1 << 1) /* fixate the non-optional unset fields */ #define SPA_PORT_FORMAT_FLAG_NEAREST (1 << 2) /* allow set fields to be rounded to the * nearest allowed field value. */ - SpaResult (*port_set_format) (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - uint32_t flags, - const SpaFormat *format); + int (*port_set_format) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + uint32_t flags, + const struct spa_format *format); /** - * SpaNode::port_get_format: - * @node: a #SpaNode - * @direction: a #SpaDirection + * struct spa_node::port_get_format: + * @node: a #struct spa_node + * @direction: a #enum spa_direction * @port_id: the port to query - * @format: a pointer to a location to hold the #SpaFormat + * @format: a pointer to a location to hold the #struct spa_format * - * Get the format on @port_id of @node. The result #SpaFormat can + * Get the format on @port_id of @node. The result #struct spa_format can * not be modified. * * This function must be called from the main thread. @@ -398,30 +398,30 @@ struct _SpaNode { * #SPA_RESULT_INVALID_PORT when @port_id is not valid * #SPA_RESULT_INVALID_NO_FORMAT when no format was set */ - SpaResult (*port_get_format) (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - const SpaFormat **format); + int (*port_get_format) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + const struct spa_format **format); - SpaResult (*port_get_info) (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - const SpaPortInfo **info); + int (*port_get_info) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + const struct spa_port_info **info); - SpaResult (*port_enum_params) (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - uint32_t index, - SpaParam **param); - SpaResult (*port_set_param) (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - const SpaParam *param); + int (*port_enum_params) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + uint32_t index, + struct spa_param **param); + int (*port_set_param) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + const struct spa_param *param); /** - * SpaNode::port_use_buffers: - * @node: a #SpaNode - * @direction: a #SpaDirection + * struct spa_node::port_use_buffers: + * @node: a #struct spa_node + * @direction: a #enum spa_direction * @port_id: a port id * @buffers: an array of buffer pointers * @n_buffers: number of elements in @buffers @@ -448,15 +448,15 @@ struct _SpaNode { * Returns: #SPA_RESULT_OK on success * #SPA_RESULT_ASYNC the function is executed asynchronously */ - SpaResult (*port_use_buffers) (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers); + int (*port_use_buffers) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers); /** - * SpaNode::port_alloc_buffers: - * @node: a #SpaNode - * @direction: a #SpaDirection + * struct spa_node::port_alloc_buffers: + * @node: a #struct spa_node + * @direction: a #enum spa_direction * @port_id: a port id * @params: allocation parameters * @n_params: number of elements in @params @@ -480,7 +480,7 @@ struct _SpaNode { * node to PAUSED, when the node has enough buffers on all ports. * * Once the port has allocated buffers, the memory of the buffers can be - * released again by calling SpaNode::port_use_buffers with %NULL. + * released again by calling struct spa_node::port_use_buffers with %NULL. * * This function must be called from the main thread. * @@ -488,19 +488,19 @@ struct _SpaNode { * #SPA_RESULT_ERROR when the node already has allocated buffers. * #SPA_RESULT_ASYNC the function is executed asynchronously */ - SpaResult (*port_alloc_buffers) (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers); + int (*port_alloc_buffers) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers); /** - * SpaNode::port_set_io: - * @direction: a #SpaDirection + * struct spa_node::port_set_io: + * @direction: a #enum spa_direction * @port_id: a port id - * @io: a #SpaPortIO + * @io: a #struct spa_port_io * * Configure the given io structure on @port_id. This * structure is allocated by the host and is used to query the state @@ -510,14 +510,14 @@ struct _SpaNode { * * Returns: #SPA_RESULT_OK on success */ - SpaResult (*port_set_io) (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaPortIO *io); + int (*port_set_io) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_port_io *io); /** - * SpaNode::port_reuse_buffer: - * @node: a #SpaNode + * struct spa_node::port_reuse_buffer: + * @node: a #struct spa_node * @port_id: a port id * @buffer_id: a buffer id to reuse * @@ -528,74 +528,87 @@ struct _SpaNode { * Returns: #SPA_RESULT_OK on success * #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL */ - SpaResult (*port_reuse_buffer) (SpaNode *node, - uint32_t port_id, - uint32_t buffer_id); + int (*port_reuse_buffer) (struct spa_node *node, + uint32_t port_id, + uint32_t buffer_id); - SpaResult (*port_send_command) (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command); + int (*port_send_command) (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command); /** - * SpaNode::process_input: - * @node: a #SpaNode + * struct spa_node::process_input: + * @node: a #struct spa_node * * Process the input area of the node. * * For synchronous nodes, this function is called to start processing data - * or when process_output returned SPA_RESULT_NEED_MORE_INPUT + * or when process_output returned SPA_RESULT_NEED_BUFFER * * For Asynchronous node, this function is called when a NEED_INPUT event * is received from the node. * - * Before calling this function, you must configure SpaPortInput structures + * Before calling this function, you must configure spa_port_io structures * configured on the input ports. * - * The node will loop through all SpaPortInput structures and will - * process the buffers. For each port, the port info will be updated as: + * The node will loop through all spa_port_io structures and will + * process the buffers. For each port, the port io will be used as: * - * - The buffer_id is set to SPA_ID_INVALID and the status is set to - * SPA_RESULT_OK when the buffer was successfully consumed + * - if status is set to HAVE_BUFFER, buffer_id is read and processed. * - * - The buffer_id is untouched and the status is set to an error when - * the buffer was invalid. + * The spa_port_io of the port is then updated as follows. * - * - The buffer_id is untouched and the status is set to SPA_RESULT_OK - * when no input was consumed. This can happen when the node does not - * need input on this port. + * - buffer_id is set to a buffer id that should be reused. SPA_ID_INVALID + * is set when there is no buffer to reuse + * + * - status is set to SPA_RESULT_OK when no new buffer is needed + * + * - status is set to SPA_RESULT_NEED_BUFFER when a new buffer is needed + * on the pad. + * + * - status is set to an error code when the buffer_id was invalid or any + * processing error happened on the port. * * Returns: #SPA_RESULT_OK on success or when the node is asynchronous - * #SPA_RESULT_HAVE_OUTPUT for synchronous nodes when output + * #SPA_RESULT_HAVE_BUFFER for synchronous nodes when output * can be consumed. - * #SPA_RESULT_OUT_OF_BUFFERS for synchronous nodes when buffers - * should be released with port_reuse_buffer * #SPA_RESULT_ERROR when one of the inputs is in error */ - SpaResult (*process_input) (SpaNode *node); + int (*process_input) (struct spa_node *node); /** - * SpaNode::process_output: - * @node: a #SpaNode + * struct spa_node::process_output: + * @node: a #struct spa_node * - * Tell the node to produce more output. - * - * Before calling this function you must process the buffers and events - * in the SpaPortOutput structure and set the buffer_id to SPA_ID_INVALID - * for all consumed buffers. Buffers that you do not want to consume should - * be returned to the node with port_reuse_buffer. + * Tell the node that output is consumed. * * For synchronous nodes, this function can be called when process_input - * returned #SPA_RESULT_HAVE_ENOUGH_INPUT. + * returned #SPA_RESULT_HAVE_BUFFER. * * For Asynchronous node, this function is called when a HAVE_OUTPUT event * is received from the node. * + * Before calling this function you must process the buffers + * in each of the output ports spa_port_io structure as follows: + * + * - use the buffer_id from the io for all the ports where the status is + * SPA_RESULT_HAVE_BUFFER + * + * - set buffer_id to a buffer_id you would like to reuse or SPA_ID_INVALID + * when no buffer is to be reused. + * + * - set the status to SPA_RESULT_NEED_BUFFER for all port you want more + * output from + * + * - set the status to SPA_RESULT_OK for the port you don't want more + * buffer from. + * * Returns: #SPA_RESULT_OK on success or when the node is asynchronous - * #SPA_RESULT_NEED_INPUT for synchronous nodes when input + * #SPA_RESULT_NEED_BUFFER for synchronous nodes when input * is needed. * #SPA_RESULT_ERROR when one of the outputs is in error */ - SpaResult (*process_output) (SpaNode *node); + int (*process_output) (struct spa_node *node); }; #define spa_node_get_props(n,...) (n)->get_props((n),__VA_ARGS__) diff --git a/spa/include/spa/param-alloc.h b/spa/include/spa/param-alloc.h index 073a68312..e2bde2b6e 100644 --- a/spa/include/spa/param-alloc.h +++ b/spa/include/spa/param-alloc.h @@ -39,16 +39,17 @@ extern "C" { #define SPA_TYPE_PARAM_ALLOC_BUFFERS__buffers SPA_TYPE_PARAM_ALLOC_BUFFERS_BASE "buffers" #define SPA_TYPE_PARAM_ALLOC_BUFFERS__align SPA_TYPE_PARAM_ALLOC_BUFFERS_BASE "align" -typedef struct { +struct spa_type_param_alloc_buffers { uint32_t Buffers; uint32_t size; uint32_t stride; uint32_t buffers; uint32_t align; -} SpaTypeParamAllocBuffers; +}; static inline void -spa_type_param_alloc_buffers_map (SpaTypeMap *map, SpaTypeParamAllocBuffers *type) +spa_type_param_alloc_buffers_map (struct spa_type_map *map, + struct spa_type_param_alloc_buffers *type) { if (type->Buffers == 0) { type->Buffers = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC__Buffers); @@ -69,7 +70,7 @@ spa_type_param_alloc_buffers_map (SpaTypeMap *map, SpaTypeParamAllocBuffers *typ #define SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferBlocks SPA_TYPE_PARAM_ALLOC_META_ENABLE_BASE "ringbufferBlocks" #define SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferAlign SPA_TYPE_PARAM_ALLOC_META_ENABLE_BASE "ringbufferAlign" -typedef struct { +struct spa_type_param_alloc_meta_enable { uint32_t MetaEnable; uint32_t type; uint32_t size; @@ -77,19 +78,20 @@ typedef struct { uint32_t ringbufferStride; uint32_t ringbufferBlocks; uint32_t ringbufferAlign; -} SpaTypeParamAllocMetaEnable; +}; static inline void -spa_type_param_alloc_meta_enable_map (SpaTypeMap *map, SpaTypeParamAllocMetaEnable *type) +spa_type_param_alloc_meta_enable_map (struct spa_type_map *map, + struct spa_type_param_alloc_meta_enable *type) { if (type->MetaEnable == 0) { - type->MetaEnable = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC__MetaEnable); - type->type = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__type); - type->size = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__size); - type->ringbufferSize = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferSize); - type->ringbufferStride = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferStride); - type->ringbufferBlocks = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferBlocks); - type->ringbufferAlign = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferAlign); + type->MetaEnable = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC__MetaEnable); + type->type = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__type); + type->size = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__size); + type->ringbufferSize = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferSize); + type->ringbufferStride = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferStride); + type->ringbufferBlocks = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferBlocks); + type->ringbufferAlign = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferAlign); } } @@ -105,28 +107,29 @@ spa_type_param_alloc_meta_enable_map (SpaTypeMap *map, SpaTypeParamAllocMetaEnab #define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign2 SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE "strideAlign2" #define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign3 SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE "strideAlign3" -typedef struct { +struct spa_type_param_alloc_video_padding { uint32_t VideoPadding; uint32_t top; uint32_t bottom; uint32_t left; uint32_t right; uint32_t strideAlign[4]; -} SpaTypeParamAllocVideoPadding; +}; static inline void -spa_type_param_alloc_video_padding_map (SpaTypeMap *map, SpaTypeParamAllocVideoPadding *type) +spa_type_param_alloc_video_padding_map (struct spa_type_map *map, + struct spa_type_param_alloc_video_padding *type) { if (type->VideoPadding == 0) { - type->VideoPadding = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC__VideoPadding); - type->top = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__top); - type->bottom = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__bottom); - type->left = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__left); - type->right = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__right); - type->strideAlign[0] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign0); - type->strideAlign[1] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign1); - type->strideAlign[2] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign2); - type->strideAlign[3] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign3); + type->VideoPadding = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC__VideoPadding); + type->top = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__top); + type->bottom = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__bottom); + type->left = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__left); + type->right = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__right); + type->strideAlign[0] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign0); + type->strideAlign[1] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign1); + type->strideAlign[2] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign2); + type->strideAlign[3] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign3); } } diff --git a/spa/include/spa/param.h b/spa/include/spa/param.h index 474fe383e..dc0442dab 100644 --- a/spa/include/spa/param.h +++ b/spa/include/spa/param.h @@ -24,49 +24,43 @@ extern "C" { #endif -typedef struct _SpaParam SpaParam; #include #include +struct spa_param; #define SPA_TYPE__Param SPA_TYPE_POD_OBJECT_BASE "Param" #define SPA_TYPE_PARAM_BASE SPA_TYPE__Param ":" -typedef struct { - SpaPODObjectBody body; - /* SpaPODProp follow */ -} SpaParamBody; - -struct _SpaParam { - SpaPOD pod; - SpaParamBody body; +struct spa_param { + struct spa_pod_object object; }; static inline uint32_t -spa_param_query (const SpaParam *param, uint32_t key, ...) +spa_param_query (const struct spa_param *param, uint32_t key, ...) { uint32_t count; va_list args; va_start (args, key); - count = spa_pod_contents_queryv (¶m->pod, sizeof (SpaParam), key, args); + count = spa_pod_contents_queryv (¶m->object.pod, sizeof (struct spa_param), key, args); va_end (args); return count; } #define SPA_PARAM_BODY_FOREACH(body, size, iter) \ - for ((iter) = SPA_MEMBER ((body), sizeof (SpaParamBody), SpaPODProp); \ - (iter) < SPA_MEMBER ((body), (size), SpaPODProp); \ - (iter) = SPA_MEMBER ((iter), SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), SpaPODProp)) + for ((iter) = SPA_MEMBER ((body), sizeof (struct spa_pod_object_body), struct spa_pod_prop); \ + (iter) < SPA_MEMBER ((body), (size), struct spa_pod_prop); \ + (iter) = SPA_MEMBER ((iter), SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), struct spa_pod_prop)) #define SPA_PARAM_FOREACH(param, iter) \ - SPA_PARAM_BODY_FOREACH(¶m->body, SPA_POD_BODY_SIZE(param), iter) + SPA_PARAM_BODY_FOREACH(¶m->object.body, SPA_POD_BODY_SIZE(param), iter) -static inline SpaResult -spa_param_fixate (SpaParam *param) +static inline int +spa_param_fixate (struct spa_param *param) { - SpaPODProp *prop; + struct spa_pod_prop *prop; SPA_PARAM_FOREACH (param, prop) prop->body.flags &= ~SPA_POD_PROP_FLAG_UNSET; diff --git a/spa/include/spa/plugin.h b/spa/include/spa/plugin.h index a5c42ce2d..6ec53d18d 100644 --- a/spa/include/spa/plugin.h +++ b/spa/include/spa/plugin.h @@ -30,15 +30,12 @@ extern "C" { #define SPA_TYPE__Handle SPA_TYPE_INTERFACE_BASE "Handle" #define SPA_TYPE__HandleFactory SPA_TYPE_INTERFACE_BASE "HandleFactory" -typedef struct _SpaHandle SpaHandle; -typedef struct _SpaHandleFactory SpaHandleFactory; - -struct _SpaHandle { +struct spa_handle { /* user_data that can be set by the application */ void * user_data; /** - * SpaHandle::get_interface: - * @handle: a #SpaHandle + * spa_handle::get_interface: + * @handle: a #spa_handle * @interface_id: the interface id * @interface: result to hold the interface. * @@ -48,11 +45,11 @@ struct _SpaHandle { * #SPA_RESULT_NOT_IMPLEMENTED when there are no extensions * #SPA_RESULT_INVALID_ARGUMENTS when handle or info is %NULL */ - SpaResult (*get_interface) (SpaHandle *handle, - uint32_t interface_id, - void **interface); + int (*get_interface) (struct spa_handle *handle, + uint32_t interface_id, + void **interface); /** - * SpaHandle::clear + * spa_handle::clear * @handle: a pointer to memory * * Clean up the memory of @handle. After this, @handle should not be used @@ -60,67 +57,67 @@ struct _SpaHandle { * * Returns: #SPA_RESULT_OK on success */ - SpaResult (*clear) (SpaHandle *handle); + int (*clear) (struct spa_handle *handle); }; #define spa_handle_get_interface(h,...) (h)->get_interface((h),__VA_ARGS__) #define spa_handle_clear(h) (h)->clear((h)) /** - * SpaInterfaceInfo: + * struct spa_interface_info: * @type: the type of the interface, can be used to get the interface * * This structure lists the information about available interfaces on * handles. */ -typedef struct { +struct spa_interface_info { const char *type; -} SpaInterfaceInfo; +}; /** - * SpaSupport: + * struct spa_support: * @type: the type of the support item * @data: specific data for the item * * Extra supporting infrastructure passed to the init() function of * a factory. It can be extra information or interfaces such as logging. */ -typedef struct { +struct spa_support { const char *type; void *data; -} SpaSupport; +}; -struct _SpaHandleFactory { +struct spa_handle_factory { /** - * SpaHandleFactory::name + * spa_handle_factory::name * * The name */ const char * name; /** - * SpaHandleFactory::info + * spa_handle_factory::info * * Extra information about the handles of this factory. */ - const SpaDict * info; + const struct spa_dict * info; /** - * SpaHandleFactory::size + * spa_handle_factory::size * * The size of handles from this factory */ const size_t size; /** - * SpaHandleFactory::init - * @factory: a #SpaHandleFactory + * spa_handle_factory::init + * @factory: a #spa_handle_factory * @handle: a pointer to memory * @info: extra handle specific information, usually obtained - * from a #SpaMonitor. This can be used to configure the handle. + * from a #spa_monitor. This can be used to configure the handle. * @support: support items * @n_support: number of elements in @support * * Initialize an instance of this factory. The caller should allocate - * memory at least SpaHandleFactory::size bytes and pass this as @handle. + * memory at least spa_handle_factory::size bytes and pass this as @handle. * * @support can optionally contain extra interfaces or data ites that the * plugin can use such as a logger. @@ -129,16 +126,16 @@ struct _SpaHandleFactory { * #SPA_RESULT_NOT_IMPLEMENTED when an instance can't be made * #SPA_RESULT_INVALID_ARGUMENTS when factory or handle are %NULL */ - SpaResult (*init) (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, - uint32_t n_support); + int (*init) (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, + uint32_t n_support); /** - * SpaHandle::enum_interface_info: - * @factory: a #SpaHandleFactory - * @info: result to hold SpaInterfaceInfo. + * spa_handle_factory::enum_interface_info: + * @factory: a #spa_handle_factory + * @info: result to hold spa_interface_info. * @index: index to keep track of the enumeration, 0 for first item * * Enumerate the interface information for @factory. @@ -148,16 +145,16 @@ struct _SpaHandleFactory { * #SPA_RESULT_INVALID_ARGUMENTS when handle or info is %NULL * #SPA_RESULT_ENUM_END when there are no more infos */ - SpaResult (*enum_interface_info) (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, - uint32_t index); + int (*enum_interface_info) (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, + uint32_t index); }; #define spa_handle_factory_init(h,...) (h)->init((h),__VA_ARGS__) #define spa_handle_factory_enum_interface_info(h,...) (h)->enum_interface_info((h),__VA_ARGS__) /** - * SpaEnumHandleFactoryFunc: + * spa_handle_factory_enum_func_t: * @factory: a location to hold the factory result * @index: index to keep track of the enumeration * @@ -167,11 +164,13 @@ struct _SpaHandleFactory { * #SPA_RESULT_INVALID_ARGUMENTS when factory is %NULL * #SPA_RESULT_ENUM_END when there are no more factories */ -typedef SpaResult (*SpaEnumHandleFactoryFunc) (const SpaHandleFactory **factory, - uint32_t index); +typedef int (*spa_handle_factory_enum_func_t) (const struct spa_handle_factory **factory, + uint32_t index); + +#define SPA_HANDLE_FACTORY_ENUM_FUNC_NAME "spa_handle_factory_enum" /** - * spa_enum_handle_factory: + * spa_handle_factory_enum: * @factory: a location to hold the factory result * @index: index to keep track of the enumeration * @@ -181,8 +180,8 @@ typedef SpaResult (*SpaEnumHandleFactoryFunc) (const SpaHandleFactory **factory, * #SPA_RESULT_INVALID_ARGUMENTS when factory is %NULL * #SPA_RESULT_ENUM_END when there are no more factories */ -SpaResult spa_enum_handle_factory (const SpaHandleFactory **factory, - uint32_t index); +int spa_handle_factory_enum (const struct spa_handle_factory **factory, + uint32_t index); #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/include/spa/pod-builder.h b/spa/include/spa/pod-builder.h index 23c364d26..c1e08e19d 100644 --- a/spa/include/spa/pod-builder.h +++ b/spa/include/spa/pod-builder.h @@ -28,30 +28,30 @@ extern "C" { #include #include -typedef struct _SpaPODFrame { - struct _SpaPODFrame *parent; - SpaPOD pod; - uint32_t ref; -} SpaPODFrame; +struct spa_pod_frame { + struct spa_pod_frame *parent; + struct spa_pod pod; + uint32_t ref; +}; -typedef struct _SpaPODBuilder { +struct spa_pod_builder { void *data; uint32_t size; uint32_t offset; - SpaPODFrame *stack; - uint32_t (*write) (struct _SpaPODBuilder *builder, uint32_t ref, const void *data, uint32_t size); + struct spa_pod_frame *stack; + uint32_t (*write) (struct spa_pod_builder *builder, uint32_t ref, const void *data, uint32_t size); bool in_array; bool first; -} SpaPODBuilder; +}; #define SPA_POD_BUILDER_INIT(buffer,size) { buffer, size, } #define SPA_POD_BUILDER_DEREF(b,ref,type) SPA_MEMBER ((b)->data, (ref), type) static inline void -spa_pod_builder_init (SpaPODBuilder *builder, - void *data, - uint32_t size) +spa_pod_builder_init (struct spa_pod_builder *builder, + void *data, + uint32_t size) { builder->data = data; builder->size = size; @@ -60,10 +60,10 @@ spa_pod_builder_init (SpaPODBuilder *builder, } static inline uint32_t -spa_pod_builder_push (SpaPODBuilder *builder, - SpaPODFrame *frame, - const SpaPOD *pod, - uint32_t ref) +spa_pod_builder_push (struct spa_pod_builder *builder, + struct spa_pod_frame *frame, + const struct spa_pod *pod, + uint32_t ref) { frame->parent = builder->stack; frame->pod = *pod; @@ -75,10 +75,10 @@ spa_pod_builder_push (SpaPODBuilder *builder, } static inline uint32_t -spa_pod_builder_raw (SpaPODBuilder *builder, const void *data, uint32_t size) +spa_pod_builder_raw (struct spa_pod_builder *builder, const void *data, uint32_t size) { uint32_t ref; - SpaPODFrame *f; + struct spa_pod_frame *f; if (builder->write) { ref = builder->write (builder, -1, data, size); @@ -98,7 +98,7 @@ spa_pod_builder_raw (SpaPODBuilder *builder, const void *data, uint32_t size) } static void -spa_pod_builder_pad (SpaPODBuilder *builder, uint32_t size) +spa_pod_builder_pad (struct spa_pod_builder *builder, uint32_t size) { uint64_t zeroes = 0; size = SPA_ROUND_UP_N (size, 8) - size; @@ -107,7 +107,7 @@ spa_pod_builder_pad (SpaPODBuilder *builder, uint32_t size) } static inline uint32_t -spa_pod_builder_raw_padded (SpaPODBuilder *builder, const void *data, uint32_t size) +spa_pod_builder_raw_padded (struct spa_pod_builder *builder, const void *data, uint32_t size) { uint32_t ref = size ? spa_pod_builder_raw (builder, data, size) : -1; spa_pod_builder_pad (builder, size); @@ -115,14 +115,14 @@ spa_pod_builder_raw_padded (SpaPODBuilder *builder, const void *data, uint32_t s } static inline void -spa_pod_builder_pop (SpaPODBuilder *builder, - SpaPODFrame *frame) +spa_pod_builder_pop (struct spa_pod_builder *builder, + struct spa_pod_frame *frame) { if (frame->ref != -1) { if (builder->write) - builder->write (builder, frame->ref, &frame->pod, sizeof(SpaPOD)); + builder->write (builder, frame->ref, &frame->pod, sizeof(struct spa_pod)); else - memcpy (builder->data + frame->ref, &frame->pod, sizeof(SpaPOD)); + memcpy (builder->data + frame->ref, &frame->pod, sizeof(struct spa_pod)); } builder->stack = frame->parent; builder->in_array = (builder->stack && (builder->stack->pod.type == SPA_POD_TYPE_ARRAY || @@ -131,7 +131,7 @@ spa_pod_builder_pop (SpaPODBuilder *builder, } static inline uint32_t -spa_pod_builder_primitive (SpaPODBuilder *builder, const SpaPOD *p) +spa_pod_builder_primitive (struct spa_pod_builder *builder, const struct spa_pod *p) { const void *data; uint32_t size, ref; @@ -153,63 +153,63 @@ spa_pod_builder_primitive (SpaPODBuilder *builder, const SpaPOD *p) #define SPA_POD_BOOL_INIT(val) { { sizeof (uint32_t), SPA_POD_TYPE_BOOL }, val ? 1 : 0 } static inline uint32_t -spa_pod_builder_bool (SpaPODBuilder *builder, bool val) +spa_pod_builder_bool (struct spa_pod_builder *builder, bool val) { - const SpaPODBool p = SPA_POD_BOOL_INIT (val); + const struct spa_pod_bool p = SPA_POD_BOOL_INIT (val); return spa_pod_builder_primitive (builder, &p.pod); } #define SPA_POD_ID_INIT(val) { { sizeof (uint32_t), SPA_POD_TYPE_ID }, val } static inline uint32_t -spa_pod_builder_id (SpaPODBuilder *builder, uint32_t val) +spa_pod_builder_id (struct spa_pod_builder *builder, uint32_t val) { - const SpaPODId p = SPA_POD_ID_INIT (val); + const struct spa_pod_id p = SPA_POD_ID_INIT (val); return spa_pod_builder_primitive (builder, &p.pod); } #define SPA_POD_INT_INIT(val) { { sizeof (uint32_t), SPA_POD_TYPE_INT }, val } static inline uint32_t -spa_pod_builder_int (SpaPODBuilder *builder, int32_t val) +spa_pod_builder_int (struct spa_pod_builder *builder, int32_t val) { - const SpaPODInt p = SPA_POD_INT_INIT (val); + const struct spa_pod_int p = SPA_POD_INT_INIT (val); return spa_pod_builder_primitive (builder, &p.pod); } #define SPA_POD_LONG_INIT(val) { { sizeof (uint64_t), SPA_POD_TYPE_LONG }, val } static inline uint32_t -spa_pod_builder_long (SpaPODBuilder *builder, int64_t val) +spa_pod_builder_long (struct spa_pod_builder *builder, int64_t val) { - const SpaPODLong p = SPA_POD_LONG_INIT (val); + const struct spa_pod_long p = SPA_POD_LONG_INIT (val); return spa_pod_builder_primitive (builder, &p.pod); } #define SPA_POD_FLOAT_INIT(val) { { sizeof (float), SPA_POD_TYPE_FLOAT }, val } static inline uint32_t -spa_pod_builder_float (SpaPODBuilder *builder, float val) +spa_pod_builder_float (struct spa_pod_builder *builder, float val) { - const SpaPODFloat p = SPA_POD_FLOAT_INIT (val); + const struct spa_pod_float p = SPA_POD_FLOAT_INIT (val); return spa_pod_builder_primitive (builder, &p.pod); } #define SPA_POD_DOUBLE_INIT(val) { { sizeof (double), SPA_POD_TYPE_DOUBLE }, val } static inline uint32_t -spa_pod_builder_double (SpaPODBuilder *builder, double val) +spa_pod_builder_double (struct spa_pod_builder *builder, double val) { - const SpaPODDouble p = SPA_POD_DOUBLE_INIT (val); + const struct spa_pod_double p = SPA_POD_DOUBLE_INIT (val); return spa_pod_builder_primitive (builder, &p.pod); } #define SPA_POD_STRING_INIT(len) { { len, SPA_POD_TYPE_STRING } } static inline uint32_t -spa_pod_builder_string_len (SpaPODBuilder *builder, const char *str, uint32_t len) +spa_pod_builder_string_len (struct spa_pod_builder *builder, const char *str, uint32_t len) { - const SpaPODString p = SPA_POD_STRING_INIT (len); + const struct spa_pod_string p = SPA_POD_STRING_INIT (len); uint32_t ref = spa_pod_builder_raw (builder, &p, sizeof (p)); if (spa_pod_builder_raw_padded (builder, str, len) == -1) ref = -1; @@ -217,7 +217,7 @@ spa_pod_builder_string_len (SpaPODBuilder *builder, const char *str, uint32_t le } static inline uint32_t -spa_pod_builder_string (SpaPODBuilder *builder, const char *str) +spa_pod_builder_string (struct spa_pod_builder *builder, const char *str) { uint32_t len = str ? strlen (str) : 0; return spa_pod_builder_string_len (builder, str ? str : "", len + 1); @@ -226,60 +226,60 @@ spa_pod_builder_string (SpaPODBuilder *builder, const char *str) #define SPA_POD_BYTES_INIT(len) { { len, SPA_POD_TYPE_BYTES } } static inline uint32_t -spa_pod_builder_bytes (SpaPODBuilder *builder, const void *bytes, uint32_t len) +spa_pod_builder_bytes (struct spa_pod_builder *builder, const void *bytes, uint32_t len) { - const SpaPODBytes p = SPA_POD_BYTES_INIT (len); + const struct spa_pod_bytes p = SPA_POD_BYTES_INIT (len); uint32_t ref = spa_pod_builder_raw (builder, &p, sizeof (p)); if (spa_pod_builder_raw_padded (builder, bytes, len) == -1) ref = -1; return ref; } -#define SPA_POD_POINTER_INIT(type,value) { { sizeof (SpaPODPointerBody), SPA_POD_TYPE_POINTER }, { type, value } } +#define SPA_POD_POINTER_INIT(type,value) { { sizeof (struct spa_pod_pointer_body), SPA_POD_TYPE_POINTER }, { type, value } } static inline uint32_t -spa_pod_builder_pointer (SpaPODBuilder *builder, uint32_t type, void *val) +spa_pod_builder_pointer (struct spa_pod_builder *builder, uint32_t type, void *val) { - const SpaPODPointer p = SPA_POD_POINTER_INIT (type, val); + const struct spa_pod_pointer p = SPA_POD_POINTER_INIT (type, val); return spa_pod_builder_primitive (builder, &p.pod); } -#define SPA_POD_RECTANGLE_INIT(width,height) { { sizeof (SpaRectangle), SPA_POD_TYPE_RECTANGLE }, { width, height } } +#define SPA_POD_RECTANGLE_INIT(width,height) { { sizeof (struct spa_rectangle), SPA_POD_TYPE_RECTANGLE }, { width, height } } static inline uint32_t -spa_pod_builder_rectangle (SpaPODBuilder *builder, uint32_t width, uint32_t height) +spa_pod_builder_rectangle (struct spa_pod_builder *builder, uint32_t width, uint32_t height) { - const SpaPODRectangle p = SPA_POD_RECTANGLE_INIT (width, height); + const struct spa_pod_rectangle p = SPA_POD_RECTANGLE_INIT (width, height); return spa_pod_builder_primitive (builder, &p.pod); } -#define SPA_POD_FRACTION_INIT(num,denom) { { sizeof (SpaFraction), SPA_POD_TYPE_FRACTION }, { num, denom } } +#define SPA_POD_FRACTION_INIT(num,denom) { { sizeof (struct spa_fraction), SPA_POD_TYPE_FRACTION }, { num, denom } } static inline uint32_t -spa_pod_builder_fraction (SpaPODBuilder *builder, uint32_t num, uint32_t denom) +spa_pod_builder_fraction (struct spa_pod_builder *builder, uint32_t num, uint32_t denom) { - const SpaPODFraction p = SPA_POD_FRACTION_INIT (num, denom); + const struct spa_pod_fraction p = SPA_POD_FRACTION_INIT (num, denom); return spa_pod_builder_primitive (builder, &p.pod); } static inline uint32_t -spa_pod_builder_push_array (SpaPODBuilder *builder, - SpaPODFrame *frame) +spa_pod_builder_push_array (struct spa_pod_builder *builder, + struct spa_pod_frame *frame) { - const SpaPODArray p = { { sizeof (SpaPODArrayBody) - sizeof (SpaPOD), SPA_POD_TYPE_ARRAY }, { { 0, 0 } } }; + const struct spa_pod_array p = { { sizeof (struct spa_pod_array_body) - sizeof (struct spa_pod), SPA_POD_TYPE_ARRAY }, { { 0, 0 } } }; return spa_pod_builder_push (builder, frame, &p.pod, - spa_pod_builder_raw (builder, &p, sizeof(p) - sizeof(SpaPOD))); + spa_pod_builder_raw (builder, &p, sizeof(p) - sizeof(struct spa_pod))); } static inline uint32_t -spa_pod_builder_array (SpaPODBuilder *builder, +spa_pod_builder_array (struct spa_pod_builder *builder, uint32_t child_size, uint32_t child_type, uint32_t n_elems, const void *elems) { - const SpaPODArray p = { - { sizeof (SpaPODArrayBody) + n_elems * child_size, SPA_POD_TYPE_ARRAY }, + const struct spa_pod_array p = { + { sizeof (struct spa_pod_array_body) + n_elems * child_size, SPA_POD_TYPE_ARRAY }, { { child_size, child_type } } }; uint32_t ref = spa_pod_builder_raw (builder, &p, sizeof(p)); @@ -291,10 +291,10 @@ spa_pod_builder_array (SpaPODBuilder *builder, #define SPA_POD_STRUCT_INIT(size) { { size, SPA_POD_TYPE_STRUCT } } static inline uint32_t -spa_pod_builder_push_struct (SpaPODBuilder *builder, - SpaPODFrame *frame) +spa_pod_builder_push_struct (struct spa_pod_builder *builder, + struct spa_pod_frame *frame) { - const SpaPODStruct p = SPA_POD_STRUCT_INIT (0); + const struct spa_pod_struct p = SPA_POD_STRUCT_INIT (0); return spa_pod_builder_push (builder, frame, &p.pod, spa_pod_builder_raw (builder, &p, sizeof(p))); } @@ -303,51 +303,52 @@ spa_pod_builder_push_struct (SpaPODBuilder *builder, #define SPA_POD_OBJECT_INIT_COMPLEX(size,id,type,...) { { size, SPA_POD_TYPE_OBJECT }, { id, type }, __VA_ARGS__ } static inline uint32_t -spa_pod_builder_push_object (SpaPODBuilder *builder, - SpaPODFrame *frame, +spa_pod_builder_push_object (struct spa_pod_builder *builder, + struct spa_pod_frame *frame, uint32_t id, uint32_t type) { - const SpaPODObject p = SPA_POD_OBJECT_INIT (sizeof (SpaPODObjectBody), id, type); + const struct spa_pod_object p = SPA_POD_OBJECT_INIT (sizeof (struct spa_pod_object_body), id, type); return spa_pod_builder_push (builder, frame, &p.pod, spa_pod_builder_raw (builder, &p, sizeof(p))); } static inline uint32_t -spa_pod_builder_push_prop (SpaPODBuilder *builder, - SpaPODFrame *frame, +spa_pod_builder_push_prop (struct spa_pod_builder *builder, + struct spa_pod_frame *frame, uint32_t key, uint32_t flags) { - const SpaPODProp p = { { sizeof (SpaPODPropBody) - sizeof(SpaPOD), SPA_POD_TYPE_PROP}, - { key, flags, { 0, 0 } } }; + const struct spa_pod_prop p = { { sizeof (struct spa_pod_prop_body) - + sizeof(struct spa_pod), SPA_POD_TYPE_PROP}, + { key, flags, { 0, 0 } } }; return spa_pod_builder_push (builder, frame, &p.pod, - spa_pod_builder_raw (builder, &p, sizeof(p) - sizeof(SpaPOD))); + spa_pod_builder_raw (builder, &p, sizeof(p) - sizeof(struct spa_pod))); } static inline void -spa_pod_builder_addv (SpaPODBuilder *builder, +spa_pod_builder_addv (struct spa_pod_builder *builder, uint32_t type, va_list args) { uint32_t n_values = 0; union { - SpaPOD pod; - SpaPODBool bool_pod; - SpaPODId id_pod; - SpaPODInt int_pod; - SpaPODLong long_pod; - SpaPODFloat float_pod; - SpaPODDouble double_pod; - SpaPODString string_pod; - SpaPODBytes bytes_pod; - SpaPODPointer pointer_pod; - SpaPODRectangle rectangle_pod; - SpaPODFraction fraction_pod; - SpaPODArray array_pod; - SpaPODStruct struct_pod; - SpaPODObject object_pod; - SpaPODProp prop_pod; + struct spa_pod pod; + struct spa_pod_bool bool_pod; + struct spa_pod_id id_pod; + struct spa_pod_int int_pod; + struct spa_pod_long long_pod; + struct spa_pod_float float_pod; + struct spa_pod_double double_pod; + struct spa_pod_string string_pod; + struct spa_pod_bytes bytes_pod; + struct spa_pod_pointer pointer_pod; + struct spa_pod_rectangle rectangle_pod; + struct spa_pod_fraction fraction_pod; + struct spa_pod_array array_pod; + struct spa_pod_struct struct_pod; + struct spa_pod_object object_pod; + struct spa_pod_prop prop_pod; } head; uint32_t head_size; const void *body; @@ -355,7 +356,7 @@ spa_pod_builder_addv (SpaPODBuilder *builder, static const uint64_t zeroes = 0; while (type != SPA_POD_TYPE_INVALID) { - SpaPODFrame *f = NULL; + struct spa_pod_frame *f = NULL; const void *data[3]; uint32_t size[3], ref, i, n_sizes = 0; @@ -368,28 +369,28 @@ spa_pod_builder_addv (SpaPODBuilder *builder, head.int_pod.pod.type = type; head.int_pod.pod.size = body_size = sizeof (uint32_t); head.int_pod.value = va_arg (args, int); - head_size = sizeof (SpaPOD); + head_size = sizeof (struct spa_pod); body = &head.int_pod.value; goto primitive; case SPA_POD_TYPE_LONG: head.long_pod.pod.type = SPA_POD_TYPE_LONG; head.long_pod.pod.size = body_size = sizeof (uint32_t); head.long_pod.value = va_arg (args, int64_t); - head_size = sizeof (SpaPOD); + head_size = sizeof (struct spa_pod); body = &head.long_pod.value; goto primitive; case SPA_POD_TYPE_FLOAT: head.float_pod.pod.type = SPA_POD_TYPE_FLOAT; head.float_pod.pod.size = body_size = sizeof (float); head.float_pod.value = va_arg (args, double); - head_size = sizeof (SpaPOD); + head_size = sizeof (struct spa_pod); body = &head.float_pod.value; goto primitive; case SPA_POD_TYPE_DOUBLE: head.double_pod.pod.type = SPA_POD_TYPE_DOUBLE; head.double_pod.pod.size = body_size = sizeof (double); head.double_pod.value = va_arg (args, double); - head_size = sizeof (SpaPOD); + head_size = sizeof (struct spa_pod); body = &head.double_pod.value; goto primitive; case SPA_POD_TYPE_STRING: @@ -397,94 +398,94 @@ spa_pod_builder_addv (SpaPODBuilder *builder, body_size = body ? strlen (body) + 1 : (body = "", 1); head.string_pod.pod.type = SPA_POD_TYPE_STRING; head.string_pod.pod.size = body_size; - head_size = sizeof (SpaPOD); + head_size = sizeof (struct spa_pod); goto primitive; case -SPA_POD_TYPE_STRING: body = va_arg (args, const char *); body_size = va_arg (args, uint32_t); head.string_pod.pod.type = SPA_POD_TYPE_STRING; head.string_pod.pod.size = body_size; - head_size = sizeof (SpaPOD); + head_size = sizeof (struct spa_pod); goto primitive; case SPA_POD_TYPE_BYTES: body = va_arg (args, void *); body_size = va_arg (args, uint32_t); head.bytes_pod.pod.type = SPA_POD_TYPE_BYTES; head.bytes_pod.pod.size = body_size; - head_size = sizeof (SpaPOD); + head_size = sizeof (struct spa_pod); goto primitive; case SPA_POD_TYPE_POINTER: head.pointer_pod.pod.type = SPA_POD_TYPE_POINTER; - head.pointer_pod.pod.size = body_size = sizeof (SpaPODPointerBody); + head.pointer_pod.pod.size = body_size = sizeof (struct spa_pod_pointer_body); head.pointer_pod.body.type = va_arg (args, uint32_t); head.pointer_pod.body.value = va_arg (args, void *); - head_size = sizeof (SpaPOD); + head_size = sizeof (struct spa_pod); body = &head.pointer_pod.body; goto primitive; case SPA_POD_TYPE_RECTANGLE: head.rectangle_pod.pod.type = SPA_POD_TYPE_RECTANGLE; - head.rectangle_pod.pod.size = body_size = sizeof (SpaRectangle); + head.rectangle_pod.pod.size = body_size = sizeof (struct spa_rectangle); head.rectangle_pod.value.width = va_arg (args, uint32_t); head.rectangle_pod.value.height = va_arg (args, uint32_t); - head_size = sizeof (SpaPOD); + head_size = sizeof (struct spa_pod); body = &head.rectangle_pod.value; goto primitive; case -SPA_POD_TYPE_RECTANGLE: head.rectangle_pod.pod.type = SPA_POD_TYPE_RECTANGLE; - head.rectangle_pod.pod.size = body_size = sizeof (SpaRectangle); - head.rectangle_pod.value = *va_arg (args, SpaRectangle *); - head_size = sizeof (SpaPOD); + head.rectangle_pod.pod.size = body_size = sizeof (struct spa_rectangle); + head.rectangle_pod.value = *va_arg (args, struct spa_rectangle *); + head_size = sizeof (struct spa_pod); body = &head.rectangle_pod.value; goto primitive; case SPA_POD_TYPE_FRACTION: head.fraction_pod.pod.type = SPA_POD_TYPE_FRACTION; - head.fraction_pod.pod.size = body_size = sizeof (SpaFraction); + head.fraction_pod.pod.size = body_size = sizeof (struct spa_fraction); head.fraction_pod.value.num = va_arg (args, uint32_t); head.fraction_pod.value.denom = va_arg (args, uint32_t); - head_size = sizeof (SpaPOD); + head_size = sizeof (struct spa_pod); body = &head.fraction_pod.value; goto primitive; case -SPA_POD_TYPE_FRACTION: head.fraction_pod.pod.type = SPA_POD_TYPE_FRACTION; - head.fraction_pod.pod.size = body_size = sizeof (SpaFraction); - head.fraction_pod.value = *va_arg (args, SpaFraction *); - head_size = sizeof (SpaPOD); + head.fraction_pod.pod.size = body_size = sizeof (struct spa_fraction); + head.fraction_pod.value = *va_arg (args, struct spa_fraction *); + head_size = sizeof (struct spa_pod); body = &head.fraction_pod.value; goto primitive; case SPA_POD_TYPE_BITMASK: break; case SPA_POD_TYPE_ARRAY: - f = va_arg (args, SpaPODFrame *); + f = va_arg (args, struct spa_pod_frame *); type = va_arg (args, uint32_t); n_values = va_arg (args, uint32_t); head.array_pod.pod.type = SPA_POD_TYPE_ARRAY; head.array_pod.pod.size = 0; - head_size = sizeof(SpaPOD); + head_size = sizeof(struct spa_pod); body = NULL; goto primitive; case SPA_POD_TYPE_STRUCT: - f = va_arg (args, SpaPODFrame *); + f = va_arg (args, struct spa_pod_frame *); head.struct_pod.pod.type = SPA_POD_TYPE_STRUCT; head.struct_pod.pod.size = 0; - head_size = sizeof(SpaPOD); + head_size = sizeof(struct spa_pod); body = NULL; goto primitive; case SPA_POD_TYPE_OBJECT: - f = va_arg (args, SpaPODFrame *); + f = va_arg (args, struct spa_pod_frame *); head.object_pod.pod.type = SPA_POD_TYPE_OBJECT; - head.object_pod.pod.size = sizeof (SpaPODObjectBody); + head.object_pod.pod.size = sizeof (struct spa_pod_object_body); head.object_pod.body.id = va_arg (args, uint32_t); head.object_pod.body.type = va_arg (args, uint32_t); - head_size = sizeof(SpaPODObject); + head_size = sizeof(struct spa_pod_object); body = NULL; goto primitive; case SPA_POD_TYPE_PROP: - f = va_arg (args, SpaPODFrame *); + f = va_arg (args, struct spa_pod_frame *); head.prop_pod.pod.type = SPA_POD_TYPE_PROP; - head.prop_pod.pod.size = sizeof (SpaPODPropBody) - sizeof(SpaPOD); + head.prop_pod.pod.size = sizeof (struct spa_pod_prop_body) - sizeof(struct spa_pod); head.prop_pod.body.key = va_arg (args, uint32_t); head.prop_pod.body.flags = va_arg (args, uint32_t); - head_size = sizeof (SpaPODProp) - sizeof(SpaPOD); + head_size = sizeof (struct spa_pod_prop) - sizeof(struct spa_pod); body = NULL; type = va_arg (args, uint32_t); n_values = va_arg (args, uint32_t); @@ -493,7 +494,7 @@ spa_pod_builder_addv (SpaPODBuilder *builder, case -SPA_POD_TYPE_STRUCT: case -SPA_POD_TYPE_OBJECT: case -SPA_POD_TYPE_PROP: - f = va_arg (args, SpaPODFrame *); + f = va_arg (args, struct spa_pod_frame *); spa_pod_builder_pop (builder, f); break; case SPA_POD_TYPE_POD: @@ -535,8 +536,8 @@ extra: } static inline void -spa_pod_builder_add (SpaPODBuilder *builder, - uint32_t type, ...) +spa_pod_builder_add (struct spa_pod_builder *builder, + uint32_t type, ...) { va_list args; diff --git a/spa/include/spa/pod-iter.h b/spa/include/spa/pod-iter.h index e1a91e1a3..5f69204a5 100644 --- a/spa/include/spa/pod-iter.h +++ b/spa/include/spa/pod-iter.h @@ -29,14 +29,14 @@ extern "C" { #include #include -typedef struct { +struct spa_pod_iter { const void *data; uint32_t size; uint32_t offset; -} SpaPODIter; +}; static inline void -spa_pod_iter_contents (SpaPODIter *iter, const void *data, uint32_t size) +spa_pod_iter_contents (struct spa_pod_iter *iter, const void *data, uint32_t size) { iter->data = data; iter->size = size; @@ -44,40 +44,40 @@ spa_pod_iter_contents (SpaPODIter *iter, const void *data, uint32_t size) } static inline bool -spa_pod_iter_struct (SpaPODIter *iter, const void *data, uint32_t size) +spa_pod_iter_struct (struct spa_pod_iter *iter, const void *data, uint32_t size) { if (data == NULL || size < 8 || SPA_POD_SIZE (data) > size || SPA_POD_TYPE (data) != SPA_POD_TYPE_STRUCT) return false; - spa_pod_iter_contents (iter, SPA_POD_CONTENTS (SpaPODStruct, data), - SPA_POD_CONTENTS_SIZE (SpaPODStruct, data)); + spa_pod_iter_contents (iter, SPA_POD_CONTENTS (struct spa_pod_struct, data), + SPA_POD_CONTENTS_SIZE (struct spa_pod_struct, data)); return true; } static inline bool -spa_pod_iter_object (SpaPODIter *iter, const void *data, uint32_t size) +spa_pod_iter_object (struct spa_pod_iter *iter, const void *data, uint32_t size) { if (data == NULL || SPA_POD_SIZE (data) > size || SPA_POD_TYPE (data) != SPA_POD_TYPE_OBJECT) return false; - spa_pod_iter_contents (iter, SPA_POD_CONTENTS (SpaPODObject, data), - SPA_POD_CONTENTS_SIZE (SpaPODObject, data)); + spa_pod_iter_contents (iter, SPA_POD_CONTENTS (struct spa_pod_object, data), + SPA_POD_CONTENTS_SIZE (struct spa_pod_object, data)); return true; } static inline bool -spa_pod_iter_pod (SpaPODIter *iter, SpaPOD *pod) +spa_pod_iter_pod (struct spa_pod_iter *iter, struct spa_pod *pod) { void *data; uint32_t size; switch (SPA_POD_TYPE (pod)) { case SPA_POD_TYPE_STRUCT: - data = SPA_POD_CONTENTS (SpaPODStruct, pod); - size = SPA_POD_CONTENTS_SIZE (SpaPODStruct, pod); + data = SPA_POD_CONTENTS (struct spa_pod_struct, pod); + size = SPA_POD_CONTENTS_SIZE (struct spa_pod_struct, pod); break; case SPA_POD_TYPE_OBJECT: - data = SPA_POD_CONTENTS (SpaPODObject, pod); - size = SPA_POD_CONTENTS_SIZE (SpaPODObject, pod); + data = SPA_POD_CONTENTS (struct spa_pod_object, pod); + size = SPA_POD_CONTENTS_SIZE (struct spa_pod_object, pod); break; default: spa_pod_iter_contents (iter, NULL, 0); @@ -88,22 +88,22 @@ spa_pod_iter_pod (SpaPODIter *iter, SpaPOD *pod) } static inline bool -spa_pod_iter_has_next (SpaPODIter *iter) +spa_pod_iter_has_next (struct spa_pod_iter *iter) { return (iter->offset + 8 <= iter->size && - SPA_POD_SIZE (SPA_MEMBER (iter->data, iter->offset, SpaPOD)) <= iter->size); + SPA_POD_SIZE (SPA_MEMBER (iter->data, iter->offset, struct spa_pod)) <= iter->size); } -static inline SpaPOD * -spa_pod_iter_next (SpaPODIter *iter) +static inline struct spa_pod * +spa_pod_iter_next (struct spa_pod_iter *iter) { - SpaPOD *res = SPA_MEMBER (iter->data, iter->offset, SpaPOD); + struct spa_pod *res = SPA_MEMBER (iter->data, iter->offset, struct spa_pod); iter->offset += SPA_ROUND_UP_N (SPA_POD_SIZE (res), 8); return res; } -static inline SpaPOD * -spa_pod_iter_first (SpaPODIter *iter, SpaPOD *pod) +static inline struct spa_pod * +spa_pod_iter_first (struct spa_pod_iter *iter, struct spa_pod *pod) { if (!spa_pod_iter_pod (iter, pod) || !spa_pod_iter_has_next (iter)) @@ -112,14 +112,14 @@ spa_pod_iter_first (SpaPODIter *iter, SpaPOD *pod) } static inline bool -spa_pod_iter_getv (SpaPODIter *iter, +spa_pod_iter_getv (struct spa_pod_iter *iter, uint32_t type, va_list args) { bool res = true; while (type && (res = spa_pod_iter_has_next (iter))) { - SpaPOD *pod = spa_pod_iter_next (iter); + struct spa_pod *pod = spa_pod_iter_next (iter); SPA_POD_COLLECT (pod, type, args, error); @@ -131,7 +131,7 @@ error: } static inline bool -spa_pod_iter_get (SpaPODIter *iter, uint32_t type, ...) +spa_pod_iter_get (struct spa_pod_iter *iter, uint32_t type, ...) { va_list args; bool res; diff --git a/spa/include/spa/pod-utils.h b/spa/include/spa/pod-utils.h index 792a13357..3815ea91a 100644 --- a/spa/include/spa/pod-utils.h +++ b/spa/include/spa/pod-utils.h @@ -28,80 +28,80 @@ extern "C" { #include #include -#define SPA_POD_BODY_SIZE(pod) (((SpaPOD*)(pod))->size) -#define SPA_POD_TYPE(pod) (((SpaPOD*)(pod))->type) -#define SPA_POD_SIZE(pod) (sizeof(SpaPOD) + SPA_POD_BODY_SIZE(pod)) +#define SPA_POD_BODY_SIZE(pod) (((struct spa_pod*)(pod))->size) +#define SPA_POD_TYPE(pod) (((struct spa_pod*)(pod))->type) +#define SPA_POD_SIZE(pod) (sizeof(struct spa_pod) + SPA_POD_BODY_SIZE(pod)) #define SPA_POD_CONTENTS_SIZE(type,pod) (SPA_POD_SIZE(pod)-sizeof(type)) #define SPA_POD_CONTENTS(type,pod) SPA_MEMBER((pod),sizeof(type),void) #define SPA_POD_CONTENTS_CONST(type,pod) SPA_MEMBER((pod),sizeof(type),const void) -#define SPA_POD_BODY(pod) SPA_MEMBER((pod),sizeof(SpaPOD),void) -#define SPA_POD_BODY_CONST(pod) SPA_MEMBER((pod),sizeof(SpaPOD),const void) +#define SPA_POD_BODY(pod) SPA_MEMBER((pod),sizeof(struct spa_pod),void) +#define SPA_POD_BODY_CONST(pod) SPA_MEMBER((pod),sizeof(struct spa_pod),const void) #define SPA_POD_VALUE(type,pod) (((type*)pod)->value) -#define SPA_POD_PROP_N_VALUES(prop) (((prop)->pod.size - sizeof (SpaPODPropBody)) / (prop)->body.value.size) +#define SPA_POD_PROP_N_VALUES(prop) (((prop)->pod.size - sizeof (struct spa_pod_prop_body)) / (prop)->body.value.size) static inline bool -spa_pod_is_object_type (SpaPOD *pod, uint32_t type) +spa_pod_is_object_type (struct spa_pod *pod, uint32_t type) { - return (pod->type == SPA_POD_TYPE_OBJECT && ((SpaPODObject*)pod)->body.type == type); + return (pod->type == SPA_POD_TYPE_OBJECT && ((struct spa_pod_object*)pod)->body.type == type); } #define SPA_POD_ARRAY_BODY_FOREACH(body, _size, iter) \ - for ((iter) = SPA_MEMBER ((body), sizeof(SpaPODArrayBody), __typeof__(*(iter))); \ + for ((iter) = SPA_MEMBER ((body), sizeof(struct spa_pod_array_body), __typeof__(*(iter))); \ (iter) < SPA_MEMBER ((body), (_size), __typeof__(*(iter))); \ (iter) = SPA_MEMBER ((iter), (body)->child.size, __typeof__(*(iter)))) #define SPA_POD_FOREACH(pod, size, iter) \ for ((iter) = (pod); \ - (iter) < SPA_MEMBER ((pod), (size), SpaPOD); \ - (iter) = SPA_MEMBER ((iter), SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), SpaPOD)) + (iter) < SPA_MEMBER ((pod), (size), struct spa_pod); \ + (iter) = SPA_MEMBER ((iter), SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), struct spa_pod)) #define SPA_POD_CONTENTS_FOREACH(pod, offset, iter) \ - SPA_POD_FOREACH(SPA_MEMBER ((pod), (offset), SpaPOD),SPA_POD_SIZE (pod),iter) + SPA_POD_FOREACH(SPA_MEMBER ((pod), (offset), struct spa_pod),SPA_POD_SIZE (pod),iter) #define SPA_POD_OBJECT_BODY_FOREACH(body, size, iter) \ - for ((iter) = SPA_MEMBER ((body), sizeof (SpaPODObjectBody), SpaPOD); \ - (iter) < SPA_MEMBER ((body), (size), SpaPOD); \ - (iter) = SPA_MEMBER ((iter), SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), SpaPOD)) + for ((iter) = SPA_MEMBER ((body), sizeof (struct spa_pod_object_body), struct spa_pod); \ + (iter) < SPA_MEMBER ((body), (size), struct spa_pod); \ + (iter) = SPA_MEMBER ((iter), SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), struct spa_pod)) #define SPA_POD_OBJECT_FOREACH(obj, iter) \ SPA_POD_OBJECT_BODY_FOREACH(&obj->body, SPA_POD_BODY_SIZE(obj), iter) #define SPA_POD_PROP_ALTERNATIVE_FOREACH(body, _size, iter) \ - for ((iter) = SPA_MEMBER ((body), (body)->value.size + sizeof (SpaPODPropBody), __typeof__(*iter)); \ + for ((iter) = SPA_MEMBER ((body), (body)->value.size + sizeof (struct spa_pod_prop_body), __typeof__(*iter)); \ (iter) <= SPA_MEMBER ((body), (_size)-(body)->value.size, __typeof__(*iter)); \ (iter) = SPA_MEMBER ((iter), (body)->value.size, __typeof__(*iter))) -static inline SpaPODProp * -spa_pod_contents_find_prop (const SpaPOD *pod, uint32_t offset, uint32_t key) +static inline struct spa_pod_prop * +spa_pod_contents_find_prop (const struct spa_pod *pod, uint32_t offset, uint32_t key) { - SpaPOD *res; + struct spa_pod *res; SPA_POD_CONTENTS_FOREACH (pod, offset, res) { - if (res->type == SPA_POD_TYPE_PROP && ((SpaPODProp*)res)->body.key == key) - return (SpaPODProp *)res; + if (res->type == SPA_POD_TYPE_PROP && ((struct spa_pod_prop*)res)->body.key == key) + return (struct spa_pod_prop *)res; } return NULL; } -static inline SpaPODProp * -spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key) +static inline struct spa_pod_prop * +spa_pod_object_find_prop (const struct spa_pod_object *obj, uint32_t key) { - return spa_pod_contents_find_prop (&obj->pod, sizeof (SpaPODObject), key); + return spa_pod_contents_find_prop (&obj->pod, sizeof (struct spa_pod_object), key); } #define SPA_POD_COLLECT(pod,type,args,error) \ do { \ if (type == SPA_POD_TYPE_POD) { \ - *(va_arg (args, SpaPOD **)) = pod; \ + *(va_arg (args, struct spa_pod **)) = pod; \ } else if ((pod)->type == SPA_POD_TYPE_NONE) { \ switch (type) { \ case -SPA_POD_TYPE_ARRAY: \ case -SPA_POD_TYPE_STRUCT: \ case -SPA_POD_TYPE_OBJECT: \ case -SPA_POD_TYPE_PROP: \ - *(va_arg (args, SpaPOD **)) = NULL; \ + *(va_arg (args, struct spa_pod **)) = NULL; \ break; \ default: \ goto error; \ @@ -111,45 +111,47 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key) case SPA_POD_TYPE_BOOL: \ case SPA_POD_TYPE_ID: \ case SPA_POD_TYPE_INT: \ - *(va_arg (args, int32_t*)) = SPA_POD_VALUE(SpaPODInt, pod); \ + *(va_arg (args, int32_t*)) = SPA_POD_VALUE(struct spa_pod_int, pod); \ break; \ case SPA_POD_TYPE_LONG: \ - *(va_arg (args, int64_t*)) = SPA_POD_VALUE (SpaPODLong, pod); \ + *(va_arg (args, int64_t*)) = SPA_POD_VALUE (struct spa_pod_long, pod); \ break; \ case SPA_POD_TYPE_FLOAT: \ - *(va_arg (args, float*)) = SPA_POD_VALUE (SpaPODFloat, pod); \ + *(va_arg (args, float*)) = SPA_POD_VALUE (struct spa_pod_float, pod); \ break; \ case SPA_POD_TYPE_DOUBLE: \ - *(va_arg (args, double*)) = SPA_POD_VALUE (SpaPODDouble, pod); \ + *(va_arg (args, double*)) = SPA_POD_VALUE (struct spa_pod_double, pod); \ break; \ case SPA_POD_TYPE_STRING: \ - *(va_arg (args, char **)) = SPA_POD_CONTENTS (SpaPODString, pod); \ + *(va_arg (args, char **)) = SPA_POD_CONTENTS (struct spa_pod_string, pod); \ break; \ case -SPA_POD_TYPE_STRING: \ { \ char *dest = va_arg (args, char *); \ uint32_t maxlen = va_arg (args, uint32_t); \ - strncpy (dest, SPA_POD_CONTENTS (SpaPODString, pod), maxlen-1); \ + strncpy (dest, SPA_POD_CONTENTS (struct spa_pod_string, pod), maxlen-1); \ break; \ } \ case SPA_POD_TYPE_BYTES: \ - *(va_arg (args, void **)) = SPA_POD_CONTENTS (SpaPODBytes, pod); \ + *(va_arg (args, void **)) = SPA_POD_CONTENTS (struct spa_pod_bytes, pod); \ *(va_arg (args, uint32_t *)) = SPA_POD_BODY_SIZE (pod); \ break; \ case SPA_POD_TYPE_POINTER: \ { \ - SpaPODPointerBody *b = SPA_POD_BODY (pod); \ + struct spa_pod_pointer_body *b = SPA_POD_BODY (pod); \ *(va_arg (args, void **)) = b->value; \ break; \ } \ case SPA_POD_TYPE_RECTANGLE: \ - *(va_arg (args, SpaRectangle *)) = SPA_POD_VALUE (SpaPODRectangle, pod); \ + *(va_arg (args, struct spa_rectangle *)) = \ + SPA_POD_VALUE (struct spa_pod_rectangle, pod); \ break; \ case SPA_POD_TYPE_FRACTION: \ - *(va_arg (args, SpaFraction *)) = SPA_POD_VALUE (SpaPODFraction, pod); \ + *(va_arg (args, struct spa_fraction *)) = \ + SPA_POD_VALUE (struct spa_pod_fraction, pod); \ break; \ case SPA_POD_TYPE_BITMASK: \ - *(va_arg (args, uint32_t **)) = SPA_POD_CONTENTS (SpaPOD, pod); \ + *(va_arg (args, uint32_t **)) = SPA_POD_CONTENTS (struct spa_pod, pod); \ break; \ case SPA_POD_TYPE_ARRAY: \ case SPA_POD_TYPE_STRUCT: \ @@ -159,14 +161,14 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key) case -SPA_POD_TYPE_STRUCT: \ case -SPA_POD_TYPE_OBJECT: \ case -SPA_POD_TYPE_PROP: \ - *(va_arg (args, SpaPOD **)) = pod; \ + *(va_arg (args, struct spa_pod **)) = pod; \ break; \ default: \ goto error; \ } \ } else \ goto error; \ - } while (false); \ + } while (false); #define SPA_POD_COLLECT_SKIP(type,args) \ switch (type) { \ @@ -200,13 +202,13 @@ spa_pod_object_find_prop (const SpaPODObject *obj, uint32_t key) } \ static inline uint32_t -spa_pod_contents_queryv (const SpaPOD *pod, uint32_t offset, uint32_t key, va_list args) +spa_pod_contents_queryv (const struct spa_pod *pod, uint32_t offset, uint32_t key, va_list args) { uint32_t count = 0; while (key) { uint32_t type; - SpaPODProp *prop = spa_pod_contents_find_prop (pod, offset, key); + struct spa_pod_prop *prop = spa_pod_contents_find_prop (pod, offset, key); type = va_arg (args, uint32_t); @@ -224,7 +226,7 @@ next: } static inline uint32_t -spa_pod_contents_query (const SpaPOD *pod, uint32_t offset, uint32_t key, ...) +spa_pod_contents_query (const struct spa_pod *pod, uint32_t offset, uint32_t key, ...) { va_list args; uint32_t count; @@ -237,7 +239,7 @@ spa_pod_contents_query (const SpaPOD *pod, uint32_t offset, uint32_t key, ...) } #define spa_pod_object_query(object,key, ...) \ - spa_pod_contents_query (&object->pod, sizeof (SpaPODObject), key, __VA_ARGS__) + spa_pod_contents_query (&(object)->pod, sizeof (struct spa_pod_object), key, __VA_ARGS__) #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/include/spa/pod.h b/spa/include/spa/pod.h index c016d9bf9..0522da9cf 100644 --- a/spa/include/spa/pod.h +++ b/spa/include/spa/pod.h @@ -38,9 +38,9 @@ extern "C" { #define SPA_TYPE_POD_STRUCT_BASE SPA_TYPE_POD__Struct ":" /** - * SpaPODType: + * spa_pod_type: */ -typedef enum { +enum spa_pod_type { SPA_POD_TYPE_INVALID = 0, SPA_POD_TYPE_NONE = 1, SPA_POD_TYPE_BOOL, @@ -60,88 +60,97 @@ typedef enum { SPA_POD_TYPE_OBJECT, SPA_POD_TYPE_PROP, SPA_POD_TYPE_POD, -} SpaPODType; +}; -typedef struct { +struct spa_pod { uint32_t size; - uint32_t type; /* one of SpaPODType */ -} SpaPOD; + uint32_t type; /* one of spa_pod_type */ +}; -typedef struct { - SpaPOD pod; - int32_t value; +struct spa_pod_int { + struct spa_pod pod; + int32_t value; int32_t __padding; -} SpaPODInt; +}; -typedef SpaPODInt SpaPODBool; -typedef SpaPODInt SpaPODId; +struct spa_pod_bool { + struct spa_pod pod; + int32_t value; + int32_t __padding; +}; -typedef struct { - SpaPOD pod; - int64_t value; -} SpaPODLong; +struct spa_pod_id { + struct spa_pod pod; + int32_t value; + int32_t __padding; +}; -typedef struct { - SpaPOD pod; - float value; -} SpaPODFloat; +struct spa_pod_long { + struct spa_pod pod; + int64_t value; +}; -typedef struct { - SpaPOD pod; - double value; -} SpaPODDouble; +struct spa_pod_float { + struct spa_pod pod; + float value; +}; -typedef struct { - SpaPOD pod; +struct spa_pod_double { + struct spa_pod pod; + double value; +}; + +struct spa_pod_string { + struct spa_pod pod; /* value here */ -} SpaPODString; +}; -typedef struct { - SpaPOD pod; +struct spa_pod_bytes { + struct spa_pod pod; /* value here */ -} SpaPODBytes; +}; -typedef struct { +struct spa_pod_pointer_body { uint32_t type; void *value; -} SpaPODPointerBody; +}; -typedef struct { - SpaPOD pod; - SpaPODPointerBody body; -} SpaPODPointer; +struct spa_pod_pointer { + struct spa_pod pod; + struct spa_pod_pointer_body body; +}; -typedef struct { - SpaPOD pod; - SpaRectangle value; -} SpaPODRectangle; +struct spa_pod_rectangle { + struct spa_pod pod; + struct spa_rectangle value; +}; -typedef struct { - SpaPOD pod; - SpaFraction value; -} SpaPODFraction; +struct spa_pod_fraction { + struct spa_pod pod; + struct spa_fraction value; +}; -typedef struct { - SpaPOD pod; +struct spa_pod_bitmap { + struct spa_pod pod; /* array of uint8_t follows with the bitmap */ -} SpaPODBitmap; +}; -typedef struct { - SpaPOD child; +struct spa_pod_array_body { + struct spa_pod child; /* array with elements of child.size follows */ -} SpaPODArrayBody; +}; -typedef struct { - SpaPOD pod; - SpaPODArrayBody body; -} SpaPODArray; +struct spa_pod_array { + struct spa_pod pod; + struct spa_pod_array_body body; +}; -typedef struct { - SpaPOD pod; - /* one or more SpaPOD follow */ -} SpaPODStruct; +struct spa_pod_struct { + struct spa_pod pod; + /* one or more spa_pod follow */ +}; -typedef struct { +struct spa_pod_prop_body { uint32_t key; #define SPA_POD_PROP_RANGE_NONE 0 #define SPA_POD_PROP_RANGE_MIN_MAX 1 @@ -154,26 +163,26 @@ typedef struct { #define SPA_POD_PROP_FLAG_READONLY (1 << 6) #define SPA_POD_PROP_FLAG_DEPRECATED (1 << 7) uint32_t flags; - SpaPOD value; + struct spa_pod value; /* array with elements of value.size follows, * first element is value/default, rest are alternatives */ -} SpaPODPropBody; +}; -typedef struct { - SpaPOD pod; - SpaPODPropBody body; -} SpaPODProp; +struct spa_pod_prop { + struct spa_pod pod; + struct spa_pod_prop_body body; +}; -typedef struct { +struct spa_pod_object_body { uint32_t id; uint32_t type; - /* contents follow, series of SpaPODProp */ -} SpaPODObjectBody; + /* contents follow, series of spa_pod_prop */ +}; -typedef struct { - SpaPOD pod; - SpaPODObjectBody body; -} SpaPODObject; +struct spa_pod_object { + struct spa_pod pod; + struct spa_pod_object_body body; +}; #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/include/spa/props.h b/spa/include/spa/props.h index 713de5da8..5e31a1c29 100644 --- a/spa/include/spa/props.h +++ b/spa/include/spa/props.h @@ -27,7 +27,9 @@ extern "C" { #include #include -typedef SpaPODObject SpaProps; +struct spa_props { + struct spa_pod_object object; +}; #define SPA_TYPE__Props SPA_TYPE_POD_OBJECT_BASE "Props" #define SPA_TYPE_PROPS_BASE SPA_TYPE__Props ":" @@ -49,8 +51,8 @@ typedef SpaPODObject SpaProps; #define SPA_TYPE_PROPS__patternType SPA_TYPE_PROPS_BASE "patternType" static inline uint32_t -spa_pod_builder_push_props (SpaPODBuilder *builder, - SpaPODFrame *frame, +spa_pod_builder_push_props (struct spa_pod_builder *builder, + struct spa_pod_frame *frame, uint32_t props_type) { return spa_pod_builder_push_object (builder, frame, 0, props_type); @@ -60,13 +62,13 @@ spa_pod_builder_push_props (SpaPODBuilder *builder, spa_pod_builder_object(b, f, 0, props_type,__VA_ARGS__) static inline uint32_t -spa_props_query (const SpaProps *props, uint32_t key, ...) +spa_props_query (const struct spa_props *props, uint32_t key, ...) { uint32_t count; va_list args; va_start (args, key); - count = spa_pod_contents_queryv (&props->pod, sizeof (SpaProps), key, args); + count = spa_pod_contents_queryv (&props->object.pod, sizeof (struct spa_props), key, args); va_end (args); return count; diff --git a/spa/include/spa/ringbuffer.h b/spa/include/spa/ringbuffer.h index 86ed3227b..93f14f095 100644 --- a/spa/include/spa/ringbuffer.h +++ b/spa/include/spa/ringbuffer.h @@ -24,8 +24,7 @@ extern "C" { #endif -typedef struct _SpaRingbuffer SpaRingbuffer; - +struct spa_ringbuffer; #define SPA_TYPE__RingBuffer SPA_TYPE_INTERFACE_BASE "RingBuffer" #define SPA_TYPE_RINGBUFFER_BASE SPA_TYPE__RingBuffer ":" @@ -34,13 +33,13 @@ typedef struct _SpaRingbuffer SpaRingbuffer; #include /** - * SpaRingbuffer: + * spa_ringbuffer: * @readindex: the current read index * @writeindex: the current write index * @size: the size of the ringbuffer must be power of 2 * @mask: mask as @size - 1 */ -struct _SpaRingbuffer { +struct spa_ringbuffer { uint32_t readindex; uint32_t writeindex; uint32_t size; @@ -49,17 +48,17 @@ struct _SpaRingbuffer { /** * spa_ringbuffer_init: - * @rbuf: a #SpaRingbuffer + * @rbuf: a #struct spa_ringbuffer * @data: pointer to an array * @size: the number of elements in @data * - * Initialize a #SpaRingbuffer with @data and @size. + * Initialize a #struct spa_ringbuffer with @data and @size. * Size must be a power of 2. * * Returns: %SPA_RESULT_OK, unless size is not a power of 2. */ -static inline SpaResult -spa_ringbuffer_init (SpaRingbuffer *rbuf, +static inline int +spa_ringbuffer_init (struct spa_ringbuffer *rbuf, uint32_t size) { if (SPA_UNLIKELY ((size & (size - 1)) != 0)) @@ -75,12 +74,12 @@ spa_ringbuffer_init (SpaRingbuffer *rbuf, /** * spa_ringbuffer_clear: - * @rbuf: a #SpaRingbuffer + * @rbuf: a #struct spa_ringbuffer * * Clear @rbuf */ static inline void -spa_ringbuffer_clear (SpaRingbuffer *rbuf) +spa_ringbuffer_clear (struct spa_ringbuffer *rbuf) { rbuf->readindex = 0; rbuf->writeindex = 0; @@ -88,7 +87,7 @@ spa_ringbuffer_clear (SpaRingbuffer *rbuf) /** * spa_ringbuffer_get_read_index: - * @rbuf: a #SpaRingbuffer + * @rbuf: a #struct spa_ringbuffer * @index: the value of readindex, should be masked to get the * offset in the ringbuffer memory * @@ -97,8 +96,8 @@ spa_ringbuffer_clear (SpaRingbuffer *rbuf) * was an overrun. */ static inline int32_t -spa_ringbuffer_get_read_index (SpaRingbuffer *rbuf, - uint32_t *index) +spa_ringbuffer_get_read_index (struct spa_ringbuffer *rbuf, + uint32_t *index) { int32_t avail; @@ -110,7 +109,7 @@ spa_ringbuffer_get_read_index (SpaRingbuffer *rbuf, /** * spa_ringbuffer_read_data: - * @rbuf: a #SpaRingbuffer + * @rbuf: a #struct spa_ringbuffer * @buffer: memory to read from * @offset: offset in @buffer to read from * @data: destination memory @@ -120,11 +119,11 @@ spa_ringbuffer_get_read_index (SpaRingbuffer *rbuf, * with the size of @rbuf and len should be smaller than the size. */ static inline void -spa_ringbuffer_read_data (SpaRingbuffer *rbuf, - void *buffer, - uint32_t offset, - void *data, - uint32_t len) +spa_ringbuffer_read_data (struct spa_ringbuffer *rbuf, + void *buffer, + uint32_t offset, + void *data, + uint32_t len) { uint32_t first = SPA_MIN (len, rbuf->size - offset); memcpy (data, buffer + offset, first); @@ -135,21 +134,21 @@ spa_ringbuffer_read_data (SpaRingbuffer *rbuf, /** * spa_ringbuffer_read_update: - * @rbuf: a #SpaRingbuffer + * @rbuf: a #struct spa_ringbuffer * @index: new index * * Update the read pointer to @index */ static inline void -spa_ringbuffer_read_update (SpaRingbuffer *rbuf, - int32_t index) +spa_ringbuffer_read_update (struct spa_ringbuffer *rbuf, + int32_t index) { __atomic_store_n (&rbuf->readindex, index, __ATOMIC_RELEASE); } /** * spa_ringbuffer_get_write_index: - * @rbuf: a #SpaRingbuffer + * @rbuf: a #struct spa_ringbuffer * @index: the value of writeindex, should be masked to get the * offset in the ringbuffer memory * @@ -159,8 +158,8 @@ spa_ringbuffer_read_update (SpaRingbuffer *rbuf, * the number of bytes available for writing. */ static inline int32_t -spa_ringbuffer_get_write_index (SpaRingbuffer *rbuf, - uint32_t *index) +spa_ringbuffer_get_write_index (struct spa_ringbuffer *rbuf, + uint32_t *index) { int32_t filled; @@ -171,11 +170,11 @@ spa_ringbuffer_get_write_index (SpaRingbuffer *rbuf, } static inline void -spa_ringbuffer_write_data (SpaRingbuffer *rbuf, - void *buffer, - uint32_t offset, - void *data, - uint32_t len) +spa_ringbuffer_write_data (struct spa_ringbuffer *rbuf, + void *buffer, + uint32_t offset, + void *data, + uint32_t len) { uint32_t first = SPA_MIN (len, rbuf->size - offset); memcpy (buffer + offset, data, first); @@ -186,15 +185,15 @@ spa_ringbuffer_write_data (SpaRingbuffer *rbuf, /** * spa_ringbuffer_write_update: - * @rbuf: a #SpaRingbuffer + * @rbuf: a #struct spa_ringbuffer * @index: new index * * Update the write pointer to @index * */ static inline void -spa_ringbuffer_write_update (SpaRingbuffer *rbuf, - int32_t index) +spa_ringbuffer_write_update (struct spa_ringbuffer *rbuf, + int32_t index) { __atomic_store_n (&rbuf->writeindex, index, __ATOMIC_RELEASE); } diff --git a/spa/include/spa/type-map.h b/spa/include/spa/type-map.h index 7c941d9b0..b2754196f 100644 --- a/spa/include/spa/type-map.h +++ b/spa/include/spa/type-map.h @@ -24,8 +24,6 @@ extern "C" { #endif -typedef struct _SpaTypeMap SpaTypeMap; - #include #include #include @@ -33,28 +31,28 @@ typedef struct _SpaTypeMap SpaTypeMap; #define SPA_TYPE__TypeMap SPA_TYPE_INTERFACE_BASE "TypeMap" /** - * SpaTypeMap: + * spa_type_map: * * Maps between string types and their type id */ -struct _SpaTypeMap { +struct spa_type_map { /* the total size of this structure. This can be used to expand this * structure in the future */ const size_t size; /** - * SpaTypeMap::info + * spa_type_map::info * * Extra information about the type map */ - const SpaDict *info; + const struct spa_dict *info; - SpaType (*get_id) (SpaTypeMap *map, - const char *type); + uint32_t (*get_id) (struct spa_type_map *map, + const char *type); - const char * (*get_type) (const SpaTypeMap *map, - SpaType id); + const char * (*get_type) (const struct spa_type_map *map, + uint32_t id); - size_t (*get_size) (const SpaTypeMap *map); + size_t (*get_size) (const struct spa_type_map *map); }; #define spa_type_map_get_id(n,...) (n)->get_id((n),__VA_ARGS__) diff --git a/spa/include/spa/type.h b/spa/include/spa/type.h index 4b3f8d959..75e0d42d4 100644 --- a/spa/include/spa/type.h +++ b/spa/include/spa/type.h @@ -26,8 +26,6 @@ extern "C" { #include -typedef uint32_t SpaType; - #define SPA_TYPE_BASE "Spa:" #define SPA_TYPE__Enum SPA_TYPE_BASE "Enum" diff --git a/spa/include/spa/video/chroma.h b/spa/include/spa/video/chroma.h index 8d2a1965f..e76558b6a 100644 --- a/spa/include/spa/video/chroma.h +++ b/spa/include/spa/video/chroma.h @@ -25,7 +25,7 @@ extern "C" { #endif /** - * SpaVideoChromaSite: + * spa_video_chroma_site: * @SPA_VIDEO_CHROMA_SITE_UNKNOWN: unknown cositing * @SPA_VIDEO_CHROMA_SITE_NONE: no cositing * @SPA_VIDEO_CHROMA_SITE_H_COSITED: chroma is horizontally cosited @@ -38,7 +38,7 @@ extern "C" { * * Various Chroma sitings. */ -typedef enum { +enum spa_video_chroma_site { SPA_VIDEO_CHROMA_SITE_UNKNOWN = 0, SPA_VIDEO_CHROMA_SITE_NONE = (1 << 0), SPA_VIDEO_CHROMA_SITE_H_COSITED = (1 << 1), @@ -49,7 +49,7 @@ typedef enum { SPA_VIDEO_CHROMA_SITE_JPEG = (SPA_VIDEO_CHROMA_SITE_NONE), SPA_VIDEO_CHROMA_SITE_MPEG2 = (SPA_VIDEO_CHROMA_SITE_H_COSITED), SPA_VIDEO_CHROMA_SITE_DV = (SPA_VIDEO_CHROMA_SITE_COSITED | SPA_VIDEO_CHROMA_SITE_ALT_LINE), -} SpaVideoChromaSite; +}; #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/include/spa/video/color.h b/spa/include/spa/video/color.h index 444031b1d..1683c45e9 100644 --- a/spa/include/spa/video/color.h +++ b/spa/include/spa/video/color.h @@ -25,7 +25,7 @@ extern "C" { #endif /** - * SpaVideoColorRange: + * spa_video_color_range: * @SPA_VIDEO_COLOR_RANGE_UNKNOWN: unknown range * @SPA_VIDEO_COLOR_RANGE_0_255: [0..255] for 8 bit components * @SPA_VIDEO_COLOR_RANGE_16_235: [16..235] for 8 bit components. Chroma has @@ -34,14 +34,14 @@ extern "C" { * Possible color range values. These constants are defined for 8 bit color * values and can be scaled for other bit depths. */ -typedef enum { +enum spa_video_color_range { SPA_VIDEO_COLOR_RANGE_UNKNOWN = 0, SPA_VIDEO_COLOR_RANGE_0_255, SPA_VIDEO_COLOR_RANGE_16_235 -} SpaVideoColorRange; +}; /** - * SpaVideoColorMatrix: + * spa_video_color_matrix: * @SPA_VIDEO_COLOR_MATRIX_UNKNOWN: unknown matrix * @SPA_VIDEO_COLOR_MATRIX_RGB: identity matrix * @SPA_VIDEO_COLOR_MATRIX_FCC: FCC color matrix @@ -53,7 +53,7 @@ typedef enum { * The color matrix is used to convert between Y'PbPr and * non-linear RGB (R'G'B') */ -typedef enum { +enum spa_video_color_matrix { SPA_VIDEO_COLOR_MATRIX_UNKNOWN = 0, SPA_VIDEO_COLOR_MATRIX_RGB, SPA_VIDEO_COLOR_MATRIX_FCC, @@ -61,10 +61,10 @@ typedef enum { SPA_VIDEO_COLOR_MATRIX_BT601, SPA_VIDEO_COLOR_MATRIX_SMPTE240M, SPA_VIDEO_COLOR_MATRIX_BT2020 -} SpaVideoColorMatrix; +}; /** - * SpaVideoTransferFunction: + * spa_video_transfer_function: * @SPA_VIDEO_TRANSFER_UNKNOWN: unknown transfer function * @SPA_VIDEO_TRANSFER_GAMMA10: linear RGB, gamma 1.0 curve * @SPA_VIDEO_TRANSFER_GAMMA18: Gamma 1.8 curve @@ -89,7 +89,7 @@ typedef enum { * The video transfer function defines the formula for converting between * non-linear RGB (R'G'B') and linear RGB */ -typedef enum { +enum spa_video_transfer_function { SPA_VIDEO_TRANSFER_UNKNOWN = 0, SPA_VIDEO_TRANSFER_GAMMA10, SPA_VIDEO_TRANSFER_GAMMA18, @@ -103,10 +103,10 @@ typedef enum { SPA_VIDEO_TRANSFER_LOG316, SPA_VIDEO_TRANSFER_BT2020_12, SPA_VIDEO_TRANSFER_ADOBERGB -} SpaVideoTransferFunction; +}; /** - * SpaVideoColorPrimaries: + * spa_video_color_primaries: * @SPA_VIDEO_COLOR_PRIMARIES_UNKNOWN: unknown color primaries * @SPA_VIDEO_COLOR_PRIMARIES_BT709: BT709 primaries * @SPA_VIDEO_COLOR_PRIMARIES_BT470M: BT470M primaries @@ -120,7 +120,7 @@ typedef enum { * The color primaries define the how to transform linear RGB values to and from * the CIE XYZ colorspace. */ -typedef enum { +enum spa_video_color_primaries { SPA_VIDEO_COLOR_PRIMARIES_UNKNOWN = 0, SPA_VIDEO_COLOR_PRIMARIES_BT709, SPA_VIDEO_COLOR_PRIMARIES_BT470M, @@ -130,10 +130,10 @@ typedef enum { SPA_VIDEO_COLOR_PRIMARIES_FILM, SPA_VIDEO_COLOR_PRIMARIES_BT2020, SPA_VIDEO_COLOR_PRIMARIES_ADOBERGB -} SpaVideoColorPrimaries; +}; /** - * SpaVideoColorimetry: + * spa_video_colorimetry: * @range: the color range. This is the valid range for the samples. * It is used to convert the samples to Y'PbPr values. * @matrix: the color matrix. Used to convert between Y'PbPr and @@ -143,12 +143,12 @@ typedef enum { * * Structure describing the color info. */ -typedef struct { - SpaVideoColorRange range; - SpaVideoColorMatrix matrix; - SpaVideoTransferFunction transfer; - SpaVideoColorPrimaries primaries; -} SpaVideoColorimetry; +struct spa_video_colorimetry { + enum spa_video_color_range range; + enum spa_video_color_matrix matrix; + enum spa_video_transfer_function transfer; + enum spa_video_color_primaries primaries; +}; #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/include/spa/video/encoded.h b/spa/include/spa/video/encoded.h index 0110f21f3..2b45a81fd 100644 --- a/spa/include/spa/video/encoded.h +++ b/spa/include/spa/video/encoded.h @@ -24,37 +24,37 @@ extern "C" { #endif -typedef struct _SpaVideoInfoH264 SpaVideoInfoH264; -typedef struct _SpaVideoInfoMJPG SpaVideoInfoMJPG; +struct spa_video_info_h264; +struct spa_video_info_mjpg; #include #include -typedef enum { +enum spa_h264_stream_format { SPA_H264_STREAM_FORMAT_UNKNOWN = 0, SPA_H264_STREAM_FORMAT_AVC, SPA_H264_STREAM_FORMAT_AVC3, SPA_H264_STREAM_FORMAT_BYTESTREAM -} SpaH264StreamFormat; +}; -typedef enum { +enum spa_h264_alignment { SPA_H264_ALIGNMENT_UNKNOWN = 0, SPA_H264_ALIGNMENT_AU, SPA_H264_ALIGNMENT_NAL -} SpaH264Alignment; - -struct _SpaVideoInfoH264 { - SpaRectangle size; - SpaFraction framerate; - SpaFraction max_framerate; - SpaH264StreamFormat stream_format; - SpaH264Alignment alignment; }; -struct _SpaVideoInfoMJPG { - SpaRectangle size; - SpaFraction framerate; - SpaFraction max_framerate; +struct spa_video_info_h264 { + struct spa_rectangle size; + struct spa_fraction framerate; + struct spa_fraction max_framerate; + enum spa_h264_stream_format stream_format; + enum spa_h264_alignment alignment; +}; + +struct spa_video_info_mjpg { + struct spa_rectangle size; + struct spa_fraction framerate; + struct spa_fraction max_framerate; }; #ifdef __cplusplus diff --git a/spa/include/spa/video/format-utils.h b/spa/include/spa/video/format-utils.h index 8ac8d39c6..53ab77d47 100644 --- a/spa/include/spa/video/format-utils.h +++ b/spa/include/spa/video/format-utils.h @@ -28,7 +28,7 @@ extern "C" { #include #include -typedef struct { +struct spa_type_format_video { uint32_t format; uint32_t size; uint32_t framerate; @@ -47,10 +47,10 @@ typedef struct { uint32_t level; uint32_t stream_format; uint32_t alignment; -} SpaTypeFormatVideo; +}; static inline void -spa_type_format_video_map (SpaTypeMap *map, SpaTypeFormatVideo *type) +spa_type_format_video_map (struct spa_type_map *map, struct spa_type_format_video *type) { if (type->format == 0) { type->format = spa_type_map_get_id (map, SPA_TYPE_FORMAT_VIDEO__format); @@ -75,9 +75,9 @@ spa_type_format_video_map (SpaTypeMap *map, SpaTypeFormatVideo *type) } static inline bool -spa_format_video_raw_parse (const SpaFormat *format, - SpaVideoInfoRaw *info, - SpaTypeFormatVideo *type) +spa_format_video_raw_parse (const struct spa_format *format, + struct spa_video_info_raw *info, + struct spa_type_format_video *type) { spa_format_query (format, type->format, SPA_POD_TYPE_ID, &info->format, @@ -99,9 +99,9 @@ spa_format_video_raw_parse (const SpaFormat *format, } static inline bool -spa_format_video_h264_parse (const SpaFormat *format, - SpaVideoInfoH264 *info, - SpaTypeFormatVideo *type) +spa_format_video_h264_parse (const struct spa_format *format, + struct spa_video_info_h264 *info, + struct spa_type_format_video *type) { spa_format_query (format, type->size, SPA_POD_TYPE_RECTANGLE, &info->size, @@ -114,9 +114,9 @@ spa_format_video_h264_parse (const SpaFormat *format, } static inline bool -spa_format_video_mjpg_parse (const SpaFormat *format, - SpaVideoInfoMJPG *info, - SpaTypeFormatVideo *type) +spa_format_video_mjpg_parse (const struct spa_format *format, + struct spa_video_info_mjpg *info, + struct spa_type_format_video *type) { spa_format_query (format, type->size, SPA_POD_TYPE_RECTANGLE, &info->size, diff --git a/spa/include/spa/video/format.h b/spa/include/spa/video/format.h index 69d613a3d..26240aba4 100644 --- a/spa/include/spa/video/format.h +++ b/spa/include/spa/video/format.h @@ -28,8 +28,6 @@ extern "C" { #include #include -typedef struct _SpaVideoInfo SpaVideoInfo; - #define SPA_TYPE_FORMAT__Video SPA_TYPE_FORMAT_BASE "Video" #define SPA_TYPE_FORMAT_VIDEO_BASE SPA_TYPE_FORMAT__Video ":" @@ -52,13 +50,13 @@ typedef struct _SpaVideoInfo SpaVideoInfo; #define SPA_TYPE_FORMAT_VIDEO__streamFormat SPA_TYPE_FORMAT_VIDEO_BASE "stream-format" #define SPA_TYPE_FORMAT_VIDEO__alignment SPA_TYPE_FORMAT_VIDEO_BASE "alignment" -struct _SpaVideoInfo { +struct spa_video_info { uint32_t media_type; uint32_t media_subtype; union { - SpaVideoInfoRaw raw; - SpaVideoInfoH264 h264; - SpaVideoInfoMJPG mjpg; + struct spa_video_info_raw raw; + struct spa_video_info_h264 h264; + struct spa_video_info_mjpg mjpg; } info; }; diff --git a/spa/include/spa/video/multiview.h b/spa/include/spa/video/multiview.h index 9573d0d76..552a3071c 100644 --- a/spa/include/spa/video/multiview.h +++ b/spa/include/spa/video/multiview.h @@ -25,9 +25,9 @@ extern "C" { #endif /** - * SpaVideoMultiviewMode: + * spa_video_multiview_mode: * @SPA_VIDEO_MULTIVIEW_MODE_NONE: A special value indicating - * no multiview information. Used in SpaVideoInfo and other places to + * no multiview information. Used in spa_video_info and other places to * indicate that no specific multiview handling has been requested or * provided. This value is never carried on caps. * @SPA_VIDEO_MULTIVIEW_MODE_MONO: All frames are monoscopic. @@ -53,18 +53,17 @@ extern "C" { * @SPA_VIDEO_MULTIVIEW_MODE_MULTIVIEW_FRAME_BY_FRAME: Multiple * independent views are provided in separate frames in sequence. * This method only applies to raw video buffers at the moment. - * Specific view identification is via the #SpaVideoMultiviewMeta - * and #SpaVideoMeta(s) on raw video buffers. + * Specific view identification is via the #spa_video_multiview_meta + * on raw video buffers. * @SPA_VIDEO_MULTIVIEW_MODE_SEPARATED: Multiple views are - * provided as separate #SpaMemory framebuffers attached to each - * #SpaBuffer, described by the #SpaVideoMultiviewMeta - * and #SpaVideoMeta(s) + * provided as separate #spa_data framebuffers attached to each + * #spa_buffer, described by the #spa_video_multiview_meta * * All possible stereoscopic 3D and multiview representations. - * In conjunction with #SpaVideoMultiviewFlags, describes how + * In conjunction with #soa_video_multiview_flags, describes how * multiview content is being transported in the stream. */ -typedef enum { +enum spa_video_multiview_mode { SPA_VIDEO_MULTIVIEW_MODE_NONE = -1, SPA_VIDEO_MULTIVIEW_MODE_MONO = 0, /* Single view modes */ @@ -84,10 +83,10 @@ typedef enum { SPA_VIDEO_MULTIVIEW_MODE_MULTIVIEW_FRAME_BY_FRAME, SPA_VIDEO_MULTIVIEW_MODE_SEPARATED /* future expansion for annotated modes */ -} SpaVideoMultiviewMode; +}; /** - * SpaVideoMultiviewFlags: + * spa_video_multiview_flags: * @SPA_VIDEO_MULTIVIEW_FLAGS_NONE: No flags * @SPA_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST: For stereo streams, the * normal arrangement of left and right views is reversed. @@ -113,11 +112,11 @@ typedef enum { * absence or presence of the @SPA_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW * buffer flag. * - * SpaVideoMultiviewFlags are used to indicate extra properties of a + * spa_video_multiview_flags are used to indicate extra properties of a * stereo/multiview stream beyond the frame layout and buffer mapping - * that is conveyed in the #SpaMultiviewMode. + * that is conveyed in the #spa_video_multiview_mode. */ -typedef enum { +enum spa_video_multiview_flags { SPA_VIDEO_MULTIVIEW_FLAGS_NONE = 0, SPA_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST = (1 << 0), SPA_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED = (1 << 1), @@ -126,7 +125,7 @@ typedef enum { SPA_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED = (1 << 4), SPA_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT = (1 << 14), SPA_VIDEO_MULTIVIEW_FLAGS_MIXED_MONO = (1 << 15) -} SpaVideoMultiviewFlags; +}; #ifdef __cplusplus diff --git a/spa/include/spa/video/raw-utils.h b/spa/include/spa/video/raw-utils.h index 3309f09b7..33ad1d501 100644 --- a/spa/include/spa/video/raw-utils.h +++ b/spa/include/spa/video/raw-utils.h @@ -24,13 +24,10 @@ extern "C" { #endif -typedef struct _SpaVideoInfoRaw SpaVideoInfoRaw; - #include #include -typedef struct -{ +struct spa_type_video_format { uint32_t UNKNOWN; uint32_t ENCODED; uint32_t I420; @@ -109,10 +106,10 @@ typedef struct uint32_t I422_12LE; uint32_t Y444_12BE; uint32_t Y444_12LE; -} SpaTypeVideoFormat; +}; static inline void -spa_type_video_format_map (SpaTypeMap *map, SpaTypeVideoFormat *type) +spa_type_video_format_map (struct spa_type_map *map, struct spa_type_video_format *type) { if (type->ENCODED == 0) { type->UNKNOWN = 0; diff --git a/spa/include/spa/video/raw.h b/spa/include/spa/video/raw.h index 20ed93703..3e063255f 100644 --- a/spa/include/spa/video/raw.h +++ b/spa/include/spa/video/raw.h @@ -24,8 +24,6 @@ extern "C" { #endif -typedef struct _SpaVideoInfoRaw SpaVideoInfoRaw; - #include #include #include @@ -116,7 +114,7 @@ typedef struct _SpaVideoInfoRaw SpaVideoInfoRaw; #define SPA_TYPE_VIDEO_FORMAT__Y444_12LE SPA_TYPE_VIDEO_FORMAT_BASE "Y444_12LE" /** - * SpaVideoFlags: + * spa_video_flags: * @SPA_VIDEO_FLAG_NONE: no flags * @SPA_VIDEO_FLAG_VARIABLE_FPS: a variable fps is selected, fps_n and fps_d * denote the maximum fps of the video @@ -125,14 +123,14 @@ typedef struct _SpaVideoInfoRaw SpaVideoInfoRaw; * * Extra video flags */ -typedef enum { +enum spa_video_flags { SPA_VIDEO_FLAG_NONE = 0, SPA_VIDEO_FLAG_VARIABLE_FPS = (1 << 0), SPA_VIDEO_FLAG_PREMULTIPLIED_ALPHA = (1 << 1) -} SpaVideoFlags; +}; /** - * SpaVideoInterlaceMode: + * spa_video_interlace_mode: * @SPA_VIDEO_INTERLACE_MODE_PROGRESSIVE: all frames are progressive * @SPA_VIDEO_INTERLACE_MODE_INTERLEAVED: 2 fields are interleaved in one video * frame. Extra buffer flags describe the field order. @@ -143,21 +141,21 @@ typedef enum { * 'views' property > 1) the fields of view N can be found at frame ID * (N * 2) and (N * 2) + 1. * Each field has only half the amount of lines as noted in the - * height property. This mode requires multiple SpaVideoMeta metadata + * height property. This mode requires multiple spa_data * to describe the fields. * - * The possible values of the #SpaVideoInterlaceMode describing the interlace + * The possible values of the #spa_video_interlace_mode describing the interlace * mode of the stream. */ -typedef enum { +enum spa_video_interlace_mode { SPA_VIDEO_INTERLACE_MODE_PROGRESSIVE = 0, SPA_VIDEO_INTERLACE_MODE_INTERLEAVED, SPA_VIDEO_INTERLACE_MODE_MIXED, SPA_VIDEO_INTERLACE_MODE_FIELDS -} SpaVideoInterlaceMode; +}; /** - * SpaVideoInfoRaw: + * spa_video_info_raw: * @format: the format * @size: the frame size of the video * @framerate: the framerate of the video 0/1 means variable rate @@ -176,21 +174,21 @@ typedef enum { * @transfer_function: the transfer function. used to convert between R'G'B' and RGB * @color_primaries: color primaries. used to convert between R'G'B' and CIE XYZ */ -struct _SpaVideoInfoRaw { - uint32_t format; - SpaRectangle size; - SpaFraction framerate; - SpaFraction max_framerate; - uint32_t views; - SpaVideoInterlaceMode interlace_mode; - SpaFraction pixel_aspect_ratio; - SpaVideoMultiviewMode multiview_mode; - SpaVideoMultiviewFlags multiview_flags; - SpaVideoChromaSite chroma_site; - SpaVideoColorRange color_range; - SpaVideoColorMatrix color_matrix; - SpaVideoTransferFunction transfer_function; - SpaVideoColorPrimaries color_primaries; +struct spa_video_info_raw { + uint32_t format; + struct spa_rectangle size; + struct spa_fraction framerate; + struct spa_fraction max_framerate; + uint32_t views; + enum spa_video_interlace_mode interlace_mode; + struct spa_fraction pixel_aspect_ratio; + enum spa_video_multiview_mode multiview_mode; + enum spa_video_multiview_flags multiview_flags; + enum spa_video_chroma_site chroma_site; + enum spa_video_color_range color_range; + enum spa_video_color_matrix color_matrix; + enum spa_video_transfer_function transfer_function; + enum spa_video_color_primaries color_primaries; }; #ifdef __cplusplus diff --git a/spa/lib/debug.c b/spa/lib/debug.c index 391230e67..5785d0d18 100644 --- a/spa/lib/debug.c +++ b/spa/lib/debug.c @@ -26,31 +26,31 @@ #include #include "debug.h" -SpaResult -spa_debug_port_info (const SpaPortInfo *info, const SpaTypeMap *map) +int +spa_debug_port_info (const struct spa_port_info *info, const struct spa_type_map *map) { if (info == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - fprintf (stderr, "SpaPortInfo %p:\n", info); + fprintf (stderr, "struct spa_port_info %p:\n", info); fprintf (stderr, " flags: \t%08x\n", info->flags); return SPA_RESULT_OK; } -SpaResult -spa_debug_buffer (const SpaBuffer *buffer, const SpaTypeMap *map) +int +spa_debug_buffer (const struct spa_buffer *buffer, const struct spa_type_map *map) { int i; if (buffer == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - fprintf (stderr, "SpaBuffer %p:\n", buffer); + fprintf (stderr, "spa_buffer %p:\n", buffer); fprintf (stderr, " id: %08X\n", buffer->id); fprintf (stderr, " n_metas: %u (at %p)\n", buffer->n_metas, buffer->metas); for (i = 0; i < buffer->n_metas; i++) { - SpaMeta *m = &buffer->metas[i]; + struct spa_meta *m = &buffer->metas[i]; const char *type_name; type_name = spa_type_map_get_type (map, m->type); @@ -58,38 +58,38 @@ spa_debug_buffer (const SpaBuffer *buffer, const SpaTypeMap *map) type_name, m->data, m->size); if (!strcmp (type_name, SPA_TYPE_META__Header)) { - SpaMetaHeader *h = m->data; - fprintf (stderr, " SpaMetaHeader:\n"); + struct spa_meta_header *h = m->data; + fprintf (stderr, " struct spa_meta_header:\n"); fprintf (stderr, " flags: %08x\n", h->flags); fprintf (stderr, " seq: %u\n", h->seq); fprintf (stderr, " pts: %"PRIi64"\n", h->pts); fprintf (stderr, " dts_offset: %"PRIi64"\n", h->dts_offset); } else if (!strcmp (type_name, SPA_TYPE_META__Pointer)) { - SpaMetaPointer *h = m->data; - fprintf (stderr, " SpaMetaPointer:\n"); + struct spa_meta_pointer *h = m->data; + fprintf (stderr, " struct spa_meta_pointer:\n"); fprintf (stderr, " type: %s\n", spa_type_map_get_type (map, h->type)); fprintf (stderr, " ptr: %p\n", h->ptr); } else if (!strcmp (type_name, SPA_TYPE_META__VideoCrop)) { - SpaMetaVideoCrop *h = m->data; - fprintf (stderr, " SpaMetaVideoCrop:\n"); + struct spa_meta_video_crop *h = m->data; + fprintf (stderr, " struct spa_meta_video_crop:\n"); fprintf (stderr, " x: %d\n", h->x); fprintf (stderr, " y: %d\n", h->y); fprintf (stderr, " width: %d\n", h->width); fprintf (stderr, " height: %d\n", h->height); } else if (!strcmp (type_name, SPA_TYPE_META__Ringbuffer)) { - SpaMetaRingbuffer *h = m->data; - fprintf (stderr, " SpaMetaRingbuffer:\n"); + struct spa_meta_ringbuffer *h = m->data; + fprintf (stderr, " struct spa_meta_ringbuffer:\n"); fprintf (stderr, " readindex: %d\n", h->ringbuffer.readindex); fprintf (stderr, " writeindex: %d\n", h->ringbuffer.writeindex); fprintf (stderr, " size: %d\n", h->ringbuffer.size); fprintf (stderr, " mask: %d\n", h->ringbuffer.mask); } else if (!strcmp (type_name, SPA_TYPE_META__Shared)) { - SpaMetaShared *h = m->data; - fprintf (stderr, " SpaMetaShared:\n"); + struct spa_meta_shared *h = m->data; + fprintf (stderr, " struct spa_meta_shared:\n"); fprintf (stderr, " flags: %d\n", h->flags); fprintf (stderr, " fd: %d\n", h->fd); fprintf (stderr, " offset: %d\n", h->offset); @@ -102,7 +102,7 @@ spa_debug_buffer (const SpaBuffer *buffer, const SpaTypeMap *map) } fprintf (stderr, " n_datas: \t%u (at %p)\n", buffer->n_datas, buffer->datas); for (i = 0; i < buffer->n_datas; i++) { - SpaData *d = &buffer->datas[i]; + struct spa_data *d = &buffer->datas[i]; fprintf (stderr, " type: %d (%s)\n", d->type, spa_type_map_get_type (map, d->type)); fprintf (stderr, " flags: %d\n", d->flags); fprintf (stderr, " data: %p\n", d->data); @@ -117,7 +117,7 @@ spa_debug_buffer (const SpaBuffer *buffer, const SpaTypeMap *map) return SPA_RESULT_OK; } -SpaResult +int spa_debug_dump_mem (const void *mem, size_t size) { const uint8_t *t = mem; @@ -136,17 +136,17 @@ spa_debug_dump_mem (const void *mem, size_t size) return SPA_RESULT_OK; } -SpaResult -spa_debug_props (const SpaProps *props, const SpaTypeMap *map) +int +spa_debug_props (const struct spa_props *props, const struct spa_type_map *map) { - spa_debug_pod (&props->pod, map); + spa_debug_pod (&props->object.pod, map); return SPA_RESULT_OK; } -SpaResult -spa_debug_param (const SpaParam *param, const SpaTypeMap *map) +int +spa_debug_param (const struct spa_param *param, const struct spa_type_map *map) { - spa_debug_pod (¶m->pod, map); + spa_debug_pod (¶m->object.pod, map); return SPA_RESULT_OK; } @@ -175,7 +175,7 @@ struct pod_type_name { }; static void -print_pod_value (const SpaTypeMap *map, uint32_t size, uint32_t type, void *body, int prefix) +print_pod_value (const struct spa_type_map *map, uint32_t size, uint32_t type, void *body, int prefix) { switch (type) { case SPA_POD_TYPE_BOOL: @@ -202,20 +202,20 @@ print_pod_value (const SpaTypeMap *map, uint32_t size, uint32_t type, void *body break; case SPA_POD_TYPE_POINTER: { - SpaPODPointerBody *b = body; + struct spa_pod_pointer_body *b = body; printf ("%-*sPointer %s %p\n", prefix, "", spa_type_map_get_type (map, b->type), b->value); break; } case SPA_POD_TYPE_RECTANGLE: { - SpaRectangle *r = body; + struct spa_rectangle *r = body; printf ("%-*sRectangle %dx%d\n", prefix, "", r->width, r->height); break; } case SPA_POD_TYPE_FRACTION: { - SpaFraction *f = body; + struct spa_fraction *f = body; printf ("%-*sFraction %d/%d\n", prefix, "", f->num, f->denom); break; } @@ -224,7 +224,7 @@ print_pod_value (const SpaTypeMap *map, uint32_t size, uint32_t type, void *body break; case SPA_POD_TYPE_ARRAY: { - SpaPODArrayBody *b = body; + struct spa_pod_array_body *b = body; void *p; printf ("%-*sArray: child.size %d, child.type %d\n", prefix, "", b->child.size, b->child.type); @@ -234,7 +234,7 @@ print_pod_value (const SpaTypeMap *map, uint32_t size, uint32_t type, void *body } case SPA_POD_TYPE_STRUCT: { - SpaPOD *b = body, *p; + struct spa_pod *b = body, *p; printf ("%-*sStruct: size %d\n", prefix, "", size); SPA_POD_FOREACH (b, size, p) print_pod_value (map, p->size, p->type, SPA_POD_BODY (p), prefix + 2); @@ -242,8 +242,8 @@ print_pod_value (const SpaTypeMap *map, uint32_t size, uint32_t type, void *body } case SPA_POD_TYPE_OBJECT: { - SpaPODObjectBody *b = body; - SpaPOD *p; + struct spa_pod_object_body *b = body; + struct spa_pod *p; printf ("%-*sObject: size %d, id %d, type %s\n", prefix, "", size, b->id, spa_type_map_get_type (map, b->type)); @@ -253,7 +253,7 @@ print_pod_value (const SpaTypeMap *map, uint32_t size, uint32_t type, void *body } case SPA_POD_TYPE_PROP: { - SpaPODPropBody *b = body; + struct spa_pod_prop_body *b = body; void *alt; int i; @@ -288,8 +288,8 @@ print_pod_value (const SpaTypeMap *map, uint32_t size, uint32_t type, void *body } } -SpaResult -spa_debug_pod (const SpaPOD *pod, const SpaTypeMap *map) +int +spa_debug_pod (const struct spa_pod *pod, const struct spa_type_map *map) { map = map ? map : spa_type_map_get_default (); print_pod_value (map, pod->size, pod->type, SPA_POD_BODY (pod), 0); @@ -297,7 +297,7 @@ spa_debug_pod (const SpaPOD *pod, const SpaTypeMap *map) } static void -print_format_value (const SpaTypeMap *map, uint32_t size, uint32_t type, void *body) +print_format_value (const struct spa_type_map *map, uint32_t size, uint32_t type, void *body) { switch (type) { case SPA_POD_TYPE_BOOL: @@ -333,13 +333,13 @@ print_format_value (const SpaTypeMap *map, uint32_t size, uint32_t type, void *b break; case SPA_POD_TYPE_RECTANGLE: { - SpaRectangle *r = body; + struct spa_rectangle *r = body; fprintf (stderr, "%"PRIu32"x%"PRIu32, r->width, r->height); break; } case SPA_POD_TYPE_FRACTION: { - SpaFraction *f = body; + struct spa_fraction *f = body; fprintf (stderr, "%"PRIu32"/%"PRIu32, f->num, f->denom); break; } @@ -354,13 +354,13 @@ print_format_value (const SpaTypeMap *map, uint32_t size, uint32_t type, void *b } } -SpaResult -spa_debug_format (const SpaFormat *format, const SpaTypeMap *map) +int +spa_debug_format (const struct spa_format *format, const struct spa_type_map *map) { int i; const char *media_type; const char *media_subtype; - SpaPODProp *prop; + struct spa_pod_prop *prop; uint32_t mtype, mstype; if (format == NULL) @@ -427,8 +427,8 @@ spa_debug_format (const SpaFormat *format, const SpaTypeMap *map) return SPA_RESULT_OK; } -SpaResult -spa_debug_dict (const SpaDict *dict) +int +spa_debug_dict (const struct spa_dict *dict) { unsigned int i; @@ -446,23 +446,23 @@ spa_debug_dict (const SpaDict *dict) #define TRACE_BUFFER 4096 -typedef struct { - SpaLog log; - SpaRingbuffer trace_rb; +struct debug_log { + struct spa_log log; + struct spa_ringbuffer trace_rb; uint8_t trace_data[TRACE_BUFFER]; - SpaSource *source; -} DebugLog; + struct spa_source *source; +}; static void -do_logv (SpaLog *log, - SpaLogLevel level, - const char *file, - int line, - const char *func, - const char *fmt, - va_list args) +do_logv (struct spa_log *log, + enum spa_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, + va_list args) { - DebugLog *l = SPA_CONTAINER_OF (log, DebugLog, log); + struct debug_log *l = SPA_CONTAINER_OF (log, struct debug_log, log); char text[512], location[1024]; static const char *levels[] = { "-", "E", "W", "I", "D", "T", "*T*" }; int size; @@ -491,12 +491,12 @@ do_logv (SpaLog *log, } static void -do_log (SpaLog *log, - SpaLogLevel level, - const char *file, - int line, - const char *func, - const char *fmt, ...) +do_log (struct spa_log *log, + enum spa_log_level level, + const char *file, + int line, + const char *func, + const char *fmt, ...) { va_list args; va_start (args, fmt); @@ -504,8 +504,8 @@ do_log (SpaLog *log, va_end (args); } -static DebugLog log = { - { sizeof (SpaLog), +static struct debug_log log = { + { sizeof (struct spa_log), NULL, DEFAULT_LOG_LEVEL, do_log, @@ -514,14 +514,14 @@ static DebugLog log = { { 0, 0, TRACE_BUFFER, TRACE_BUFFER - 1 }, }; -SpaLog * +struct spa_log * spa_log_get_default (void) { return &log.log; } static void -on_trace_event (SpaSource *source) +on_trace_event (struct spa_source *source) { int32_t avail; uint32_t index; @@ -549,7 +549,7 @@ on_trace_event (SpaSource *source) } void -spa_log_default_set_trace_event (SpaSource *source) +spa_log_default_set_trace_event (struct spa_source *source) { log.source = source; log.source->func = on_trace_event; diff --git a/spa/lib/debug.h b/spa/lib/debug.h index 9de18a097..6cc0ddf02 100644 --- a/spa/lib/debug.h +++ b/spa/lib/debug.h @@ -33,17 +33,17 @@ extern "C" { #include #include -SpaResult spa_debug_port_info (const SpaPortInfo *info, const SpaTypeMap *map); -SpaResult spa_debug_buffer (const SpaBuffer *buffer, const SpaTypeMap *map); -SpaResult spa_debug_props (const SpaProps *props, const SpaTypeMap *map); -SpaResult spa_debug_param (const SpaParam *param, const SpaTypeMap *map); -SpaResult spa_debug_pod (const SpaPOD *pod, const SpaTypeMap *map); -SpaResult spa_debug_format (const SpaFormat *format, const SpaTypeMap *map); -SpaResult spa_debug_dump_mem (const void *data, size_t size); -SpaResult spa_debug_dict (const SpaDict *dict); +int spa_debug_port_info (const struct spa_port_info *info, const struct spa_type_map *map); +int spa_debug_buffer (const struct spa_buffer *buffer, const struct spa_type_map *map); +int spa_debug_props (const struct spa_props *props, const struct spa_type_map *map); +int spa_debug_param (const struct spa_param *param, const struct spa_type_map *map); +int spa_debug_pod (const struct spa_pod *pod, const struct spa_type_map *map); +int spa_debug_format (const struct spa_format *format, const struct spa_type_map *map); +int spa_debug_dump_mem (const void *data, size_t size); +int spa_debug_dict (const struct spa_dict *dict); -SpaLog * spa_log_get_default (void); -void spa_log_default_trace_purge (void); +struct spa_log* spa_log_get_default (void); +void spa_log_default_trace_purge (void); #ifdef __cplusplus diff --git a/spa/lib/format.c b/spa/lib/format.c index ac1a46d88..630985f7d 100644 --- a/spa/lib/format.c +++ b/spa/lib/format.c @@ -27,13 +27,13 @@ #include #include -SpaResult -spa_format_filter (const SpaFormat *format, - const SpaFormat *filter, - SpaPODBuilder *result) +int +spa_format_filter (const struct spa_format *format, + const struct spa_format *filter, + struct spa_pod_builder *result) { - SpaPODFrame f; - SpaResult res; + struct spa_pod_frame f; + int res; if (format == NULL || result == NULL) return SPA_RESULT_INVALID_ARGUMENTS; @@ -51,10 +51,10 @@ spa_format_filter (const SpaFormat *format, SPA_FORMAT_MEDIA_TYPE (filter), SPA_FORMAT_MEDIA_SUBTYPE (filter)); res = spa_props_filter (result, - SPA_POD_CONTENTS (SpaFormat, format), - SPA_POD_CONTENTS_SIZE (SpaFormat, format), - SPA_POD_CONTENTS (SpaFormat, filter), - SPA_POD_CONTENTS_SIZE (SpaFormat, filter)); + SPA_POD_CONTENTS (struct spa_format, format), + SPA_POD_CONTENTS_SIZE (struct spa_format, format), + SPA_POD_CONTENTS (struct spa_format, filter), + SPA_POD_CONTENTS_SIZE (struct spa_format, filter)); spa_pod_builder_pop (result, &f); return res; diff --git a/spa/lib/mapper.c b/spa/lib/mapper.c index 8147d1fb4..afc25b35c 100644 --- a/spa/lib/mapper.c +++ b/spa/lib/mapper.c @@ -28,16 +28,16 @@ #define MAX_TYPES 4096 -typedef struct { - SpaTypeMap map; +struct type_map{ + struct spa_type_map map; char *types[MAX_TYPES]; unsigned int n_types; -} TypeMap; +}; static uint32_t -type_map_get_id (SpaTypeMap *map, const char *type) +type_map_get_id (struct spa_type_map *map, const char *type) { - TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map); + struct type_map *this = SPA_CONTAINER_OF (map, struct type_map, map); unsigned int i = 0; if (type != NULL) { @@ -52,9 +52,9 @@ type_map_get_id (SpaTypeMap *map, const char *type) } static const char * -type_map_get_type (const SpaTypeMap *map, uint32_t id) +type_map_get_type (const struct spa_type_map *map, uint32_t id) { - TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map); + struct type_map *this = SPA_CONTAINER_OF (map, struct type_map, map); if (id <= this->n_types) return this->types[id]; @@ -63,14 +63,14 @@ type_map_get_type (const SpaTypeMap *map, uint32_t id) } static size_t -type_map_get_size (const SpaTypeMap *map) +type_map_get_size (const struct spa_type_map *map) { - TypeMap *this = SPA_CONTAINER_OF (map, TypeMap, map); + struct type_map *this = SPA_CONTAINER_OF (map, struct type_map, map); return this->n_types; } -static TypeMap default_type_map = { - { sizeof (SpaTypeMap), +static struct type_map default_type_map = { + { sizeof (struct spa_type_map), NULL, type_map_get_id, type_map_get_type, @@ -80,16 +80,16 @@ static TypeMap default_type_map = { 0 }; -static SpaTypeMap *default_map = &default_type_map.map; +static struct spa_type_map *default_map = &default_type_map.map; -SpaTypeMap * +struct spa_type_map * spa_type_map_get_default (void) { return default_map; } void -spa_type_map_set_default (SpaTypeMap *map) +spa_type_map_set_default (struct spa_type_map *map) { default_map = map; } diff --git a/spa/lib/mapper.h b/spa/lib/mapper.h index 7e1f23c16..a277b3175 100644 --- a/spa/lib/mapper.h +++ b/spa/lib/mapper.h @@ -26,8 +26,8 @@ extern "C" { #include -void spa_type_map_set_default (SpaTypeMap *map); -SpaTypeMap * spa_type_map_get_default (void); +void spa_type_map_set_default (struct spa_type_map *map); +struct spa_type_map * spa_type_map_get_default (void); #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/lib/props.c b/spa/lib/props.c index 64827907a..fc6c7fd97 100644 --- a/spa/lib/props.c +++ b/spa/lib/props.c @@ -25,7 +25,7 @@ #include static int -compare_value (SpaPODType type, const void *r1, const void *r2) +compare_value (enum spa_pod_type type, const void *r1, const void *r2) { switch (type) { case SPA_POD_TYPE_INVALID: @@ -45,8 +45,8 @@ compare_value (SpaPODType type, const void *r1, const void *r2) return strcmp (r1, r2); case SPA_POD_TYPE_RECTANGLE: { - const SpaRectangle *rec1 = (SpaRectangle*)r1, - *rec2 = (SpaRectangle*)r2; + const struct spa_rectangle *rec1 = (struct spa_rectangle*)r1, + *rec2 = (struct spa_rectangle*)r2; if (rec1->width == rec2->width && rec1->height == rec2->height) return 0; else if (rec1->width < rec2->width || rec1->height < rec2->height) @@ -56,8 +56,8 @@ compare_value (SpaPODType type, const void *r1, const void *r2) } case SPA_POD_TYPE_FRACTION: { - const SpaFraction *f1 = (SpaFraction*)r1, - *f2 = (SpaFraction*)r2; + const struct spa_fraction *f1 = (struct spa_fraction*)r1, + *f2 = (struct spa_fraction*)r2; uint64_t n1, n2; n1 = ((int64_t) f1->num) * f2->denom; n2 = ((int64_t) f2->num) * f1->denom; @@ -75,9 +75,9 @@ compare_value (SpaPODType type, const void *r1, const void *r2) } static void -fix_default (SpaPODProp *prop) +fix_default (struct spa_pod_prop *prop) { - void *val = SPA_MEMBER (prop, sizeof (SpaPODProp), void), + void *val = SPA_MEMBER (prop, sizeof (struct spa_pod_prop), void), *alt = SPA_MEMBER (val, prop->body.value.size, void); int i, nalt = SPA_POD_PROP_N_VALUES (prop) - 1; @@ -120,30 +120,30 @@ fix_default (SpaPODProp *prop) } } -static inline SpaPODProp * -find_prop (const SpaPOD *pod, uint32_t size, uint32_t key) +static inline struct spa_pod_prop * +find_prop (const struct spa_pod *pod, uint32_t size, uint32_t key) { - const SpaPOD *res; + const struct spa_pod *res; SPA_POD_FOREACH (pod, size, res) { - if (res->type == SPA_POD_TYPE_PROP && ((SpaPODProp*)res)->body.key == key) - return (SpaPODProp *)res; + if (res->type == SPA_POD_TYPE_PROP && ((struct spa_pod_prop*)res)->body.key == key) + return (struct spa_pod_prop *)res; } return NULL; } -SpaResult -spa_props_filter (SpaPODBuilder *b, - const SpaPOD *props, - uint32_t props_size, - const SpaPOD *filter, - uint32_t filter_size) +int +spa_props_filter (struct spa_pod_builder *b, + const struct spa_pod *props, + uint32_t props_size, + const struct spa_pod *filter, + uint32_t filter_size) { int j, k; - const SpaPOD *pr; + const struct spa_pod *pr; SPA_POD_FOREACH (props, props_size, pr) { - SpaPODFrame f; - SpaPODProp *p1, *p2, *np; + struct spa_pod_frame f; + struct spa_pod_prop *p1, *p2, *np; int nalt1, nalt2; void *alt1, *alt2, *a1, *a2; uint32_t rt1, rt2; @@ -151,7 +151,7 @@ spa_props_filter (SpaPODBuilder *b, if (pr->type != SPA_POD_TYPE_PROP) continue; - p1 = (SpaPODProp *) pr; + p1 = (struct spa_pod_prop *) pr; if (filter == NULL || (p2 = find_prop (filter, filter_size, p1->body.key)) == NULL) { /* no filter, copy the complete property */ @@ -168,14 +168,14 @@ spa_props_filter (SpaPODBuilder *b, /* else we filter. start with copying the property */ spa_pod_builder_push_prop (b, &f, p1->body.key, 0), - np = SPA_POD_BUILDER_DEREF (b, f.ref, SpaPODProp); + np = SPA_POD_BUILDER_DEREF (b, f.ref, struct spa_pod_prop); /* default value */ spa_pod_builder_raw (b, &p1->body.value, sizeof (p1->body.value) + p1->body.value.size); - alt1 = SPA_MEMBER (p1, sizeof (SpaPODProp), void); + alt1 = SPA_MEMBER (p1, sizeof (struct spa_pod_prop), void); nalt1 = SPA_POD_PROP_N_VALUES (p1); - alt2 = SPA_MEMBER (p2, sizeof (SpaPODProp), void); + alt2 = SPA_MEMBER (p2, sizeof (struct spa_pod_prop), void); nalt2 = SPA_POD_PROP_N_VALUES (p2); if (p1->body.flags & SPA_POD_PROP_FLAG_UNSET) { diff --git a/spa/lib/props.h b/spa/lib/props.h index 423523fb2..85f10be5f 100644 --- a/spa/lib/props.h +++ b/spa/lib/props.h @@ -26,12 +26,12 @@ extern "C" { #include -SpaResult -spa_props_filter (SpaPODBuilder *b, - const SpaPOD *props, - uint32_t props_size, - const SpaPOD *filter, - uint32_t filter_size); +int +spa_props_filter (struct spa_pod_builder *b, + const struct spa_pod *props, + uint32_t props_size, + const struct spa_pod *filter, + uint32_t filter_size); #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/plugins/alsa/alsa-monitor.c b/spa/plugins/alsa/alsa-monitor.c index 573770db8..146bb722d 100644 --- a/spa/plugins/alsa/alsa-monitor.c +++ b/spa/plugins/alsa/alsa-monitor.c @@ -33,33 +33,33 @@ #include #include -extern const SpaHandleFactory spa_alsa_sink_factory; -extern const SpaHandleFactory spa_alsa_source_factory; +#define NAME "alsa-monitor" -typedef struct _SpaALSAMonitor SpaALSAMonitor; +extern const struct spa_handle_factory spa_alsa_sink_factory; +extern const struct spa_handle_factory spa_alsa_source_factory; -typedef struct { +struct type { uint32_t handle_factory; - SpaTypeMonitor monitor; -} Type; + struct spa_type_monitor monitor; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->handle_factory = spa_type_map_get_id (map, SPA_TYPE__HandleFactory); spa_type_monitor_map (map, &type->monitor); } -struct _SpaALSAMonitor { - SpaHandle handle; - SpaMonitor monitor; +struct impl { + struct spa_handle handle; + struct spa_monitor monitor; - Type type; - SpaTypeMap *map; - SpaLog *log; - SpaLoop *main_loop; + struct type type; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop *main_loop; - SpaEventMonitorCallback event_cb; + struct spa_monitor_callbacks callbacks; void *user_data; struct udev* udev; @@ -69,7 +69,7 @@ struct _SpaALSAMonitor { struct udev_list_entry *devices; uint8_t item_buffer[4096]; - SpaMonitorItem *item; + struct spa_monitor_item *item; snd_ctl_t *ctl_hndl; struct udev_device *dev; @@ -78,11 +78,11 @@ struct _SpaALSAMonitor { int stream_idx; int fd; - SpaSource source; + struct spa_source source; }; -static SpaResult -alsa_udev_open (SpaALSAMonitor *this) +static int +impl_udev_open (struct impl *this) { if (this->udev != NULL) return SPA_RESULT_OK; @@ -110,15 +110,15 @@ path_get_card_id (const char *path) } static int -fill_item (SpaALSAMonitor *this, +fill_item (struct impl *this, snd_ctl_card_info_t *card_info, snd_pcm_info_t *dev_info, struct udev_device *dev) { const char *str, *name, *klass = NULL; - SpaPODBuilder b = SPA_POD_BUILDER_INIT (this->item_buffer, sizeof (this->item_buffer)); - const SpaHandleFactory *factory = NULL; - SpaPODFrame f[3]; + struct spa_pod_builder b = SPA_POD_BUILDER_INIT (this->item_buffer, sizeof (this->item_buffer)); + const struct spa_handle_factory *factory = NULL; + struct spa_pod_frame f[3]; char card_name[64]; switch (snd_pcm_info_get_stream (dev_info)) { @@ -229,13 +229,13 @@ fill_item (SpaALSAMonitor *this, -SPA_POD_TYPE_OBJECT, &f[0], 0); - this->item = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaMonitorItem); + this->item = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_monitor_item); return 0; } static void -close_card (SpaALSAMonitor *this) +close_card (struct impl *this) { if (this->ctl_hndl) snd_ctl_close (this->ctl_hndl); @@ -243,7 +243,7 @@ close_card (SpaALSAMonitor *this) } static int -open_card (SpaALSAMonitor *this, struct udev_device *dev) +open_card (struct impl *this, struct udev_device *dev) { int err; const char *str; @@ -274,7 +274,7 @@ open_card (SpaALSAMonitor *this, struct udev_device *dev) } static int -get_next_device (SpaALSAMonitor *this, struct udev_device *dev) +get_next_device (struct impl *this, struct udev_device *dev) { int err; snd_pcm_info_t *dev_info; @@ -324,9 +324,9 @@ again: } static void -alsa_on_fd_events (SpaSource *source) +impl_on_fd_events (struct spa_source *source) { - SpaALSAMonitor *this = source->data; + struct impl *this = source->data; struct udev_device *dev; const char *action; uint32_t type; @@ -350,37 +350,38 @@ alsa_on_fd_events (SpaSource *source) while (true) { uint8_t buffer[4096]; - SpaPODBuilder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); - SpaPODFrame f[1]; - SpaEventMonitor *event; + struct spa_pod_builder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); + struct spa_pod_frame f[1]; + struct spa_event *event; if (get_next_device (this, dev) < 0) break; spa_pod_builder_object (&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->item); - event = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaEventMonitor); - this->event_cb (&this->monitor, event, this->user_data); + event = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_event); + this->callbacks.event (&this->monitor, event, this->user_data); } close_card (this); } -static SpaResult -spa_alsa_monitor_set_event_callback (SpaMonitor *monitor, - SpaEventMonitorCallback callback, - void *user_data) +static int +impl_monitor_set_callbacks (struct spa_monitor *monitor, + const struct spa_monitor_callbacks *callbacks, + size_t callbacks_size, + void *user_data) { - SpaResult res; - SpaALSAMonitor *this; + int res; + struct impl *this; spa_return_val_if_fail (monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (monitor, SpaALSAMonitor, monitor); + this = SPA_CONTAINER_OF (monitor, struct impl, monitor); - this->event_cb = callback; - this->user_data = user_data; + if (callbacks) { + this->callbacks = *callbacks; + this->user_data = user_data; - if (callback) { - if ((res = alsa_udev_open (this)) < 0) + if ((res = impl_udev_open (this)) < 0) return res; this->umonitor = udev_monitor_new_from_netlink (this->udev, "udev"); @@ -393,33 +394,34 @@ spa_alsa_monitor_set_event_callback (SpaMonitor *monitor, udev_monitor_enable_receiving (this->umonitor); - this->source.func = alsa_on_fd_events; + this->source.func = impl_on_fd_events; this->source.data = this; this->source.fd = udev_monitor_get_fd (this->umonitor);; this->source.mask = SPA_IO_IN | SPA_IO_ERR; spa_loop_add_source (this->main_loop, &this->source); } else { + spa_zero (this->callbacks); spa_loop_remove_source (this->main_loop, &this->source); } return SPA_RESULT_OK; } -static SpaResult -spa_alsa_monitor_enum_items (SpaMonitor *monitor, - SpaMonitorItem **item, +static int +impl_monitor_enum_items (struct spa_monitor *monitor, + struct spa_monitor_item **item, uint32_t index) { - SpaResult res; - SpaALSAMonitor *this; + int res; + struct impl *this; spa_return_val_if_fail (monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (item != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (monitor, SpaALSAMonitor, monitor); + this = SPA_CONTAINER_OF (monitor, struct impl, monitor); - if ((res = alsa_udev_open (this)) < 0) + if ((res = impl_udev_open (this)) < 0) return res; if (index == 0 || this->index > index) { @@ -465,24 +467,24 @@ next: return SPA_RESULT_OK; } -static const SpaMonitor alsamonitor = { +static const struct spa_monitor impl_monitor = { NULL, - sizeof (SpaMonitor), - spa_alsa_monitor_set_event_callback, - spa_alsa_monitor_enum_items, + sizeof (struct spa_monitor), + impl_monitor_set_callbacks, + impl_monitor_enum_items, }; -static SpaResult -spa_alsa_monitor_get_interface (SpaHandle *handle, - uint32_t interface_id, - void **interface) +static int +impl_get_interface (struct spa_handle *handle, + uint32_t interface_id, + void **interface) { - SpaALSAMonitor *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaALSAMonitor *) handle; + this = (struct impl *) handle; if (interface_id == this->type.monitor.Monitor) *interface = &this->monitor; @@ -492,29 +494,29 @@ spa_alsa_monitor_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -alsa_monitor_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { return SPA_RESULT_OK; } -static SpaResult -alsa_monitor_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaALSAMonitor *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_alsa_monitor_get_interface; - handle->clear = alsa_monitor_clear, + handle->get_interface = impl_get_interface; + handle->clear = impl_clear, - this = (SpaALSAMonitor *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -535,35 +537,36 @@ alsa_monitor_init (const SpaHandleFactory *factory, init_type (&this->type, this->map); - this->monitor = alsamonitor; + this->monitor = impl_monitor; return SPA_RESULT_OK; } -static const SpaInterfaceInfo alsa_monitor_interfaces[] = +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Monitor, }, }; -static SpaResult -alsa_monitor_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - if (index < 0 || index >= SPA_N_ELEMENTS (alsa_monitor_interfaces)) + if (index < 0 || index >= SPA_N_ELEMENTS (impl_interfaces)) return SPA_RESULT_ENUM_END; - *info = &alsa_monitor_interfaces[index]; + *info = &impl_interfaces[index]; return SPA_RESULT_OK; } -const SpaHandleFactory spa_alsa_monitor_factory = -{ "alsa-monitor", +const struct spa_handle_factory spa_alsa_monitor_factory = +{ + NAME, NULL, - sizeof (SpaALSAMonitor), - alsa_monitor_init, - alsa_monitor_enum_interface_info, + sizeof (struct impl), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index e6a5b1327..4b649de60 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -25,34 +25,34 @@ #include #include +#define NAME "alsa-sink" + #include "alsa-utils.h" #define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0) -typedef struct _SpaALSAState SpaALSASink; - static const char default_device[] = "default"; static const uint32_t default_min_latency = 1024; static void -reset_alsa_sink_props (SpaALSAProps *props) +reset_props (struct props *props) { strncpy (props->device, default_device, 64); props->min_latency = default_min_latency; } -static SpaResult -spa_alsa_sink_node_get_props (SpaNode *node, - SpaProps **props) +static int +impl_node_get_props (struct spa_node *node, + struct spa_props **props) { - SpaALSASink *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct state *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); @@ -62,23 +62,23 @@ spa_alsa_sink_node_get_props (SpaNode *node, PROP (&f[1], this->type.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)), PROP_MM (&f[1], this->type.prop_min_latency, SPA_POD_TYPE_INT, this->props.min_latency, 1, INT32_MAX)); - *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_set_props (SpaNode *node, - const SpaProps *props) +static int +impl_node_set_props (struct spa_node *node, + const struct spa_props *props) { - SpaALSASink *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); if (props == NULL) { - reset_alsa_sink_props (&this->props); + reset_props (&this->props); return SPA_RESULT_OK; } else { spa_props_query (props, @@ -89,32 +89,32 @@ spa_alsa_sink_node_set_props (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -do_send_event (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_send_event (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - SpaALSASink *this = user_data; + struct state *this = user_data; this->callbacks.event (&this->node, data, this->user_data); return SPA_RESULT_OK; } -static SpaResult -do_command (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_command (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - SpaALSASink *this = user_data; - SpaResult res; - SpaCommand *cmd = data; + struct state *this = user_data; + int res; + struct spa_command *cmd = data; if (SPA_COMMAND_TYPE (cmd) == this->type.command_node.Start || SPA_COMMAND_TYPE (cmd) == this->type.command_node.Pause) { @@ -130,7 +130,7 @@ do_command (SpaLoop *loop, spa_loop_invoke (this->main_loop, do_send_event, SPA_ID_INVALID, - sizeof (SpaEventNodeAsyncComplete), + sizeof (struct spa_event_node_async_complete), &SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete, seq, res), this); @@ -138,16 +138,16 @@ do_command (SpaLoop *loop, return res; } -static SpaResult -spa_alsa_sink_node_send_command (SpaNode *node, - SpaCommand *command) +static int +impl_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaALSASink *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start || SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) { @@ -169,17 +169,17 @@ spa_alsa_sink_node_send_command (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_sink_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +impl_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaALSASink *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); this->callbacks = *callbacks; this->user_data = user_data; @@ -187,8 +187,8 @@ spa_alsa_sink_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_get_n_ports (SpaNode *node, +static int +impl_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -208,8 +208,8 @@ spa_alsa_sink_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_get_port_ids (SpaNode *node, +static int +impl_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -224,44 +224,44 @@ spa_alsa_sink_node_get_port_ids (SpaNode *node, } -static SpaResult -spa_alsa_sink_node_add_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_sink_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_sink_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - SpaALSASink *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); return spa_alsa_enum_format (this, format, filter, index); } -static SpaResult -spa_alsa_clear_buffers (SpaALSASink *this) +static int +clear_buffers (struct state *this) { if (this->n_buffers > 0) { spa_list_init (&this->ready); @@ -270,30 +270,30 @@ spa_alsa_clear_buffers (SpaALSASink *this) return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaALSASink *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); if (format == NULL) { spa_log_info (this->log, "clear format"); spa_alsa_pause (this, false); - spa_alsa_clear_buffers (this); + clear_buffers (this); spa_alsa_close (this); this->have_format = false; } else { - SpaAudioInfo info = { SPA_FORMAT_MEDIA_TYPE (format), - SPA_FORMAT_MEDIA_SUBTYPE (format), }; + struct spa_audio_info info = { SPA_FORMAT_MEDIA_TYPE (format), + SPA_FORMAT_MEDIA_SUBTYPE (format), }; if (info.media_type != this->type.media_type.audio || info.media_subtype != this->type.media_subtype.raw) @@ -318,20 +318,20 @@ spa_alsa_sink_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaALSASink *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct state *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -345,23 +345,23 @@ spa_alsa_sink_node_port_get_format (SpaNode *node, PROP (&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT, this->current_format.info.raw.rate), PROP (&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT, this->current_format.info.raw.channels)); - *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaALSASink *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -370,22 +370,22 @@ spa_alsa_sink_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { - SpaALSASink *this; - SpaPODBuilder b = { NULL }; - SpaPODFrame f[2]; + struct state *this; + struct spa_pod_builder b = { NULL }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (param != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -404,13 +404,13 @@ spa_alsa_sink_node_port_enum_params (SpaNode *node, case 1: spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header), - PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); + PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); break; case 2: spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Ringbuffer), - PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaRingbuffer)), + PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_ringbuffer)), PROP (&f[1], this->type.param_alloc_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, this->period_frames * this->frame_size * 32), PROP (&f[1], this->type.param_alloc_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0), PROP (&f[1], this->type.param_alloc_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1), @@ -421,33 +421,33 @@ spa_alsa_sink_node_port_enum_params (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } - *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_sink_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +impl_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { - SpaALSASink *this; + struct state *this; int i; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -458,12 +458,12 @@ spa_alsa_sink_node_port_use_buffers (SpaNode *node, if (n_buffers == 0) { spa_alsa_pause (this, false); - spa_alsa_clear_buffers (this); + clear_buffers (this); return SPA_RESULT_OK; } for (i = 0; i < n_buffers; i++) { - SpaALSABuffer *b = &this->buffers[i]; + struct buffer *b = &this->buffers[i]; uint32_t type = buffers[i]->datas[0].type; b->outbuf = buffers[i]; @@ -476,7 +476,7 @@ spa_alsa_sink_node_port_use_buffers (SpaNode *node, type == this->type.data.DmaBuf || type == this->type.data.MemPtr) && buffers[i]->datas[0].data == NULL) { - spa_log_error (this->log, "alsa-source: need mapped memory"); + spa_log_error (this->log, NAME " %p: need mapped memory", this); return SPA_RESULT_ERROR; } } @@ -485,21 +485,21 @@ spa_alsa_sink_node_port_use_buffers (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +impl_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { - SpaALSASink *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (buffers != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -509,17 +509,17 @@ spa_alsa_sink_node_port_alloc_buffers (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_sink_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaALSASink *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -528,26 +528,26 @@ spa_alsa_sink_node_port_set_io (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_port_reuse_buffer (SpaNode *node, +static int +impl_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_sink_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +impl_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { - SpaALSASink *this; - SpaResult res; + struct state *this; + int res; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -563,29 +563,29 @@ spa_alsa_sink_node_port_send_command (SpaNode *node, return res; } -static SpaResult -spa_alsa_sink_node_process_input (SpaNode *node) +static int +impl_node_process_input (struct spa_node *node) { - SpaALSASink *this; - SpaPortIO *input; + struct state *this; + struct spa_port_io *input; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASink, node); + this = SPA_CONTAINER_OF (node, struct state, node); input = this->io; spa_return_val_if_fail (input != NULL, SPA_RESULT_WRONG_STATE); if (input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id != SPA_ID_INVALID) { - SpaALSABuffer *b = &this->buffers[input->buffer_id]; + struct buffer *b = &this->buffers[input->buffer_id]; if (!b->outstanding) { - spa_log_warn (this->log, "alsa-sink %p: buffer %u in use", this, input->buffer_id); + spa_log_warn (this->log, NAME " %p: buffer %u in use", this, input->buffer_id); input->status = SPA_RESULT_INVALID_BUFFER_ID; return SPA_RESULT_ERROR; } - spa_log_trace (this->log, "alsa-sink %p: queue buffer %u", this, input->buffer_id); + spa_log_trace (this->log, NAME " %p: queue buffer %u", this, input->buffer_id); spa_list_insert (this->ready.prev, &b->link); b->outstanding = false; @@ -595,50 +595,50 @@ spa_alsa_sink_node_process_input (SpaNode *node) return SPA_RESULT_OK; } -static SpaResult -spa_alsa_sink_node_process_output (SpaNode *node) +static int +impl_node_process_output (struct spa_node *node) { return SPA_RESULT_NOT_IMPLEMENTED; } -static const SpaNode alsasink_node = { - sizeof (SpaNode), +static const struct spa_node impl_node = { + sizeof (struct spa_node), NULL, - spa_alsa_sink_node_get_props, - spa_alsa_sink_node_set_props, - spa_alsa_sink_node_send_command, - spa_alsa_sink_node_set_callbacks, - spa_alsa_sink_node_get_n_ports, - spa_alsa_sink_node_get_port_ids, - spa_alsa_sink_node_add_port, - spa_alsa_sink_node_remove_port, - spa_alsa_sink_node_port_enum_formats, - spa_alsa_sink_node_port_set_format, - spa_alsa_sink_node_port_get_format, - spa_alsa_sink_node_port_get_info, - spa_alsa_sink_node_port_enum_params, - spa_alsa_sink_node_port_set_param, - spa_alsa_sink_node_port_use_buffers, - spa_alsa_sink_node_port_alloc_buffers, - spa_alsa_sink_node_port_set_io, - spa_alsa_sink_node_port_reuse_buffer, - spa_alsa_sink_node_port_send_command, - spa_alsa_sink_node_process_input, - spa_alsa_sink_node_process_output, + impl_node_get_props, + impl_node_set_props, + impl_node_send_command, + impl_node_set_callbacks, + impl_node_get_n_ports, + impl_node_get_port_ids, + impl_node_add_port, + impl_node_remove_port, + impl_node_port_enum_formats, + impl_node_port_set_format, + impl_node_port_get_format, + impl_node_port_get_info, + impl_node_port_enum_params, + impl_node_port_set_param, + impl_node_port_use_buffers, + impl_node_port_alloc_buffers, + impl_node_port_set_io, + impl_node_port_reuse_buffer, + impl_node_port_send_command, + impl_node_process_input, + impl_node_process_output, }; -static SpaResult -spa_alsa_sink_get_interface (SpaHandle *handle, +static int +impl_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaALSASink *this; + struct state *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaALSASink *) handle; + this = (struct state *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -648,29 +648,29 @@ spa_alsa_sink_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -alsa_sink_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { return SPA_RESULT_OK; } -static SpaResult -alsa_sink_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaALSASink *this; + struct state *this; uint32_t i; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_alsa_sink_get_interface; - handle->clear = alsa_sink_clear; + handle->get_interface = impl_get_interface; + handle->clear = impl_clear; - this = (SpaALSASink *) handle; + this = (struct state *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -696,9 +696,9 @@ alsa_sink_init (const SpaHandleFactory *factory, } init_type (&this->type, this->map); - this->node = alsasink_node; + this->node = impl_node; this->stream = SND_PCM_STREAM_PLAYBACK; - reset_alsa_sink_props (&this->props); + reset_props (&this->props); spa_list_init (&this->ready); @@ -711,14 +711,14 @@ alsa_sink_init (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -static const SpaInterfaceInfo alsa_sink_interfaces[] = +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Node, }, }; -static SpaResult -alsa_sink_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -726,7 +726,7 @@ alsa_sink_enum_interface_info (const SpaHandleFactory *factory, switch (index) { case 0: - *info = &alsa_sink_interfaces[index]; + *info = &impl_interfaces[index]; break; default: return SPA_RESULT_ENUM_END; @@ -734,10 +734,10 @@ alsa_sink_enum_interface_info (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -const SpaHandleFactory spa_alsa_sink_factory = -{ "alsa-sink", +const struct spa_handle_factory spa_alsa_sink_factory = +{ NAME, NULL, - sizeof (SpaALSASink), - alsa_sink_init, - alsa_sink_enum_interface_info, + sizeof (struct state), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index 8bf7a4952..fb8b9d8fb 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -26,34 +26,34 @@ #include #include +#define NAME "alsa-source" + #include "alsa-utils.h" #define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0) -typedef struct _SpaALSAState SpaALSASource; - static const char default_device[] = "hw:0"; static const uint32_t default_min_latency = 1024; static void -reset_alsa_props (SpaALSAProps *props) +reset_props (struct props *props) { strncpy (props->device, default_device, 64); props->min_latency = default_min_latency; } -static SpaResult -spa_alsa_source_node_get_props (SpaNode *node, - SpaProps **props) +static int +impl_node_get_props (struct spa_node *node, + struct spa_props **props) { - SpaALSASource *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct state *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); @@ -63,23 +63,23 @@ spa_alsa_source_node_get_props (SpaNode *node, PROP (&f[1], this->type.prop_card_name, -SPA_POD_TYPE_STRING, this->props.card_name, sizeof (this->props.card_name)), PROP_MM (&f[1], this->type.prop_min_latency, SPA_POD_TYPE_INT, this->props.min_latency, 1, INT32_MAX)); - *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_set_props (SpaNode *node, - const SpaProps *props) +static int +impl_node_set_props (struct spa_node *node, + const struct spa_props *props) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); if (props == NULL) { - reset_alsa_props (&this->props); + reset_props (&this->props); return SPA_RESULT_OK; } else { spa_props_query (props, @@ -91,31 +91,31 @@ spa_alsa_source_node_set_props (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -do_send_event (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_send_event (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - SpaALSASource *this = user_data; + struct state *this = user_data; this->callbacks.event (&this->node, data, this->user_data); return SPA_RESULT_OK; } -static SpaResult -do_start (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_start (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - SpaALSASource *this = user_data; - SpaResult res; + struct state *this = user_data; + int res; res = spa_alsa_start (this, false); @@ -123,7 +123,7 @@ do_start (SpaLoop *loop, spa_loop_invoke (this->main_loop, do_send_event, SPA_ID_INVALID, - sizeof (SpaEventNodeAsyncComplete), + sizeof (struct spa_event_node_async_complete), &SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete, seq, res), this); @@ -131,16 +131,16 @@ do_start (SpaLoop *loop, return res; } -static SpaResult -do_pause (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_pause (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - SpaALSASource *this = user_data; - SpaResult res; + struct state *this = user_data; + int res; res = spa_alsa_pause (this, false); @@ -148,7 +148,7 @@ do_pause (SpaLoop *loop, spa_loop_invoke (this->main_loop, do_send_event, SPA_ID_INVALID, - sizeof (SpaEventNodeAsyncComplete), + sizeof (struct spa_event_node_async_complete), &SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete, seq, res), this); @@ -156,16 +156,16 @@ do_pause (SpaLoop *loop, return res; } -static SpaResult -spa_alsa_source_node_send_command (SpaNode *node, - SpaCommand *command) +static int +impl_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { if (!this->have_format) @@ -201,17 +201,17 @@ spa_alsa_source_node_send_command (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +impl_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); this->callbacks = *callbacks; this->user_data = user_data; @@ -219,8 +219,8 @@ spa_alsa_source_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_get_n_ports (SpaNode *node, +static int +impl_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -240,8 +240,8 @@ spa_alsa_source_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_get_port_ids (SpaNode *node, +static int +impl_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -256,36 +256,36 @@ spa_alsa_source_node_get_port_ids (SpaNode *node, } -static SpaResult -spa_alsa_source_node_add_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_source_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_source_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -293,11 +293,11 @@ spa_alsa_source_node_port_enum_formats (SpaNode *node, } static void -recycle_buffer (SpaALSASource *this, uint32_t buffer_id) +recycle_buffer (struct state *this, uint32_t buffer_id) { - SpaALSABuffer *b; + struct buffer *b; - spa_log_trace (this->log, "alsa-source %p: recycle buffer %u", this, buffer_id); + spa_log_trace (this->log, NAME " %p: recycle buffer %u", this, buffer_id); b = &this->buffers[buffer_id]; spa_return_if_fail (b->outstanding); @@ -306,8 +306,8 @@ recycle_buffer (SpaALSASource *this, uint32_t buffer_id) spa_list_insert (this->free.prev, &b->link); } -static SpaResult -spa_alsa_clear_buffers (SpaALSASource *this) +static int +clear_buffers (struct state *this) { if (this->n_buffers > 0) { spa_list_init (&this->free); @@ -317,29 +317,29 @@ spa_alsa_clear_buffers (SpaALSASource *this) return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); if (format == NULL) { spa_alsa_pause (this, false); - spa_alsa_clear_buffers (this); + clear_buffers (this); spa_alsa_close (this); this->have_format = false; } else { - SpaAudioInfo info = { SPA_FORMAT_MEDIA_TYPE (format), - SPA_FORMAT_MEDIA_SUBTYPE (format), }; + struct spa_audio_info info = { SPA_FORMAT_MEDIA_TYPE (format), + SPA_FORMAT_MEDIA_SUBTYPE (format), }; if (info.media_type != this->type.media_type.audio || info.media_subtype != this->type.media_subtype.raw) @@ -364,20 +364,20 @@ spa_alsa_source_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaALSASource *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct state *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -391,23 +391,23 @@ spa_alsa_source_node_port_get_format (SpaNode *node, PROP (&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT, this->current_format.info.raw.rate), PROP (&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT, this->current_format.info.raw.channels)); - *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -416,21 +416,21 @@ spa_alsa_source_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { - SpaALSASource *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct state *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (param != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -449,41 +449,41 @@ spa_alsa_source_node_port_enum_params (SpaNode *node, case 1: spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header), - PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); + PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); break; default: return SPA_RESULT_NOT_IMPLEMENTED; } - *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_source_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +impl_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { - SpaALSASource *this; - SpaResult res; + struct state *this; + int res; int i; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -492,12 +492,12 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node, if (this->n_buffers > 0) { spa_alsa_pause (this, false); - if ((res = spa_alsa_clear_buffers (this)) < 0) + if ((res = clear_buffers (this)) < 0) return res; } for (i = 0; i < n_buffers; i++) { - SpaALSABuffer *b = &this->buffers[i]; - SpaData *d = buffers[i]->datas; + struct buffer *b = &this->buffers[i]; + struct spa_data *d = buffers[i]->datas; b->outbuf = buffers[i]; b->outstanding = false; @@ -508,7 +508,7 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node, d[0].type == this->type.data.DmaBuf || d[0].type == this->type.data.MemPtr) && d[0].data != NULL)) { - spa_log_error (this->log, "alsa-source: need mapped memory"); + spa_log_error (this->log, NAME " %p: need mapped memory", this); return SPA_RESULT_ERROR; } spa_list_insert (this->free.prev, &b->link); @@ -519,21 +519,21 @@ spa_alsa_source_node_port_use_buffers (SpaNode *node, } -static SpaResult -spa_alsa_source_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +impl_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (buffers != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -543,17 +543,17 @@ spa_alsa_source_node_port_alloc_buffers (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_source_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -562,16 +562,16 @@ spa_alsa_source_node_port_set_io (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_port_reuse_buffer (SpaNode *node, +static int +impl_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (port_id == 0, SPA_RESULT_INVALID_PORT); @@ -586,18 +586,18 @@ spa_alsa_source_node_port_reuse_buffer (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_alsa_source_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +impl_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { - SpaALSASource *this; - SpaResult res; + struct state *this; + int res; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -611,21 +611,21 @@ spa_alsa_source_node_port_send_command (SpaNode *node, return res; } -static SpaResult -spa_alsa_source_node_process_input (SpaNode *node) +static int +impl_node_process_input (struct spa_node *node) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_source_node_process_output (SpaNode *node) +static int +impl_node_process_output (struct spa_node *node) { - SpaALSASource *this; - SpaPortIO *io; + struct state *this; + struct spa_port_io *io; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaALSASource, node); + this = SPA_CONTAINER_OF (node, struct state, node); io = this->io; spa_return_val_if_fail (io != NULL, SPA_RESULT_WRONG_STATE); @@ -639,57 +639,57 @@ spa_alsa_source_node_process_output (SpaNode *node) return SPA_RESULT_OK; } -static const SpaNode alsasource_node = { - sizeof (SpaNode), +static const struct spa_node impl_node = { + sizeof (struct spa_node), NULL, - spa_alsa_source_node_get_props, - spa_alsa_source_node_set_props, - spa_alsa_source_node_send_command, - spa_alsa_source_node_set_callbacks, - spa_alsa_source_node_get_n_ports, - spa_alsa_source_node_get_port_ids, - spa_alsa_source_node_add_port, - spa_alsa_source_node_remove_port, - spa_alsa_source_node_port_enum_formats, - spa_alsa_source_node_port_set_format, - spa_alsa_source_node_port_get_format, - spa_alsa_source_node_port_get_info, - spa_alsa_source_node_port_enum_params, - spa_alsa_source_node_port_set_param, - spa_alsa_source_node_port_use_buffers, - spa_alsa_source_node_port_alloc_buffers, - spa_alsa_source_node_port_set_io, - spa_alsa_source_node_port_reuse_buffer, - spa_alsa_source_node_port_send_command, - spa_alsa_source_node_process_input, - spa_alsa_source_node_process_output, + impl_node_get_props, + impl_node_set_props, + impl_node_send_command, + impl_node_set_callbacks, + impl_node_get_n_ports, + impl_node_get_port_ids, + impl_node_add_port, + impl_node_remove_port, + impl_node_port_enum_formats, + impl_node_port_set_format, + impl_node_port_get_format, + impl_node_port_get_info, + impl_node_port_enum_params, + impl_node_port_set_param, + impl_node_port_use_buffers, + impl_node_port_alloc_buffers, + impl_node_port_set_io, + impl_node_port_reuse_buffer, + impl_node_port_send_command, + impl_node_process_input, + impl_node_process_output, }; -static SpaResult -spa_alsa_source_clock_get_props (SpaClock *clock, - SpaProps **props) +static int +impl_clock_get_props (struct spa_clock *clock, + struct spa_props **props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_source_clock_set_props (SpaClock *clock, - const SpaProps *props) +static int +impl_clock_set_props (struct spa_clock *clock, + const struct spa_props *props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_alsa_source_clock_get_time (SpaClock *clock, +static int +impl_clock_get_time (struct spa_clock *clock, int32_t *rate, int64_t *ticks, int64_t *monotonic_time) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (clock != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (clock, SpaALSASource, clock); + this = SPA_CONTAINER_OF (clock, struct state, clock); if (rate) *rate = SPA_USEC_PER_SEC; @@ -701,26 +701,26 @@ spa_alsa_source_clock_get_time (SpaClock *clock, return SPA_RESULT_OK; } -static const SpaClock alsasource_clock = { - sizeof (SpaClock), +static const struct spa_clock impl_clock = { + sizeof (struct spa_clock), NULL, SPA_CLOCK_STATE_STOPPED, - spa_alsa_source_clock_get_props, - spa_alsa_source_clock_set_props, - spa_alsa_source_clock_get_time, + impl_clock_get_props, + impl_clock_set_props, + impl_clock_get_time, }; -static SpaResult -spa_alsa_source_get_interface (SpaHandle *handle, +static int +impl_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaALSASource *this; + struct state *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaALSASource *) handle; + this = (struct state *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -732,29 +732,29 @@ spa_alsa_source_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -alsa_source_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { return SPA_RESULT_OK; } -static SpaResult -alsa_source_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaALSASource *this; + struct state *this; uint32_t i; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_alsa_source_get_interface; - handle->clear = alsa_source_clear; + handle->get_interface = impl_get_interface; + handle->clear = impl_clear; - this = (SpaALSASource *) handle; + this = (struct state *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -780,10 +780,10 @@ alsa_source_init (const SpaHandleFactory *factory, } init_type (&this->type, this->map); - this->node = alsasource_node; - this->clock = alsasource_clock; + this->node = impl_node; + this->clock = impl_clock; this->stream = SND_PCM_STREAM_CAPTURE; - reset_alsa_props (&this->props); + reset_props (&this->props); spa_list_init (&this->free); spa_list_init (&this->ready); @@ -796,32 +796,32 @@ alsa_source_init (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -static const SpaInterfaceInfo alsa_source_interfaces[] = +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Node, }, { SPA_TYPE__Clock, }, }; -static SpaResult -alsa_source_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - if (index < 0 || index >= SPA_N_ELEMENTS (alsa_source_interfaces)) + if (index < 0 || index >= SPA_N_ELEMENTS (impl_interfaces)) return SPA_RESULT_ENUM_END; - *info = &alsa_source_interfaces[index]; + *info = &impl_interfaces[index]; return SPA_RESULT_OK; } -const SpaHandleFactory spa_alsa_source_factory = -{ "alsa-source", +const struct spa_handle_factory spa_alsa_source_factory = +{ NAME, NULL, - sizeof (SpaALSASource), - alsa_source_init, - alsa_source_enum_interface_info, + sizeof (struct state), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index 238a7acdb..be2df9a48 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -15,10 +15,10 @@ #define CHECK(s,msg) if ((err = (s)) < 0) { spa_log_error (state->log, msg ": %s", snd_strerror(err)); return err; } static int -spa_alsa_open (SpaALSAState *state) +spa_alsa_open (struct state *state) { int err; - SpaALSAProps *props = &state->props; + struct props *props = &state->props; if (state->opened) return 0; @@ -41,7 +41,7 @@ spa_alsa_open (SpaALSAState *state) } int -spa_alsa_close (SpaALSAState *state) +spa_alsa_close (struct state *state) { int err = 0; @@ -57,24 +57,24 @@ spa_alsa_close (SpaALSAState *state) return err; } -typedef struct { +struct format_info { off_t format_offset; snd_pcm_format_t format; -} FormatInfo; +}; #if __BYTE_ORDER == __BIG_ENDIAN -#define _FORMAT_LE(fmt) offsetof(Type, audio_format. fmt ## _OE) -#define _FORMAT_BE(fmt) offsetof(Type, audio_format. fmt) +#define _FORMAT_LE(fmt) offsetof(struct type, audio_format. fmt ## _OE) +#define _FORMAT_BE(fmt) offsetof(struct type, audio_format. fmt) #elif __BYTE_ORDER == __LITTLE_ENDIAN -#define _FORMAT_LE(fmt) offsetof(Type, audio_format. fmt) -#define _FORMAT_BE(fmt) offsetof(Type, audio_format. fmt ## _OE) +#define _FORMAT_LE(fmt) offsetof(struct type, audio_format. fmt) +#define _FORMAT_BE(fmt) offsetof(struct type, audio_format. fmt ## _OE) #endif -static const FormatInfo format_info[] = +static const struct format_info format_info[] = { - { offsetof(Type, audio_format.UNKNOWN), SND_PCM_FORMAT_UNKNOWN }, - { offsetof(Type, audio_format.S8), SND_PCM_FORMAT_S8 }, - { offsetof(Type, audio_format.U8), SND_PCM_FORMAT_U8 }, + { offsetof(struct type, audio_format.UNKNOWN), SND_PCM_FORMAT_UNKNOWN }, + { offsetof(struct type, audio_format.S8), SND_PCM_FORMAT_S8 }, + { offsetof(struct type, audio_format.U8), SND_PCM_FORMAT_U8 }, { _FORMAT_LE (S16), SND_PCM_FORMAT_S16_LE }, { _FORMAT_BE (S16), SND_PCM_FORMAT_S16_BE }, { _FORMAT_LE (U16), SND_PCM_FORMAT_U16_LE }, @@ -98,7 +98,7 @@ static const FormatInfo format_info[] = }; static snd_pcm_format_t -spa_alsa_format_to_alsa (Type *map, uint32_t format) +spa_alsa_format_to_alsa (struct type *map, uint32_t format) { int i; @@ -110,10 +110,10 @@ spa_alsa_format_to_alsa (Type *map, uint32_t format) return SND_PCM_FORMAT_UNKNOWN; } -SpaResult -spa_alsa_enum_format (SpaALSAState *state, - SpaFormat **format, - const SpaFormat *filter, +int +spa_alsa_enum_format (struct state *state, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { snd_pcm_t *hndl; @@ -122,11 +122,11 @@ spa_alsa_enum_format (SpaALSAState *state, int err, i, j, dir; unsigned int min, max; uint8_t buffer[4096]; - SpaPODBuilder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); - SpaPODFrame f[2]; - SpaPODProp *prop; - SpaFormat *fmt; - SpaResult res; + struct spa_pod_builder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); + struct spa_pod_frame f[2]; + struct spa_pod_prop *prop; + struct spa_format *fmt; + int res; bool opened; if (index == 1) @@ -150,10 +150,10 @@ spa_alsa_enum_format (SpaALSAState *state, spa_pod_builder_push_prop (&b, &f[1], state->type.format_audio.format, SPA_POD_PROP_RANGE_NONE); - prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, SpaPODProp); + prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, struct spa_pod_prop); for (i = 1, j = 0; i < SPA_N_ELEMENTS (format_info); i++) { - const FormatInfo *fi = &format_info[i]; + const struct format_info *fi = &format_info[i]; if (snd_pcm_format_mask_test (fmask, fi->format)) { uint32_t f = *SPA_MEMBER (&state->type, fi->format_offset, uint32_t); @@ -172,7 +172,7 @@ spa_alsa_enum_format (SpaALSAState *state, spa_pod_builder_push_prop (&b, &f[1], state->type.format_audio.rate, SPA_POD_PROP_RANGE_NONE); - prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, SpaPODProp); + prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, struct spa_pod_prop); spa_pod_builder_int (&b, SPA_CLAMP (44100, min, max)); if (min != max) { @@ -188,7 +188,7 @@ spa_alsa_enum_format (SpaALSAState *state, spa_pod_builder_push_prop (&b, &f[1], state->type.format_audio.channels, SPA_POD_PROP_RANGE_NONE); - prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, SpaPODProp); + prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, struct spa_pod_prop); spa_pod_builder_int (&b, SPA_CLAMP (2, min, max)); if (min != max) { @@ -199,13 +199,13 @@ spa_alsa_enum_format (SpaALSAState *state, spa_pod_builder_pop (&b, &f[1]); spa_pod_builder_pop (&b, &f[0]); - fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); spa_pod_builder_init (&b, state->format_buffer, sizeof (state->format_buffer)); if ((res = spa_format_filter (fmt, filter, &b)) < 0) return res; - *format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, 0, struct spa_format); if (!opened) spa_alsa_close (state); @@ -213,14 +213,14 @@ spa_alsa_enum_format (SpaALSAState *state, } int -spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, uint32_t flags) +spa_alsa_set_format (struct state *state, struct spa_audio_info *fmt, uint32_t flags) { unsigned int rrate, rchannels; snd_pcm_uframes_t period_size; int err, dir; snd_pcm_hw_params_t *params; snd_pcm_format_t format; - SpaAudioInfoRaw *info = &fmt->info.raw; + struct spa_audio_info_raw *info = &fmt->info.raw; snd_pcm_t *hndl; unsigned int periods; @@ -297,7 +297,7 @@ spa_alsa_set_format (SpaALSAState *state, SpaAudioInfo *fmt, uint32_t flags) } static int -set_swparams (SpaALSAState *state) +set_swparams (struct state *state) { snd_pcm_t *hndl = state->hndl; int err = 0; @@ -326,14 +326,14 @@ set_swparams (SpaALSAState *state) } static inline snd_pcm_uframes_t -pull_frames (SpaALSAState *state, +pull_frames (struct state *state, const snd_pcm_channel_area_t *my_areas, snd_pcm_uframes_t offset, snd_pcm_uframes_t frames, bool do_pull) { snd_pcm_uframes_t total_frames = 0, to_write = frames; - SpaPortIO *io = state->io; + struct spa_port_io *io = state->io; if (spa_list_is_empty (&state->ready) && do_pull) { io->status = SPA_RESULT_NEED_BUFFER; @@ -346,17 +346,17 @@ pull_frames (SpaALSAState *state, uint8_t *src, *dst; size_t n_bytes, n_frames, size; off_t offs; - SpaALSABuffer *b; + struct buffer *b; bool reuse = false; - SpaData *d; + struct spa_data *d; - b = spa_list_first (&state->ready, SpaALSABuffer, link); + b = spa_list_first (&state->ready, struct buffer, link); d = b->outbuf->datas; dst = SPA_MEMBER (my_areas[0].addr, offset * state->frame_size, uint8_t); if (b->rb) { - SpaRingbuffer *ringbuffer = &b->rb->ringbuffer; + struct spa_ringbuffer *ringbuffer = &b->rb->ringbuffer; uint32_t index; int32_t avail; @@ -406,13 +406,13 @@ pull_frames (SpaALSAState *state, } static snd_pcm_uframes_t -push_frames (SpaALSAState *state, +push_frames (struct state *state, const snd_pcm_channel_area_t *my_areas, snd_pcm_uframes_t offset, snd_pcm_uframes_t frames) { snd_pcm_uframes_t total_frames = 0; - SpaPortIO *io = state->io; + struct spa_port_io *io = state->io; if (spa_list_is_empty (&state->free)) { spa_log_trace (state->log, "no more buffers"); @@ -420,10 +420,10 @@ push_frames (SpaALSAState *state, else { uint8_t *src; size_t n_bytes; - SpaALSABuffer *b; - SpaData *d; + struct buffer *b; + struct spa_data *d; - b = spa_list_first (&state->free, SpaALSABuffer, link); + b = spa_list_first (&state->free, struct buffer, link); spa_list_remove (&b->link); if (b->h) { @@ -455,7 +455,7 @@ push_frames (SpaALSAState *state, } static int -alsa_try_resume (SpaALSAState *state) +alsa_try_resume (struct state *state) { int res; @@ -489,11 +489,11 @@ calc_timeout (size_t target, } static void -alsa_on_playback_timeout_event (SpaSource *source) +alsa_on_playback_timeout_event (struct spa_source *source) { uint64_t exp; int res; - SpaALSAState *state = source->data; + struct state *state = source->data; snd_pcm_t *hndl = state->hndl; snd_pcm_sframes_t avail; struct itimerspec ts; @@ -576,11 +576,11 @@ alsa_on_playback_timeout_event (SpaSource *source) static void -alsa_on_capture_timeout_event (SpaSource *source) +alsa_on_capture_timeout_event (struct spa_source *source) { uint64_t exp; int res; - SpaALSAState *state = source->data; + struct state *state = source->data; snd_pcm_t *hndl = state->hndl; snd_pcm_sframes_t avail; snd_pcm_uframes_t total_read = 0; @@ -645,8 +645,8 @@ alsa_on_capture_timeout_event (SpaSource *source) timerfd_settime (state->timerfd, TFD_TIMER_ABSTIME, &ts, NULL); } -SpaResult -spa_alsa_start (SpaALSAState *state, bool xrun_recover) +int +spa_alsa_start (struct state *state, bool xrun_recover) { int err; @@ -693,8 +693,8 @@ spa_alsa_start (SpaALSAState *state, bool xrun_recover) return SPA_RESULT_OK; } -SpaResult -spa_alsa_pause (SpaALSAState *state, bool xrun_recover) +int +spa_alsa_pause (struct state *state, bool xrun_recover) { int err; diff --git a/spa/plugins/alsa/alsa-utils.h b/spa/plugins/alsa/alsa-utils.h index 21381741a..06c8defd1 100644 --- a/spa/plugins/alsa/alsa-utils.h +++ b/spa/plugins/alsa/alsa-utils.h @@ -39,27 +39,24 @@ extern "C" { #include #include -typedef struct _SpaALSAState SpaALSAState; -typedef struct _SpaALSABuffer SpaALSABuffer; - -typedef struct { +struct props { char device[64]; char device_name[128]; char card_name[128]; uint32_t min_latency; -} SpaALSAProps; +}; #define MAX_BUFFERS 64 -struct _SpaALSABuffer { - SpaBuffer *outbuf; - SpaMetaHeader *h; - SpaMetaRingbuffer *rb; +struct buffer { + struct spa_buffer *outbuf; + struct spa_meta_header *h; + struct spa_meta_ringbuffer *rb; bool outstanding; - SpaList link; + struct spa_list link; }; -typedef struct { +struct type { uint32_t node; uint32_t clock; uint32_t format; @@ -68,21 +65,21 @@ typedef struct { uint32_t prop_device_name; uint32_t prop_card_name; uint32_t prop_min_latency; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeMediaSubtypeAudio media_subtype_audio; - SpaTypeFormatAudio format_audio; - SpaTypeAudioFormat audio_format; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; - SpaTypeParamAllocBuffers param_alloc_buffers; - SpaTypeParamAllocMetaEnable param_alloc_meta_enable; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_media_subtype_audio media_subtype_audio; + struct spa_type_format_audio format_audio; + struct spa_type_audio_format audio_format; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; + struct spa_type_param_alloc_buffers param_alloc_buffers; + struct spa_type_param_alloc_meta_enable param_alloc_meta_enable; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock); @@ -106,33 +103,33 @@ init_type (Type *type, SpaTypeMap *map) spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable); } -struct _SpaALSAState { - SpaHandle handle; - SpaNode node; - SpaClock clock; +struct state { + struct spa_handle handle; + struct spa_node node; + struct spa_clock clock; uint32_t seq; - Type type; - SpaTypeMap *map; - SpaLog *log; - SpaLoop *main_loop; - SpaLoop *data_loop; + struct type type; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop *main_loop; + struct spa_loop *data_loop; snd_pcm_stream_t stream; snd_output_t *output; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; uint8_t props_buffer[1024]; - SpaALSAProps props; + struct props props; bool opened; snd_pcm_t *hndl; bool have_format; - SpaAudioInfo current_format; + struct spa_audio_info current_format; uint8_t format_buffer[1024]; snd_pcm_uframes_t buffer_frames; @@ -142,20 +139,20 @@ struct _SpaALSAState { int channels; size_t frame_size; - SpaPortInfo info; + struct spa_port_info info; uint32_t params[3]; uint8_t params_buffer[1024]; - SpaPortIO *io; + struct spa_port_io *io; - SpaALSABuffer buffers[MAX_BUFFERS]; + struct buffer buffers[MAX_BUFFERS]; unsigned int n_buffers; - SpaList free; - SpaList ready; + struct spa_list free; + struct spa_list ready; size_t ready_offset; bool started; - SpaSource source; + struct spa_source source; int timerfd; bool alsa_started; int threshold; @@ -178,19 +175,19 @@ struct _SpaALSAState { SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \ SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__) -SpaResult -spa_alsa_enum_format (SpaALSAState *state, - SpaFormat **format, - const SpaFormat *filter, - uint32_t index); +int +spa_alsa_enum_format (struct state *state, + struct spa_format **format, + const struct spa_format *filter, + uint32_t index); -int spa_alsa_set_format (SpaALSAState *state, - SpaAudioInfo *info, - uint32_t flags); +int spa_alsa_set_format (struct state *state, + struct spa_audio_info *info, + uint32_t flags); -SpaResult spa_alsa_start (SpaALSAState *state, bool xrun_recover); -SpaResult spa_alsa_pause (SpaALSAState *state, bool xrun_recover); -SpaResult spa_alsa_close (SpaALSAState *state); +int spa_alsa_start (struct state *state, bool xrun_recover); +int spa_alsa_pause (struct state *state, bool xrun_recover); +int spa_alsa_close (struct state *state); #ifdef __cplusplus } /* extern "C" */ diff --git a/spa/plugins/alsa/alsa.c b/spa/plugins/alsa/alsa.c index 4da4ee1de..3141fe89f 100644 --- a/spa/plugins/alsa/alsa.c +++ b/spa/plugins/alsa/alsa.c @@ -20,12 +20,12 @@ #include #include -extern const SpaHandleFactory spa_alsa_source_factory; -extern const SpaHandleFactory spa_alsa_sink_factory; -extern const SpaHandleFactory spa_alsa_monitor_factory; +extern const struct spa_handle_factory spa_alsa_source_factory; +extern const struct spa_handle_factory spa_alsa_sink_factory; +extern const struct spa_handle_factory spa_alsa_monitor_factory; -SpaResult -spa_enum_handle_factory (const SpaHandleFactory **factory, +int +spa_handle_factory_enum (const struct spa_handle_factory **factory, uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index d6dad7394..ecab1b093 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -28,46 +28,46 @@ #include #include +#define NAME "audiomixer" + #define MAX_BUFFERS 64 #define MAX_PORTS 128 -typedef struct _SpaAudioMixer SpaAudioMixer; +struct buffer { + struct spa_buffer *outbuf; + bool outstanding; + struct spa_meta_header *h; + struct spa_list link; +}; -typedef struct { - SpaBuffer *outbuf; - bool outstanding; - SpaMetaHeader *h; - SpaList link; -} MixerBuffer; - -typedef struct { - SpaPortIO *io; +struct port { + struct spa_port_io *io; bool have_format; - SpaPortInfo info; + struct spa_port_info info; - MixerBuffer buffers[MAX_BUFFERS]; - uint32_t n_buffers; + struct buffer buffers[MAX_BUFFERS]; + uint32_t n_buffers; - SpaList queue; - size_t queued_offset; - size_t queued_bytes; -} SpaAudioMixerPort; + struct spa_list queue; + size_t queued_offset; + size_t queued_bytes; +}; -typedef struct { +struct type { uint32_t node; uint32_t format; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatAudio format_audio; - SpaTypeAudioFormat audio_format; - SpaTypeCommandNode command_node; - SpaTypeMeta meta; - SpaTypeData data; -} Type; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_audio format_audio; + struct spa_type_audio_format audio_format; + struct spa_type_command_node command_node; + struct spa_type_meta meta; + struct spa_type_data data; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->format = spa_type_map_get_id (map, SPA_TYPE__Format); @@ -80,24 +80,24 @@ init_type (Type *type, SpaTypeMap *map) spa_type_data_map (map, &type->data); } -struct _SpaAudioMixer { - SpaHandle handle; - SpaNode node; +struct impl { + struct spa_handle handle; + struct spa_node node; - Type type; - SpaTypeMap *map; - SpaLog *log; + struct type type; + struct spa_type_map *map; + struct spa_log *log; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; int port_count; int port_queued; - SpaAudioMixerPort in_ports[MAX_PORTS]; - SpaAudioMixerPort out_ports[1]; + struct port in_ports[MAX_PORTS]; + struct port out_ports[1]; bool have_format; - SpaAudioInfo format; + struct spa_audio_info format; uint8_t format_buffer[4096]; bool started; @@ -123,30 +123,30 @@ struct _SpaAudioMixer { SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \ SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__) -static SpaResult -spa_audiomixer_node_get_props (SpaNode *node, - SpaProps **props) +static int +impl_node_get_props (struct spa_node *node, + struct spa_props **props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiomixer_node_set_props (SpaNode *node, - const SpaProps *props) +static int +impl_node_set_props (struct spa_node *node, + const struct spa_props *props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiomixer_node_send_command (SpaNode *node, - SpaCommand *command) +static int +impl_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaAudioMixer *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { this->started = true; @@ -160,17 +160,17 @@ spa_audiomixer_node_send_command (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +impl_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaAudioMixer *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); this->callbacks = *callbacks; this->user_data = user_data; @@ -178,8 +178,8 @@ spa_audiomixer_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_node_get_n_ports (SpaNode *node, +static int +impl_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -199,19 +199,19 @@ spa_audiomixer_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_node_get_port_ids (SpaNode *node, +static int +impl_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, uint32_t *output_ids) { - SpaAudioMixer *this; + struct impl *this; int i, idx; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (input_ids) { for (i = 0, idx = 0; i < MAX_PORTS && idx < n_input_ports; i++) { @@ -225,16 +225,16 @@ spa_audiomixer_node_get_port_ids (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_node_add_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { - SpaAudioMixer *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_FREE_IN_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -248,17 +248,17 @@ spa_audiomixer_node_add_port (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { - SpaAudioMixer *this; - SpaPortIO *io; + struct impl *this; + struct spa_port_io *io; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_IN_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -273,26 +273,26 @@ spa_audiomixer_node_remove_port (SpaNode *node, } -static SpaResult -spa_audiomixer_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - SpaAudioMixer *this; - SpaResult res; - SpaFormat *fmt; + struct impl *this; + int res; + struct spa_format *fmt; uint8_t buffer[256]; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; uint32_t count, match; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -312,20 +312,20 @@ next: default: return SPA_RESULT_ENUM_END; } - fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer)); if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK || match++ != index) goto next; - *format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, 0, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -clear_buffers (SpaAudioMixer *this, SpaAudioMixerPort *port) +static int +clear_buffers (struct impl *this, struct port *port) { if (port->n_buffers > 0) { spa_log_info (this->log, "audio-mixer %p: clear buffers %p", this, port); @@ -335,19 +335,19 @@ clear_buffers (SpaAudioMixer *this, SpaAudioMixerPort *port) return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaAudioMixer *this; - SpaAudioMixerPort *port; + struct impl *this; + struct port *port; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -357,8 +357,8 @@ spa_audiomixer_node_port_set_format (SpaNode *node, port->have_format = false; clear_buffers (this, port); } else { - SpaAudioInfo info = { SPA_FORMAT_MEDIA_TYPE (format), - SPA_FORMAT_MEDIA_SUBTYPE (format), }; + struct spa_audio_info info = { SPA_FORMAT_MEDIA_TYPE (format), + SPA_FORMAT_MEDIA_SUBTYPE (format), }; if (info.media_type != this->type.media_type.audio || info.media_subtype != this->type.media_subtype.raw) @@ -374,21 +374,21 @@ spa_audiomixer_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaAudioMixer *this; - SpaAudioMixerPort *port; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct port *port; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -403,24 +403,24 @@ spa_audiomixer_node_port_get_format (SpaNode *node, PROP (&f[1], this->type.format_audio.format, SPA_POD_TYPE_ID, this->format.info.raw.format), PROP (&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT, this->format.info.raw.rate), PROP (&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT, this->format.info.raw.channels)); - *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaAudioMixer *this; - SpaAudioMixerPort *port; + struct impl *this; + struct port *port; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -430,39 +430,39 @@ spa_audiomixer_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiomixer_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiomixer_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +impl_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { - SpaAudioMixer *this; - SpaAudioMixerPort *port; + struct impl *this; + struct port *port; uint32_t i; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -473,8 +473,8 @@ spa_audiomixer_node_port_use_buffers (SpaNode *node, clear_buffers (this, port); for (i = 0; i < n_buffers; i++) { - MixerBuffer *b; - SpaData *d = buffers[i]->datas; + struct buffer *b; + struct spa_data *d = buffers[i]->datas; b = &port->buffers[i]; b->outbuf = buffers[i]; @@ -496,30 +496,30 @@ spa_audiomixer_node_port_use_buffers (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +impl_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiomixer_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaAudioMixer *this; - SpaAudioMixerPort *port; + struct impl *this; + struct port *port; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT_NUM (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -530,31 +530,31 @@ spa_audiomixer_node_port_set_io (SpaNode *node, } static void -recycle_buffer (SpaAudioMixer *this, uint32_t id) +recycle_buffer (struct impl *this, uint32_t id) { - SpaAudioMixerPort *port = &this->out_ports[0]; - MixerBuffer *b = &port->buffers[id]; + struct port *port = &this->out_ports[0]; + struct buffer *b = &port->buffers[id]; if (!b->outstanding) { - spa_log_warn (this->log, "audiomixer %p: buffer %d not outstanding", this, id); + spa_log_warn (this->log, NAME "%p: buffer %d not outstanding", this, id); return; } spa_list_insert (port->queue.prev, &b->link); b->outstanding = false; - spa_log_trace (this->log, "audiomixer %p: recycle buffer %d", this, id); + spa_log_trace (this->log, NAME " %p: recycle buffer %d", this, id); } -static SpaResult -spa_audiomixer_node_port_reuse_buffer (SpaNode *node, +static int +impl_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { - SpaAudioMixer *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id), SPA_RESULT_INVALID_PORT); @@ -563,24 +563,24 @@ spa_audiomixer_node_port_reuse_buffer (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiomixer_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +impl_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { return SPA_RESULT_NOT_IMPLEMENTED; } static inline void -add_port_data (SpaAudioMixer *this, void *out, size_t outsize, SpaAudioMixerPort *port, int layer) +add_port_data (struct impl *this, void *out, size_t outsize, struct port *port, int layer) { void *in; size_t insize; - MixerBuffer *b; - SpaData *id; + struct buffer *b; + struct spa_data *id; - b = spa_list_first (&port->queue, MixerBuffer, link); + b = spa_list_first (&port->queue, struct buffer, link); id = b->outbuf->datas; in = SPA_MEMBER (id[0].data, port->queued_offset + id[0].chunk->offset, void); @@ -604,26 +604,26 @@ add_port_data (SpaAudioMixer *this, void *out, size_t outsize, SpaAudioMixerPort port->queued_bytes -= outsize; if (outsize == insize) { - spa_log_trace (this->log, "audiomixer %p: return buffer %d on port %p %zd", + spa_log_trace (this->log, NAME " %p: return buffer %d on port %p %zd", this, b->outbuf->id, port, outsize); port->io->buffer_id = b->outbuf->id; spa_list_remove (&b->link); b->outstanding = true; port->queued_offset = 0; } else { - spa_log_trace (this->log, "audiomixer %p: keeping buffer %d on port %p %zd %zd", + spa_log_trace (this->log, NAME " %p: keeping buffer %d on port %p %zd %zd", this, b->outbuf->id, port, port->queued_bytes, outsize); } } -static SpaResult -mix_output (SpaAudioMixer *this, size_t n_bytes) +static int +mix_output (struct impl *this, size_t n_bytes) { - MixerBuffer *outbuf; + struct buffer *outbuf; int i, layer; - SpaAudioMixerPort *outport; - SpaPortIO *output; - SpaData *od; + struct port *outport; + struct spa_port_io *output; + struct spa_data *od; outport = &this->out_ports[0]; output = outport->io; @@ -631,7 +631,7 @@ mix_output (SpaAudioMixer *this, size_t n_bytes) if (spa_list_is_empty (&outport->queue)) return SPA_RESULT_OUT_OF_BUFFERS; - outbuf = spa_list_first (&outport->queue, MixerBuffer, link); + outbuf = spa_list_first (&outport->queue, struct buffer, link); spa_list_remove (&outbuf->link); outbuf->outstanding = true; @@ -641,16 +641,16 @@ mix_output (SpaAudioMixer *this, size_t n_bytes) od[0].chunk->size = n_bytes; od[0].chunk->stride = 0; - spa_log_trace (this->log, "audiomixer %p: dequeue output buffer %d %zd", + spa_log_trace (this->log, NAME " %p: dequeue output buffer %d %zd", this, outbuf->outbuf->id, n_bytes); for (layer = 0, i = 0; i < MAX_PORTS; i++) { - SpaAudioMixerPort *port = &this->in_ports[i]; + struct port *port = &this->in_ports[i]; if (port->io == NULL || port->n_buffers == 0) continue; if (spa_list_is_empty (&port->queue)) { - spa_log_warn (this->log, "audiomixer %p: underrun stream %d", this, i); + spa_log_warn (this->log, NAME " %p: underrun stream %d", this, i); port->queued_bytes = 0; port->queued_offset = 0; continue; @@ -663,18 +663,18 @@ mix_output (SpaAudioMixer *this, size_t n_bytes) return SPA_RESULT_HAVE_BUFFER; } -static SpaResult -spa_audiomixer_node_process_input (SpaNode *node) +static int +impl_node_process_input (struct spa_node *node) { - SpaAudioMixer *this; + struct impl *this; uint32_t i; - SpaAudioMixerPort *outport; + struct port *outport; size_t min_queued = SIZE_MAX; - SpaPortIO *output; + struct spa_port_io *output; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); outport = &this->out_ports[0]; output = outport->io; @@ -684,8 +684,8 @@ spa_audiomixer_node_process_input (SpaNode *node) return SPA_RESULT_HAVE_BUFFER; for (i = 0; i < MAX_PORTS; i++) { - SpaAudioMixerPort *port = &this->in_ports[i]; - SpaPortIO *input; + struct port *port = &this->in_ports[i]; + struct spa_port_io *input; if ((input = port->io) == NULL || port->n_buffers == 0) continue; @@ -693,10 +693,10 @@ spa_audiomixer_node_process_input (SpaNode *node) if (port->queued_bytes == 0 && input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id != SPA_ID_INVALID) { - MixerBuffer *b = &port->buffers[input->buffer_id]; + struct buffer *b = &port->buffers[input->buffer_id]; if (!b->outstanding) { - spa_log_warn (this->log, "audiomixer %p: buffer %u in use", this, input->buffer_id); + spa_log_warn (this->log, NAME " %p: buffer %u in use", this, input->buffer_id); input->status = SPA_RESULT_INVALID_BUFFER_ID; continue; } @@ -708,7 +708,7 @@ spa_audiomixer_node_process_input (SpaNode *node) spa_list_insert (port->queue.prev, &b->link); port->queued_bytes += b->outbuf->datas[0].chunk->size; - spa_log_trace (this->log, "audiomixer %p: queue buffer %d on port %d %zd %zd", + spa_log_trace (this->log, NAME " %p: queue buffer %d on port %d %zd %zd", this, b->outbuf->id, i, port->queued_bytes, min_queued); } if (port->queued_bytes > 0 && port->queued_bytes < min_queued) @@ -723,18 +723,18 @@ spa_audiomixer_node_process_input (SpaNode *node) return output->status; } -static SpaResult -spa_audiomixer_node_process_output (SpaNode *node) +static int +impl_node_process_output (struct spa_node *node) { - SpaAudioMixer *this; - SpaAudioMixerPort *port; - SpaPortIO *output; + struct impl *this; + struct port *port; + struct spa_port_io *output; int i; size_t min_queued = SIZE_MAX; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); + this = SPA_CONTAINER_OF (node, struct impl, node); port = &this->out_ports[0]; output = port->io; @@ -750,7 +750,7 @@ spa_audiomixer_node_process_output (SpaNode *node) } /* produce more output if possible */ for (i = 0; i < MAX_PORTS; i++) { - SpaAudioMixerPort *port = &this->in_ports[i]; + struct port *port = &this->in_ports[i]; if (port->io == NULL || port->n_buffers == 0) continue; @@ -764,8 +764,8 @@ spa_audiomixer_node_process_output (SpaNode *node) else { /* take requested output range and apply to input */ for (i = 0; i < MAX_PORTS; i++) { - SpaAudioMixerPort *port = &this->in_ports[i]; - SpaPortIO *input; + struct port *port = &this->in_ports[i]; + struct spa_port_io *input; if ((input = port->io) == NULL || port->n_buffers == 0) continue; @@ -777,50 +777,50 @@ spa_audiomixer_node_process_output (SpaNode *node) else { input->status = SPA_RESULT_OK; } - spa_log_trace (this->log, "audiomixer %p: port %d %d queued %zd, res %d", this, + spa_log_trace (this->log, NAME " %p: port %d %d queued %zd, res %d", this, i, output->range.min_size, port->queued_bytes, input->status); } } return output->status; } -static const SpaNode audiomixer_node = { - sizeof (SpaNode), +static const struct spa_node impl_node = { + sizeof (struct spa_node), NULL, - spa_audiomixer_node_get_props, - spa_audiomixer_node_set_props, - spa_audiomixer_node_send_command, - spa_audiomixer_node_set_callbacks, - spa_audiomixer_node_get_n_ports, - spa_audiomixer_node_get_port_ids, - spa_audiomixer_node_add_port, - spa_audiomixer_node_remove_port, - spa_audiomixer_node_port_enum_formats, - spa_audiomixer_node_port_set_format, - spa_audiomixer_node_port_get_format, - spa_audiomixer_node_port_get_info, - spa_audiomixer_node_port_enum_params, - spa_audiomixer_node_port_set_param, - spa_audiomixer_node_port_use_buffers, - spa_audiomixer_node_port_alloc_buffers, - spa_audiomixer_node_port_set_io, - spa_audiomixer_node_port_reuse_buffer, - spa_audiomixer_node_port_send_command, - spa_audiomixer_node_process_input, - spa_audiomixer_node_process_output, + impl_node_get_props, + impl_node_set_props, + impl_node_send_command, + impl_node_set_callbacks, + impl_node_get_n_ports, + impl_node_get_port_ids, + impl_node_add_port, + impl_node_remove_port, + impl_node_port_enum_formats, + impl_node_port_set_format, + impl_node_port_get_format, + impl_node_port_get_info, + impl_node_port_enum_params, + impl_node_port_set_param, + impl_node_port_use_buffers, + impl_node_port_alloc_buffers, + impl_node_port_set_io, + impl_node_port_reuse_buffer, + impl_node_port_send_command, + impl_node_process_input, + impl_node_process_output, }; -static SpaResult -spa_audiomixer_get_interface (SpaHandle *handle, +static int +impl_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaAudioMixer *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaAudioMixer *) handle; + this = (struct impl *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -830,29 +830,29 @@ spa_audiomixer_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { return SPA_RESULT_OK; } -static SpaResult -spa_audiomixer_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaAudioMixer *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_audiomixer_get_interface; - handle->clear = spa_audiomixer_clear; + handle->get_interface = impl_get_interface; + handle->clear = impl_clear; - this = (SpaAudioMixer *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -866,7 +866,7 @@ spa_audiomixer_init (const SpaHandleFactory *factory, } init_type (&this->type, this->map); - this->node = audiomixer_node; + this->node = impl_node; this->out_ports[0].io = NULL; this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | @@ -876,14 +876,14 @@ spa_audiomixer_init (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -static const SpaInterfaceInfo audiomixer_interfaces[] = +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Node, }, }; -static SpaResult -audiomixer_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -891,7 +891,7 @@ audiomixer_enum_interface_info (const SpaHandleFactory *factory, switch (index) { case 0: - *info = &audiomixer_interfaces[index]; + *info = &impl_interfaces[index]; break; default: return SPA_RESULT_ENUM_END; @@ -899,10 +899,10 @@ audiomixer_enum_interface_info (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -const SpaHandleFactory spa_audiomixer_factory = -{ "audiomixer", +const struct spa_handle_factory spa_audiomixer_factory = +{ NAME, NULL, - sizeof (SpaAudioMixer), - spa_audiomixer_init, - audiomixer_enum_interface_info, + sizeof (struct impl), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/audiomixer/plugin.c b/spa/plugins/audiomixer/plugin.c index 633b7bed7..99687238d 100644 --- a/spa/plugins/audiomixer/plugin.c +++ b/spa/plugins/audiomixer/plugin.c @@ -20,20 +20,21 @@ #include #include -extern const SpaHandleFactory spa_audiomixer_factory; +extern const struct spa_handle_factory spa_audiomixer_factory; -SpaResult -spa_enum_handle_factory (const SpaHandleFactory **factory, - uint32_t index) +int +spa_handle_factory_enum(const struct spa_handle_factory **factory, + uint32_t index) { - spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); + spa_return_val_if_fail(factory != NULL, + SPA_RESULT_INVALID_ARGUMENTS); - switch (index) { - case 0: - *factory = &spa_audiomixer_factory; - break; - default: - return SPA_RESULT_ENUM_END; - } - return SPA_RESULT_OK; + switch (index) { + case 0: + *factory = &spa_audiomixer_factory; + break; + default: + return SPA_RESULT_ENUM_END; + } + return SPA_RESULT_OK; } diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index f018bfc80..2ec45806f 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -34,11 +34,13 @@ #include #include +#define IMPL_NAME "audiotestsrc" + #define SAMPLES_TO_TIME(this,s) ((s) * SPA_NSEC_PER_SEC / (this)->current_format.info.raw.rate) #define BYTES_TO_SAMPLES(this,b) ((b)/(this)->bpf) #define BYTES_TO_TIME(this,b) SAMPLES_TO_TIME(this, BYTES_TO_SAMPLES (this, b)) -typedef struct { +struct type { uint32_t node; uint32_t clock; uint32_t format; @@ -49,20 +51,20 @@ typedef struct { uint32_t prop_volume; uint32_t wave_sine; uint32_t wave_square; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatAudio format_audio; - SpaTypeAudioFormat audio_format; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; - SpaTypeParamAllocBuffers param_alloc_buffers; - SpaTypeParamAllocMetaEnable param_alloc_meta_enable; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_audio format_audio; + struct spa_type_audio_format audio_format; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; + struct spa_type_param_alloc_buffers param_alloc_buffers; + struct spa_type_param_alloc_meta_enable param_alloc_meta_enable; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock); @@ -86,61 +88,59 @@ init_type (Type *type, SpaTypeMap *map) spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable); } -typedef struct _SpaAudioTestSrc SpaAudioTestSrc; - -typedef struct { +struct props { bool live; uint32_t wave; double freq; double volume; -} SpaAudioTestSrcProps; +}; #define MAX_BUFFERS 16 -typedef struct _ATSBuffer ATSBuffer; - -struct _ATSBuffer { - SpaBuffer *outbuf; +struct buffer { + struct spa_buffer *outbuf; bool outstanding; - SpaMetaHeader *h; - SpaMetaRingbuffer *rb; - SpaList link; + struct spa_meta_header *h; + struct spa_meta_ringbuffer *rb; + struct spa_list link; }; -typedef SpaResult (*RenderFunc) (SpaAudioTestSrc *this, void *samples, size_t n_samples); +struct impl; -struct _SpaAudioTestSrc { - SpaHandle handle; - SpaNode node; - SpaClock clock; +typedef int (*render_func_t) (struct impl *this, void *samples, size_t n_samples); - Type type; - SpaTypeMap *map; - SpaLog *log; - SpaLoop *data_loop; +struct impl { + struct spa_handle handle; + struct spa_node node; + struct spa_clock clock; + + struct type type; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop *data_loop; uint8_t props_buffer[512]; - SpaAudioTestSrcProps props; + struct props props; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; - SpaSource timer_source; + struct spa_source timer_source; struct itimerspec timerspec; - SpaPortInfo info; + struct spa_port_info info; uint32_t params[2]; uint8_t params_buffer[1024]; - SpaPortIO *io; + struct spa_port_io *io; bool have_format; - SpaAudioInfo current_format; + struct spa_audio_info current_format; uint8_t format_buffer[1024]; size_t bpf; - RenderFunc render_func; + render_func_t render_func; double accumulator; - ATSBuffer buffers[MAX_BUFFERS]; + struct buffer buffers[MAX_BUFFERS]; uint32_t n_buffers; bool started; @@ -148,7 +148,7 @@ struct _SpaAudioTestSrc { uint64_t elapsed_time; uint64_t sample_count; - SpaList empty; + struct spa_list empty; }; #define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0) @@ -159,7 +159,7 @@ struct _SpaAudioTestSrc { #define DEFAULT_VOLUME 1.0 static void -reset_audiotestsrc_props (SpaAudioTestSrc *this, SpaAudioTestSrcProps *props) +impl_reset_props (struct impl *this, struct props *props) { props->live = DEFAULT_LIVE; props->wave = this->type. DEFAULT_WAVE; @@ -180,18 +180,18 @@ reset_audiotestsrc_props (SpaAudioTestSrc *this, SpaAudioTestSrcProps *props) SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \ SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__) -static SpaResult -spa_audiotestsrc_node_get_props (SpaNode *node, - SpaProps **props) +static int +impl_node_get_props (struct spa_node *node, + struct spa_props **props) { - SpaAudioTestSrc *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_props (&b, &f[0], this->type.props, @@ -204,23 +204,23 @@ spa_audiotestsrc_node_get_props (SpaNode *node, PROP_MM (&f[1], this->type.prop_volume, SPA_POD_TYPE_DOUBLE, this->props.volume, 0.0, 10.0)); - *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_set_props (SpaNode *node, - const SpaProps *props) +static int +impl_node_set_props (struct spa_node *node, + const struct spa_props *props) { - SpaAudioTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (props == NULL) { - reset_audiotestsrc_props (this, &this->props); + impl_reset_props (this, &this->props); } else { spa_props_query (props, this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live, @@ -238,8 +238,8 @@ spa_audiotestsrc_node_set_props (SpaNode *node, return SPA_RESULT_OK; } -static inline SpaResult -send_have_output (SpaAudioTestSrc *this) +static inline int +send_have_output (struct impl *this) { if (this->callbacks.have_output) this->callbacks.have_output (&this->node, this->user_data); @@ -249,7 +249,7 @@ send_have_output (SpaAudioTestSrc *this) #include "render.c" static void -set_timer (SpaAudioTestSrc *this, bool enabled) +set_timer (struct impl *this, bool enabled) { if (this->callbacks.have_output || this->props.live) { if (enabled) { @@ -270,7 +270,7 @@ set_timer (SpaAudioTestSrc *this, bool enabled) } static void -read_timer (SpaAudioTestSrc *this) +read_timer (struct impl *this) { uint64_t expirations; @@ -280,11 +280,11 @@ read_timer (SpaAudioTestSrc *this) } } -static SpaResult -audiotestsrc_make_buffer (SpaAudioTestSrc *this) +static int +make_buffer (struct impl *this) { - ATSBuffer *b; - SpaPortIO *io = this->io; + struct buffer *b; + struct spa_port_io *io = this->io; int n_bytes, n_samples; read_timer (this); @@ -293,7 +293,7 @@ audiotestsrc_make_buffer (SpaAudioTestSrc *this) set_timer (this, false); return SPA_RESULT_OUT_OF_BUFFERS; } - b = spa_list_first (&this->empty, ATSBuffer, link); + b = spa_list_first (&this->empty, struct buffer, link); spa_list_remove (&b->link); b->outstanding = true; @@ -304,7 +304,7 @@ audiotestsrc_make_buffer (SpaAudioTestSrc *this) n_bytes = io->range.max_size; } - spa_log_trace (this->log, "audiotestsrc %p: dequeue buffer %d %d %d", this, b->outbuf->id, + spa_log_trace (this->log, IMPL_NAME " %p: dequeue buffer %d %d %d", this, b->outbuf->id, b->outbuf->datas[0].maxsize, n_bytes); if (b->rb) { @@ -348,31 +348,31 @@ audiotestsrc_make_buffer (SpaAudioTestSrc *this) io->buffer_id = b->outbuf->id; io->status = SPA_RESULT_HAVE_BUFFER; - return SPA_RESULT_HAVE_BUFFER; + return io->status; } static void -audiotestsrc_on_output (SpaSource *source) +on_output (struct spa_source *source) { - SpaAudioTestSrc *this = source->data; - SpaResult res; + struct impl *this = source->data; + int res; - res = audiotestsrc_make_buffer (this); + res = make_buffer (this); if (res == SPA_RESULT_HAVE_BUFFER) send_have_output (this); } -static SpaResult -spa_audiotestsrc_node_send_command (SpaNode *node, - SpaCommand *command) +static int +impl_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaAudioTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { struct timespec now; @@ -416,17 +416,17 @@ spa_audiotestsrc_node_send_command (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +impl_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaAudioTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (this->data_loop == NULL && callbacks->have_output) { spa_log_error (this->log, "a data_loop is needed for async operation"); @@ -439,8 +439,8 @@ spa_audiotestsrc_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_get_n_ports (SpaNode *node, +static int +impl_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -460,8 +460,8 @@ spa_audiotestsrc_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_get_port_ids (SpaNode *node, +static int +impl_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -475,42 +475,42 @@ spa_audiotestsrc_node_get_port_ids (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_add_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiotestsrc_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiotestsrc_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - SpaAudioTestSrc *this; - SpaResult res; - SpaFormat *fmt; + struct impl *this; + int res; + struct spa_format *fmt; uint8_t buffer[256]; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; uint32_t count, match; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -534,23 +534,23 @@ next: default: return SPA_RESULT_ENUM_END; } - fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer)); if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK || match++ != index) goto next; - *format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, 0, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -clear_buffers (SpaAudioTestSrc *this) +static int +clear_buffers (struct impl *this) { if (this->n_buffers > 0) { - spa_log_info (this->log, "audiotestsrc %p: clear buffers", this); + spa_log_info (this->log, IMPL_NAME " %p: clear buffers", this); this->n_buffers = 0; spa_list_init (&this->empty); this->started = false; @@ -559,18 +559,18 @@ clear_buffers (SpaAudioTestSrc *this) return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_port_set_format (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - uint32_t flags, - const SpaFormat *format) +static int +impl_node_port_set_format (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + uint32_t flags, + const struct spa_format *format) { - SpaAudioTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -578,8 +578,8 @@ spa_audiotestsrc_node_port_set_format (SpaNode *node, this->have_format = false; clear_buffers (this); } else { - SpaAudioInfo info = { SPA_FORMAT_MEDIA_TYPE (format), - SPA_FORMAT_MEDIA_SUBTYPE (format), }; + struct spa_audio_info info = { SPA_FORMAT_MEDIA_TYPE (format), + SPA_FORMAT_MEDIA_SUBTYPE (format), }; int idx; int sizes[4] = { 2, 4, 4, 8 }; @@ -614,20 +614,20 @@ spa_audiotestsrc_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaAudioTestSrc *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -641,23 +641,23 @@ spa_audiotestsrc_node_port_get_format (SpaNode *node, PROP (&f[1], this->type.format_audio.rate, SPA_POD_TYPE_INT, this->current_format.info.raw.rate), PROP (&f[1], this->type.format_audio.channels, SPA_POD_TYPE_INT, this->current_format.info.raw.channels)); - *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaAudioTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -666,21 +666,21 @@ spa_audiotestsrc_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { - SpaAudioTestSrc *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (param != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -698,40 +698,40 @@ spa_audiotestsrc_node_port_enum_params (SpaNode *node, case 1: spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header), - PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); + PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); break; default: return SPA_RESULT_NOT_IMPLEMENTED; } - *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiotestsrc_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +impl_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { - SpaAudioTestSrc *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -741,8 +741,8 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node, clear_buffers (this); for (i = 0; i < n_buffers; i++) { - ATSBuffer *b; - SpaData *d = buffers[i]->datas; + struct buffer *b; + struct spa_data *d = buffers[i]->datas; b = &this->buffers[i]; b->outbuf = buffers[i]; @@ -754,7 +754,7 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node, d[0].type == this->type.data.MemFd || d[0].type == this->type.data.DmaBuf) && d[0].data == NULL) { - spa_log_error (this->log, "audiotestsrc %p: invalid memory on buffer %p", this, buffers[i]); + spa_log_error (this->log, IMPL_NAME " %p: invalid memory on buffer %p", this, buffers[i]); } spa_list_insert (this->empty.prev, &b->link); } @@ -763,20 +763,20 @@ spa_audiotestsrc_node_port_use_buffers (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +impl_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { - SpaAudioTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -786,17 +786,17 @@ spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiotestsrc_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaAudioTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -806,12 +806,12 @@ spa_audiotestsrc_node_port_set_io (SpaNode *node, } static inline void -reuse_buffer (SpaAudioTestSrc *this, uint32_t id) +reuse_buffer (struct impl *this, uint32_t id) { - ATSBuffer *b = &this->buffers[id]; + struct buffer *b = &this->buffers[id]; spa_return_if_fail (b->outstanding); - spa_log_trace (this->log, "audiotestsrc %p: reuse buffer %d", this, id); + spa_log_trace (this->log, IMPL_NAME " %p: reuse buffer %d", this, id); b->outstanding = false; spa_list_insert (this->empty.prev, &b->link); @@ -820,16 +820,16 @@ reuse_buffer (SpaAudioTestSrc *this, uint32_t id) set_timer (this, true); } -static SpaResult -spa_audiotestsrc_node_port_reuse_buffer (SpaNode *node, +static int +impl_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { - SpaAudioTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (port_id == 0, SPA_RESULT_INVALID_PORT); spa_return_val_if_fail (this->n_buffers > 0, SPA_RESULT_NO_BUFFERS); @@ -840,30 +840,30 @@ spa_audiotestsrc_node_port_reuse_buffer (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_audiotestsrc_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +impl_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiotestsrc_node_process_input (SpaNode *node) +static int +impl_node_process_input (struct spa_node *node) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiotestsrc_node_process_output (SpaNode *node) +static int +impl_node_process_output (struct spa_node *node) { - SpaAudioTestSrc *this; - SpaPortIO *io; + struct impl *this; + struct spa_port_io *io; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); io = this->io; spa_return_val_if_fail (io != NULL, SPA_RESULT_WRONG_STATE); @@ -876,53 +876,53 @@ spa_audiotestsrc_node_process_output (SpaNode *node) } if (!this->callbacks.have_output && (io->status == SPA_RESULT_NEED_BUFFER)) - return audiotestsrc_make_buffer (this); + return make_buffer (this); else return SPA_RESULT_OK; } -static const SpaNode audiotestsrc_node = { - sizeof (SpaNode), +static const struct spa_node impl_node = { + sizeof (struct spa_node), NULL, - spa_audiotestsrc_node_get_props, - spa_audiotestsrc_node_set_props, - spa_audiotestsrc_node_send_command, - spa_audiotestsrc_node_set_callbacks, - spa_audiotestsrc_node_get_n_ports, - spa_audiotestsrc_node_get_port_ids, - spa_audiotestsrc_node_add_port, - spa_audiotestsrc_node_remove_port, - spa_audiotestsrc_node_port_enum_formats, - spa_audiotestsrc_node_port_set_format, - spa_audiotestsrc_node_port_get_format, - spa_audiotestsrc_node_port_get_info, - spa_audiotestsrc_node_port_enum_params, - spa_audiotestsrc_node_port_set_param, - spa_audiotestsrc_node_port_use_buffers, - spa_audiotestsrc_node_port_alloc_buffers, - spa_audiotestsrc_node_port_set_io, - spa_audiotestsrc_node_port_reuse_buffer, - spa_audiotestsrc_node_port_send_command, - spa_audiotestsrc_node_process_input, - spa_audiotestsrc_node_process_output, + impl_node_get_props, + impl_node_set_props, + impl_node_send_command, + impl_node_set_callbacks, + impl_node_get_n_ports, + impl_node_get_port_ids, + impl_node_add_port, + impl_node_remove_port, + impl_node_port_enum_formats, + impl_node_port_set_format, + impl_node_port_get_format, + impl_node_port_get_info, + impl_node_port_enum_params, + impl_node_port_set_param, + impl_node_port_use_buffers, + impl_node_port_alloc_buffers, + impl_node_port_set_io, + impl_node_port_reuse_buffer, + impl_node_port_send_command, + impl_node_process_input, + impl_node_process_output, }; -static SpaResult -spa_audiotestsrc_clock_get_props (SpaClock *clock, - SpaProps **props) +static int +impl_clock_get_props (struct spa_clock *clock, + struct spa_props **props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiotestsrc_clock_set_props (SpaClock *clock, - const SpaProps *props) +static int +impl_clock_set_props (struct spa_clock *clock, + const struct spa_props *props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_audiotestsrc_clock_get_time (SpaClock *clock, +static int +impl_clock_get_time (struct spa_clock *clock, int32_t *rate, int64_t *ticks, int64_t *monotonic_time) @@ -946,26 +946,26 @@ spa_audiotestsrc_clock_get_time (SpaClock *clock, return SPA_RESULT_OK; } -static const SpaClock audiotestsrc_clock = { - sizeof (SpaClock), +static const struct spa_clock impl_clock = { + sizeof (struct spa_clock), NULL, SPA_CLOCK_STATE_STOPPED, - spa_audiotestsrc_clock_get_props, - spa_audiotestsrc_clock_set_props, - spa_audiotestsrc_clock_get_time, + impl_clock_get_props, + impl_clock_set_props, + impl_clock_get_time, }; -static SpaResult -spa_audiotestsrc_get_interface (SpaHandle *handle, +static int +impl_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaAudioTestSrc *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaAudioTestSrc *) handle; + this = (struct impl *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -977,14 +977,14 @@ spa_audiotestsrc_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -audiotestsrc_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { - SpaAudioTestSrc *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaAudioTestSrc *) handle; + this = (struct impl *) handle; if (this->data_loop) spa_loop_remove_source (this->data_loop, &this->timer_source); @@ -993,23 +993,23 @@ audiotestsrc_clear (SpaHandle *handle) return SPA_RESULT_OK; } -static SpaResult -audiotestsrc_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, - uint32_t n_support) +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, + uint32_t n_support) { - SpaAudioTestSrc *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_audiotestsrc_get_interface; - handle->clear = audiotestsrc_clear; + handle->get_interface = impl_get_interface; + handle->clear = impl_clear; - this = (SpaAudioTestSrc *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -1025,13 +1025,13 @@ audiotestsrc_init (const SpaHandleFactory *factory, } init_type (&this->type, this->map); - this->node = audiotestsrc_node; - this->clock = audiotestsrc_clock; - reset_audiotestsrc_props (this, &this->props); + this->node = impl_node; + this->clock = impl_clock; + impl_reset_props (this, &this->props); spa_list_init (&this->empty); - this->timer_source.func = audiotestsrc_on_output; + this->timer_source.func = on_output; this->timer_source.data = this; this->timer_source.fd = timerfd_create (CLOCK_MONOTONIC, TFD_CLOEXEC); this->timer_source.mask = SPA_IO_IN; @@ -1049,28 +1049,27 @@ audiotestsrc_init (const SpaHandleFactory *factory, if (this->props.live) this->info.flags |= SPA_PORT_INFO_FLAG_LIVE; - spa_log_info (this->log, "audiotestsrc %p: initialized", this); + spa_log_info (this->log, IMPL_NAME " %p: initialized", this); return SPA_RESULT_OK; } -static const SpaInterfaceInfo audiotestsrc_interfaces[] = -{ +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Node, }, { SPA_TYPE__Clock, }, }; -static SpaResult -audiotestsrc_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, - uint32_t index) +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, + uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); switch (index) { case 0: - *info = &audiotestsrc_interfaces[index]; + *info = &impl_interfaces[index]; break; default: return SPA_RESULT_ENUM_END; @@ -1078,10 +1077,10 @@ audiotestsrc_enum_interface_info (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -const SpaHandleFactory spa_audiotestsrc_factory = -{ "audiotestsrc", +const struct spa_handle_factory spa_audiotestsrc_factory = { + IMPL_NAME, NULL, - sizeof (SpaAudioTestSrc), - audiotestsrc_init, - audiotestsrc_enum_interface_info, + sizeof (struct impl), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/audiotestsrc/plugin.c b/spa/plugins/audiotestsrc/plugin.c index 77014c04a..751cc10f1 100644 --- a/spa/plugins/audiotestsrc/plugin.c +++ b/spa/plugins/audiotestsrc/plugin.c @@ -20,20 +20,21 @@ #include #include -extern const SpaHandleFactory spa_audiotestsrc_factory; +extern const struct spa_handle_factory spa_audiotestsrc_factory; -SpaResult -spa_enum_handle_factory (const SpaHandleFactory **factory, - uint32_t index) +int +spa_handle_factory_enum(const struct spa_handle_factory **factory, + uint32_t index) { - spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); + spa_return_val_if_fail(factory != NULL, + SPA_RESULT_INVALID_ARGUMENTS); - switch (index) { - case 0: - *factory = &spa_audiotestsrc_factory; - break; - default: - return SPA_RESULT_ENUM_END; - } - return SPA_RESULT_OK; + switch (index) { + case 0: + *factory = &spa_audiotestsrc_factory; + break; + default: + return SPA_RESULT_ENUM_END; + } + return SPA_RESULT_OK; } diff --git a/spa/plugins/audiotestsrc/render.c b/spa/plugins/audiotestsrc/render.c index 3cd21ae33..1dcac62f2 100644 --- a/spa/plugins/audiotestsrc/render.c +++ b/spa/plugins/audiotestsrc/render.c @@ -21,11 +21,9 @@ #define M_PI_M2 ( M_PI + M_PI ) -typedef SpaResult (*RenderFunc) (SpaAudioTestSrc *this, void *samples, size_t n_samples); - #define DEFINE_SINE(type,scale) \ static void \ -audio_test_src_create_sine_##type (SpaAudioTestSrc *this, type * samples, size_t n_samples) \ +audio_test_src_create_sine_##type (struct impl *this, type * samples, size_t n_samples) \ { \ int i, c, channels; \ double step, amp; \ @@ -48,9 +46,9 @@ DEFINE_SINE (int32_t, 2147483647.0); DEFINE_SINE (float, 1.0); DEFINE_SINE (double, 1.0); -static const RenderFunc sine_funcs[] = { - (RenderFunc) audio_test_src_create_sine_int16_t, - (RenderFunc) audio_test_src_create_sine_int32_t, - (RenderFunc) audio_test_src_create_sine_float, - (RenderFunc) audio_test_src_create_sine_double +static const render_func_t sine_funcs[] = { + (render_func_t) audio_test_src_create_sine_int16_t, + (render_func_t) audio_test_src_create_sine_int32_t, + (render_func_t) audio_test_src_create_sine_float, + (render_func_t) audio_test_src_create_sine_double }; diff --git a/spa/plugins/ffmpeg/ffmpeg-dec.c b/spa/plugins/ffmpeg/ffmpeg-dec.c index 2e9f3b691..aabb76cf9 100644 --- a/spa/plugins/ffmpeg/ffmpeg-dec.c +++ b/spa/plugins/ffmpeg/ffmpeg-dec.c @@ -28,38 +28,34 @@ #include #include -typedef struct _SpaFFMpegDec SpaFFMpegDec; - #define IS_VALID_PORT(this,d,id) ((id) == 0) #define MAX_BUFFERS 32 -typedef struct _FFMpegBuffer FFMpegBuffer; - -struct _FFMpegBuffer { - SpaBuffer *outbuf; +struct buffer { + struct spa_buffer *outbuf; bool outstanding; - FFMpegBuffer *next; + struct buffer *next; }; -typedef struct { +struct port { bool have_format; - SpaVideoInfo current_format; + struct spa_video_info current_format; bool have_buffers; - FFMpegBuffer buffers[MAX_BUFFERS]; - SpaPortInfo info; - SpaPortIO *io; -} SpaFFMpegPort; + struct buffer buffers[MAX_BUFFERS]; + struct spa_port_info info; + struct spa_port_io *io; +}; -typedef struct { +struct type { uint32_t node; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatVideo format_video; - SpaTypeCommandNode command_node; -} Type; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_video format_video; + struct spa_type_command_node command_node; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); spa_type_media_type_map (map, &type->media_type); @@ -68,51 +64,47 @@ init_type (Type *type, SpaTypeMap *map) spa_type_command_node_map (map, &type->command_node); } -struct _SpaFFMpegDec { - SpaHandle handle; - SpaNode node; +struct impl { + struct spa_handle handle; + struct spa_node node; - Type type; - SpaTypeMap *map; - SpaLog *log; + struct type type; + struct spa_type_map *map; + struct spa_log *log; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; - SpaFFMpegPort in_ports[1]; - SpaFFMpegPort out_ports[1]; + struct port in_ports[1]; + struct port out_ports[1]; bool started; }; -enum { - PROP_ID_LAST, -}; - -static SpaResult -spa_ffmpeg_dec_node_get_props (SpaNode *node, - SpaProps **props) +static int +spa_ffmpeg_dec_node_get_props (struct spa_node *node, + struct spa_props **props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_dec_node_set_props (SpaNode *node, - const SpaProps *props) +static int +spa_ffmpeg_dec_node_set_props (struct spa_node *node, + const struct spa_props *props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_dec_node_send_command (SpaNode *node, - SpaCommand *command) +static int +spa_ffmpeg_dec_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaFFMpegDec *this; + struct impl *this; if (node == NULL || command == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { this->started = true; @@ -126,18 +118,18 @@ spa_ffmpeg_dec_node_send_command (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_dec_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +spa_ffmpeg_dec_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaFFMpegDec *this; + struct impl *this; if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node); + this = SPA_CONTAINER_OF (node, struct impl, node); this->callbacks = *callbacks; this->user_data = user_data; @@ -145,8 +137,8 @@ spa_ffmpeg_dec_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_dec_node_get_n_ports (SpaNode *node, +static int +spa_ffmpeg_dec_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -167,8 +159,8 @@ spa_ffmpeg_dec_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_dec_node_get_port_ids (SpaNode *node, +static int +spa_ffmpeg_dec_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -186,36 +178,36 @@ spa_ffmpeg_dec_node_get_port_ids (SpaNode *node, } -static SpaResult -spa_ffmpeg_dec_node_add_port (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_dec_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_dec_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_dec_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_dec_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_dec_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - //SpaFFMpegDec *this; + //struct impl *this; if (node == NULL || format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - //this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node); + //this = SPA_CONTAINER_OF (node, struct impl, node); if (!IS_VALID_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -231,20 +223,20 @@ spa_ffmpeg_dec_node_port_enum_formats (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_dec_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_dec_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaFFMpegDec *this; - SpaFFMpegPort *port; + struct impl *this; + struct port *port; if (node == NULL || format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!IS_VALID_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -255,8 +247,8 @@ spa_ffmpeg_dec_node_port_set_format (SpaNode *node, port->have_format = false; return SPA_RESULT_OK; } else { - SpaVideoInfo info = { SPA_FORMAT_MEDIA_TYPE (format), - SPA_FORMAT_MEDIA_SUBTYPE (format), }; + struct spa_video_info info = { SPA_FORMAT_MEDIA_TYPE (format), + SPA_FORMAT_MEDIA_SUBTYPE (format), }; if (info.media_type != this->type.media_type.video && info.media_subtype != this->type.media_subtype.raw) @@ -273,19 +265,19 @@ spa_ffmpeg_dec_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_dec_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_dec_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaFFMpegDec *this; - SpaFFMpegPort *port; + struct impl *this; + struct port *port; if (node == NULL || format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!IS_VALID_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -300,19 +292,19 @@ spa_ffmpeg_dec_node_port_get_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_dec_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_dec_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaFFMpegDec *this; - SpaFFMpegPort *port; + struct impl *this; + struct port *port; if (node == NULL || info == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!IS_VALID_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -323,31 +315,31 @@ spa_ffmpeg_dec_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_dec_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_dec_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_dec_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_dec_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_dec_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +spa_ffmpeg_dec_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; @@ -358,31 +350,31 @@ spa_ffmpeg_dec_node_port_use_buffers (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_dec_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +spa_ffmpeg_dec_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_dec_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_dec_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaFFMpegDec *this; - SpaFFMpegPort *port; + struct impl *this; + struct port *port; if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!IS_VALID_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -393,23 +385,23 @@ spa_ffmpeg_dec_node_port_set_io (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_dec_node_process_input (SpaNode *node) +static int +spa_ffmpeg_dec_node_process_input (struct spa_node *node) { return SPA_RESULT_INVALID_PORT; } -static SpaResult -spa_ffmpeg_dec_node_process_output (SpaNode *node) +static int +spa_ffmpeg_dec_node_process_output (struct spa_node *node) { - SpaFFMpegDec *this; - SpaFFMpegPort *port; - SpaPortIO *output; + struct impl *this; + struct port *port; + struct spa_port_io *output; if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegDec, node); + this = SPA_CONTAINER_OF (node, struct impl, node); port = &this->out_ports[0]; @@ -425,8 +417,8 @@ spa_ffmpeg_dec_node_process_output (SpaNode *node) return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_dec_node_port_reuse_buffer (SpaNode *node, +static int +spa_ffmpeg_dec_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { @@ -439,18 +431,18 @@ spa_ffmpeg_dec_node_port_reuse_buffer (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_dec_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +spa_ffmpeg_dec_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { return SPA_RESULT_NOT_IMPLEMENTED; } -static const SpaNode ffmpeg_dec_node = { - sizeof (SpaNode), +static const struct spa_node ffmpeg_dec_node = { + sizeof (struct spa_node), NULL, spa_ffmpeg_dec_node_get_props, spa_ffmpeg_dec_node_set_props, @@ -475,17 +467,17 @@ static const SpaNode ffmpeg_dec_node = { spa_ffmpeg_dec_node_process_output, }; -static SpaResult -spa_ffmpeg_dec_get_interface (SpaHandle *handle, +static int +spa_ffmpeg_dec_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaFFMpegDec *this; + struct impl *this; if (handle == NULL || interface == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = (SpaFFMpegDec *) handle; + this = (struct impl *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -495,18 +487,18 @@ spa_ffmpeg_dec_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -SpaResult -spa_ffmpeg_dec_init (SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, - uint32_t n_support) +int +spa_ffmpeg_dec_init (struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, + uint32_t n_support) { - SpaFFMpegDec *this; + struct impl *this; uint32_t i; handle->get_interface = spa_ffmpeg_dec_get_interface; - this = (SpaFFMpegDec *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) diff --git a/spa/plugins/ffmpeg/ffmpeg-enc.c b/spa/plugins/ffmpeg/ffmpeg-enc.c index 2919d5e98..25fd804e8 100644 --- a/spa/plugins/ffmpeg/ffmpeg-enc.c +++ b/spa/plugins/ffmpeg/ffmpeg-enc.c @@ -28,43 +28,38 @@ #include #include -typedef struct _SpaFFMpegEnc SpaFFMpegEnc; - #define IS_VALID_PORT(this,d,id) ((id) == 0) #define MAX_BUFFERS 32 -typedef struct _FFMpegBuffer FFMpegBuffer; - -struct _FFMpegBuffer { - SpaBuffer buffer; - SpaMeta metas[1]; - SpaMetaHeader header; - SpaData datas[1]; - SpaFFMpegEnc *enc; - SpaBuffer *imported; +struct buffer { + struct spa_buffer buffer; + struct spa_meta metas[1]; + struct spa_meta_header header; + struct spa_data datas[1]; + struct spa_buffer *imported; bool outstanding; - FFMpegBuffer *next; + struct buffer *next; }; -typedef struct { +struct port { bool have_format; - SpaVideoInfo current_format; + struct spa_video_info current_format; bool have_buffers; - FFMpegBuffer buffers[MAX_BUFFERS]; - SpaPortInfo info; - SpaPortIO *io; -} SpaFFMpegPort; + struct buffer buffers[MAX_BUFFERS]; + struct spa_port_info info; + struct spa_port_io *io; +}; -typedef struct { +struct type { uint32_t node; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatVideo format_video; - SpaTypeCommandNode command_node; -} Type; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_video format_video; + struct spa_type_command_node command_node; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); spa_type_media_type_map (map, &type->media_type); @@ -73,47 +68,47 @@ init_type (Type *type, SpaTypeMap *map) spa_type_command_node_map (map, &type->command_node); } -struct _SpaFFMpegEnc { - SpaHandle handle; - SpaNode node; +struct impl { + struct spa_handle handle; + struct spa_node node; - Type type; - SpaTypeMap *map; - SpaLog *log; + struct type type; + struct spa_type_map *map; + struct spa_log *log; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; - SpaFFMpegPort in_ports[1]; - SpaFFMpegPort out_ports[1]; + struct port in_ports[1]; + struct port out_ports[1]; bool started; }; -static SpaResult -spa_ffmpeg_enc_node_get_props (SpaNode *node, - SpaProps **props) +static int +spa_ffmpeg_enc_node_get_props (struct spa_node *node, + struct spa_props **props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_enc_node_set_props (SpaNode *node, - const SpaProps *props) +static int +spa_ffmpeg_enc_node_set_props (struct spa_node *node, + const struct spa_props *props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_enc_node_send_command (SpaNode *node, - SpaCommand *command) +static int +spa_ffmpeg_enc_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaFFMpegEnc *this; + struct impl *this; if (node == NULL || command == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { this->started = true; @@ -127,18 +122,18 @@ spa_ffmpeg_enc_node_send_command (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_enc_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +spa_ffmpeg_enc_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaFFMpegEnc *this; + struct impl *this; if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); this->callbacks = *callbacks; this->user_data = user_data; @@ -146,8 +141,8 @@ spa_ffmpeg_enc_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_enc_node_get_n_ports (SpaNode *node, +static int +spa_ffmpeg_enc_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -168,8 +163,8 @@ spa_ffmpeg_enc_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_enc_node_get_port_ids (SpaNode *node, +static int +spa_ffmpeg_enc_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -187,37 +182,37 @@ spa_ffmpeg_enc_node_get_port_ids (SpaNode *node, } -static SpaResult -spa_ffmpeg_enc_node_add_port (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_enc_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_enc_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_enc_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_enc_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_enc_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - //SpaFFMpegEnc *this; - //SpaFFMpegPort *port; + //struct impl *this; + //struct port *port; if (node == NULL || format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - //this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node); + //this = SPA_CONTAINER_OF (node, struct impl, node); if (!IS_VALID_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -235,20 +230,20 @@ spa_ffmpeg_enc_node_port_enum_formats (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_enc_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_enc_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaFFMpegEnc *this; - SpaFFMpegPort *port; + struct impl *this; + struct port *port; if (node == NULL || format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!IS_VALID_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -259,8 +254,8 @@ spa_ffmpeg_enc_node_port_set_format (SpaNode *node, port->have_format = false; return SPA_RESULT_OK; } else { - SpaVideoInfo info = { SPA_FORMAT_MEDIA_TYPE (format), - SPA_FORMAT_MEDIA_SUBTYPE (format), }; + struct spa_video_info info = { SPA_FORMAT_MEDIA_TYPE (format), + SPA_FORMAT_MEDIA_SUBTYPE (format), }; if (info.media_type != this->type.media_type.video && info.media_subtype != this->type.media_subtype.raw) @@ -277,19 +272,19 @@ spa_ffmpeg_enc_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_enc_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_enc_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaFFMpegEnc *this; - SpaFFMpegPort *port; + struct impl *this; + struct port *port; if (node == NULL || format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!IS_VALID_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -304,19 +299,19 @@ spa_ffmpeg_enc_node_port_get_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_enc_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_enc_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaFFMpegEnc *this; - SpaFFMpegPort *port; + struct impl *this; + struct port *port; if (node == NULL || info == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!IS_VALID_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -327,31 +322,31 @@ spa_ffmpeg_enc_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_enc_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_enc_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_enc_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_enc_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_enc_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +spa_ffmpeg_enc_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; @@ -362,31 +357,31 @@ spa_ffmpeg_enc_node_port_use_buffers (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_enc_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +spa_ffmpeg_enc_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_enc_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +spa_ffmpeg_enc_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaFFMpegEnc *this; - SpaFFMpegPort *port; + struct impl *this; + struct port *port; if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!IS_VALID_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -397,8 +392,8 @@ spa_ffmpeg_enc_node_port_set_io (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_ffmpeg_enc_node_port_reuse_buffer (SpaNode *node, +static int +spa_ffmpeg_enc_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { @@ -411,32 +406,32 @@ spa_ffmpeg_enc_node_port_reuse_buffer (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_enc_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +spa_ffmpeg_enc_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_ffmpeg_enc_node_process_input (SpaNode *node) +static int +spa_ffmpeg_enc_node_process_input (struct spa_node *node) { return SPA_RESULT_INVALID_PORT; } -static SpaResult -spa_ffmpeg_enc_node_process_output (SpaNode *node) +static int +spa_ffmpeg_enc_node_process_output (struct spa_node *node) { - SpaFFMpegEnc *this; - SpaFFMpegPort *port; - SpaPortIO *output; + struct impl *this; + struct port *port; + struct spa_port_io *output; if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaFFMpegEnc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if ((output = this->out_ports[0].io) == NULL) return SPA_RESULT_OK; @@ -452,8 +447,8 @@ spa_ffmpeg_enc_node_process_output (SpaNode *node) return SPA_RESULT_OK; } -static const SpaNode ffmpeg_enc_node = { - sizeof (SpaNode), +static const struct spa_node ffmpeg_enc_node = { + sizeof (struct spa_node), NULL, spa_ffmpeg_enc_node_get_props, spa_ffmpeg_enc_node_set_props, @@ -478,17 +473,17 @@ static const SpaNode ffmpeg_enc_node = { spa_ffmpeg_enc_node_process_output, }; -static SpaResult -spa_ffmpeg_enc_get_interface (SpaHandle *handle, +static int +spa_ffmpeg_enc_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaFFMpegEnc *this; + struct impl *this; if (handle == NULL || interface == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = (SpaFFMpegEnc *) handle; + this = (struct impl *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -498,18 +493,18 @@ spa_ffmpeg_enc_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -SpaResult -spa_ffmpeg_enc_init (SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, - uint32_t n_support) +int +spa_ffmpeg_enc_init (struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, + uint32_t n_support) { - SpaFFMpegEnc *this; + struct impl *this; uint32_t i; handle->get_interface = spa_ffmpeg_enc_get_interface; - this = (SpaFFMpegEnc *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) diff --git a/spa/plugins/ffmpeg/ffmpeg.c b/spa/plugins/ffmpeg/ffmpeg.c index 23a0a387e..67dd30419 100644 --- a/spa/plugins/ffmpeg/ffmpeg.c +++ b/spa/plugins/ffmpeg/ffmpeg.c @@ -25,14 +25,14 @@ #include #include -SpaResult spa_ffmpeg_dec_init (SpaHandle *handle, const SpaDict *info, const SpaSupport *support, uint32_t n_support); -SpaResult spa_ffmpeg_enc_init (SpaHandle *handle, const SpaDict *info, const SpaSupport *support, uint32_t n_support); +int spa_ffmpeg_dec_init (struct spa_handle *handle, const struct spa_dict *info, const struct spa_support *support, uint32_t n_support); +int spa_ffmpeg_enc_init (struct spa_handle *handle, const struct spa_dict *info, const struct spa_support *support, uint32_t n_support); -static SpaResult -ffmpeg_dec_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +ffmpeg_dec_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { if (factory == NULL || handle == NULL) @@ -41,11 +41,11 @@ ffmpeg_dec_init (const SpaHandleFactory *factory, return spa_ffmpeg_dec_init (handle, info, support, n_support); } -static SpaResult -ffmpeg_enc_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +ffmpeg_enc_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { if (factory == NULL || handle == NULL) @@ -54,15 +54,15 @@ ffmpeg_enc_init (const SpaHandleFactory *factory, return spa_ffmpeg_enc_init (handle, info, support, n_support); } -static const SpaInterfaceInfo ffmpeg_interfaces[] = +static const struct spa_interface_info ffmpeg_interfaces[] = { { SPA_TYPE__Node, }, }; -static SpaResult -ffmpeg_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +ffmpeg_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { if (factory == NULL || info == NULL) @@ -76,13 +76,13 @@ ffmpeg_enum_interface_info (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -SpaResult -spa_enum_handle_factory (const SpaHandleFactory **factory, +int +spa_handle_factory_enum (const struct spa_handle_factory **factory, uint32_t index) { static const AVCodec *c = NULL; static int ci = 0; - static SpaHandleFactory f; + static struct spa_handle_factory f; static char name[128]; av_register_all(); diff --git a/spa/plugins/libva/libva-dec.c b/spa/plugins/libva/libva-dec.c index 99a9e669f..b3a9e2266 100644 --- a/spa/plugins/libva/libva-dec.c +++ b/spa/plugins/libva/libva-dec.c @@ -83,7 +83,7 @@ static const SpaPropInfo prop_info[] = { 0, }, }; -static SpaResult +static int spa_libva_dec_node_get_props (SpaHandle *handle, SpaProps **props) { @@ -98,13 +98,13 @@ spa_libva_dec_node_get_props (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_dec_node_set_props (SpaHandle *handle, const SpaProps *props) { SpaLibvaDec *this = (SpaLibvaDec *) handle; SpaLibvaDecProps *p = &this->props[1]; - SpaResult res; + int res; if (handle == NULL) return SPA_RESULT_INVALID_ARGUMENTS; @@ -119,7 +119,7 @@ spa_libva_dec_node_set_props (SpaHandle *handle, return res; } -static SpaResult +static int spa_libva_dec_node_send_command (SpaHandle *handle, SpaCommand *command) { @@ -169,7 +169,7 @@ spa_libva_dec_node_send_command (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_dec_node_set_event_callback (SpaHandle *handle, SpaNodeEventCallback event, void *user_data) @@ -185,7 +185,7 @@ spa_libva_dec_node_set_event_callback (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_dec_node_get_n_ports (SpaHandle *handle, uint32_t *n_input_ports, uint32_t *max_input_ports, @@ -207,7 +207,7 @@ spa_libva_dec_node_get_n_ports (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_dec_node_get_port_ids (SpaHandle *handle, uint32_t n_input_ports, uint32_t *input_ids, @@ -226,7 +226,7 @@ spa_libva_dec_node_get_port_ids (SpaHandle *handle, } -static SpaResult +static int spa_libva_dec_node_add_port (SpaHandle *handle, SpaDirection direction, uint32_t *port_id) @@ -234,14 +234,14 @@ spa_libva_dec_node_add_port (SpaHandle *handle, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult +static int spa_libva_dec_node_remove_port (SpaHandle *handle, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult +static int spa_libva_dec_node_port_enum_formats (SpaHandle *handle, uint32_t port_id, uint32_t index, @@ -270,7 +270,7 @@ spa_libva_dec_node_port_enum_formats (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_dec_node_port_set_format (SpaHandle *handle, uint32_t port_id, bool test_only, @@ -278,7 +278,7 @@ spa_libva_dec_node_port_set_format (SpaHandle *handle, { SpaLibvaDec *this = (SpaLibvaDec *) handle; SpaLibvaState *state; - SpaResult res; + int res; SpaFormat *f, *tf; size_t fs; @@ -316,7 +316,7 @@ spa_libva_dec_node_port_set_format (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_dec_node_port_get_format (SpaHandle *handle, uint32_t port_id, const SpaFormat **format) @@ -340,7 +340,7 @@ spa_libva_dec_node_port_get_format (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_dec_node_port_get_info (SpaHandle *handle, uint32_t port_id, const SpaPortInfo **info) @@ -358,7 +358,7 @@ spa_libva_dec_node_port_get_info (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_dec_node_port_get_props (SpaHandle *handle, uint32_t port_id, SpaProps **props) @@ -366,7 +366,7 @@ spa_libva_dec_node_port_get_props (SpaHandle *handle, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult +static int spa_libva_dec_node_port_set_props (SpaHandle *handle, uint32_t port_id, const SpaProps *props) @@ -374,7 +374,7 @@ spa_libva_dec_node_port_set_props (SpaHandle *handle, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult +static int spa_libva_dec_node_port_get_status (SpaHandle *handle, uint32_t port_id, const SpaPortStatus **status) @@ -392,7 +392,7 @@ spa_libva_dec_node_port_get_status (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_dec_node_port_use_buffers (SpaHandle *handle, uint32_t port_id, SpaBuffer **buffers, @@ -407,7 +407,7 @@ spa_libva_dec_node_port_use_buffers (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_dec_node_port_alloc_buffers (SpaHandle *handle, uint32_t port_id, SpaParam **params, @@ -419,7 +419,7 @@ spa_libva_dec_node_port_alloc_buffers (SpaHandle *handle, } -static SpaResult +static int spa_libva_dec_node_port_push_input (SpaHandle *handle, uint32_t n_info, SpaInputInfo *info) @@ -427,7 +427,7 @@ spa_libva_dec_node_port_push_input (SpaHandle *handle, return SPA_RESULT_INVALID_PORT; } -static SpaResult +static int spa_libva_dec_node_port_pull_output (SpaHandle *handle, uint32_t n_info, SpaOutputInfo *info) @@ -485,7 +485,7 @@ static const SpaNode libva_dec_node = { spa_libva_dec_node_port_pull_output, }; -static SpaResult +static int spa_libva_dec_get_interface (SpaHandle *handle, uint32_t interface_id, const void **interface) diff --git a/spa/plugins/libva/libva-enc.c b/spa/plugins/libva/libva-enc.c index 4e5171061..3fba31ff7 100644 --- a/spa/plugins/libva/libva-enc.c +++ b/spa/plugins/libva/libva-enc.c @@ -85,7 +85,7 @@ static const SpaPropInfo prop_info[] = { 0, }, }; -static SpaResult +static int spa_libva_enc_node_get_props (SpaHandle *handle, SpaProps **props) { @@ -100,13 +100,13 @@ spa_libva_enc_node_get_props (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_enc_node_set_props (SpaHandle *handle, const SpaProps *props) { SpaLibvaEnc *this = (SpaLibvaEnc *) handle; SpaLibvaEncProps *p = &this->props[1]; - SpaResult res; + int res; if (handle == NULL) return SPA_RESULT_INVALID_ARGUMENTS; @@ -121,7 +121,7 @@ spa_libva_enc_node_set_props (SpaHandle *handle, return res; } -static SpaResult +static int spa_libva_enc_node_send_command (SpaHandle *handle, SpaCommand *command) { @@ -171,7 +171,7 @@ spa_libva_enc_node_send_command (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_enc_node_set_event_callback (SpaHandle *handle, SpaEventCallback event, void *user_data) @@ -187,7 +187,7 @@ spa_libva_enc_node_set_event_callback (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_enc_node_get_n_ports (SpaHandle *handle, uint32_t *n_input_ports, uint32_t *max_input_ports, @@ -209,7 +209,7 @@ spa_libva_enc_node_get_n_ports (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_enc_node_get_port_ids (SpaHandle *handle, uint32_t n_input_ports, uint32_t *input_ids, @@ -228,7 +228,7 @@ spa_libva_enc_node_get_port_ids (SpaHandle *handle, } -static SpaResult +static int spa_libva_enc_node_add_port (SpaHandle *handle, SpaDirection direction, uint32_t *port_id) @@ -236,14 +236,14 @@ spa_libva_enc_node_add_port (SpaHandle *handle, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult +static int spa_libva_enc_node_remove_port (SpaHandle *handle, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult +static int spa_libva_enc_node_port_enum_formats (SpaHandle *handle, uint32_t port_id, uint32_t index, @@ -272,7 +272,7 @@ spa_libva_enc_node_port_enum_formats (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_enc_node_port_set_format (SpaHandle *handle, uint32_t port_id, bool test_only, @@ -280,7 +280,7 @@ spa_libva_enc_node_port_set_format (SpaHandle *handle, { SpaLibvaEnc *this = (SpaLibvaEnc *) handle; SpaLibvaState *state; - SpaResult res; + int res; SpaFormat *f, *tf; size_t fs; @@ -318,7 +318,7 @@ spa_libva_enc_node_port_set_format (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_enc_node_port_get_format (SpaHandle *handle, uint32_t port_id, const SpaFormat **format) @@ -342,7 +342,7 @@ spa_libva_enc_node_port_get_format (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_enc_node_port_get_info (SpaHandle *handle, uint32_t port_id, const SpaPortInfo **info) @@ -360,7 +360,7 @@ spa_libva_enc_node_port_get_info (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_enc_node_port_get_props (SpaHandle *handle, uint32_t port_id, SpaProps **props) @@ -368,7 +368,7 @@ spa_libva_enc_node_port_get_props (SpaHandle *handle, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult +static int spa_libva_enc_node_port_set_props (SpaHandle *handle, uint32_t port_id, const SpaProps *props) @@ -376,7 +376,7 @@ spa_libva_enc_node_port_set_props (SpaHandle *handle, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult +static int spa_libva_enc_node_port_get_status (SpaHandle *handle, uint32_t port_id, const SpaPortStatus **status) @@ -394,7 +394,7 @@ spa_libva_enc_node_port_get_status (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_enc_node_port_use_buffers (SpaHandle *handle, uint32_t port_id, SpaBuffer **buffers, @@ -409,7 +409,7 @@ spa_libva_enc_node_port_use_buffers (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult +static int spa_libva_enc_node_port_alloc_buffers (SpaHandle *handle, uint32_t port_id, SpaAllocParam **params, @@ -421,7 +421,7 @@ spa_libva_enc_node_port_alloc_buffers (SpaHandle *handle, } -static SpaResult +static int spa_libva_enc_node_port_push_input (SpaHandle *handle, uint32_t n_info, SpaInputInfo *info) @@ -429,7 +429,7 @@ spa_libva_enc_node_port_push_input (SpaHandle *handle, return SPA_RESULT_INVALID_PORT; } -static SpaResult +static int spa_libva_enc_node_port_pull_output (SpaHandle *handle, uint32_t n_info, SpaOutputInfo *info) @@ -487,7 +487,7 @@ static const SpaNode libva_enc_node = { spa_libva_enc_node_port_pull_output, }; -static SpaResult +static int spa_libva_enc_get_interface (SpaHandle *handle, uint32_t interface_id, const void **interface) diff --git a/spa/plugins/libva/libva.c b/spa/plugins/libva/libva.c index fca53f6c0..87c78c3eb 100644 --- a/spa/plugins/libva/libva.c +++ b/spa/plugins/libva/libva.c @@ -23,8 +23,8 @@ SpaHandle * spa_libva_dec_new (void); SpaHandle * spa_libva_enc_new (void); -static SpaResult -libva_dec_instantiate (const SpaHandleFactory *factory, +static int +libva_dec_instantiate (const struct spa_handle_factory *factory, SpaHandle **handle) { if (factory == NULL || handle == NULL) @@ -35,8 +35,8 @@ libva_dec_instantiate (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -static SpaResult -libva_enc_instantiate (const SpaHandleFactory *factory, +static int +libva_enc_instantiate (const struct spa_handle_factory *factory, SpaHandle **handle) { if (factory == NULL || handle == NULL) @@ -48,7 +48,7 @@ libva_enc_instantiate (const SpaHandleFactory *factory, } -static const SpaInterfaceInfo libva_interfaces[] = +static const struct spa_interface_info libva_interfaces[] = { { SPA_INTERFACE_ID_NODE, SPA_INTERFACE_ID_NODE_NAME, @@ -56,10 +56,10 @@ static const SpaInterfaceInfo libva_interfaces[] = }, }; -static SpaResult -libva_enum_interface_info (const SpaHandleFactory *factory, +static int +libva_enum_interface_info (const struct spa_handle_factory *factory, uint32_t index, - const SpaInterfaceInfo **info) + const struct spa_interface_info **info) { if (index >= 1) return SPA_RESULT_ENUM_END; @@ -69,7 +69,7 @@ libva_enum_interface_info (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -static const SpaHandleFactory factories[] = +static const struct spa_handle_factory factories[] = { { "libva-dec", NULL, @@ -83,9 +83,9 @@ static const SpaHandleFactory factories[] = } }; -SpaResult -spa_enum_handle_factory (uint32_t index, - const SpaHandleFactory **factory) +int +spa_handle_factory_enum (uint32_t index, + const struct spa_handle_factory **factory) { if (index >= 2) return SPA_RESULT_ENUM_END; diff --git a/spa/plugins/test/fakesink.c b/spa/plugins/test/fakesink.c index 0610b3457..ed685f34b 100644 --- a/spa/plugins/test/fakesink.c +++ b/spa/plugins/test/fakesink.c @@ -33,22 +33,24 @@ #include #include -typedef struct { +#define NAME "fakesink" + +struct type { uint32_t node; uint32_t clock; uint32_t format; uint32_t props; uint32_t prop_live; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; - SpaTypeParamAllocBuffers param_alloc_buffers; - SpaTypeParamAllocMetaEnable param_alloc_meta_enable; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; + struct spa_type_param_alloc_buffers param_alloc_buffers; + struct spa_type_param_alloc_meta_enable param_alloc_meta_enable; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock); @@ -63,51 +65,47 @@ init_type (Type *type, SpaTypeMap *map) spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable); } -typedef struct _SpaFakeSink SpaFakeSink; - -typedef struct { +struct props { bool live; -} SpaFakeSinkProps; +}; #define MAX_BUFFERS 16 #define MAX_PORTS 1 -typedef struct _Buffer Buffer; - -struct _Buffer { - SpaBuffer *outbuf; - bool outstanding; - SpaMetaHeader *h; - SpaList link; +struct buffer { + struct spa_buffer *outbuf; + bool outstanding; + struct spa_meta_header *h; + struct spa_list link; }; -struct _SpaFakeSink { - SpaHandle handle; - SpaNode node; - SpaClock clock; +struct impl { + struct spa_handle handle; + struct spa_node node; + struct spa_clock clock; - Type type; - SpaTypeMap *map; - SpaLog *log; - SpaLoop *data_loop; + struct type type; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop *data_loop; uint8_t props_buffer[512]; - SpaFakeSinkProps props; + struct props props; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; - SpaSource timer_source; + struct spa_source timer_source; struct itimerspec timerspec; - SpaPortInfo info; + struct spa_port_info info; uint8_t params_buffer[1024]; - SpaPortIO *io; + struct spa_port_io *io; bool have_format; uint8_t format_buffer[1024]; - Buffer buffers[MAX_BUFFERS]; + struct buffer buffers[MAX_BUFFERS]; uint32_t n_buffers; bool started; @@ -115,7 +113,7 @@ struct _SpaFakeSink { uint64_t elapsed_time; uint64_t buffer_count; - SpaList ready; + struct spa_list ready; }; #define CHECK_PORT_NUM(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) < MAX_PORTS) @@ -124,7 +122,7 @@ struct _SpaFakeSink { #define DEFAULT_LIVE false static void -reset_fakesink_props (SpaFakeSink *this, SpaFakeSinkProps *props) +reset_props (struct impl *this, struct props *props) { props->live = DEFAULT_LIVE; } @@ -142,39 +140,39 @@ reset_fakesink_props (SpaFakeSink *this, SpaFakeSinkProps *props) SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \ SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__) -static SpaResult -spa_fakesink_node_get_props (SpaNode *node, - SpaProps **props) +static int +impl_node_get_props (struct spa_node *node, + struct spa_props **props) { - SpaFakeSink *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_props (&b, &f[0], this->type.props, PROP (&f[1], this->type.prop_live, SPA_POD_TYPE_BOOL, this->props.live)); - *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_set_props (SpaNode *node, - const SpaProps *props) +static int +impl_node_set_props (struct spa_node *node, + const struct spa_props *props) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (props == NULL) { - reset_fakesink_props (this, &this->props); + reset_props (this, &this->props); } else { spa_props_query (props, this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live, @@ -190,7 +188,7 @@ spa_fakesink_node_set_props (SpaNode *node, } static void -set_timer (SpaFakeSink *this, bool enabled) +set_timer (struct impl *this, bool enabled) { if (this->callbacks.need_input || this->props.live) { if (enabled) { @@ -211,7 +209,7 @@ set_timer (SpaFakeSink *this, bool enabled) } static inline void -read_timer (SpaFakeSink *this) +read_timer (struct impl *this) { uint64_t expirations; @@ -222,15 +220,15 @@ read_timer (SpaFakeSink *this) } static void -render_buffer (SpaFakeSink *this, Buffer *b) +render_buffer (struct impl *this, struct buffer *b) { } -static SpaResult -fakesink_consume_buffer (SpaFakeSink *this) +static int +consume_buffer (struct impl *this) { - Buffer *b; - SpaPortIO *io = this->io; + struct buffer *b; + struct spa_port_io *io = this->io; int n_bytes; read_timer (this); @@ -241,16 +239,16 @@ fakesink_consume_buffer (SpaFakeSink *this) this->callbacks.need_input (&this->node, this->user_data); } if (spa_list_is_empty (&this->ready)) { - spa_log_error (this->log, "fakesink %p: no buffers", this); + spa_log_error (this->log, NAME " %p: no buffers", this); return SPA_RESULT_NEED_BUFFER; } - b = spa_list_first (&this->ready, Buffer, link); + b = spa_list_first (&this->ready, struct buffer, link); spa_list_remove (&b->link); n_bytes = b->outbuf->datas[0].maxsize; - spa_log_trace (this->log, "fakesink %p: dequeue buffer %d", this, b->outbuf->id); + spa_log_trace (this->log, NAME " %p: dequeue buffer %d", this, b->outbuf->id); render_buffer (this, b); @@ -276,23 +274,23 @@ fakesink_consume_buffer (SpaFakeSink *this) } static void -fakesink_on_input (SpaSource *source) +on_input (struct spa_source *source) { - SpaFakeSink *this = source->data; + struct impl *this = source->data; - fakesink_consume_buffer (this); + consume_buffer (this); } -static SpaResult -spa_fakesink_node_send_command (SpaNode *node, - SpaCommand *command) +static int +impl_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { struct timespec now; @@ -336,17 +334,17 @@ spa_fakesink_node_send_command (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +impl_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (this->data_loop == NULL && callbacks->need_input != NULL) { spa_log_error (this->log, "a data_loop is needed for async operation"); @@ -358,8 +356,8 @@ spa_fakesink_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_get_n_ports (SpaNode *node, +static int +impl_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -379,8 +377,8 @@ spa_fakesink_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_get_port_ids (SpaNode *node, +static int +impl_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -394,47 +392,47 @@ spa_fakesink_node_get_port_ids (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_add_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesink_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesink_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); return SPA_RESULT_ENUM_END; } -static SpaResult -clear_buffers (SpaFakeSink *this) +static int +clear_buffers (struct impl *this) { if (this->n_buffers > 0) { - spa_log_info (this->log, "fakesink %p: clear buffers", this); + spa_log_info (this->log, NAME " %p: clear buffers", this); this->n_buffers = 0; spa_list_init (&this->ready); this->started = false; @@ -443,18 +441,18 @@ clear_buffers (SpaFakeSink *this) return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -470,41 +468,41 @@ spa_fakesink_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); if (!this->have_format) return SPA_RESULT_NO_FORMAT; - *format = (const SpaFormat *) this->format_buffer; + *format = (const struct spa_format *) this->format_buffer; return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -513,21 +511,21 @@ spa_fakesink_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { - SpaFakeSink *this; - SpaPODBuilder b = { NULL }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (param != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -545,39 +543,39 @@ spa_fakesink_node_port_enum_params (SpaNode *node, case 1: spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header), - PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); + PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); break; default: return SPA_RESULT_NOT_IMPLEMENTED; } - *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesink_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +impl_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { - SpaFakeSink *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -587,8 +585,8 @@ spa_fakesink_node_port_use_buffers (SpaNode *node, clear_buffers (this); for (i = 0; i < n_buffers; i++) { - Buffer *b; - SpaData *d = buffers[i]->datas; + struct buffer *b; + struct spa_data *d = buffers[i]->datas; b = &this->buffers[i]; b->outbuf = buffers[i]; @@ -599,7 +597,7 @@ spa_fakesink_node_port_use_buffers (SpaNode *node, d[0].type == this->type.data.MemFd || d[0].type == this->type.data.DmaBuf) && d[0].data == NULL) { - spa_log_error (this->log, "fakesink %p: invalid memory on buffer %p", this, buffers[i]); + spa_log_error (this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); } } this->n_buffers = n_buffers; @@ -607,20 +605,20 @@ spa_fakesink_node_port_use_buffers (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +impl_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -630,17 +628,17 @@ spa_fakesink_node_port_alloc_buffers (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesink_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT_NUM (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -649,46 +647,46 @@ spa_fakesink_node_port_set_io (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_port_reuse_buffer (SpaNode *node, +static int +impl_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesink_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +impl_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesink_node_process_input (SpaNode *node) +static int +impl_node_process_input (struct spa_node *node) { - SpaFakeSink *this; - SpaPortIO *input; + struct impl *this; + struct spa_port_io *input; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); input = this->io; spa_return_val_if_fail (input != NULL, SPA_RESULT_WRONG_STATE); if (input->status == SPA_RESULT_HAVE_BUFFER && input->buffer_id != SPA_ID_INVALID) { - Buffer *b = &this->buffers[input->buffer_id]; + struct buffer *b = &this->buffers[input->buffer_id]; if (!b->outstanding) { - spa_log_warn (this->log, "fakesink %p: buffer %u in use", this, input->buffer_id); + spa_log_warn (this->log, NAME " %p: buffer %u in use", this, input->buffer_id); input->status = SPA_RESULT_INVALID_BUFFER_ID; return SPA_RESULT_ERROR; } - spa_log_trace (this->log, "fakesink %p: queue buffer %u", this, input->buffer_id); + spa_log_trace (this->log, NAME " %p: queue buffer %u", this, input->buffer_id); spa_list_insert (this->ready.prev, &b->link); b->outstanding = false; @@ -697,62 +695,62 @@ spa_fakesink_node_process_input (SpaNode *node) input->status = SPA_RESULT_OK; } if (this->callbacks.need_input == NULL) - return fakesink_consume_buffer (this); + return consume_buffer (this); else return SPA_RESULT_OK; } -static SpaResult -spa_fakesink_node_process_output (SpaNode *node) +static int +impl_node_process_output (struct spa_node *node) { return SPA_RESULT_NOT_IMPLEMENTED; } -static const SpaNode fakesink_node = { - sizeof (SpaNode), +static const struct spa_node impl_node = { + sizeof (struct spa_node), NULL, - spa_fakesink_node_get_props, - spa_fakesink_node_set_props, - spa_fakesink_node_send_command, - spa_fakesink_node_set_callbacks, - spa_fakesink_node_get_n_ports, - spa_fakesink_node_get_port_ids, - spa_fakesink_node_add_port, - spa_fakesink_node_remove_port, - spa_fakesink_node_port_enum_formats, - spa_fakesink_node_port_set_format, - spa_fakesink_node_port_get_format, - spa_fakesink_node_port_get_info, - spa_fakesink_node_port_enum_params, - spa_fakesink_node_port_set_param, - spa_fakesink_node_port_use_buffers, - spa_fakesink_node_port_alloc_buffers, - spa_fakesink_node_port_set_io, - spa_fakesink_node_port_reuse_buffer, - spa_fakesink_node_port_send_command, - spa_fakesink_node_process_input, - spa_fakesink_node_process_output, + impl_node_get_props, + impl_node_set_props, + impl_node_send_command, + impl_node_set_callbacks, + impl_node_get_n_ports, + impl_node_get_port_ids, + impl_node_add_port, + impl_node_remove_port, + impl_node_port_enum_formats, + impl_node_port_set_format, + impl_node_port_get_format, + impl_node_port_get_info, + impl_node_port_enum_params, + impl_node_port_set_param, + impl_node_port_use_buffers, + impl_node_port_alloc_buffers, + impl_node_port_set_io, + impl_node_port_reuse_buffer, + impl_node_port_send_command, + impl_node_process_input, + impl_node_process_output, }; -static SpaResult -spa_fakesink_clock_get_props (SpaClock *clock, - SpaProps **props) +static int +impl_clock_get_props (struct spa_clock *clock, + struct spa_props **props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesink_clock_set_props (SpaClock *clock, - const SpaProps *props) +static int +impl_clock_set_props (struct spa_clock *clock, + const struct spa_props *props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesink_clock_get_time (SpaClock *clock, - int32_t *rate, - int64_t *ticks, - int64_t *monotonic_time) +static int +impl_clock_get_time (struct spa_clock *clock, + int32_t *rate, + int64_t *ticks, + int64_t *monotonic_time) { struct timespec now; uint64_t tnow; @@ -773,26 +771,26 @@ spa_fakesink_clock_get_time (SpaClock *clock, return SPA_RESULT_OK; } -static const SpaClock fakesink_clock = { - sizeof (SpaClock), +static const struct spa_clock impl_clock = { + sizeof (struct spa_clock), NULL, SPA_CLOCK_STATE_STOPPED, - spa_fakesink_clock_get_props, - spa_fakesink_clock_set_props, - spa_fakesink_clock_get_time, + impl_clock_get_props, + impl_clock_set_props, + impl_clock_get_time, }; -static SpaResult -spa_fakesink_get_interface (SpaHandle *handle, +static int +impl_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaFakeSink *) handle; + this = (struct impl *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -804,14 +802,14 @@ spa_fakesink_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -fakesink_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { - SpaFakeSink *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaFakeSink *) handle; + this = (struct impl *) handle; if (this->data_loop) spa_loop_remove_source (this->data_loop, &this->timer_source); @@ -820,23 +818,23 @@ fakesink_clear (SpaHandle *handle) return SPA_RESULT_OK; } -static SpaResult -fakesink_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaFakeSink *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_fakesink_get_interface; - handle->clear = fakesink_clear; + handle->get_interface = impl_get_interface; + handle->clear = impl_clear; - this = (SpaFakeSink *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -852,13 +850,13 @@ fakesink_init (const SpaHandleFactory *factory, } init_type (&this->type, this->map); - this->node = fakesink_node; - this->clock = fakesink_clock; - reset_fakesink_props (this, &this->props); + this->node = impl_node; + this->clock = impl_clock; + reset_props (this, &this->props); spa_list_init (&this->ready); - this->timer_source.func = fakesink_on_input; + this->timer_source.func = on_input; this->timer_source.data = this; this->timer_source.fd = timerfd_create (CLOCK_MONOTONIC, TFD_CLOEXEC); this->timer_source.mask = SPA_IO_IN; @@ -876,20 +874,20 @@ fakesink_init (const SpaHandleFactory *factory, if (this->props.live) this->info.flags |= SPA_PORT_INFO_FLAG_LIVE; - spa_log_info (this->log, "fakesink %p: initialized", this); + spa_log_info (this->log, NAME " %p: initialized", this); return SPA_RESULT_OK; } -static const SpaInterfaceInfo fakesink_interfaces[] = +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Node, }, { SPA_TYPE__Clock, }, }; -static SpaResult -fakesink_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -897,7 +895,7 @@ fakesink_enum_interface_info (const SpaHandleFactory *factory, switch (index) { case 0: - *info = &fakesink_interfaces[index]; + *info = &impl_interfaces[index]; break; default: return SPA_RESULT_ENUM_END; @@ -905,10 +903,10 @@ fakesink_enum_interface_info (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -const SpaHandleFactory spa_fakesink_factory = -{ "fakesink", +const struct spa_handle_factory spa_fakesink_factory = +{ NAME, NULL, - sizeof (SpaFakeSink), - fakesink_init, - fakesink_enum_interface_info, + sizeof (struct impl), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/test/fakesrc.c b/spa/plugins/test/fakesrc.c index 6ed0d6518..f505aa04d 100644 --- a/spa/plugins/test/fakesrc.c +++ b/spa/plugins/test/fakesrc.c @@ -33,23 +33,25 @@ #include #include -typedef struct { +#define NAME "fakesrc" + +struct type { uint32_t node; uint32_t clock; uint32_t format; uint32_t props; uint32_t prop_live; uint32_t prop_pattern; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; - SpaTypeParamAllocBuffers param_alloc_buffers; - SpaTypeParamAllocMetaEnable param_alloc_meta_enable; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; + struct spa_type_param_alloc_buffers param_alloc_buffers; + struct spa_type_param_alloc_meta_enable param_alloc_meta_enable; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock); @@ -65,52 +67,48 @@ init_type (Type *type, SpaTypeMap *map) spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable); } -typedef struct _SpaFakeSrc SpaFakeSrc; - -typedef struct { +struct props { bool live; uint32_t pattern; -} SpaFakeSrcProps; +}; #define MAX_BUFFERS 16 #define MAX_PORTS 1 -typedef struct _Buffer Buffer; - -struct _Buffer { - SpaBuffer *outbuf; +struct buffer { + struct spa_buffer *outbuf; bool outstanding; - SpaMetaHeader *h; - SpaList link; + struct spa_meta_header *h; + struct spa_list link; }; -struct _SpaFakeSrc { - SpaHandle handle; - SpaNode node; - SpaClock clock; +struct impl { + struct spa_handle handle; + struct spa_node node; + struct spa_clock clock; - Type type; - SpaTypeMap *map; - SpaLog *log; - SpaLoop *data_loop; + struct type type; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop *data_loop; uint8_t props_buffer[512]; - SpaFakeSrcProps props; + struct props props; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; - SpaSource timer_source; + struct spa_source timer_source; struct itimerspec timerspec; - SpaPortInfo info; + struct spa_port_info info; uint8_t params_buffer[1024]; - SpaPortIO *io; + struct spa_port_io *io; bool have_format; uint8_t format_buffer[1024]; - Buffer buffers[MAX_BUFFERS]; + struct buffer buffers[MAX_BUFFERS]; uint32_t n_buffers; bool started; @@ -118,7 +116,7 @@ struct _SpaFakeSrc { uint64_t elapsed_time; uint64_t buffer_count; - SpaList empty; + struct spa_list empty; bool underrun; }; @@ -129,7 +127,7 @@ struct _SpaFakeSrc { #define DEFAULT_PATTERN 0 static void -reset_fakesrc_props (SpaFakeSrc *this, SpaFakeSrcProps *props) +reset_props (struct impl *this, struct props *props) { props->live = DEFAULT_LIVE; props->pattern = DEFAULT_PATTERN; @@ -148,18 +146,18 @@ reset_fakesrc_props (SpaFakeSrc *this, SpaFakeSrcProps *props) SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \ SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__) -static SpaResult -spa_fakesrc_node_get_props (SpaNode *node, - SpaProps **props) +static int +impl_node_get_props (struct spa_node *node, + struct spa_props **props) { - SpaFakeSrc *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_props (&b, &f[0], this->type.props, @@ -168,23 +166,23 @@ spa_fakesrc_node_get_props (SpaNode *node, this->props.pattern, this->props.pattern)); - *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_set_props (SpaNode *node, - const SpaProps *props) +static int +impl_node_set_props (struct spa_node *node, + const struct spa_props *props) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (props == NULL) { - reset_fakesrc_props (this, &this->props); + reset_props (this, &this->props); } else { spa_props_query (props, this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live, @@ -200,14 +198,14 @@ spa_fakesrc_node_set_props (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -fill_buffer (SpaFakeSrc *this, Buffer *b) +static int +fill_buffer (struct impl *this, struct buffer *b) { return SPA_RESULT_OK; } static void -set_timer (SpaFakeSrc *this, bool enabled) +set_timer (struct impl *this, bool enabled) { if (this->callbacks.have_output || this->props.live) { if (enabled) { @@ -228,7 +226,7 @@ set_timer (SpaFakeSrc *this, bool enabled) } static inline void -read_timer (SpaFakeSrc *this) +read_timer (struct impl *this) { uint64_t expirations; @@ -238,11 +236,11 @@ read_timer (SpaFakeSrc *this) } } -static SpaResult -fakesrc_make_buffer (SpaFakeSrc *this) +static int +make_buffer (struct impl *this) { - Buffer *b; - SpaPortIO *io = this->io; + struct buffer *b; + struct spa_port_io *io = this->io; int n_bytes; read_timer (this); @@ -250,16 +248,16 @@ fakesrc_make_buffer (SpaFakeSrc *this) if (spa_list_is_empty (&this->empty)) { set_timer (this, false); this->underrun = true; - spa_log_error (this->log, "fakesrc %p: out of buffers", this); + spa_log_error (this->log, NAME " %p: out of buffers", this); return SPA_RESULT_OUT_OF_BUFFERS; } - b = spa_list_first (&this->empty, Buffer, link); + b = spa_list_first (&this->empty, struct buffer, link); spa_list_remove (&b->link); b->outstanding = true; n_bytes = b->outbuf->datas[0].maxsize; - spa_log_trace (this->log, "fakesrc %p: dequeue buffer %d", this, b->outbuf->id); + spa_log_trace (this->log, NAME " %p: dequeue buffer %d", this, b->outbuf->id); fill_buffer (this, b); @@ -284,27 +282,27 @@ fakesrc_make_buffer (SpaFakeSrc *this) } static void -fakesrc_on_output (SpaSource *source) +on_output (struct spa_source *source) { - SpaFakeSrc *this = source->data; - SpaResult res; + struct impl *this = source->data; + int res; - res = fakesrc_make_buffer (this); + res = make_buffer (this); if (res == SPA_RESULT_HAVE_BUFFER && this->callbacks.have_output) this->callbacks.have_output (&this->node, this->user_data); } -static SpaResult -spa_fakesrc_node_send_command (SpaNode *node, - SpaCommand *command) +static int +impl_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { struct timespec now; @@ -348,17 +346,17 @@ spa_fakesrc_node_send_command (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +impl_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (this->data_loop == NULL && callbacks->have_output != NULL) { spa_log_error (this->log, "a data_loop is needed for async operation"); @@ -370,8 +368,8 @@ spa_fakesrc_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_get_n_ports (SpaNode *node, +static int +impl_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -391,8 +389,8 @@ spa_fakesrc_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_get_port_ids (SpaNode *node, +static int +impl_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -406,47 +404,47 @@ spa_fakesrc_node_get_port_ids (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_add_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesrc_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesrc_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); return SPA_RESULT_ENUM_END; } -static SpaResult -clear_buffers (SpaFakeSrc *this) +static int +clear_buffers (struct impl *this) { if (this->n_buffers > 0) { - spa_log_info (this->log, "fakesrc %p: clear buffers", this); + spa_log_info (this->log, NAME " %p: clear buffers", this); this->n_buffers = 0; spa_list_init (&this->empty); this->started = false; @@ -455,18 +453,18 @@ clear_buffers (SpaFakeSrc *this) return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -486,41 +484,41 @@ spa_fakesrc_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); if (!this->have_format) return SPA_RESULT_NO_FORMAT; - *format = (const SpaFormat *) this->format_buffer; + *format = (const struct spa_format *) this->format_buffer; return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -529,21 +527,21 @@ spa_fakesrc_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { - SpaFakeSrc *this; - SpaPODBuilder b = { NULL }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (param != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -561,39 +559,39 @@ spa_fakesrc_node_port_enum_params (SpaNode *node, case 1: spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header), - PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); + PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); break; default: return SPA_RESULT_NOT_IMPLEMENTED; } - *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesrc_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +impl_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { - SpaFakeSrc *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -603,8 +601,8 @@ spa_fakesrc_node_port_use_buffers (SpaNode *node, clear_buffers (this); for (i = 0; i < n_buffers; i++) { - Buffer *b; - SpaData *d = buffers[i]->datas; + struct buffer *b; + struct spa_data *d = buffers[i]->datas; b = &this->buffers[i]; b->outbuf = buffers[i]; @@ -615,7 +613,7 @@ spa_fakesrc_node_port_use_buffers (SpaNode *node, d[0].type == this->type.data.MemFd || d[0].type == this->type.data.DmaBuf) && d[0].data == NULL) { - spa_log_error (this->log, "fakesrc %p: invalid memory on buffer %p", this, buffers[i]); + spa_log_error (this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); } spa_list_insert (this->empty.prev, &b->link); } @@ -625,20 +623,20 @@ spa_fakesrc_node_port_use_buffers (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +impl_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -648,17 +646,17 @@ spa_fakesrc_node_port_alloc_buffers (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesrc_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT_NUM (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -668,12 +666,12 @@ spa_fakesrc_node_port_set_io (SpaNode *node, } static inline void -reuse_buffer (SpaFakeSrc *this, uint32_t id) +reuse_buffer (struct impl *this, uint32_t id) { - Buffer *b = &this->buffers[id]; + struct buffer *b = &this->buffers[id]; spa_return_if_fail (b->outstanding); - spa_log_trace (this->log, "fakesrc %p: reuse buffer %d", this, id); + spa_log_trace (this->log, NAME " %p: reuse buffer %d", this, id); b->outstanding = false; spa_list_insert (this->empty.prev, &b->link); @@ -684,16 +682,16 @@ reuse_buffer (SpaFakeSrc *this, uint32_t id) } } -static SpaResult -spa_fakesrc_node_port_reuse_buffer (SpaNode *node, +static int +impl_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (port_id == 0, SPA_RESULT_INVALID_PORT); spa_return_val_if_fail (this->n_buffers > 0, SPA_RESULT_NO_BUFFERS); @@ -704,30 +702,30 @@ spa_fakesrc_node_port_reuse_buffer (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_fakesrc_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +impl_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesrc_node_process_input (SpaNode *node) +static int +impl_node_process_input (struct spa_node *node) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesrc_node_process_output (SpaNode *node) +static int +impl_node_process_output (struct spa_node *node) { - SpaFakeSrc *this; - SpaPortIO *io; + struct impl *this; + struct spa_port_io *io; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaFakeSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); io = this->io; spa_return_val_if_fail (io != NULL, SPA_RESULT_WRONG_STATE); @@ -740,53 +738,53 @@ spa_fakesrc_node_process_output (SpaNode *node) } if (this->callbacks.have_output == NULL && (io->status == SPA_RESULT_NEED_BUFFER)) - return fakesrc_make_buffer (this); + return make_buffer (this); else return SPA_RESULT_OK; } -static const SpaNode fakesrc_node = { - sizeof (SpaNode), +static const struct spa_node impl_node = { + sizeof (struct spa_node), NULL, - spa_fakesrc_node_get_props, - spa_fakesrc_node_set_props, - spa_fakesrc_node_send_command, - spa_fakesrc_node_set_callbacks, - spa_fakesrc_node_get_n_ports, - spa_fakesrc_node_get_port_ids, - spa_fakesrc_node_add_port, - spa_fakesrc_node_remove_port, - spa_fakesrc_node_port_enum_formats, - spa_fakesrc_node_port_set_format, - spa_fakesrc_node_port_get_format, - spa_fakesrc_node_port_get_info, - spa_fakesrc_node_port_enum_params, - spa_fakesrc_node_port_set_param, - spa_fakesrc_node_port_use_buffers, - spa_fakesrc_node_port_alloc_buffers, - spa_fakesrc_node_port_set_io, - spa_fakesrc_node_port_reuse_buffer, - spa_fakesrc_node_port_send_command, - spa_fakesrc_node_process_input, - spa_fakesrc_node_process_output, + impl_node_get_props, + impl_node_set_props, + impl_node_send_command, + impl_node_set_callbacks, + impl_node_get_n_ports, + impl_node_get_port_ids, + impl_node_add_port, + impl_node_remove_port, + impl_node_port_enum_formats, + impl_node_port_set_format, + impl_node_port_get_format, + impl_node_port_get_info, + impl_node_port_enum_params, + impl_node_port_set_param, + impl_node_port_use_buffers, + impl_node_port_alloc_buffers, + impl_node_port_set_io, + impl_node_port_reuse_buffer, + impl_node_port_send_command, + impl_node_process_input, + impl_node_process_output, }; -static SpaResult -spa_fakesrc_clock_get_props (SpaClock *clock, - SpaProps **props) +static int +impl_clock_get_props (struct spa_clock *clock, + struct spa_props **props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesrc_clock_set_props (SpaClock *clock, - const SpaProps *props) +static int +impl_clock_set_props (struct spa_clock *clock, + const struct spa_props *props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_fakesrc_clock_get_time (SpaClock *clock, +static int +impl_clock_get_time (struct spa_clock *clock, int32_t *rate, int64_t *ticks, int64_t *monotonic_time) @@ -810,26 +808,26 @@ spa_fakesrc_clock_get_time (SpaClock *clock, return SPA_RESULT_OK; } -static const SpaClock fakesrc_clock = { - sizeof (SpaClock), +static const struct spa_clock impl_clock = { + sizeof (struct spa_clock), NULL, SPA_CLOCK_STATE_STOPPED, - spa_fakesrc_clock_get_props, - spa_fakesrc_clock_set_props, - spa_fakesrc_clock_get_time, + impl_clock_get_props, + impl_clock_set_props, + impl_clock_get_time, }; -static SpaResult -spa_fakesrc_get_interface (SpaHandle *handle, +static int +impl_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaFakeSrc *) handle; + this = (struct impl *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -841,14 +839,14 @@ spa_fakesrc_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -fakesrc_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { - SpaFakeSrc *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaFakeSrc *) handle; + this = (struct impl *) handle; if (this->data_loop) spa_loop_remove_source (this->data_loop, &this->timer_source); @@ -857,23 +855,23 @@ fakesrc_clear (SpaHandle *handle) return SPA_RESULT_OK; } -static SpaResult -fakesrc_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaFakeSrc *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_fakesrc_get_interface; - handle->clear = fakesrc_clear; + handle->get_interface = impl_get_interface; + handle->clear = impl_clear; - this = (SpaFakeSrc *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -889,13 +887,13 @@ fakesrc_init (const SpaHandleFactory *factory, } init_type (&this->type, this->map); - this->node = fakesrc_node; - this->clock = fakesrc_clock; - reset_fakesrc_props (this, &this->props); + this->node = impl_node; + this->clock = impl_clock; + reset_props (this, &this->props); spa_list_init (&this->empty); - this->timer_source.func = fakesrc_on_output; + this->timer_source.func = on_output; this->timer_source.data = this; this->timer_source.fd = timerfd_create (CLOCK_MONOTONIC, TFD_CLOEXEC); this->timer_source.mask = SPA_IO_IN; @@ -913,20 +911,20 @@ fakesrc_init (const SpaHandleFactory *factory, if (this->props.live) this->info.flags |= SPA_PORT_INFO_FLAG_LIVE; - spa_log_info (this->log, "fakesrc %p: initialized", this); + spa_log_info (this->log, NAME " %p: initialized", this); return SPA_RESULT_OK; } -static const SpaInterfaceInfo fakesrc_interfaces[] = +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Node, }, { SPA_TYPE__Clock, }, }; -static SpaResult -fakesrc_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -934,7 +932,7 @@ fakesrc_enum_interface_info (const SpaHandleFactory *factory, switch (index) { case 0: - *info = &fakesrc_interfaces[index]; + *info = &impl_interfaces[index]; break; default: return SPA_RESULT_ENUM_END; @@ -942,10 +940,10 @@ fakesrc_enum_interface_info (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -const SpaHandleFactory spa_fakesrc_factory = -{ "fakesrc", +const struct spa_handle_factory spa_fakesrc_factory = +{ NAME, NULL, - sizeof (SpaFakeSrc), - fakesrc_init, - fakesrc_enum_interface_info, + sizeof (struct impl), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/test/plugin.c b/spa/plugins/test/plugin.c index 5ec7df0dc..4106b78fb 100644 --- a/spa/plugins/test/plugin.c +++ b/spa/plugins/test/plugin.c @@ -20,24 +20,25 @@ #include #include -extern const SpaHandleFactory spa_fakesrc_factory; -extern const SpaHandleFactory spa_fakesink_factory; +extern const struct spa_handle_factory spa_fakesrc_factory; +extern const struct spa_handle_factory spa_fakesink_factory; -SpaResult -spa_enum_handle_factory (const SpaHandleFactory **factory, - uint32_t index) +int +spa_handle_factory_enum(const struct spa_handle_factory **factory, + uint32_t index) { - spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); + spa_return_val_if_fail(factory != NULL, + SPA_RESULT_INVALID_ARGUMENTS); - switch (index) { - case 0: - *factory = &spa_fakesrc_factory; - break; - case 1: - *factory = &spa_fakesink_factory; - break; - default: - return SPA_RESULT_ENUM_END; - } - return SPA_RESULT_OK; + switch (index) { + case 0: + *factory = &spa_fakesrc_factory; + break; + case 1: + *factory = &spa_fakesink_factory; + break; + default: + return SPA_RESULT_ENUM_END; + } + return SPA_RESULT_OK; } diff --git a/spa/plugins/v4l2/v4l2-monitor.c b/spa/plugins/v4l2/v4l2-monitor.c index 093e86161..8cbbfda68 100644 --- a/spa/plugins/v4l2/v4l2-monitor.c +++ b/spa/plugins/v4l2/v4l2-monitor.c @@ -31,37 +31,37 @@ #include #include -extern const SpaHandleFactory spa_v4l2_source_factory; +#define NAME "v4l2-monitor" -typedef struct _SpaV4l2Monitor SpaV4l2Monitor; +extern const struct spa_handle_factory spa_v4l2_source_factory; -typedef struct { - SpaMonitorItem *item; +struct item { + struct spa_monitor_item *item; struct udev_device *udevice; -} V4l2Item; +}; -typedef struct { +struct type { uint32_t handle_factory; - SpaTypeMonitor monitor; -} Type; + struct spa_type_monitor monitor; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->handle_factory = spa_type_map_get_id (map, SPA_TYPE__HandleFactory); spa_type_monitor_map (map, &type->monitor); } -struct _SpaV4l2Monitor { - SpaHandle handle; - SpaMonitor monitor; +struct impl { + struct spa_handle handle; + struct spa_monitor monitor; - Type type; - SpaTypeMap *map; - SpaLog *log; - SpaLoop *main_loop; + struct type type; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop *main_loop; - SpaEventMonitorCallback event_cb; + struct spa_monitor_callbacks callbacks; void *user_data; struct udev* udev; @@ -71,13 +71,13 @@ struct _SpaV4l2Monitor { struct udev_list_entry *devices; uint8_t item_buffer[4096]; - V4l2Item uitem; + struct item uitem; - SpaSource source; + struct spa_source source; }; -static SpaResult -v4l2_udev_open (SpaV4l2Monitor *this) +static int +impl_udev_open (struct impl *this) { if (this->udev != NULL) return SPA_RESULT_OK; @@ -88,11 +88,11 @@ v4l2_udev_open (SpaV4l2Monitor *this) } static void -fill_item (SpaV4l2Monitor *this, V4l2Item *item, struct udev_device *udevice) +fill_item (struct impl *this, struct item *item, struct udev_device *udevice) { const char *str, *name; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[3]; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[3]; if (item->udevice) udev_device_unref (item->udevice); @@ -187,19 +187,19 @@ fill_item (SpaV4l2Monitor *this, V4l2Item *item, struct udev_device *udevice) spa_pod_builder_pop (&b, &f[0]); - item->item = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaMonitorItem); + item->item = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_monitor_item); } static void -v4l2_on_fd_events (SpaSource *source) +impl_on_fd_events (struct spa_source *source) { - SpaV4l2Monitor *this = source->data; + struct impl *this = source->data; struct udev_device *dev; - SpaEvent *event; + struct spa_event *event; const char *action; uint32_t type; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[1]; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[1]; uint8_t buffer[4096]; dev = udev_monitor_receive_device (this->umonitor); @@ -223,27 +223,28 @@ v4l2_on_fd_events (SpaSource *source) spa_pod_builder_object (&b, &f[0], 0, type, SPA_POD_TYPE_POD, this->uitem.item); - event = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaEventMonitor); - this->event_cb (&this->monitor, event, this->user_data); + event = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_event); + this->callbacks.event (&this->monitor, event, this->user_data); } -static SpaResult -spa_v4l2_monitor_set_event_callback (SpaMonitor *monitor, - SpaEventMonitorCallback callback, - void *user_data) +static int +impl_monitor_set_callbacks (struct spa_monitor *monitor, + const struct spa_monitor_callbacks *callbacks, + size_t callbacks_size, + void *user_data) { - SpaResult res; - SpaV4l2Monitor *this; + int res; + struct impl *this; spa_return_val_if_fail (monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (monitor, SpaV4l2Monitor, monitor); + this = SPA_CONTAINER_OF (monitor, struct impl, monitor); - this->event_cb = callback; - this->user_data = user_data; + if (callbacks) { + this->callbacks = *callbacks; + this->user_data = user_data; - if (callback) { - if ((res = v4l2_udev_open (this)) < 0) + if ((res = impl_udev_open (this)) < 0) return res; this->umonitor = udev_monitor_new_from_netlink (this->udev, "udev"); @@ -255,34 +256,35 @@ spa_v4l2_monitor_set_event_callback (SpaMonitor *monitor, NULL); udev_monitor_enable_receiving (this->umonitor); - this->source.func = v4l2_on_fd_events; + this->source.func = impl_on_fd_events; this->source.data = this; this->source.fd = udev_monitor_get_fd (this->umonitor);; this->source.mask = SPA_IO_IN | SPA_IO_ERR; spa_loop_add_source (this->main_loop, &this->source); } else { + spa_zero (this->callbacks); spa_loop_remove_source (this->main_loop, &this->source); } return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_monitor_enum_items (SpaMonitor *monitor, - SpaMonitorItem **item, +static int +impl_monitor_enum_items (struct spa_monitor *monitor, + struct spa_monitor_item **item, uint32_t index) { - SpaResult res; - SpaV4l2Monitor *this; + int res; + struct impl *this; struct udev_device *dev; spa_return_val_if_fail (monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (item != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (monitor, SpaV4l2Monitor, monitor); + this = SPA_CONTAINER_OF (monitor, struct impl, monitor); - if ((res = v4l2_udev_open (this)) < 0) + if ((res = impl_udev_open (this)) < 0) return res; if (index == 0) { @@ -320,24 +322,24 @@ spa_v4l2_monitor_enum_items (SpaMonitor *monitor, return SPA_RESULT_OK; } -static const SpaMonitor v4l2monitor = { +static const struct spa_monitor impl_monitor = { NULL, - sizeof (SpaMonitor), - spa_v4l2_monitor_set_event_callback, - spa_v4l2_monitor_enum_items, + sizeof (struct spa_monitor), + impl_monitor_set_callbacks, + impl_monitor_enum_items, }; -static SpaResult -spa_v4l2_monitor_get_interface (SpaHandle *handle, +static int +impl_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaV4l2Monitor *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaV4l2Monitor *) handle; + this = (struct impl *) handle; if (interface_id == this->type.monitor.Monitor) *interface = &this->monitor; @@ -347,29 +349,29 @@ spa_v4l2_monitor_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -v4l2_monitor_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { return SPA_RESULT_OK; } -static SpaResult -v4l2_monitor_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaV4l2Monitor *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_v4l2_monitor_get_interface; - handle->clear = v4l2_monitor_clear, + handle->get_interface = impl_get_interface; + handle->clear = impl_clear, - this = (SpaV4l2Monitor *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -389,35 +391,35 @@ v4l2_monitor_init (const SpaHandleFactory *factory, } init_type (&this->type, this->map); - this->monitor = v4l2monitor; + this->monitor = impl_monitor; return SPA_RESULT_OK; } -static const SpaInterfaceInfo v4l2_monitor_interfaces[] = +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Monitor, }, }; -static SpaResult -v4l2_monitor_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, - uint32_t index) +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, + uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - if (index < 0 || index >= SPA_N_ELEMENTS (v4l2_monitor_interfaces)) + if (index < 0 || index >= SPA_N_ELEMENTS (impl_interfaces)) return SPA_RESULT_ENUM_END; - *info = &v4l2_monitor_interfaces[index]; + *info = &impl_interfaces[index]; return SPA_RESULT_OK; } -const SpaHandleFactory spa_v4l2_monitor_factory = -{ "v4l2-monitor", +const struct spa_handle_factory spa_v4l2_monitor_factory = +{ NAME, NULL, - sizeof (SpaV4l2Monitor), - v4l2_monitor_init, - v4l2_monitor_enum_interface_info, + sizeof (struct impl), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 5b4131a87..825c49c01 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -36,35 +36,33 @@ #include #include -typedef struct _SpaV4l2Source SpaV4l2Source; +#define NAME "v4l2-source" static const char default_device[] = "/dev/video0"; -typedef struct { +struct props { char device[64]; char device_name[128]; int device_fd; -} SpaV4l2SourceProps; +}; static void -reset_v4l2_source_props (SpaV4l2SourceProps *props) +reset_props (struct props *props) { strncpy (props->device, default_device, 64); } #define MAX_BUFFERS 64 -typedef struct _V4l2Buffer V4l2Buffer; - -struct _V4l2Buffer { - SpaBuffer *outbuf; - SpaMetaHeader *h; +struct buffer { + struct spa_buffer *outbuf; + struct spa_meta_header *h; bool outstanding; bool allocated; struct v4l2_buffer v4l2_buffer; }; -typedef struct { +struct type { uint32_t node; uint32_t clock; uint32_t format; @@ -72,21 +70,21 @@ typedef struct { uint32_t prop_device; uint32_t prop_device_name; uint32_t prop_device_fd; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeMediaSubtypeVideo media_subtype_video; - SpaTypeFormatVideo format_video; - SpaTypeVideoFormat video_format; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; - SpaTypeParamAllocBuffers param_alloc_buffers; - SpaTypeParamAllocMetaEnable param_alloc_meta_enable; - SpaTypeMeta meta; - SpaTypeData data; -} Type; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_media_subtype_video media_subtype_video; + struct spa_type_format_video format_video; + struct spa_type_video_format video_format; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; + struct spa_type_param_alloc_buffers param_alloc_buffers; + struct spa_type_param_alloc_meta_enable param_alloc_meta_enable; + struct spa_type_meta meta; + struct spa_type_data data; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock); @@ -108,10 +106,10 @@ init_type (Type *type, SpaTypeMap *map) spa_type_data_map (map, &type->data); } -typedef struct { - SpaLog *log; - SpaLoop *main_loop; - SpaLoop *data_loop; +struct port { + struct spa_log *log; + struct spa_loop *main_loop; + struct spa_loop *data_loop; bool export_buf; bool started; @@ -123,7 +121,7 @@ typedef struct { struct v4l2_frmivalenum frmival; bool have_format; - SpaVideoInfo current_format; + struct spa_video_info current_format; uint8_t format_buffer[1024]; int fd; @@ -133,38 +131,38 @@ typedef struct { enum v4l2_buf_type type; enum v4l2_memory memtype; - V4l2Buffer buffers[MAX_BUFFERS]; - uint32_t n_buffers; + struct buffer buffers[MAX_BUFFERS]; + uint32_t n_buffers; bool source_enabled; - SpaSource source; + struct spa_source source; - SpaPortInfo info; + struct spa_port_info info; uint8_t params_buffer[1024]; - SpaPortIO *io; + struct spa_port_io *io; int64_t last_ticks; int64_t last_monotonic; -} SpaV4l2State; +}; -struct _SpaV4l2Source { - SpaHandle handle; - SpaNode node; - SpaClock clock; +struct impl { + struct spa_handle handle; + struct spa_node node; + struct spa_clock clock; - SpaTypeMap *map; - SpaLog *log; - Type type; + struct spa_type_map *map; + struct spa_log *log; + struct type type; uint32_t seq; uint8_t props_buffer[512]; - SpaV4l2SourceProps props; + struct props props; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; - SpaV4l2State state[1]; + struct port out_ports[1]; }; #define CHECK_PORT(this,direction,port_id) ((direction) == SPA_DIRECTION_OUTPUT && (port_id) == 0) @@ -186,41 +184,41 @@ struct _SpaV4l2Source { SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__) #include "v4l2-utils.c" -static SpaResult -spa_v4l2_source_node_get_props (SpaNode *node, - SpaProps **props) +static int +impl_node_get_props (struct spa_node *node, + struct spa_props **props) { - SpaV4l2Source *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_props (&b, &f[0], this->type.props, PROP (&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)), PROP_R (&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)), PROP_R (&f[1], this->type.prop_device_fd, SPA_POD_TYPE_INT, this->props.device_fd)); - *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_source_node_set_props (SpaNode *node, - const SpaProps *props) +static int +impl_node_set_props (struct spa_node *node, + const struct spa_props *props) { - SpaV4l2Source *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (props == NULL) { - reset_v4l2_source_props (&this->props); + reset_props (&this->props); return SPA_RESULT_OK; } else { spa_props_query (props, @@ -230,36 +228,36 @@ spa_v4l2_source_node_set_props (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -do_pause_done (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_pause_done (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - SpaV4l2Source *this = user_data; - SpaEventNodeAsyncComplete *ac = data; + struct impl *this = user_data; + struct spa_event_node_async_complete *ac = data; if (SPA_RESULT_IS_OK (ac->body.res.value)) ac->body.res.value = spa_v4l2_stream_off (this); - this->callbacks.event (&this->node, (SpaEvent *)ac, this->user_data); + this->callbacks.event (&this->node, (struct spa_event *)ac, this->user_data); return SPA_RESULT_OK; } -static SpaResult -do_pause (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_pause (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - SpaV4l2Source *this = user_data; - SpaResult res; - SpaCommand *cmd = data; + struct impl *this = user_data; + int res; + struct spa_command *cmd = data; res = spa_node_port_send_command (&this->node, SPA_DIRECTION_OUTPUT, @@ -267,10 +265,10 @@ do_pause (SpaLoop *loop, cmd); if (async) { - spa_loop_invoke (this->state[0].main_loop, + spa_loop_invoke (this->out_ports[0].main_loop, do_pause_done, seq, - sizeof (SpaEventNodeAsyncComplete), + sizeof (struct spa_event_node_async_complete), &SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete, seq, res), this); @@ -278,33 +276,33 @@ do_pause (SpaLoop *loop, return res; } -static SpaResult -do_start_done (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_start_done (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - SpaV4l2Source *this = user_data; - SpaEventNodeAsyncComplete *ac = data; + struct impl *this = user_data; + struct spa_event_node_async_complete *ac = data; - this->callbacks.event (&this->node, (SpaEvent *)ac, this->user_data); + this->callbacks.event (&this->node, (struct spa_event *)ac, this->user_data); return SPA_RESULT_OK; } -static SpaResult -do_start (SpaLoop *loop, - bool async, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_start (struct spa_loop *loop, + bool async, + uint32_t seq, + size_t size, + void *data, + void *user_data) { - SpaV4l2Source *this = user_data; - SpaResult res; - SpaCommand *cmd = data; + struct impl *this = user_data; + int res; + struct spa_command *cmd = data; res = spa_node_port_send_command (&this->node, SPA_DIRECTION_OUTPUT, @@ -312,10 +310,10 @@ do_start (SpaLoop *loop, cmd); if (async) { - spa_loop_invoke (this->state[0].main_loop, + spa_loop_invoke (this->out_ports[0].main_loop, do_start_done, seq, - sizeof (SpaEventNodeAsyncComplete), + sizeof (struct spa_event_node_async_complete), &SPA_EVENT_NODE_ASYNC_COMPLETE_INIT (this->type.event_node.AsyncComplete, seq, res), this); @@ -324,20 +322,20 @@ do_start (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_source_node_send_command (SpaNode *node, - SpaCommand *command) +static int +impl_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaV4l2Source *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { - SpaV4l2State *state = &this->state[0]; - SpaResult res; + struct port *state = &this->out_ports[0]; + int res; if (!state->have_format) return SPA_RESULT_NO_FORMAT; @@ -348,7 +346,7 @@ spa_v4l2_source_node_send_command (SpaNode *node, if ((res = spa_v4l2_stream_on (this)) < 0) return res; - return spa_loop_invoke (this->state[0].data_loop, + return spa_loop_invoke (this->out_ports[0].data_loop, do_start, ++this->seq, SPA_POD_SIZE (command), @@ -356,7 +354,7 @@ spa_v4l2_source_node_send_command (SpaNode *node, this); } else if (SPA_COMMAND_TYPE (command) == this->type.command_node.Pause) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; if (!state->have_format) return SPA_RESULT_NO_FORMAT; @@ -364,7 +362,7 @@ spa_v4l2_source_node_send_command (SpaNode *node, if (state->n_buffers == 0) return SPA_RESULT_NO_BUFFERS; - return spa_loop_invoke (this->state[0].data_loop, + return spa_loop_invoke (this->out_ports[0].data_loop, do_pause, ++this->seq, SPA_POD_SIZE (command), @@ -378,17 +376,17 @@ spa_v4l2_source_node_send_command (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_v4l2_source_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +impl_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaV4l2Source *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); this->callbacks = *callbacks; this->user_data = user_data; @@ -396,8 +394,8 @@ spa_v4l2_source_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_source_node_get_n_ports (SpaNode *node, +static int +impl_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -417,8 +415,8 @@ spa_v4l2_source_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_source_node_get_port_ids (SpaNode *node, +static int +impl_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -433,37 +431,37 @@ spa_v4l2_source_node_get_port_ids (SpaNode *node, } -static SpaResult -spa_v4l2_source_node_add_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_v4l2_source_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_v4l2_source_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - SpaV4l2Source *this; - SpaResult res; + struct impl *this; + int res; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -472,24 +470,24 @@ spa_v4l2_source_node_port_enum_formats (SpaNode *node, return res; } -static SpaResult -spa_v4l2_source_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaV4l2Source *this; - SpaV4l2State *state; - SpaVideoInfo info; + struct impl *this; + struct port *state; + struct spa_video_info info; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); - state = &this->state[port_id]; + state = &this->out_ports[port_id]; if (format == NULL) { spa_v4l2_stream_off (this); @@ -557,25 +555,25 @@ spa_v4l2_source_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_source_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaV4l2Source *this; - SpaV4l2State *state; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct port *state; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); - state = &this->state[port_id]; + state = &this->out_ports[port_id]; if (!state->have_format) return SPA_RESULT_NO_FORMAT; @@ -611,52 +609,52 @@ spa_v4l2_source_node_port_get_format (SpaNode *node, spa_pod_builder_pop (&b, &f[0]); - *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_source_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaV4l2Source *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); - *info = &this->state[port_id].info; + *info = &this->out_ports[port_id].info; return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_source_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { - SpaV4l2Source *this; - SpaV4l2State *state; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct port *state; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (param != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); - state = &this->state[port_id]; + state = &this->out_ports[port_id]; spa_pod_builder_init (&b, state->params_buffer, sizeof (state->params_buffer)); @@ -672,45 +670,45 @@ spa_v4l2_source_node_port_enum_params (SpaNode *node, case 1: spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header), - PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); + PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); break; default: return SPA_RESULT_NOT_IMPLEMENTED; } - *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_source_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_v4l2_source_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +impl_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { - SpaV4l2Source *this; - SpaV4l2State *state; - SpaResult res; + struct impl *this; + struct port *state; + int res; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); - state = &this->state[port_id]; + state = &this->out_ports[port_id]; if (!state->have_format) return SPA_RESULT_NO_FORMAT; @@ -727,27 +725,27 @@ spa_v4l2_source_node_port_use_buffers (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_source_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +impl_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { - SpaV4l2Source *this; - SpaV4l2State *state; - SpaResult res; + struct impl *this; + struct port *state; + int res; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (buffers != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); - state = &this->state[port_id]; + state = &this->out_ports[port_id]; if (!state->have_format) return SPA_RESULT_NO_FORMAT; @@ -757,39 +755,39 @@ spa_v4l2_source_node_port_alloc_buffers (SpaNode *node, return res; } -static SpaResult -spa_v4l2_source_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaV4l2Source *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); - this->state[port_id].io = io; + this->out_ports[port_id].io = io; return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_source_node_port_reuse_buffer (SpaNode *node, +static int +impl_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { - SpaV4l2Source *this; - SpaV4l2State *state; - SpaResult res; + struct impl *this; + struct port *state; + int res; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (port_id == 0, SPA_RESULT_INVALID_PORT); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); - state = &this->state[port_id]; + this = SPA_CONTAINER_OF (node, struct impl, node); + state = &this->out_ports[port_id]; spa_return_val_if_fail (state->n_buffers > 0, SPA_RESULT_NO_BUFFERS); spa_return_val_if_fail (buffer_id < state->n_buffers, SPA_RESULT_INVALID_BUFFER_ID); @@ -799,18 +797,18 @@ spa_v4l2_source_node_port_reuse_buffer (SpaNode *node, return res; } -static SpaResult -spa_v4l2_source_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +impl_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { - SpaV4l2Source *this; - SpaResult res; + struct impl *this; + int res; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -826,23 +824,23 @@ spa_v4l2_source_node_port_send_command (SpaNode *node, return res; } -static SpaResult -spa_v4l2_source_node_process_input (SpaNode *node) +static int +impl_node_process_input (struct spa_node *node) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_v4l2_source_node_process_output (SpaNode *node) +static int +impl_node_process_output (struct spa_node *node) { - SpaV4l2Source *this; - SpaResult res = SPA_RESULT_OK; - SpaPortIO *io; + struct impl *this; + int res = SPA_RESULT_OK; + struct spa_port_io *io; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); - io = this->state[0].io; + this = SPA_CONTAINER_OF (node, struct impl, node); + io = this->out_ports[0].io; spa_return_val_if_fail (io != NULL, SPA_RESULT_WRONG_STATE); if (io->status == SPA_RESULT_HAVE_BUFFER) @@ -855,59 +853,59 @@ spa_v4l2_source_node_process_output (SpaNode *node) return res; } -static const SpaNode v4l2source_node = { - sizeof (SpaNode), +static const struct spa_node impl_node = { + sizeof (struct spa_node), NULL, - spa_v4l2_source_node_get_props, - spa_v4l2_source_node_set_props, - spa_v4l2_source_node_send_command, - spa_v4l2_source_node_set_callbacks, - spa_v4l2_source_node_get_n_ports, - spa_v4l2_source_node_get_port_ids, - spa_v4l2_source_node_add_port, - spa_v4l2_source_node_remove_port, - spa_v4l2_source_node_port_enum_formats, - spa_v4l2_source_node_port_set_format, - spa_v4l2_source_node_port_get_format, - spa_v4l2_source_node_port_get_info, - spa_v4l2_source_node_port_enum_params, - spa_v4l2_source_node_port_set_param, - spa_v4l2_source_node_port_use_buffers, - spa_v4l2_source_node_port_alloc_buffers, - spa_v4l2_source_node_port_set_io, - spa_v4l2_source_node_port_reuse_buffer, - spa_v4l2_source_node_port_send_command, - spa_v4l2_source_node_process_input, - spa_v4l2_source_node_process_output, + impl_node_get_props, + impl_node_set_props, + impl_node_send_command, + impl_node_set_callbacks, + impl_node_get_n_ports, + impl_node_get_port_ids, + impl_node_add_port, + impl_node_remove_port, + impl_node_port_enum_formats, + impl_node_port_set_format, + impl_node_port_get_format, + impl_node_port_get_info, + impl_node_port_enum_params, + impl_node_port_set_param, + impl_node_port_use_buffers, + impl_node_port_alloc_buffers, + impl_node_port_set_io, + impl_node_port_reuse_buffer, + impl_node_port_send_command, + impl_node_process_input, + impl_node_process_output, }; -static SpaResult -spa_v4l2_source_clock_get_props (SpaClock *clock, - SpaProps **props) +static int +impl_clock_get_props (struct spa_clock *clock, + struct spa_props **props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_v4l2_source_clock_set_props (SpaClock *clock, - const SpaProps *props) +static int +impl_clock_set_props (struct spa_clock *clock, + const struct spa_props *props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_v4l2_source_clock_get_time (SpaClock *clock, +static int +impl_clock_get_time (struct spa_clock *clock, int32_t *rate, int64_t *ticks, int64_t *monotonic_time) { - SpaV4l2Source *this; - SpaV4l2State *state; + struct impl *this; + struct port *state; spa_return_val_if_fail (clock != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (clock, SpaV4l2Source, clock); - state = &this->state[0]; + this = SPA_CONTAINER_OF (clock, struct impl, clock); + state = &this->out_ports[0]; if (rate) *rate = SPA_USEC_PER_SEC; @@ -919,26 +917,26 @@ spa_v4l2_source_clock_get_time (SpaClock *clock, return SPA_RESULT_OK; } -static const SpaClock v4l2source_clock = { - sizeof (SpaClock), +static const struct spa_clock impl_clock = { + sizeof (struct spa_clock), NULL, SPA_CLOCK_STATE_STOPPED, - spa_v4l2_source_clock_get_props, - spa_v4l2_source_clock_set_props, - spa_v4l2_source_clock_get_time, + impl_clock_get_props, + impl_clock_set_props, + impl_clock_get_time, }; -static SpaResult -spa_v4l2_source_get_interface (SpaHandle *handle, +static int +impl_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaV4l2Source *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaV4l2Source *) handle; + this = (struct impl *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -950,30 +948,30 @@ spa_v4l2_source_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -v4l2_source_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { return SPA_RESULT_OK; } -static SpaResult -v4l2_source_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaV4l2Source *this; + struct impl *this; uint32_t i; const char *str; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_v4l2_source_get_interface; - handle->clear = v4l2_source_clear, + handle->get_interface = impl_get_interface; + handle->clear = impl_clear, - this = (SpaV4l2Source *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -981,33 +979,33 @@ v4l2_source_init (const SpaHandleFactory *factory, else if (strcmp (support[i].type, SPA_TYPE__Log) == 0) this->log = support[i].data; else if (strcmp (support[i].type, SPA_TYPE_LOOP__MainLoop) == 0) - this->state[0].main_loop = support[i].data; + this->out_ports[0].main_loop = support[i].data; else if (strcmp (support[i].type, SPA_TYPE_LOOP__DataLoop) == 0) - this->state[0].data_loop = support[i].data; + this->out_ports[0].data_loop = support[i].data; } if (this->map == NULL) { spa_log_error (this->log, "a type-map is needed"); return SPA_RESULT_ERROR; } - if (this->state[0].main_loop == NULL) { + if (this->out_ports[0].main_loop == NULL) { spa_log_error (this->log, "a main_loop is needed"); return SPA_RESULT_ERROR; } - if (this->state[0].data_loop == NULL) { + if (this->out_ports[0].data_loop == NULL) { spa_log_error (this->log, "a data_loop is needed"); return SPA_RESULT_ERROR; } init_type (&this->type, this->map); - this->node = v4l2source_node; - this->clock = v4l2source_clock; + this->node = impl_node; + this->clock = impl_clock; - reset_v4l2_source_props (&this->props); + reset_props (&this->props); - this->state[0].log = this->log; - this->state[0].info.flags = SPA_PORT_INFO_FLAG_LIVE; + this->out_ports[0].log = this->log; + this->out_ports[0].info.flags = SPA_PORT_INFO_FLAG_LIVE; - this->state[0].export_buf = true; + this->out_ports[0].export_buf = true; if (info && (str = spa_dict_lookup (info, "device.path"))) { strncpy (this->props.device, str, 63); @@ -1016,31 +1014,31 @@ v4l2_source_init (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -static const SpaInterfaceInfo v4l2_source_interfaces[] = +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Node, }, { SPA_TYPE__Clock, }, }; -static SpaResult -v4l2_source_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - if (index < 0 || index >= SPA_N_ELEMENTS (v4l2_source_interfaces)) + if (index < 0 || index >= SPA_N_ELEMENTS (impl_interfaces)) return SPA_RESULT_ENUM_END; - *info = &v4l2_source_interfaces[index]; + *info = &impl_interfaces[index]; return SPA_RESULT_OK; } -const SpaHandleFactory spa_v4l2_source_factory = -{ "v4l2-source", +const struct spa_handle_factory spa_v4l2_source_factory = +{ NAME, NULL, - sizeof (SpaV4l2Source), - v4l2_source_init, - v4l2_source_enum_interface_info, + sizeof (struct impl), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index 97e52a191..cd1d79dfa 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -9,7 +9,7 @@ #define CLEAR(x) memset(&(x), 0, sizeof(x)) -static void v4l2_on_fd_events (SpaSource *source); +static void v4l2_on_fd_events (struct spa_source *source); static int xioctl (int fd, int request, void *arg) @@ -24,11 +24,11 @@ xioctl (int fd, int request, void *arg) } static int -spa_v4l2_open (SpaV4l2Source *this) +spa_v4l2_open (struct impl *this) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; struct stat st; - SpaV4l2SourceProps *props = &this->props; + struct props *props = &this->props; if (state->opened) return 0; @@ -80,11 +80,11 @@ spa_v4l2_open (SpaV4l2Source *this) return 0; } -static SpaResult -spa_v4l2_buffer_recycle (SpaV4l2Source *this, uint32_t buffer_id) +static int +spa_v4l2_buffer_recycle (struct impl *this, uint32_t buffer_id) { - SpaV4l2State *state = &this->state[0]; - V4l2Buffer *b = &state->buffers[buffer_id]; + struct port *state = &this->out_ports[0]; + struct buffer *b = &state->buffers[buffer_id]; if (!b->outstanding) return SPA_RESULT_OK; @@ -98,10 +98,10 @@ spa_v4l2_buffer_recycle (SpaV4l2Source *this, uint32_t buffer_id) return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_clear_buffers (SpaV4l2Source *this) +static int +spa_v4l2_clear_buffers (struct impl *this) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; struct v4l2_requestbuffers reqbuf; int i; @@ -109,7 +109,7 @@ spa_v4l2_clear_buffers (SpaV4l2Source *this) return SPA_RESULT_OK; for (i = 0; i < state->n_buffers; i++) { - V4l2Buffer *b; + struct buffer *b; b = &state->buffers[i]; if (b->outstanding) { @@ -138,10 +138,10 @@ spa_v4l2_clear_buffers (SpaV4l2Source *this) return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_port_set_enabled (SpaV4l2Source *this, bool enabled) +static int +spa_v4l2_port_set_enabled (struct impl *this, bool enabled) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; if (state->source_enabled != enabled) { spa_log_info (state->log, "v4l2: enabled %d", enabled); state->source_enabled = enabled; @@ -154,9 +154,9 @@ spa_v4l2_port_set_enabled (SpaV4l2Source *this, bool enabled) } static int -spa_v4l2_close (SpaV4l2Source *this) +spa_v4l2_close (struct impl *this) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; if (!state->opened) return 0; @@ -177,63 +177,63 @@ spa_v4l2_close (SpaV4l2Source *this) return 0; } -typedef struct { +struct format_info { uint32_t fourcc; off_t format_offset; off_t media_type_offset; off_t media_subtype_offset; -} FormatInfo; +}; -#define VIDEO offsetof(Type, media_type.video) -#define IMAGE offsetof(Type, media_type.image) +#define VIDEO offsetof(struct type, media_type.video) +#define IMAGE offsetof(struct type, media_type.image) -#define RAW offsetof(Type, media_subtype.raw) +#define RAW offsetof(struct type, media_subtype.raw) -#define BAYER offsetof(Type, media_subtype_video.bayer) -#define MJPG offsetof(Type, media_subtype_video.mjpg) -#define JPEG offsetof(Type, media_subtype_video.jpeg) -#define DV offsetof(Type, media_subtype_video.dv) -#define MPEGTS offsetof(Type, media_subtype_video.mpegts) -#define H264 offsetof(Type, media_subtype_video.h264) -#define H263 offsetof(Type, media_subtype_video.h263) -#define MPEG1 offsetof(Type, media_subtype_video.mpeg1) -#define MPEG2 offsetof(Type, media_subtype_video.mpeg2) -#define MPEG4 offsetof(Type, media_subtype_video.mpeg4) -#define XVID offsetof(Type, media_subtype_video.xvid) -#define VC1 offsetof(Type, media_subtype_video.vc1) -#define VP8 offsetof(Type, media_subtype_video.vp8) +#define BAYER offsetof(struct type, media_subtype_video.bayer) +#define MJPG offsetof(struct type, media_subtype_video.mjpg) +#define JPEG offsetof(struct type, media_subtype_video.jpeg) +#define DV offsetof(struct type, media_subtype_video.dv) +#define MPEGTS offsetof(struct type, media_subtype_video.mpegts) +#define H264 offsetof(struct type, media_subtype_video.h264) +#define H263 offsetof(struct type, media_subtype_video.h263) +#define MPEG1 offsetof(struct type, media_subtype_video.mpeg1) +#define MPEG2 offsetof(struct type, media_subtype_video.mpeg2) +#define MPEG4 offsetof(struct type, media_subtype_video.mpeg4) +#define XVID offsetof(struct type, media_subtype_video.xvid) +#define VC1 offsetof(struct type, media_subtype_video.vc1) +#define VP8 offsetof(struct type, media_subtype_video.vp8) -#define FORMAT_UNKNOWN offsetof(Type, video_format.UNKNOWN) -#define FORMAT_ENCODED offsetof(Type, video_format.ENCODED) -#define FORMAT_RGB15 offsetof(Type, video_format.RGB15) -#define FORMAT_BGR15 offsetof(Type, video_format.BGR15) -#define FORMAT_RGB16 offsetof(Type, video_format.RGB16) -#define FORMAT_BGR offsetof(Type, video_format.BGR) -#define FORMAT_RGB offsetof(Type, video_format.RGB) -#define FORMAT_BGRA offsetof(Type, video_format.BGRA) -#define FORMAT_BGRx offsetof(Type, video_format.BGRx) -#define FORMAT_ARGB offsetof(Type, video_format.ARGB) -#define FORMAT_xRGB offsetof(Type, video_format.xRGB) -#define FORMAT_GRAY8 offsetof(Type, video_format.GRAY8) -#define FORMAT_GRAY16_LE offsetof(Type, video_format.GRAY16_LE) -#define FORMAT_GRAY16_BE offsetof(Type, video_format.GRAY16_BE) -#define FORMAT_YVU9 offsetof(Type, video_format.YVU9) -#define FORMAT_YV12 offsetof(Type, video_format.YV12) -#define FORMAT_YUY2 offsetof(Type, video_format.YUY2) -#define FORMAT_YVYU offsetof(Type, video_format.YVYU) -#define FORMAT_UYVY offsetof(Type, video_format.UYVY) -#define FORMAT_Y42B offsetof(Type, video_format.Y42B) -#define FORMAT_Y41B offsetof(Type, video_format.Y41B) -#define FORMAT_YUV9 offsetof(Type, video_format.YUV9) -#define FORMAT_I420 offsetof(Type, video_format.I420) -#define FORMAT_NV12 offsetof(Type, video_format.NV12) -#define FORMAT_NV12_64Z32 offsetof(Type, video_format.NV12_64Z32) -#define FORMAT_NV21 offsetof(Type, video_format.NV21) -#define FORMAT_NV16 offsetof(Type, video_format.NV16) -#define FORMAT_NV61 offsetof(Type, video_format.NV61) -#define FORMAT_NV24 offsetof(Type, video_format.NV24) +#define FORMAT_UNKNOWN offsetof(struct type, video_format.UNKNOWN) +#define FORMAT_ENCODED offsetof(struct type, video_format.ENCODED) +#define FORMAT_RGB15 offsetof(struct type, video_format.RGB15) +#define FORMAT_BGR15 offsetof(struct type, video_format.BGR15) +#define FORMAT_RGB16 offsetof(struct type, video_format.RGB16) +#define FORMAT_BGR offsetof(struct type, video_format.BGR) +#define FORMAT_RGB offsetof(struct type, video_format.RGB) +#define FORMAT_BGRA offsetof(struct type, video_format.BGRA) +#define FORMAT_BGRx offsetof(struct type, video_format.BGRx) +#define FORMAT_ARGB offsetof(struct type, video_format.ARGB) +#define FORMAT_xRGB offsetof(struct type, video_format.xRGB) +#define FORMAT_GRAY8 offsetof(struct type, video_format.GRAY8) +#define FORMAT_GRAY16_LE offsetof(struct type, video_format.GRAY16_LE) +#define FORMAT_GRAY16_BE offsetof(struct type, video_format.GRAY16_BE) +#define FORMAT_YVU9 offsetof(struct type, video_format.YVU9) +#define FORMAT_YV12 offsetof(struct type, video_format.YV12) +#define FORMAT_YUY2 offsetof(struct type, video_format.YUY2) +#define FORMAT_YVYU offsetof(struct type, video_format.YVYU) +#define FORMAT_UYVY offsetof(struct type, video_format.UYVY) +#define FORMAT_Y42B offsetof(struct type, video_format.Y42B) +#define FORMAT_Y41B offsetof(struct type, video_format.Y41B) +#define FORMAT_YUV9 offsetof(struct type, video_format.YUV9) +#define FORMAT_I420 offsetof(struct type, video_format.I420) +#define FORMAT_NV12 offsetof(struct type, video_format.NV12) +#define FORMAT_NV12_64Z32 offsetof(struct type, video_format.NV12_64Z32) +#define FORMAT_NV21 offsetof(struct type, video_format.NV21) +#define FORMAT_NV16 offsetof(struct type, video_format.NV16) +#define FORMAT_NV61 offsetof(struct type, video_format.NV61) +#define FORMAT_NV24 offsetof(struct type, video_format.NV24) -static const FormatInfo format_info[] = +static const struct format_info format_info[] = { /* RGB formats */ { V4L2_PIX_FMT_RGB332, FORMAT_UNKNOWN, VIDEO, RAW }, @@ -342,7 +342,7 @@ static const FormatInfo format_info[] = { V4L2_PIX_FMT_PWC2, FORMAT_UNKNOWN, VIDEO, RAW }, }; -static const FormatInfo * +static const struct format_info * fourcc_to_format_info (uint32_t fourcc) { int i; @@ -355,8 +355,8 @@ fourcc_to_format_info (uint32_t fourcc) } #if 0 -static const FormatInfo * -video_format_to_format_info (SpaVideoFormat format) +static const struct format_info * +video_format_to_format_info (uint32_t format) { int i; @@ -368,8 +368,8 @@ video_format_to_format_info (SpaVideoFormat format) } #endif -static const FormatInfo * -find_format_info_by_media_type (Type *types, +static const struct format_info * +find_format_info_by_media_type (struct type *types, uint32_t type, uint32_t subtype, uint32_t format, @@ -393,14 +393,14 @@ find_format_info_by_media_type (Type *types, } static uint32_t -enum_filter_format (Type *type, const SpaFormat *filter, uint32_t index) +enum_filter_format (struct type *type, const struct spa_format *filter, uint32_t index) { uint32_t video_format = 0; if ((filter->body.media_type.value == type->media_type.video || filter->body.media_type.value == type->media_type.image)) { if (filter->body.media_subtype.value == type->media_subtype.raw) { - SpaPODProp *p; + struct spa_pod_prop *p; uint32_t n_values; const uint32_t *values; @@ -429,10 +429,10 @@ enum_filter_format (Type *type, const SpaFormat *filter, uint32_t index) } static bool -filter_framesize (struct v4l2_frmsizeenum *frmsize, - const SpaRectangle *min, - const SpaRectangle *max, - const SpaRectangle *step) +filter_framesize (struct v4l2_frmsizeenum *frmsize, + const struct spa_rectangle *min, + const struct spa_rectangle *max, + const struct spa_rectangle *step) { if (frmsize->type == V4L2_FRMSIZE_TYPE_DISCRETE) { if (frmsize->discrete.width < min->width || @@ -464,7 +464,7 @@ filter_framesize (struct v4l2_frmsizeenum *frmsize, } static int -compare_fraction (struct v4l2_fract *f1, const SpaFraction *f2) +compare_fraction (struct v4l2_fract *f1, const struct spa_fraction *f2) { uint64_t n1, n2; @@ -481,10 +481,10 @@ compare_fraction (struct v4l2_fract *f1, const SpaFraction *f2) } static bool -filter_framerate (struct v4l2_frmivalenum *frmival, - const SpaFraction *min, - const SpaFraction *max, - const SpaFraction *step) +filter_framerate (struct v4l2_frmivalenum *frmival, + const struct spa_fraction *min, + const struct spa_fraction *max, + const struct spa_fraction *step) { if (frmival->type == V4L2_FRMIVAL_TYPE_DISCRETE) { if (compare_fraction (&frmival->discrete, min) < 0 || @@ -516,18 +516,18 @@ filter_framerate (struct v4l2_frmivalenum *frmival, #define FOURCC_ARGS(f) (f)&0x7f,((f)>>8)&0x7f,((f)>>16)&0x7f,((f)>>24)&0x7f -static SpaResult -spa_v4l2_enum_format (SpaV4l2Source *this, - SpaFormat **format, - const SpaFormat *filter, +static int +spa_v4l2_enum_format (struct impl *this, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; int res, n_fractions; - const FormatInfo *info; - SpaPODFrame f[2]; - SpaPODProp *prop; - SpaPODBuilder b = { NULL, }; + const struct format_info *info; + struct spa_pod_frame f[2]; + struct spa_pod_prop *prop; + struct spa_pod_builder b = { NULL, }; uint32_t media_type, media_subtype, video_format; if (spa_v4l2_open (this) < 0) @@ -584,7 +584,7 @@ next_fmtdesc: next_frmsize: while (state->next_frmsize) { if (filter) { - SpaPODProp *p; + struct spa_pod_prop *p; /* check if we have a fixed frame size */ if (!(p = spa_format_find_prop (filter, this->type.format_video.size))) @@ -594,7 +594,7 @@ next_frmsize: return SPA_RESULT_ENUM_END; if (!(p->body.flags & SPA_POD_PROP_FLAG_UNSET)) { - const SpaRectangle *values = SPA_POD_BODY_CONST (&p->body.value); + const struct spa_rectangle *values = SPA_POD_BODY_CONST (&p->body.value); if (state->frmsize.index > 0) goto next_fmtdesc; @@ -614,8 +614,8 @@ do_frmsize: return SPA_RESULT_ENUM_END; } if (filter) { - SpaPODProp *p; - const SpaRectangle step = { 1, 1 }, *values; + struct spa_pod_prop *p; + const struct spa_rectangle step = { 1, 1 }, *values; uint32_t range; uint32_t i, n_values; @@ -697,7 +697,7 @@ have_size: SPA_POD_PROP_RANGE_NONE | SPA_POD_PROP_FLAG_UNSET); - prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, SpaPODProp); + prop = SPA_POD_BUILDER_DEREF (&b, f[1].ref, struct spa_pod_prop); n_fractions = 0; state->frmival.index = 0; @@ -715,10 +715,10 @@ have_size: return SPA_RESULT_ENUM_END; } if (filter) { - SpaPODProp *p; + struct spa_pod_prop *p; uint32_t range; uint32_t i, n_values; - const SpaFraction step = { 1, 1 }, *values; + const struct spa_fraction step = { 1, 1 }, *values; if (!(p = spa_format_find_prop (filter, this->type.format_video.framerate))) goto have_framerate; @@ -798,22 +798,22 @@ have_framerate: spa_pod_builder_pop (&b, &f[1]); spa_pod_builder_pop (&b, &f[0]); - *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); return SPA_RESULT_OK; } static int -spa_v4l2_set_format (SpaV4l2Source *this, SpaVideoInfo *format, bool try_only) +spa_v4l2_set_format (struct impl *this, struct spa_video_info *format, bool try_only) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; int cmd; struct v4l2_format reqfmt, fmt; struct v4l2_streamparm streamparm; - const FormatInfo *info = NULL; + const struct format_info *info = NULL; uint32_t video_format; - SpaRectangle *size = NULL; - SpaFraction *framerate = NULL; + struct spa_rectangle *size = NULL; + struct spa_fraction *framerate = NULL; CLEAR (fmt); CLEAR (streamparm); @@ -906,15 +906,15 @@ spa_v4l2_set_format (SpaV4l2Source *this, SpaVideoInfo *format, bool try_only) return 0; } -static SpaResult -mmap_read (SpaV4l2Source *this) +static int +mmap_read (struct impl *this) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; struct v4l2_buffer buf; - V4l2Buffer *b; - SpaData *d; + struct buffer *b; + struct spa_data *d; int64_t pts; - SpaPortIO *io = state->io; + struct spa_port_io *io = state->io; CLEAR(buf); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; @@ -962,9 +962,9 @@ mmap_read (SpaV4l2Source *this) } static void -v4l2_on_fd_events (SpaSource *source) +v4l2_on_fd_events (struct spa_source *source) { - SpaV4l2Source *this = source->data; + struct impl *this = source->data; if (source->rmask & SPA_IO_ERR) return; @@ -976,16 +976,16 @@ v4l2_on_fd_events (SpaSource *source) return; } -static SpaResult -spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffers) +static int +spa_v4l2_use_buffers (struct impl *this, struct spa_buffer **buffers, uint32_t n_buffers) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; struct v4l2_requestbuffers reqbuf; int i; - SpaData *d; + struct spa_data *d; if (n_buffers > 0) { - SpaData *d = buffers[0]->datas; + d = buffers[0]->datas; if ((d[0].type == this->type.data.MemPtr || d[0].type == this->type.data.MemFd) && @@ -1017,7 +1017,7 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe } for (i = 0; i < reqbuf.count; i++) { - V4l2Buffer *b; + struct buffer *b; b = &state->buffers[i]; b->outbuf = buffers[i]; @@ -1053,14 +1053,14 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe return SPA_RESULT_OK; } -static SpaResult -mmap_init (SpaV4l2Source *this, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +mmap_init (struct impl *this, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; struct v4l2_requestbuffers reqbuf; int i; @@ -1087,8 +1087,8 @@ mmap_init (SpaV4l2Source *this, spa_log_info (state->log, "v4l2: using EXPBUF"); for (i = 0; i < reqbuf.count; i++) { - V4l2Buffer *b; - SpaData *d; + struct buffer *b; + struct spa_data *d; if (buffers[i]->n_datas < 1) { spa_log_error (state->log, "v4l2: invalid buffer data"); @@ -1153,27 +1153,27 @@ mmap_init (SpaV4l2Source *this, return SPA_RESULT_OK; } -static SpaResult -userptr_init (SpaV4l2Source *this) +static int +userptr_init (struct impl *this) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -read_init (SpaV4l2Source *this) +static int +read_init (struct impl *this) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_v4l2_alloc_buffers (SpaV4l2Source *this, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +spa_v4l2_alloc_buffers (struct impl *this, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { - SpaResult res; - SpaV4l2State *state = &this->state[0]; + int res; + struct port *state = &this->out_ports[0]; if (state->n_buffers > 0) return SPA_RESULT_ERROR; @@ -1191,10 +1191,10 @@ spa_v4l2_alloc_buffers (SpaV4l2Source *this, return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_stream_on (SpaV4l2Source *this) +static int +spa_v4l2_stream_on (struct impl *this) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; enum v4l2_buf_type type; if (state->started) @@ -1210,10 +1210,10 @@ spa_v4l2_stream_on (SpaV4l2Source *this) return SPA_RESULT_OK; } -static SpaResult -spa_v4l2_stream_off (SpaV4l2Source *this) +static int +spa_v4l2_stream_off (struct impl *this) { - SpaV4l2State *state = &this->state[0]; + struct port *state = &this->out_ports[0]; enum v4l2_buf_type type; int i; @@ -1228,7 +1228,7 @@ spa_v4l2_stream_off (SpaV4l2Source *this) return SPA_RESULT_ERROR; } for (i = 0; i < state->n_buffers; i++) { - V4l2Buffer *b; + struct buffer *b; b = &state->buffers[i]; if (!b->outstanding) diff --git a/spa/plugins/v4l2/v4l2.c b/spa/plugins/v4l2/v4l2.c index 7997df0ac..8bcbc7a56 100644 --- a/spa/plugins/v4l2/v4l2.c +++ b/spa/plugins/v4l2/v4l2.c @@ -20,24 +20,25 @@ #include #include -extern const SpaHandleFactory spa_v4l2_source_factory; -extern const SpaHandleFactory spa_v4l2_monitor_factory; +extern const struct spa_handle_factory spa_v4l2_source_factory; +extern const struct spa_handle_factory spa_v4l2_monitor_factory; -SpaResult -spa_enum_handle_factory (const SpaHandleFactory **factory, - uint32_t index) +int +spa_handle_factory_enum(const struct spa_handle_factory **factory, + uint32_t index) { - spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); + spa_return_val_if_fail(factory != NULL, + SPA_RESULT_INVALID_ARGUMENTS); - switch (index) { - case 0: - *factory = &spa_v4l2_source_factory; - break; - case 1: - *factory = &spa_v4l2_monitor_factory; - break; - default: - return SPA_RESULT_ENUM_END; - } - return SPA_RESULT_OK; + switch (index) { + case 0: + *factory = &spa_v4l2_source_factory; + break; + case 1: + *factory = &spa_v4l2_monitor_factory; + break; + default: + return SPA_RESULT_ENUM_END; + } + return SPA_RESULT_OK; } diff --git a/spa/plugins/videotestsrc/draw.c b/spa/plugins/videotestsrc/draw.c index 300809b67..d4707d8b2 100644 --- a/spa/plugins/videotestsrc/draw.c +++ b/spa/plugins/videotestsrc/draw.c @@ -136,13 +136,13 @@ draw_pixel_uyvy (DrawingData *dd, int x, Pixel *color) } } -static SpaResult +static int drawing_data_init (DrawingData *dd, - SpaVideoTestSrc *this, + struct impl *this, char* data) { - SpaVideoInfo *format = &this->current_format; - SpaRectangle *size = &format->info.raw.size; + struct spa_video_info *format = &this->current_format; + struct spa_rectangle *size = &format->info.raw.size; if ((format->media_type != this->type.media_type.video) || (format->media_subtype != this->type.media_subtype.raw)) @@ -276,11 +276,11 @@ draw_snow (DrawingData *dd) } } -static SpaResult -draw (SpaVideoTestSrc *this, char *data) +static int +draw (struct impl *this, char *data) { DrawingData dd; - SpaResult res; + int res; uint32_t pattern; init_colors (); diff --git a/spa/plugins/videotestsrc/plugin.c b/spa/plugins/videotestsrc/plugin.c index 8006361b0..9caabc8d2 100644 --- a/spa/plugins/videotestsrc/plugin.c +++ b/spa/plugins/videotestsrc/plugin.c @@ -20,20 +20,21 @@ #include #include -extern const SpaHandleFactory spa_videotestsrc_factory; +extern const struct spa_handle_factory spa_videotestsrc_factory; -SpaResult -spa_enum_handle_factory (const SpaHandleFactory **factory, - uint32_t index) +int +spa_handle_factory_enum(const struct spa_handle_factory **factory, + uint32_t index) { - spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); + spa_return_val_if_fail(factory != NULL, + SPA_RESULT_INVALID_ARGUMENTS); - switch (index) { - case 0: - *factory = &spa_videotestsrc_factory; - break; - default: - return SPA_RESULT_ENUM_END; - } - return SPA_RESULT_OK; + switch (index) { + case 0: + *factory = &spa_videotestsrc_factory; + break; + default: + return SPA_RESULT_ENUM_END; + } + return SPA_RESULT_OK; } diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index 9d353b8b6..14216a075 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -35,10 +35,12 @@ #include #include +#define NAME "videotestsrc" + #define FRAMES_TO_TIME(this,f) ((this->current_format.info.raw.framerate.denom * (f) * SPA_NSEC_PER_SEC) / \ (this->current_format.info.raw.framerate.num)) -typedef struct { +struct type { uint32_t node; uint32_t clock; uint32_t format; @@ -47,20 +49,20 @@ typedef struct { uint32_t prop_pattern; uint32_t pattern_smpte_snow; uint32_t pattern_snow; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatVideo format_video; - SpaTypeVideoFormat video_format; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; - SpaTypeParamAllocBuffers param_alloc_buffers; - SpaTypeParamAllocMetaEnable param_alloc_meta_enable; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_video format_video; + struct spa_type_video_format video_format; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; + struct spa_type_param_alloc_buffers param_alloc_buffers; + struct spa_type_param_alloc_meta_enable param_alloc_meta_enable; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->clock = spa_type_map_get_id (map, SPA_TYPE__Clock); @@ -82,55 +84,51 @@ init_type (Type *type, SpaTypeMap *map) spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable); } -typedef struct _SpaVideoTestSrc SpaVideoTestSrc; - -typedef struct { +struct props { bool live; uint32_t pattern; -} SpaVideoTestSrcProps; +}; #define MAX_BUFFERS 16 #define MAX_PORTS 1 -typedef struct _VTSBuffer VTSBuffer; - -struct _VTSBuffer { - SpaBuffer *outbuf; +struct buffer { + struct spa_buffer *outbuf; bool outstanding; - SpaMetaHeader *h; - SpaList link; + struct spa_meta_header *h; + struct spa_list link; }; -struct _SpaVideoTestSrc { - SpaHandle handle; - SpaNode node; - SpaClock clock; +struct impl { + struct spa_handle handle; + struct spa_node node; + struct spa_clock clock; - Type type; - SpaTypeMap *map; - SpaLog *log; - SpaLoop *data_loop; + struct type type; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop *data_loop; uint8_t props_buffer[512]; - SpaVideoTestSrcProps props; + struct props props; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; - SpaSource timer_source; + struct spa_source timer_source; struct itimerspec timerspec; - SpaPortInfo info; + struct spa_port_info info; uint8_t params_buffer[1024]; - SpaPortIO *io; + struct spa_port_io *io; bool have_format; - SpaVideoInfo current_format; + struct spa_video_info current_format; uint8_t format_buffer[1024]; size_t bpp; int stride; - VTSBuffer buffers[MAX_BUFFERS]; + struct buffer buffers[MAX_BUFFERS]; uint32_t n_buffers; bool started; @@ -138,7 +136,7 @@ struct _SpaVideoTestSrc { uint64_t elapsed_time; uint64_t frame_count; - SpaList empty; + struct spa_list empty; }; #define CHECK_PORT_NUM(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) < MAX_PORTS) @@ -148,7 +146,7 @@ struct _SpaVideoTestSrc { #define DEFAULT_PATTERN pattern_smpte_snow static void -reset_videotestsrc_props (SpaVideoTestSrc *this, SpaVideoTestSrcProps *props) +reset_props (struct impl *this, struct props *props) { props->live = DEFAULT_LIVE; props->pattern = this->type. DEFAULT_PATTERN; @@ -167,18 +165,18 @@ reset_videotestsrc_props (SpaVideoTestSrc *this, SpaVideoTestSrcProps *props) SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \ SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__) -static SpaResult -spa_videotestsrc_node_get_props (SpaNode *node, - SpaProps **props) +static int +impl_node_get_props (struct spa_node *node, + struct spa_props **props) { - SpaVideoTestSrc *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_props (&b, &f[0], this->type.props, @@ -188,23 +186,23 @@ spa_videotestsrc_node_get_props (SpaNode *node, this->type.pattern_smpte_snow, this->type.pattern_snow)); - *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_set_props (SpaNode *node, - const SpaProps *props) +static int +impl_node_set_props (struct spa_node *node, + const struct spa_props *props) { - SpaVideoTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (props == NULL) { - reset_videotestsrc_props (this, &this->props); + reset_props (this, &this->props); } else { spa_props_query (props, this->type.prop_live, SPA_POD_TYPE_BOOL, &this->props.live, @@ -222,14 +220,14 @@ spa_videotestsrc_node_set_props (SpaNode *node, #include "draw.c" -static SpaResult -fill_buffer (SpaVideoTestSrc *this, VTSBuffer *b) +static int +fill_buffer (struct impl *this, struct buffer *b) { return draw (this, b->outbuf->datas[0].data); } static void -set_timer (SpaVideoTestSrc *this, bool enabled) +set_timer (struct impl *this, bool enabled) { if (this->callbacks.have_output || this->props.live) { if (enabled) { @@ -250,7 +248,7 @@ set_timer (SpaVideoTestSrc *this, bool enabled) } static void -read_timer (SpaVideoTestSrc *this) +read_timer (struct impl *this) { uint64_t expirations; @@ -260,27 +258,27 @@ read_timer (SpaVideoTestSrc *this) } } -static SpaResult -videotestsrc_make_buffer (SpaVideoTestSrc *this) +static int +make_buffer (struct impl *this) { - VTSBuffer *b; - SpaPortIO *io = this->io; + struct buffer *b; + struct spa_port_io *io = this->io; int n_bytes; read_timer (this); if (spa_list_is_empty (&this->empty)) { set_timer (this, false); - spa_log_error (this->log, "videotestsrc %p: out of buffers", this); + spa_log_error (this->log, NAME " %p: out of buffers", this); return SPA_RESULT_OUT_OF_BUFFERS; } - b = spa_list_first (&this->empty, VTSBuffer, link); + b = spa_list_first (&this->empty, struct buffer, link); spa_list_remove (&b->link); b->outstanding = true; n_bytes = b->outbuf->datas[0].maxsize; - spa_log_trace (this->log, "videotestsrc %p: dequeue buffer %d", this, b->outbuf->id); + spa_log_trace (this->log, NAME " %p: dequeue buffer %d", this, b->outbuf->id); fill_buffer (this, b); @@ -305,27 +303,27 @@ videotestsrc_make_buffer (SpaVideoTestSrc *this) } static void -videotestsrc_on_output (SpaSource *source) +impl_on_output (struct spa_source *source) { - SpaVideoTestSrc *this = source->data; - SpaResult res; + struct impl *this = source->data; + int res; - res = videotestsrc_make_buffer (this); + res = make_buffer (this); if (res == SPA_RESULT_HAVE_BUFFER) this->callbacks.have_output (&this->node, this->user_data); } -static SpaResult -spa_videotestsrc_node_send_command (SpaNode *node, - SpaCommand *command) +static int +impl_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaVideoTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { struct timespec now; @@ -369,17 +367,17 @@ spa_videotestsrc_node_send_command (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +impl_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaVideoTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (this->data_loop == NULL && callbacks->have_output != NULL) { spa_log_error (this->log, "a data_loop is needed for async operation"); @@ -391,8 +389,8 @@ spa_videotestsrc_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_get_n_ports (SpaNode *node, +static int +impl_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -412,8 +410,8 @@ spa_videotestsrc_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_get_port_ids (SpaNode *node, +static int +impl_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -427,42 +425,42 @@ spa_videotestsrc_node_get_port_ids (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_add_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_videotestsrc_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_videotestsrc_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - SpaVideoTestSrc *this; - SpaResult res; - SpaFormat *fmt; + struct impl *this; + int res; + struct spa_format *fmt; uint8_t buffer[1024]; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; uint32_t count, match; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -491,23 +489,23 @@ next: default: return SPA_RESULT_ENUM_END; } - fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer)); if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK || match++ != index) goto next; - *format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, 0, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -clear_buffers (SpaVideoTestSrc *this) +static int +clear_buffers (struct impl *this) { if (this->n_buffers > 0) { - spa_log_info (this->log, "videotestsrc %p: clear buffers", this); + spa_log_info (this->log, NAME " %p: clear buffers", this); this->n_buffers = 0; spa_list_init (&this->empty); this->started = false; @@ -516,18 +514,18 @@ clear_buffers (SpaVideoTestSrc *this) return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaVideoTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -535,8 +533,8 @@ spa_videotestsrc_node_port_set_format (SpaNode *node, this->have_format = false; clear_buffers (this); } else { - SpaVideoInfo info = { SPA_FORMAT_MEDIA_TYPE (format), - SPA_FORMAT_MEDIA_SUBTYPE (format), }; + struct spa_video_info info = { SPA_FORMAT_MEDIA_TYPE (format), + SPA_FORMAT_MEDIA_SUBTYPE (format), }; if (info.media_type != this->type.media_type.video && info.media_subtype != this->type.media_subtype.raw) @@ -559,27 +557,27 @@ spa_videotestsrc_node_port_set_format (SpaNode *node, } if (this->have_format) { - SpaVideoInfoRaw *raw_info = &this->current_format.info.raw; + struct spa_video_info_raw *raw_info = &this->current_format.info.raw; this->stride = SPA_ROUND_UP_N (this->bpp * raw_info->size.width, 4); } return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaVideoTestSrc *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -592,23 +590,23 @@ spa_videotestsrc_node_port_get_format (SpaNode *node, PROP (&f[1], this->type.format_video.format, SPA_POD_TYPE_ID, this->current_format.info.raw.format), PROP (&f[1], this->type.format_video.size, -SPA_POD_TYPE_RECTANGLE, &this->current_format.info.raw.size), PROP (&f[1], this->type.format_video.framerate, -SPA_POD_TYPE_FRACTION, &this->current_format.info.raw.framerate)); - *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaVideoTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -617,21 +615,21 @@ spa_videotestsrc_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { - SpaVideoTestSrc *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (param != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -640,7 +638,7 @@ spa_videotestsrc_node_port_enum_params (SpaNode *node, switch (index) { case 0: { - SpaVideoInfoRaw *raw_info = &this->current_format.info.raw; + struct spa_video_info_raw *raw_info = &this->current_format.info.raw; spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_buffers.Buffers, PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, this->stride * raw_info->size.height), @@ -652,40 +650,40 @@ spa_videotestsrc_node_port_enum_params (SpaNode *node, case 1: spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header), - PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); + PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); break; default: return SPA_RESULT_NOT_IMPLEMENTED; } - *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_videotestsrc_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +impl_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { - SpaVideoTestSrc *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -695,8 +693,8 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node, clear_buffers (this); for (i = 0; i < n_buffers; i++) { - VTSBuffer *b; - SpaData *d = buffers[i]->datas; + struct buffer *b; + struct spa_data *d = buffers[i]->datas; b = &this->buffers[i]; b->outbuf = buffers[i]; @@ -707,7 +705,7 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node, d[0].type == this->type.data.MemFd || d[0].type == this->type.data.DmaBuf) && d[0].data == NULL) { - spa_log_error (this->log, "videotestsrc %p: invalid memory on buffer %p", this, buffers[i]); + spa_log_error (this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); } spa_list_insert (this->empty.prev, &b->link); } @@ -716,20 +714,20 @@ spa_videotestsrc_node_port_use_buffers (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +impl_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { - SpaVideoTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -739,17 +737,17 @@ spa_videotestsrc_node_port_alloc_buffers (SpaNode *node, return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_videotestsrc_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaVideoTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT_NUM (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -759,12 +757,12 @@ spa_videotestsrc_node_port_set_io (SpaNode *node, } static inline void -reuse_buffer (SpaVideoTestSrc *this, uint32_t id) +reuse_buffer (struct impl *this, uint32_t id) { - VTSBuffer *b = &this->buffers[id]; + struct buffer *b = &this->buffers[id]; spa_return_if_fail (b->outstanding); - spa_log_trace (this->log, "videotestsrc %p: reuse buffer %d", this, id); + spa_log_trace (this->log, NAME " %p: reuse buffer %d", this, id); b->outstanding = false; spa_list_insert (this->empty.prev, &b->link); @@ -773,16 +771,16 @@ reuse_buffer (SpaVideoTestSrc *this, uint32_t id) set_timer (this, true); } -static SpaResult -spa_videotestsrc_node_port_reuse_buffer (SpaNode *node, +static int +impl_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { - SpaVideoTestSrc *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (port_id == 0, SPA_RESULT_INVALID_PORT); spa_return_val_if_fail (this->n_buffers > 0, SPA_RESULT_NO_BUFFERS); @@ -793,30 +791,30 @@ spa_videotestsrc_node_port_reuse_buffer (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_videotestsrc_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +impl_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_videotestsrc_node_process_input (SpaNode *node) +static int +impl_node_process_input (struct spa_node *node) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_videotestsrc_node_process_output (SpaNode *node) +static int +impl_node_process_output (struct spa_node *node) { - SpaVideoTestSrc *this; - SpaPortIO *io; + struct impl *this; + struct spa_port_io *io; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); + this = SPA_CONTAINER_OF (node, struct impl, node); io = this->io; spa_return_val_if_fail (io != NULL, SPA_RESULT_WRONG_STATE); @@ -829,53 +827,53 @@ spa_videotestsrc_node_process_output (SpaNode *node) } if (!this->callbacks.have_output && (io->status == SPA_RESULT_NEED_BUFFER)) - return videotestsrc_make_buffer (this); + return make_buffer (this); else return SPA_RESULT_OK; } -static const SpaNode videotestsrc_node = { - sizeof (SpaNode), +static const struct spa_node impl_node = { + sizeof (struct spa_node), NULL, - spa_videotestsrc_node_get_props, - spa_videotestsrc_node_set_props, - spa_videotestsrc_node_send_command, - spa_videotestsrc_node_set_callbacks, - spa_videotestsrc_node_get_n_ports, - spa_videotestsrc_node_get_port_ids, - spa_videotestsrc_node_add_port, - spa_videotestsrc_node_remove_port, - spa_videotestsrc_node_port_enum_formats, - spa_videotestsrc_node_port_set_format, - spa_videotestsrc_node_port_get_format, - spa_videotestsrc_node_port_get_info, - spa_videotestsrc_node_port_enum_params, - spa_videotestsrc_node_port_set_param, - spa_videotestsrc_node_port_use_buffers, - spa_videotestsrc_node_port_alloc_buffers, - spa_videotestsrc_node_port_set_io, - spa_videotestsrc_node_port_reuse_buffer, - spa_videotestsrc_node_port_send_command, - spa_videotestsrc_node_process_input, - spa_videotestsrc_node_process_output, + impl_node_get_props, + impl_node_set_props, + impl_node_send_command, + impl_node_set_callbacks, + impl_node_get_n_ports, + impl_node_get_port_ids, + impl_node_add_port, + impl_node_remove_port, + impl_node_port_enum_formats, + impl_node_port_set_format, + impl_node_port_get_format, + impl_node_port_get_info, + impl_node_port_enum_params, + impl_node_port_set_param, + impl_node_port_use_buffers, + impl_node_port_alloc_buffers, + impl_node_port_set_io, + impl_node_port_reuse_buffer, + impl_node_port_send_command, + impl_node_process_input, + impl_node_process_output, }; -static SpaResult -spa_videotestsrc_clock_get_props (SpaClock *clock, - SpaProps **props) +static int +impl_clock_get_props (struct spa_clock *clock, + struct spa_props **props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_videotestsrc_clock_set_props (SpaClock *clock, - const SpaProps *props) +static int +impl_clock_set_props (struct spa_clock *clock, + const struct spa_props *props) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_videotestsrc_clock_get_time (SpaClock *clock, +static int +impl_clock_get_time (struct spa_clock *clock, int32_t *rate, int64_t *ticks, int64_t *monotonic_time) @@ -899,26 +897,26 @@ spa_videotestsrc_clock_get_time (SpaClock *clock, return SPA_RESULT_OK; } -static const SpaClock videotestsrc_clock = { - sizeof (SpaClock), +static const struct spa_clock impl_clock = { + sizeof (struct spa_clock), NULL, SPA_CLOCK_STATE_STOPPED, - spa_videotestsrc_clock_get_props, - spa_videotestsrc_clock_set_props, - spa_videotestsrc_clock_get_time, + impl_clock_get_props, + impl_clock_set_props, + impl_clock_get_time, }; -static SpaResult -spa_videotestsrc_get_interface (SpaHandle *handle, +static int +impl_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaVideoTestSrc *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaVideoTestSrc *) handle; + this = (struct impl *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -930,14 +928,14 @@ spa_videotestsrc_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -videotestsrc_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { - SpaVideoTestSrc *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaVideoTestSrc *) handle; + this = (struct impl *) handle; if (this->data_loop) spa_loop_remove_source (this->data_loop, &this->timer_source); @@ -946,23 +944,23 @@ videotestsrc_clear (SpaHandle *handle) return SPA_RESULT_OK; } -static SpaResult -videotestsrc_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaVideoTestSrc *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_videotestsrc_get_interface; - handle->clear = videotestsrc_clear; + handle->get_interface = impl_get_interface; + handle->clear = impl_clear; - this = (SpaVideoTestSrc *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -978,13 +976,13 @@ videotestsrc_init (const SpaHandleFactory *factory, } init_type (&this->type, this->map); - this->node = videotestsrc_node; - this->clock = videotestsrc_clock; - reset_videotestsrc_props (this, &this->props); + this->node = impl_node; + this->clock = impl_clock; + reset_props (this, &this->props); spa_list_init (&this->empty); - this->timer_source.func = videotestsrc_on_output; + this->timer_source.func = impl_on_output; this->timer_source.data = this; this->timer_source.fd = timerfd_create (CLOCK_MONOTONIC, TFD_CLOEXEC); this->timer_source.mask = SPA_IO_IN; @@ -1002,20 +1000,20 @@ videotestsrc_init (const SpaHandleFactory *factory, if (this->props.live) this->info.flags |= SPA_PORT_INFO_FLAG_LIVE; - spa_log_info (this->log, "videotestsrc %p: initialized", this); + spa_log_info (this->log, NAME " %p: initialized", this); return SPA_RESULT_OK; } -static const SpaInterfaceInfo videotestsrc_interfaces[] = +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Node, }, { SPA_TYPE__Clock, }, }; -static SpaResult -videotestsrc_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -1023,7 +1021,7 @@ videotestsrc_enum_interface_info (const SpaHandleFactory *factory, switch (index) { case 0: - *info = &videotestsrc_interfaces[index]; + *info = &impl_interfaces[index]; break; default: return SPA_RESULT_ENUM_END; @@ -1031,10 +1029,10 @@ videotestsrc_enum_interface_info (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -const SpaHandleFactory spa_videotestsrc_factory = -{ "videotestsrc", +const struct spa_handle_factory spa_videotestsrc_factory = +{ NAME, NULL, - sizeof (SpaVideoTestSrc), - videotestsrc_init, - videotestsrc_enum_interface_info, + sizeof (struct impl), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/volume/plugin.c b/spa/plugins/volume/plugin.c index 471e64203..6d40e0dcb 100644 --- a/spa/plugins/volume/plugin.c +++ b/spa/plugins/volume/plugin.c @@ -20,20 +20,21 @@ #include #include -extern const SpaHandleFactory spa_volume_factory; +extern const struct spa_handle_factory spa_volume_factory; -SpaResult -spa_enum_handle_factory (const SpaHandleFactory **factory, - uint32_t index) +int +spa_handle_factory_enum(const struct spa_handle_factory **factory, + uint32_t index) { - spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); + spa_return_val_if_fail(factory != NULL, + SPA_RESULT_INVALID_ARGUMENTS); - switch (index) { - case 0: - *factory = &spa_volume_factory; - break; - default: - return SPA_RESULT_ENUM_END; - } - return SPA_RESULT_OK; + switch (index) { + case 0: + *factory = &spa_volume_factory; + break; + default: + return SPA_RESULT_ENUM_END; + } + return SPA_RESULT_OK; } diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index ace79a749..77ef0b31c 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -29,57 +29,57 @@ #include #include +#define NAME "volume" + #define MAX_BUFFERS 16 -typedef struct _SpaVolume SpaVolume; - -typedef struct { +struct props { double volume; bool mute; -} SpaVolumeProps; +}; -typedef struct { - SpaBuffer *outbuf; - bool outstanding; - SpaMetaHeader *h; - void *ptr; - size_t size; - SpaList link; -} SpaVolumeBuffer; +struct buffer { + struct spa_buffer *outbuf; + bool outstanding; + struct spa_meta_header *h; + void *ptr; + size_t size; + struct spa_list link; +}; -typedef struct { +struct port { bool have_format; - SpaPortInfo info; + struct spa_port_info info; uint8_t params_buffer[1024]; - SpaVolumeBuffer buffers[MAX_BUFFERS]; + struct buffer buffers[MAX_BUFFERS]; uint32_t n_buffers; - SpaPortIO *io; + struct spa_port_io *io; - SpaList empty; -} SpaVolumePort; + struct spa_list empty; +}; -typedef struct { +struct type { uint32_t node; uint32_t format; uint32_t props; uint32_t prop_volume; uint32_t prop_mute; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatAudio format_audio; - SpaTypeAudioFormat audio_format; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; - SpaTypeParamAllocBuffers param_alloc_buffers; - SpaTypeParamAllocMetaEnable param_alloc_meta_enable; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_audio format_audio; + struct spa_type_audio_format audio_format; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; + struct spa_type_param_alloc_buffers param_alloc_buffers; + struct spa_type_param_alloc_meta_enable param_alloc_meta_enable; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->format = spa_type_map_get_id (map, SPA_TYPE__Format); @@ -98,25 +98,25 @@ init_type (Type *type, SpaTypeMap *map) spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable); } -struct _SpaVolume { - SpaHandle handle; - SpaNode node; +struct impl { + struct spa_handle handle; + struct spa_node node; - Type type; - SpaTypeMap *map; - SpaLog *log; + struct type type; + struct spa_type_map *map; + struct spa_log *log; uint8_t props_buffer[512]; - SpaVolumeProps props; + struct props props; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; uint8_t format_buffer[1024]; - SpaAudioInfo current_format; + struct spa_audio_info current_format; - SpaVolumePort in_ports[1]; - SpaVolumePort out_ports[1]; + struct port in_ports[1]; + struct port out_ports[1]; bool started; }; @@ -129,7 +129,7 @@ struct _SpaVolume { #define DEFAULT_MUTE false static void -reset_volume_props (SpaVolumeProps *props) +reset_props (struct props *props) { props->volume = DEFAULT_VOLUME; props->mute = DEFAULT_MUTE; @@ -147,41 +147,41 @@ reset_volume_props (SpaVolumeProps *props) SPA_POD_PROP_RANGE_ENUM,type,n,__VA_ARGS__) -static SpaResult -spa_volume_node_get_props (SpaNode *node, - SpaProps **props) +static int +impl_node_get_props (struct spa_node *node, + struct spa_props **props) { - SpaVolume *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (props != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_props (&b, &f[0], this->type.props, PROP_MM (&f[1], this->type.prop_volume, SPA_POD_TYPE_DOUBLE, this->props.volume, 0.0, 10.0), PROP (&f[1], this->type.prop_mute, SPA_POD_TYPE_BOOL, this->props.mute)); - *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_set_props (SpaNode *node, - const SpaProps *props) +static int +impl_node_set_props (struct spa_node *node, + const struct spa_props *props) { - SpaVolume *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (props == NULL) { - reset_volume_props (&this->props); + reset_props (&this->props); } else { spa_props_query (props, this->type.prop_volume, SPA_POD_TYPE_DOUBLE, &this->props.volume, @@ -191,16 +191,16 @@ spa_volume_node_set_props (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_send_command (SpaNode *node, - SpaCommand *command) +static int +impl_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaVolume *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (command != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { this->started = true; @@ -214,17 +214,17 @@ spa_volume_node_send_command (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +impl_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaVolume *this; + struct impl *this; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); this->callbacks = *callbacks; this->user_data = user_data; @@ -232,8 +232,8 @@ spa_volume_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_get_n_ports (SpaNode *node, +static int +impl_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -253,8 +253,8 @@ spa_volume_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_get_port_ids (SpaNode *node, +static int +impl_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -271,42 +271,42 @@ spa_volume_node_get_port_ids (SpaNode *node, } -static SpaResult -spa_volume_node_add_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_volume_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +impl_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_volume_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - SpaVolume *this; - SpaResult res; - SpaFormat *fmt; + struct impl *this; + int res; + struct spa_format *fmt; uint8_t buffer[1024]; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; uint32_t count, match; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -330,41 +330,41 @@ next: default: return SPA_RESULT_ENUM_END; } - fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + fmt = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); spa_pod_builder_init (&b, this->format_buffer, sizeof (this->format_buffer)); if ((res = spa_format_filter (fmt, filter, &b)) != SPA_RESULT_OK || match++ != index) goto next; - *format = SPA_POD_BUILDER_DEREF (&b, 0, SpaFormat); + *format = SPA_POD_BUILDER_DEREF (&b, 0, struct spa_format); return SPA_RESULT_OK; } -static SpaResult -clear_buffers (SpaVolume *this, SpaVolumePort *port) +static int +clear_buffers (struct impl *this, struct port *port) { if (port->n_buffers > 0) { - spa_log_info (this->log, "volume %p: clear buffers", this); + spa_log_info (this->log, NAME " %p: clear buffers", this); port->n_buffers = 0; spa_list_init (&port->empty); } return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaVolume *this; - SpaVolumePort *port; + struct impl *this; + struct port *port; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -374,8 +374,8 @@ spa_volume_node_port_set_format (SpaNode *node, port->have_format = false; clear_buffers (this, port); } else { - SpaAudioInfo info = { SPA_FORMAT_MEDIA_TYPE (format), - SPA_FORMAT_MEDIA_SUBTYPE (format), }; + struct spa_audio_info info = { SPA_FORMAT_MEDIA_TYPE (format), + SPA_FORMAT_MEDIA_SUBTYPE (format), }; if (info.media_type != this->type.media_type.audio || info.media_subtype != this->type.media_subtype.raw) @@ -391,19 +391,19 @@ spa_volume_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaVolume *this; - SpaVolumePort *port; + struct impl *this; + struct port *port; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (format != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -417,19 +417,19 @@ spa_volume_node_port_get_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaVolume *this; - SpaVolumePort *port; + struct impl *this; + struct port *port; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (info != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -439,22 +439,22 @@ spa_volume_node_port_get_info (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { - SpaPODBuilder b = { NULL }; - SpaPODFrame f[2]; - SpaVolume *this; - SpaVolumePort *port; + struct spa_pod_builder b = { NULL }; + struct spa_pod_frame f[2]; + struct impl *this; + struct port *port; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (param != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -474,41 +474,41 @@ spa_volume_node_port_enum_params (SpaNode *node, case 1: spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable, PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header), - PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); + PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (struct spa_meta_header))); break; default: return SPA_RESULT_NOT_IMPLEMENTED; } - *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam); + *param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_param); return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_volume_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +impl_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { - SpaVolume *this; - SpaVolumePort *port; + struct impl *this; + struct port *port; uint32_t i; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -520,8 +520,8 @@ spa_volume_node_port_use_buffers (SpaNode *node, clear_buffers (this, port); for (i = 0; i < n_buffers; i++) { - SpaVolumeBuffer *b; - SpaData *d = buffers[i]->datas; + struct buffer *b; + struct spa_data *d = buffers[i]->datas; b = &port->buffers[i]; b->outbuf = buffers[i]; @@ -536,7 +536,7 @@ spa_volume_node_port_use_buffers (SpaNode *node, b->size = d[0].maxsize; } else { - spa_log_error (this->log, "volume %p: invalid memory on buffer %p", this, buffers[i]); + spa_log_error (this->log, NAME " %p: invalid memory on buffer %p", this, buffers[i]); return SPA_RESULT_ERROR; } spa_list_insert (port->empty.prev, &b->link); @@ -546,30 +546,30 @@ spa_volume_node_port_use_buffers (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +impl_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_volume_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +impl_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaVolume *this; - SpaVolumePort *port; + struct impl *this; + struct port *port; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT); @@ -580,32 +580,32 @@ spa_volume_node_port_set_io (SpaNode *node, } static void -recycle_buffer (SpaVolume *this, uint32_t id) +recycle_buffer (struct impl *this, uint32_t id) { - SpaVolumePort *port = &this->out_ports[0]; - SpaVolumeBuffer *b = &port->buffers[id]; + struct port *port = &this->out_ports[0]; + struct buffer *b = &port->buffers[id]; if (!b->outstanding) { - spa_log_warn (this->log, "volume %p: buffer %d not outstanding", this, id); + spa_log_warn (this->log, NAME " %p: buffer %d not outstanding", this, id); return; } spa_list_insert (port->empty.prev, &b->link); b->outstanding = false; - spa_log_trace (this->log, "volume %p: recycle buffer %d", this, id); + spa_log_trace (this->log, NAME " %p: recycle buffer %d", this, id); } -static SpaResult -spa_volume_node_port_reuse_buffer (SpaNode *node, +static int +impl_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { - SpaVolume *this; - SpaVolumePort *port; + struct impl *this; + struct port *port; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_return_val_if_fail (CHECK_PORT (this, SPA_DIRECTION_OUTPUT, port_id), SPA_RESULT_INVALID_PORT); @@ -622,24 +622,24 @@ spa_volume_node_port_reuse_buffer (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_volume_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +impl_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaBuffer * -find_free_buffer (SpaVolume *this, SpaVolumePort *port) +static struct spa_buffer * +find_free_buffer (struct impl *this, struct port *port) { - SpaVolumeBuffer *b; + struct buffer *b; if (spa_list_is_empty (&port->empty)) return NULL; - b = spa_list_first (&port->empty, SpaVolumeBuffer, link); + b = spa_list_first (&port->empty, struct buffer, link); spa_list_remove (&b->link); b->outstanding = true; @@ -647,17 +647,17 @@ find_free_buffer (SpaVolume *this, SpaVolumePort *port) } static inline void -release_buffer (SpaVolume *this, SpaBuffer *buffer) +release_buffer (struct impl *this, struct spa_buffer *buffer) { if (this->callbacks.reuse_buffer) this->callbacks.reuse_buffer (&this->node, 0, buffer->id, this->user_data); } static void -do_volume (SpaVolume *this, SpaBuffer *dbuf, SpaBuffer *sbuf) +do_volume (struct impl *this, struct spa_buffer *dbuf, struct spa_buffer *sbuf) { uint32_t si, di, i, n_samples, n_bytes, soff, doff ; - SpaData *sd, *dd; + struct spa_data *sd, *dd; uint16_t *src, *dst; double volume; @@ -696,18 +696,18 @@ do_volume (SpaVolume *this, SpaBuffer *dbuf, SpaBuffer *sbuf) } } -static SpaResult -spa_volume_node_process_input (SpaNode *node) +static int +impl_node_process_input (struct spa_node *node) { - SpaVolume *this; - SpaPortIO *input; - SpaPortIO *output; - SpaVolumePort *in_port, *out_port; - SpaBuffer *dbuf, *sbuf; + struct impl *this; + struct spa_port_io *input; + struct spa_port_io *output; + struct port *in_port, *out_port; + struct spa_buffer *dbuf, *sbuf; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); out_port = &this->out_ports[0]; output = out_port->io; @@ -735,16 +735,16 @@ spa_volume_node_process_input (SpaNode *node) return SPA_RESULT_HAVE_BUFFER; } -static SpaResult -spa_volume_node_process_output (SpaNode *node) +static int +impl_node_process_output (struct spa_node *node) { - SpaVolume *this; - SpaVolumePort *in_port, *out_port; - SpaPortIO *input, *output; + struct impl *this; + struct port *in_port, *out_port; + struct spa_port_io *input, *output; spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = SPA_CONTAINER_OF (node, SpaVolume, node); + this = SPA_CONTAINER_OF (node, struct impl, node); out_port = &this->out_ports[0]; output = out_port->io; @@ -769,43 +769,43 @@ spa_volume_node_process_output (SpaNode *node) return SPA_RESULT_NEED_BUFFER; } -static const SpaNode volume_node = { - sizeof (SpaNode), +static const struct spa_node impl_node = { + sizeof (struct spa_node), NULL, - spa_volume_node_get_props, - spa_volume_node_set_props, - spa_volume_node_send_command, - spa_volume_node_set_callbacks, - spa_volume_node_get_n_ports, - spa_volume_node_get_port_ids, - spa_volume_node_add_port, - spa_volume_node_remove_port, - spa_volume_node_port_enum_formats, - spa_volume_node_port_set_format, - spa_volume_node_port_get_format, - spa_volume_node_port_get_info, - spa_volume_node_port_enum_params, - spa_volume_node_port_set_param, - spa_volume_node_port_use_buffers, - spa_volume_node_port_alloc_buffers, - spa_volume_node_port_set_io, - spa_volume_node_port_reuse_buffer, - spa_volume_node_port_send_command, - spa_volume_node_process_input, - spa_volume_node_process_output, + impl_node_get_props, + impl_node_set_props, + impl_node_send_command, + impl_node_set_callbacks, + impl_node_get_n_ports, + impl_node_get_port_ids, + impl_node_add_port, + impl_node_remove_port, + impl_node_port_enum_formats, + impl_node_port_set_format, + impl_node_port_get_format, + impl_node_port_get_info, + impl_node_port_enum_params, + impl_node_port_set_param, + impl_node_port_use_buffers, + impl_node_port_alloc_buffers, + impl_node_port_set_io, + impl_node_port_reuse_buffer, + impl_node_port_send_command, + impl_node_process_input, + impl_node_process_output, }; -static SpaResult -spa_volume_get_interface (SpaHandle *handle, +static int +impl_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaVolume *this; + struct impl *this; spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (interface != NULL, SPA_RESULT_INVALID_ARGUMENTS); - this = (SpaVolume *) handle; + this = (struct impl *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -815,29 +815,29 @@ spa_volume_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -volume_clear (SpaHandle *handle) +static int +impl_clear (struct spa_handle *handle) { return SPA_RESULT_OK; } -static SpaResult -volume_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +impl_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaVolume *this; + struct impl *this; uint32_t i; spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (handle != NULL, SPA_RESULT_INVALID_ARGUMENTS); - handle->get_interface = spa_volume_get_interface; - handle->clear = volume_clear; + handle->get_interface = impl_get_interface; + handle->clear = impl_clear; - this = (SpaVolume *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -851,8 +851,8 @@ volume_init (const SpaHandleFactory *factory, } init_type (&this->type, this->map); - this->node = volume_node; - reset_volume_props (&this->props); + this->node = impl_node; + reset_props (&this->props); this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_IN_PLACE; @@ -865,14 +865,14 @@ volume_init (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -static const SpaInterfaceInfo volume_interfaces[] = +static const struct spa_interface_info impl_interfaces[] = { { SPA_TYPE__Node, }, }; -static SpaResult -volume_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +impl_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { spa_return_val_if_fail (factory != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -880,7 +880,7 @@ volume_enum_interface_info (const SpaHandleFactory *factory, switch (index) { case 0: - *info = &volume_interfaces[index]; + *info = &impl_interfaces[index]; break; default: return SPA_RESULT_ENUM_END; @@ -888,10 +888,10 @@ volume_enum_interface_info (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -const SpaHandleFactory spa_volume_factory = -{ "volume", +const struct spa_handle_factory spa_volume_factory = +{ NAME, NULL, - sizeof (SpaVolume), - volume_init, - volume_enum_interface_info, + sizeof (struct impl), + impl_init, + impl_enum_interface_info, }; diff --git a/spa/plugins/xv/xv-sink.c b/spa/plugins/xv/xv-sink.c index f7f6b1f3d..adfdf8171 100644 --- a/spa/plugins/xv/xv-sink.c +++ b/spa/plugins/xv/xv-sink.c @@ -22,67 +22,67 @@ #include #include -#include - #include #include +#include #include #include #include -typedef struct _SpaXvSink SpaXvSink; - static const char default_device[] = "/dev/video0"; -typedef struct { +struct props { char device[64]; char device_name[128]; int device_fd; -} SpaXvSinkProps; +}; static void -reset_xv_sink_props (SpaXvSinkProps *props) +reset_props (struct props *props) { strncpy (props->device, default_device, 64); } -#define MAX_BUFFERS 256 +#define MAX_BUFFERS 32 -typedef struct _XvBuffer XvBuffer; - -struct _XvBuffer { - SpaBuffer buffer; - SpaMeta meta[1]; - SpaMetaHeader header; - SpaData data[1]; - XvBuffer *next; - uint32_t index; - SpaXvSink *sink; +struct buffer { + struct spa_buffer buffer; + struct spa_meta meta[1]; + struct spa_meta_header header; + struct spa_data data[1]; + struct spa_list link; bool outstanding; }; -typedef struct { +struct port { bool opened; int fd; - XvBuffer buffers[MAX_BUFFERS]; - XvBuffer *ready; - uint32_t ready_count; -} SpaXvState; -typedef struct { + struct spa_port_io *io; + + bool have_format; + uint8_t format_buffer[1024]; + struct spa_video_info current_format; + struct spa_port_info info; + + struct buffer buffers[MAX_BUFFERS]; + struct spa_list ready; +}; + +struct type { uint32_t node; uint32_t props; uint32_t prop_device; uint32_t prop_device_name; uint32_t prop_device_fd; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatVideo format_video; - SpaTypeCommandNode command_node; -} Type; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_video format_video; + struct spa_type_command_node command_node; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->props = spa_type_map_get_id (map, SPA_TYPE__Props); @@ -95,31 +95,24 @@ init_type (Type *type, SpaTypeMap *map) spa_type_command_node_map (map, &type->command_node); } -struct _SpaXvSink { - SpaHandle handle; - SpaNode node; +struct impl { + struct spa_handle handle; + struct spa_node node; - Type type; - SpaTypeMap *map; - SpaLog *log; + struct type type; + struct spa_type_map *map; + struct spa_log *log; uint8_t props_buffer[512]; - SpaXvSinkProps props; + struct props props; - SpaNodeCallbacks callbacks; + struct spa_node_callbacks callbacks; void *user_data; - bool have_format; - uint8_t format_buffer[1024]; - SpaVideoInfo current_format; - - SpaPortInfo info; - SpaXvState state; - - SpaPortIO *io; + struct port in_ports[1]; }; -#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0) +#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_INPUT && (p) == 0) #include "xv-utils.c" @@ -128,42 +121,42 @@ struct _SpaXvSink { #define PROP_R(f,key,type,...) \ SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_READONLY,type,1,__VA_ARGS__) -static SpaResult -spa_xv_sink_node_get_props (SpaNode *node, - SpaProps **props) +static int +spa_xv_sink_node_get_props (struct spa_node *node, + struct spa_props **props) { - SpaXvSink *this; - SpaPODBuilder b = { NULL, }; - SpaPODFrame f[2]; + struct impl *this; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame f[2]; if (node == NULL || props == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaXvSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); spa_pod_builder_init (&b, this->props_buffer, sizeof (this->props_buffer)); spa_pod_builder_props (&b, &f[0], this->type.props, PROP (&f[1], this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device)), PROP_R (&f[1], this->type.prop_device_name, -SPA_POD_TYPE_STRING, this->props.device_name, sizeof (this->props.device_name)), PROP_R (&f[1], this->type.prop_device_fd, SPA_POD_TYPE_INT, this->props.device_fd)); - *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + *props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); return SPA_RESULT_OK; } -static SpaResult -spa_xv_sink_node_set_props (SpaNode *node, - const SpaProps *props) +static int +spa_xv_sink_node_set_props (struct spa_node *node, + const struct spa_props *props) { - SpaXvSink *this; + struct impl *this; if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaXvSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (props == NULL) { - reset_xv_sink_props (&this->props); + reset_props (&this->props); } else { spa_props_query (props, this->type.prop_device, -SPA_POD_TYPE_STRING, this->props.device, sizeof (this->props.device), @@ -172,16 +165,16 @@ spa_xv_sink_node_set_props (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_xv_sink_node_send_command (SpaNode *node, - SpaCommand *command) +static int +spa_xv_sink_node_send_command (struct spa_node *node, + struct spa_command *command) { - SpaXvSink *this; + struct impl *this; if (node == NULL || command == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaXvSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (SPA_COMMAND_TYPE (command) == this->type.command_node.Start) { spa_xv_start (this); @@ -195,18 +188,18 @@ spa_xv_sink_node_send_command (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_xv_sink_node_set_callbacks (SpaNode *node, - const SpaNodeCallbacks *callbacks, +static int +spa_xv_sink_node_set_callbacks (struct spa_node *node, + const struct spa_node_callbacks *callbacks, size_t callbacks_size, void *user_data) { - SpaXvSink *this; + struct impl *this; if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaXvSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); this->callbacks = *callbacks; this->user_data = user_data; @@ -214,8 +207,8 @@ spa_xv_sink_node_set_callbacks (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_xv_sink_node_get_n_ports (SpaNode *node, +static int +spa_xv_sink_node_get_n_ports (struct spa_node *node, uint32_t *n_input_ports, uint32_t *max_input_ports, uint32_t *n_output_ports, @@ -236,8 +229,8 @@ spa_xv_sink_node_get_n_ports (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_xv_sink_node_get_port_ids (SpaNode *node, +static int +spa_xv_sink_node_get_port_ids (struct spa_node *node, uint32_t n_input_ports, uint32_t *input_ids, uint32_t n_output_ports, @@ -253,36 +246,36 @@ spa_xv_sink_node_get_port_ids (SpaNode *node, } -static SpaResult -spa_xv_sink_node_add_port (SpaNode *node, - SpaDirection direction, +static int +spa_xv_sink_node_add_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_xv_sink_node_remove_port (SpaNode *node, - SpaDirection direction, +static int +spa_xv_sink_node_remove_port (struct spa_node *node, + enum spa_direction direction, uint32_t port_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_xv_sink_node_port_enum_formats (SpaNode *node, - SpaDirection direction, +static int +spa_xv_sink_node_port_enum_formats (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaFormat **format, - const SpaFormat *filter, + struct spa_format **format, + const struct spa_format *filter, uint32_t index) { - //SpaXvSink *this; + //struct impl *this; if (node == NULL || format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - //this = SPA_CONTAINER_OF (node, SpaXvSink, node); + //this = SPA_CONTAINER_OF (node, struct impl, node); if (!CHECK_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; @@ -298,29 +291,32 @@ spa_xv_sink_node_port_enum_formats (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_xv_sink_node_port_set_format (SpaNode *node, - SpaDirection direction, +static int +spa_xv_sink_node_port_set_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t flags, - const SpaFormat *format) + const struct spa_format *format) { - SpaXvSink *this; + struct impl *this; + struct port *port; if (node == NULL || format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaXvSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!CHECK_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; + port = &this->in_ports[0]; + if (format == NULL) { - this->have_format = false; + port->have_format = false; return SPA_RESULT_OK; } else { - SpaVideoInfo info = { SPA_FORMAT_MEDIA_TYPE (format), - SPA_FORMAT_MEDIA_SUBTYPE (format), }; + struct spa_video_info info = { SPA_FORMAT_MEDIA_TYPE (format), + SPA_FORMAT_MEDIA_SUBTYPE (format), }; if (info.media_type != this->type.media_type.video && @@ -334,31 +330,34 @@ spa_xv_sink_node_port_set_format (SpaNode *node, return SPA_RESULT_INVALID_MEDIA_TYPE; if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) { - this->current_format = info; - this->have_format = true; + port->current_format = info; + port->have_format = true; } } return SPA_RESULT_OK; } -static SpaResult -spa_xv_sink_node_port_get_format (SpaNode *node, - SpaDirection direction, +static int +spa_xv_sink_node_port_get_format (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaFormat **format) + const struct spa_format **format) { - SpaXvSink *this; + struct impl *this; + struct port *port; if (node == NULL || format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaXvSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!CHECK_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; - if (!this->have_format) + port = &this->in_ports[0]; + + if (!port->have_format) return SPA_RESULT_NO_FORMAT; *format = NULL; @@ -366,120 +365,125 @@ spa_xv_sink_node_port_get_format (SpaNode *node, return SPA_RESULT_OK; } -static SpaResult -spa_xv_sink_node_port_get_info (SpaNode *node, - SpaDirection direction, +static int +spa_xv_sink_node_port_get_info (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaPortInfo **info) + const struct spa_port_info **info) { - SpaXvSink *this; + struct impl *this; + struct port *port; if (node == NULL || info == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaXvSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!CHECK_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; - *info = &this->info; + port = &this->in_ports[0]; + + *info = &port->info; return SPA_RESULT_OK; } -static SpaResult -spa_xv_sink_node_port_enum_params (SpaNode *node, - SpaDirection direction, +static int +spa_xv_sink_node_port_enum_params (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, uint32_t index, - SpaParam **param) + struct spa_param **param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_xv_sink_node_port_set_param (SpaNode *node, - SpaDirection direction, +static int +spa_xv_sink_node_port_set_param (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - const SpaParam *param) + const struct spa_param *param) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_xv_sink_node_port_use_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaBuffer **buffers, - uint32_t n_buffers) +static int +spa_xv_sink_node_port_use_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_buffer **buffers, + uint32_t n_buffers) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_xv_sink_node_port_alloc_buffers (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaParam **params, - uint32_t n_params, - SpaBuffer **buffers, - uint32_t *n_buffers) +static int +spa_xv_sink_node_port_alloc_buffers (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_param **params, + uint32_t n_params, + struct spa_buffer **buffers, + uint32_t *n_buffers) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_xv_sink_node_port_set_io (SpaNode *node, - SpaDirection direction, +static int +spa_xv_sink_node_port_set_io (struct spa_node *node, + enum spa_direction direction, uint32_t port_id, - SpaPortIO *io) + struct spa_port_io *io) { - SpaXvSink *this; + struct impl *this; + struct port *port; if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = SPA_CONTAINER_OF (node, SpaXvSink, node); + this = SPA_CONTAINER_OF (node, struct impl, node); if (!CHECK_PORT (this, direction, port_id)) return SPA_RESULT_INVALID_PORT; - this->io = io; + port = &this->in_ports[0]; + port->io = io; return SPA_RESULT_OK; } -static SpaResult -spa_xv_sink_node_port_reuse_buffer (SpaNode *node, +static int +spa_xv_sink_node_port_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_xv_sink_node_port_send_command (SpaNode *node, - SpaDirection direction, - uint32_t port_id, - SpaCommand *command) +static int +spa_xv_sink_node_port_send_command (struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + struct spa_command *command) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_xv_sink_node_process_input (SpaNode *node) +static int +spa_xv_sink_node_process_input (struct spa_node *node) { return SPA_RESULT_NOT_IMPLEMENTED; } -static SpaResult -spa_xv_sink_node_process_output (SpaNode *node) +static int +spa_xv_sink_node_process_output (struct spa_node *node) { return SPA_RESULT_INVALID_PORT; } -static const SpaNode xvsink_node = { - sizeof (SpaNode), +static const struct spa_node xvsink_node = { + sizeof (struct spa_node), NULL, spa_xv_sink_node_get_props, spa_xv_sink_node_set_props, @@ -504,17 +508,17 @@ static const SpaNode xvsink_node = { spa_xv_sink_node_process_output, }; -static SpaResult -spa_xv_sink_get_interface (SpaHandle *handle, +static int +spa_xv_sink_get_interface (struct spa_handle *handle, uint32_t interface_id, void **interface) { - SpaXvSink *this; + struct impl *this; if (handle == NULL || interface == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - this = (SpaXvSink *) handle; + this = (struct impl *) handle; if (interface_id == this->type.node) *interface = &this->node; @@ -524,20 +528,20 @@ spa_xv_sink_get_interface (SpaHandle *handle, return SPA_RESULT_OK; } -static SpaResult -xv_sink_clear (SpaHandle *handle) +static int +xv_sink_clear (struct spa_handle *handle) { return SPA_RESULT_OK; } -static SpaResult -xv_sink_init (const SpaHandleFactory *factory, - SpaHandle *handle, - const SpaDict *info, - const SpaSupport *support, +static int +xv_sink_init (const struct spa_handle_factory *factory, + struct spa_handle *handle, + const struct spa_dict *info, + const struct spa_support *support, uint32_t n_support) { - SpaXvSink *this; + struct impl *this; uint32_t i; if (factory == NULL || handle == NULL) @@ -546,7 +550,7 @@ xv_sink_init (const SpaHandleFactory *factory, handle->get_interface = spa_xv_sink_get_interface; handle->clear = xv_sink_clear; - this = (SpaXvSink *) handle; + this = (struct impl *) handle; for (i = 0; i < n_support; i++) { if (strcmp (support[i].type, SPA_TYPE__TypeMap) == 0) @@ -561,21 +565,21 @@ xv_sink_init (const SpaHandleFactory *factory, init_type (&this->type, this->map); this->node = xvsink_node; - reset_xv_sink_props (&this->props); + reset_props (&this->props); - this->info.flags = 0; + this->in_ports[0].info.flags = 0; return SPA_RESULT_OK; } -static const SpaInterfaceInfo xv_sink_interfaces[] = +static const struct spa_interface_info xv_sink_interfaces[] = { { SPA_TYPE__Node, }, }; -static SpaResult -xv_sink_enum_interface_info (const SpaHandleFactory *factory, - const SpaInterfaceInfo **info, +static int +xv_sink_enum_interface_info (const struct spa_handle_factory *factory, + const struct spa_interface_info **info, uint32_t index) { if (factory == NULL || info == NULL) @@ -591,10 +595,11 @@ xv_sink_enum_interface_info (const SpaHandleFactory *factory, return SPA_RESULT_OK; } -const SpaHandleFactory spa_xv_sink_factory = -{ "xv-sink", +const struct spa_handle_factory spa_xv_sink_factory = +{ + "xv-sink", NULL, - sizeof (SpaXvSink), + sizeof (struct impl), xv_sink_init, xv_sink_enum_interface_info, }; diff --git a/spa/plugins/xv/xv-utils.c b/spa/plugins/xv/xv-utils.c index e2b882d96..dc536d85e 100644 --- a/spa/plugins/xv/xv-utils.c +++ b/spa/plugins/xv/xv-utils.c @@ -10,20 +10,20 @@ #define CLEAR(x) memset(&(x), 0, sizeof(x)) static int -spa_xv_open (SpaXvSink *this) +spa_xv_open (struct impl *this) { - SpaXvState *state = &this->state; + struct port *port = &this->in_ports[0]; - if (state->opened) + if (port->opened) return 0; - state->opened = true; + port->opened = true; return 0; } static int -spa_xv_set_format (SpaXvSink *this, SpaVideoInfo *info, bool try_only) +spa_xv_set_format (struct impl *this, struct spa_video_info *info, bool try_only) { if (spa_xv_open (this) < 0) return -1; @@ -32,20 +32,20 @@ spa_xv_set_format (SpaXvSink *this, SpaVideoInfo *info, bool try_only) } static int -spa_xv_close (SpaXvSink *this) +spa_xv_close (struct impl *this) { - SpaXvState *state = &this->state; + struct port *port = &this->in_ports[0]; - if (!state->opened) + if (!port->opened) return 0; - state->opened = false; + port->opened = false; return 0; } static int -spa_xv_start (SpaXvSink *this) +spa_xv_start (struct impl *this) { if (spa_xv_open (this) < 0) return -1; @@ -54,7 +54,7 @@ spa_xv_start (SpaXvSink *this) } static int -spa_xv_stop (SpaXvSink *this) +spa_xv_stop (struct impl *this) { spa_xv_close (this); diff --git a/spa/plugins/xv/xv.c b/spa/plugins/xv/xv.c index b8242e498..68e73ec38 100644 --- a/spa/plugins/xv/xv.c +++ b/spa/plugins/xv/xv.c @@ -20,21 +20,21 @@ #include #include -extern const SpaHandleFactory spa_xv_sink_factory; +extern const struct spa_handle_factory spa_xv_sink_factory; -SpaResult -spa_enum_handle_factory (const SpaHandleFactory **factory, - uint32_t index) +int +spa_handle_factory_enum(const struct spa_handle_factory **factory, + uint32_t index) { - if (factory == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; + spa_return_val_if_fail(factory != NULL, + SPA_RESULT_INVALID_ARGUMENTS); - switch (index) { - case 0: - *factory = &spa_xv_sink_factory; - break; - default: - return SPA_RESULT_ENUM_END; - } - return SPA_RESULT_OK; + switch (index) { + case 0: + *factory = &spa_xv_sink_factory; + break; + default: + return SPA_RESULT_ENUM_END; + } + return SPA_RESULT_OK; } diff --git a/spa/tests/stress-ringbuffer.c b/spa/tests/stress-ringbuffer.c index f7e69f583..6f0a1388a 100644 --- a/spa/tests/stress-ringbuffer.c +++ b/spa/tests/stress-ringbuffer.c @@ -9,7 +9,7 @@ #define ARRAY_SIZE 64 #define MAX_VALUE 0x10000 -SpaRingbuffer rb; +struct spa_ringbuffer rb; uint8_t *data; static int diff --git a/spa/tests/test-graph.c b/spa/tests/test-graph.c index c94227a5d..ca737698a 100644 --- a/spa/tests/test-graph.c +++ b/spa/tests/test-graph.c @@ -39,7 +39,7 @@ #include #include -typedef struct { +struct type { uint32_t node; uint32_t props; uint32_t format; @@ -48,18 +48,18 @@ typedef struct { uint32_t props_volume; uint32_t props_min_latency; uint32_t props_live; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatAudio format_audio; - SpaTypeAudioFormat audio_format; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_audio format_audio; + struct spa_type_audio_format audio_format; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->props = spa_type_map_get_id (map, SPA_TYPE__Props); @@ -79,66 +79,66 @@ init_type (Type *type, SpaTypeMap *map) spa_type_command_node_map (map, &type->command_node); } -typedef struct { - SpaBuffer buffer; - SpaMeta metas[1]; - SpaMetaHeader header; - SpaData datas[1]; - SpaChunk chunks[1]; -} Buffer; +struct buffer { + struct spa_buffer buffer; + struct spa_meta metas[1]; + struct spa_meta_header header; + struct spa_data datas[1]; + struct spa_chunk chunks[1]; +}; -typedef struct { - SpaTypeMap *map; - SpaLog *log; - SpaLoop data_loop; - Type type; +struct data { + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop data_loop; + struct type type; - SpaSupport support[4]; + struct spa_support support[4]; uint32_t n_support; - SpaGraph graph; - SpaGraphNode source_node; - SpaGraphPort source_out; - SpaGraphPort volume_in; - SpaGraphNode volume_node; - SpaGraphPort volume_out; - SpaGraphPort sink_in; - SpaGraphNode sink_node; + struct spa_graph graph; + struct spa_graph_node source_node; + struct spa_graph_port source_out; + struct spa_graph_port volume_in; + struct spa_graph_node volume_node; + struct spa_graph_port volume_out; + struct spa_graph_port sink_in; + struct spa_graph_node sink_node; - SpaNode *sink; - SpaPortIO volume_sink_io[1]; + struct spa_node *sink; + struct spa_port_io volume_sink_io[1]; - SpaNode *volume; - SpaBuffer *volume_buffers[1]; - Buffer volume_buffer[1]; + struct spa_node *volume; + struct spa_buffer *volume_buffers[1]; + struct buffer volume_buffer[1]; - SpaNode *source; - SpaPortIO source_volume_io[1]; - SpaBuffer *source_buffers[1]; - Buffer source_buffer[1]; + struct spa_node *source; + struct spa_port_io source_volume_io[1]; + struct spa_buffer *source_buffers[1]; + struct buffer source_buffer[1]; bool running; pthread_t thread; - SpaSource sources[16]; + struct spa_source sources[16]; unsigned int n_sources; bool rebuild_fds; struct pollfd fds[16]; unsigned int n_fds; -} AppData; +}; #define MIN_LATENCY 64 #define BUFFER_SIZE MIN_LATENCY static void -init_buffer (AppData *data, SpaBuffer **bufs, Buffer *ba, int n_buffers, size_t size) +init_buffer (struct data *data, struct spa_buffer **bufs, struct buffer *ba, int n_buffers, size_t size) { int i; for (i = 0; i < n_buffers; i++) { - Buffer *b = &ba[i]; + struct buffer *b = &ba[i]; bufs[i] = &b->buffer; b->buffer.id = i; @@ -168,13 +168,13 @@ init_buffer (AppData *data, SpaBuffer **bufs, Buffer *ba, int n_buffers, size_t } } -static SpaResult -make_node (AppData *data, SpaNode **node, const char *lib, const char *name) +static int +make_node (struct data *data, struct spa_node **node, const char *lib, const char *name) { - SpaHandle *handle; - SpaResult res; + struct spa_handle *handle; + int res; void *hnd; - SpaEnumHandleFactoryFunc enum_func; + spa_handle_factory_enum_func_t enum_func; unsigned int i; uint32_t state = 0; @@ -182,13 +182,13 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name) printf ("can't load %s: %s\n", lib, dlerror()); return SPA_RESULT_ERROR; } - if ((enum_func = dlsym (hnd, "spa_enum_handle_factory")) == NULL) { + if ((enum_func = dlsym (hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { printf ("can't find enum function\n"); return SPA_RESULT_ERROR; } for (i = 0; ;i++) { - const SpaHandleFactory *factory; + const struct spa_handle_factory *factory; void *iface; if ((res = enum_func (&factory, state++)) < 0) { @@ -215,15 +215,15 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name) } static void -on_sink_event (SpaNode *node, SpaEvent *event, void *user_data) +on_sink_event (struct spa_node *node, struct spa_event *event, void *user_data) { printf ("got event %d\n", SPA_EVENT_TYPE (event)); } static void -on_sink_need_input (SpaNode *node, void *user_data) +on_sink_need_input (struct spa_node *node, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; data->sink_node.action = SPA_GRAPH_ACTION_CHECK; data->sink_node.state = SPA_RESULT_NEED_BUFFER; @@ -232,14 +232,14 @@ on_sink_need_input (SpaNode *node, void *user_data) } static void -on_sink_reuse_buffer (SpaNode *node, uint32_t port_id, uint32_t buffer_id, void *user_data) +on_sink_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; data->volume_sink_io[0].buffer_id = buffer_id; } -static const SpaNodeCallbacks sink_callbacks = +static const struct spa_node_callbacks sink_callbacks = { &on_sink_event, &on_sink_need_input, @@ -247,11 +247,11 @@ static const SpaNodeCallbacks sink_callbacks = &on_sink_reuse_buffer }; -static SpaResult -do_add_source (SpaLoop *loop, - SpaSource *source) +static int +do_add_source (struct spa_loop *loop, + struct spa_source *source) { - AppData *data = SPA_CONTAINER_OF (loop, AppData, data_loop); + struct data *data = SPA_CONTAINER_OF (loop, struct data, data_loop); data->sources[data->n_sources] = *source; data->n_sources++; @@ -260,35 +260,35 @@ do_add_source (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -do_update_source (SpaSource *source) +static int +do_update_source (struct spa_source *source) { return SPA_RESULT_OK; } static void -do_remove_source (SpaSource *source) +do_remove_source (struct spa_source *source) { } -static SpaResult -do_invoke (SpaLoop *loop, - SpaInvokeFunc func, - uint32_t seq, - size_t size, - void *data, - void *user_data) +static int +do_invoke (struct spa_loop *loop, + spa_invoke_func_t func, + uint32_t seq, + size_t size, + void *data, + void *user_data) { return func (loop, false, seq, size, data, user_data); } -static SpaResult -make_nodes (AppData *data, const char *device) +static int +make_nodes (struct data *data, const char *device) { - SpaResult res; - SpaProps *props; - SpaPODBuilder b = { 0 }; - SpaPODFrame f[2]; + int res; + struct spa_props *props; + struct spa_pod_builder b = { 0 }; + struct spa_pod_frame f[2]; uint8_t buffer[128]; if ((res = make_node (data, &data->sink, @@ -303,7 +303,7 @@ make_nodes (AppData *data, const char *device) spa_pod_builder_props (&b, &f[0], data->type.props, SPA_POD_PROP (&f[1], data->type.props_device, 0, SPA_POD_TYPE_STRING, 1, device ? device : "hw:0"), SPA_POD_PROP (&f[1], data->type.props_min_latency, 0, SPA_POD_TYPE_INT, 1, MIN_LATENCY)); - props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); if ((res = spa_node_set_props (data->sink, props)) < 0) printf ("got set_props error %d\n", res); @@ -327,7 +327,7 @@ make_nodes (AppData *data, const char *device) SPA_POD_PROP (&f[1], data->type.props_freq, 0, SPA_POD_TYPE_DOUBLE, 1, 600.0), SPA_POD_PROP (&f[1], data->type.props_volume, 0, SPA_POD_TYPE_DOUBLE, 1, 0.5), SPA_POD_PROP (&f[1], data->type.props_live, 0, SPA_POD_TYPE_BOOL, 1, false)); - props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); if ((res = spa_node_set_props (data->source, props)) < 0) printf ("got set_props error %d\n", res); @@ -366,14 +366,14 @@ make_nodes (AppData *data, const char *device) return res; } -static SpaResult -negotiate_formats (AppData *data) +static int +negotiate_formats (struct data *data) { - SpaResult res; - SpaFormat *format, *filter; + int res; + struct spa_format *format, *filter; uint32_t state = 0; - SpaPODBuilder b = { 0 }; - SpaPODFrame f[2]; + struct spa_pod_builder b = { 0 }; + struct spa_pod_frame f[2]; uint8_t buffer[256]; spa_pod_builder_init (&b, buffer, sizeof (buffer)); @@ -391,7 +391,7 @@ negotiate_formats (AppData *data) SPA_POD_PROP (&f[1], data->type.format_audio.channels, 0, SPA_POD_TYPE_INT, 1, 2)); - filter = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + filter = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); if ((res = spa_node_port_enum_formats (data->sink, SPA_DIRECTION_INPUT, 0, &format, filter, state)) < 0) return res; @@ -426,7 +426,7 @@ negotiate_formats (AppData *data) static void * loop (void *user_data) { - AppData *data = user_data; + struct data *data = user_data; printf ("enter thread %d\n", data->n_sources); while (data->running) { @@ -435,7 +435,7 @@ loop (void *user_data) /* rebuild */ if (data->rebuild_fds) { for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; data->fds[i].fd = p->fd; data->fds[i].events = p->mask; } @@ -456,7 +456,7 @@ loop (void *user_data) /* after */ for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; p->rmask = 0; if (data->fds[i].revents & POLLIN) p->rmask |= SPA_IO_IN; @@ -468,7 +468,7 @@ loop (void *user_data) p->rmask |= SPA_IO_ERR; } for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; if (p->rmask) p->func (p); } @@ -479,13 +479,13 @@ loop (void *user_data) } static void -run_async_sink (AppData *data) +run_async_sink (struct data *data) { - SpaResult res; + int res; int err; { - SpaCommand cmd = SPA_COMMAND_INIT (data->type.command_node.Start); + struct spa_command cmd = SPA_COMMAND_INIT (data->type.command_node.Start); if ((res = spa_node_send_command (data->source, &cmd)) < 0) printf ("got source error %d\n", res); if ((res = spa_node_send_command (data->volume, &cmd)) < 0) @@ -509,7 +509,7 @@ run_async_sink (AppData *data) } { - SpaCommand cmd = SPA_COMMAND_INIT (data->type.command_node.Pause); + struct spa_command cmd = SPA_COMMAND_INIT (data->type.command_node.Pause); if ((res = spa_node_send_command (data->sink, &cmd)) < 0) printf ("got error %d\n", res); if ((res = spa_node_send_command (data->volume, &cmd)) < 0) @@ -522,8 +522,8 @@ run_async_sink (AppData *data) int main (int argc, char *argv[]) { - AppData data = { NULL }; - SpaResult res; + struct data data = { NULL }; + int res; const char *str; @@ -531,7 +531,7 @@ main (int argc, char *argv[]) data.map = spa_type_map_get_default(); data.log = spa_log_get_default(); - data.data_loop.size = sizeof (SpaLoop); + data.data_loop.size = sizeof (struct spa_loop); data.data_loop.add_source = do_add_source; data.data_loop.update_source = do_update_source; data.data_loop.remove_source = do_remove_source; diff --git a/spa/tests/test-mixer.c b/spa/tests/test-mixer.c index 0091a8185..bf573813f 100644 --- a/spa/tests/test-mixer.c +++ b/spa/tests/test-mixer.c @@ -40,7 +40,7 @@ #undef USE_GRAPH -typedef struct { +struct type { uint32_t node; uint32_t props; uint32_t format; @@ -49,18 +49,18 @@ typedef struct { uint32_t props_volume; uint32_t props_min_latency; uint32_t props_live; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatAudio format_audio; - SpaTypeAudioFormat audio_format; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_audio format_audio; + struct spa_type_audio_format audio_format; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->props = spa_type_map_get_id (map, SPA_TYPE__Props); @@ -80,62 +80,62 @@ init_type (Type *type, SpaTypeMap *map) spa_type_command_node_map (map, &type->command_node); } -typedef struct { - SpaBuffer buffer; - SpaMeta metas[1]; - SpaMetaHeader header; - SpaData datas[1]; - SpaChunk chunks[1]; -} Buffer; +struct buffer { + struct spa_buffer buffer; + struct spa_meta metas[1]; + struct spa_meta_header header; + struct spa_data datas[1]; + struct spa_chunk chunks[1]; +}; -typedef struct { - SpaTypeMap *map; - SpaLog *log; - SpaLoop data_loop; - Type type; +struct data { + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop data_loop; + struct type type; - SpaSupport support[4]; + struct spa_support support[4]; uint32_t n_support; - SpaGraph graph; - SpaGraphNode source1_node; - SpaGraphPort source1_out; - SpaGraphNode source2_node; - SpaGraphPort source2_out; - SpaGraphPort mix_in[2]; - SpaGraphNode mix_node; - SpaGraphPort mix_out; - SpaGraphPort sink_in; - SpaGraphNode sink_node; + struct spa_graph graph; + struct spa_graph_node source1_node; + struct spa_graph_port source1_out; + struct spa_graph_node source2_node; + struct spa_graph_port source2_out; + struct spa_graph_port mix_in[2]; + struct spa_graph_node mix_node; + struct spa_graph_port mix_out; + struct spa_graph_port sink_in; + struct spa_graph_node sink_node; - SpaNode *sink; - SpaPortIO mix_sink_io[1]; + struct spa_node *sink; + struct spa_port_io mix_sink_io[1]; - SpaNode *mix; + struct spa_node *mix; uint32_t mix_ports[2]; - SpaBuffer *mix_buffers[1]; - Buffer mix_buffer[1]; + struct spa_buffer *mix_buffers[1]; + struct buffer mix_buffer[1]; - SpaNode *source1; - SpaPortIO source1_mix_io[1]; - SpaBuffer *source1_buffers[2]; - Buffer source1_buffer[2]; + struct spa_node *source1; + struct spa_port_io source1_mix_io[1]; + struct spa_buffer *source1_buffers[2]; + struct buffer source1_buffer[2]; - SpaNode *source2; - SpaPortIO source2_mix_io[1]; - SpaBuffer *source2_buffers[2]; - Buffer source2_buffer[2]; + struct spa_node *source2; + struct spa_port_io source2_mix_io[1]; + struct spa_buffer *source2_buffers[2]; + struct buffer source2_buffer[2]; bool running; pthread_t thread; - SpaSource sources[16]; + struct spa_source sources[16]; unsigned int n_sources; bool rebuild_fds; struct pollfd fds[16]; unsigned int n_fds; -} AppData; +}; #define MIN_LATENCY 64 @@ -143,12 +143,12 @@ typedef struct { #define BUFFER_SIZE2 MIN_LATENCY - 4 static void -init_buffer (AppData *data, SpaBuffer **bufs, Buffer *ba, int n_buffers, size_t size) +init_buffer (struct data *data, struct spa_buffer **bufs, struct buffer *ba, int n_buffers, size_t size) { int i; for (i = 0; i < n_buffers; i++) { - Buffer *b = &ba[i]; + struct buffer *b = &ba[i]; bufs[i] = &b->buffer; b->buffer.id = i; @@ -178,13 +178,13 @@ init_buffer (AppData *data, SpaBuffer **bufs, Buffer *ba, int n_buffers, size_t } } -static SpaResult -make_node (AppData *data, SpaNode **node, const char *lib, const char *name) +static int +make_node (struct data *data, struct spa_node **node, const char *lib, const char *name) { - SpaHandle *handle; - SpaResult res; + struct spa_handle *handle; + int res; void *hnd; - SpaEnumHandleFactoryFunc enum_func; + spa_handle_factory_enum_func_t enum_func; unsigned int i; uint32_t state = 0; @@ -192,13 +192,13 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name) printf ("can't load %s: %s\n", lib, dlerror()); return SPA_RESULT_ERROR; } - if ((enum_func = dlsym (hnd, "spa_enum_handle_factory")) == NULL) { + if ((enum_func = dlsym (hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { printf ("can't find enum function\n"); return SPA_RESULT_ERROR; } for (i = 0; ;i++) { - const SpaHandleFactory *factory; + const struct spa_handle_factory *factory; void *iface; if ((res = enum_func (&factory, state++)) < 0) { @@ -225,22 +225,22 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name) } static void -on_sink_event (SpaNode *node, SpaEvent *event, void *user_data) +on_sink_event (struct spa_node *node, struct spa_event *event, void *user_data) { printf ("got event %d\n", SPA_EVENT_TYPE (event)); } static void -on_sink_need_input (SpaNode *node, void *user_data) +on_sink_need_input (struct spa_node *node, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; #ifdef USE_GRAPH data->sink_node.action = PROCESS_CHECK; data->sink_node.state = SPA_RESULT_NEED_BUFFER; spa_graph_node_schedule (&data->graph, &data->sink_node); #else - SpaResult res; + int res; res = spa_node_process_output (data->mix); if (res == SPA_RESULT_NEED_BUFFER) { @@ -273,14 +273,14 @@ push: } static void -on_sink_reuse_buffer (SpaNode *node, uint32_t port_id, uint32_t buffer_id, void *user_data) +on_sink_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; data->mix_sink_io[0].buffer_id = buffer_id; } -static const SpaNodeCallbacks sink_callbacks = +static const struct spa_node_callbacks sink_callbacks = { &on_sink_event, &on_sink_need_input, @@ -288,11 +288,11 @@ static const SpaNodeCallbacks sink_callbacks = &on_sink_reuse_buffer }; -static SpaResult -do_add_source (SpaLoop *loop, - SpaSource *source) +static int +do_add_source (struct spa_loop *loop, + struct spa_source *source) { - AppData *data = SPA_CONTAINER_OF (loop, AppData, data_loop); + struct data *data = SPA_CONTAINER_OF (loop, struct data, data_loop); data->sources[data->n_sources] = *source; data->n_sources++; @@ -301,20 +301,20 @@ do_add_source (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -do_update_source (SpaSource *source) +static int +do_update_source (struct spa_source *source) { return SPA_RESULT_OK; } static void -do_remove_source (SpaSource *source) +do_remove_source (struct spa_source *source) { } -static SpaResult -do_invoke (SpaLoop *loop, - SpaInvokeFunc func, +static int +do_invoke (struct spa_loop *loop, + spa_invoke_func_t func, uint32_t seq, size_t size, void *data, @@ -323,13 +323,13 @@ do_invoke (SpaLoop *loop, return func (loop, false, seq, size, data, user_data); } -static SpaResult -make_nodes (AppData *data, const char *device) +static int +make_nodes (struct data *data, const char *device) { - SpaResult res; - SpaProps *props; - SpaPODBuilder b = { 0 }; - SpaPODFrame f[2]; + int res; + struct spa_props *props; + struct spa_pod_builder b = { 0 }; + struct spa_pod_frame f[2]; uint8_t buffer[128]; if ((res = make_node (data, &data->sink, @@ -344,7 +344,7 @@ make_nodes (AppData *data, const char *device) spa_pod_builder_props (&b, &f[0], data->type.props, SPA_POD_PROP (&f[1], data->type.props_device, 0, SPA_POD_TYPE_STRING, 1, device ? device : "hw:0"), SPA_POD_PROP (&f[1], data->type.props_min_latency, 0, SPA_POD_TYPE_INT, 1, MIN_LATENCY)); - props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); if ((res = spa_node_set_props (data->sink, props)) < 0) printf ("got set_props error %d\n", res); @@ -368,7 +368,7 @@ make_nodes (AppData *data, const char *device) SPA_POD_PROP (&f[1], data->type.props_freq, 0, SPA_POD_TYPE_DOUBLE, 1, 600.0), SPA_POD_PROP (&f[1], data->type.props_volume, 0, SPA_POD_TYPE_DOUBLE, 1, 0.5), SPA_POD_PROP (&f[1], data->type.props_live, 0, SPA_POD_TYPE_BOOL, 1, false)); - props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); if ((res = spa_node_set_props (data->source1, props)) < 0) printf ("got set_props error %d\n", res); @@ -385,7 +385,7 @@ make_nodes (AppData *data, const char *device) SPA_POD_PROP (&f[1], data->type.props_freq, 0, SPA_POD_TYPE_DOUBLE, 1, 440.0), SPA_POD_PROP (&f[1], data->type.props_volume, 0, SPA_POD_TYPE_DOUBLE, 1, 0.5), SPA_POD_PROP (&f[1], data->type.props_live, 0, SPA_POD_TYPE_BOOL, 1, false)); - props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); if ((res = spa_node_set_props (data->source2, props)) < 0) printf ("got set_props error %d\n", res); @@ -446,14 +446,14 @@ make_nodes (AppData *data, const char *device) return res; } -static SpaResult -negotiate_formats (AppData *data) +static int +negotiate_formats (struct data *data) { - SpaResult res; - SpaFormat *format, *filter; + int res; + struct spa_format *format, *filter; uint32_t state = 0; - SpaPODBuilder b = { 0 }; - SpaPODFrame f[2]; + struct spa_pod_builder b = { 0 }; + struct spa_pod_frame f[2]; uint8_t buffer[256]; spa_pod_builder_init (&b, buffer, sizeof (buffer)); @@ -471,7 +471,7 @@ negotiate_formats (AppData *data) SPA_POD_PROP (&f[1], data->type.format_audio.channels, 0, SPA_POD_TYPE_INT, 1, 2)); - filter = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + filter = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); if ((res = spa_node_port_enum_formats (data->sink, SPA_DIRECTION_INPUT, 0, &format, filter, state)) < 0) return res; @@ -518,7 +518,7 @@ negotiate_formats (AppData *data) static void * loop (void *user_data) { - AppData *data = user_data; + struct data *data = user_data; printf ("enter thread %d\n", data->n_sources); while (data->running) { @@ -527,7 +527,7 @@ loop (void *user_data) /* rebuild */ if (data->rebuild_fds) { for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; data->fds[i].fd = p->fd; data->fds[i].events = p->mask; } @@ -548,7 +548,7 @@ loop (void *user_data) /* after */ for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; p->rmask = 0; if (data->fds[i].revents & POLLIN) p->rmask |= SPA_IO_IN; @@ -560,7 +560,7 @@ loop (void *user_data) p->rmask |= SPA_IO_ERR; } for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; if (p->rmask) p->func (p); } @@ -571,13 +571,13 @@ loop (void *user_data) } static void -run_async_sink (AppData *data) +run_async_sink (struct data *data) { - SpaResult res; + int res; int err; { - SpaCommand cmd = SPA_COMMAND_INIT (data->type.command_node.Start); + struct spa_command cmd = SPA_COMMAND_INIT (data->type.command_node.Start); if ((res = spa_node_send_command (data->source1, &cmd)) < 0) printf ("got source1 error %d\n", res); if ((res = spa_node_send_command (data->source2, &cmd)) < 0) @@ -603,7 +603,7 @@ run_async_sink (AppData *data) } { - SpaCommand cmd = SPA_COMMAND_INIT (data->type.command_node.Pause); + struct spa_command cmd = SPA_COMMAND_INIT (data->type.command_node.Pause); if ((res = spa_node_send_command (data->sink, &cmd)) < 0) printf ("got error %d\n", res); if ((res = spa_node_send_command (data->mix, &cmd)) < 0) @@ -618,13 +618,13 @@ run_async_sink (AppData *data) int main (int argc, char *argv[]) { - AppData data = { NULL }; - SpaResult res; + struct data data = { NULL }; + int res; const char *str; data.map = spa_type_map_get_default(); data.log = spa_log_get_default(); - data.data_loop.size = sizeof (SpaLoop); + data.data_loop.size = sizeof (struct spa_loop); data.data_loop.add_source = do_add_source; data.data_loop.update_source = do_update_source; data.data_loop.remove_source = do_remove_source; diff --git a/spa/tests/test-perf.c b/spa/tests/test-perf.c index 99d0e5ccd..532eab5b7 100644 --- a/spa/tests/test-perf.c +++ b/spa/tests/test-perf.c @@ -46,7 +46,7 @@ #define MODE_ASYNC_BOTH (MODE_ASYNC_PUSH|MODE_ASYNC_PULL) #define MODE_DIRECT (1<<4) -typedef struct { +struct type { uint32_t node; uint32_t props; uint32_t format; @@ -55,16 +55,16 @@ typedef struct { uint32_t props_volume; uint32_t props_min_latency; uint32_t props_live; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->props = spa_type_map_get_id (map, SPA_TYPE__Props); @@ -82,44 +82,44 @@ init_type (Type *type, SpaTypeMap *map) spa_type_command_node_map (map, &type->command_node); } -typedef struct { - SpaBuffer buffer; - SpaMeta metas[1]; - SpaMetaHeader header; - SpaData datas[1]; - SpaChunk chunks[1]; -} Buffer; +struct buffer { + struct spa_buffer buffer; + struct spa_meta metas[1]; + struct spa_meta_header header; + struct spa_data datas[1]; + struct spa_chunk chunks[1]; +}; -typedef struct { - SpaTypeMap *map; - SpaLog *log; - SpaLoop data_loop; - Type type; +struct data { + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop data_loop; + struct type type; int mode; - SpaSupport support[4]; + struct spa_support support[4]; uint32_t n_support; int iterations; - SpaGraph graph; - SpaGraphNode source_node; - SpaGraphPort source_out; - SpaGraphPort sink_in; - SpaGraphNode sink_node; + struct spa_graph graph; + struct spa_graph_node source_node; + struct spa_graph_port source_out; + struct spa_graph_port sink_in; + struct spa_graph_node sink_node; - SpaNode *sink; - SpaPortIO source_sink_io[1]; + struct spa_node *sink; + struct spa_port_io source_sink_io[1]; - SpaNode *source; - SpaBuffer *source_buffers[1]; - Buffer source_buffer[1]; + struct spa_node *source; + struct spa_buffer *source_buffers[1]; + struct buffer source_buffer[1]; bool running; pthread_t thread; - SpaSource sources[16]; + struct spa_source sources[16]; unsigned int n_sources; bool rebuild_fds; @@ -127,19 +127,19 @@ typedef struct { unsigned int n_fds; void *hnd; -} AppData; +}; #define MIN_LATENCY 64 #define BUFFER_SIZE MIN_LATENCY static void -init_buffer (AppData *data, SpaBuffer **bufs, Buffer *ba, int n_buffers, size_t size) +init_buffer (struct data *data, struct spa_buffer **bufs, struct buffer *ba, int n_buffers, size_t size) { int i; for (i = 0; i < n_buffers; i++) { - Buffer *b = &ba[i]; + struct buffer *b = &ba[i]; bufs[i] = &b->buffer; b->buffer.id = i; @@ -169,12 +169,12 @@ init_buffer (AppData *data, SpaBuffer **bufs, Buffer *ba, int n_buffers, size_t } } -static SpaResult -make_node (AppData *data, SpaNode **node, const char *lib, const char *name) +static int +make_node (struct data *data, struct spa_node **node, const char *lib, const char *name) { - SpaHandle *handle; - SpaResult res; - SpaEnumHandleFactoryFunc enum_func; + struct spa_handle *handle; + int res; + spa_handle_factory_enum_func_t enum_func; unsigned int i; uint32_t state = 0; @@ -184,13 +184,13 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name) return SPA_RESULT_ERROR; } } - if ((enum_func = dlsym (data->hnd, "spa_enum_handle_factory")) == NULL) { + if ((enum_func = dlsym (data->hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { printf ("can't find enum function\n"); return SPA_RESULT_ERROR; } for (i = 0; ;i++) { - const SpaHandleFactory *factory; + const struct spa_handle_factory *factory; void *iface; if ((res = enum_func (&factory, state++)) < 0) { @@ -217,7 +217,7 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name) } static void -on_sink_pull (AppData *data) +on_sink_pull (struct data *data) { spa_log_trace (data->log, "do sink pull"); data->sink_node.state = SPA_RESULT_NEED_BUFFER; @@ -232,7 +232,7 @@ on_sink_pull (AppData *data) } static void -on_source_push (AppData *data) +on_source_push (struct data *data) { spa_log_trace (data->log, "do source push"); if (data->mode & MODE_DIRECT) { @@ -246,16 +246,16 @@ on_source_push (AppData *data) } static void -on_sink_event (SpaNode *node, SpaEvent *event, void *user_data) +on_sink_event (struct spa_node *node, struct spa_event *event, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; spa_log_trace (data->log, "got sink event %d", SPA_EVENT_TYPE (event)); } static void -on_sink_need_input (SpaNode *node, void *user_data) +on_sink_need_input (struct spa_node *node, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; spa_log_trace (data->log, "need input"); on_sink_pull (data); if (--data->iterations == 0) @@ -263,14 +263,14 @@ on_sink_need_input (SpaNode *node, void *user_data) } static void -on_sink_reuse_buffer (SpaNode *node, uint32_t port_id, uint32_t buffer_id, void *user_data) +on_sink_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; data->source_sink_io[0].buffer_id = buffer_id; } -static const SpaNodeCallbacks sink_callbacks = +static const struct spa_node_callbacks sink_callbacks = { &on_sink_event, &on_sink_need_input, @@ -279,23 +279,23 @@ static const SpaNodeCallbacks sink_callbacks = }; static void -on_source_event (SpaNode *node, SpaEvent *event, void *user_data) +on_source_event (struct spa_node *node, struct spa_event *event, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; spa_log_trace (data->log, "got source event %d", SPA_EVENT_TYPE (event)); } static void -on_source_have_output (SpaNode *node, void *user_data) +on_source_have_output (struct spa_node *node, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; spa_log_trace (data->log, "have_output"); on_source_push (data); if (--data->iterations == 0) data->running = false; } -static const SpaNodeCallbacks source_callbacks = +static const struct spa_node_callbacks source_callbacks = { &on_source_event, NULL, @@ -304,11 +304,11 @@ static const SpaNodeCallbacks source_callbacks = }; -static SpaResult -do_add_source (SpaLoop *loop, - SpaSource *source) +static int +do_add_source (struct spa_loop *loop, + struct spa_source *source) { - AppData *data = SPA_CONTAINER_OF (loop, AppData, data_loop); + struct data *data = SPA_CONTAINER_OF (loop, struct data, data_loop); data->sources[data->n_sources] = *source; data->n_sources++; @@ -317,20 +317,20 @@ do_add_source (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -do_update_source (SpaSource *source) +static int +do_update_source (struct spa_source *source) { return SPA_RESULT_OK; } static void -do_remove_source (SpaSource *source) +do_remove_source (struct spa_source *source) { } -static SpaResult -do_invoke (SpaLoop *loop, - SpaInvokeFunc func, +static int +do_invoke (struct spa_loop *loop, + spa_invoke_func_t func, uint32_t seq, size_t size, void *data, @@ -339,10 +339,10 @@ do_invoke (SpaLoop *loop, return func (loop, false, seq, size, data, user_data); } -static SpaResult -make_nodes (AppData *data) +static int +make_nodes (struct data *data) { - SpaResult res; + int res; if ((res = make_node (data, &data->sink, "build/spa/plugins/test/libspa-test.so", @@ -388,19 +388,19 @@ make_nodes (AppData *data) return res; } -static SpaResult -negotiate_formats (AppData *data) +static int +negotiate_formats (struct data *data) { - SpaResult res; - SpaFormat *format; - SpaPODBuilder b = { 0 }; - SpaPODFrame f[2]; + int res; + struct spa_format *format; + struct spa_pod_builder b = { 0 }; + struct spa_pod_frame f[2]; uint8_t buffer[256]; spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_format (&b, &f[0], data->type.format, data->type.media_type.binary, data->type.media_subtype.raw, 0); - format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); if ((res = spa_node_port_set_format (data->sink, SPA_DIRECTION_INPUT, 0, 0, format)) < 0) return res; @@ -421,7 +421,7 @@ negotiate_formats (AppData *data) static void * loop (void *user_data) { - AppData *data = user_data; + struct data *data = user_data; printf ("enter thread %d\n", data->n_sources); while (data->running) { @@ -430,7 +430,7 @@ loop (void *user_data) /* rebuild */ if (data->rebuild_fds) { for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; data->fds[i].fd = p->fd; data->fds[i].events = p->mask; } @@ -451,7 +451,7 @@ loop (void *user_data) /* after */ for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; p->rmask = 0; if (data->fds[i].revents & POLLIN) p->rmask |= SPA_IO_IN; @@ -463,7 +463,7 @@ loop (void *user_data) p->rmask |= SPA_IO_ERR; } for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; if (p->rmask) p->func (p); } @@ -474,15 +474,15 @@ loop (void *user_data) } static void -run_graph (AppData *data) +run_graph (struct data *data) { - SpaResult res; + int res; int err, i; struct timespec now; int64_t start, stop; { - SpaCommand cmd = SPA_COMMAND_INIT (data->type.command_node.Start); + struct spa_command cmd = SPA_COMMAND_INIT (data->type.command_node.Start); if ((res = spa_node_send_command (data->source, &cmd)) < 0) printf ("got source error %d\n", res); if ((res = spa_node_send_command (data->sink, &cmd)) < 0) @@ -519,7 +519,7 @@ run_graph (AppData *data) printf ("stopping, elapsed %"PRIi64"\n", stop - start); { - SpaCommand cmd = SPA_COMMAND_INIT (data->type.command_node.Pause); + struct spa_command cmd = SPA_COMMAND_INIT (data->type.command_node.Pause); if ((res = spa_node_send_command (data->sink, &cmd)) < 0) printf ("got error %d\n", res); if ((res = spa_node_send_command (data->source, &cmd)) < 0) @@ -530,15 +530,15 @@ run_graph (AppData *data) int main (int argc, char *argv[]) { - AppData data = { NULL }; - SpaResult res; + struct data data = { NULL }; + int res; const char *str; spa_graph_init (&data.graph); data.map = spa_type_map_get_default(); data.log = spa_log_get_default(); - data.data_loop.size = sizeof (SpaLoop); + data.data_loop.size = sizeof (struct spa_loop); data.data_loop.add_source = do_add_source; data.data_loop.update_source = do_update_source; data.data_loop.remove_source = do_remove_source; diff --git a/spa/tests/test-props.c b/spa/tests/test-props.c index 1f8dde64b..1ae8e4444 100644 --- a/spa/tests/test-props.c +++ b/spa/tests/test-props.c @@ -62,14 +62,14 @@ spa_build (SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW, static struct { uint32_t format; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatVideo format_video; - SpaTypeVideoFormat video_format; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_video format_video; + struct spa_type_video_format video_format; } type = { 0, }; static inline void -type_init (SpaTypeMap *map) +type_init (struct spa_type_map *map) { type.format = spa_type_map_get_id (map, SPA_TYPE__Format); spa_type_media_type_map (map, &type.media_type); @@ -79,58 +79,58 @@ type_init (SpaTypeMap *map) } static void -do_static_struct (SpaTypeMap *map) +do_static_struct (struct spa_type_map *map) { struct _test_format { - SpaFormat fmt; + struct spa_format fmt; struct { - SpaPODProp prop_format; + struct spa_pod_prop prop_format; struct { uint32_t def_format; uint32_t enum_format[2]; } format_vals; uint32_t pad; - SpaPODProp prop_size; + struct spa_pod_prop prop_size; struct { - SpaRectangle def_size; - SpaRectangle min_size; - SpaRectangle max_size; + struct spa_rectangle def_size; + struct spa_rectangle min_size; + struct spa_rectangle max_size; } size_vals; - SpaPODProp prop_framerate; + struct spa_pod_prop prop_framerate; struct { - SpaFraction def_framerate; - SpaFraction min_framerate; - SpaFraction max_framerate; + struct spa_fraction def_framerate; + struct spa_fraction min_framerate; + struct spa_fraction max_framerate; } framerate_vals; } props; } test_format = { - { { sizeof (test_format.props) + sizeof (SpaFormatBody), SPA_POD_TYPE_OBJECT }, + { { sizeof (test_format.props) + sizeof (struct spa_format), SPA_POD_TYPE_OBJECT }, { { 0, type.format }, { { sizeof (uint32_t), SPA_POD_TYPE_ID }, type.media_type.video }, { { sizeof (uint32_t), SPA_POD_TYPE_ID }, type.media_subtype.raw } }, }, { - { { sizeof (test_format.props.format_vals) + sizeof (SpaPODPropBody), + { { sizeof (test_format.props.format_vals) + sizeof (struct spa_pod_prop_body), SPA_POD_TYPE_PROP } , { type.format_video.format, SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET, { sizeof (uint32_t), SPA_POD_TYPE_ID } }, }, { type.video_format.I420, { type.video_format.I420, type.video_format.YUY2 } }, 0, - { { sizeof (test_format.props.size_vals) + sizeof (SpaPODPropBody), + { { sizeof (test_format.props.size_vals) + sizeof (struct spa_pod_prop_body), SPA_POD_TYPE_PROP } , { type.format_video.size, SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET, - { sizeof (SpaRectangle), SPA_POD_TYPE_RECTANGLE } }, }, + { sizeof (struct spa_rectangle), SPA_POD_TYPE_RECTANGLE } }, }, { { 320, 243 }, { 1, 1 }, { INT32_MAX, INT32_MAX } }, - { { sizeof (test_format.props.framerate_vals) + sizeof (SpaPODPropBody), + { { sizeof (test_format.props.framerate_vals) + sizeof (struct spa_pod_prop_body), SPA_POD_TYPE_PROP } , { type.format_video.framerate, SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET, - { sizeof (SpaFraction), SPA_POD_TYPE_FRACTION } }, }, + { sizeof (struct spa_fraction), SPA_POD_TYPE_FRACTION } }, }, { { 25, 1 }, { 0, 1 }, { INT32_MAX, 1 } }, @@ -142,9 +142,9 @@ do_static_struct (SpaTypeMap *map) { uint32_t format = 0, match; - SpaFraction frac = { 0, 0 }; + struct spa_fraction frac = { 0, 0 }; - match = spa_pod_contents_query (&test_format.fmt.pod, sizeof (SpaFormat), + match = spa_pod_contents_query (&test_format.fmt.pod, sizeof (struct spa_format), type.format_video.format, SPA_POD_TYPE_INT, &format, type.format_video.framerate, SPA_POD_TYPE_FRACTION, &frac, 0); @@ -157,11 +157,11 @@ do_static_struct (SpaTypeMap *map) int main (int argc, char *argv[]) { - SpaPODBuilder b = { NULL, }; - SpaPODFrame frame[4]; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame frame[4]; uint8_t buffer[1024]; - SpaFormat *fmt; - SpaTypeMap *map = spa_type_map_get_default(); + struct spa_format *fmt; + struct spa_type_map *map = spa_type_map_get_default(); type_init (map); @@ -169,7 +169,7 @@ main (int argc, char *argv[]) fmt = SPA_MEMBER (buffer, spa_pod_builder_push_format (&b, &frame[0], type.format, type.media_type.video, - type.media_subtype.raw), SpaFormat); + type.media_subtype.raw), struct spa_format); spa_pod_builder_push_prop (&b, &frame[1], type.format_video.format, SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET); @@ -178,7 +178,7 @@ main (int argc, char *argv[]) spa_pod_builder_id (&b, type.video_format.YUY2); spa_pod_builder_pop (&b, &frame[1]); - SpaRectangle size_min_max[] = { { 1, 1 }, { INT32_MAX, INT32_MAX } }; + struct spa_rectangle size_min_max[] = { { 1, 1 }, { INT32_MAX, INT32_MAX } }; spa_pod_builder_push_prop (&b, &frame[1], type.format_video.size, SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET); @@ -186,7 +186,7 @@ main (int argc, char *argv[]) spa_pod_builder_raw (&b, size_min_max, sizeof(size_min_max)); spa_pod_builder_pop (&b, &frame[1]); - SpaFraction rate_min_max[] = { { 0, 1 }, { INT32_MAX, 1 } }; + struct spa_fraction rate_min_max[] = { { 0, 1 }, { INT32_MAX, 1 } }; spa_pod_builder_push_prop (&b, &frame[1], type.format_video.framerate, SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET); @@ -227,7 +227,7 @@ main (int argc, char *argv[]) INT32_MAX, 1, -SPA_POD_TYPE_PROP, &frame[1]); - fmt = SPA_MEMBER (buffer, frame[0].ref, SpaFormat); + fmt = SPA_MEMBER (buffer, frame[0].ref, struct spa_format); spa_debug_pod (&fmt->pod, map); spa_debug_format (fmt, map); @@ -264,7 +264,7 @@ main (int argc, char *argv[]) -SPA_POD_TYPE_OBJECT, &frame[0], 0); - fmt = SPA_MEMBER (buffer, frame[0].ref, SpaFormat); + fmt = SPA_MEMBER (buffer, frame[0].ref, struct spa_format); spa_debug_pod (&fmt->pod, map); spa_debug_format (fmt, map); diff --git a/spa/tests/test-props2.c b/spa/tests/test-props2.c index 128414f5a..ea18538cf 100644 --- a/spa/tests/test-props2.c +++ b/spa/tests/test-props2.c @@ -37,12 +37,12 @@ int main (int argc, char *argv[]) { - SpaPODBuilder b = { NULL, }; - SpaPODFrame frame[4]; + struct spa_pod_builder b = { NULL, }; + struct spa_pod_frame frame[4]; uint8_t buffer[1024]; - SpaPOD *obj; - SpaPODIter i; - SpaTypeMap *map = spa_type_map_get_default (); + struct spa_pod *obj; + struct spa_pod_iter i; + struct spa_type_map *map = spa_type_map_get_default (); b.data = buffer; b.size = 1024; @@ -61,7 +61,7 @@ main (int argc, char *argv[]) spa_pod_builder_int (&b, 42); spa_pod_builder_pop (&b, &frame[1]); - SpaRectangle sizes[] = { { 0, 0 }, { 1024, 1024} }; + struct spa_rectangle sizes[] = { { 0, 0 }, { 1024, 1024} }; spa_pod_builder_push_prop (&b, &frame[1], 3, SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET); spa_pod_builder_rectangle (&b, 320, 240); @@ -86,23 +86,23 @@ main (int argc, char *argv[]) spa_pod_builder_pop (&b, &frame[1]); spa_pod_builder_pop (&b, &frame[0]); - obj = SPA_POD_BUILDER_DEREF (&b, frame[0].ref, SpaPOD); + obj = SPA_POD_BUILDER_DEREF (&b, frame[0].ref, struct spa_pod); spa_debug_pod (obj, map); - SpaPODProp *p = spa_pod_object_find_prop ((SpaPODObject *)obj, 4); + struct spa_pod_prop *p = spa_pod_object_find_prop ((struct spa_pod_object *)obj, 4); printf ("%d %d\n", p->body.key, p->body.flags); spa_debug_pod (&p->body.value, map); - obj = SPA_POD_BUILDER_DEREF (&b, frame[2].ref, SpaPOD); + obj = SPA_POD_BUILDER_DEREF (&b, frame[2].ref, struct spa_pod); int32_t vi, *pi; int64_t vl; float vf; double vd; char *vs; - SpaRectangle vr; - SpaFraction vfr; - SpaPODArray *va; + struct spa_rectangle vr; + struct spa_fraction vfr; + struct spa_pod_array *va; spa_pod_iter_pod (&i, obj); spa_pod_iter_get (&i, SPA_POD_TYPE_INT, &vi, SPA_POD_TYPE_LONG, &vl, diff --git a/spa/tests/test-ringbuffer.c b/spa/tests/test-ringbuffer.c index a053b62ee..25c189a55 100644 --- a/spa/tests/test-ringbuffer.c +++ b/spa/tests/test-ringbuffer.c @@ -37,7 +37,7 @@ #include #include -typedef struct { +struct type { uint32_t node; uint32_t props; uint32_t format; @@ -46,18 +46,18 @@ typedef struct { uint32_t props_volume; uint32_t props_min_latency; uint32_t props_live; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatAudio format_audio; - SpaTypeAudioFormat audio_format; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_audio format_audio; + struct spa_type_audio_format audio_format; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->props = spa_type_map_get_id (map, SPA_TYPE__Props); @@ -77,51 +77,51 @@ init_type (Type *type, SpaTypeMap *map) spa_type_command_node_map (map, &type->command_node); } -typedef struct { - SpaBuffer buffer; - SpaMeta metas[2]; - SpaMetaHeader header; - SpaMetaRingbuffer rb; - SpaData datas[1]; - SpaChunk chunks[1]; -} Buffer; +struct buffer { + struct spa_buffer buffer; + struct spa_meta metas[2]; + struct spa_meta_header header; + struct spa_meta_ringbuffer rb; + struct spa_data datas[1]; + struct spa_chunk chunks[1]; +}; -typedef struct { - SpaTypeMap *map; - SpaLog *log; - SpaLoop data_loop; - Type type; +struct data { + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop data_loop; + struct type type; - SpaSupport support[4]; + struct spa_support support[4]; uint32_t n_support; - SpaNode *sink; - SpaPortIO source_sink_io[1]; + struct spa_node *sink; + struct spa_port_io source_sink_io[1]; - SpaNode *source; - SpaBuffer *source_buffers[1]; - Buffer source_buffer[1]; + struct spa_node *source; + struct spa_buffer *source_buffers[1]; + struct buffer source_buffer[1]; bool running; pthread_t thread; - SpaSource sources[16]; + struct spa_source sources[16]; unsigned int n_sources; bool rebuild_fds; struct pollfd fds[16]; unsigned int n_fds; -} AppData; +}; #define BUFFER_SIZE 4096 static void -init_buffer (AppData *data, SpaBuffer **bufs, Buffer *ba, int n_buffers, size_t size) +init_buffer (struct data *data, struct spa_buffer **bufs, struct buffer *ba, int n_buffers, size_t size) { int i; for (i = 0; i < n_buffers; i++) { - Buffer *b = &ba[i]; + struct buffer *b = &ba[i]; bufs[i] = &b->buffer; b->buffer.id = i; @@ -156,13 +156,13 @@ init_buffer (AppData *data, SpaBuffer **bufs, Buffer *ba, int n_buffers, size_t } } -static SpaResult -make_node (AppData *data, SpaNode **node, const char *lib, const char *name) +static int +make_node (struct data *data, struct spa_node **node, const char *lib, const char *name) { - SpaHandle *handle; - SpaResult res; + struct spa_handle *handle; + int res; void *hnd; - SpaEnumHandleFactoryFunc enum_func; + spa_handle_factory_enum_func_t enum_func; unsigned int i; uint32_t state = 0; @@ -170,13 +170,13 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name) printf ("can't load %s: %s\n", lib, dlerror()); return SPA_RESULT_ERROR; } - if ((enum_func = dlsym (hnd, "spa_enum_handle_factory")) == NULL) { + if ((enum_func = dlsym (hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { printf ("can't find enum function\n"); return SPA_RESULT_ERROR; } for (i = 0; ;i++) { - const SpaHandleFactory *factory; + const struct spa_handle_factory *factory; void *iface; if ((res = enum_func (&factory, state++)) < 0) { @@ -203,16 +203,16 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name) } static void -on_sink_event (SpaNode *node, SpaEvent *event, void *user_data) +on_sink_event (struct spa_node *node, struct spa_event *event, void *user_data) { printf ("got event %d\n", SPA_EVENT_TYPE (event)); } static void -on_sink_need_input (SpaNode *node, void *user_data) +on_sink_need_input (struct spa_node *node, void *user_data) { - AppData *data = user_data; - SpaResult res; + struct data *data = user_data; + int res; res = spa_node_process_output (data->source); if (res != SPA_RESULT_HAVE_BUFFER) @@ -223,24 +223,24 @@ on_sink_need_input (SpaNode *node, void *user_data) } static void -on_sink_reuse_buffer (SpaNode *node, uint32_t port_id, uint32_t buffer_id, void *user_data) +on_sink_reuse_buffer (struct spa_node *node, uint32_t port_id, uint32_t buffer_id, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; data->source_sink_io[0].buffer_id = buffer_id; } -static const SpaNodeCallbacks sink_callbacks = { +static const struct spa_node_callbacks sink_callbacks = { &on_sink_event, &on_sink_need_input, NULL, &on_sink_reuse_buffer }; -static SpaResult -do_add_source (SpaLoop *loop, - SpaSource *source) +static int +do_add_source (struct spa_loop *loop, + struct spa_source *source) { - AppData *data = SPA_CONTAINER_OF (loop, AppData, data_loop); + struct data *data = SPA_CONTAINER_OF (loop, struct data, data_loop); data->sources[data->n_sources] = *source; data->n_sources++; @@ -249,20 +249,20 @@ do_add_source (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -do_update_source (SpaSource *source) +static int +do_update_source (struct spa_source *source) { return SPA_RESULT_OK; } static void -do_remove_source (SpaSource *source) +do_remove_source (struct spa_source *source) { } -static SpaResult -do_invoke (SpaLoop *loop, - SpaInvokeFunc func, +static int +do_invoke (struct spa_loop *loop, + spa_invoke_func_t func, uint32_t seq, size_t size, void *data, @@ -271,13 +271,13 @@ do_invoke (SpaLoop *loop, return func (loop, false, seq, size, data, user_data); } -static SpaResult -make_nodes (AppData *data, const char *device) +static int +make_nodes (struct data *data, const char *device) { - SpaResult res; - SpaProps *props; - SpaPODBuilder b = { 0 }; - SpaPODFrame f[2]; + int res; + struct spa_props *props; + struct spa_pod_builder b = { 0 }; + struct spa_pod_frame f[2]; uint8_t buffer[128]; if ((res = make_node (data, &data->sink, @@ -292,7 +292,7 @@ make_nodes (AppData *data, const char *device) spa_pod_builder_props (&b, &f[0], data->type.props, SPA_POD_PROP (&f[1], data->type.props_device, 0, SPA_POD_TYPE_STRING, 1, device ? device : "hw:0"), SPA_POD_PROP (&f[1], data->type.props_min_latency, 0, SPA_POD_TYPE_INT, 1, 64)); - props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); if ((res = spa_node_set_props (data->sink, props)) < 0) printf ("got set_props error %d\n", res); @@ -307,21 +307,21 @@ make_nodes (AppData *data, const char *device) spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_props (&b, &f[0], data->type.props, SPA_POD_PROP (&f[1], data->type.props_live, 0, SPA_POD_TYPE_BOOL, 1, false)); - props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); if ((res = spa_node_set_props (data->source, props)) < 0) printf ("got set_props error %d\n", res); return res; } -static SpaResult -negotiate_formats (AppData *data) +static int +negotiate_formats (struct data *data) { - SpaResult res; - SpaFormat *format, *filter; + int res; + struct spa_format *format, *filter; uint32_t state = 0; - SpaPODBuilder b = { 0 }; - SpaPODFrame f[2]; + struct spa_pod_builder b = { 0 }; + struct spa_pod_frame f[2]; uint8_t buffer[256]; spa_pod_builder_init (&b, buffer, sizeof (buffer)); @@ -339,7 +339,7 @@ negotiate_formats (AppData *data) SPA_POD_PROP (&f[1], data->type.format_audio.channels, 0, SPA_POD_TYPE_INT, 1, 2)); - filter = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + filter = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); if ((res = spa_node_port_enum_formats (data->sink, SPA_DIRECTION_INPUT, 0, &format, filter, state)) < 0) return res; @@ -368,7 +368,7 @@ negotiate_formats (AppData *data) static void * loop (void *user_data) { - AppData *data = user_data; + struct data *data = user_data; printf ("enter thread %d\n", data->n_sources); while (data->running) { @@ -377,7 +377,7 @@ loop (void *user_data) /* rebuild */ if (data->rebuild_fds) { for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; data->fds[i].fd = p->fd; data->fds[i].events = p->mask; } @@ -398,7 +398,7 @@ loop (void *user_data) /* after */ for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; p->rmask = 0; if (data->fds[i].revents & POLLIN) p->rmask |= SPA_IO_IN; @@ -410,7 +410,7 @@ loop (void *user_data) p->rmask |= SPA_IO_ERR; } for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; if (p->rmask) p->func (p); } @@ -421,13 +421,13 @@ loop (void *user_data) } static void -run_async_sink (AppData *data) +run_async_sink (struct data *data) { - SpaResult res; + int res; int err; { - SpaCommand cmd = SPA_COMMAND_INIT (data->type.command_node.Start); + struct spa_command cmd = SPA_COMMAND_INIT (data->type.command_node.Start); if ((res = spa_node_send_command (data->source, &cmd)) < 0) printf ("got source error %d\n", res); if ((res = spa_node_send_command (data->sink, &cmd)) < 0) @@ -449,7 +449,7 @@ run_async_sink (AppData *data) } { - SpaCommand cmd = SPA_COMMAND_INIT (data->type.command_node.Pause); + struct spa_command cmd = SPA_COMMAND_INIT (data->type.command_node.Pause); if ((res = spa_node_send_command (data->sink, &cmd)) < 0) printf ("got sink error %d\n", res); if ((res = spa_node_send_command (data->source, &cmd)) < 0) @@ -460,13 +460,13 @@ run_async_sink (AppData *data) int main (int argc, char *argv[]) { - AppData data = { NULL }; - SpaResult res; + struct data data = { NULL }; + int res; const char *str; data.map = spa_type_map_get_default(); data.log = spa_log_get_default(); - data.data_loop.size = sizeof (SpaLoop); + data.data_loop.size = sizeof (struct spa_loop); data.data_loop.add_source = do_add_source; data.data_loop.update_source = do_update_source; data.data_loop.remove_source = do_remove_source; diff --git a/spa/tests/test-v4l2.c b/spa/tests/test-v4l2.c index 846845cfc..2ed8d20aa 100644 --- a/spa/tests/test-v4l2.c +++ b/spa/tests/test-v4l2.c @@ -38,24 +38,24 @@ #include #include -typedef struct { +struct type { uint32_t node; uint32_t props; uint32_t format; uint32_t props_device; uint32_t SDL_Texture; - SpaTypeMeta meta; - SpaTypeData data; - SpaTypeMediaType media_type; - SpaTypeMediaSubtype media_subtype; - SpaTypeFormatVideo format_video; - SpaTypeVideoFormat video_format; - SpaTypeEventNode event_node; - SpaTypeCommandNode command_node; -} Type; + struct spa_type_meta meta; + struct spa_type_data data; + struct spa_type_media_type media_type; + struct spa_type_media_subtype media_subtype; + struct spa_type_format_video format_video; + struct spa_type_video_format video_format; + struct spa_type_event_node event_node; + struct spa_type_command_node command_node; +}; static inline void -init_type (Type *type, SpaTypeMap *map) +init_type (struct type *type, struct spa_type_map *map) { type->node = spa_type_map_get_id (map, SPA_TYPE__Node); type->props = spa_type_map_get_id (map, SPA_TYPE__Props); @@ -74,27 +74,27 @@ init_type (Type *type, SpaTypeMap *map) #define MAX_BUFFERS 8 -typedef struct { - SpaBuffer buffer; - SpaMeta metas[2]; - SpaMetaHeader header; - SpaMetaPointer ptr; - SpaData datas[1]; - SpaChunk chunks[1]; -} SDLBuffer; +struct buffer { + struct spa_buffer buffer; + struct spa_meta metas[2]; + struct spa_meta_header header; + struct spa_meta_pointer ptr; + struct spa_data datas[1]; + struct spa_chunk chunks[1]; +}; -typedef struct { - Type type; +struct data { + struct type type; - SpaTypeMap *map; - SpaLog *log; - SpaLoop data_loop; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop data_loop; - SpaSupport support[4]; + struct spa_support support[4]; uint32_t n_support; - SpaNode *source; - SpaPortIO source_output[1]; + struct spa_node *source; + struct spa_port_io source_output[1]; SDL_Renderer *renderer; SDL_Window *window; @@ -105,25 +105,25 @@ typedef struct { bool running; pthread_t thread; - SpaSource sources[16]; + struct spa_source sources[16]; unsigned int n_sources; bool rebuild_fds; struct pollfd fds[16]; unsigned int n_fds; - SpaBuffer *bp[MAX_BUFFERS]; - SDLBuffer buffers[MAX_BUFFERS]; + struct spa_buffer *bp[MAX_BUFFERS]; + struct buffer buffers[MAX_BUFFERS]; unsigned int n_buffers; -} AppData; +}; -static SpaResult -make_node (AppData *data, SpaNode **node, const char *lib, const char *name) +static int +make_node (struct data *data, struct spa_node **node, const char *lib, const char *name) { - SpaHandle *handle; - SpaResult res; + struct spa_handle *handle; + int res; void *hnd; - SpaEnumHandleFactoryFunc enum_func; + spa_handle_factory_enum_func_t enum_func; unsigned int i; uint32_t state = 0; @@ -131,13 +131,13 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name) printf ("can't load %s: %s\n", lib, dlerror()); return SPA_RESULT_ERROR; } - if ((enum_func = dlsym (hnd, "spa_enum_handle_factory")) == NULL) { + if ((enum_func = dlsym (hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { printf ("can't find enum function\n"); return SPA_RESULT_ERROR; } for (i = 0; ;i++) { - const SpaHandleFactory *factory; + const struct spa_handle_factory *factory; void *iface; if ((res = enum_func (&factory, state)) < 0) { @@ -164,7 +164,7 @@ make_node (AppData *data, SpaNode **node, const char *lib, const char *name) } static void -handle_events (AppData *data) +handle_events (struct data *data) { SDL_Event event; while (SDL_PollEvent (&event)) { @@ -177,9 +177,9 @@ handle_events (AppData *data) } static void -on_source_event (SpaNode *node, SpaEvent *event, void *user_data) +on_source_event (struct spa_node *node, struct spa_event *event, void *user_data) { - AppData *data = user_data; + struct data *data = user_data; handle_events (data); @@ -187,18 +187,18 @@ on_source_event (SpaNode *node, SpaEvent *event, void *user_data) } static void -on_source_have_output (SpaNode *node, void *user_data) +on_source_have_output (struct spa_node *node, void *user_data) { - AppData *data = user_data; - SpaResult res; - SpaBuffer *b; + struct data *data = user_data; + int res; + struct spa_buffer *b; void *sdata, *ddata; int sstride, dstride; int i; uint8_t *src, *dst; - SpaMeta *metas; - SpaData *datas; - SpaPortIO *io = &data->source_output[0]; + struct spa_meta *metas; + struct spa_data *datas; + struct spa_port_io *io = &data->source_output[0]; handle_events (data); @@ -208,9 +208,9 @@ on_source_have_output (SpaNode *node, void *user_data) datas = b->datas; if (metas[1].type == data->type.meta.Pointer && - ((SpaMetaPointer *)metas[1].data)->type == data->type.SDL_Texture) { + ((struct spa_meta_pointer *)metas[1].data)->type == data->type.SDL_Texture) { SDL_Texture *texture; - texture = ((SpaMetaPointer *)metas[1].data)->ptr; + texture = ((struct spa_meta_pointer *)metas[1].data)->ptr; SDL_UnlockTexture(texture); @@ -257,18 +257,18 @@ on_source_have_output (SpaNode *node, void *user_data) printf ("got pull error %d\n", res); } -static const SpaNodeCallbacks source_callbacks = { +static const struct spa_node_callbacks source_callbacks = { &on_source_event, NULL, &on_source_have_output, NULL }; -static SpaResult -do_add_source (SpaLoop *loop, - SpaSource *source) +static int +do_add_source (struct spa_loop *loop, + struct spa_source *source) { - AppData *data = SPA_CONTAINER_OF (loop, AppData, data_loop); + struct data *data = SPA_CONTAINER_OF (loop, struct data, data_loop); data->sources[data->n_sources] = *source; data->n_sources++; @@ -277,20 +277,20 @@ do_add_source (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -do_update_source (SpaSource *source) +static int +do_update_source (struct spa_source *source) { return SPA_RESULT_OK; } static void -do_remove_source (SpaSource *source) +do_remove_source (struct spa_source *source) { } -static SpaResult -do_invoke (SpaLoop *loop, - SpaInvokeFunc func, +static int +do_invoke (struct spa_loop *loop, + spa_invoke_func_t func, uint32_t seq, size_t size, void *data, @@ -299,13 +299,13 @@ do_invoke (SpaLoop *loop, return func (loop, false, seq, size, data, user_data); } -static SpaResult -make_nodes (AppData *data, const char *device) +static int +make_nodes (struct data *data, const char *device) { - SpaResult res; - SpaProps *props; - SpaPODBuilder b = { 0 }; - SpaPODFrame f[2]; + int res; + struct spa_props *props; + struct spa_pod_builder b = { 0 }; + struct spa_pod_frame f[2]; uint8_t buffer[256]; if ((res = make_node (data, &data->source, "build/spa/plugins/v4l2/libspa-v4l2.so", "v4l2-source")) < 0) { @@ -319,7 +319,7 @@ make_nodes (AppData *data, const char *device) SPA_POD_PROP (&f[1], data->type.props_device, 0, SPA_POD_TYPE_STRING, 1, device ? device : "/dev/video0")); - props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaProps); + props = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_props); if ((res = spa_node_set_props (data->source, props)) < 0) printf ("got set_props error %d\n", res); @@ -327,13 +327,13 @@ make_nodes (AppData *data, const char *device) return res; } -static SpaResult -alloc_buffers (AppData *data) +static int +alloc_buffers (struct data *data) { int i; for (i = 0; i < MAX_BUFFERS; i++) { - SDLBuffer *b = &data->buffers[i]; + struct buffer *b = &data->buffers[i]; SDL_Texture *texture; void *ptr; int stride; @@ -389,15 +389,15 @@ alloc_buffers (AppData *data) return spa_node_port_use_buffers (data->source, SPA_DIRECTION_OUTPUT, 0, data->bp, data->n_buffers); } -static SpaResult -negotiate_formats (AppData *data) +static int +negotiate_formats (struct data *data) { - SpaResult res; - const SpaPortInfo *info; - SpaFormat *format; - SpaPODFrame f[2]; + int res; + const struct spa_port_info *info; + struct spa_format *format; + struct spa_pod_frame f[2]; uint8_t buffer[256]; - SpaPODBuilder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); + struct spa_pod_builder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer)); data->source_output[0] = SPA_PORT_IO_INIT; @@ -422,7 +422,7 @@ negotiate_formats (AppData *data) SPA_POD_PROP (&f[1], data->type.format_video.framerate, 0, SPA_POD_TYPE_FRACTION, 1, 25, 1)); - format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaFormat); + format = SPA_POD_BUILDER_DEREF (&b, f[0].ref, struct spa_format); #endif if ((res = spa_node_port_set_format (data->source, SPA_DIRECTION_OUTPUT, 0, 0, format)) < 0) @@ -458,7 +458,7 @@ negotiate_formats (AppData *data) static void * loop (void *user_data) { - AppData *data = user_data; + struct data *data = user_data; printf ("enter thread\n"); while (data->running) { @@ -467,7 +467,7 @@ loop (void *user_data) /* rebuild */ if (data->rebuild_fds) { for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; data->fds[i].fd = p->fd; data->fds[i].events = p->mask; } @@ -488,7 +488,7 @@ loop (void *user_data) /* after */ for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; p->rmask = 0; if (data->fds[i].revents & POLLIN) p->rmask |= SPA_IO_IN; @@ -500,7 +500,7 @@ loop (void *user_data) p->rmask |= SPA_IO_ERR; } for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; if (p->rmask) p->func (p); } @@ -510,13 +510,13 @@ loop (void *user_data) } static void -run_async_source (AppData *data) +run_async_source (struct data *data) { - SpaResult res; + int res; int err; { - SpaCommand cmd = SPA_COMMAND_INIT (data->type.command_node.Start); + struct spa_command cmd = SPA_COMMAND_INIT (data->type.command_node.Start); if ((res = spa_node_send_command (data->source, &cmd)) < 0) printf ("got error %d\n", res); } @@ -535,7 +535,7 @@ run_async_source (AppData *data) } { - SpaCommand cmd = SPA_COMMAND_INIT (data->type.command_node.Pause); + struct spa_command cmd = SPA_COMMAND_INIT (data->type.command_node.Pause); if ((res = spa_node_send_command (data->source, &cmd)) < 0) printf ("got error %d\n", res); } @@ -544,8 +544,8 @@ run_async_source (AppData *data) int main (int argc, char *argv[]) { - AppData data = { 0 }; - SpaResult res; + struct data data = { 0 }; + int res; const char *str; data.use_buffer = true; @@ -556,7 +556,7 @@ main (int argc, char *argv[]) if ((str = getenv ("SPA_DEBUG"))) data.log->level = atoi (str); - data.data_loop.size = sizeof (SpaLoop); + data.data_loop.size = sizeof (struct spa_loop); data.data_loop.add_source = do_add_source; data.data_loop.update_source = do_update_source; data.data_loop.remove_source = do_remove_source; diff --git a/spa/tools/spa-inspect.c b/spa/tools/spa-inspect.c index 9462f54c1..a3ded06ce 100644 --- a/spa/tools/spa-inspect.c +++ b/spa/tools/spa-inspect.c @@ -31,26 +31,26 @@ #include #include -typedef struct { +struct type { uint32_t node; uint32_t clock; -} Type; +}; -typedef struct { - Type type; +struct data { + struct type type; - SpaSupport support[4]; + struct spa_support support[4]; uint32_t n_support; - SpaTypeMap *map; - SpaLog *log; - SpaLoop loop; -} AppData; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop loop; +}; static void -inspect_port (AppData *data, SpaNode *node, SpaDirection direction, uint32_t port_id) +inspect_port (struct data *data, struct spa_node *node, enum spa_direction direction, uint32_t port_id) { - SpaResult res; - SpaFormat *format; + int res; + struct spa_format *format; uint32_t index; for (index = 0; ; index++) { @@ -65,7 +65,7 @@ inspect_port (AppData *data, SpaNode *node, SpaDirection direction, uint32_t por for (index = 0; ; index++) { - SpaParam *param; + struct spa_param *param; if ((res = spa_node_port_enum_params (node, direction, port_id, index, ¶m)) < 0) { if (res != SPA_RESULT_ENUM_END) @@ -77,12 +77,12 @@ inspect_port (AppData *data, SpaNode *node, SpaDirection direction, uint32_t por } static void -inspect_node (AppData *data, SpaNode *node) +inspect_node (struct data *data, struct spa_node *node) { - SpaResult res; + int res; uint32_t i, n_input, max_input, n_output, max_output; uint32_t *in_ports, *out_ports; - SpaProps *props; + struct spa_props *props; if ((res = spa_node_get_props (node, &props)) < 0) printf ("can't get properties: %d\n", res); @@ -116,10 +116,10 @@ inspect_node (AppData *data, SpaNode *node) } static void -inspect_factory (AppData *data, const SpaHandleFactory *factory) +inspect_factory (struct data *data, const struct spa_handle_factory *factory) { - SpaResult res; - SpaHandle *handle; + int res; + struct spa_handle *handle; void *interface; uint32_t index = 0; @@ -139,7 +139,7 @@ inspect_factory (AppData *data, const SpaHandleFactory *factory) printf ("factory interfaces:\n"); while (true) { - const SpaInterfaceInfo *info; + const struct spa_interface_info *info; uint32_t interface_id; if ((res = spa_handle_factory_enum_interface_info (factory, &info, index)) < 0) { @@ -165,29 +165,29 @@ inspect_factory (AppData *data, const SpaHandleFactory *factory) } } -static SpaResult -do_add_source (SpaLoop *loop, - SpaSource *source) +static int +do_add_source (struct spa_loop *loop, + struct spa_source *source) { return SPA_RESULT_OK; } -static SpaResult -do_update_source (SpaSource *source) +static int +do_update_source (struct spa_source *source) { return SPA_RESULT_OK; } static void -do_remove_source (SpaSource *source) +do_remove_source (struct spa_source *source) { } int main (int argc, char *argv[]) { - AppData data; - SpaResult res; + struct data data; + int res; void *handle; - SpaEnumHandleFactoryFunc enum_func; + spa_handle_factory_enum_func_t enum_func; uint32_t index = 0; if (argc < 2) { @@ -197,7 +197,7 @@ main (int argc, char *argv[]) data.map = spa_type_map_get_default(); data.log = NULL; - data.loop.size = sizeof (SpaLoop); + data.loop.size = sizeof (struct spa_loop); data.loop.add_source = do_add_source; data.loop.update_source = do_update_source; data.loop.remove_source = do_remove_source; @@ -219,13 +219,13 @@ main (int argc, char *argv[]) printf ("can't load %s\n", argv[1]); return -1; } - if ((enum_func = dlsym (handle, "spa_enum_handle_factory")) == NULL) { + if ((enum_func = dlsym (handle, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { printf ("can't find function\n"); return -1; } while (true) { - const SpaHandleFactory *factory; + const struct spa_handle_factory *factory; if ((res = enum_func (&factory, index)) < 0) { if (res != SPA_RESULT_ENUM_END) diff --git a/spa/tools/spa-monitor.c b/spa/tools/spa-monitor.c index fc66ca131..2dacc1eba 100644 --- a/spa/tools/spa-monitor.c +++ b/spa/tools/spa-monitor.c @@ -32,61 +32,61 @@ #include #include -typedef struct { - SpaTypeMonitor monitor; -} Type; +struct type { + struct spa_type_monitor monitor; +}; -typedef struct { - Type type; +struct data { + struct type type; - SpaTypeMap *map; - SpaLog *log; - SpaLoop main_loop; + struct spa_type_map *map; + struct spa_log *log; + struct spa_loop main_loop; - SpaSupport support[3]; + struct spa_support support[3]; uint32_t n_support; unsigned int n_sources; - SpaSource sources[16]; + struct spa_source sources[16]; bool rebuild_fds; struct pollfd fds[16]; unsigned int n_fds; -} AppData; +}; static void -inspect_item (AppData *data, SpaMonitorItem *item) +inspect_item (struct data *data, struct spa_monitor_item *item) { - spa_debug_pod (&item->pod, data->map); + spa_debug_pod (&item->object.pod, data->map); } static void -on_monitor_event (SpaMonitor *monitor, - SpaEvent *event, - void *user_data) +on_monitor_event (struct spa_monitor *monitor, + struct spa_event *event, + void *user_data) { - AppData *data = user_data; + struct data *data = user_data; if (SPA_EVENT_TYPE (event) == data->type.monitor.Added) { fprintf (stderr, "added:\n"); - inspect_item (data, (SpaMonitorItem*)event); + inspect_item (data, (struct spa_monitor_item*)event); } else if (SPA_EVENT_TYPE (event) == data->type.monitor.Removed) { fprintf (stderr, "removed:\n"); - inspect_item (data, (SpaMonitorItem*)event); + inspect_item (data, (struct spa_monitor_item*)event); } else if (SPA_EVENT_TYPE (event) == data->type.monitor.Changed) { fprintf (stderr, "changed:\n"); - inspect_item (data, (SpaMonitorItem*)event); + inspect_item (data, (struct spa_monitor_item*)event); } } -static SpaResult -do_add_source (SpaLoop *loop, - SpaSource *source) +static int +do_add_source (struct spa_loop *loop, + struct spa_source *source) { - AppData *data = SPA_CONTAINER_OF (loop, AppData, main_loop); + struct data *data = SPA_CONTAINER_OF (loop, struct data, main_loop); data->sources[data->n_sources] = *source; data->n_sources++; @@ -95,28 +95,32 @@ do_add_source (SpaLoop *loop, return SPA_RESULT_OK; } -static SpaResult -do_update_source (SpaSource *source) +static int +do_update_source (struct spa_source *source) { return SPA_RESULT_OK; } static void -do_remove_source (SpaSource *source) +do_remove_source (struct spa_source *source) { } +static const struct spa_monitor_callbacks callbacks = { + on_monitor_event, +}; + static void -handle_monitor (AppData *data, SpaMonitor *monitor) +handle_monitor (struct data *data, struct spa_monitor *monitor) { - SpaResult res; + int res; uint32_t index; if (monitor->info) spa_debug_dict (monitor->info); for (index = 0; ; index++) { - SpaMonitorItem *item; + struct spa_monitor_item *item; if ((res = spa_monitor_enum_items (monitor, &item, index)) < 0) { if (res != SPA_RESULT_ENUM_END) @@ -126,7 +130,7 @@ handle_monitor (AppData *data, SpaMonitor *monitor) inspect_item (data, item); } - spa_monitor_set_event_callback (monitor, on_monitor_event, &data); + spa_monitor_set_callbacks (monitor, &callbacks, sizeof (callbacks), &data); while (true) { int i, r; @@ -134,7 +138,7 @@ handle_monitor (AppData *data, SpaMonitor *monitor) /* rebuild */ if (data->rebuild_fds) { for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; data->fds[i].fd = p->fd; data->fds[i].events = p->mask; } @@ -155,7 +159,7 @@ handle_monitor (AppData *data, SpaMonitor *monitor) /* after */ for (i = 0; i < data->n_sources; i++) { - SpaSource *p = &data->sources[i]; + struct spa_source *p = &data->sources[i]; p->func (p); } } @@ -164,15 +168,15 @@ handle_monitor (AppData *data, SpaMonitor *monitor) int main (int argc, char *argv[]) { - AppData data = { 0 }; - SpaResult res; + struct data data = { 0 }; + int res; void *handle; - SpaEnumHandleFactoryFunc enum_func; + spa_handle_factory_enum_func_t enum_func; uint32_t fidx; data.map = spa_type_map_get_default (); data.log = NULL; - data.main_loop.size = sizeof (SpaLoop); + data.main_loop.size = sizeof (struct spa_loop); data.main_loop.add_source = do_add_source; data.main_loop.update_source = do_update_source; data.main_loop.remove_source = do_remove_source; @@ -196,13 +200,13 @@ main (int argc, char *argv[]) printf ("can't load %s\n", argv[1]); return -1; } - if ((enum_func = dlsym (handle, "spa_enum_handle_factory")) == NULL) { + if ((enum_func = dlsym (handle, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { printf ("can't find function\n"); return -1; } for (fidx = 0;; fidx++) { - const SpaHandleFactory *factory; + const struct spa_handle_factory *factory; uint32_t iidx; if ((res = enum_func (&factory, fidx)) < 0) { @@ -212,7 +216,7 @@ main (int argc, char *argv[]) } for (iidx = 0;; iidx++) { - const SpaInterfaceInfo *info; + const struct spa_interface_info *info; if ((res = spa_handle_factory_enum_interface_info (factory, &info, iidx)) < 0) { if (res != SPA_RESULT_ENUM_END) @@ -221,7 +225,7 @@ main (int argc, char *argv[]) } if (!strcmp (info->type, SPA_TYPE__Monitor)) { - SpaHandle *handle; + struct spa_handle *handle; void *interface; handle = calloc (1, factory->size);