mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-22 06:59:59 -05:00
improve error handling
Make sure we free properties we take ownership of. Add some more return values to functions that can fail.
This commit is contained in:
parent
00ea15dc1f
commit
d1241e2c1c
17 changed files with 241 additions and 158 deletions
|
|
@ -222,11 +222,11 @@ struct spa_loop_utils_methods {
|
|||
struct spa_source *(*add_idle) (void *object,
|
||||
bool enabled,
|
||||
spa_source_idle_func_t func, void *data);
|
||||
void (*enable_idle) (void *object, struct spa_source *source, bool enabled);
|
||||
int (*enable_idle) (void *object, struct spa_source *source, bool enabled);
|
||||
|
||||
struct spa_source *(*add_event) (void *object,
|
||||
spa_source_event_func_t func, void *data);
|
||||
void (*signal_event) (void *object, struct spa_source *source);
|
||||
int (*signal_event) (void *object, struct spa_source *source);
|
||||
|
||||
struct spa_source *(*add_timer) (void *object,
|
||||
spa_source_timer_func_t func, void *data);
|
||||
|
|
@ -276,9 +276,9 @@ struct spa_loop_utils_methods {
|
|||
#define spa_loop_utils_add_io(l,...) spa_loop_utils_method_s(l,add_io,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_update_io(l,...) spa_loop_utils_method_r(l,update_io,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_add_idle(l,...) spa_loop_utils_method_s(l,add_idle,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_enable_idle(l,...) spa_loop_utils_method_v(l,enable_idle,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_enable_idle(l,...) spa_loop_utils_method_r(l,enable_idle,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_add_event(l,...) spa_loop_utils_method_s(l,add_event,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_signal_event(l,...) spa_loop_utils_method_v(l,signal_event,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_signal_event(l,...) spa_loop_utils_method_r(l,signal_event,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_add_timer(l,...) spa_loop_utils_method_s(l,add_timer,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_update_timer(l,...) spa_loop_utils_method_r(l,update_timer,0,__VA_ARGS__)
|
||||
#define spa_loop_utils_add_signal(l,...) spa_loop_utils_method_s(l,add_signal,0,__VA_ARGS__)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ struct invoke_item {
|
|||
int res;
|
||||
};
|
||||
|
||||
static void loop_signal_event(void *object, struct spa_source *source);
|
||||
static int loop_signal_event(void *object, struct spa_source *source);
|
||||
|
||||
struct impl {
|
||||
struct spa_handle handle;
|
||||
|
|
@ -361,10 +361,10 @@ static void source_idle_func(struct spa_source *source)
|
|||
}
|
||||
|
||||
|
||||
static void loop_enable_idle(void *object, struct spa_source *source, bool enabled)
|
||||
static int loop_enable_idle(void *object, struct spa_source *source, bool enabled)
|
||||
{
|
||||
struct source_impl *impl = SPA_CONTAINER_OF(source, struct source_impl, source);
|
||||
int res;
|
||||
int res = 0;
|
||||
|
||||
if (enabled && !impl->enabled) {
|
||||
if ((res = spa_system_eventfd_write(impl->impl->system, source->fd, 1)) < 0)
|
||||
|
|
@ -377,6 +377,7 @@ static void loop_enable_idle(void *object, struct spa_source *source, bool enabl
|
|||
source, source->fd, spa_strerror(res));
|
||||
}
|
||||
impl->enabled = enabled;
|
||||
return res;
|
||||
}
|
||||
static struct spa_source *loop_add_idle(void *object,
|
||||
bool enabled, spa_source_idle_func_t func, void *data)
|
||||
|
|
@ -474,7 +475,7 @@ err_free:
|
|||
goto out;
|
||||
}
|
||||
|
||||
static void loop_signal_event(void *object, struct spa_source *source)
|
||||
static int loop_signal_event(void *object, struct spa_source *source)
|
||||
{
|
||||
struct source_impl *impl = SPA_CONTAINER_OF(source, struct source_impl, source);
|
||||
int res;
|
||||
|
|
@ -482,6 +483,7 @@ static void loop_signal_event(void *object, struct spa_source *source)
|
|||
if ((res = spa_system_eventfd_write(impl->impl->system, source->fd, 1)) < 0)
|
||||
spa_log_warn(impl->impl->log, NAME " %p: failed to write event fd %d: %s",
|
||||
source, source->fd, spa_strerror(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
static void source_timer_func(struct spa_source *source)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue