mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	stream: report queued and dequeued buffers in pw_time
This commit is contained in:
		
							parent
							
								
									0503ced8ab
								
							
						
					
					
						commit
						5d31ec74ac
					
				
					 3 changed files with 11 additions and 4 deletions
				
			
		| 
						 | 
					@ -2134,7 +2134,7 @@ 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;
 | 
						uint32_t buffered, quantum, index;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	do {
 | 
						do {
 | 
				
			||||||
		seq1 = SEQ_READ(impl->seq);
 | 
							seq1 = SEQ_READ(impl->seq);
 | 
				
			||||||
| 
						 | 
					@ -2153,8 +2153,12 @@ int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t
 | 
				
			||||||
	time->delay += (impl->latency.min_rate + impl->latency.max_rate) / 2;
 | 
						time->delay += (impl->latency.min_rate + impl->latency.max_rate) / 2;
 | 
				
			||||||
	time->delay += ((impl->latency.min_ns + impl->latency.max_ns) / 2) * time->rate.denom / SPA_NSEC_PER_SEC;
 | 
						time->delay += ((impl->latency.min_ns + impl->latency.max_ns) / 2) * time->rate.denom / SPA_NSEC_PER_SEC;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (size >= sizeof(struct pw_time))
 | 
						if (size >= offsetof(struct pw_time, queued_buffers))
 | 
				
			||||||
		time->buffered = buffered;
 | 
							time->buffered = buffered;
 | 
				
			||||||
 | 
						if (size >= offsetof(struct pw_time, avail_buffers))
 | 
				
			||||||
 | 
							time->queued_buffers = spa_ringbuffer_get_read_index(&impl->queued.ring, &index);
 | 
				
			||||||
 | 
						if (size >= sizeof(struct pw_time))
 | 
				
			||||||
 | 
							time->avail_buffers = spa_ringbuffer_get_read_index(&impl->dequeued.ring, &index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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, stream,
 | 
								PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, stream,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -292,6 +292,8 @@ struct pw_time {
 | 
				
			||||||
	uint64_t buffered;		/**< for audio/raw streams, this contains the extra
 | 
						uint64_t buffered;		/**< for audio/raw streams, this contains the extra
 | 
				
			||||||
					  *  number of samples buffered in the resampler.
 | 
										  *  number of samples buffered in the resampler.
 | 
				
			||||||
					  *  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 avail_buffers;		/**< The number of buffers that can be dequeued. Since 0.3.50 */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <pipewire/port.h>
 | 
					#include <pipewire/port.h>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1026,10 +1026,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" \n",
 | 
								" buffered:%"PRIi64" buffers:%u avail:%u\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);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum {
 | 
					enum {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue