mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-11 13:30:07 -05:00
stream: add time field to pw_buffer
For capture streams, place the time of the cycle when we received this buffer in the new buffer time field. Without this (and without timestamps in an optional header metadata) it's impossible to determine when a buffer was created. With this field and the pw_stream_get_time_n() and pw_stream_get_nsec() we can derive the mapping to ticks and delay in the graph.
This commit is contained in:
parent
46e6fd2ae4
commit
f0dcdf4d31
2 changed files with 10 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue