mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
Use errno for result errors
Make new enumeration for data transport status and use errno style error numbers for errors.
This commit is contained in:
parent
dda28b1589
commit
6fb0f580ea
86 changed files with 2019 additions and 1988 deletions
|
|
@ -84,11 +84,11 @@ struct impl {
|
|||
static int impl_udev_open(struct impl *this)
|
||||
{
|
||||
if (this->udev != NULL)
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
|
||||
this->udev = udev_new();
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *path_get_card_id(const char *path)
|
||||
|
|
@ -350,7 +350,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
int res;
|
||||
struct impl *this;
|
||||
|
||||
spa_return_val_if_fail(monitor != NULL, SPA_RESULT_INVALID_ARGUMENTS);
|
||||
spa_return_val_if_fail(monitor != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
udev_monitor_unref(this->umonitor);
|
||||
this->umonitor = udev_monitor_new_from_netlink(this->udev, "udev");
|
||||
if (this->umonitor == NULL)
|
||||
return SPA_RESULT_ERROR;
|
||||
return -ENODEV;
|
||||
|
||||
udev_monitor_filter_add_match_subsystem_devtype(this->umonitor, "sound", NULL);
|
||||
udev_monitor_enable_receiving(this->umonitor);
|
||||
|
|
@ -380,25 +380,25 @@ impl_monitor_set_callbacks(struct spa_monitor *monitor,
|
|||
spa_loop_remove_source(this->main_loop, &this->source);
|
||||
}
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_monitor_enum_items(struct spa_monitor *monitor,
|
||||
struct spa_monitor_item **item,
|
||||
uint32_t index)
|
||||
uint32_t *index)
|
||||
{
|
||||
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);
|
||||
spa_return_val_if_fail(monitor != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(item != NULL, -EINVAL);
|
||||
|
||||
this = SPA_CONTAINER_OF(monitor, struct impl, monitor);
|
||||
|
||||
if ((res = impl_udev_open(this)) < 0)
|
||||
return res;
|
||||
|
||||
if (index == 0 || this->index > index) {
|
||||
if (*index == 0 || this->index > *index) {
|
||||
if (this->enumerate)
|
||||
udev_enumerate_unref(this->enumerate);
|
||||
this->enumerate = udev_enumerate_new(this->udev);
|
||||
|
|
@ -409,13 +409,13 @@ static int impl_monitor_enum_items(struct spa_monitor *monitor,
|
|||
this->devices = udev_enumerate_get_list_entry(this->enumerate);
|
||||
this->index = 0;
|
||||
}
|
||||
while (index > this->index && this->devices) {
|
||||
while (*index > this->index && this->devices) {
|
||||
this->devices = udev_list_entry_get_next(this->devices);
|
||||
this->index++;
|
||||
}
|
||||
again:
|
||||
if (this->devices == NULL)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
return 0;
|
||||
|
||||
if (this->dev == NULL) {
|
||||
this->dev = udev_device_new_from_syspath(this->udev, udev_list_entry_get_name(this->devices));
|
||||
|
|
@ -435,10 +435,11 @@ static int impl_monitor_enum_items(struct spa_monitor *monitor,
|
|||
}
|
||||
|
||||
this->index++;
|
||||
(*index)++;
|
||||
|
||||
*item = this->item;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct spa_monitor impl_monitor = {
|
||||
|
|
@ -452,17 +453,17 @@ static int impl_get_interface(struct spa_handle *handle, uint32_t interface_id,
|
|||
{
|
||||
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);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(interface != NULL, -EINVAL);
|
||||
|
||||
this = (struct impl *) handle;
|
||||
|
||||
if (interface_id == this->type.monitor.Monitor)
|
||||
*interface = &this->monitor;
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_INTERFACE;
|
||||
return -ENOENT;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int impl_clear(struct spa_handle *handle)
|
||||
|
|
@ -478,7 +479,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
if (this->udev)
|
||||
udev_unref(this->udev);
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
@ -491,8 +492,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
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);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(handle != NULL, -EINVAL);
|
||||
|
||||
handle->get_interface = impl_get_interface;
|
||||
handle->clear = impl_clear;
|
||||
|
|
@ -509,18 +510,18 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
}
|
||||
if (this->map == NULL) {
|
||||
spa_log_error(this->log, "an id-map is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
if (this->main_loop == NULL) {
|
||||
spa_log_error(this->log, "a main-loop is needed");
|
||||
return SPA_RESULT_ERROR;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
init_type(&this->type, this->map);
|
||||
|
||||
this->monitor = impl_monitor;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_interface_info impl_interfaces[] = {
|
||||
|
|
@ -530,16 +531,17 @@ static const struct spa_interface_info impl_interfaces[] = {
|
|||
static int
|
||||
impl_enum_interface_info(const struct spa_handle_factory *factory,
|
||||
const struct spa_interface_info **info,
|
||||
uint32_t index)
|
||||
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);
|
||||
spa_return_val_if_fail(factory != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(info != NULL, -EINVAL);
|
||||
spa_return_val_if_fail(index != NULL, -EINVAL);
|
||||
|
||||
if (index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return SPA_RESULT_ENUM_END;
|
||||
if (*index >= SPA_N_ELEMENTS(impl_interfaces))
|
||||
return 0;
|
||||
|
||||
*info = &impl_interfaces[index];
|
||||
return SPA_RESULT_OK;
|
||||
*info = &impl_interfaces[(*index)++];
|
||||
return 1;
|
||||
}
|
||||
|
||||
const struct spa_handle_factory spa_alsa_monitor_factory = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue