work on separating port mixers

Make it possible to assign an arbitary node as the port mixer.
Also remove dynamically added ports.
Improve negotiation and allocation on the mixer ports
Add some more SSE optimisations
Move float mixer from the audio dsp to the port
Remove pw_node_get_free_port() and do things more explicitly.
Handle mixer ports in client-node
This commit is contained in:
Wim Taymans 2018-07-31 12:23:35 +02:00
parent f55cb422cb
commit ca898a00db
29 changed files with 2422 additions and 1504 deletions

View file

@ -774,6 +774,9 @@ static int impl_node_process(struct spa_node *node)
r = spa_node_process(this->nodes[i]);
spa_log_trace(this->log, NAME " %p: process %d %d", this, i, r);
if (r < 0)
return r;
if (r & SPA_STATUS_HAVE_BUFFER)
ready++;

View file

@ -0,0 +1,269 @@
/* Spa
* Copyright (C) 2018 Wim Taymans <wim.taymans@gmail.com>
*
* 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.
*/
#include <string.h>
#include <stdio.h>
#include <spa/utils/defs.h>
#include <xmmintrin.h>
static void
conv_s16_to_f32d_1_sse(void *data, int n_dst, void *dst[n_dst], const void *src, int n_bytes)
{
const int16_t *s = src;
float **d = (float **) dst;
int n, n_samples;
__m128 out, factor = _mm_set1_ps(1.0f / S16_SCALE);
n_samples = n_bytes / (sizeof(int16_t) * n_dst);
for(n = 0; n_samples--; n++) {
out = _mm_cvtsi32_ss(out, *s);
out = _mm_mul_ss(out, factor);
_mm_store_ss(&d[0][n], out);
s += n_dst;
}
}
static void
conv_s16_to_f32d_2_sse(void *data, int n_dst, void *dst[n_dst], const void *src, int n_bytes)
{
const int16_t *s = src;
float **d = (float **) dst;
int n, n_samples, unrolled;
__m128i in, t[2];
__m128 out[2], factor = _mm_set1_ps(1.0f / S16_SCALE);
n_samples = n_bytes / (sizeof(int16_t) * n_dst);
unrolled = n_samples / 4;
n_samples = n_samples & 3;
for(n = 0; unrolled--; n += 4) {
in = _mm_loadu_si128((__m128i*)s);
t[0] = _mm_slli_epi32(in, 16);
t[0] = _mm_srai_epi32(t[0], 16);
t[1] = _mm_srai_epi32(in, 16);
out[0] = _mm_cvtepi32_ps(t[0]);
out[0] = _mm_mul_ps(out[0], factor);
out[1] = _mm_cvtepi32_ps(t[1]);
out[1] = _mm_mul_ps(out[1], factor);
_mm_storeu_ps(&d[0][n], out[0]);
_mm_storeu_ps(&d[1][n], out[1]);
s += 4*n_dst;
}
for(; n_samples--; n++) {
out[0] = _mm_cvtsi32_ss(out[0], s[0]);
out[0] = _mm_mul_ss(out[0], factor);
out[1] = _mm_cvtsi32_ss(out[1], s[1]);
out[1] = _mm_mul_ss(out[1], factor);
_mm_store_ss(&d[0][n], out[0]);
_mm_store_ss(&d[1][n], out[1]);
s += n_dst;
}
}
static void
conv_s16_to_f32d_sse(void *data, int n_dst, void *dst[n_dst], int n_src, const void *src[n_src], int n_bytes)
{
const int16_t *s = src[0];
int i = 0;
for(; i + 1 < n_dst; i += 2)
conv_s16_to_f32d_2_sse(data, n_dst, &dst[i], &s[i], n_bytes);
for(; i < n_dst; i++)
conv_s16_to_f32d_1_sse(data, n_dst, &dst[i], &s[i], n_bytes);
}
static void
conv_f32d_to_s32_1_sse(void *data, void *dst, int n_src, const void *src[n_src], int n_bytes)
{
const float **s = (const float **) src;
int32_t *d = dst;
int n, n_samples, unrolled;
__m128 in[1];
__m128i out[4];
__m128 int_max = _mm_set1_ps(S24_MAX_F);
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
n_samples = n_bytes / sizeof(float);
unrolled = n_samples / 4;
n_samples = n_samples & 3;
for(n = 0; unrolled--; n += 4) {
in[0] = _mm_mul_ps(_mm_loadu_ps(&s[0][n]), int_max);
in[0] = _mm_min_ps(int_max, _mm_max_ps(in[0], int_min));
out[0] = _mm_slli_epi32(_mm_cvttps_epi32(in[0]), 8);
out[1] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(0, 3, 2, 1));
out[2] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(1, 0, 3, 2));
out[3] = _mm_shuffle_epi32(out[0], _MM_SHUFFLE(2, 1, 0, 3));
*(d + 0*n_src) = _mm_cvtsi128_si32(out[0]);
*(d + 1*n_src) = _mm_cvtsi128_si32(out[1]);
*(d + 2*n_src) = _mm_cvtsi128_si32(out[2]);
*(d + 3*n_src) = _mm_cvtsi128_si32(out[3]);
d += 4*n_src;
}
for(; n_samples--; n++) {
in[0] = _mm_load_ss(&s[0][n]);
in[0] = _mm_mul_ss(in[0], int_max);
in[0] = _mm_min_ss(int_max, _mm_max_ss(in[0], int_min));
*d = _mm_cvttss_si32(in[0]) << 8;
d += n_src;
}
}
static void
conv_f32d_to_s32_2_sse(void *data, void *dst, int n_src, const void *src[n_src], int n_bytes)
{
const float **s = (const float **) src;
int32_t *d = dst;
int n, n_samples, unrolled;
__m128 in[2];
__m128i out[2], t[2];
__m128 int_max = _mm_set1_ps(S24_MAX_F);
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
n_samples = n_bytes / sizeof(float);
unrolled = n_samples / 4;
n_samples = n_samples & 3;
for(n = 0; unrolled--; n += 4) {
in[0] = _mm_mul_ps(_mm_loadu_ps(&s[0][n]), int_max);
in[1] = _mm_mul_ps(_mm_loadu_ps(&s[1][n]), int_max);
in[0] = _mm_min_ps(int_max, _mm_max_ps(in[0], int_min));
in[1] = _mm_min_ps(int_max, _mm_max_ps(in[1], int_min));
out[0] = _mm_slli_epi32(_mm_cvttps_epi32(in[0]), 8);
out[1] = _mm_slli_epi32(_mm_cvttps_epi32(in[1]), 8);
t[0] = _mm_unpacklo_epi32(out[0], out[1]);
t[1] = _mm_shuffle_epi32(t[0], _MM_SHUFFLE(0, 0, 2, 2));
t[2] = _mm_unpackhi_epi32(out[0], out[1]);
t[3] = _mm_shuffle_epi32(t[2], _MM_SHUFFLE(0, 0, 2, 2));
_mm_storel_epi64((__m128i*)(d + 0*n_src), t[0]);
_mm_storel_epi64((__m128i*)(d + 1*n_src), t[1]);
_mm_storel_epi64((__m128i*)(d + 2*n_src), t[2]);
_mm_storel_epi64((__m128i*)(d + 3*n_src), t[3]);
d += 4*n_src;
}
for(; n_samples--; n++) {
in[0] = _mm_load_ss(&s[0][n]);
in[1] = _mm_load_ss(&s[1][n]);
in[0] = _mm_unpacklo_ps(in[0], in[1]);
in[0] = _mm_mul_ps(in[0], int_max);
in[0] = _mm_min_ps(int_max, _mm_max_ps(in[0], int_min));
out[0] = _mm_slli_epi32(_mm_cvttps_epi32(in[0]), 8);
_mm_storel_epi64((__m128i*)d, out[0]);
d += n_src;
}
}
static void
conv_f32d_to_s32_4_sse(void *data, void *dst, int n_src, const void *src[n_src], int n_bytes)
{
const float **s = (const float **) src;
int32_t *d = dst;
int n, n_samples, unrolled;
__m128 in[4];
__m128i out[4], t[4];
__m128 int_max = _mm_set1_ps(S24_MAX_F);
__m128 int_min = _mm_sub_ps(_mm_setzero_ps(), int_max);
n_samples = n_bytes / sizeof(float);
unrolled = n_samples / 4;
n_samples = n_samples & 3;
for(n = 0; unrolled--; n += 4) {
in[0] = _mm_mul_ps(_mm_loadu_ps(&s[0][n]), int_max);
in[1] = _mm_mul_ps(_mm_loadu_ps(&s[1][n]), int_max);
in[2] = _mm_mul_ps(_mm_loadu_ps(&s[2][n]), int_max);
in[3] = _mm_mul_ps(_mm_loadu_ps(&s[3][n]), int_max);
in[0] = _mm_min_ps(int_max, _mm_max_ps(in[0], int_min));
in[1] = _mm_min_ps(int_max, _mm_max_ps(in[1], int_min));
in[2] = _mm_min_ps(int_max, _mm_max_ps(in[2], int_min));
in[3] = _mm_min_ps(int_max, _mm_max_ps(in[3], int_min));
out[0] = _mm_slli_epi32(_mm_cvttps_epi32(in[0]), 8);
out[1] = _mm_slli_epi32(_mm_cvttps_epi32(in[1]), 8);
out[2] = _mm_slli_epi32(_mm_cvttps_epi32(in[2]), 8);
out[3] = _mm_slli_epi32(_mm_cvttps_epi32(in[3]), 8);
/* transpose */
t[0] = _mm_unpacklo_epi32(out[0], out[1]);
t[1] = _mm_unpacklo_epi32(out[2], out[3]);
t[2] = _mm_unpackhi_epi32(out[0], out[1]);
t[3] = _mm_unpackhi_epi32(out[2], out[3]);
out[0] = _mm_unpacklo_epi64(t[0], t[1]);
out[1] = _mm_unpackhi_epi64(t[0], t[1]);
out[2] = _mm_unpacklo_epi64(t[2], t[3]);
out[3] = _mm_unpackhi_epi64(t[2], t[3]);
_mm_storeu_si128((__m128i*)(d + 0), out[0]);
_mm_storeu_si128((__m128i*)(d + 4), out[1]);
_mm_storeu_si128((__m128i*)(d + 8), out[2]);
_mm_storeu_si128((__m128i*)(d + 12), out[3]);
d += 4*n_src;
}
for(; n_samples--; n++) {
in[0] = _mm_load_ss(&s[0][n]);
in[1] = _mm_load_ss(&s[1][n]);
in[2] = _mm_load_ss(&s[2][n]);
in[3] = _mm_load_ss(&s[3][n]);
in[0] = _mm_unpacklo_ps(in[0], in[2]);
in[1] = _mm_unpacklo_ps(in[1], in[3]);
in[0] = _mm_unpacklo_ps(in[0], in[1]);
in[0] = _mm_mul_ps(in[0], int_max);
in[0] = _mm_min_ps(int_max, _mm_max_ps(in[0], int_min));
out[0] = _mm_slli_epi32(_mm_cvttps_epi32(in[0]), 8);
_mm_storeu_si128((__m128i*)d, out[0]);
d += n_src;
}
}
static void
conv_f32d_to_s32_sse(void *data, int n_dst, void *dst[n_dst], int n_src, const void *src[n_src], int n_bytes)
{
int32_t *d = dst[0];
int i = 0;
for(; i + 3 < n_src; i += 4)
conv_f32d_to_s32_4_sse(data, &d[i], n_src, &src[i], n_bytes);
for(; i + 1 < n_src; i += 2)
conv_f32d_to_s32_2_sse(data, &d[i], n_src, &src[i], n_bytes);
for(; i < n_src; i++)
conv_f32d_to_s32_1_sse(data, &d[i], n_src, &src[i], n_bytes);
}

View file

@ -33,12 +33,17 @@
#define S24_MIN -8388607
#define S24_MAX 8388607
#define S24_MAX_F 8388607.0f
#define S24_SCALE 8388607
#define S32_MIN -2147483647
#define S32_MAX 2147483647
#define S32_SCALE 2147483647
#if defined (__SSE__)
#include "fmt-ops-sse.c"
#endif
static void
conv_copy(void *data, int n_dst, void *dst[n_dst], int n_src, const void *src[n_src], int n_bytes)
{
@ -430,6 +435,7 @@ conv_f32d_to_s32(void *data, int n_dst, void *dst[n_dst], int n_src, const void
}
}
#define F32_TO_S24(v) \
({ \
typeof(v) _v = (v); \
@ -662,6 +668,8 @@ typedef void (*convert_func_t) (void *data, int n_dst, void *dst[n_dst],
static const struct conv_info {
off_t src_fmt;
off_t dst_fmt;
#define FEATURE_SSE (1<<0)
uint32_t features;
convert_func_t i2i;
convert_func_t i2d;
@ -670,75 +678,86 @@ static const struct conv_info {
{
/* to f32 */
{ offsetof(struct spa_type_audio_format, U8),
offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, F32), 0,
conv_u8_to_f32, conv_u8_to_f32d, conv_u8d_to_f32 },
#if defined (__SSE2__)
{ offsetof(struct spa_type_audio_format, S16),
offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, F32), FEATURE_SSE,
conv_s16_to_f32, conv_s16_to_f32d_sse, conv_s16d_to_f32 },
#endif
{ offsetof(struct spa_type_audio_format, S16),
offsetof(struct spa_type_audio_format, F32), 0,
conv_s16_to_f32, conv_s16_to_f32d, conv_s16d_to_f32 },
{ offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, F32), 0,
conv_copy, deinterleave_32, interleave_32 },
{ offsetof(struct spa_type_audio_format, S32),
offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, F32), 0,
conv_s32_to_f32, conv_s32_to_f32d, conv_s32d_to_f32 },
{ offsetof(struct spa_type_audio_format, S24),
offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, F32), 0,
conv_s24_to_f32, conv_s24_to_f32d, conv_s24d_to_f32 },
{ offsetof(struct spa_type_audio_format, S24_32),
offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, F32), 0,
conv_s24_32_to_f32, conv_s24_32_to_f32d, conv_s24_32d_to_f32 },
/* from f32 */
{ offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, U8),
offsetof(struct spa_type_audio_format, U8), 0,
conv_f32_to_u8, conv_f32_to_u8d, conv_f32d_to_u8 },
{ offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, S16),
offsetof(struct spa_type_audio_format, S16), 0,
conv_f32_to_s16, conv_f32_to_s16d, conv_f32d_to_s16 },
#if defined (__SSE2__)
{ offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, S32),
offsetof(struct spa_type_audio_format, S32), FEATURE_SSE,
conv_f32_to_s32, conv_f32_to_s32d, conv_f32d_to_s32_sse },
#endif
{ offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, S32), 0,
conv_f32_to_s32, conv_f32_to_s32d, conv_f32d_to_s32 },
{ offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, S24),
offsetof(struct spa_type_audio_format, S24), 0,
conv_f32_to_s24, conv_f32_to_s24d, conv_f32d_to_s24 },
{ offsetof(struct spa_type_audio_format, F32),
offsetof(struct spa_type_audio_format, S24_32),
offsetof(struct spa_type_audio_format, S24_32), 0,
conv_f32_to_s24_32, conv_f32_to_s24_32d, conv_f32d_to_s24_32 },
/* u8 */
{ offsetof(struct spa_type_audio_format, U8),
offsetof(struct spa_type_audio_format, U8),
offsetof(struct spa_type_audio_format, U8), 0,
conv_copy, deinterleave_8, interleave_8 },
/* s16 */
{ offsetof(struct spa_type_audio_format, S16),
offsetof(struct spa_type_audio_format, S16),
offsetof(struct spa_type_audio_format, S16), 0,
conv_copy, deinterleave_16, interleave_16 },
/* s32 */
{ offsetof(struct spa_type_audio_format, S32),
offsetof(struct spa_type_audio_format, S32),
offsetof(struct spa_type_audio_format, S32), 0,
conv_copy, deinterleave_32, interleave_32 },
/* s24 */
{ offsetof(struct spa_type_audio_format, S24),
offsetof(struct spa_type_audio_format, S24),
offsetof(struct spa_type_audio_format, S24), 0,
conv_copy, deinterleave_24, interleave_24 },
/* s24_32 */
{ offsetof(struct spa_type_audio_format, S24_32),
offsetof(struct spa_type_audio_format, S24_32),
offsetof(struct spa_type_audio_format, S24_32), 0,
conv_copy, deinterleave_32, interleave_32 },
};
static const struct conv_info *find_conv_info(struct spa_type_audio_format *audio_format,
uint32_t src_fmt, uint32_t dst_fmt)
uint32_t src_fmt, uint32_t dst_fmt, uint32_t features)
{
int i;
for (i = 0; i < SPA_N_ELEMENTS(conv_table); i++) {
if (*SPA_MEMBER(audio_format, conv_table[i].src_fmt, uint32_t) == src_fmt &&
*SPA_MEMBER(audio_format, conv_table[i].dst_fmt, uint32_t) == dst_fmt)
*SPA_MEMBER(audio_format, conv_table[i].dst_fmt, uint32_t) == dst_fmt &&
(conv_table[i].features == 0 || (conv_table[i].features & features) != 0))
return &conv_table[i];
}
return NULL;

View file

@ -160,9 +160,9 @@ struct impl {
bool started;
const struct conv_info *conv[2];
convert_func_t convert;
float empty[4096];
};
#define CHECK_FREE_PORT(this,d,id) (id < MAX_PORTS && !GET_PORT(this,d,id)->valid)
@ -196,6 +196,7 @@ static int setup_convert(struct impl *this)
uint32_t src_fmt, dst_fmt;
struct type *t = &this->type;
struct format informat, outformat;
const struct conv_info *conv;
if (collect_format(this, SPA_DIRECTION_INPUT, &informat) < 0)
return -1;
@ -222,19 +223,21 @@ static int setup_convert(struct impl *this)
return -EINVAL;
/* find fast path */
this->conv[0] = find_conv_info(&t->audio_format, src_fmt, dst_fmt);
if (this->conv[0] != NULL) {
conv = find_conv_info(&t->audio_format, src_fmt, dst_fmt, FEATURE_SSE);
if (conv != NULL) {
spa_log_info(this->log, NAME " %p: got converter features %08x", this,
conv->features);
if (informat.format.info.raw.layout == SPA_AUDIO_LAYOUT_INTERLEAVED) {
if (outformat.format.info.raw.layout == SPA_AUDIO_LAYOUT_INTERLEAVED)
this->convert = this->conv[0]->i2i;
this->convert = conv->i2i;
else
this->convert = this->conv[0]->i2d;
this->convert = conv->i2d;
}
else {
if (outformat.format.info.raw.layout == SPA_AUDIO_LAYOUT_INTERLEAVED)
this->convert = this->conv[0]->d2i;
this->convert = conv->d2i;
else
this->convert = this->conv[0]->i2i;
this->convert = conv->i2i;
}
return 0;
}
@ -972,18 +975,15 @@ static int process_merge(struct impl *this)
for (i = 0; i < n_ins; i++) {
inport = GET_IN_PORT(this, i);
inio = inport->io;
if (inio == NULL)
if ((inio = inport->io) == NULL ||
inio->status != SPA_STATUS_HAVE_BUFFER ||
inio->buffer_id >= inport->n_buffers)
continue;
spa_log_trace(this->log, NAME " %p: %d %p %d %d %d", this, i,
inio, inio->status, inio->buffer_id, inport->stride);
if (inio->status != SPA_STATUS_HAVE_BUFFER)
continue;
if (inio->buffer_id >= inport->n_buffers)
continue;
inbuf = &inport->buffers[inio->buffer_id];
inb = inbuf->outbuf;
@ -1063,13 +1063,14 @@ static int process_split(struct impl *this)
outport = GET_OUT_PORT(this, i);
outio = outport->io;
if (outio == NULL)
continue;
goto empty;
spa_log_trace(this->log, NAME " %p: %d %p %d %d %d", this, i,
outio, outio->status, outio->buffer_id, outport->stride);
if (outio->status == SPA_STATUS_HAVE_BUFFER) {
res |= SPA_STATUS_HAVE_BUFFER;
continue;
goto empty;
}
if (outio->buffer_id < outport->n_buffers) {
@ -1077,8 +1078,12 @@ static int process_split(struct impl *this)
outio->buffer_id = SPA_ID_INVALID;
}
if ((outbuf = peek_buffer(this, outport)) == NULL)
return outio->status = -EPIPE;
if ((outbuf = peek_buffer(this, outport)) == NULL) {
outio->status = -EPIPE;
empty:
dst_datas[n_dst_datas++] = this->empty;
continue;
}
outb = outbuf->outbuf;

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@ audioconvert_sources = ['fmtconvert.c',
'channelmix.c',
'resample.c',
'splitter.c',
'merger.c',
'audioconvert.c',
'plugin.c']

View file

@ -26,6 +26,7 @@ extern const struct spa_handle_factory spa_fmtconvert_factory;
extern const struct spa_handle_factory spa_channelmix_factory;
extern const struct spa_handle_factory spa_resample_factory;
extern const struct spa_handle_factory spa_splitter_factory;
extern const struct spa_handle_factory spa_merger_factory;
int
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
@ -49,6 +50,9 @@ spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *ind
case 4:
*factory = &spa_splitter_factory;
break;
case 5:
*factory = &spa_merger_factory;
break;
default:
return 0;
}

View file

@ -89,8 +89,6 @@ struct port {
struct spa_io_control_range *ctrl;
struct spa_port_info info;
struct spa_dict info_props;
struct spa_dict_item info_props_items[2];
bool have_format;
@ -256,10 +254,6 @@ static int impl_node_add_port(struct spa_node *node, enum spa_direction directio
port->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
SPA_PORT_INFO_FLAG_REMOVABLE;
port->info_props_items[0] = SPA_DICT_ITEM_INIT("port.dsp", "32 bit float mono audio");
port->info_props = SPA_DICT_INIT(port->info_props_items, 1);
port->info.props = &port->info_props;
this->port_count++;
if (this->last_port <= port_id)
this->last_port = port_id + 1;

View file

@ -943,71 +943,6 @@ static int mix_output(struct impl *this, size_t n_bytes)
return SPA_STATUS_HAVE_BUFFER;
}
#if 0
static int impl_node_process_input(struct spa_node *node)
{
struct impl *this;
uint32_t i;
struct port *outport;
size_t min_queued = SIZE_MAX;
struct spa_io_buffers *outio;
spa_return_val_if_fail(node != NULL, -EINVAL);
this = SPA_CONTAINER_OF(node, struct impl, node);
outport = GET_OUT_PORT(this, 0);
outio = outport->io;
spa_return_val_if_fail(outio != NULL, -EIO);
spa_log_trace(this->log, NAME " %p: status %d", this, outio->status);
if (outio->status == SPA_STATUS_HAVE_BUFFER)
return SPA_STATUS_HAVE_BUFFER;
for (i = 0; i < this->last_port; i++) {
struct port *inport = GET_IN_PORT(this, i);
struct spa_io_buffers *inio;
if ((inio = inport->io) == NULL)
continue;
if (inport->queued_bytes == 0 &&
inio->status == SPA_STATUS_HAVE_BUFFER && inio->buffer_id < inport->n_buffers) {
struct buffer *b = &inport->buffers[inio->buffer_id];
struct spa_data *d = b->outbuf->datas;
if (!b->outstanding) {
spa_log_warn(this->log, NAME " %p: buffer %u in use", this,
inio->buffer_id);
inio->status = -EINVAL;
continue;
}
b->outstanding = false;
inio->buffer_id = SPA_ID_INVALID;
inio->status = SPA_STATUS_OK;
spa_list_append(&inport->queue, &b->link);
inport->queued_bytes = SPA_MIN(d[0].chunk->size, d[0].maxsize);
spa_log_trace(this->log, NAME " %p: queue buffer %d on port %d %zd %zd",
this, b->outbuf->id, i, inport->queued_bytes, min_queued);
}
if (inport->queued_bytes > 0 && inport->queued_bytes < min_queued)
min_queued = inport->queued_bytes;
}
if (min_queued != SIZE_MAX && min_queued > 0) {
outio->status = mix_output(this, min_queued);
} else {
outio->status = SPA_STATUS_NEED_BUFFER;
}
return outio->status;
}
#endif
static int impl_node_process(struct spa_node *node)
{
struct impl *this;
@ -1034,6 +969,7 @@ static int impl_node_process(struct spa_node *node)
recycle_buffer(this, outio->buffer_id);
outio->buffer_id = SPA_ID_INVALID;
}
/* produce more output if possible */
for (i = 0; i < this->last_port; i++) {
struct port *inport = GET_IN_PORT(this, i);