diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index 9500c5874..c5267221f 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -1053,7 +1053,7 @@ static int impl_node_process_input(void *object) struct stream *impl = object; struct pw_stream *stream = &impl->this; struct spa_io_buffers *io = impl->io; - struct buffer *b; + struct buffer *b = NULL; if (io == NULL) return -EIO; @@ -1072,6 +1072,8 @@ static int impl_node_process_input(void *object) } copy_position(impl, impl->dequeued.incount); + if (b != NULL) + b->this.time = impl->time.now; if (!queue_is_empty(impl, &impl->dequeued)) call_process(impl); diff --git a/src/pipewire/stream.h b/src/pipewire/stream.h index 59e9bf570..3fbbf4c8a 100644 --- a/src/pipewire/stream.h +++ b/src/pipewire/stream.h @@ -203,7 +203,7 @@ enum pw_stream_state { }; /** a buffer structure obtained from pw_stream_dequeue_buffer(). The size of this - * structure can grow as more field are added in the future */ + * structure can grow as more fields are added in the future */ struct pw_buffer { struct spa_buffer *buffer; /**< the spa buffer */ void *user_data; /**< user data attached to the buffer. The user of @@ -213,7 +213,7 @@ struct pw_buffer { * event. The user data is returned unmodified each * time a buffer is dequeued. */ uint64_t size; /**< This field is set by the user and the sum of - * all queued buffer is returned in the time info. + * all queued buffers is returned in the time info. * For audio, it is advised to use the number of * frames in the buffer for this field. */ uint64_t requested; /**< For playback streams, this field contains the @@ -221,6 +221,11 @@ struct pw_buffer { * streams this will be the amount of frames * required by the resampler. This field is 0 * when no suggestion is provided. Since 0.3.49 */ + uint64_t time; /**< For capture streams, this field contains the + * cycle time in nanoseconds when this buffer was + * queued in the stream. It can be compared against + * the pw_time values or pw_stream_get_nsec() + * Since 1.0.5 */ }; struct pw_stream_control {