mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	stream: fix writable size when no timing info received
Always report that we can write a buffer, even when we have not yet received timing info. Fixes stalled spotify. Fixes #238
This commit is contained in:
		
							parent
							
								
									653ae96b20
								
							
						
					
					
						commit
						df8ad59e37
					
				
					 1 changed files with 7 additions and 6 deletions
				
			
		| 
						 | 
					@ -1335,14 +1335,15 @@ size_t pa_stream_writable_size(PA_CONST pa_stream *s)
 | 
				
			||||||
	PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direction != PA_STREAM_RECORD,
 | 
						PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direction != PA_STREAM_RECORD,
 | 
				
			||||||
			PA_ERR_BADSTATE, (size_t) -1);
 | 
								PA_ERR_BADSTATE, (size_t) -1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!s->have_time)
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	i = &s->timing_info;
 | 
						i = &s->timing_info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	clock_gettime(CLOCK_MONOTONIC, &ts);
 | 
						if (s->have_time) {
 | 
				
			||||||
	now = SPA_TIMESPEC_TO_USEC(&ts);
 | 
							clock_gettime(CLOCK_MONOTONIC, &ts);
 | 
				
			||||||
	elapsed = pa_usec_to_bytes(now - SPA_TIMEVAL_TO_USEC(&i->timestamp), &s->sample_spec);
 | 
							now = SPA_TIMESPEC_TO_USEC(&ts);
 | 
				
			||||||
 | 
							elapsed = pa_usec_to_bytes(now - SPA_TIMEVAL_TO_USEC(&i->timestamp), &s->sample_spec);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							elapsed = 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	queued = i->write_index - SPA_MIN(i->read_index, i->write_index);
 | 
						queued = i->write_index - SPA_MIN(i->read_index, i->write_index);
 | 
				
			||||||
	queued -= SPA_MIN(queued, elapsed);
 | 
						queued -= SPA_MIN(queued, elapsed);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue