From b9c719ac7e28ff89808ba00fcbd7472691f5327b Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 14 Jun 2017 10:16:24 +0200 Subject: [PATCH] log: don't crash when failed to load Improve docs for node --- pipewire/client/log.c | 15 ++++++++------- spa/include/spa/node.h | 42 ++++++++++++++++++++---------------------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/pipewire/client/log.c b/pipewire/client/log.c index 5dbec0ba7..12ea5692d 100644 --- a/pipewire/client/log.c +++ b/pipewire/client/log.c @@ -52,25 +52,25 @@ struct spa_log *pw_spa_log_load(const char *lib, map = support[index].data; } if (map == NULL) { - fprintf(stderr, "no type map"); + fprintf(stderr, "no type map\n"); return NULL; } type_log = spa_type_map_get_id(map, SPA_TYPE__Log); if ((hnd = dlopen(lib, RTLD_NOW)) == NULL) { - fprintf(stderr, "can't load %s: %s", lib, dlerror()); + fprintf(stderr, "can't load %s: %s\n", lib, dlerror()); return NULL; } if ((enum_func = dlsym(hnd, SPA_HANDLE_FACTORY_ENUM_FUNC_NAME)) == NULL) { - fprintf(stderr, "can't find enum function"); + fprintf(stderr, "can't find enum function\n"); goto no_symbol; } for (index = 0;; index++) { if ((res = enum_func(&factory, index)) < 0) { if (res != SPA_RESULT_ENUM_END) - fprintf(stderr, "can't enumerate factories: %d", res); + fprintf(stderr, "can't enumerate factories: %d\n", res); goto enum_failed; } if (strcmp(factory->name, factory_name) == 0) @@ -80,11 +80,11 @@ struct spa_log *pw_spa_log_load(const char *lib, handle = calloc(1, factory->size); if ((res = spa_handle_factory_init(factory, handle, NULL, support, n_support)) < 0) { - fprintf(stderr, "can't make factory instance: %d", res); + fprintf(stderr, "can't make factory instance: %d\n", res); goto init_failed; } if ((res = spa_handle_get_interface(handle, type_log, &iface)) < 0) { - fprintf(stderr, "can't get log interface %d", res); + fprintf(stderr, "can't get log interface %d\n", res); goto interface_failed; } return iface; @@ -111,7 +111,8 @@ struct spa_log *pw_log_get(struct spa_support *support, "logger", support, n_support); - global_log->level = pw_log_level; + if (global_log) + global_log->level = pw_log_level; } return global_log; } diff --git a/spa/include/spa/node.h b/spa/include/spa/node.h index 91c3f811a..b74c9eb5a 100644 --- a/spa/include/spa/node.h +++ b/spa/include/spa/node.h @@ -38,25 +38,22 @@ struct spa_node; #include #include +/** A range */ struct spa_range { - uint64_t offset; - uint32_t min_size; - uint32_t max_size; + uint64_t offset; /**< offset in range */ + uint32_t min_size; /**< minimum size of data */ + uint32_t max_size; /**< maximum size of data */ }; -/** - * struct spa_port_io: - * @status: the status - * @buffer_id: a buffer id - * @range: requested range +/** Port IO area * * IO information for a port on a node. This is allocated * by the host and configured on all ports for which IO is requested. */ struct spa_port_io { - uint32_t status; - uint32_t buffer_id; - struct spa_range range; + uint32_t status; /**< the status code */ + uint32_t buffer_id; /**< a buffer id */ + struct spa_range range; /**< the requested range */ }; #define SPA_PORT_IO_INIT (struct spa_port_io) { SPA_RESULT_NEED_BUFFER, SPA_ID_INVALID, } @@ -67,17 +64,18 @@ struct spa_port_io { * @rate: rate of sequence number increment per second of media data */ 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 */ -#define SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS (1<<3) /* the port can use a provided buffer */ -#define SPA_PORT_INFO_FLAG_IN_PLACE (1<<4) /* the port can process data in-place and will need - * a writable input buffer */ -#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; +#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 */ +#define SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS (1<<3) /**< the port can use a provided buffer */ +#define SPA_PORT_INFO_FLAG_IN_PLACE (1<<4) /**< the port can process data in-place and will need + * a writable input buffer */ +#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; /**< port flags */ + uint32_t rate; /**< rate of sequence numbers on port */ + const struct spa_dict *props; /**< extra port properties */ };