mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pulse-server: fix timestamp in latency query
We are supposed to place the current timeofday as the timestamp in the reply.
This commit is contained in:
		
							parent
							
								
									38763da20f
								
							
						
					
					
						commit
						3eca7557f8
					
				
					 1 changed files with 10 additions and 8 deletions
				
			
		| 
						 | 
					@ -166,7 +166,7 @@ struct stream {
 | 
				
			||||||
	uint64_t underrun_for;
 | 
						uint64_t underrun_for;
 | 
				
			||||||
	uint64_t playing_for;
 | 
						uint64_t playing_for;
 | 
				
			||||||
	uint64_t ticks_base;
 | 
						uint64_t ticks_base;
 | 
				
			||||||
	struct timeval timestamp;
 | 
						uint64_t timestamp;
 | 
				
			||||||
	int64_t delay;
 | 
						int64_t delay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint32_t missing;
 | 
						uint32_t missing;
 | 
				
			||||||
| 
						 | 
					@ -428,7 +428,7 @@ static int send_underflow(struct stream *stream, int64_t offset)
 | 
				
			||||||
	struct impl *impl = client->impl;
 | 
						struct impl *impl = client->impl;
 | 
				
			||||||
	struct message *reply;
 | 
						struct message *reply;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ratelimit_test(&impl->rate_limit, SPA_TIMEVAL_TO_NSEC(&stream->timestamp))) {
 | 
						if (ratelimit_test(&impl->rate_limit, stream->timestamp)) {
 | 
				
			||||||
		pw_log_warn(NAME" %p: [%s] UNDERFLOW channel:%u offset:%"PRIi64,
 | 
							pw_log_warn(NAME" %p: [%s] UNDERFLOW channel:%u offset:%"PRIi64,
 | 
				
			||||||
				client, client->name, stream->channel, offset);
 | 
									client, client->name, stream->channel, offset);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -1301,8 +1301,7 @@ do_process_done(struct spa_loop *loop,
 | 
				
			||||||
	uint32_t index;
 | 
						uint32_t index;
 | 
				
			||||||
	int32_t avail;
 | 
						int32_t avail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	stream->timestamp.tv_sec = pd->pwt.now / SPA_NSEC_PER_SEC;
 | 
						stream->timestamp = pd->pwt.now;
 | 
				
			||||||
	stream->timestamp.tv_usec = (pd->pwt.now % SPA_NSEC_PER_SEC) / SPA_NSEC_PER_USEC;
 | 
					 | 
				
			||||||
	if (pd->pwt.rate.denom > 0) {
 | 
						if (pd->pwt.rate.denom > 0) {
 | 
				
			||||||
		stream->delay = pd->pwt.delay * SPA_USEC_PER_SEC / pd->pwt.rate.denom;
 | 
							stream->delay = pd->pwt.delay * SPA_USEC_PER_SEC / pd->pwt.rate.denom;
 | 
				
			||||||
		stream->delay += pd->pwt.queued * SPA_USEC_PER_SEC / stream->ss.rate;
 | 
							stream->delay += pd->pwt.queued * SPA_USEC_PER_SEC / stream->ss.rate;
 | 
				
			||||||
| 
						 | 
					@ -1971,7 +1970,7 @@ static int do_get_playback_latency(struct client *client, uint32_t command, uint
 | 
				
			||||||
	struct impl *impl = client->impl;
 | 
						struct impl *impl = client->impl;
 | 
				
			||||||
	struct message *reply;
 | 
						struct message *reply;
 | 
				
			||||||
	uint32_t channel;
 | 
						uint32_t channel;
 | 
				
			||||||
	struct timeval tv;
 | 
						struct timeval tv, now;
 | 
				
			||||||
	struct stream *stream;
 | 
						struct stream *stream;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1990,6 +1989,8 @@ static int do_get_playback_latency(struct client *client, uint32_t command, uint
 | 
				
			||||||
			stream->read_index, stream->write_index,
 | 
								stream->read_index, stream->write_index,
 | 
				
			||||||
			stream->write_index - stream->read_index, stream->delay);
 | 
								stream->write_index - stream->read_index, stream->delay);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						gettimeofday(&now, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	reply = reply_new(client, tag);
 | 
						reply = reply_new(client, tag);
 | 
				
			||||||
	message_put(reply,
 | 
						message_put(reply,
 | 
				
			||||||
		TAG_USEC, stream->delay,	/* sink latency + queued samples */
 | 
							TAG_USEC, stream->delay,	/* sink latency + queued samples */
 | 
				
			||||||
| 
						 | 
					@ -1997,7 +1998,7 @@ static int do_get_playback_latency(struct client *client, uint32_t command, uint
 | 
				
			||||||
		TAG_BOOLEAN, stream->playing_for > 0 &&
 | 
							TAG_BOOLEAN, stream->playing_for > 0 &&
 | 
				
			||||||
				!stream->corked,	/* playing state */
 | 
									!stream->corked,	/* playing state */
 | 
				
			||||||
		TAG_TIMEVAL, &tv,
 | 
							TAG_TIMEVAL, &tv,
 | 
				
			||||||
		TAG_TIMEVAL, &stream->timestamp,
 | 
							TAG_TIMEVAL, &now,
 | 
				
			||||||
		TAG_S64, stream->write_index,
 | 
							TAG_S64, stream->write_index,
 | 
				
			||||||
		TAG_S64, stream->read_index,
 | 
							TAG_S64, stream->read_index,
 | 
				
			||||||
		TAG_INVALID);
 | 
							TAG_INVALID);
 | 
				
			||||||
| 
						 | 
					@ -2016,7 +2017,7 @@ static int do_get_record_latency(struct client *client, uint32_t command, uint32
 | 
				
			||||||
	struct impl *impl = client->impl;
 | 
						struct impl *impl = client->impl;
 | 
				
			||||||
	struct message *reply;
 | 
						struct message *reply;
 | 
				
			||||||
	uint32_t channel;
 | 
						uint32_t channel;
 | 
				
			||||||
	struct timeval tv;
 | 
						struct timeval tv, now;
 | 
				
			||||||
	struct stream *stream;
 | 
						struct stream *stream;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2031,13 +2032,14 @@ static int do_get_record_latency(struct client *client, uint32_t command, uint32
 | 
				
			||||||
	if (stream == NULL || stream->type != STREAM_TYPE_RECORD)
 | 
						if (stream == NULL || stream->type != STREAM_TYPE_RECORD)
 | 
				
			||||||
		return -ENOENT;
 | 
							return -ENOENT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						gettimeofday(&now, NULL);
 | 
				
			||||||
	reply = reply_new(client, tag);
 | 
						reply = reply_new(client, tag);
 | 
				
			||||||
	message_put(reply,
 | 
						message_put(reply,
 | 
				
			||||||
		TAG_USEC, 0,			/* monitor latency */
 | 
							TAG_USEC, 0,			/* monitor latency */
 | 
				
			||||||
		TAG_USEC, stream->delay,	/* source latency + queued */
 | 
							TAG_USEC, stream->delay,	/* source latency + queued */
 | 
				
			||||||
		TAG_BOOLEAN, !stream->corked,	/* playing state */
 | 
							TAG_BOOLEAN, !stream->corked,	/* playing state */
 | 
				
			||||||
		TAG_TIMEVAL, &tv,
 | 
							TAG_TIMEVAL, &tv,
 | 
				
			||||||
		TAG_TIMEVAL, &stream->timestamp,
 | 
							TAG_TIMEVAL, &now,
 | 
				
			||||||
		TAG_S64, stream->write_index,
 | 
							TAG_S64, stream->write_index,
 | 
				
			||||||
		TAG_S64, stream->read_index,
 | 
							TAG_S64, stream->read_index,
 | 
				
			||||||
		TAG_INVALID);
 | 
							TAG_INVALID);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue