mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	stream: Support extended API with PULSE_LATENCY_MSEC if possible
This only works in the single-format case (i.e. we know the format up-front and we're not negotiating).
This commit is contained in:
		
							parent
							
								
									a1c4a6916f
								
							
						
					
					
						commit
						5adb126259
					
				
					 1 changed files with 9 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -987,6 +987,14 @@ static void patch_buffer_attr(pa_stream *s, pa_buffer_attr *attr, pa_stream_flag
 | 
			
		|||
 | 
			
		||||
    if ((e = getenv("PULSE_LATENCY_MSEC"))) {
 | 
			
		||||
        uint32_t ms;
 | 
			
		||||
        pa_sample_spec ss;
 | 
			
		||||
 | 
			
		||||
        pa_sample_spec_init(&ss);
 | 
			
		||||
 | 
			
		||||
        if (pa_sample_spec_valid(&s->sample_spec))
 | 
			
		||||
            ss = s->sample_spec;
 | 
			
		||||
        else if (s->n_formats == 1)
 | 
			
		||||
            pa_format_info_to_sample_spec(s->req_formats[0], &ss, NULL);
 | 
			
		||||
 | 
			
		||||
        if (pa_atou(e, &ms) < 0 || ms <= 0)
 | 
			
		||||
            pa_log_debug("Failed to parse $PULSE_LATENCY_MSEC: %s", e);
 | 
			
		||||
| 
						 | 
				
			
			@ -994,7 +1002,7 @@ static void patch_buffer_attr(pa_stream *s, pa_buffer_attr *attr, pa_stream_flag
 | 
			
		|||
            pa_log_debug("Ignoring $PULSE_LATENCY_MSEC: %s (invalid sample spec)", e);
 | 
			
		||||
        else {
 | 
			
		||||
            attr->maxlength = (uint32_t) -1;
 | 
			
		||||
            attr->tlength = pa_usec_to_bytes(ms * PA_USEC_PER_MSEC, &s->sample_spec);
 | 
			
		||||
            attr->tlength = pa_usec_to_bytes(ms * PA_USEC_PER_MSEC, &ss);
 | 
			
		||||
            attr->minreq = (uint32_t) -1;
 | 
			
		||||
            attr->prebuf = (uint32_t) -1;
 | 
			
		||||
            attr->fragsize = attr->tlength;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue