mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
resample: return the number of consumed samples
We need to return the number of consumed samples, even when we don't start from the first sample in the buffer. Add some more logging.
This commit is contained in:
parent
a44ee31abe
commit
dc01b294a2
4 changed files with 18 additions and 10 deletions
|
|
@ -116,7 +116,7 @@ DEFINE_RESAMPLER(full,arch) \
|
|||
inner_product_##arch(&d[o], ip, taps, n_taps); \
|
||||
} \
|
||||
} \
|
||||
*in_len = index - data->index; \
|
||||
*in_len = index; \
|
||||
*out_len = o; \
|
||||
data->index = index; \
|
||||
data->phase = phase; \
|
||||
|
|
@ -163,7 +163,7 @@ DEFINE_RESAMPLER(inter,arch) \
|
|||
inner_product_ip_##arch(&d[o], ip, t0, t1, x, n_taps); \
|
||||
} \
|
||||
} \
|
||||
*in_len = index - data->index; \
|
||||
*in_len = index; \
|
||||
*out_len = o; \
|
||||
data->index = index; \
|
||||
data->phase = phase; \
|
||||
|
|
|
|||
|
|
@ -142,8 +142,8 @@ static void impl_native_process(struct resample *r,
|
|||
const float **s = (const float **)src;
|
||||
uint32_t c, refill, hist, in, out, remain;
|
||||
|
||||
out = refill = in = 0;
|
||||
hist = data->hist;
|
||||
refill = 0;
|
||||
|
||||
if (hist) {
|
||||
/* first work on the history if any. */
|
||||
|
|
@ -169,37 +169,42 @@ static void impl_native_process(struct resample *r,
|
|||
in = hist + refill;
|
||||
out = *out_len;
|
||||
data->func(r, (const void**)history, &in, dst, 0, &out);
|
||||
spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d idx:%d hist:%d",
|
||||
r, hist + refill, in, *out_len, out, data->index, hist);
|
||||
} else {
|
||||
out = in = 0;
|
||||
}
|
||||
|
||||
if (data->index >= hist) {
|
||||
if (in >= hist) {
|
||||
/* we are past the history and can now work on the new
|
||||
* input data */
|
||||
data->index -= hist;
|
||||
in = *in_len;
|
||||
data->func(r, src, &in, dst, out, out_len);
|
||||
spa_log_trace_fp(r->log, "native %p: in:%d/%d out %d/%d",
|
||||
r, *in_len, in, *out_len, out);
|
||||
|
||||
remain = *in_len - in;
|
||||
if (remain < n_taps) {
|
||||
if (remain > 0 && remain < n_taps) {
|
||||
/* not enough input data remaining for more output,
|
||||
* copy to history */
|
||||
for (c = 0; c < r->channels; c++)
|
||||
memcpy(history[c], &s[c][in], remain * sizeof(float));
|
||||
} else {
|
||||
/* we have enough input data remaining to produce
|
||||
* more output ask to resubmit. else we copy the
|
||||
* remainder to the history */
|
||||
* more output ask to resubmit. */
|
||||
remain = 0;
|
||||
*in_len = in;
|
||||
}
|
||||
} else {
|
||||
/* we are still working on the history */
|
||||
*out_len = out;
|
||||
remain = hist - in;
|
||||
if (*in_len < n_taps) {
|
||||
/* not enough input data, add it to the history because
|
||||
* resubmitting it is not going to make progress.
|
||||
* We copied this into the history above. */
|
||||
remain += refill;
|
||||
*in_len = refill;
|
||||
} else {
|
||||
/* input has enough data to possibly produce more output
|
||||
* from the history so ask to resubmit */
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ static int setup_convert(struct impl *this,
|
|||
this->resample.channels = src_info->info.raw.channels;
|
||||
this->resample.i_rate = src_info->info.raw.rate;
|
||||
this->resample.o_rate = dst_info->info.raw.rate;
|
||||
this->resample.log = this->log;
|
||||
|
||||
if (this->monitor)
|
||||
err = impl_peaks_init(&this->resample);
|
||||
|
|
@ -749,8 +750,8 @@ static int impl_node_process(struct spa_node *node)
|
|||
spa_return_val_if_fail(outio != NULL, -EIO);
|
||||
spa_return_val_if_fail(inio != NULL, -EIO);
|
||||
|
||||
spa_log_trace_fp(this->log, NAME " %p: status %d %d %p",
|
||||
this, inio->status, outio->status, outport->io_control);
|
||||
spa_log_trace_fp(this->log, NAME " %p: status %d %d %d",
|
||||
this, inio->status, outio->status, inio->buffer_id);
|
||||
|
||||
if (outport->io_control)
|
||||
process_control(this, outport, &outport->io_control->sequence);
|
||||
|
|
|
|||
|
|
@ -26,12 +26,14 @@
|
|||
#define RESAMPLE_H
|
||||
|
||||
#include <spa/support/cpu.h>
|
||||
#include <spa/support/log.h>
|
||||
|
||||
struct resample {
|
||||
uint32_t cpu_flags;
|
||||
uint32_t channels;
|
||||
uint32_t i_rate;
|
||||
uint32_t o_rate;
|
||||
struct spa_log *log;
|
||||
|
||||
void (*free) (struct resample *r);
|
||||
void (*update_rate) (struct resample *r, double rate);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue