stream: rename requested to size in pw_time

Now that both the expected input and output of the resampler is placed
in the rate_match, rename the 'requested' field in pw_time to 'size'
and update the docs.

See #3750
This commit is contained in:
Wim Taymans 2024-01-16 15:11:08 +01:00
parent 627f148665
commit a769a014e0
3 changed files with 12 additions and 11 deletions

View file

@ -100,7 +100,7 @@ struct stream {
struct spa_io_buffers *io; struct spa_io_buffers *io;
struct spa_io_rate_match *rate_match; struct spa_io_rate_match *rate_match;
uint32_t rate_queued; uint32_t rate_queued;
uint64_t rate_requested; uint64_t rate_size;
struct { struct {
struct spa_io_position *position; struct spa_io_position *position;
} rt; } rt;
@ -642,7 +642,7 @@ static inline void copy_position(struct stream *impl, int64_t queued)
} }
if (SPA_LIKELY(impl->rate_match != NULL)) { if (SPA_LIKELY(impl->rate_match != NULL)) {
impl->rate_queued = impl->rate_match->delay; impl->rate_queued = impl->rate_match->delay;
impl->rate_requested = impl->rate_match->size; impl->rate_size = impl->rate_match->size;
} }
SPA_SEQ_WRITE(impl->seq); SPA_SEQ_WRITE(impl->seq);
} }
@ -2354,14 +2354,14 @@ int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t
{ {
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
uintptr_t seq1, seq2; uintptr_t seq1, seq2;
uint32_t buffered, quantum, index, requested; uint32_t buffered, quantum, index, rate_size;
int32_t avail_buffers; int32_t avail_buffers;
do { do {
seq1 = SPA_SEQ_READ(impl->seq); seq1 = SPA_SEQ_READ(impl->seq);
memcpy(time, &impl->time, SPA_MIN(size, sizeof(struct pw_time))); memcpy(time, &impl->time, SPA_MIN(size, sizeof(struct pw_time)));
buffered = impl->rate_queued; buffered = impl->rate_queued;
requested = impl->rate_requested; rate_size = impl->rate_size;
quantum = impl->quantum; quantum = impl->quantum;
seq2 = SPA_SEQ_READ(impl->seq); seq2 = SPA_SEQ_READ(impl->seq);
} while (!SPA_SEQ_READ_SUCCESS(seq1, seq2)); } while (!SPA_SEQ_READ_SUCCESS(seq1, seq2));
@ -2382,10 +2382,10 @@ int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t
time->buffered = buffered; time->buffered = buffered;
if (size >= offsetof(struct pw_time, avail_buffers)) if (size >= offsetof(struct pw_time, avail_buffers))
time->queued_buffers = impl->n_buffers - avail_buffers; time->queued_buffers = impl->n_buffers - avail_buffers;
if (size >= offsetof(struct pw_time, requested)) if (size >= offsetof(struct pw_time, size))
time->avail_buffers = avail_buffers; time->avail_buffers = avail_buffers;
if (size >= sizeof(struct pw_time)) if (size >= sizeof(struct pw_time))
time->requested = requested; time->size = rate_size;
pw_log_trace_fp("%p: %"PRIi64" %"PRIi64" %"PRIu64" %d/%d %"PRIu64" %" pw_log_trace_fp("%p: %"PRIi64" %"PRIi64" %"PRIu64" %d/%d %"PRIu64" %"
PRIu64" %"PRIu64" %"PRIu64" %"PRIu64" %d/%d", stream, PRIu64" %"PRIu64" %"PRIu64" %"PRIu64" %d/%d", stream,

View file

@ -332,9 +332,10 @@ struct pw_time {
* Since 0.3.50. */ * Since 0.3.50. */
uint32_t queued_buffers; /**< the number of buffers that are queued. Since 0.3.50 */ uint32_t queued_buffers; /**< the number of buffers that are queued. Since 0.3.50 */
uint32_t avail_buffers; /**< the number of buffers that can be dequeued. Since 0.3.50 */ uint32_t avail_buffers; /**< the number of buffers that can be dequeued. Since 0.3.50 */
uint64_t requested; /**< for audio/raw playback streams, this contains the number of uint64_t size; /**< for audio/raw playback streams, this contains the number of
* samples requested by the resampler to fill the current * samples requested by the resampler for the current
* quantum. Since 1.1.0 */ * quantum. for audio/raw capture streams this will be the number
* of samples available for the current quantum. Since 1.1.0 */
}; };
#include <pipewire/port.h> #include <pipewire/port.h>

View file

@ -932,11 +932,11 @@ static void do_print_delay(void *userdata, uint64_t expirations)
pw_stream_get_time_n(data->stream, &time, sizeof(time)); pw_stream_get_time_n(data->stream, &time, sizeof(time));
printf("stream time: now:%"PRIi64" rate:%u/%u ticks:%"PRIu64 printf("stream time: now:%"PRIi64" rate:%u/%u ticks:%"PRIu64
" delay:%"PRIi64" queued:%"PRIu64 " delay:%"PRIi64" queued:%"PRIu64
" buffered:%"PRIi64" buffers:%u avail:%u req:%"PRIu64"\n", " buffered:%"PRIi64" buffers:%u avail:%u size:%"PRIu64"\n",
time.now, time.now,
time.rate.num, time.rate.denom, time.rate.num, time.rate.denom,
time.ticks, time.delay, time.queued, time.buffered, time.ticks, time.delay, time.queued, time.buffered,
time.queued_buffers, time.avail_buffers, time.requested); time.queued_buffers, time.avail_buffers, time.size);
} }
enum { enum {