diff --git a/spa/include/spa/defs.h b/spa/include/spa/defs.h index c725ffdf9..62ccfe8f6 100644 --- a/spa/include/spa/defs.h +++ b/spa/include/spa/defs.h @@ -72,6 +72,7 @@ enum spa_result { SPA_RESULT_INCOMPATIBLE_PROPS = -36, SPA_RESULT_INCOMPATIBLE_VERSION = -37, SPA_RESULT_NOT_FOUND = -38, + SPA_RESULT_BUSY = -39, }; #define SPA_ASYNC_BIT (1 << 30) diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 44858bced..7a4f9e30c 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -245,6 +245,7 @@ impl_node_port_set_format(struct spa_node *node, const struct spa_format *format) { struct state *this; + int err; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -270,8 +271,8 @@ impl_node_port_set_format(struct spa_node *node, if (spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio) < 0) return SPA_RESULT_INVALID_MEDIA_TYPE; - if (spa_alsa_set_format(this, &info, flags) < 0) - return SPA_RESULT_ERROR; + if ((err = spa_alsa_set_format(this, &info, flags)) < 0) + return err; this->current_format = info; this->have_format = true; diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index 027688cfd..8f86e440c 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -273,6 +273,7 @@ impl_node_port_set_format(struct spa_node *node, uint32_t port_id, uint32_t flags, const struct spa_format *format) { struct state *this; + int err; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -297,8 +298,8 @@ impl_node_port_set_format(struct spa_node *node, if (spa_format_audio_raw_parse(format, &info.info.raw, &this->type.format_audio) < 0) return SPA_RESULT_INVALID_MEDIA_TYPE; - if (spa_alsa_set_format(this, &info, flags) < 0) - return SPA_RESULT_ERROR; + if ((err = spa_alsa_set_format(this, &info, flags)) < 0) + return err; this->current_format = info; this->have_format = true; @@ -384,7 +385,7 @@ impl_node_port_enum_params(struct spa_node *node, t->param_alloc_buffers.Buffers, ":", t->param_alloc_buffers.size, "i", this->props.min_latency * this->frame_size, ":", t->param_alloc_buffers.stride, "i", 0, - ":", t->param_alloc_buffers.buffers, "i", 2, + ":", t->param_alloc_buffers.buffers, "ir", 2, 2, 1, 32, ":", t->param_alloc_buffers.align, "i", 16); break; diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index aa827dc83..f04472d78 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -14,7 +14,16 @@ #include "alsa-utils.h" -#define CHECK(s,msg) if ((err = (s)) < 0) { spa_log_error(state->log, msg ": %s", snd_strerror(err)); return err; } +static int convert_errnum(struct state *state, int errnum) +{ + switch (errnum) { + case -EBUSY: + return SPA_RESULT_BUSY; + } + return SPA_RESULT_ERROR; +} + +#define CHECK(s,msg) if ((err = (s)) < 0) { spa_log_error(state->log, msg ": %s", snd_strerror(err)); return convert_errnum(state, err); } static int spa_alsa_open(struct state *state) { @@ -128,7 +137,7 @@ spa_alsa_enum_format(struct state *state, struct spa_format **format, const stru opened = state->opened; if ((err = spa_alsa_open(state)) < 0) - return SPA_RESULT_ERROR; + return err; hndl = state->hndl; snd_pcm_hw_params_alloca(¶ms); diff --git a/src/pipewire/mem.c b/src/pipewire/mem.c index 10d42d337..0851435b0 100644 --- a/src/pipewire/mem.c +++ b/src/pipewire/mem.c @@ -74,7 +74,7 @@ static inline int memfd_create(const char *name, unsigned int flags) #endif -#undef USE_MEMFD +#define USE_MEMFD /** Map a memblock * \param mem a memblock diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 97771d614..c3bf27310 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -372,7 +372,7 @@ int pw_port_set_format(struct pw_port *port, uint32_t flags, const struct spa_fo pw_log_debug("port %p: set format %d", port, res); if (!SPA_RESULT_IS_ASYNC(res)) { - if (format == NULL) { + if (format == NULL || res < 0) { if (port->allocated) { free(port->buffers); pw_memblock_free(&port->buffer_mem); diff --git a/src/pipewire/remote.c b/src/pipewire/remote.c index 7d1688575..f582e2367 100644 --- a/src/pipewire/remote.c +++ b/src/pipewire/remote.c @@ -1124,11 +1124,12 @@ static void node_proxy_destroy(void *_data) struct pw_proxy *proxy = (struct pw_proxy*) data->node_proxy; int i; - for (i = 0; i < data->trans->area->max_input_ports; i++) - clear_port(&data->in_ports[i]); - for (i = 0; i < data->trans->area->max_output_ports; i++) - clear_port(&data->out_ports[i]); - + if (data->trans) { + for (i = 0; i < data->trans->area->max_input_ports; i++) + clear_port(&data->in_ports[i]); + for (i = 0; i < data->trans->area->max_output_ports; i++) + clear_port(&data->out_ports[i]); + } clean_transport(proxy); spa_hook_remove(&data->node_listener);